TaskManager.php.task.js 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898
  1. // @required var BASE_URL
  2. // @required var TASK
  3. // @required var USER
  4. // @required var TYPE
  5. // @required var ProblemsTableId
  6. // @required var ProjectsTableId
  7. var activeCount = 0;
  8. var allCount = 0;
  9. var acceptedCount = 0;
  10. var picker;
  11. var position = 0;
  12. var wordLen = 0;
  13. var projectId;
  14. var author;
  15. var state = [];
  16. var loaded;
  17. renderForm();
  18. /*$(document).on('click', '#save', function() {
  19. $("#save").prop('disabled', true);
  20. save();
  21. });*/
  22. function setSort() {
  23. var req = `
  24. <Transaction
  25. xmlns="http://www.opengis.net/wfs"
  26. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  27. version="1.0.0"
  28. service="WFS"
  29. xmlns:p5_default_db="` + BASE_URL + `wfs/default_db/PROBLEMS"
  30. xsi:schemaLocation="` + BASE_URL + `wfs/default_db/PROBLEMS` + BASE_URL + `dev-pl/se-feature-api/wfs.php/xml/wfs/default_db/PROBLEMS/?SERVICE=WFS&amp;VERSION=1.0.0&amp;REQUEST=DescribeFeatureType&amp;TYPENAME=p5_default_db:PROBLEMS&amp;SRSNAME=EPSG:4326&amp;"
  31. xmlns:gml="http://www.opengis.net/gml">
  32. `;
  33. var i = 0;
  34. var idx = [];
  35. $("#sortable").find(".singleTask").each(function() {
  36. i++;
  37. req += `
  38. <Insert xmlns="http://www.opengis.net/wfs">
  39. <PROBLEMS xmlns="` + BASE_URL + `wfs/default_db/PROBLEMS">
  40. <ID xmlns="` + BASE_URL + `wfs/default_db/PROBLEMS">` + $(this).data("id") + `</ID>
  41. <SORT_PRIO xmlns="` + BASE_URL + `wfs/default_db/PROBLEMS">` + i + `</SORT_PRIO>
  42. </PROBLEMS>
  43. </Insert>
  44. `;
  45. idx.push($(this).data("id"));
  46. });
  47. req += `</Transaction>`;
  48. var link = BASE_URL + 'wfs-data.php/default_db/?SERVICE=WFS&VERSION=1.0.0&SRSNAME=EPSG:3003&';
  49. //console.log(req);
  50. $.ajax({
  51. url: link,
  52. data: req,
  53. type: 'POST',
  54. contentType: "text/xml",
  55. dataType: "xml",
  56. success: function(data) {
  57. //console.log("sorted");
  58. //console.log(data);
  59. $.notify("Sortowanie zsynchronizowane", "success");
  60. }
  61. });
  62. var temp = [];
  63. $.each(idx, function(i, e){
  64. var index = getIndexById(e);
  65. temp.push(state[index]);
  66. });
  67. $.each(state, function(i, e){
  68. if(e['percent'] == "100%")
  69. temp.push(e);
  70. });
  71. state = [];
  72. state = temp;
  73. render();
  74. }
  75. function createLink(name, id, target) {
  76. var link;
  77. if (TYPE == "PROBLEM") {
  78. link = BASE_URL + 'index.php?MENU_INIT=VIEWTABLE_AJAX&ZASOB_ID=' + ProblemsTableId + "#EDIT/" + id;
  79. }
  80. if (TYPE == "PROJECT") {
  81. link = BASE_URL + 'index.php?MENU_INIT=VIEWTABLE_AJAX&ZASOB_ID=' + ProjectsTableId + "#EDIT/" + id;
  82. }
  83. $(target).attr("href", link);
  84. }
  85. function getDetails(value) {
  86. var date = false;
  87. var worker = false;
  88. $.each(value.split(" "), function(i, e) {
  89. if (e.substr(0, 1) == "@") {
  90. var query = e.substr(1);
  91. if (query != "" && isNaN(query.substr(0, 1)) && !worker) {
  92. worker = query;
  93. }
  94. if (query != "" && !isNaN(query.substr(0, 1)) && !date) {
  95. date = moment(query).format('YYYY-MM-DD HH:mm:ss');
  96. }
  97. }
  98. });
  99. return {
  100. worker: worker,
  101. date: date
  102. };
  103. }
  104. //Deleted function to save changes.
  105. /*function save() {
  106. var link = BASE_URL + 'wfs-data.php/default_db/?SERVICE=WFS&VERSION=1.0.0&SRSNAME=EPSG:3003&';
  107. var saveQuery = `
  108. <Transaction
  109. xmlns="http://www.opengis.net/wfs"
  110. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  111. version="1.0.0"
  112. service="WFS"
  113. xmlns:p5_default_db="` + BASE_URL + `wfs/default_db/PROBLEMS"
  114. xsi:schemaLocation="` + BASE_URL + `wfs/default_db/PROBLEMS ` + BASE_URL + `dev-pl/se-feature-api/wfs.php/xml/wfs/default_db/PROBLEMS/?SERVICE=WFS&amp;VERSION=1.0.0&amp;REQUEST=DescribeFeatureType&amp;TYPENAME=p5_default_db:PROBLEMS&amp;SRSNAME=EPSG:4326&amp;"
  115. xmlns:gml="http://www.opengis.net/gml">
  116. <Insert xmlns="http://www.opengis.net/wfs">
  117. <PROBLEMS xmlns="` + BASE_URL + `wfs/default_db/PROBLEMS">
  118. <ID xmlns="` + BASE_URL + `wfs/default_db/CRM_PROCES">` + TASK + `</ID>
  119. `;
  120. $("#left").find("input").each(function() {
  121. saveQuery += '<' + $(this).attr("name") + ' xmlns="' + BASE_URL + 'wfs/default_db/PROBLEMS">' + $(this).val() + '</' + $(this).attr("name") + '>\n';
  122. });
  123. $("#left").find("select").each(function() {
  124. saveQuery += '<' + $(this).attr("name") + ' xmlns="' + BASE_URL + 'wfs/default_db/PROBLEMS">' + $(this).find("option:selected").text() + '</' + $(this).attr("name") + '>\n';
  125. });
  126. saveQuery += `
  127. </PROBLEMS>
  128. </Insert>
  129. </Transaction>
  130. `;
  131. //console.log(saveQuery);
  132. $.ajax({
  133. url: link,
  134. data: saveQuery,
  135. type: 'POST',
  136. contentType: "text/xml",
  137. dataType: "text",
  138. success: function(data) {
  139. //console.log(data);
  140. $.notify("Zapisano!", "success");
  141. $("#save").prop('disabled', false);
  142. renderForm();
  143. },
  144. error: function(xhr, ajaxOptions, thrownError) {
  145. $.notify("Brak połączenia z bazą danych", "error");
  146. }
  147. });
  148. }*/
  149. function updateProgress() {
  150. var proc;
  151. var procAcc;
  152. allCount = state.length;
  153. activeCount = 0;
  154. acceptedCount = 0;
  155. $.each(state, function(i, e){
  156. if (e["percent"] != "100%") {
  157. activeCount++;
  158. }
  159. if (e["status"] == "OFF_HARD") {
  160. acceptedCount++;
  161. }
  162. });
  163. if (allCount != 0) {
  164. proc = Math.round((allCount - activeCount) / allCount * 100 / 10) * 10;
  165. procAcc = Math.round((acceptedCount) / allCount * 100 / 10) * 10;
  166. } else {
  167. proc = 0;
  168. procAcc = 0;
  169. }
  170. $("#completed").css('width', proc - procAcc + "%").attr('aria-valuenow', proc - procAcc).text(proc + '%');
  171. $("#accepted").css('width', procAcc + "%").attr('aria-valuenow', procAcc).text(procAcc + '%');
  172. if (proc == 0) {
  173. $("#completed").text("");
  174. }
  175. if (procAcc == 0) {
  176. $("#accepted").text("");
  177. }
  178. }
  179. function getCaretPosition(ctrl) {
  180. var start, end;
  181. if (ctrl.setSelectionRange) {
  182. start = ctrl.selectionStart;
  183. end = ctrl.selectionEnd;
  184. } else if (document.selection && document.selection.createRange) {
  185. var range = document.selection.createRange();
  186. start = 0 - range.duplicate().moveStart('character', -100000);
  187. end = start + range.text.length;
  188. }
  189. return {
  190. start: start,
  191. end: end
  192. }
  193. }
  194. $(document).on('dblclick', '#sortable li', function(e) {
  195. var link = BASE_URL + 'wfs-data.php/default_db/?SERVICE=WFS&VERSION=1.0.0&SRSNAME=EPSG:3003&';
  196. var index = getIndexById($(this).data("id"));
  197. var req = `
  198. <Transaction
  199. xmlns="http://www.opengis.net/wfs"
  200. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  201. version="1.0.0"
  202. service="WFS"
  203. xmlns:p5_default_db="` + BASE_URL + `wfs/default_db/PROBLEMS"
  204. xsi:schemaLocation="` + BASE_URL + `wfs/default_db/PROBLEMS` + BASE_URL + `dev-pl/se-feature-api/wfs.php/xml/wfs/default_db/PROBLEMS/?SERVICE=WFS&amp;VERSION=1.0.0&amp;REQUEST=DescribeFeatureType&amp;TYPENAME=p5_default_db:PROBLEMS&amp;SRSNAME=EPSG:4326&amp;"
  205. xmlns:gml="http://www.opengis.net/gml">
  206. `;
  207. req += `
  208. <Insert xmlns="http://www.opengis.net/wfs">
  209. <PROBLEMS xmlns="` + BASE_URL + `wfs/default_db/PROBLEMS">
  210. <ID xmlns="` + BASE_URL + `wfs/default_db/PROBLEMS">` + $(this).data("id") + `</ID>`;
  211. if (state[index]["status"] == "NORMAL") {
  212. state[index]["status"] = "WAITING";
  213. req += '<A_STATUS xmlns="' + BASE_URL + 'wfs/default_db/PROBLEMS">WAITING</A_STATUS>';
  214. } else if (state[index]["status"] == "WAITING") {
  215. state[index]["status"] = "NORMAL";
  216. req += '<A_STATUS xmlns="' + BASE_URL + 'wfs/default_db/PROBLEMS">NORMAL</A_STATUS>';
  217. }
  218. req += `</PROBLEMS>
  219. </Insert>
  220. </Transaction>`;
  221. render();
  222. $.ajax({
  223. url: link,
  224. data: req,
  225. type: 'POST',
  226. contentType: "text/xml",
  227. dataType: "text",
  228. success: function(data) {}
  229. });
  230. });
  231. function autoCom() {
  232. var hide = true;
  233. $(".eInput").autocomplete({
  234. source: function(request, response) {
  235. $.ajax({
  236. url: BASE_URL + 'wfs-data.php/default_db/?SERVICE=WFS&VERSION=1.0.0&REQUEST=GetFeature&TYPENAME=p5_default_db:ADMIN_USERS&SRSNAME=EPSG:3003&Filter=<ogc:Filter><ogc:PropertyIsLike wildCard="*" singleChar="^" escapeChar="!"><ogc:PropertyName>ADM_ACCOUNT</ogc:PropertyName><ogc:Literal>*' + request.term + '*</ogc:Literal></ogc:PropertyIsLike></ogc:Filter>&maxFeatures=10',
  237. dataType: "xml",
  238. success: function(xmlResponse) {
  239. var data = $("featureMember", xmlResponse).map(function() {
  240. if ($("ID", this).text() != 0)
  241. return {
  242. value: $("ADM_ACCOUNT", this).text(),
  243. id: $("ID", this).text()
  244. };
  245. });
  246. response(data);
  247. }
  248. });
  249. },
  250. search: function() {
  251. if (hide) return false;
  252. },
  253. select: function(event, ui) {
  254. var text = this.value;
  255. this.value = text.substring(0, position) + " @" +
  256. ui.item.value + " " + text.substring(position + wordLen + 2);
  257. return false;
  258. },
  259. focus: function() {
  260. return false;
  261. },
  262. minLength: 0
  263. }).bind("keyup", function() {
  264. hide = true;
  265. $(this).autocomplete("close");
  266. var caret = getCaretPosition(this);
  267. var val = this.value;
  268. val += " ";
  269. var result = /\S+$/.exec(val.slice(0, val.indexOf(' ', caret.end)));
  270. var lastWord = result ? result[0] : null;
  271. if (lastWord != null && lastWord.substring(0, 1) == "@") {
  272. wordLen = lastWord.length;
  273. var query = lastWord.substr(1);
  274. if (isNaN(query.substring(0, 1)) && query != "") {
  275. hide = false;
  276. if (val.substr(0, caret.end).lastIndexOf(" ") > 0) {
  277. position = val.substr(0, caret.end).lastIndexOf(" ");
  278. } else {
  279. position = 0;
  280. }
  281. }
  282. if (!isNaN(query.substring(0, 1)) && query != "") {
  283. if (val.substr(0, caret.end).lastIndexOf(" ") > 0) {
  284. position = val.substr(0, caret.end).lastIndexOf(" ");
  285. } else {
  286. position = 0;
  287. }
  288. $(picker).data("DateTimePicker").show();
  289. }
  290. }
  291. $(this).autocomplete("search", query);
  292. });
  293. }
  294. $(document).on('keydown', '.hours', function(e) {
  295. var textarea = this;
  296. if (e.which == 13) {
  297. $(textarea).prop("disabled", true);
  298. var req = `
  299. <Transaction
  300. xmlns="http://www.opengis.net/wfs"
  301. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  302. version="1.0.0"
  303. service="WFS"
  304. xmlns:p5_default_db="` + BASE_URL + `wfs/default_db/PROBLEMS"
  305. xsi:schemaLocation="` + BASE_URL + `wfs/default_db/PROBLEMS` + BASE_URL + `dev-pl/se-feature-api/wfs.php/xml/wfs/default_db/PROBLEMS/?SERVICE=WFS&amp;VERSION=1.0.0&amp;REQUEST=DescribeFeatureType&amp;TYPENAME=p5_default_db:PROBLEMS&amp;SRSNAME=EPSG:4326&amp;"
  306. xmlns:gml="http://www.opengis.net/gml">
  307. `;
  308. req += `
  309. <Insert xmlns="http://www.opengis.net/wfs">
  310. <PROBLEMS xmlns="` + BASE_URL + `wfs/default_db/PROBLEMS">
  311. <ID xmlns="` + BASE_URL + `wfs/default_db/PROBLEMS">` + $(this).parents("li").data('id') + `</ID>
  312. <L_APPOITMENT_PERIOD xmlns="` + BASE_URL + `wfs/default_db/PROBLEMS">` + $(textarea).val()+ `</L_APPOITMENT_PERIOD>
  313. </PROBLEMS>
  314. </Insert>`;
  315. req += '</Transaction>';
  316. var id = getIndexById($(this).parents("li").data('id'));
  317. var period = $(this).val();
  318. var link = BASE_URL + 'wfs-data.php/default_db/?SERVICE=WFS&VERSION=1.0.0&SRSNAME=EPSG:3003&';
  319. $.ajax({
  320. url: link,
  321. data: req,
  322. type: 'POST',
  323. contentType: "text/xml",
  324. dataType: "xml",
  325. success: function(data) {
  326. $.notify("Zapisano!", "success");
  327. state[id]["period"] = period;
  328. render();
  329. }
  330. });
  331. }
  332. });
  333. $(document).on('keydown', '.editable', function(e) {
  334. var textarea = this;
  335. if (e.keyCode == 13) {
  336. $(textarea).prop("disabled", true);
  337. var details = getDetails($(this).val());
  338. var req = `
  339. <Transaction
  340. xmlns="http://www.opengis.net/wfs"
  341. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  342. version="1.0.0"
  343. service="WFS"
  344. xmlns:p5_default_db="` + BASE_URL + `wfs/default_db/PROBLEMS"
  345. xsi:schemaLocation="` + BASE_URL + `wfs/default_db/PROBLEMS` + BASE_URL + `dev-pl/se-feature-api/wfs.php/xml/wfs/default_db/PROBLEMS/?SERVICE=WFS&amp;VERSION=1.0.0&amp;REQUEST=DescribeFeatureType&amp;TYPENAME=p5_default_db:PROBLEMS&amp;SRSNAME=EPSG:4326&amp;"
  346. xmlns:gml="http://www.opengis.net/gml">
  347. `;
  348. req += `
  349. <Insert xmlns="http://www.opengis.net/wfs">
  350. <PROBLEMS xmlns="` + BASE_URL + `wfs/default_db/PROBLEMS">
  351. <ID xmlns="` + BASE_URL + `wfs/default_db/PROBLEMS">` + $(this).parents("li").data('id') + `</ID>`;
  352. if (details.worker != false)
  353. req += '<L_APPOITMENT_USER xmlns="' + BASE_URL + 'wfs/default_db/PROBLEMS">' + details.worker + '</L_APPOITMENT_USER>';
  354. else
  355. req += '<L_APPOITMENT_USER xmlns="' + BASE_URL + 'wfs/default_db/PROBLEMS">' + USER + '</L_APPOITMENT_USER>';
  356. if (details.date != false)
  357. req += '<A_PROBLEM_DATE xmlns="' + BASE_URL + 'wfs/default_db/PROBLEMS">' + details.date + '</A_PROBLEM_DATE>';
  358. else
  359. req += '<A_PROBLEM_DATE xmlns="' + BASE_URL + 'wfs/default_db/PROBLEMS">' + moment().format('YYYY-MM-DD HH:mm:ss') + '</A_PROBLEM_DATE>';
  360. req += `<A_PROBLEM_DESC xmlns="` + BASE_URL + `wfs/default_db/PROBLEMS">` + $(this).val() + `</A_PROBLEM_DESC>
  361. <CUSTOMER_ADMIN_USER xmlns="` + BASE_URL + `wfs/default_db/PROBLEMS">BRAK</CUSTOMER_ADMIN_USER>
  362. </PROBLEMS>
  363. </Insert>`;
  364. req += '</Transaction>';
  365. var id = getIndexById($(this).parents("li").data('id'));
  366. var desc = $(this).val();
  367. var link = BASE_URL + 'wfs-data.php/default_db/?SERVICE=WFS&VERSION=1.0.0&SRSNAME=EPSG:3003&';
  368. $.ajax({
  369. url: link,
  370. data: req,
  371. type: 'POST',
  372. contentType: "text/xml",
  373. dataType: "xml",
  374. success: function(data) {
  375. state[id]["desc"] = desc;
  376. if (details.worker != false) {
  377. state[id]["worker"] = details.worker
  378. } else {
  379. state[id]["worker"] = USER;
  380. }
  381. render();
  382. $.notify("Zapisano!", "success");
  383. }
  384. });
  385. return false;
  386. }
  387. });
  388. $(document).on('keydown', '.eInput', function(e) {
  389. if (e.keyCode == 13) {
  390. if ($(this).val() != "") {
  391. var details = getDetails($(this).val());
  392. var req = `
  393. <Transaction
  394. xmlns="http://www.opengis.net/wfs"
  395. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  396. version="1.0.0"
  397. service="WFS"
  398. xmlns:p5_default_db="` + BASE_URL + `wfs/default_db/PROBLEMS"
  399. xsi:schemaLocation="` + BASE_URL + `wfs/default_db/PROBLEMS` + BASE_URL + `dev-pl/se-feature-api/wfs.php/xml/wfs/default_db/PROBLEMS/?SERVICE=WFS&amp;VERSION=1.0.0&amp;REQUEST=DescribeFeatureType&amp;TYPENAME=p5_default_db:PROBLEMS&amp;SRSNAME=EPSG:4326&amp;"
  400. xmlns:gml="http://www.opengis.net/gml">
  401. `;
  402. req += `
  403. <Insert xmlns="http://www.opengis.net/wfs">
  404. <PROBLEMS xmlns="` + BASE_URL + `wfs/default_db/PROBLEMS">`;
  405. if (TYPE == "PROBLEM") {
  406. req += `<PARENT_ID xmlns="` + BASE_URL + `wfs/default_db/PROBLEMS">` + TASK + `</PARENT_ID>`;
  407. }
  408. if (TYPE == "PROJECT") {
  409. req += `<PARENT_ID xmlns="` + BASE_URL + `wfs/default_db/PROBLEMS">0</PARENT_ID>`;
  410. }
  411. if (details.worker != false) {
  412. req += '<L_APPOITMENT_USER xmlns="' + BASE_URL + 'wfs/default_db/PROBLEMS">' + details.worker + '</L_APPOITMENT_USER>';
  413. } else {
  414. req += '<L_APPOITMENT_USER xmlns="' + BASE_URL + 'wfs/default_db/PROBLEMS">' + USER + '</L_APPOITMENT_USER>';
  415. }
  416. if (details.date != false) {
  417. req += '<A_PROBLEM_DATE xmlns="' + BASE_URL + 'wfs/default_db/PROBLEMS">' + details.date + '</A_PROBLEM_DATE>';
  418. } else {
  419. req += '<A_PROBLEM_DATE xmlns="' + BASE_URL + 'wfs/default_db/PROBLEMS">' + moment().format('YYYY-MM-DD HH:mm:ss') + '</A_PROBLEM_DATE>';
  420. }
  421. req += `<ID_PROJECT xmlns="` + BASE_URL + `wfs/default_db/PROBLEMS">` + ProjectId + `</ID_PROJECT>`;
  422. req += `<L_APPOITMENT_PERIOD xmlns="` + BASE_URL + `wfs/default_db/PROBLEMS">0</L_APPOITMENT_PERIOD>`;
  423. req += `<A_PROBLEM_DESC xmlns="` + BASE_URL + `wfs/default_db/PROBLEMS">` + $(this).val() + `</A_PROBLEM_DESC>
  424. <CUSTOMER_ADMIN_USER xmlns="` + BASE_URL + `wfs/default_db/PROBLEMS">BRAK</CUSTOMER_ADMIN_USER>
  425. </PROBLEMS>
  426. </Insert>`;
  427. req += '</Transaction>';
  428. var link = BASE_URL + 'wfs-data.php/default_db/?SERVICE=WFS&VERSION=1.0.0&SRSNAME=EPSG:3003&';
  429. var info = this;
  430. $.ajax({
  431. url: link,
  432. data: req,
  433. type: 'POST',
  434. contentType: "text/xml",
  435. dataType: "xml",
  436. success: function(data) {
  437. var temp = {};
  438. temp["id"] = $(data).find("FeatureId").attr("fid").substr($(data).find("FeatureId").attr("fid").indexOf('.') + 1);
  439. temp["desc"] = $(info).val();
  440. temp["percent"] = "0%";
  441. temp["period"] = "0";
  442. temp["status"] = "WAITING";
  443. temp["worker"] = (details.worker != false ? details.worker : USER);
  444. temp["owner"] = USER;
  445. state.push(temp);
  446. $(".eInput").val("");
  447. updateProgress();
  448. render();
  449. setSort();
  450. }
  451. });
  452. }
  453. return false;
  454. }
  455. });
  456. $(document).on('click', '.delTask', function() {
  457. if ($(this).parents(".singleTask").find(".aCheck").data("state") == "1") {
  458. $.notify("Nie możesz zmieniać stanu zatwierdzonych zadań", "danger");
  459. return true;
  460. }
  461. if ($(this).parents(".singleTask").data("step") == 2) {
  462. allCount--;
  463. } else {
  464. allCount--;
  465. activeCount--;
  466. }
  467. var id = $(this).closest(".singleTask").data("id");
  468. var index = getIndexById(id);
  469. var req = `
  470. <Transaction
  471. xmlns="http://www.opengis.net/wfs"
  472. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  473. version="1.0.0"
  474. service="WFS"
  475. xmlns:p5_default_db="` + BASE_URL + `wfs/default_db/PROBLEMS"
  476. xsi:schemaLocation="` + BASE_URL + `wfs/default_db/PROBLEMS` + BASE_URL + `dev-pl/se-feature-api/wfs.php/xml/wfs/default_db/PROBLEMS/?SERVICE=WFS&amp;VERSION=1.0.0&amp;REQUEST=DescribeFeatureType&amp;TYPENAME=p5_default_db:PROBLEMS&amp;SRSNAME=EPSG:4326&amp;"
  477. xmlns:gml="http://www.opengis.net/gml">
  478. `;
  479. req += `
  480. <Insert xmlns="http://www.opengis.net/wfs">
  481. <PROBLEMS xmlns="` + BASE_URL + `wfs/default_db/PROBLEMS">`;
  482. req += `<ID xmlns="` + BASE_URL + `wfs/default_db/PROBLEMS">` + id + `</ID>`;
  483. req += `<A_STATUS xmlns="` + BASE_URL + `wfs/default_db/PROBLEMS">DELETED</A_STATUS>
  484. </PROBLEMS>
  485. </Insert>`;
  486. req += '</Transaction>';
  487. var link = BASE_URL + 'wfs-data.php/default_db/?SERVICE=WFS&VERSION=1.0.0&SRSNAME=EPSG:3003&';
  488. $.ajax({
  489. url: link,
  490. data: req,
  491. type: 'POST',
  492. contentType: "text/xml",
  493. dataType: "xml",
  494. success: function(data) {
  495. }
  496. });
  497. state.splice(index, 1);
  498. render();
  499. });
  500. $(document).on('click', '#showMore', function() {
  501. if ($("#doneList").is(":visible")) {
  502. $("#doneList").slideUp("fast");
  503. $(this).html("Pokaż wykonane zadania <span class='glyphicon glyphicon-chevron-down'></span>");
  504. } else {
  505. $("#doneList").slideDown("fast");
  506. $(this).html("Ukryj wykonane zadania <span class='glyphicon glyphicon-chevron-up'></span>");
  507. }
  508. });
  509. $(document).on('click', '.aCheck', function() {
  510. var node = this;
  511. var id = getIndexById($(node).parents("li").data("id"));
  512. if (state[id]["owner"] != USER) {
  513. $.notify("Tylko zleceniodawca może zatwierdzać postęp prac.", "danger");
  514. return true;
  515. }
  516. var link = BASE_URL + 'wfs-data.php/default_db/?SERVICE=WFS&VERSION=1.0.0&SRSNAME=EPSG:3003&';
  517. var req = `
  518. <Transaction
  519. xmlns="http://www.opengis.net/wfs"
  520. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  521. version="1.0.0"
  522. service="WFS"
  523. xmlns:p5_default_db="` + BASE_URL + `wfs/default_db/PROBLEMS"
  524. xsi:schemaLocation="` + BASE_URL + `wfs/default_db/PROBLEMS` + BASE_URL + `dev-pl/se-feature-api/wfs.php/xml/wfs/default_db/PROBLEMS/?SERVICE=WFS&amp;VERSION=1.0.0&amp;REQUEST=DescribeFeatureType&amp;TYPENAME=p5_default_db:PROBLEMS&amp;SRSNAME=EPSG:4326&amp;"
  525. xmlns:gml="http://www.opengis.net/gml">
  526. `;
  527. req += `
  528. <Insert xmlns="http://www.opengis.net/wfs">
  529. <PROBLEMS xmlns="` + BASE_URL + `wfs/default_db/PROBLEMS">
  530. <ID xmlns="` + BASE_URL + `wfs/default_db/PROBLEMS">` + id + `</ID>`;
  531. if (state[id]['status'] != "OFF_HARD") {
  532. req += '<A_STATUS xmlns="' + BASE_URL + 'wfs/default_db/PROBLEMS">OFF_HARD</A_STATUS>';
  533. state[id]['status'] = "OFF_HARD";
  534. } else {
  535. req += '<A_STATUS xmlns="' + BASE_URL + 'wfs/default_db/PROBLEMS">WAITING</A_STATUS>';
  536. state[id]['status'] = "WAITING";
  537. }
  538. req += `</PROBLEMS>
  539. </Insert>
  540. </Transaction>`;
  541. $.ajax({
  542. url: link,
  543. data: req,
  544. type: 'POST',
  545. contentType: "text/xml",
  546. dataType: "text",
  547. success: function(data) {
  548. setSort();
  549. updateProgress();
  550. render();
  551. }
  552. });
  553. });
  554. function getIndexById(id){
  555. for (var i = 0; i < state.length; i++) {
  556. if (state[i]['id'] == id) {
  557. return i;
  558. }
  559. }
  560. return false;
  561. }
  562. $(document).on('click', '.check', function() {
  563. var node = this;
  564. var id = $(node).parents("li").data("id");
  565. var index = getIndexById(id);
  566. if (state[index]['status'] == "OFF_HARD") {
  567. $.notify("Nie możesz zmieniać stanu zatwierdzonych zadań", "danger");
  568. return true;
  569. }
  570. if(state[index]['childs'] != false){
  571. $.notify("Zmieniać status można tylko wtedy, jeżeli zadanie nie ma podzadań.", "danger");
  572. return;
  573. }
  574. var link = BASE_URL + 'wfs-data.php/default_db/?SERVICE=WFS&VERSION=1.0.0&SRSNAME=EPSG:3003&';
  575. var req = `
  576. <Transaction
  577. xmlns="http://www.opengis.net/wfs"
  578. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  579. version="1.0.0"
  580. service="WFS"
  581. xmlns:p5_default_db="` + BASE_URL + `wfs/default_db/PROBLEMS"
  582. xsi:schemaLocation="` + BASE_URL + `wfs/default_db/PROBLEMS` + BASE_URL + `dev-pl/se-feature-api/wfs.php/xml/wfs/default_db/PROBLEMS/?SERVICE=WFS&amp;VERSION=1.0.0&amp;REQUEST=DescribeFeatureType&amp;TYPENAME=p5_default_db:PROBLEMS&amp;SRSNAME=EPSG:4326&amp;"
  583. xmlns:gml="http://www.opengis.net/gml">
  584. `;
  585. req += `
  586. <Insert xmlns="http://www.opengis.net/wfs">
  587. <PROBLEMS xmlns="` + BASE_URL + `wfs/default_db/PROBLEMS">
  588. <ID xmlns="` + BASE_URL + `wfs/default_db/PROBLEMS">` + $(node).parents("li").data("id") + `</ID>`;
  589. if (state[index]['percent'] != "100%") {
  590. req += '<A_PROBLEM_COMPLETE_PERCENT xmlns="' + BASE_URL + 'wfs/default_db/PROBLEMS">100%</A_PROBLEM_COMPLETE_PERCENT>';
  591. state[index]['percent'] = "100%";
  592. } else {
  593. req += '<A_PROBLEM_COMPLETE_PERCENT xmlns="' + BASE_URL + 'wfs/default_db/PROBLEMS">0%</A_PROBLEM_COMPLETE_PERCENT>';
  594. state[index]['percent'] = "0%";
  595. }
  596. req += `</PROBLEMS>
  597. </Insert>
  598. </Transaction>`;
  599. $.ajax({
  600. url: link,
  601. data: req,
  602. type: 'POST',
  603. contentType: "text/xml",
  604. dataType: "text",
  605. success: function(data) {
  606. setSort();
  607. }
  608. });
  609. updateProgress();
  610. render();
  611. });
  612. function stripHTML(dirtyString) {
  613. var container = document.createElement('div');
  614. var text = document.createTextNode(dirtyString);
  615. container.appendChild(text);
  616. return container.innerHTML; // innerHTML will be a xss safe string
  617. }
  618. function renderForm() {
  619. $("#left").empty();
  620. var link, link2;
  621. if (TYPE == "PROBLEM") {
  622. link = BASE_URL + "wfs-data.php/default_db/?SERVICE=WFS&VERSION=1.0.0&TYPENAME=p5_default_db:PROBLEMS&REQUEST=DescribeFeatureTypeAdvanced";
  623. link2 = BASE_URL + "wfs-data.php/default_db/?SERVICE=WFS&VERSION=1.0.0&REQUEST=GetFeature&TYPENAME=p5_default_db:PROBLEMS&SRSNAME=EPSG:3003&Filter=<ogc:Filter><ogc:PropertyIsEqualTo><ogc:PropertyName>ID</ogc:PropertyName><ogc:Literal>" + TASK + "</ogc:Literal></ogc:PropertyIsEqualTo></ogc:Filter>";
  624. }
  625. if (TYPE == "PROJECT") {
  626. link = BASE_URL + "wfs-data.php/default_db/?SERVICE=WFS&VERSION=1.0.0&TYPENAME=p5_default_db:IN7_MK_BAZA_DYSTRYBUCJI&REQUEST=DescribeFeatureTypeAdvanced";
  627. link2 = BASE_URL + "wfs-data.php/default_db/?SERVICE=WFS&VERSION=1.0.0&REQUEST=GetFeature&TYPENAME=p5_default_db:IN7_MK_BAZA_DYSTRYBUCJI&SRSNAME=EPSG:3003&Filter=<ogc:Filter><ogc:PropertyIsEqualTo><ogc:PropertyName>ID</ogc:PropertyName><ogc:Literal>" + TASK + "</ogc:Literal></ogc:PropertyIsEqualTo></ogc:Filter>";
  628. }
  629. var field = '';
  630. $.get(link, function(fields) {
  631. $.get(link2, function(data) {
  632. author = $(data).find("A_RECORD_CREATE_AUTHOR").text();
  633. if (TYPE == "PROBLEM") {
  634. ProjectId = $(data).find("ID_PROJECT").text();
  635. }
  636. if (TYPE == "PROJECT") {
  637. ProjectId = TASK;
  638. }
  639. if (TYPE == "PROBLEM") {
  640. var breadcrumb = `
  641. <ol class="breadcrumb">
  642. ` + ($(data).find("ID_PROJECT").text() != 0 ? "<li><a href='" + BASE_URL + "index.php?_route=UrlAction_TaskManager&ID_PROJECT=" + $(data).find("ID_PROJECT").text() + "'> Projekt " + $(data).find("ID_PROJECT").text() + "</a></li>" : "") + `
  643. ` + ($(data).find("PARENT_ID").text() != 0 ? "<li><a href='" + BASE_URL + "index.php?_route=UrlAction_TaskManager&ID_PROBLEM=" + $(data).find("PARENT_ID").text() + "'> Zadanie " + $(data).find("PARENT_ID").text() + "</a></li>" : "") + `
  644. <li class="active">Zadanie ` + $(data).find("ID").text() + ` </li>
  645. </ol>`;
  646. }
  647. if (TYPE == "PROJECT") {
  648. var breadcrumb = `
  649. <ol class="breadcrumb">
  650. <li class=active> Projekt ` + TASK + `</li>
  651. </ol>`;
  652. }
  653. $("#left").append(breadcrumb);
  654. field += '';
  655. $(fields).find("sequence").find("element").each(function() {
  656. var show = true;
  657. if ($(this).attr('name') == "ID") {
  658. show = false;
  659. }
  660. if (show) {
  661. field += '<div class="form-group">';
  662. field += '<label class="col-xs-12 col-sm-12 col-md-12 control-label" for="' + $(this).attr('name') + '">';
  663. if ($(this).attr('p5:label')) {
  664. field += $(this).attr('p5:label');
  665. } else {
  666. field += $(this).attr('name');
  667. }
  668. field += ' <i class="glyphicon glyphicon-info-sign frm-help" data-toggle="popover" data-trigger="hover" title="" data-content="' + stripHTML($(this).attr('p5:description')) + '" data-original-title="' + $(this).attr('name') + '">';
  669. field += '</i>';
  670. field += '</label>';
  671. field += '<div class="col-xs-12 col-sm-12 col-md-12">';
  672. var value = $(data).find($(this).attr('name')).text();
  673. if ($(this).attr('p5:allow_write') == "true") {
  674. if ($(this).attr('type') == "gml:LineStringPropertyType") {
  675. field += '...';
  676. } else if ($(this).attr('type') == "xsd:string" || $(this).attr('type') == "xsd:integer" || true) {// || true due to changes of saving system.
  677. field += '<input readOnly name="' + $(this).attr('name') + '" type="text" value="' + $(data).find($(this).attr('name')).text() + '" maxlength="255" class="form-control">';
  678. } else if ($(this).attr('type') == "xsd:dateTime") {
  679. field += '<div class="input-group"><input name="' + $(this).attr('name') + '" readOnly type="text" value="' + value + '" maxlength="255" class="se_type-datetime form-control" data-format="yyyy-MM-dd hh:mm"><span class="input-group-addon"><span class="glyphicon glyphicon-calendar"></span></div>';
  680. } else {
  681. field += '<select name="' + $(this).attr('name') + '" class="form-control"><option></option>';
  682. $(fields).find("simpleType[name='" + $(this).attr('type').replace("p5_default_db:", "") + "']").find("enumeration").each(function() {
  683. if (value == $(this).attr("value")) {
  684. field += '<option selected=SELECTED >' + $(this).attr("value") + '</option>';
  685. } else {
  686. field += '<option >' + $(this).attr("value") + '</option>';
  687. }
  688. });
  689. field += "</select>";
  690. }
  691. } else {
  692. field += $(data).find($(this).attr('name')).text();
  693. }
  694. field += '</div>';
  695. field += '<div class=clearfix></div></div>';
  696. }
  697. });
  698. field += '<div class="form-group">';
  699. field += '<div class="col-xs-offset-0 col-xs-12 col-sm-offset-3 col-sm-9 col-md-offset-2 col-md-10">';
  700. field += '</div></div>';
  701. field += '<a><button type="submit" class="btn btn-primary" id=save tabindex="20">Edytuj</button></a>';
  702. $("#left").append(field);
  703. $("#left").append("<div class=clearfix></div>");
  704. createLink("PROBLEMS", TASK, $("#save").parents("a"));
  705. //renderTaskManager();
  706. getData();
  707. });
  708. });
  709. }
  710. $(document).ajaxStop(function() {
  711. if (loaded) return;
  712. loaded = true;
  713. renderTaskManager();
  714. });
  715. function getData() {
  716. if (TYPE == "PROBLEM") {
  717. link = BASE_URL + 'wfs-data.php/default_db/?SERVICE=WFS&VERSION=1.0.0&REQUEST=GetFeature&TYPENAME=p5_default_db:PROBLEMS&SRSNAME=EPSG:3003&Filter=<ogc:Filter><ogc:And><ogc:PropertyIsEqualTo><ogc:PropertyName>PARENT_ID</ogc:PropertyName><ogc:Literal>' + TASK + '</ogc:Literal></ogc:PropertyIsEqualTo><ogc:Not><ogc:PropertyIsEqualTo><ogc:PropertyName>A_STATUS</ogc:PropertyName><ogc:Literal>Deleted</ogc:Literal></ogc:PropertyIsEqualTo></ogc:Not></ogc:And></ogc:Filter>&sortBy=SORT_PRIO+A';
  718. }
  719. if (TYPE == "PROJECT") {
  720. link = BASE_URL + 'wfs-data.php/default_db/?SERVICE=WFS&VERSION=1.0.0&REQUEST=GetFeature&TYPENAME=p5_default_db:PROBLEMS&SRSNAME=EPSG:3003&Filter=<ogc:Filter><ogc:And><ogc:PropertyIsEqualTo><ogc:PropertyName>ID_PROJECT</ogc:PropertyName><ogc:Literal>' + TASK + '</ogc:Literal></ogc:PropertyIsEqualTo><ogc:PropertyIsEqualTo><ogc:PropertyName>PARENT_ID</ogc:PropertyName><ogc:Literal>0</ogc:Literal></ogc:PropertyIsEqualTo><ogc:Not><ogc:PropertyIsEqualTo><ogc:PropertyName>A_STATUS</ogc:PropertyName><ogc:Literal>DELETED</ogc:Literal></ogc:PropertyIsEqualTo></ogc:Not></ogc:And></ogc:Filter>&sortBy=SORT_PRIO+A';
  721. }
  722. $.get(link, function(data) {
  723. loaded = false;
  724. //console.log(data);
  725. var count = $(data).find("featureMember").length;
  726. $(data).find("featureMember").each(function(e) {
  727. if ($(this).find("ID").text() == 0) {
  728. return;
  729. }
  730. var temp = {};
  731. temp["id"] = $(this).find("ID").text();
  732. temp["desc"] = $(this).find("A_PROBLEM_DESC").text();
  733. temp["percent"] = $(this).find("A_PROBLEM_COMPLETE_PERCENT").text();
  734. temp["status"] = $(this).find("A_STATUS").text();
  735. temp["worker"] = $(this).find("L_APPOITMENT_USER").text();
  736. temp["period"] = $(this).find("L_APPOITMENT_PERIOD").text();
  737. temp["owner"] = $(this).find("A_RECORD_CREATE_AUTHOR").text();
  738. temp["childs"] = false;
  739. var linkChilds = BASE_URL + "wfs-data.php/default_db/?SERVICE=WFS&VERSION=1.0.0&REQUEST=GetFeature&TYPENAME=p5_default_db:PROBLEMS&SRSNAME=EPSG:3003&Filter=<ogc:Filter><ogc:PropertyIsEqualTo><ogc:PropertyName>PARENT_ID</ogc:PropertyName><ogc:Literal>" + temp["id"] + "</ogc:Literal></ogc:PropertyIsEqualTo></ogc:Filter>";
  740. $.get(linkChilds, function(data) {
  741. if ($(data).find("ID").text() != '0') {
  742. temp["childs"] = true;
  743. }
  744. state.push(temp);
  745. });
  746. });
  747. });
  748. }
  749. function render() {
  750. var resultActive = "";
  751. var resultDone = "";
  752. //console.log(state);
  753. $.each(state, function(i, e) {
  754. var result = "";
  755. var css = "";
  756. if (e["percent"] != "100%") {
  757. if (e['status'] == "NORMAL") {
  758. css = "background: linear-gradient(to right, #73fb73 0%, #73fb73 " + e["percent"] + ", #bdefbd " + e["percent"] + ", #bdefbd 100%);";
  759. } else if (e['status'] == "WAITING") {
  760. css = "background: linear-gradient(to right, rgba(0,0,0,0.1) 0%, rgba(0,0,0,0.1) " + e["percent"] + ", transparent " + e["percent"] + ", transparent 100%);";
  761. }
  762. }
  763. result += "<li class=singleTask data-id=" + e["id"] + " style='"+css+"'>";
  764. result += "<span class='glyphicon glyphicon-option-vertical ico'></span>";
  765. if (e["percent"] == "100%") {
  766. result += "<span class=check style='background-color:#333333'></span>";
  767. if (e['status'] != "OFF_HARD") {
  768. result += "<span class=aCheck></span>";
  769. } else {
  770. result += "<span class=aCheck style=background-color:green;></span>";
  771. }
  772. } else {
  773. result += "<span class=check></span>";
  774. }
  775. result += "<input type=text "+(e["childs"] ? "DISABLED" : "")+" class='form-control hours' value='"+e["period"]+"' style=width:40px;float:left;padding:0px;height:25px;>"
  776. result += "<textarea " + (USER != e["owner"] || e['status'] == "OFF_HARD" ? "DISABLED" : "") + " class=editable>" + e['desc'] + "</textarea>";
  777. result += `<div class="dropdown" style=display:inline;>
  778. <span class="glyphicon glyphicon glyphicon-menu-hamburger" data-toggle="dropdown"></span>
  779. <ul class="dropdown-menu dropdown-menu-right">
  780. <li><a href=` + BASE_URL + `index.php?_route=UrlAction_TaskManager&ID_PROBLEM=` + e['id'] + `>Szczegóły</a></li>
  781. <li><p style="cursor:pointer;padding:3px 20px;" class=delTask>Usuń</p></li>
  782. </ul>
  783. </div>`;
  784. result += ((e['owner'] != USER) ? " <span class='glyphicon glyphicon-user user' title='Zlecone przez inną osobę'></span>" : "") + "</li>";
  785. if (e['percent'] == "100%") {
  786. resultDone += result;
  787. } else {
  788. resultActive += result;
  789. }
  790. });
  791. resultActive += "<div class=clearfix></div>";
  792. resultDone += "<div class=clearfix></div>";
  793. $("#sortable").html(resultActive);
  794. $("#doneList").html(resultDone);
  795. }
  796. function loadStats(){
  797. var link;
  798. if (TYPE == "PROBLEM") {
  799. link = BASE_URL + "index.php?_route=UrlAction_TaskManager&_task=getStatsAjax&TYPE=PROBLEM&ID="+TASK;
  800. } else {
  801. link = BASE_URL + "index.php?_route=UrlAction_TaskManager&_task=getStatsAjax&TYPE=PROBLEM&ID="+TASK;
  802. }
  803. $.get(link, function(data) {
  804. data = data[0];
  805. var result = "<td>L. wykonanych podzadań: "+data["CHILDS_DONE_COUNT"]+"/"+data["CHILDS_COUNT"]+"</td><td></td>";
  806. $("#line1", ".stats").html(result);
  807. });
  808. }
  809. function renderTaskManager() {
  810. $("#right").append("<div class=taskList ></div>");
  811. if (false) {// TODO
  812. $("#right").append("<h2>Statystyki</h2><div class=stats></div>");
  813. $(".stats").append("<div class=table-responsive><table class=table><tr id=line1></tr><tr id=line2></tr></table></div>");
  814. loadStats();
  815. }
  816. $(".taskList").append("<div class=progress></div>");
  817. $(".progress").append("<div id=accepted class='progress-bar progress-bar-success progress-bar-striped' role=progressbar style=width:9%>0%</div>");
  818. $(".progress").append("<div id=completed class='progress-bar progress-bar-info progress-bar-striped' role=progressbar style=width:9%>0%</div>");
  819. $(".taskList").append("<ul id='sortable'></ul>");
  820. // $("#sortable").append("<li><span class='glyphicon glyphicon-option-vertical ico'></span><span class=check data-step=0></span> <div class=editable contentEditable='true'>Zaprojektować podstawowy layout skryptu</div></li>");
  821. // $("#sortable").append("<li><span class='glyphicon glyphicon-option-vertical ico'></span><span class=check data-step=0></span> <div class=editable contentEditable='true'>Stworzyć tasklistę, dodać przesuwaunie i flagowanie</div></li>");
  822. // $("#sortable").append("<li><span class='glyphicon glyphicon-option-vertical ico'></span><span class=check data-step=0></span> <div class=editable contentEditable='true'>Dodać po lewej stronie formularz</div></li>");
  823. // $("#sortable").append("<li><span class='glyphicon glyphicon-option-vertical ico'></span><span class=check data-step=0></span> <div class=editable contentEditable='true'>Połączyć z API</div></li>");
  824. $(".taskList").append("<div id=add><span class='glyphicon glyphicon-plus addIco'></span> <textarea class=eInput id=datepicker placeholder='Dodaj zadanie'></textarea><div class=clearfix></div></div>");
  825. picker = $("<input/>", {
  826. type: 'text',
  827. style: 'width:0px;height:0px;outline:none;overflow:0;border:0;margin:0px;padding:0px;',
  828. id: "date",
  829. }).datetimepicker({
  830. defaultDate: false,
  831. useCurrent: false,
  832. widgetPositioning: {
  833. horizontal: 'auto',
  834. vertical: 'bottom'
  835. }
  836. })
  837. $('.taskList').append(picker);
  838. $(".taskList").append("<div id=showMore >Pokaż wykonane zadania <span class='glyphicon glyphicon-chevron-down'></span></div>");
  839. $(".taskList").append("<ul id='doneList'></ul>");
  840. var link;
  841. $('.editable').autosize();
  842. $("#doneList").hide();
  843. updateProgress();
  844. $(picker).on("dp.change", function(e) {
  845. var date = e.date;
  846. date = date.format('YYYY-MM-DD');
  847. var text = $(".eInput").val();
  848. var result = text.substring(0, position) + " @" + date + " " + text.substring(position + wordLen + 2);
  849. $(".eInput").val(result);
  850. $(picker).data("DateTimePicker").hide();
  851. });
  852. $(function() {
  853. $("#sortable").sortable({
  854. stop: function(event, ui) {
  855. setSort();
  856. },
  857. handle: ".ico"
  858. });
  859. autoCom();
  860. $('.eInput').autosize();
  861. });
  862. render();
  863. }