procesView.js 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796
  1. $(document).ready(function() {
  2. var procesy = {};
  3. var res = {};
  4. var state = [];
  5. var panels = true;
  6. var menuShow = false;
  7. var sTimeout = false;
  8. $("#SE-menu").hide();
  9. $("#SE-menu-sub").hide();
  10. function translate(objId, arr) {
  11. var data = [];
  12. $.each(arr[objId]["childs"], function(indexChilds, childs) {
  13. var temp = {};
  14. var id = childs["ID"];
  15. var style = "";
  16. switch (arr[id]["TYPE"]) {
  17. case "PROCES_INIT":
  18. style = 'style="background-color:#ffe5e5;color:#333"';
  19. break;
  20. case "PROCES":
  21. style = 'style="background-color:#ededed;color:#333"';
  22. break;
  23. case "PROCES_GROUP_1":
  24. style = 'style="background-color:#9999cc;color:#fff"';
  25. break;
  26. case "PROCES_GROUP_2":
  27. style = 'style="background-color:#d8d8b2;color:#fff"';
  28. break;
  29. default:
  30. style = 'style="background-color:#ededed;color:#333"';
  31. break;
  32. }
  33. temp["id"] = id;
  34. if(TYPE == "childs")
  35. temp["type"] = "proces";
  36. else
  37. if(arr[id]["TYPE"] == "STANOWISKO" || arr[id]["TYPE"] == "DZIAL" || arr[id]["TYPE"] == "PODMIOT")
  38. temp["type"] = "stanowiska";
  39. else
  40. temp["type"] = "zasoby";
  41. temp["text"] = "<span class=detailsTable2 " + style + " >" + id + "</span> " + arr[id]["DESC"];
  42. temp["parent"] = arr[id]["PARENT_ID"];
  43. data.push(temp);
  44. //console.log(data);
  45. $.merge(data, translate(id, arr));
  46. });
  47. return data;
  48. }
  49. $(document).on('keyup', '#search', function(e) {
  50. if (sTimeout) {
  51. clearTimeout(sTimeout);
  52. }
  53. sTimeout = setTimeout(function() {
  54. var val = $('#search').val();
  55. $('#tree').jstree(true).search(val, false);
  56. }, 250);
  57. });
  58. function customMenu(node) {
  59. var tree = $("#tree").jstree(true);
  60. var id = node.id;
  61. var items = {};
  62. if (node.type === "proces")
  63. items = {
  64. "ProcesEditor": {
  65. "separator_before": false,
  66. "separator_after": false,
  67. "label": "Edytor procesów",
  68. "action": function(obj) {
  69. window.location = BASE_URL + 'index.php?_route=UrlAction_procesEditor&id=' + id;
  70. }
  71. },
  72. "EditProces": {
  73. "separator_before": false,
  74. "separator_after": false,
  75. "label": "Edytuj proces",
  76. "action": function(obj) {
  77. window.location = BASE_URL + 'index.php?_route=ViewTableAjax&typeName=p5_default_db:CRM_PROCES#EDIT/' + id;
  78. }
  79. },
  80. "AddPytania": {
  81. "separator_before": false,
  82. "separator_after": true,
  83. "label": "Edytuj pytania",
  84. "action": function(obj) {
  85. window.location = BASE_URL + 'procesy5.php?task=CRM_TESTY_ADD_PYTANIA&id_proces=' + id;
  86. }
  87. },
  88. "ProcesMap": {
  89. "separator_before": false,
  90. "separator_after": false,
  91. "label": "Mapa procesu",
  92. "action": function(obj) {
  93. window.location = BASE_URL + 'index.php?FUNCTION_INIT=GRAPH_VIEW_PROCES&PROCES_INIT_SCAN=1&id_proces=' + id;
  94. }
  95. },
  96. "ListView": {
  97. "separator_before": false,
  98. "separator_after": false,
  99. "label": "Widok listy",
  100. "action": function(obj) {
  101. window.location = BASE_URL + 'procesy5.php?task=PROCES_VIEW_LIST&HIDE_PANEL=0&show_big_img=1&group_stanowiska=1&id_proces=' + id;
  102. }
  103. },
  104. "AddResource": {
  105. "separator_before": true,
  106. "separator_after": false,
  107. "label": "Dodaj zasób",
  108. "action": function(obj) {
  109. window.location = BASE_URL + 'index.php?MENU_INIT=PROCES_ADD_ZASOB&task=CRM_PROCES&procesID=' + id;
  110. }
  111. },
  112. "AddChild": {
  113. "separator_before": false,
  114. "separator_after": false,
  115. "label": "Dodaj dziecko",
  116. "action": function(obj) {
  117. window.location = BASE_URL + 'index.php?_route=ViewTableAjax&typeName=p5_default_db:CRM_PROCES&ff_PARENT_ID=' + id + '#CREATE';
  118. }
  119. },
  120. "ShowWsk": {
  121. "separator_before": true,
  122. "separator_after": false,
  123. "label": "Pokaż powiązane zasoby",
  124. "action": function(obj) {
  125. node = { id:"res"+id, text:"Zasoby"};
  126. $('#tree').jstree('create_node', id, node, 'first');
  127. var node = { id:"prof"+id,text:"Stanowiska"};
  128. $('#tree').jstree('create_node', id, node, 'first');
  129. var link = BASE_URL + "index.php?_route=UrlAction_ProcesView&_task=getDetailsAjax&id=" + id;
  130. $.get(link, function(data){
  131. var isProf = false;
  132. var isRes = false;
  133. $.each(data["wsk"], function(i, e){
  134. //console.log(e);
  135. var idX = e["ID_ZASOB"];
  136. var node = { id:"wsk"+e["ID"],text: "["+e["ID_ZASOB"]+"] " + res[idX]["DESC"]};
  137. if(res[idX]["TYPE"] == "STANOWISKO" || res[idX]["TYPE"] == "DZIAL" || res[idX]["TYPE"] == "PODMIOT"){
  138. node["type"] = "stanowiska";
  139. isProf = true;
  140. $('#tree').jstree('create_node', "prof"+id, node, 'first');
  141. }else{
  142. node["type"] = "zasoby";
  143. isRes = false;
  144. $('#tree').jstree('create_node', "res"+id, node, 'first');
  145. }
  146. });
  147. if(!isProf)
  148. $("#tree").jstree('rename_node', "prof"+id , "Stanowiska <b style=color:red>[BRAK]</b>" );
  149. if(!isRes)
  150. $("#tree").jstree('rename_node', "res"+id , "Zasoby <b style=color:red>[BRAK]</b>" );
  151. $("#tree").jstree("open_node", id);
  152. $("#tree").jstree("open_node", "res"+id);
  153. $("#tree").jstree("open_node", "prof"+id);
  154. })
  155. }
  156. },
  157. };
  158. if (node.type === "zasoby" || node.type === "stanowiska")
  159. items = {
  160. "Edit": {
  161. "separator_before": false,
  162. "separator_after": true,
  163. "label": "Edytuj zasób",
  164. "action": function(obj) {
  165. var zId = id.replace("wsk", "");
  166. window.location = BASE_URL + 'index.php?_route=ViewTableAjax&typeName=p5_default_db:CRM_LISTA_ZASOBOW#EDIT/' + zId;
  167. }
  168. },
  169. };
  170. return items;
  171. }
  172. function renderTree() {
  173. // jQuery.jstree.defaults.core.themes.responsive = true;
  174. $('#view').empty();
  175. $("#view").append("<input id=search type=next class=form-control>")
  176. $('#view').append("<div id=tree></div>");
  177. $('#tree').jstree({
  178. "core": {
  179. "animation": 0,
  180. "check_callback": true,
  181. "themes": {
  182. "stripes": false,
  183. "dots": false
  184. },
  185. 'data': (TYPE == "childs" ? translate(0, procesy) : translate(0, res))
  186. },
  187. "types": {
  188. "default": {
  189. "icon": "glyphicon glyphicon-folder-open",
  190. },
  191. "proces": {
  192. "icon": "glyphicon glyphicon-file",
  193. },
  194. "stanowiska": {
  195. "icon": "glyphicon glyphicon glyphicon-user",
  196. },
  197. "zasoby": {
  198. "icon": "glyphicon glyphicon glyphicon-hdd",
  199. },
  200. },
  201. "plugins": [
  202. "contextmenu", "search",
  203. "types"
  204. ],
  205. "search": {
  206. // search config
  207. "show_only_matches": true,
  208. },
  209. "contextmenu": {
  210. "items": customMenu
  211. }
  212. });
  213. }
  214. function renderPanels() {
  215. $("#view").html("<div id=ulproc><div id=procCon><div class=clearfix></div></div></div>");
  216. //console.log(procesy);
  217. if (localStorage.getItem(TYPE) !== null) {
  218. var arr = JSON.parse( localStorage.getItem(TYPE) );
  219. $.each(arr, function(i, e){
  220. createPanel(e["ID"], i, e["TYPE"]);
  221. });
  222. }else{
  223. createPanel(START_ID, 0, TYPE);
  224. }
  225. }
  226. function createPanel(id, depth, type) {
  227. state.splice(depth);
  228. var temp = {};
  229. temp["ID"] = id;
  230. var inherit = $("#depth" + (depth - 1)).data("type");
  231. if ("connect" == inherit)
  232. inherit = "childs";
  233. if ("aliasChilds" == inherit)
  234. inherit = "res";
  235. if ("gotoChilds" == inherit)
  236. inherit = "childs";
  237. if (type == "inherit")
  238. type = inherit;
  239. if (type == "childs" && procesy[id]["childs"].length == 0)
  240. type = "details";
  241. if (type == "alias")
  242. type = "detailsRes";
  243. if (type == "res" && res[id]["childs"].length == 0)
  244. type = "detailsRes";
  245. temp["TYPE"] = type;
  246. temp["FOCUS"] = 0;
  247. state[depth] = temp;
  248. if(depth > 0)
  249. state[depth-1]["FOCUS"] = id;
  250. //console.log(state);
  251. renderPanel(depth);
  252. }
  253. function renderPanel(depth) {
  254. var type = state[depth]["TYPE"];
  255. var id = state[depth]["ID"];
  256. var link = BASE_URL + "index.php?_route=UrlAction_ProcesView&_task=getDetailsAjax&id=" + id;
  257. if ("connect" == type)
  258. link = BASE_URL + "index.php?_route=UrlAction_ProcesView&_task=getConnectedProcAjax&id=" + id;
  259. $("#depth" + (depth - 1)).nextAll(".singleAdv").remove();
  260. var target = $("<div class=singleAdv data-depth=" + depth + " id=depth" + depth + " data-parent=" + id + " data-type=" + type + " ></div>");
  261. target.appendTo("#procCon");
  262. $("#procCon").css("width", depth * 460 + 460);
  263. $("#ulproc").scrollLeft(depth * 460 + 460);
  264. $.get(link, function(exp) {
  265. //console.log(procesy);
  266. //console.log(next);
  267. var result = "";
  268. result += "<li ";
  269. if(id != 0){
  270. if("childs" == type || "goto" == type || "details" == type)
  271. result += "data-opis='" + procesy[id]["OPIS"] + "' data-desc='" + procesy[id]["DESC"] + "' data-id=" + id + " ";
  272. else
  273. result += "data-opis='" + res[id]["OPIS"] + "' data-desc='" + res[id]["DESC"] + "' data-id=" + id + " ";
  274. }
  275. if ("childs" == type)
  276. result += "class='list-group-item disabled-item normalChilds'>" + (id == 0 ? "Procesy" : "{" + id + "} Procesy podrzędne");
  277. if ("details" == type)
  278. result += "class='list-group-item disabled-item normalChilds '>{" + id + "} Szczegóły";
  279. if ("res" == type || "alias" == type)
  280. result += "class='list-group-item disabled-item normalChilds'>" + (id == 0 ? "Zasoby" : "[" + id + "] Zasoby podrzędne");
  281. if ("detailsRes" == type)
  282. result += "class='list-group-item disabled-item normalChilds'>[" + id + "] Szczegóły";
  283. if ("goto" == type)
  284. result += "class='list-group-item disabled-item normalChilds'>{" + id + "} Procesy podrzędne";
  285. if ("connect" == type)
  286. result += "class='list-group-item disabled-item normalChilds'>[" + id + "] Procesy powiązane";
  287. if(id != 0 && "connect" != type){
  288. result += "<div style=float:right;><div class='dropdown '>";
  289. if ("goto" == type || "details" == type || "childs" == type) {
  290. result += "<span class='glyph glyphicon glyphicon glyphicon-menu-hamburger dropdown-toggle' data-toggle='dropdown' aria-haspopup='true' aria-expanded='true' id='dropdownMenuP" + procesy[id]["ID"] + "'></span>";
  291. result += '<ul class="dropdown-menu dropdown-menu-right" style=z-index:100 aria-labelledby="dropdownMenuP' + procesy[id]["ID"] + '">';
  292. }
  293. if ("res" == type || "alias" == type || "connect" == type || "detailsRes" == type) {
  294. result += "<span class='glyph glyphicon glyphicon glyphicon-menu-hamburger dropdown-toggle' data-toggle='dropdown' aria-haspopup='true' aria-expanded='true' id='dropdownMenuR" + res[id]["ID"] + "'></span>";
  295. result += '<ul class="dropdown-menu dropdown-menu-right" style=z-index:100 aria-labelledby="dropdownMenuR' + res[id]["ID"] + '">';
  296. }
  297. if("detailsRes" != type && "details" != type)
  298. result += '<li><a href="" class=details>Szczegóły</a></li>';
  299. if ("goto" == type || "details" == type || "childs" == type) {
  300. data = procesy[id];
  301. result += '<li><a href="' + BASE_URL + 'index.php?_route=UrlAction_procesEditor&id=' + data["ID"] + '">Edytor procesu</a></li>';
  302. result += '<li><a href="' + BASE_URL + 'index.php?_route=ViewTableAjax&typeName=p5_default_db:CRM_PROCES#EDIT/' + data["ID"] + '">Edytuj proces</a></li>';
  303. result += '<li><a href="' + BASE_URL + 'index.php?MENU_INIT=PROCES_ADD_ZASOB&task=CRM_PROCES&procesID=' + data["ID"] + '">Dodaj zasób</a></li>';
  304. result += '<li><a href="' + BASE_URL + 'procesy5.php?task=CRM_TESTY_ADD_PYTANIA&id_proces=' + data["ID"] + '">Edytuj Pytania</a></li>';
  305. result += '<li><a href="' + BASE_URL + 'index.php?FUNCTION_INIT=GRAPH_VIEW_PROCES&PROCES_INIT_SCAN=1&id_proces=' + data["ID"] + '">Mapa procesu</a></li>';
  306. result += '<li><a href="' + BASE_URL + 'procesy5.php?task=PROCES_VIEW_LIST&HIDE_PANEL=0&show_big_img=1&group_stanowiska=1&id_proces=' + data["ID"] + '">Widok listy</a></li>';
  307. result += '<li><a href="' + BASE_URL + 'index.php?_route=ViewTableAjax&typeName=p5_default_db:CRM_PROCES&ff_PARENT_ID=' + data["ID"] + '#CREATE">Dodaj dziecko</a></li>';
  308. }
  309. if ("res" == type || "alias" == type || "connect" == type || "detailsRes" == type) {
  310. data = res[id];
  311. result += '<li><a href="' + BASE_URL + 'index.php?_route=ViewTableAjax&typeName=p5_default_db:CRM_LISTA_ZASOBOW#EDIT/' + data["ID"] + '">Edytuj zasób</a></li>';
  312. result += '<li><a href="" class=connect>Procesy powiązane</a></li>';
  313. }
  314. result += '</ul>';
  315. result += "</div><div>";
  316. }
  317. result += "</li>";
  318. result += "<ul class='singleAdvList list-group' style=margin-bottom:0px;>";
  319. if (("details" == type && "res" != $("#depth" + (depth - 1)).data("type"))) {
  320. result += getDetails(procesy[id], exp, "proces");
  321. }
  322. if (("details" == type && "res" == $("#depth" + (depth - 1)).data("type")) || "detailsRes" == type) {
  323. result += getDetails(res[id], exp, "res");
  324. }
  325. if ("childs" == type || "gotoChilds" == type) {
  326. if (procesy[id]["childs"].length > 0) {
  327. $.each(procesy[id]["childs"], function(i, e) {
  328. result += getView(procesy[e["ID"]], false, "proces", depth);
  329. });
  330. } else {
  331. result += getDetails(procesy[id], exp, "proces");
  332. }
  333. }
  334. if ("goto" == type) {
  335. result += getDetails(procesy[id], exp);
  336. }
  337. if ("connect" == type) {
  338. if (exp["wsk"].length > 0) {
  339. $.each(exp["wsk"], function(i, e) {
  340. result += getView(procesy[e["ID_PROCES"]], false, "childs", depth);
  341. });
  342. } else {
  343. result += "<li class='list-group-item disabled-item list-group-item-danger'>Brak procesów powiązanych.</li>";
  344. }
  345. }
  346. if ("res" == type || "aliasChilds" == type) {
  347. if (res[id]["childs"].length > 0) {
  348. $.each(res[id]["childs"], function(i, e) {
  349. result += getView(res[e["ID"]], false, "res", depth);
  350. });
  351. } else {
  352. result += getDetails(res[id], exp);
  353. }
  354. }
  355. if ("alias" == type) {
  356. result += getDetails(res[id], exp);
  357. }
  358. result += "</ul></div>";
  359. $("#ulproc").scrollTop(0);
  360. target.html(result);
  361. $(".singleAdvList").css("height", $(window).height() - 200 + "px");
  362. });
  363. //console.log(result);
  364. localStorage.setItem( TYPE, JSON.stringify(state) );
  365. }
  366. function render() {
  367. if (panels) {
  368. //console.log("panels");
  369. renderPanels();
  370. } else {
  371. //console.log("drzewo");
  372. renderTree();
  373. }
  374. }
  375. function updateParent(id, parent, item) {
  376. var link = BASE_URL + 'wfs-data.php/default_db/?SERVICE=WFS&VERSION=1.0.0&SRSNAME=EPSG:3003&';
  377. var req = `
  378. <Transaction
  379. xmlns="http://www.opengis.net/wfs"
  380. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  381. version="1.0.0"
  382. service="WFS"
  383. xmlns:p5_default_db="` + BASE_URL + `wfs/default_db/CRM_PROCES"
  384. xsi:schemaLocation="` + BASE_URL + `wfs/default_db/CRM_PROCES ` + BASE_URL + `dev-pl/se-feature-api/wfs.php/xml/wfs/default_db/CRM_PROCES/?SERVICE=WFS&amp;VERSION=1.0.0&amp;REQUEST=DescribeFeatureType&amp;TYPENAME=p5_default_db:CRM_PROCES&amp;SRSNAME=EPSG:4326&amp;"
  385. xmlns:gml="http://www.opengis.net/gml">
  386. <Insert xmlns="http://www.opengis.net/wfs">
  387. <CRM_PROCES xmlns="` + BASE_URL + `wfs/default_db/CRM_PROCES">
  388. <ID xmlns="` + BASE_URL + `wfs/default_db/CRM_PROCES">` + id + `</ID>
  389. <PARENT_ID xmlns="` + BASE_URL + `wfs/default_db/CRM_PROCES">` + parent + `</PARENT_ID>
  390. </CRM_PROCES>
  391. </Insert>
  392. </Transaction>`;
  393. //console.log(req);
  394. $.ajax({
  395. url: link,
  396. data: req,
  397. type: 'POST',
  398. contentType: "text/xml",
  399. dataType: "text",
  400. success: function(data) {
  401. return true;
  402. },
  403. error: function(xhr, ajaxOptions, thrownError) {
  404. $(item).sortable('cancel');
  405. $.notify("Brak połączenia z bazą danych", "error");
  406. }
  407. });
  408. }
  409. $(document).on("click", ".toggleRoute", function(){
  410. var obj = $(this).closest(".singleAdv");
  411. var id = $(obj).data("parent");
  412. var type = $(obj).data("type");
  413. if($(this).data("state") == 0){
  414. $(this).data("state", 1);
  415. $(this).text("UKRYJ ŚCIEŻKĘ");
  416. $(this).parent().find(".route").html("<ul style=list-style:none;padding-left:0px;>"+showTree(id, type, 0)+"</ul>");
  417. var depth = 0;
  418. $(this).parent().find(".route").find("li").each(function(){
  419. $(this).css("padding-left", depth);
  420. depth += 16;
  421. });
  422. $(this).parent().find(".route").show();
  423. }else{
  424. $(this).data("state", 0);
  425. $(this).text("POKAŻ ŚCIEŻKĘ");
  426. $(this).parent().find(".route").hide();
  427. $(this).parent().find(".route").html("");
  428. }
  429. });
  430. function showTree(id, type, count) {
  431. //console.log(count);
  432. if(id == "#" || count >= 100)
  433. return "";
  434. if(type == "detailsRes" || type == "alias")
  435. if(typeof res[id]["DESC"] != "undefined")
  436. return showTree(res[id]["PARENT_ID"], "detailsRes", count+1)+"<li style=padding-left:0px;><span class='glyphicon glyphicon-arrow-right'></span> " + res[id]["DESC"] + "</li>";
  437. else
  438. return "";
  439. else
  440. if(typeof procesy[id]["DESC"] != "undefined")
  441. return showTree(procesy[id]["PARENT_ID"], "detailsProc", count+1)+"<li style=padding-left:0px;><span class='glyphicon glyphicon-arrow-right'></span> " + procesy[id]["DESC"] + "</li>";
  442. else
  443. return "";
  444. }
  445. function getDetails(e, data, type) {
  446. //console.log("test", e);
  447. var result = "";
  448. if(type == "proces")
  449. result += '<div class="panel panel-info" style=margin-bottom:0px;>';
  450. else
  451. result += '<div class="panel panel-success" style=margin-bottom:0px;>';
  452. result += '<div class="panel-heading"><h3 class="panel-title">' + e["DESC"] + '</h3></div>';
  453. result += '<div class="panel-body pbody">';
  454. result += e["OPIS"];
  455. result += '<div class=toggleRoute data-state=0>POKAŻ ŚCIEŻKĘ</div>';
  456. result += '<div class=route></div>';
  457. result += '</div>';
  458. result += '</div>';
  459. if (data["wsk"].length > 0 && type == "proces") {
  460. result += "<li class='list-group-item disabled-item list-group-item-success'>Zasoby powiązane</li>";
  461. result += "<ul class='singleAdvList list-group' list-group' style=margin-bottom:0px;>";
  462. $.each(data["wsk"], function(i, e) {
  463. id = e["ID_ZASOB"];
  464. if (typeof res[id] !== "undefined") {
  465. result += "<li class='list-group-item liProc wsk'";
  466. result += "data-opis='" + res[id]["OPIS"] + "' data-desc='" + res[id]["DESC"] + "' data-id=" + res[id]["ID"] + " >";
  467. result += '<div class="textTable">';
  468. result += "<span class=detailsTable>" + res[id]["ID"] + "</span> ";
  469. result += res[id]["DESC"];
  470. result += "</div>"
  471. result += "<div style=float:right;><span class='glyph glyphicon gl glyphicon-triangle-right'></span>";
  472. result += "<div class='dropdown '>";
  473. result += "<span class='glyph glyphicon glyphicon glyphicon-menu-hamburger dropdown-toggle' data-toggle='dropdown' aria-haspopup='true' aria-expanded='true' id='dropdownMenu" + res[id]["ID"] + "'></span>";
  474. result += '<ul class="dropdown-menu dropdown-menu-right" style=z-index:100 aria-labelledby="dropdownMenu' + res[id]["ID"] + '">';
  475. result += '<li><a href="" class=details>Szczegóły</a></li>';
  476. result += '</ul>';
  477. result += "</div>";
  478. result += '</div><div class=clearfix></div></li>';
  479. }
  480. });
  481. result += "</ul>";
  482. }
  483. return result;
  484. }
  485. $(document).on("click", ".goto", function() {
  486. $(this).parents(".singleAdv").find(".active").removeClass("active");
  487. $(this).parents(".singleAdv").find(".list-group-item-info").removeClass("list-group-item-info");
  488. $(this).addClass("list-group-item-info");
  489. var parent_id = $(this).data("id");
  490. var id = procesy[parent_id]["ID"];
  491. var depth = $(this).closest(".singleAdv").data("depth") + 1;
  492. createPanel(id, depth, "goto");
  493. return false;
  494. });
  495. $(document).on("click", ".alias", function() {
  496. $(this).parents(".singleAdv").find(".active").removeClass("active");
  497. $(this).parents(".singleAdv").find(".list-group-item-info").removeClass("list-group-item-info");
  498. $(this).addClass("list-group-item-info");
  499. var parent_id = $(this).data("id");
  500. var id = res[parent_id]["ID"];
  501. var depth = $(this).closest(".singleAdv").data("depth") + 1;
  502. createPanel(id, depth, "alias");
  503. return false;
  504. });
  505. function getView(data, active, type, depth) {
  506. var result = "";
  507. var style = "";
  508. switch (data["TYPE"]) {
  509. case "PROCES_INIT":
  510. style = 'style="background-color:#ffe5e5;color:#333"';
  511. break;
  512. case "PROCES":
  513. style = 'style="background-color:#ededed;color:#333"';
  514. break;
  515. case "PROCES_GROUP_1":
  516. style = 'style="background-color:#9999cc;color:#fff"';
  517. break;
  518. case "PROCES_GROUP_2":
  519. style = 'style="background-color:#d8d8b2;color:#fff"';
  520. break;
  521. default:
  522. style = 'style="background-color:#ededed;color:#333"';
  523. break;
  524. }
  525. result += "<li class='list-group-item liProc " + (state[depth]["FOCUS"] == data["ID"] ? "active" : "") + "'; ";
  526. result += "data-opis='" + data["OPIS"] + "' data-desc='" + data["DESC"] + "' data-id=" + data["ID"] + " >";
  527. result += '<div class="textTable">'
  528. result += "<span class=detailsTable " + style + ">" + data["ID"] + "</span> "
  529. result += data["DESC"];
  530. result += "</div>"
  531. result += "<div style=float:right;><span class='glyph glyphicon gl glyphicon-triangle-right'></span>";
  532. result += "<div class='dropdown '>";
  533. result += "<span class='glyph glyphicon glyphicon glyphicon-menu-hamburger dropdown-toggle' data-toggle='dropdown' aria-haspopup='true' aria-expanded='true' id='dropdownMenu" + data["ID"] + "'></span>";
  534. result += '<ul class="dropdown-menu dropdown-menu-right" style=z-index:100 aria-labelledby="dropdownMenu' + data["ID"] + '">';
  535. if ("proces" == type) {
  536. result += '<li><a href="' + BASE_URL + 'index.php?_route=UrlAction_procesEditor&id=' + data["ID"] + '">Edytor procesu</a></li>';
  537. result += '<li><a href="' + BASE_URL + 'index.php?_route=ViewTableAjax&typeName=p5_default_db:CRM_PROCES#EDIT/' + data["ID"] + '">Edytuj proces</a></li>';
  538. result += '<li><a href="' + BASE_URL + 'index.php?MENU_INIT=PROCES_ADD_ZASOB&task=CRM_PROCES&procesID=' + data["ID"] + '">Dodaj zasób</a></li>';
  539. result += '<li><a href="' + BASE_URL + 'procesy5.php?task=CRM_TESTY_ADD_PYTANIA&id_proces=' + data["ID"] + '">Edytuj Pytania</a></li>';
  540. result += '<li><a href="' + BASE_URL + 'index.php?FUNCTION_INIT=GRAPH_VIEW_PROCES&PROCES_INIT_SCAN=1&id_proces=' + data["ID"] + '">Mapa procesu</a></li>';
  541. result += '<li><a href="' + BASE_URL + 'procesy5.php?task=PROCES_VIEW_LIST&HIDE_PANEL=0&show_big_img=1&group_stanowiska=1&id_proces=' + data["ID"] + '">Widok listy</a></li>';
  542. result += '<li><a href="' + BASE_URL + 'index.php?_route=ViewTableAjax&typeName=p5_default_db:CRM_PROCES&ff_PARENT_ID=' + data["ID"] + '#CREATE">Dodaj dziecko</a></li>';
  543. }
  544. if ("res" == type) {
  545. result += '<li><a href="' + BASE_URL + 'index.php?_route=ViewTableAjax&typeName=p5_default_db:CRM_LISTA_ZASOBOW#EDIT/' + data["ID"] + '">Edytuj zasób</a></li>';
  546. result += '<li><a href="" class=connect>Procesy powiązane</a></li>';
  547. }
  548. //result += '<li><a href="'+BASE_URL+''+$(this).find("ID").text()+'">Widok listy</a></li>';
  549. result += '<li><a href="" class=details>Szczegóły</a></li>';
  550. result += '</ul>';
  551. result += "</div>";
  552. result += '</div><div class=clearfix></div></li>';
  553. if (data["IF_TRUE_GOTO"] != 0 && type == "proces") {
  554. var goto = data["IF_TRUE_GOTO_FLAG"];
  555. var id = data["IF_TRUE_GOTO"];
  556. data = procesy[id];
  557. result += "<li class='list-group-item goto " + (state[depth]["FOCUS"] == data["ID"] ? "list-group-item-info" : "") + "'; ";
  558. result += "data-opis='" + data["OPIS"] + "' data-desc='" + data["DESC"] + "' data-id=" + data["ID"] + " style=border-top-style:none;>";
  559. result += "";
  560. result += '<div class="textTable">'
  561. result += "<span class=gotoInfo><span class='glyphicon glyphicon-arrow-right'></span> " + goto + " </span><span class=gotoWay>" + data["ID"] + "</span>";
  562. result += "</div>"
  563. result += "<div style=float:right;><span class='glyph glyphicon gl glyphicon-triangle-right'></span>";
  564. result += "<div class='dropdown '>";
  565. result += "<span class='glyph glyphicon glyphicon glyphicon-menu-hamburger dropdown-toggle' data-toggle='dropdown' aria-haspopup='true' aria-expanded='true' id='dropdownMenu" + data["ID"] + "'></span>";
  566. result += '<ul class="dropdown-menu dropdown-menu-right" style=z-index:100 aria-labelledby="dropdownMenu' + data["ID"] + '">';
  567. result += '<li><a href="' + BASE_URL + 'index.php?_route=UrlAction_procesEditor&id=' + data["ID"] + '">Edytor procesu</a></li>';
  568. result += '<li><a href="' + BASE_URL + 'index.php?_route=ViewTableAjax&typeName=p5_default_db:CRM_PROCES#EDIT/' + data["ID"] + '">Edytuj proces</a></li>';
  569. result += '<li><a href="' + BASE_URL + 'index.php?MENU_INIT=PROCES_ADD_ZASOB&task=CRM_PROCES&procesID=' + data["ID"] + '">Dodaj zasób</a></li>';
  570. result += '<li><a href="' + BASE_URL + 'procesy5.php?task=CRM_TESTY_ADD_PYTANIA&id_proces=' + data["ID"] + '">Edytuj Pytania</a></li>';
  571. result += '<li><a href="' + BASE_URL + 'index.php?FUNCTION_INIT=GRAPH_VIEW_PROCES&PROCES_INIT_SCAN=1&id_proces=' + data["ID"] + '">Mapa procesu</a></li>';
  572. result += '<li><a href="' + BASE_URL + 'procesy5.php?task=PROCES_VIEW_LIST&HIDE_PANEL=0&show_big_img=1&group_stanowiska=1&id_proces=' + data["ID"] + '">Widok listy</a></li>';
  573. result += '<li><a href="' + BASE_URL + 'index.php?_route=ViewTableAjax&typeName=p5_default_db:CRM_PROCES&ff_PARENT_ID=' + data["ID"] + '#CREATE">Dodaj dziecko</a></li>';
  574. //result += '<li><a href="'+BASE_URL+''+$(this).find("ID").text()+'">Widok listy</a></li>';
  575. result += '<li><a href="" class=details>Szczegóły</a></li>';
  576. result += '</ul>';
  577. result += "</div>";
  578. result += '</div><div class=clearfix></div></blockqoute></li>';
  579. }
  580. if (data["ALIAS_ID"] != 0 && type == "res") {
  581. var id = data["ALIAS_ID"];
  582. data = res[id];
  583. result += "<li class='list-group-item alias " + (state[depth]["FOCUS"] == data["ID"] ? "list-group-item-info" : "") + "'; ";
  584. result += "data-opis='" + data["OPIS"] + "' data-desc='" + data["DESC"] + "' data-id=" + data["ID"] + " style=border-top-style:none;>";
  585. result += "";
  586. result += '<div class="textTable">'
  587. result += "<span class=gotoInfo><span class='glyphicon glyphicon-arrow-right'></span> ALIAS </span><span class=gotoWay>" + data["ID"] + "</span>";
  588. result += "</div>"
  589. result += "<div style=float:right;><span class='glyph glyphicon gl glyphicon-triangle-right'></span>";
  590. result += "<div class='dropdown '>";
  591. result += "<span class='glyph glyphicon glyphicon glyphicon-menu-hamburger dropdown-toggle' data-toggle='dropdown' aria-haspopup='true' aria-expanded='true' id='dropdownMenu" + data["ID"] + "'></span>";
  592. result += '<ul class="dropdown-menu dropdown-menu-right" style=z-index:100 aria-labelledby="dropdownMenu' + data["ID"] + '">';
  593. result += '<li><a href="' + BASE_URL + 'index.php?_route=ViewTableAjax&typeName=p5_default_db:CRM_LISTA_ZASOBOW#EDIT/' + data["ID"] + '">Edytuj zasób</a></li>';
  594. result += '<li><a href="" class=connect>Procesy powiązane</a></li>';
  595. result += '<li><a href="" class=details>Szczegóły</a></li>';
  596. result += '</ul>';
  597. result += "</div>";
  598. result += '</div><div class=clearfix></div></blockqoute></li>';
  599. }
  600. return result;
  601. }
  602. $(document).on('click', '.connect', function(e) {
  603. e.preventDefault();
  604. $(this).parents(".singleAdv").nextAll(".singleAdv").remove();
  605. $(this).parents(".singleAdv").find(".active").removeClass("active");
  606. $(this).parents(".singleAdv").find(".list-group-item-info").removeClass("list-group-item-info");
  607. $(this).parents(".liProc").addClass("active");
  608. $('.dropdown.open .dropdown-toggle').dropdown('toggle');
  609. var parent_id = $(this).closest(".list-group-item").data("id");
  610. var parentOfParent_id = $(this).closest(".singleAdv").data("parent");
  611. var depth = $(this).closest(".singleAdv").data("depth") + 1;
  612. createPanel(parent_id, depth, "connect");
  613. });
  614. $(document).on('click', '.details', function(e) {
  615. e.preventDefault();
  616. $(this).parents(".singleAdv").nextAll(".singleAdv").remove();
  617. $(this).parents(".singleAdv").find(".active").removeClass("active");
  618. $(this).parents(".singleAdv").find(".list-group-item-info").removeClass("list-group-item-info");
  619. $(this).parents(".liProc").addClass("active");
  620. $('.dropdown.open .dropdown-toggle').dropdown('toggle');
  621. var parent_id = $(this).closest(".list-group-item").data("id");
  622. var parentOfParent_id = $(this).closest(".singleAdv").data("parent");
  623. var depth = $(this).closest(".singleAdv").data("depth") + 1;
  624. if ($(this).closest(".list-group-item").hasClass("wsk") || $(this).closest(".singleAdv").data("type") == "res" || $(this).closest(".list-group-item").hasClass("alias")) {
  625. createPanel(parent_id, depth, "detailsRes");
  626. //console.log("detailsRes");
  627. } else {
  628. createPanel(parent_id, depth, "details");
  629. //console.log("details");
  630. }
  631. initSortable();
  632. });
  633. $(document).on('click', '.dropdown-toggle', function(e) {
  634. e.stopPropagation();
  635. });
  636. $(document).on('click', '.dropdown', function(e) {
  637. e.stopPropagation();
  638. });
  639. $(document).on('click', '#toggleMenu', function(e) {
  640. e.preventDefault();
  641. if (!menuShow) {
  642. $("#SE-menu").show();
  643. $("#SE-menu-sub").show();
  644. menuShow = true;
  645. } else {
  646. menuShow = false;
  647. $("#SE-menu").hide();
  648. $("#SE-menu-sub").hide();
  649. }
  650. });
  651. $(document).on('click', '#toggleView', function(e) {
  652. e.preventDefault();
  653. if (!panels) {
  654. panels = true;
  655. render();
  656. } else {
  657. panels = false;
  658. render();
  659. }
  660. });
  661. $(document).on('click', '.liProc', function() {
  662. $(this).parents(".singleAdv").find(".active").removeClass("active");
  663. $(this).parents(".singleAdv").find(".list-group-item-info").removeClass("list-group-item-info");
  664. $(this).addClass("active");
  665. var parent_id = $(this).data("id");
  666. var parentOfParent_id = $(this).closest(".singleAdv").data("parent");
  667. var depth = $(this).closest(".singleAdv").data("depth") + 1;
  668. if ($(this).hasClass("wsk"))
  669. createPanel(parent_id, depth, "res");
  670. else
  671. createPanel(parent_id, depth, "inherit");
  672. initSortable();
  673. });
  674. function initSortable() {
  675. // $( ".singleAdvList" ).sortable({
  676. // items: "li",
  677. // connectWith: ".singleAdvList",
  678. // cancel: ".disabled-item",
  679. // beforeStop: function(ev, ui) {
  680. // if($(ui.item).data("id") == $(ui.placeholder).closest(".singleAdv").data("parent") || $(ui.item).hasClass("active")){
  681. // $(this).sortable('cancel');
  682. // $.notify("Nielogiczny ruch.", "error");
  683. // }
  684. //
  685. // },
  686. // stop: function(ev, ui) {
  687. // updateParent($(ui.item).data("id"),$(ui.item).closest(".singleAdv").data("parent"), this);
  688. // },
  689. // }).disableSelection();
  690. }
  691. function start() {
  692. var link = BASE_URL + 'index.php?_route=UrlAction_ProcesView&_task=getAllAjax';
  693. $.get(link, function(data) {
  694. //console.log("x");
  695. //console.log(data);
  696. procesy = data;
  697. if (TYPE == "childs")
  698. render();
  699. //console.log(procesy);
  700. });
  701. link = BASE_URL + 'index.php?_route=UrlAction_ProcesView&_task=getAllResAjax';
  702. $.get(link, function(data) {
  703. //console.log("x");
  704. //console.log(data);
  705. res = data;
  706. if (TYPE == "res")
  707. render();
  708. //console.log(res);
  709. });
  710. }
  711. start();
  712. });