TaskManager.php.task.js 37 KB

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