Advertisement
Guest User

Untitled

a guest
Jul 3rd, 2018
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 124.82 KB | None | 0 0
  1. scheduler.ajax.js
  2. function approveTasksPlanned_ajax(onDateUnixTimeStamp, factsTableTasksApprove, confirmButton) {
  3. $('#factsEntry_dataTable_wrapper').find('span:contains("Apstiprināt")').parent().addClass('inactiveLink');
  4. var axJournalId = $('input[name=_AxJournalId]').val();
  5. var tasksApproveStringified = JSON.stringify(factsTableTasksApprove);
  6. var request = $.ajax({
  7. type: "POST",
  8. url: "/Scheduler/ApproveTasksPlanned?AxJournalId=" + axJournalId,
  9. data: '{ "onDateUnixTimeStamp":' + onDateUnixTimeStamp + ', "factsTableTasksApprove": ' + tasksApproveStringified + ' }',
  10. contentType: "application/json; charset=utf-8",
  11. dataType: "json"
  12. });
  13. request.done(function (response) {
  14. if (response.success) {
  15. if (response.result.log.length > 0) {
  16. showLogInfo_dlg(response.result.log);
  17. }
  18. //if (response.result.log.length == 0) {
  19. dhtmlx.message("Stundas atjaunotas");
  20. // }
  21. if (lastTimeStamp) {
  22. refreshFactsTable_ajax(lastTimeStamp, confirmButton);
  23. }
  24.  
  25. } else {
  26. dhtmlx.message("Kļūda apstiprinot stundas");
  27. showLogInfo_dlg(response.result.log);
  28. refreshSumColumnsData_ajax();
  29. console.log(response.message);
  30. }
  31. });
  32. request.fail(function (jqXHR, textStatus) {
  33. dhtmlx.message("Kļūda veicot pieprasījumu");
  34. console.log(jqXHR);
  35. console.log(textStatus);
  36. });
  37. }
  38.  
  39. function refreshFactsTable_ajax(onDateUnixTimeStamp, confirmButton) {
  40. var axJournalId = $('input[name=_AxJournalId]').val();
  41. var request = $.ajax({
  42. type: "POST",
  43. url: "/Scheduler/GenerateFactsTableItems?AxJournalId=" + axJournalId,
  44. data: '{ "onDateUnixTimeStamp": ' + onDateUnixTimeStamp + ' }',
  45. contentType: "application/json; charset=utf-8",
  46. dataType: "json"
  47. });
  48. request.done(function (response) {
  49. if (response.success) {
  50. let factsEntryTable = $('#factsEntry_dataTable').DataTable();
  51. factsEntryTable.destroy();
  52. createFactsTable(response.result.factsTableContent, lastTimeStamp);
  53. $(confirmButton).prop('disabled', false);
  54. recalculateAndLoadSchedulingData_ajax();
  55. //refreshSumColumnsData_ajax(true);
  56. } else {
  57. dhtmlx.message("Kļūda ģenerējot faktu tabulu");
  58. console.log(response.message);
  59. }
  60. });
  61. request.fail(function (jqXHR, textStatus) {
  62. dhtmlx.message("Kļūda veicot pieprasījumu");
  63. console.log(jqXHR);
  64. console.log(textStatus);
  65. });
  66. }
  67. function manuallyScheduleEmployee_ajax(wtTaskId, emplId, period, wd1, hd1, wd2, hd2, planOtherPlaces, fromTemplateStart) {
  68. var axJournalId = $('input[name=_AxJournalId]').val();
  69. var request = $.ajax({
  70. type: "POST",
  71. url: "/Scheduler/ManuallyScheduleEmployee?AxJournalId=" + axJournalId,
  72. data: '{ "wtTaskId":' + wtTaskId + ', "emplId": ' + emplId + ', "period": "' + period +
  73. '", "wd1": ' + wd1 + ', "hd1": ' + hd1 + ', "wd2": ' + wd2 + ', "hd2": ' + hd2 +
  74. ', "planOtherPlaces": ' + planOtherPlaces + ', "fromTemplateStart": ' + fromTemplateStart + ' }',
  75. contentType: "application/json; charset=utf-8",
  76. dataType: "json"
  77. });
  78. request.done(function (response) {
  79. if (response.success) {
  80. dhtmlx.message("Manuālā darbinieka plānošana pabeigta");
  81. refreshSumColumnsData_ajax();
  82. //clearAndLoadSchedulingData_ajax();
  83. showInfoLog_dlg(response.result.dlgLogData, response.result.dlgHeaderData);
  84. } else {
  85. dhtmlx.message("Kļūda plānojot");
  86. console.log(response.message);
  87. }
  88. });
  89. request.fail(function (jqXHR, textStatus) {
  90. dhtmlx.message("Kļūda veicot pieprasījumu");
  91. console.log(jqXHR);
  92. console.log(textStatus);
  93. });
  94. }
  95.  
  96.  
  97. function editEmployeeWorkingTime_ajax(taskId, newTimeFromStr, newTimeToStr) {
  98. console.log('{ "taskId":"' + taskId + '", "newTimeFromStr": "' + newTimeFromStr + '", "newTimeToStr": "' + newTimeToStr +'" }')
  99. var axJournalId = $('input[name=_AxJournalId]').val();
  100. var request = $.ajax({
  101. type: "POST",
  102. url: "/Scheduler/UpdateEmployeeWorkingTime?AxJournalId=" + axJournalId,
  103. data: '{ "taskId":"' + taskId + '", "newTimeFromStr": "' + newTimeFromStr + '", "newTimeToStr": "' + newTimeToStr +'" }',
  104. contentType: "application/json; charset=utf-8",
  105. dataType: "json"
  106. })
  107.  
  108. request.done(function (response) {
  109. console.log(response);
  110. if (response.success) {
  111. if (response.result.valid) {
  112. editEmployeeWorkingTime_dlg.dialog("close");
  113. refreshFactsTable_ajax();
  114. refreshSumColumnsData_ajax();
  115. dhtmlx.message(response.result.message);
  116. } else {
  117. showEditEmployeeWorkingTimeFail_dlg("Info", response.message);
  118. }
  119. } else {
  120. editEmployeeWorkingTime_dlg.dialog("close");
  121. showEditEmployeeWorkingTimeFail_dlg("Error", response.message);
  122. }
  123. });
  124. }
  125.  
  126. function manuallyEditTime_ajax(wtTaskId, newTimeFromStr, newTimeToStr, validate) {
  127. var axJournalId = $('input[name=_AxJournalId]').val();
  128. var request = $.ajax({
  129. type: "POST",
  130. url: "/Scheduler/UpdateWorkingTime?AxJournalId=" + axJournalId,
  131. data: '{ "taskId":"' + wtTaskId + '", "newTimeFromStr": "' + newTimeFromStr + '", "newTimeToStr": "' + newTimeToStr +
  132. '", "validate": "' + validate + '" }',
  133. contentType: "application/json; charset=utf-8",
  134. dataType: "json"
  135. });
  136. request.done(function (response) {
  137. if (response.success) {
  138. if (!response.result.valid) {
  139. showCorrectWorkingTime_dlg(wtTaskId, response.result.suggestedTimeFrom, response.result.suggestedTimeTo, response.result.message);
  140. return;
  141. }
  142. var editWorkingTime_dlg = $("#editWorkingTime_dlg").dialog();
  143. editWorkingTime_dlg.dialog("close");
  144. dhtmlx.message("Darbavietas laiks mainīts");
  145. if (!validate) {
  146. refreshSumColumnsData_ajax();
  147. return;
  148. }
  149. clearAndLoadSchedulingData_ajax();
  150. } else {
  151. dhtmlx.message("Kļūda mainot darbalaiku");
  152. console.log(response.message);
  153. }
  154. });
  155. request.fail(function (jqXHR, textStatus) {
  156. dhtmlx.message("Kļūda veicot pieprasījumu");
  157. console.log(jqXHR);
  158. console.log(textStatus);
  159. });
  160. }
  161.  
  162. function manuallyScheduleWorkingTime_ajax(wpStructureId, onDateUnixTimeStamp, period, weekSchedule, includeHolidays) {
  163. var axJournalId = $('input[name=_AxJournalId]').val();
  164. var weekScheduleStringified = JSON.stringify(weekSchedule);
  165. var request = $.ajax({
  166. type: "POST",
  167. url: "/Scheduler/ManuallyScheduleWorkingTime?AxJournalId=" + axJournalId,
  168. data: '{ "wpStructureId":' + wpStructureId + ', "onDateUnixTimeStamp": ' + onDateUnixTimeStamp + ', "period": "' + period +
  169. '", "weekSchedule": ' + weekScheduleStringified + ', "includeHolidays": ' + includeHolidays + ' }',
  170. contentType: "application/json; charset=utf-8",
  171. dataType: "json"
  172. });
  173. request.done(function (response) {
  174. if (response.success) {
  175. dhtmlx.message("Manuālā darbalaika plānošana pabeigta");
  176. refreshSumColumnsData_ajax();
  177. //clearAndLoadSchedulingData_ajax();
  178.  
  179. } else {
  180. dhtmlx.message("Kļūda plānojot");
  181. console.log(response.message);
  182. }
  183. });
  184. request.fail(function (jqXHR, textStatus) {
  185. dhtmlx.message("Kļūda veicot pieprasījumu");
  186. console.log(jqXHR);
  187. console.log(textStatus);
  188. });
  189. }
  190.  
  191. function autoScheduleEmployee_ajax(wtTaskId, emplId, period, templateId) {
  192. var axJournalId = $('input[name=_AxJournalId]').val();
  193. var request = $.ajax({
  194. type: "POST",
  195. url: "/Scheduler/AutoScheduleEmployee?AxJournalId=" + axJournalId,
  196. data: '{ "wtTaskId":' + wtTaskId + ', "emplId": ' + emplId + ', "period": "' + period + '", "templateId": ' + templateId + ' }',
  197. contentType: "application/json; charset=utf-8",
  198. dataType: "json"
  199. });
  200. request.done(function (response) {
  201. if (response.success) {
  202. dhtmlx.message("Plānošana no veidnes pabeigta");
  203. refreshSumColumnsData_ajax();
  204. //clearAndLoadSchedulingData_ajax();
  205. showInfoLog_dlg(response.result.dlgLogData, response.result.dlgHeaderData);
  206. } else {
  207. dhtmlx.message("Kļūda plānojot");
  208. console.log(response.message);
  209. }
  210. });
  211. request.fail(function (jqXHR, textStatus) {
  212. dhtmlx.message("Kļūda veicot pieprasījumu");
  213. console.log(jqXHR);
  214. console.log(textStatus);
  215. });
  216. }
  217.  
  218. function autoScheduleWorkingTime_ajax(wpStructureId, onDateUnixTimeStamp, period, templateId) {
  219. var axJournalId = $('input[name=_AxJournalId]').val();
  220. var request = $.ajax({
  221. type: "POST",
  222. url: "/Scheduler/AutoScheduleWorkingTime?AxJournalId=" + axJournalId,
  223. data: '{ "wpStructureId": ' + wpStructureId + ', "onDateUnixTimeStamp": ' + onDateUnixTimeStamp + ', "period": "' + period + '", "templateId": ' + templateId + ' }',
  224. contentType: "application/json; charset=utf-8",
  225. dataType: "json"
  226. });
  227. request.done(function (response) {
  228. if (response.success) {
  229. dhtmlx.message("Darbalaika plānošana pabeigta");
  230. refreshSumColumnsData_ajax();
  231. // clearAndLoadSchedulingData_ajax();
  232. //scheduler.load("/Scheduler/Data?AxJournalId=" + axJournalId, "json");
  233. //rerenderScheduler(true);
  234. } else {
  235. dhtmlx.message("Kļūda plānojot");
  236. console.log(response.message);
  237. }
  238. });
  239. request.fail(function (jqXHR, textStatus) {
  240. dhtmlx.message("Kļūda veicot pieprasījumu");
  241. console.log(jqXHR);
  242. console.log(textStatus);
  243. });
  244. }
  245.  
  246. function clearAndLoadSchedulingData_ajax() {
  247. var axJournalId = $('input[name=_AxJournalId]').val();
  248. var request = $.ajax({
  249. type: "GET",
  250. url: "/Scheduler/Data?AxJournalId=" + axJournalId,
  251. contentType: "application/json; charset=utf-8",
  252. dataType: "json"
  253. });
  254. request.done(function (response) {
  255. if (response) {
  256. scheduler.clearAll();
  257. scheduler.parse(response.data, "json");
  258.  
  259. //logic for second scheduler
  260. scheduler2.clearAll();
  261. scheduler2.parse(response.data, "json");
  262.  
  263. rerenderScheduler(true);
  264. window.event.preventDefault();
  265. window.event.stopImmediatePropagation();
  266. window.event.stopPropagation();
  267.  
  268. } else {
  269. dhtmlx.message("Kļūda ielādējot datus");
  270. console.log(response.message);
  271. }
  272. });
  273. request.fail(function (jqXHR, textStatus) {
  274. dhtmlx.message("Kļūda veicot pieprasījumu");
  275. console.log(jqXHR);
  276. console.log(textStatus);
  277. });
  278. }
  279. function recalculateAndLoadSchedulingData_ajax() {
  280. var axJournalId = $('input[name=_AxJournalId]').val();
  281. var request = $.ajax({
  282. type: "GET",
  283. url: "/Scheduler/Data?AxJournalId=" + axJournalId + '&Recalc=true',
  284. contentType: "application/json; charset=utf-8",
  285. dataType: "json"
  286. });
  287. request.done(function (response) {
  288. if (response) {
  289. scheduler.clearAll();
  290. scheduler.parse(response.data, "json");
  291. refreshSumColumnsData_ajax();
  292. rerenderScheduler(true);
  293.  
  294. } else {
  295. dhtmlx.message("Kļūda ielādējot datus");
  296. console.log(response.message);
  297. }
  298. });
  299. request.fail(function (jqXHR, textStatus) {
  300. dhtmlx.message("Kļūda veicot pieprasījumu");
  301. console.log(jqXHR);
  302. console.log(textStatus);
  303. });
  304. }
  305.  
  306. function initSumColumnsData_ajax() {
  307. var axJournalId = $('input[name=_AxJournalId]').val();
  308. let res = document.URL;
  309. res = res.split('/Scheduler/Show/');
  310. if (!axJournalId) {
  311. axJournalId = res[1];
  312. }
  313. var request = $.ajax({
  314. type: "POST",
  315. url: "/Scheduler/GetSumColumnData?AxJournalId=" + axJournalId,
  316. contentType: "application/json; charset=utf-8",
  317. dataType: "json"
  318. });
  319. request.done(function (response) {
  320. if (response.success) {
  321. sumColumnsData = response.result.sumColumns;
  322. getCoefficient(sumColumnsData);
  323. executeAfterInit();
  324. executeAfterInit2();
  325. //setSumColumnsValues();
  326. }
  327. if (!response.success) {
  328. dhtmlx.message("Kļūda atjaunojot summas kolonnas");
  329. console.log(response.message);
  330. executeAfterInit();
  331. executeAfterInit2();
  332.  
  333. }
  334. });
  335. request.fail(function (jqXHR, textStatus) {
  336. dhtmlx.message("Kļūda atjaunojot summas kolonnas");
  337. console.log(jqXHR);
  338. console.log(textStatus);
  339. executeAfterInit();
  340. executeAfterInit2();
  341. });
  342. }
  343.  
  344. function refreshSumColumnsData_ajax(rerequest=false) {
  345. var axJournalId = $('input[name=_AxJournalId]').val();
  346.  
  347. var request = $.ajax({
  348. type: "POST",
  349. url: "/Scheduler/GetSumColumnData?AxJournalId=" + axJournalId,
  350. contentType: "application/json; charset=utf-8",
  351. dataType: "json"
  352. });
  353. request.done(function (response) {
  354. if (response.success) {
  355. console.log(sumColumnsData === response.result.sumColumns);
  356. sumColumnsData = response.result.sumColumns;
  357. getCoefficient(sumColumnsData);
  358. if (rerequest) {
  359. refreshSumColumnsData_ajax(false);
  360. }
  361. clearAndLoadSchedulingData_ajax();
  362. }
  363. if (!response.success) {
  364. dhtmlx.message("Kļūda atjaunojot summas kolonnas");
  365. console.log(response.message);
  366. }
  367. });
  368. request.fail(function (jqXHR, textStatus) {
  369. dhtmlx.message("Kļūda atjaunojot summas kolonnas");
  370. console.log(jqXHR);
  371. console.log(textStatus);
  372. // executeAfterInit();
  373. });
  374. }
  375.  
  376. function manualInputSumColumnsData_ajax(structureId, sumColumnParameter, value) {
  377. isFirstRender = false;
  378. value = value.replace(',', '.');
  379. value = parseFloat(value);
  380. var axJournalId = $('input[name=_AxJournalId]').val();
  381.  
  382. var request = $.ajax({
  383. type: "POST",
  384. url: "/Scheduler/SetSumColumnParameter?AxJournalId=" + axJournalId,
  385. data: `{ "refStructureId": '${structureId}', "value": ${value}, "sumColumnParameter": '${sumColumnParameter}'}`,
  386. contentType: "application/json; charset=utf-8",
  387. dataType: "json"
  388. });
  389. request.done(function (response) {
  390. if (response.success) {
  391. dhtmlx.message("Vērtība atjaunota");
  392. refreshSumColumnsData_ajax();
  393. //clearAndLoadSchedulingData_ajax();
  394. }
  395. if (!response.success) {
  396. showManualInputError_dlg(response.message)
  397. console.log(response.message);
  398. }
  399. });
  400. request.fail(function (jqXHR, textStatus) {
  401. dhtmlx.message("Kļūda atjaunojot summas kolonnas");
  402. console.log(jqXHR);
  403. console.log(textStatus);
  404. executeAfterInit();
  405. executeAfterInit2();
  406. });
  407. }
  408.  
  409. function deleteTasks_ajax(callerTaskId, period, mode, includeSiblings) {
  410. var axJournalId = $('input[name=_AxJournalId]').val();
  411. var request = $.ajax({
  412. type: "POST",
  413. url: "/Scheduler/DeleteTasks?AxJournalId=" + axJournalId,
  414. data: '{ "callerTaskId": ' + callerTaskId + ', "period": "' + period + '", "mode": "' + mode + '", includeSiblings:' + includeSiblings + ' }',
  415. contentType: "application/json; charset=utf-8",
  416. dataType: "json"
  417. });
  418. request.done(function (response) {
  419. if (response.success) {
  420. dhtmlx.message("Dzēšana pabeigta");
  421. refreshSumColumnsData_ajax();
  422. //clearAndLoadSchedulingData_ajax();
  423. //rerenderScheduler(true);
  424. } else {
  425. dhtmlx.message("Kļūda dzēšot");
  426. console.log(response.message);
  427. }
  428. });
  429. request.fail(function (jqXHR, textStatus) {
  430. dhtmlx.message("Kļūda veicot pieprasījumu");
  431. console.log(jqXHR);
  432. console.log(textStatus);
  433. });
  434. }
  435.  
  436. function requestFactsTable_ajax(onDateUnixTimeStamp) {
  437. var axJournalId = $('input[name=_AxJournalId]').val();
  438. var request = $.ajax({
  439. type: "POST",
  440. url: "/Scheduler/GenerateFactsTableItems?AxJournalId=" + axJournalId,
  441. data: '{ "onDateUnixTimeStamp": ' + onDateUnixTimeStamp + ' }',
  442. contentType: "application/json; charset=utf-8",
  443. dataType: "json"
  444. });
  445. request.done(function (response) {
  446. if (response.success) {
  447. showFactsTable_dlg(response.result, onDateUnixTimeStamp);
  448. rerenderScheduler(true);
  449. } else {
  450. dhtmlx.message("Kļūda ģenerējot faktu tabulu");
  451. console.log(response.message);
  452. }
  453. });
  454. request.fail(function (jqXHR, textStatus) {
  455. dhtmlx.message("Kļūda veicot pieprasījumu");
  456. console.log(jqXHR);
  457. console.log(textStatus);
  458. });
  459. }
  460.  
  461. function requestSchedulingDates_ajax(onDate, schedulingPeriod, updTarget = "") {
  462. var axJournalId = $('input[name=_AxJournalId]').val();
  463. var onDateUnixTimeStamp = parseInt((new Date(onDate).getTime() / 1000).toFixed(0));
  464. var request = $.ajax({
  465. type: "POST",
  466. url: "/Scheduler/GetSchedulingDates?AxJournalId=" + axJournalId,
  467. data: '{ "SchedulingPeriod": "' + schedulingPeriod + '", "OnDateUnixTimeStamp": ' + onDateUnixTimeStamp + ' }',
  468. contentType: "application/json; charset=utf-8",
  469. dataType: "json"
  470. });
  471. request.done(function (response) {
  472. if (response.success) {
  473. var schedStartDate = new Date(response.result.schedulingStartDate * 1000);
  474. var schedEndDate = new Date(response.result.schedulingEndDate * 1000);
  475. setSchedulingDates(schedStartDate, schedEndDate, updTarget);
  476. rerenderScheduler(true);
  477. } else {
  478. dhtmlx.message("Kļūda pieprasot plānošanas datumus");
  479. console.log(response.message);
  480. }
  481. });
  482. request.fail(function (jqXHR, textStatus) {
  483. dhtmlx.message("Kļūda veicot pieprasījumu");
  484. console.log(jqXHR);
  485. console.log(textStatus);
  486. });
  487. }
  488.  
  489. function requestMenuItems_ajax(callerType, caller, selector, id, onDate, wpStructureId, offsetLeft, offsetTop, screenX, isFrozen = false) {
  490. calculateGlobalOffset();
  491. let currentDate = new Date(onDate);
  492. if ($($(caller)[0].parentElement.parentElement).hasClass('dhx_scell_level0')) {
  493. wpStructureId = getBuildingLevelStructureId();
  494. }
  495. if (screenX) {
  496. //get scheduler offset for fix context menu date
  497. let schedulerContainerOffset = $('#scheduler_here').offset();
  498. let additionalDays = Math.floor((screenX - schedulerContainerOffset.left) / ($('.dhx_marked_timespan').outerWidth()));
  499. currentDate = scheduler._min_date.addDays(additionalDays);
  500. console.log(currentDate);
  501. }
  502.  
  503. var axJournalId = $('input[name=_AxJournalId]').val();
  504. var onDateUnixTimeStamp = parseInt((new Date(currentDate).getTime() / 1000).toFixed(0));
  505. onDateUnixTimeStamp = onDateUnixTimeStamp != undefined ? onDateUnixTimeStamp : "";
  506. wpStructureId = wpStructureId != undefined ? wpStructureId : "0";
  507. var request = $.ajax({
  508. type: "POST",
  509. url: "/Scheduler/GenerateMenuItems?AxJournalId=" + axJournalId,
  510. data: '{ "taskId": ' + id + ', "onDateUnixTimeStamp": ' + onDateUnixTimeStamp + ', "wpStructureId": ' + wpStructureId + ', "caller": "' + callerType + '", "isFrozen": ' + isFrozen + '}',
  511. contentType: "application/json; charset=utf-8",
  512. dataType: "json",
  513. async: true
  514. });
  515. request.done(function (response) {
  516. if (response.success) {
  517. if (response.result) {
  518. showContextMenu(response.result, selector, offsetLeft, offsetTop);
  519. setContextMenuPositionForAsync(caller);
  520. }
  521. }
  522. else {
  523. dhtmlx.message("Kļūda pieprasot izvēlnes saturu");
  524. console.log(response.message);
  525. }
  526. //scrollScheluder();
  527. });
  528. request.fail(function (jqXHR, textStatus) {
  529. dhtmlx.message("Kļūda veicot pieprasījumu");
  530. console.log(jqXHR);
  531. console.log(textStatus);
  532. });
  533. }
  534.  
  535. function requestJournalItems_ajax(wpStructureId, level, dialogName, action) {
  536. var axJournalId = $('input[name=_AxJournalId]').val();
  537. wpStructureId = wpStructureId != undefined ? wpStructureId : "0";
  538. var request = $.ajax({
  539. type: "POST",
  540. url: "/Scheduler/GetJournalItems?AxJournalId=" + axJournalId,
  541. data: '{ "itemType": ' + level + ', "refStructureId" : ' + wpStructureId + ' }',
  542. contentType: "application/json; charset=utf-8",
  543. dataType: "json",
  544. async: false
  545. });
  546. request.done(function (response) {
  547. if (response.success) {
  548. showInsertJourStructure_dlg(response.result, level, dialogName, wpStructureId, action);
  549. rerenderScheduler(true);
  550. }
  551. else {
  552. dhtmlx.message("Kļūda pieprasot žurnāla struktūras elementus");
  553. console.log(response.message);
  554. }
  555. });
  556. request.fail(function (jqXHR, textStatus) {
  557. dhtmlx.message("Kļūda veicot pieprasījumu");
  558. console.log(jqXHR);
  559. console.log(textStatus);
  560. });
  561. }
  562. function addAbsence_ajax(emplId, approveAbsence, dateFromUnixTimeStamp, dateToUnixTimeStamp, absenceId, validateOnly) {
  563. var axJournalId = $('input[name=_AxJournalId]').val();
  564. var request = $.ajax({
  565. type: "POST",
  566. url: "/Scheduler/AddEmplAbsence?AxJournalId=" + axJournalId,
  567. data: `{ "ApproveAbsence": ${approveAbsence}, "ValidateOnly" : ${validateOnly}, "EmplId": ${emplId}, "AbsenceId": ${absenceId},
  568. "DateFromUnixTimeStamp": ${dateFromUnixTimeStamp}, "DateToUnixTimeStamp": ${dateToUnixTimeStamp}}`,
  569. contentType: "application/json; charset=utf-8",
  570. dataType: "json",
  571. async: false
  572. });
  573. request.done(function (response) {
  574. if (!response.success) {
  575. showMessageAbsence3A_dlg(response.message)
  576. return;
  577. }
  578. if (validateOnly) {
  579. if (!response.result.valid) {
  580. //display #2A
  581. showMessageAbsence2A_dlg(response.result.message);
  582. return;
  583. }
  584. //display #2b
  585. showMessageAbsence2B_dlg(emplId, approveAbsence, dateFromUnixTimeStamp, dateToUnixTimeStamp, absenceId, response.result.message);
  586. return;
  587. }
  588. if (!response.result.axSuccess) {
  589. //display #3A
  590. showMessageAbsence3A_dlg(response.result.message)
  591. return;
  592. }
  593. if (response.result.removalLog.length > 0) {
  594. //display #3B
  595. showMessageAbsence3B_dlg(response.result.removalLog);
  596. return;
  597. }
  598.  
  599. dhtmlx.message("Prombūtne pievienota");
  600.  
  601. messageAbsence2B_dlg.dialog("close");
  602. employeeAbsence_dlg.dialog("close");
  603. return;
  604.  
  605. });
  606. request.fail(function (jqXHR, textStatus) {
  607. dhtmlx.message("Kļūda veicot pieprasījumu");
  608. console.log(jqXHR);
  609. console.log(textStatus);
  610. });
  611. }
  612.  
  613. function getAbsenceList_ajax(emplFullName, axEmplId, action, dateStart, emplId) {
  614. var axJournalId = $('input[name=_AxJournalId]').val();
  615. var request = $.ajax({
  616. type: "GET",
  617. url: "/Scheduler/GetAbsences?AxJournalId=" + axJournalId,
  618. contentType: "application/json; charset=utf-8",
  619. dataType: "json",
  620. async: false
  621. });
  622. request.done(function (response) {
  623. if (response.success) {
  624. showEmployeeAbsence_dlg(emplFullName, axEmplId, action, response.result.absences, dateStart, emplId);
  625. }
  626. else {
  627. //dhtmlx.message("Kļūda pieprasot žurnāla struktūras elementus");
  628. console.log(response.message);
  629. }
  630. });
  631. request.fail(function (jqXHR, textStatus) {
  632. dhtmlx.message("Kļūda veicot pieprasījumu");
  633. console.log(jqXHR);
  634. console.log(textStatus);
  635. });
  636. }
  637.  
  638. function wtEmplSchedMove_ajax(taskFromId, taskToId, bidirect, validateOnly) {
  639. var axJournalId = $('input[name=_AxJournalId]').val();
  640.  
  641. var request = $.ajax({
  642. type: "POST",
  643. url: "/Scheduler/WtEmplSchedMove?AxJournalId=" + axJournalId,
  644. data: `{ "taskFromId": '${taskFromId}', "taskToId" : '${taskToId}', "bidirect" : '${bidirect}', "validateOnly" : '${validateOnly}' }`,
  645. contentType: "application/json; charset=utf-8",
  646. dataType: "json",
  647. async: false
  648. });
  649. request.done(function (response) {
  650. if (response.success) {
  651.  
  652. if (!response.result.dlgHeaderData.valid) {
  653. if (response.result.dlgLogData.error.length == 0) {
  654. dhtmlx.message("Kļūda pārvietojot/validējot darbinieku");
  655. return;
  656. }
  657. showError_dlg(response.result.dlgLogData.error);
  658. }
  659. if (response.result.dlgHeaderData.valid) {
  660. if (validateOnly == false) {
  661. refreshSumColumnsData_ajax();
  662. dhtmlx.message("Pārvietošana pabeigta");
  663. }
  664. showConfirm_dlg();
  665. return;
  666. }
  667.  
  668. }
  669. else {
  670. dhtmlx.message("Kļūda pārvietojot/validējot darbinieku");
  671. clearAndLoadSchedulingData_ajax();
  672. console.log(response.message);
  673. }
  674. });
  675. request.fail(function (jqXHR, textStatus) {
  676. dhtmlx.message("Kļūda veicot pieprasījumu");
  677. clearAndLoadSchedulingData_ajax();
  678. console.log(jqXHR);
  679. console.log(textStatus);
  680. });
  681. }
  682.  
  683. function requestUpdateJournalStructure_ajax(updateType, refStructureId, itemId) {
  684. var axJournalId = $('input[name=_AxJournalId]').val();
  685. refStructureId = refStructureId != undefined ? refStructureId : "0";
  686. itemId = itemId != undefined ? itemId : "0";
  687. var request = $.ajax({
  688. type: "POST",
  689. url: "/Scheduler/UpdateJournalStructure?AxJournalId=" + axJournalId,
  690. data: '{ "updateType": "' + updateType + '", "refStructureId": "' + refStructureId + '", "itemId": "' + itemId + '" }',
  691. contentType: "application/json; charset=utf-8",
  692. dataType: "json",
  693. async: false
  694. });
  695. request.done(function (response) {
  696. if (response.success) {
  697. var axJournalId = $('input[name=_AxJournalId]').val();
  698. //scheduler.load("/Scheduler/Data?AxJournalId=" + axJournalId, "json");
  699. if (updateType == 'InsertJourStructure' || updateType == 'InsertAboveJourStructure' || updateType == 'DeleteSection') {
  700. requestGetSchedulerRender(refStructureId);
  701. refreshSumColumnsData_ajax();
  702. return;
  703. }
  704. scheduler2.load("/Scheduler/Data?AxJournalId=" + axJournalId, "json");
  705. //if (updateType !='InsertJourStructure') {
  706. // requestGetSchedulerRender(-1);
  707. // rerenderScheduler(true);
  708. // return;
  709. //}
  710. requestGetSchedulerRender(refStructureId, updateType);
  711. rerenderScheduler(true);
  712. }
  713. else {
  714. dhtmlx.message("Kļūda dzēsot žurnāla struktūras elementus");
  715. console.log(response.message);
  716. }
  717. });
  718. request.fail(function (jqXHR, textStatus) {
  719. dhtmlx.message("Kļūda veicot pieprasījumu");
  720. console.log(jqXHR);
  721. console.log(textStatus);
  722. });
  723. }
  724.  
  725. function requestGetSchedulerRender(refStructureId = null, updateType = null) {
  726. $('#load-page').val(true);
  727. var axJournalId = $('input[name=_AxJournalId]').val();
  728. if (!axJournalId) {
  729. setTimeout(function () {
  730. $('#load-page').val(false);
  731. }, 5000);
  732. return;
  733. }
  734. $.ajax({
  735. type: "POST",
  736. url: "/Scheduler/GetSectionsTree?AxJournalId=" + axJournalId,
  737. success: function (result) {
  738. if (!result.result.length) {
  739. $('.context-menu-root').remove();
  740. scheduler.deleteAllSections();
  741. scheduler2.deleteAllSections();
  742. }
  743. if (!result || !result.success) {
  744. return;
  745. }
  746. result = result.result;
  747.  
  748. var schedulerUnit = scheduler.matrix['timeline'].y_unit_original[0];
  749. createFirstLevel(result, refStructureId, updateType);
  750. var isResponsibleInTree = checkIfEmployeeInTree(filterValue);
  751. if (isResponsibleInTree) { // c20deae1, e65b0308
  752. filterByResponsibleEmployeeId(filterValue);
  753. }
  754. rerenderScheduler(true);
  755. if (!result || $.isEmptyObject(result)) {
  756. $('.dhx_row_folder').remove();
  757. }
  758. setTimeout(function () {
  759. $('#load-page').val(false);
  760. }, 5000);
  761.  
  762. },
  763. error: function (error) {
  764. console.log(error);
  765. }
  766. });
  767. }
  768.  
  769. function getInitialTreePromise() {
  770. return new Promise(function (resolve, reject) {
  771. var axJournalId = $('input[name=_AxJournalId]').val();
  772. if (!axJournalId) {
  773. resolve();
  774. }
  775. else {
  776. $.ajax({
  777. type: "POST",
  778. url: "/Scheduler/GetSectionsTree?AxJournalId=" + axJournalId,
  779. async: false,
  780. success: function (result) {
  781. if (!result || !result.success) {
  782. resolve();
  783. }
  784. else {
  785. if (!result.result.length) {
  786. $('.context-menu-root').remove();
  787. scheduler.deleteAllSections();
  788. scheduler2.deleteAllSections();
  789. }
  790. createFirstLevel(result.result);
  791. var responsibleEmployeeId = $('input[name=_EmplId]').val();
  792. if (responsibleEmployeeId && !isNaN(responsibleEmployeeId)) {
  793. filterValue = parseInt(responsibleEmployeeId);
  794. var isResponsibleInTree = checkIfEmployeeInTree(filterValue);
  795. if (isResponsibleInTree) {
  796. filterByResponsibleEmployeeId(filterValue);
  797. }
  798. }
  799. resolve();
  800. }
  801. },
  802. error: function (error) {
  803. resolve();
  804. console.log(error);
  805. }
  806. });
  807. }
  808. });
  809. }
  810.  
  811. function checkIfEmployeeInTree(responsibleEmployeeId) {
  812. var root = jQuery.extend(true, {}, initialSection);
  813. if (root && root.children) {
  814. return root.children.some(function (department) {
  815. return department.responsibleEmplId === responsibleEmployeeId;
  816. });
  817. }
  818. return false;
  819. }
  820.  
  821. function calculateHoursToPlanPromise(timeStartStr, timeEndStr, emplId, itemCombinationId, onDate) {
  822. return new Promise(function (resolve, reject) {
  823. var axJournalId = $('input[name=_AxJournalId]').val();
  824. if (!axJournalId) {
  825. reject();
  826. }
  827. else {
  828. var request = $.ajax({
  829. type: "POST",
  830. url: "/Scheduler/CalculateHoursToPlan?AxJournalId=" + axJournalId,
  831. data: JSON.stringify({ timeStart: timeStartStr, timeEnd: timeEndStr, emplId: emplId, itemCombinationId: itemCombinationId, onDate: onDate }),
  832. contentType: "application/json; charset=utf-8",
  833. dataType: "json",
  834. async: false
  835. });
  836. request.done(function (response) {
  837. if (response.success) {
  838. resolve(response.result);
  839. }
  840. else {
  841. reject();
  842. }
  843. });
  844. request.fail(function (jqXHR, textStatus) {
  845. reject();
  846. });
  847. }
  848. });
  849. }
  850.  
  851. function calculateNightHoursPromise(timeStartStr, timeEndStr, emplId, itemCombinationId, onDate) {
  852. return new Promise(function (resolve, reject) {
  853. var axJournalId = $('input[name=_AxJournalId]').val();
  854. if (!axJournalId) {
  855. reject();
  856. }
  857. else {
  858. var request = $.ajax({
  859. type: "POST",
  860. url: "/Scheduler/CalculateNightHours?AxJournalId=" + axJournalId,
  861. data: JSON.stringify({ timeStart: timeStartStr, timeEnd: timeEndStr, emplId: emplId, itemCombinationId: itemCombinationId, onDate: onDate }),
  862. contentType: "application/json; charset=utf-8",
  863. dataType: "json",
  864. async: false
  865. });
  866. request.done(function (response) {
  867. if (response.success) {
  868. resolve(response.result);
  869. }
  870. else {
  871. reject();
  872. }
  873. });
  874. request.fail(function (jqXHR, textStatus) {
  875. reject();
  876. });
  877. }
  878. });
  879. }
  880.  
  881. function updateJournalStatusPromise(taskType, toJournalStatusId) {
  882. return new Promise(function (resolve, reject) {
  883. var axJournalId = $('input[name=_AxJournalId]').val();
  884. if (!axJournalId) {
  885. reject();
  886. }
  887. else {
  888. var data = {
  889. taskType: taskType,
  890. toJournalStatusId: toJournalStatusId
  891. };
  892. var request = $.ajax({
  893. type: "POST",
  894. url: "/Scheduler/UpdateJournalStatus?AxJournalId=" + axJournalId,
  895. data: JSON.stringify(data),
  896. contentType: "application/json; charset=utf-8",
  897. dataType: "json",
  898. async: false //add button disabling and change to true??
  899. });
  900. request.done(function (response) {
  901. if (response.success && response.result) {
  902. resolve(response.result);
  903. }
  904. if (!response.success) {
  905. if (response.message) {
  906. showManualInputError_dlg(response.message);
  907. console.log(response.message);
  908. }
  909. if (response.result.axLog) {
  910. showLog_dlg(response.result.axLog);
  911. }
  912.  
  913. reject();
  914. }
  915. });
  916. request.fail(function (jqXHR, textStatus) {
  917. reject();
  918. });
  919. }
  920. });
  921. }
  922. scheduler.contextmenu.js
  923. function generateContextMenu(wpStructureId, date, id, caller, offsetLeft, offsetTop, screenX) {
  924. //if ($(caller).is('.timeline_item_label')) {
  925. if (glSelector != '') {
  926. $.contextMenu('destroy', glSelector);
  927. glSelector = '';
  928. }
  929. var context = $();
  930. var isFrozen = false;
  931. var selector = "";
  932. var callerType = "";
  933. if ($(caller).is('.dhx_time_block')) {
  934. selector = '.dhx_matrix_cell, .dhx_marked_timespan';
  935. //$.contextMenu('destroy', selector);
  936. return;
  937. }
  938. else if (id) { // has task id
  939. if (($(caller).is('.task_schedule')) || ($(caller).is('.conflict_indicator'))) {
  940. selector = '.task_schedule';
  941. callerType = "EmployeeTask";
  942. }
  943. else if ($(caller).is('.task_workplace')) {
  944. selector = '.task_workplace';
  945. callerType = "WorkingTimeTask";
  946. }
  947. }
  948. else if ($(caller).is('.dhx_scale_bar')) {
  949. selector = '.dhx_scale_bar';
  950. callerType = "Scale";
  951. }
  952. else if ($(caller).is('.dhx_matrix_cell, .dhx_marked_timespan')) {
  953. // ja section ir folder section tipa, neizsaukt ctx menu
  954. var workplacesDetails = scheduler.serverList("workplacesDetails");
  955. for (var j = 0; j < workplacesDetails.length; j++) {
  956. if (workplacesDetails[j].key == wpStructureId) {
  957. if (workplacesDetails[j].Level == 4) {
  958. var tasks = scheduler.getEvents(
  959. new Date(date.getFullYear(), date.getMonth(), date.getDate(), 0, 0, 0),
  960. new Date(date.getFullYear(), date.getMonth(), date.getDate(), 23, 59, 59)
  961. );
  962. for (var i = 0; i < tasks.length; i++) { //ja ir tasks ieplanots un menu izsauc no briva darbalaika sanos, neradit
  963. if (tasks[i].StructureId == wpStructureId) {
  964. selector = '.dhx_matrix_cell, .dhx_marked_timespan';
  965. //$.contextMenu('destroy', selector);
  966. }
  967. }
  968. selector = '.dhx_matrix_cell, .dhx_marked_timespan';
  969. callerType = "EmptyDay";
  970. }
  971. else if (workplacesDetails[j].Level == 1) { //ja section folder tipa un veikals, un nav ieplanota struktura, izsaukt
  972. //if (workplacesDetails.length == 1) {
  973. selector = '.dhx_matrix_cell, .dhx_marked_timespan';
  974. callerType = "EmptyDay";
  975. /* } else {
  976. selector = '.dhx_matrix_cell, .dhx_marked_timespan';
  977. $.contextMenu('destroy', selector);
  978. return;
  979. }*/
  980. }
  981. else {
  982. selector = '.dhx_matrix_cell, .dhx_marked_timespan';
  983. //$.contextMenu('destroy', selector);
  984. return;
  985. }
  986. break;
  987. }
  988. }
  989. selector = '.dhx_matrix_cell, .dhx_marked_timespan';
  990. callerType = "EmptyDay";
  991. }
  992. else if (($(caller).is('.timeline_item_label')) || ($(caller).is('.timeline_item_label_line'))) {
  993. selector = '.timeline_item_label';
  994. callerType = "Section";
  995. var workplacesDetails = scheduler.serverList("workplacesDetails");
  996. for (var i = 0; i < workplacesDetails.length; i++) {
  997. if (workplacesDetails[i].key == wpStructureId) {
  998. if (workplacesDetails[i].Level == 1) {
  999. //isFrozen = true / false; todo: set the value here
  1000. }
  1001. }
  1002. }
  1003. }
  1004. else if ($(caller).is('.dhx_cal_data')) {
  1005. if (wpStructureId == undefined) {
  1006. selector = '.dhx_cal_data';
  1007. callerType = "Section";
  1008. }
  1009. else {
  1010. selector = '.dhx_cal_data';
  1011. // $.contextMenu('destroy', selector);
  1012. return;
  1013. }
  1014. }
  1015. if (!wpStructureId) {
  1016. $.contextMenu('destroy');
  1017. } else {
  1018. $.contextMenu('destroy', selector);
  1019. }
  1020. if ($('.dhx_cal_data').hasClass('frozen')) {
  1021. isFrozen = true;
  1022. } else {
  1023. isFrozen = false;
  1024. }
  1025. if (callerType != "" && selector != "") {
  1026. //$.contextMenu('destroy', selector);
  1027. // store a callback on the trigger
  1028. glSelector = selector;
  1029. requestMenuItems_ajax(callerType, caller, selector, id, date, wpStructureId, offsetLeft, offsetTop, screenX, isFrozen);
  1030. }
  1031. }
  1032.  
  1033. function setContextMenuPositionForAsync(caller) {
  1034. var contextMenuElement = $(caller);
  1035. var _offsetHeader = $('#new-header').offset();
  1036. var _offsetHeader2 = $('#new-header2').offset();
  1037. if (!_offsetHeader && !_offsetHeader2) {
  1038. return;
  1039. }
  1040. var _offset = contextMenuElement.offset();
  1041. var topContext = _offset.top + 10;
  1042.  
  1043. if (_offsetHeader.top + 41 > _offset.top) {
  1044. topContext = _offsetHeader.top + 41;
  1045. }
  1046.  
  1047. var position = {
  1048. x: _offset.left + 10,
  1049. y: topContext
  1050. };
  1051. //comment because jquery has an error
  1052. //contextMenuElement.contextMenu(position);
  1053. }
  1054.  
  1055. function showContextMenu(menuItems, selector, offsetLeft, offsetTop ) {
  1056. if ($.isEmptyObject(menuItems)) {
  1057. return;
  1058. }
  1059. $.contextMenu({
  1060. selector: selector,
  1061. className: 'contextmenu-custom',
  1062. items: menuItems,
  1063. callback: executeCtxMenuAction
  1064. });
  1065. setContextmenuWidth(offsetLeft, offsetTop);
  1066. }
  1067.  
  1068. function setContextmenuWidth(offsetLeft, offsetTop ) {
  1069. var context = $('.context-menu-list.context-menu-root');
  1070. if (!context) {
  1071. return;
  1072. }
  1073. if ($(window).height() < offsetTop + context.outerHeight()) {
  1074. offsetTop = offsetTop - context.outerHeight();
  1075. }
  1076. if ($(window).width() < offsetLeft + context.outerWidth()) {
  1077. offsetLeft = offsetLeft - context.outerWidth();
  1078. }
  1079. context.css('display', 'block');
  1080. context.css('left', `${offsetLeft}px`);
  1081. context.css('top', `${offsetTop}px`);
  1082. setBoldSpans();
  1083. //because not all menus removed from html
  1084. for (var index in context) {
  1085. if (isNaN(index)) {
  1086. return;
  1087. }
  1088. var menuRootElement = $(context[index]);
  1089. var firstLevel = menuRootElement.children('.context-menu-item');
  1090. var width = getWidth(firstLevel);
  1091. menuRootElement.css('width', width + 'px');
  1092. setFirstLevel(firstLevel);
  1093. }
  1094. }
  1095.  
  1096. function setBoldSpans() {
  1097. let boldSpans = $(".context-menu-item span:contains('/!\')");
  1098. boldSpans.each(function () {
  1099. spanText = $(this).html();
  1100. let text = spanText.replace("/!", '');
  1101. let newText = text.replace(/\\/g, "");
  1102. $(this).html(newText);
  1103. //$(this).css('font-weight', 'bold');
  1104. //$(this).css('font-size', '0.9em');
  1105. $(this).css('text-shadow', '-0.06ex 0 black, 0.06ex 0 black');
  1106. })
  1107. }
  1108.  
  1109. function setFirstLevel(firstLevel) {
  1110. for (var i = 0; i < firstLevel.length; i++) {
  1111. var list = $(firstLevel[i]).children('.context-menu-list');
  1112. if (list.length === 0) {
  1113. continue;
  1114. }
  1115. var elements = list.children('.context-menu-item');
  1116. var width = getWidth(elements);
  1117. if (width != 0) {
  1118. list.css('width', width + 'px');
  1119. }
  1120. setFirstLevel(elements);
  1121. }
  1122. }
  1123.  
  1124. function getWidth(elements) {
  1125. if (elements.length == 0) {
  1126. return 0;
  1127. }
  1128. var padding = 35;
  1129. var maximumWidth = 0;
  1130. for (var i = 0; i < elements.length; i++) {
  1131. var element = $(elements[i]);
  1132. var span = element.children('span').clone(false)[0];
  1133. if (!span) {
  1134. continue;
  1135. }
  1136. span.setAttribute('style', 'visibility: hidden;position: absolute;font-family: Verdana, Arial, Helvetica, sans-serif;font-size: 11px;');
  1137. document.body.appendChild(span);
  1138. var spanWidth = span.offsetWidth;
  1139. document.body.removeChild(span);
  1140. if (spanWidth > maximumWidth) {
  1141. maximumWidth = spanWidth;
  1142. }
  1143. }
  1144. return maximumWidth + padding;
  1145. }
  1146.  
  1147. function executeCtxMenuAction(key, opt) {
  1148. var menuItemCmd = opt.commands[key];
  1149. var action = menuItemCmd.action;
  1150. console.log(action);
  1151. console.log(menuItemCmd);
  1152.  
  1153. switch (action) {
  1154. case "AddEmployee": {
  1155. if (menuItemCmd.wtTaskId == 0) { // ja izsauc no nodalas, dv izvelnes planot uz menesi, gadijums iespejams
  1156. dhtmlx.message("Darbalaiks vēl nav ieplānots");
  1157. return;
  1158. }
  1159. if (menuItemCmd.templateId == -1) { //ManualEmployeeSchedule.TemplateId const
  1160. showManualEmployeeSchedule_dlg(menuItemCmd.wtTaskId, menuItemCmd.period, menuItemCmd.emplId, menuItemCmd.axEmplId, menuItemCmd.emplFullName, menuItemCmd.planOtherPlaces);
  1161. }
  1162. else {
  1163. autoScheduleEmployee_ajax(menuItemCmd.wtTaskId, menuItemCmd.emplId, menuItemCmd.period, menuItemCmd.templateId);
  1164. }
  1165. break;
  1166. }
  1167. case "DeleteWorkingTime": {
  1168. showDeleteWorkplaceOrWorker_dlg(menuItemCmd.wtTaskId, menuItemCmd.period, action, menuItemCmd.includeSiblings);
  1169. break;
  1170. }
  1171. case "EditWorkingTime": {
  1172. showEditWorkingTime_dlg(menuItemCmd.wtTaskId, menuItemCmd.onDateUnixTimestamp, menuItemCmd.workingTimeFromHHmm, menuItemCmd.workingTimeToHHmm, menuItemCmd.wtName);
  1173. break;
  1174. }
  1175. case "DeleteEmployee": {
  1176. if (menuItemCmd.emplTaskId == 0) { // ja izsauc no nodalas, dv izvelnes dzest uz menesi, gadijums iespejams
  1177. dhtmlx.message("Darbinieks vēl nav ieplānots");
  1178. return;
  1179. }
  1180. var extMsg = '';
  1181. if (menuItemCmd.extMsg) {
  1182. extMsg += "UZMANĪBU tiks dzēsts darbinieks " + menuItemCmd.axEmplId + " " + menuItemCmd.emplFullName
  1183. + " VISAM MĒNESIM no " + menuItemCmd.workplacePath + ". Vai vēlaties turpināt?"
  1184. }
  1185. showDeleteWorkplaceOrWorker_dlg(menuItemCmd.emplTaskId, menuItemCmd.period, action, menuItemCmd.includeSiblings, extMsg);
  1186. break;
  1187. }
  1188. case "AddWorkingTime": {
  1189. if (menuItemCmd.templateId == -1) { //ManualWorkingTimeSchedule.TemplateId const
  1190.  
  1191. showManualWorkingTimeSchedule_dlg(menuItemCmd.wpStructureId, menuItemCmd.onDateUnixTimeStamp, menuItemCmd.period);
  1192. }
  1193. else {
  1194. autoScheduleWorkingTime_ajax(menuItemCmd.wpStructureId, menuItemCmd.onDateUnixTimeStamp, menuItemCmd.period, menuItemCmd.templateId);
  1195. }
  1196. break;
  1197. }
  1198. case "AddEmployeeAbsence": {
  1199. getAbsenceList_ajax(menuItemCmd.emplFullName, menuItemCmd.axEmplId, action, menuItemCmd.dateStart, menuItemCmd.emplId);
  1200. break;
  1201. }
  1202.  
  1203. case "ShowFactsForm": {
  1204. requestFactsTable_ajax(menuItemCmd.onDateUnixTimeStamp);
  1205. break;
  1206. }
  1207. case "UnfreezeSection": {
  1208. $('#freeze-scheduler').val(false);
  1209. unfreezeScheduler();
  1210. synchronizeSchedulersScroll();
  1211. break;
  1212. }
  1213. case "FreezeSection": {
  1214. $('#freeze-scheduler').val(true);
  1215. freezeScheduler(true);
  1216. synchronizeSchedulersScroll();
  1217. break;
  1218. }
  1219. case "InsertJourStructure": {
  1220. requestJournalItems_ajax(menuItemCmd.wpStructureId, menuItemCmd.level, menuItemCmd.name, action);
  1221. break;
  1222. }
  1223. case "InsertAboveJourStructure": {
  1224. requestJournalItems_ajax(menuItemCmd.wpStructureId, menuItemCmd.level, menuItemCmd.name, action);
  1225. break;
  1226. }
  1227. case "MoveAboveJourStructure": {
  1228. isContextBlocked = true;
  1229. requestUpdateJournalStructure_ajax(action, menuItemCmd.wpStructureId, 0);
  1230. asyncBlockContextMenu();
  1231. break;
  1232. }
  1233. case "MoveBelowJourStructure": {
  1234. isContextBlocked = true;
  1235. requestUpdateJournalStructure_ajax(action, menuItemCmd.wpStructureId, 0);
  1236. asyncBlockContextMenu();
  1237. break;
  1238. }
  1239. case "MoveTopJourStructure": {
  1240. isContextBlocked = true;
  1241. requestUpdateJournalStructure_ajax(action, menuItemCmd.wpStructureId, 0);
  1242. asyncBlockContextMenu();
  1243. break;
  1244. }
  1245. case "MoveBottomJourStructure": {
  1246. isContextBlocked = true;
  1247. requestUpdateJournalStructure_ajax(action, menuItemCmd.wpStructureId, 0);
  1248. asyncBlockContextMenu();
  1249. break;
  1250. }
  1251. case "DeleteSection": {
  1252. isContextBlocked = true;
  1253. showDeleteJourSection_dlg(menuItemCmd.level, menuItemCmd.wpStructureId, action);
  1254. asyncBlockContextMenu();
  1255. break;
  1256. }
  1257. case "EditEmployeeTime": {
  1258. isContextBlocked = true;
  1259. //var onDateUnixTimeStamp = new Date(menuItemCmd.onDate).getTime() / 1000;
  1260. showEditEmployeeWorkingTime_dlg(menuItemCmd.taskId, menuItemCmd.onDate, menuItemCmd.timeStart, menuItemCmd.timeEnd, menuItemCmd.emplFullName);
  1261. asyncBlockContextMenu();
  1262. break;
  1263. }
  1264.  
  1265. }
  1266. }
  1267.  
  1268. function freezeScheduler(hide) {
  1269. var isFrozen = JSON.parse($('#freeze-scheduler').val());
  1270. if (!isFrozen) {
  1271. return;
  1272. }
  1273. $('.dhx_cal_data').addClass('frozen');
  1274. addRowScheluder(hide);
  1275. $('.dhx_cal_data').unbind('scroll', scrollScheluder);
  1276. $('.dhx_cal_data').scroll(scrollScheluder);
  1277. //prevent multiple binding
  1278. }
  1279.  
  1280. function addRowScheluder(hide) {
  1281. var rows = $('.dhx_cal_data').find('tr');
  1282. var bodyFirst = $('.dhx_cal_data').find('tbody:first');
  1283. if (rows.length < 3) {
  1284. return;
  1285. }
  1286. if (bodyFirst.length < 1) {
  1287. return;
  1288. }
  1289. var headerExist = checkTable('new-header');
  1290. if (!headerExist) {
  1291. var element = $(rows[0]).clone();
  1292. var elementHtml = $(element[0]);
  1293. elementHtml.attr('id', 'new-header');
  1294. elementHtml.css('position', 'absolute');
  1295. elementHtml.css('z-index', '0');
  1296. elementHtml.css('overflow', 'hidden');
  1297. elementHtml.css('width', $('.dhx_cal_data').outerWidth());
  1298.  
  1299. // $('#new-header').css('width', $('.dhx_cal_date').outerWidth());
  1300. if (rows.length < 3) {
  1301. return;
  1302. }
  1303.  
  1304. var body = $(bodyFirst[0]);
  1305. body.append(elementHtml);
  1306. $(bodyFirst[0]).append(elementHtml);
  1307. if (hide) {
  1308. elementHtml.hide();
  1309. }
  1310. }
  1311.  
  1312. //add header for right scheduler
  1313. var headerExist = checkTable('new-header2');
  1314. if (!headerExist) {
  1315. var secondHeader = $('#new-header2');
  1316. if (secondHeader.length == 0) {
  1317. rows = $('#scheduler_here .dhx_cal_data').find('tr');
  1318. element = $(rows[0]).clone();
  1319. elementHtml = $(element[0]);
  1320. elementHtml.attr('id', 'new-header2');
  1321. elementHtml.css('position', 'absolute');
  1322. elementHtml.css('z-index', '0');
  1323. elementHtml.css('overflow', 'hidden');
  1324. elementHtml.css('width', $('#scheduler_here .dhx_cal_data').outerWidth());
  1325.  
  1326. body = $(bodyFirst[1]);
  1327. body.append(elementHtml);
  1328. $(bodyFirst[1]).append(elementHtml);
  1329. if (hide) {
  1330. elementHtml.hide();
  1331. }
  1332. }
  1333. }
  1334.  
  1335. scrollScheluder();
  1336. }
  1337.  
  1338. function checkTable(headerId) {
  1339. var flag = false;
  1340. var rows = $('.dhx_cal_data').find('tr');
  1341. for (var i = 0; i < rows.length; i++) {
  1342. var attributeId = $(rows[i]).attr('id');
  1343. if (attributeId && attributeId == headerId) {
  1344. flag = true;
  1345. break;
  1346. }
  1347. }
  1348. return flag;
  1349. }
  1350.  
  1351. function scrollScheluder() {
  1352. var rows = $('.dhx_cal_data').find('tr');
  1353. if (rows.length < 3) {
  1354. return;
  1355. }
  1356. var element = $('#new-header');
  1357. if (element.length == 0) {
  1358. addRowScheluder(true);
  1359. return;
  1360. }
  1361. var secondElement = $(rows[2]);
  1362. if (element.length)
  1363. var top = element.offset().top;
  1364.  
  1365. var secondTop = secondElement.offset().top;
  1366. var scroll = $('#scheduler2_here .dhx_cal_data').scrollTop();
  1367. var elementTop = scroll;
  1368. if (secondTop < 243 || scroll > 0) {
  1369. element.show();
  1370. element.css('top', elementTop + 'px');
  1371. }
  1372. var elemendColumns = element.find('td');
  1373. var column = elemendColumns.length > 2 ? $(elemendColumns[1]) : null;
  1374. if (column) {
  1375. column.addClass('disabled-frozen');
  1376. }
  1377. if (secondTop >= 243) {
  1378. element.hide();
  1379. if (column) {
  1380. column.removeClass('disabled-frozen');
  1381. }
  1382. }
  1383.  
  1384. //config for header of right scheduler
  1385. var rows = $('#scheduler_here .dhx_cal_data').find('tr');
  1386. if (rows.length < 3) {
  1387. return;
  1388. }
  1389. var element = $('#new-header2');
  1390. if (element.length == 0) {
  1391. addRowScheluder(true);
  1392. return;
  1393. }
  1394.  
  1395. var secondElement = $(rows[2]);
  1396. if (element.length)
  1397. var top = element.offset().top;
  1398.  
  1399. var secondTop = secondElement.offset().top;
  1400. var scroll = $('#scheduler_here .dhx_cal_data').scrollTop();
  1401. var elementTop = scroll;
  1402. if (secondTop < 243 || scroll > 0) {
  1403. element.show();
  1404. element.css('top', elementTop + 'px');
  1405. }
  1406. var elemendColumns = element.find('td');
  1407. var column = elemendColumns.length > 2 ? $(elemendColumns[1]) : null;
  1408. if (column) {
  1409. column.addClass('disabled-frozen');
  1410. }
  1411. if (secondTop >= 243) {
  1412. element.hide();
  1413. if (column) {
  1414. column.removeClass('disabled-frozen');
  1415. }
  1416. }
  1417. }
  1418.  
  1419. function unfreezeScheduler() {
  1420. $('.dhx_cal_data').removeClass('frozen');
  1421. $('.dhx_cal_data').unbind('scroll');
  1422. $(window).unbind('scroll');
  1423. var rows = $('.dhx_cal_data').find('tr');
  1424. if (rows.length < 3) {
  1425. return;
  1426. }
  1427. var element = $('#new-header');
  1428. element.hide();
  1429. var elemendColumns = element.find('td');
  1430. var column = elemendColumns.length > 2 ? $(elemendColumns[1]) : null;
  1431. if (column) {
  1432. column.removeClass('disabled-frozen');
  1433. }
  1434.  
  1435. //right scheduler header
  1436. element = $('#new-header2');
  1437. element.hide();
  1438. elemendColumns = element.find('td');
  1439. column = elemendColumns.length > 2 ? $(elemendColumns[1]) : null;
  1440. if (column) {
  1441. column.removeClass('disabled-frozen');
  1442. }
  1443.  
  1444. clearInterval(interval);
  1445. interval = null;
  1446. }
  1447. scheduler.dialogs.js
  1448. $(document).ready(function () {
  1449.  
  1450. $(document).on('click', '.columnItem', function (e) {
  1451. let items = $('.columnItem');
  1452. for (var i = 0; i < items.length; i++) {
  1453. $(items[i]).removeClass('selectedCol');
  1454. }
  1455. if ($(e.target).is('label')) {
  1456. $(e.currentTarget).addClass('selectedCol');
  1457. }
  1458. });
  1459.  
  1460. $('#employeeAbsence_dlg').on('dialogclose', function (event) {
  1461. $('#isApproved').prop('checked', false);
  1462. $('.dateStart').datepicker().val('');
  1463. $('.dateEnd').datepicker().val('');
  1464. });
  1465.  
  1466. $('#messageAbsence2A_dlg').on('dialogclose', function (event) {
  1467. $(this).empty();
  1468. });
  1469.  
  1470. $('#messageAbsence2B_dlg').on('dialogclose', function (event) {
  1471. let inputs = $(this).find('input');
  1472. $(this).empty();
  1473. $(this).append(inputs);
  1474. });
  1475.  
  1476. $('#messageAbsence3A_dlg').on('dialogclose', function (event) {
  1477. $(this).empty();
  1478. });
  1479.  
  1480. $('#messageAbsence3B_dlg').on('dialogclose', function (event) {
  1481. $(this).empty();
  1482. });
  1483.  
  1484. $('.up').click(function () {
  1485. let selectedItem = $('.selectedCol');
  1486. if (selectedItem) {
  1487. setPositionUp(selectedItem)
  1488. }
  1489. });
  1490.  
  1491. $('.down').click(function () {
  1492. let selectedItem = $('.selectedCol');
  1493. if (selectedItem) {
  1494. setPositionDown(selectedItem)
  1495. }
  1496. });
  1497.  
  1498. $(".allownumeric").on("keypress keyup blur", function (event) {
  1499. if ((event.which != 46 || $(this).val().indexOf('.') != -1) && ((event.which != 44 && event.which < 48) || event.which > 57)) {
  1500. event.preventDefault();
  1501. }
  1502. });
  1503.  
  1504. $(document).on('click', '.dhx_scell_level1 .dhx_scell_name', function () {
  1505. setOffsetLevel2();
  1506. });
  1507.  
  1508. $(document).on('click', '.timeline_item_cell', function (e) {
  1509. e.preventDefault();
  1510. });
  1511.  
  1512. $(document).on('mouseover', '.timeline_item_header', function () {
  1513. $(document).tooltip({ tooltipClass: "tooltipMaster" });
  1514. }).mousemove(function (e) {
  1515. var mousex = e.pageX + 10;
  1516. var mousey = e.pageY + 5;
  1517. $('.tooltipMaster')
  1518. .css({ top: mousey, left: mousex })
  1519. });
  1520.  
  1521. $(document).on('mouseover', '.timeline_item_cell', function () {
  1522. $(document).tooltip({ tooltipClass: "tooltipMaster" });
  1523. }).mousemove(function (e) {
  1524. var mousex = e.pageX + 10;
  1525. var mousey = e.pageY + 5;
  1526. $('.tooltipMaster')
  1527. .css({ top: mousey, left: mousex })
  1528. });
  1529. });
  1530.  
  1531. async function bindLabelClick() {
  1532. let res = await bindLabelClickAsync();
  1533. }
  1534.  
  1535. function deleteContext() {
  1536. return new Promise(function (resolve) {
  1537. for (var i = 0; i < 1; i++) {
  1538. setTimeout(() => {
  1539. var res = $('.context-menu-list.context-menu-root');
  1540. if (res.length > 1) {
  1541. for (var i = 0; i <= res.length - 2; i++) {
  1542. res[i].remove();
  1543. }
  1544. }
  1545. resolve('resolved');
  1546. }, 700);
  1547. }
  1548. });
  1549. }
  1550.  
  1551. function bindLabelClickAsync() {
  1552. return new Promise(function (resolve) {
  1553. setTimeout(() => {
  1554. let res = $('.timeline_item_label')[0];
  1555.  
  1556. $(res).on('dblclick', function (event) {
  1557. let wpStructureId = getWorkplacesDetails(event);
  1558. sumColumnParameter = 'WorkLoad';
  1559. showManualInput_dlg(wpStructureId, sumColumnParameter, null);
  1560. });
  1561. resolve('resolved');
  1562. }, 2500);
  1563. });
  1564. };
  1565.  
  1566. function setOffsetLevel2() {
  1567. let items = $('.dhx_scell_level2 .dhx_scell_name');
  1568. if (items) {
  1569. for (var i = 0; i < items.length; i++) {
  1570. if (i % 2 == 0) {
  1571. let el = items[i].childNodes[0];
  1572. $(el).css('margin-left', '-1px');
  1573. }
  1574.  
  1575. }
  1576. }
  1577. }
  1578.  
  1579. //async function initSumColumnsDataAsync() {
  1580. // let result = await initSumColumnsData();;
  1581. //}
  1582. function initSumColumnsDataAsync() {
  1583. return new Promise(function (resolve, reject) {
  1584. initSumColumnsData().then(function () {
  1585. }, reject);
  1586. });
  1587. }
  1588.  
  1589. function initSumColumnsData() {
  1590. return new Promise(resolve => {
  1591. setTimeout(() => {
  1592. initSumColumnsData_ajax();
  1593. }, 400);
  1594. });
  1595. }
  1596.  
  1597. function createSumRow(column, rowData, rowHtml, key) {
  1598. rowHtml = `${sumColumnsBody[column]} 0 <span style='font-weight: normal; display: block'> 0 </span></div>`;
  1599. if (!rowData) {
  1600. return `${sumColumnsBody[column]} <span style='font-weight: normal; display: block'> </span></div>`;
  1601. }
  1602. if (column == 'sCol1') {
  1603. rowHtml = sumColumnsBody[column] + `${rowData.BudgetHours == null ? '' : rowData.BudgetHours} <span style='font-weight: normal; display: block'>${rowData.WorkLoadAmount == null ? '' : rowData.WorkLoadAmount}</span> </div> `;
  1604. }
  1605. if (column == 'sCol2') {
  1606. rowHtml = sumColumnsBody[column] + `${rowData.BudgetAmount == null ? '' : rowData.BudgetAmount} </div> `;
  1607. }
  1608. if (column == 'sCol3') {
  1609. rowHtml = sumColumnsBody[column] + `${rowData.AmountPlanned == null ? '' : rowData.AmountPlanned} <span style='font-weight: normal; display: block'>${rowData.AmountPlannedMinusBudget == null ? '' : rowData.AmountPlannedMinusBudget}</span></div> `;
  1610. }
  1611. if (column == 'sCol4') {
  1612. rowHtml = sumColumnsBody[column] + `${rowData.AmountActual == null ? '' : rowData.AmountActual} <span style='font-weight: normal; display: block'>${rowData.AmountActualMinusPlanned == null ? '' : rowData.AmountActualMinusPlanned}</span></div> `;
  1613. }
  1614. if (column == 'sCol5') {
  1615. rowHtml = sumColumnsBody[column] + `${rowData.PublicHolidaysAmount == null ? '' : rowData.PublicHolidaysAmount} <span style='font-weight: normal; display: block'>${rowData.PublicHolidaysHours == null ? '' : rowData.PublicHolidaysHours}</span></div> `;
  1616. }
  1617. if (column == 'sCol6') {
  1618. rowHtml = sumColumnsBody[column] + `${rowData.OvertimeAmount == null ? '' : rowData.OvertimeAmount} <span style='font-weight: normal; display: block'>${rowData.OvertimeHours == null ? '' : rowData.OvertimeHours}</span></div> `;
  1619. }
  1620. if (column == 'sCol7') {
  1621. rowHtml = sumColumnsBody[column] + `${rowData.BonusAmount == null ? '' : rowData.BonusAmount} </div> `;
  1622. }
  1623. if (column == 'sCol8') {
  1624. rowHtml = sumColumnsBody[column] + `${rowData.SickLeaveAmount == null ? '' : rowData.SickLeaveAmount} </div> `;
  1625. }
  1626. if ((column == 'sCol9') && (rowData.Level < 4)) {
  1627. rowHtml = sumColumnsBody[column] + `${rowData.HoursPlannedPrevMonth == null ? '' : rowData.HoursPlannedPrevMonth} <span style='font-weight: normal; display: block'>${rowData.HoursPlannedMinusPrevMonth == null ? 0 + ' / ' : rowData.HoursPlannedMinusPrevMonth + ' / '} ${rowData.HoursPlannedMinusPrevMonthPercent == null ? 0 : rowData.HoursPlannedMinusPrevMonthPercent}</span></div> `;
  1628. }
  1629. if ((column == 'sCol9') && (rowData.Level > 3)) {
  1630. rowHtml = sumColumnsBody[column] + `${rowData.HoursPlannedPrevMonth == null ? '' : rowData.HoursPlannedPrevMonth} </div> `;
  1631. }
  1632. if ((column == 'sCol10') && (rowData.Level < 4)) {
  1633. rowHtml = sumColumnsBody[column] + `${rowData.HoursPlannedPrevYear == null ? '' : rowData.HoursPlannedPrevYear} <span style='font-weight: normal; display: block'>${rowData.HoursPlannedMinusPrevYear == null ? 0 + ' / ' : rowData.HoursPlannedMinusPrevYear + ' / '} ${rowData.HoursPlannedMinusPrevYearPercent == null ? 0 : rowData.HoursPlannedMinusPrevYearPercent}</span></div> `;
  1634. }
  1635. if ((column == 'sCol10') && (rowData.Level > 3)) {
  1636. rowHtml = sumColumnsBody[column] + `${rowData.HoursPlannedPrevYear == null ? '' : rowData.HoursPlannedPrevYear} </div> `;
  1637. }
  1638. if ((column == 'sCol11') && (rowData.Level < 4)) {
  1639. rowHtml = sumColumnsBody[column] + `${rowData.WpHoursPlanned == null ? 0 : rowData.WpHoursPlanned} <span style='font-weight: normal; display: block'>${rowData.WpHoursPlannedMinusBudgetHours == null ? 0 + ' / ' : rowData.WpHoursPlannedMinusBudgetHours + ' / '} ${rowData.WpHoursPlannedWorkLoad == null ? 0 : rowData.WpHoursPlannedWorkLoad}</span></div> `;
  1640. }
  1641. if ((column == 'sCol11') && (rowData.Level > 3)) {
  1642. rowHtml = sumColumnsBody[column] + `${rowData.WpHoursPlanned == null ? 0 : rowData.WpHoursPlanned} </div> `;
  1643. }
  1644. if ((column == 'sCol12') && (rowData.Level < 4)) {
  1645. rowHtml = sumColumnsBody[column] + `${rowData.EmplHoursPlanned == null ? '' : rowData.EmplHoursPlanned} <span style='font-weight: normal; display: block'>${rowData.EmplMinusWpHoursPlanned == null ? 0 : rowData.EmplMinusWpHoursPlanned}</span></div> `;
  1646. }
  1647. if ((column == 'sCol12') && (rowData.Level > 3)) {
  1648. rowHtml = sumColumnsBody[column] + `${rowData.EmplHoursPlanned == null ? 0 + ' / ' : rowData.EmplHoursPlanned + ' / '} ${rowData.EmplMinusWpHoursPlanned == null ? 0 : rowData.EmplMinusWpHoursPlanned}</div> `;
  1649. }
  1650. if ((column == 'sCol13') && (rowData.Level < 4)) {
  1651. rowHtml = sumColumnsBody[column] + `${rowData.EmplHoursActual == null ? '' : rowData.EmplHoursActual} <span style='font-weight: normal; display: block'>${rowData.EmplHoursActualMinusPlanned == null ? 0 : rowData.EmplHoursActualMinusPlanned}</span></div> `;
  1652. }
  1653. if ((column == 'sCol13') && (rowData.Level > 3)) {
  1654. rowHtml = sumColumnsBody[column] + `${rowData.EmplHoursActual == null ? 0 + ' / ' : rowData.EmplHoursActual + ' / '} ${rowData.EmplHoursActualMinusPlanned == null ? 0 : rowData.EmplHoursActualMinusPlanned}</div> `;
  1655. }
  1656.  
  1657. return rowHtml;
  1658. }
  1659.  
  1660. function setTitles() {
  1661. var timelineItemCells = $('.timeline_item_cell');
  1662.  
  1663. for (var i = 0; i < timelineItemCells.length; i++) {
  1664. var cellItem = $(timelineItemCells[i]);
  1665. if ((cellItem[0].offsetParent) && (cellItem[0].attributes[1].nodeValue == "")) {
  1666.  
  1667. if (cellItem.hasClass('sCol1') && (cellItem[0].offsetParent.firstChild) && (cellItem[0].offsetParent.firstChild.className != "dhx_scell_level2")) {
  1668. cellItem.attr('title', 'Budžeta stundu un slodžu skaits');
  1669. }
  1670.  
  1671. if (cellItem.hasClass('sCol2') && (cellItem[0].offsetParent.firstChild) && (cellItem[0].offsetParent.firstChild.className == "dhx_scell_level1") && (cellItem[0].offsetParent.firstChild.className != "dhx_scell_level0")) {
  1672. cellItem.attr('title', 'Ēkas budžets EUR');
  1673. }
  1674.  
  1675. if (cellItem.hasClass('sCol3') && (cellItem[0].offsetParent.firstChild) && (cellItem[0].offsetParent.firstChild.className == "dhx_scell_level0")) {
  1676. cellItem.attr('title', 'Plānotā summa EUR, starpība ar Budžetu EUR');
  1677. }
  1678.  
  1679. if (cellItem.hasClass('sCol3') && (cellItem[0].offsetParent.firstChild) && (cellItem[0].offsetParent.firstChild.className == "dhx_scell_level1")) {
  1680. cellItem.attr('title', 'Plānotā summa EUR');
  1681. }
  1682.  
  1683. if (cellItem.hasClass('sCol4') && (cellItem[0].offsetParent.firstChild) && (cellItem[0].offsetParent.firstChild.className != "dhx_scell_level2")) {
  1684. cellItem.attr('title', 'Faktiskā summa EUR, starpība ar Plānoto summu EUR');
  1685. }
  1686.  
  1687. if (cellItem.hasClass('sCol5') && (cellItem[0].offsetParent.firstChild) && (cellItem[0].offsetParent.firstChild.className != "dhx_scell_level2")) {
  1688. cellItem.attr('title', 'Svētku dienās ieplānotā summa EUR un stundas');
  1689. }
  1690.  
  1691. if (cellItem.hasClass('sCol6') && (cellItem[0].offsetParent.firstChild) && (cellItem[0].offsetParent.firstChild.className != "dhx_scell_level2")) {
  1692. cellItem.attr('title', 'Virsstundu summa EUR un stundu skaits');
  1693. }
  1694.  
  1695. if (cellItem.hasClass('sCol7') && (cellItem[0].offsetParent.firstChild) && (cellItem[0].offsetParent.firstChild.className != "dhx_scell_level2")) {
  1696. cellItem.attr('title', 'Prēmiju summa EUR');
  1697. }
  1698.  
  1699. if (cellItem.hasClass('sCol8') && (cellItem[0].offsetParent.firstChild) && (cellItem[0].offsetParent.firstChild.className != "dhx_scell_level2")) {
  1700. cellItem.attr('title', 'Slimības lapu summa EUR');
  1701. }
  1702.  
  1703. if (cellItem.hasClass('sCol9') && (cellItem[0].offsetParent.firstChild) && (cellItem[0].offsetParent.firstChild.className != "dhx_scell_level2")) {
  1704. cellItem.attr('title', 'Iepriekšējā mēneša plānotās stundas, starpība ar šo mēnesi, izmaiņas %');
  1705. }
  1706.  
  1707. if (cellItem.hasClass('sCol10') && (cellItem[0].offsetParent.firstChild) && (cellItem[0].offsetParent.firstChild.className != "dhx_scell_level2")) {
  1708. cellItem.attr('title', 'Iepriekšējā gada plānotās stundas šim mēnesim, starpība ar šo mēnesi, izmaiņas %');
  1709. }
  1710.  
  1711. if (cellItem.hasClass('sCol11') && (cellItem[0].offsetParent.firstChild) && (cellItem[0].offsetParent.firstChild.className != "dhx_scell_level2")) {
  1712. cellItem.attr('title', 'Plānotās posteņu stundas, starpība ar budžeta stundām, slodžu skaits');
  1713. }
  1714.  
  1715. if (cellItem.hasClass('sCol11') && (cellItem[0].offsetParent.firstChild) && (cellItem[0].offsetParent.firstChild.className == "dhx_scell_level2")) {
  1716. cellItem.attr('title', 'Plānotās posteņu stundas');
  1717. }
  1718.  
  1719. if (cellItem.hasClass('sCol12')) {
  1720. cellItem.attr('title', 'Plānotās darbinieku stundas, starpība ar posteņu stundām');
  1721. }
  1722.  
  1723. if (cellItem.hasClass('sCol13')) {
  1724. cellItem.attr('title', 'Faktiskās darbinieku stundas, starpība ar posteņu stundām');
  1725. }
  1726. }
  1727. }
  1728. clearTooltips();
  1729.  
  1730. }
  1731.  
  1732. function setPositionUp(selectedItem) {
  1733. let items = $('.columnItem');
  1734. for (let i = 0; i < items.length; i++) {
  1735. if (selectedItem.is(items[i]) && ((i - 1) >= 0)) {
  1736. let copyTo = $(items[i - 1]).clone(true);
  1737. let copyFrom = $(selectedItem).clone(true);
  1738. $(items[i - 1]).replaceWith(copyFrom);
  1739. $(selectedItem).replaceWith(copyTo);
  1740. }
  1741. }
  1742. }
  1743.  
  1744. function setPositionDown(selectedItem) {
  1745. let items = $('.columnItem');
  1746. for (var i = 0; i < items.length; i++) {
  1747. if (selectedItem.is(items[i]) && ((i + 1) <= items.length - 1)) {
  1748. let copyTo = $(items[i + 1]).clone(true);
  1749. let copyFrom = $(selectedItem).clone(true);
  1750. $(items[i + 1]).replaceWith(copyFrom);
  1751. $(selectedItem).replaceWith(copyTo);
  1752. }
  1753. }
  1754. }
  1755.  
  1756. function showInfoLog_dlg(logJson, dlgHeaderData) {
  1757. var templateName = dlgHeaderData.templateName;
  1758. var axEmplId = dlgHeaderData.axEmplId;
  1759. var emplFullName = dlgHeaderData.emplFullName;
  1760. var dateFrom = dlgHeaderData.dateFrom;
  1761. var dateTo = dlgHeaderData.dateTo;
  1762. var infoLogOptions = {
  1763. "title": "Plānot darbinieku - '" + axEmplId + "' " + emplFullName + "; Grafiks: " + templateName + "; Periods: " + dateFrom + "-" + dateTo + "",
  1764. "width": 900,
  1765. "height": 300,
  1766. "modal": false,
  1767. "close": function () { $(this).remove(); }
  1768. };
  1769. infoLogOptions.buttons = { "Aizvērt": function () { $(this).dialog("close"); } };
  1770. var infoLogExtendOptions = {
  1771. "resizable": true,
  1772. "closable": false,
  1773. "minimizable": true,
  1774. "collapsable": true,
  1775. "minimizeLocation": "right",
  1776. "dblclick": "minimize",
  1777. "icons": {
  1778. // "close": "ui-icon-circle-closethick", //todo:
  1779. "maximize": "ui-icon-extlink",
  1780. "minimize": "ui-icon-minus",
  1781. "restore": "ui-icon-newwin"
  1782. }
  1783. };
  1784. var errorEntries = logJson["error"];
  1785. var infoEntries = logJson["info"];
  1786. var infoLog_dlg = $("<div />").dialog(infoLogOptions).dialogExtend(infoLogExtendOptions);
  1787. infoLog_dlg.append("<b>Uzmanību! Netika ieplānots:</b><br />");
  1788. errorEntries.forEach(function (entry) {
  1789. infoLog_dlg.append("<span class='error-log-entry'>&nbsp;" + entry.msg + "</span><br />");
  1790. });
  1791. infoLog_dlg.append("<b>Ieplānotie darbinieki:</b><br />");
  1792. infoEntries.forEach(function (entry) {
  1793. infoLog_dlg.append("<span class='info-log-entry'>&nbsp;" + entry.msg + "</span><br />");
  1794. });
  1795. }
  1796.  
  1797. function showLog_dlg(logJson) {
  1798.  
  1799. var infoLogOptions = {
  1800. "title": "Kļūda mainot vērtību",
  1801. "width": 450,
  1802. "height": 300,
  1803. "modal": false,
  1804. "close": function () { $(this).remove(); }
  1805. };
  1806. infoLogOptions.buttons = { "Aizvērt": function () { $(this).dialog("close"); } };
  1807. var infoLogExtendOptions = {
  1808. "resizable": true,
  1809. "closable": false,
  1810. "minimizable": true,
  1811. "collapsable": true,
  1812. "minimizeLocation": "right",
  1813. "dblclick": "minimize",
  1814. "icons": {
  1815. // "close": "ui-icon-circle-closethick", //todo:
  1816. "maximize": "ui-icon-extlink",
  1817. "minimize": "ui-icon-minus",
  1818. "restore": "ui-icon-newwin"
  1819. }
  1820. };
  1821. var errorEntries = logJson.filter(el => el.level == 'Error');
  1822. var infoEntries = logJson.filter(el => el.level == 'Info');
  1823. var infoLog_dlg = $("<div />").dialog(infoLogOptions).dialogExtend(infoLogExtendOptions);
  1824.  
  1825. errorEntries.forEach(function (entry) {
  1826. let errorLog = "<span class='error-log-entry'>&nbsp;" + entry.msgLines + "</span><br />"
  1827. errorLog = errorLog.replace(/\,/g, ' <span class="ui-icon ui-icon-arrowthick-1-e journal-status-dialog-arrow"></span> ');
  1828.  
  1829. infoLog_dlg.append(`<b>${entry.level}</b><br />`);
  1830.  
  1831. infoLog_dlg.append(errorLog);
  1832. });
  1833. infoEntries.forEach(function (entry) {
  1834. let errorLog = "<span class='error-log-entry'>&nbsp;" + entry.msgLines + "</span><br />"
  1835. errorLog = errorLog.replace(/\,/g, ' <span class="ui-icon ui-icon-arrowthick-1-e journal-status-dialog-arrow"></span> ');
  1836.  
  1837. infoLog_dlg.append(`<b>${entry.level}</b><br />`);
  1838.  
  1839. infoLog_dlg.append(errorLog);
  1840. });
  1841. }
  1842. function showLogInfo_dlg(logJson) {
  1843.  
  1844. var infoLogOptions = {
  1845. "title": "Kļūda mainot vērtību",
  1846. "width": 450,
  1847. "height": 300,
  1848. "modal": true,
  1849. "close": function () { $(this).remove(); }
  1850. };
  1851. infoLogOptions.buttons = {
  1852. "Aizvērt": function () {
  1853. $(this).dialog("close");
  1854. }
  1855. };
  1856. var infoLogExtendOptions = {
  1857. "resizable": true,
  1858. "closable": false,
  1859. "minimizable": true,
  1860. "collapsable": true,
  1861. "minimizeLocation": "right",
  1862. "dblclick": "minimize",
  1863. "icons": {
  1864. // "close": "ui-icon-circle-closethick", //todo:
  1865. "maximize": "ui-icon-extlink",
  1866. "minimize": "ui-icon-minus",
  1867. "restore": "ui-icon-newwin"
  1868. }
  1869. };
  1870.  
  1871. var infoLog_dlg = $("<div />").dialog(infoLogOptions).dialogExtend(infoLogExtendOptions);
  1872.  
  1873. logJson.forEach(function (entry) {
  1874. let errorLog = "<span class='error-log-entry'>&nbsp;" + entry.msg + "</span><br />"
  1875.  
  1876. infoLog_dlg.append(errorLog);
  1877. });
  1878. }
  1879.  
  1880. function showSumColumns_dlg() {
  1881. let sumColumnsFilter = localStorage.getItem('sumColumnsUserFilter');
  1882. if (sumColumnsFilter) {
  1883. let userFilter = jsonToObject(sumColumnsFilter);
  1884. let items = $('.columnItem');
  1885. let sortedElements = new Array(13);
  1886.  
  1887. for (var i = 0; i < items.length; i++) {
  1888. for (var j = 0; j < items.length; j++) {
  1889. if (items[j].children[0].name == userFilter[0][i].colId) {
  1890. let l1 = items[j].children[0].name;
  1891. let r1 = userFilter[0][i].colId;
  1892. items[j].children[0].checked = userFilter[0][i].isVisible;
  1893. sortedElements[userFilter[0][i].sortOrder] = items[j];
  1894. }
  1895. }
  1896. }
  1897. $('.columnItem').remove();
  1898. for (var i = 0; i < sortedElements.length; i++) {
  1899. $('.columnsList').append(sortedElements[i]);
  1900. }
  1901. }
  1902. sumColumns_dlg.dialog("open");
  1903. }
  1904.  
  1905. function showManualInput_dlg(structureId, sumColumnParameter, currentValue) {
  1906.  
  1907. var dlg = $('#manualInput_dlg');
  1908. dlg.dialog({ title: "Ievadīt vērtību" });
  1909. if (sumColumnParameter == 'WorkLoad') {
  1910. dlg.dialog({ title: "Ievadīt slodzes koeficienta vērtību" });
  1911. dlg.find('input[name=sumColumnValue]').val(workLoadCoefficient);
  1912. }
  1913. if (currentValue || currentValue == 0) {
  1914. dlg.find('input[name=sumColumnValue]').val(currentValue);
  1915. }
  1916. dlg.find('input[name=structureId]').val(structureId);
  1917. dlg.find('input[name=sumColumnParameter]').val(sumColumnParameter);
  1918. manualInput_dlg.dialog("open");
  1919. }
  1920.  
  1921. function mapToJson(map) {
  1922. return JSON.stringify([map]);
  1923. }
  1924. function jsonToObject(jsonStr) {
  1925. return JSON.parse(jsonStr);
  1926. }
  1927.  
  1928. function showManualInputError_dlg(message) {
  1929.  
  1930. var infoLogOptions = {
  1931. "title": "Kļūda mainot vērtību",
  1932. "width": 450,
  1933. "height": 300,
  1934. "modal": false,
  1935. "close": function () { $(this).remove(); }
  1936. };
  1937. infoLogOptions.buttons = { "Aizvērt": function () { $(this).dialog("close"); } };
  1938. var infoLogExtendOptions = {
  1939. "resizable": true,
  1940. "closable": false,
  1941. "minimizable": true,
  1942. "collapsable": true,
  1943. "minimizeLocation": "right",
  1944. "dblclick": "minimize",
  1945. "icons": {
  1946. "maximize": "ui-icon-extlink",
  1947. "minimize": "ui-icon-minus",
  1948. "restore": "ui-icon-newwin"
  1949. }
  1950. };
  1951.  
  1952. var infoLog_dlg = $("<div />").dialog(infoLogOptions).dialogExtend(infoLogExtendOptions);
  1953. let errorLog = message;
  1954. if (message.constructor === Array) {
  1955. errorLog = '';
  1956. for (var i = 0; i < message.length; i++) {
  1957.  
  1958. errorLog += `<b> ${message[i].level} </b> </br >${message[i].msgLines.map(el => el)} `;
  1959. }
  1960. errorLog = errorLog.replace(/\,/g, '&nbsp;');
  1961. }
  1962. infoLog_dlg.append(errorLog);
  1963. }
  1964.  
  1965. function showEditWorkingTime_dlg(wtTaskId, onDateUnixTimeStamp, fromDate, toDate, wtName) {
  1966. console.log("showEditWorkingTime_dlg");
  1967. var onDate = new Date(onDateUnixTimeStamp * 1000);
  1968. var dateFormat = onDate.ddmmyyyy();
  1969. var dlg = $('#editWorkingTime_dlg');
  1970. dlg.find('input[name=wtTaskId]').val(wtTaskId);
  1971. dlg.find('input[name=datums]').val(dateFormat);
  1972. dlg.find('input[name=datums]').prop('disabled', true);
  1973. dlg.find('input[name=timeFrom]').val(fromDate);
  1974. dlg.find('input[name=timeTo]').val(toDate);
  1975. dlg.dialog({ title: "Plānot darba vietu (" + wtName + ")" });
  1976. editWorkingTime_dlg.dialog("open");
  1977. }
  1978.  
  1979.  
  1980.  
  1981.  
  1982. function showEditEmployeeWorkingTime_dlg(taskId, onDate, fromDate, toDate, employeeName) {
  1983. var dlg = $('#editEmployeeWorkingTime_dlg');
  1984. dlg.find('input[name=wtTaskId]').val(taskId);
  1985. dlg.find('input[name=datums]').val(onDate);
  1986. dlg.find('input[name=datums]').prop('disabled', true);
  1987. dlg.find('input[name=timeFrom]').val(fromDate);
  1988. dlg.find('input[name=timeTo]').val(toDate);
  1989. dlg.dialog({ title: "Edit employee working time (" + employeeName + ")" });
  1990. editEmployeeWorkingTime_dlg.dialog("open");
  1991. }
  1992.  
  1993. function showEditEmployeeWorkingTimeFail_dlg(title, message) {
  1994. var dlg = $('#editEmployeeWorkingTimeFail_dlg');
  1995. dlg.dialog({ title: title });
  1996. dlg.append(message);
  1997. editEmployeeWorkingTimeFail_dlg.dialog("open");
  1998. }
  1999.  
  2000. function showCorrectWorkingTime_dlg(wtTaskId, fromDate, toDate, message) {
  2001. console.log("showCorrectWorkingTime_dlg");
  2002. var dlg = $('#correctWorkingTime_dlg');
  2003. dlg.find('.info p').remove();
  2004. dlg.find('.info').append(`<p>${message}</p>`);
  2005. dlg.find('input[name=wtTaskId]').val(wtTaskId);
  2006. dlg.find('input[name=timeFrom]').val(fromDate);
  2007. dlg.find('input[name=timeTo]').val(toDate);
  2008. dlg.dialog({ title: "Apstiprināt darbalaika maiņu" });
  2009. correctWorkingTime_dlg.dialog("open");
  2010. }
  2011.  
  2012. function showManualWorkingTimeSchedule_dlg(wpStructureId, onDateUnixTimeStamp, period) {
  2013. var onDate = new Date(onDateUnixTimeStamp * 1000);
  2014. var dateFormat = onDate.ddmmyyyy();
  2015. var workplaceItemPath = "";
  2016. var workplacesDetails = scheduler.serverList("workplacesDetails");
  2017. for (var i = 0; i < workplacesDetails.length; i++) {
  2018. if (workplacesDetails[i].key == wpStructureId) {
  2019. workplaceItemPath += workplacesDetails[i].WorkplacePath;
  2020. break;
  2021. }
  2022. }
  2023. var dlg = $('#manualWtScheduling_dlg');
  2024. dlg.find('input[name=wpStructureId]').attr('value', wpStructureId);
  2025. dlg.find('input[name=onDateUnixTimeStamp]').attr('value', onDateUnixTimeStamp);
  2026. dlg.find('input[name=period]').attr('value', period);
  2027. requestSchedulingDates_ajax(onDate, period, 'manualWtScheduling_dlg');
  2028. dlg.dialog({ title: "Manuāls grafiks - " + workplaceItemPath });
  2029. manualWtScheduling_dlg.dialog("open");
  2030. }
  2031. function clearSumColumnsManualinput() {
  2032. var dlg = $('#manualInput_dlg');
  2033. dlg.find('input[name=structureId]').val('');
  2034. dlg.find('input[name=sumColumnParameter]').val('');
  2035. dlg.find('input[name=sumColumnValue]').val('');
  2036. }
  2037.  
  2038. function showFactsTable_dlg(factsTableJson, onDateUnixTimeStamp) {
  2039. $('#factsEntry_dlg_journalIdHolder').text(factsTableJson.tableHeaderData.journal.journalId);
  2040. $('#factsEntry_dlg_mainOrgUnitHolder').text(factsTableJson.tableHeaderData.journal.mainOrgUnit);
  2041. $('#factsEntry_dlg_periodHolder').text(factsTableJson.tableHeaderData.journal.period);
  2042. $('#factsEntry_dlg_dateHolder').text(factsTableJson.tableHeaderData.onDate);
  2043. createFactsTable(factsTableJson.factsTableContent, onDateUnixTimeStamp);
  2044. factsEntry_dlg.dialog("open");
  2045. }
  2046.  
  2047. function showInsertJourStructure_dlg(journalItems, itemType, dialogName, wpStructureId, action) {
  2048. createJourStructureList(journalItems, itemType);
  2049. insertJourStructure_dlg.dialog('option', 'title', dialogName);
  2050. var dlg = $('#insertJourStructure_dlg');
  2051. dlg.find('input[name=refStructureId]').attr('value', wpStructureId);
  2052. dlg.find('input[name=action]').attr('value', action);
  2053. insertJourStructure_dlg.dialog("open");
  2054. }
  2055.  
  2056. function showEmployeeAbsence_dlg(emplFullName, axEmplId, action, absences, dateStart, emplId) {
  2057.  
  2058. employeeAbsence_dlg.dialog('option', 'title', `Ievadīt prombūtni ${emplFullName}: ${axEmplId == null ? '' : axEmplId}`);
  2059.  
  2060. var dlg = $('#employeeAbsence_dlg');
  2061.  
  2062. if (dateStart === "") {
  2063. $('.dateStart').datepicker({ defaultDate: new Date(scheduler._min_date) }).val('');
  2064. $('.dateEnd').datepicker({ defaultDate: new Date(scheduler._max_date) }).val('');
  2065.  
  2066. }
  2067. else {
  2068. $('.dateStart').datepicker().val(dateStart);
  2069. var dateSplit = dateStart.split('.');
  2070. var date = new Date(dateSplit[1] + '.' + dateSplit[0] + '.' + dateSplit[2]);
  2071.  
  2072. $('.dateEnd').datepicker({ defaultDate: date }).val('');
  2073. }
  2074.  
  2075.  
  2076. dlg.find('input[name=emplId]').attr('value', emplId);
  2077. //dlg.find('input[name=action]').attr('value', action);
  2078. employeeAbsence_dlg.dialog("open");
  2079. createAbsenceList(absences);
  2080. }
  2081.  
  2082. function showDeleteJourSection_dlg(itemLevel, wpStructureId, action) {
  2083. var questionMessage = "";
  2084. if (itemLevel == 1) {
  2085. questionMessage += "Vai tiešām dzēst ēku/veikalu?"
  2086. }
  2087. if (itemLevel == 3) {
  2088. questionMessage += "Vai tiešām dzēst nodaļu?"
  2089. }
  2090. if (itemLevel == 4) {
  2091. questionMessage += "Kopā ar darbavietu tiks dzēsti arī visi darbavietas ieplānotie darbinieki. Vai tiešām dzēst darbavietu?";
  2092. }
  2093. deleteJourSection_dlg.dialog('option', 'title', "Apstiprināt dzēšanu");
  2094. var dlg = $('#deleteJourSection_dlg');
  2095. dlg.find('input[name=refStructureId]').attr('value', wpStructureId);
  2096. dlg.find('input[name=action]').attr('value', action);
  2097. dlg.find('span[name=questionMessage]').text(questionMessage);
  2098. deleteJourSection_dlg.dialog("open");
  2099. }
  2100.  
  2101. function showDeleteWorkplaceOrWorker_dlg(callerTaskId, period, action, includeSiblings, extMsg) {
  2102. var questionMessage = "";
  2103. if (action == "DeleteWorkingTime") {
  2104. questionMessage += "Vai tiešām dzēst darbavietu?"
  2105. }
  2106. if (action == "DeleteEmployee") {
  2107. if (extMsg != '')
  2108. questionMessage += extMsg;
  2109. else
  2110. questionMessage += "Vai tiešām dzēst darbinieku?"
  2111. }
  2112. deleteWorkplaceOrWorker_dlg.dialog('option', 'title', "Apstiprināt dzēšanu");
  2113. var dlg = $('#deleteWorkplaceOrWorker_dlg');
  2114. dlg.find('input[name=callerTaskId]').attr('value', callerTaskId);
  2115. dlg.find('input[name=period]').attr('value', period);
  2116. dlg.find('input[name=action]').attr('value', action);
  2117. dlg.find('input[name=includeSiblings]').attr('value', includeSiblings);
  2118. dlg.find('span[name=questionMessage]').text(questionMessage);
  2119. deleteWorkplaceOrWorker_dlg.dialog("open");
  2120. }
  2121. function showDragOrWorker_dlg(emplTasksCount_target, taskId_source, taskId_target) {
  2122. $('input[name=cb1]').prop('checked', false);
  2123. $('input[name=cb2]').prop('checked', false);
  2124.  
  2125. var dlg = $('#dragWorker_dlg');
  2126. if (emplTasksCount_target == 1) {
  2127. $('input[name=cb1]').prop('checked', true);
  2128. }
  2129. if (emplTasksCount_target == 0) {
  2130. $('input[name=cb2]').prop('disabled', true);
  2131. $('input[name=cb1]').prop('disabled', true);
  2132. $('input[name=cb2]').prop('checked', true);
  2133. }
  2134.  
  2135. dlg.find('input[name=taskId_target]').val(taskId_target);
  2136. dlg.find('input[name=taskId_source]').val(taskId_source);
  2137.  
  2138. dragWorker_dlg.dialog("open");
  2139. }
  2140.  
  2141. function showMessageAbsence3A_dlg(message) {
  2142. messageAbsence3A_dlg.dialog('option', 'title', 'Informācija');
  2143. let dlg = $('#messageAbsence3A_dlg');
  2144. dlg.append(message);
  2145.  
  2146. messageAbsence3A_dlg.dialog("open");
  2147. }
  2148.  
  2149. function showMessageAbsence3B_dlg(messageLog) {
  2150. messageAbsence3B_dlg.dialog('option', 'title', 'Darbinieks izņemts');
  2151. let dlg = $('#messageAbsence3B_dlg');
  2152.  
  2153. messageLog.forEach(function (item) {
  2154. dlg.append(item + '<br/>');
  2155. });
  2156. messageAbsence3B_dlg.dialog("open");
  2157. }
  2158.  
  2159. function showMessageAbsence2A_dlg(message) {
  2160.  
  2161. messageAbsence2A_dlg.dialog('option', 'title', 'Informācija');
  2162. let dlg = $('#messageAbsence2A_dlg');
  2163. dlg.append(message + '</br>')
  2164.  
  2165. messageAbsence2A_dlg.dialog("open");
  2166. }
  2167.  
  2168. function showMessageAbsence2B_dlg(emplId, approveAbsence, dateFromUnixTimeStamp, dateToUnixTimeStamp, absenceId, message) {
  2169.  
  2170. messageAbsence2B_dlg.dialog('option', 'title', 'Turpināt');
  2171.  
  2172. let dlg = $('#messageAbsence2B_dlg');
  2173. dlg.find('input[name=emplId]').val(emplId);
  2174. dlg.find('input[name=approveAbsence]').val(approveAbsence);
  2175. dlg.find('input[name=dateFromUnixTimeStamp]').val(dateFromUnixTimeStamp);
  2176. dlg.find('input[name=dateToUnixTimeStamp]').val(dateToUnixTimeStamp);
  2177. dlg.find('input[name=absenceId]').val(absenceId);
  2178. dlg.append(message + '</br>');
  2179. messageAbsence2B_dlg.dialog("open");
  2180. }
  2181. function showConfirm_dlg(confirmTitle, confirmText) {
  2182. var dlg = $('#dragWorker_dlg');
  2183. var confirmText = dlg.find('input[name=confirmText]').val();
  2184. $("#confirm_dlg .info p br").remove();
  2185. $("#confirm_dlg .info p").remove();
  2186. var dlg = $('#confirm_dlg');
  2187. dlg.find('.info').append(`<p>${confirmText}</p>`);
  2188. confirm_dlg.dialog("open");
  2189. }
  2190.  
  2191. function showError_dlg(errors) {
  2192. var confirmText = '';
  2193. for (let error of errors) {
  2194. confirmText += `<p>${error.msg}</p>`;
  2195. }
  2196. var dlg = $('#error_dlg');
  2197. error_dlg.dialog('option', 'title', 'Pārvietošana nav atļauta');
  2198. dlg.find('.info').append(confirmText);
  2199. error_dlg.dialog("open");
  2200. }
  2201.  
  2202. function createJourStructureList(journalItems, level) {
  2203. var select = $('#insertJourStructure_dlg_itemTable');
  2204. select.empty();
  2205. var option = document.createElement('option');
  2206. option.value = 0;
  2207. option.setAttribute('disabled', '');
  2208. option.setAttribute('selected', 'true');
  2209. if (level == 1) {
  2210. option.innerHTML = 'Ēka/veikals - Nosaukums';
  2211. }
  2212. if (level == 3) {
  2213. option.innerHTML = 'Nodaļa - Nosaukums';
  2214. }
  2215. if (level == 4) {
  2216. option.innerHTML = 'Darbavieta - Nosaukums';
  2217. }
  2218. select.append(option);
  2219. journalItems.forEach(function (item) {
  2220. var option = document.createElement('option');
  2221. option.value = item.ItemId;
  2222. option.innerHTML = item.AxItemId + ' - ' + item.Name;
  2223. select.append(option);
  2224. });
  2225. }
  2226.  
  2227. function createAbsenceList(absenceItems) {
  2228. var select = $('#absenceList');
  2229. select.empty();
  2230. var option = document.createElement('option');
  2231. option.value = 0;
  2232. option.setAttribute('disabled', '');
  2233. option.setAttribute('selected', 'true');
  2234. option.innerHTML = 'Prombūtnes veids – Prombūtnes veida nosaukums';
  2235. select.append(option);
  2236. absenceItems.forEach(function (item) {
  2237. var option = document.createElement('option');
  2238. option.value = item.AbsenceId;
  2239. option.innerHTML = item.AxAbsenceId + ' - ' + item.AxName;
  2240. select.append(option);
  2241. });
  2242. }
  2243.  
  2244. function setSchedulingDates(schedStartDate, schedEndDate, updTarget) {
  2245. var schedulingStartDateTxt = schedStartDate.ddmmyyyy();
  2246. var schedulingEndDateTxt = schedEndDate.ddmmyyyy();
  2247.  
  2248. switch (updTarget) {
  2249. case "manualScheduling_dlg": {
  2250. $('#manualScheduling_dlg_dateFrom').text(schedulingStartDateTxt);
  2251. $('#manualScheduling_dlg_dateTo').text(schedulingEndDateTxt);
  2252. break;
  2253. }
  2254. case "manualWtScheduling_dlg": {
  2255. $('#manualWtScheduling_dlg_dateFrom').text(schedulingStartDateTxt);
  2256. $('#manualWtScheduling_dlg_dateTo').text(schedulingEndDateTxt);
  2257. break;
  2258. }
  2259. }
  2260. }
  2261.  
  2262. function showManualEmployeeSchedule_dlg(wtTaskId, period, emplId, axEmplId, emplFullName, planOtherPlaces) {
  2263. var wtTask = scheduler.getEvent(wtTaskId);
  2264. var dateFormat = new Date(wtTask.DateTimeStart).ddmmyyyy();
  2265. var dlgTitle = "Plānot darbinieku";
  2266. var dlg = $('#manualScheduling_dlg');
  2267. dlg.find('input[name=wtTaskId]').attr('value', wtTaskId);
  2268. dlg.find('input[name=period]').attr('value', period);
  2269. dlg.find('input[name=emplId]').attr('value', emplId);
  2270. if (planOtherPlaces) {
  2271. var planOtherPlacesCb = dlg.find('input[name=cb1]');
  2272. planOtherPlacesCb.prop('checked', true);
  2273. planOtherPlacesCb.prop('disabled', true);
  2274. planOtherPlacesCb.prop('readonly', true);
  2275. }
  2276. requestSchedulingDates_ajax(wtTask.DateTimeStart, period, 'manualScheduling_dlg');
  2277. $('#manualScheduling_dlg_workplaceHolder').text(wtTask.WorkplacePath);
  2278. dlgTitle += (' (' + emplFullName + ': ' + axEmplId + ')');
  2279. dlg.dialog({ title: dlgTitle });
  2280. manualScheduling_dlg.dialog("open");
  2281. }
  2282.  
  2283. function runManualEmployeeScheduling() {
  2284. var dlg = $('#manualScheduling_dlg');
  2285. var wtTaskId = dlg.find('input[name=wtTaskId]').val();
  2286. var period = dlg.find('input[name=period]').val();
  2287. var emplId = dlg.find('input[name=emplId]').val();
  2288. var wd1 = parseInt(dlg.find('input[name=wd1]').val());
  2289. var hd1 = parseInt(dlg.find('input[name=hd1]').val());
  2290. var wd2 = parseInt(dlg.find('input[name=wd2]').val());
  2291. var hd2 = parseInt(dlg.find('input[name=hd2]').val());
  2292. if (wd1 == NaN) { wd1 = 0; }
  2293. if (hd1 == NaN) { hd1 = 0; }
  2294. if (wd2 == NaN) { wd2 = 0; }
  2295. if (hd2 == NaN) { hd2 = 0; }
  2296. if (hd1 + hd2 == 0) {
  2297. dhtmlx.message("Ievadiet vismaz vienu darbadienu šablonā!");
  2298. return;
  2299. }
  2300. var planOtherPlaces = dlg.find('input[name=cb1]:checked').length > 0;
  2301. var fromTemplateStart = dlg.find('input[name=cb2]:checked').length > 0;
  2302. manualScheduling_dlg.dialog("close");
  2303. resetFields_ManualEmplSchedDlg();
  2304. manuallyScheduleEmployee_ajax(wtTaskId, emplId, period, wd1, hd1, wd2, hd2, planOtherPlaces, fromTemplateStart);
  2305. }
  2306.  
  2307. function resetFields_ManualEmplSchedDlg() {
  2308. var dlg = $('#manualScheduling_dlg');
  2309. dlg.find('input[name=wd1]').val('');
  2310. dlg.find('input[name=hd1]').val('');
  2311. dlg.find('input[name=wd2]').val('');
  2312. dlg.find('input[name=hd2]').val('');
  2313. dlg.find('input[name=cb2]').prop('checked', false);
  2314.  
  2315. var planOtherPlacesCb = dlg.find('input[name=cb1]');
  2316. planOtherPlacesCb.prop('disabled', false);
  2317. planOtherPlacesCb.prop('readonly', false);
  2318. //planOtherPlacesCb.removeProp('disabled'); //dbl check
  2319. //planOtherPlacesCb.removeProp('readonly'); //dbl check
  2320. planOtherPlacesCb.prop('checked', false);
  2321. }
  2322.  
  2323. function runManualWorkingTimeScheduling() {
  2324. var dlg = $('#manualWtScheduling_dlg');
  2325. var wpStructureId = dlg.find('input[name=wpStructureId]').val();
  2326. var onDateUnixTimeStamp = dlg.find('input[name=onDateUnixTimeStamp]').val();
  2327. var period = dlg.find('input[name=period]').val();
  2328. var weekSchedule = [];
  2329. for (let dayNr = 1; dayNr <= 7; dayNr++) {
  2330. var schedOnDay = dlg.find('input[name=sched-' + dayNr + ']:checked').length > 0;
  2331. if (schedOnDay) {
  2332. var timeFromStr = dlg.find('input[name=timeFrom-' + dayNr + ']').val();
  2333. var timeToStr = dlg.find('input[name=timeTo-' + dayNr + ']').val();
  2334. if (!isTime(timeFromStr) || !isTime(timeToStr)) {
  2335. dhtmlx.message("Ievadiet laiku formātā hh:mm");
  2336. return;
  2337. }
  2338. /*if (timeFromStr == timeToStr && timeToStr != "00:00") {
  2339. dhtmlx.message("Laiks no nevar būt vienāds ar laiku līdz");
  2340. return;
  2341. }
  2342. if (timeFromStr > timeToStr && timeToStr != "00:00") {
  2343. dhtmlx.message("Laikam no jābūt mazākam kā laikam līdz");
  2344. return;
  2345. }*/
  2346. var timeFromHHmm = timeFromStr.split(":");
  2347. var timeFromHours = timeFromHHmm[0];
  2348. var timeFromMinutes = timeFromHHmm[1];
  2349. var timeToHHmm = timeToStr.split(":");
  2350. var timeToHours = timeToHHmm[0];
  2351. var timeToMinutes = timeToHHmm[1];
  2352. if (timeToStr == "00:00" || timeToStr == "24:00")
  2353. timeToStr = "23:59";
  2354. var dayObj = {};
  2355. dayObj.dayNr = dayNr;
  2356. dayObj.timeToStr = timeToStr;
  2357. dayObj.timeFromStr = timeFromStr;
  2358. weekSchedule.push(dayObj);
  2359. }
  2360. }
  2361. var includeHolidays = dlg.find('input[name=includeHolidays]:checked').length > 0;
  2362. manualWtScheduling_dlg.dialog("close");
  2363. manuallyScheduleWorkingTime_ajax(wpStructureId, onDateUnixTimeStamp, period, weekSchedule, includeHolidays);
  2364. resetFields_ManualWtSchedDlg();
  2365. }
  2366. function resetFields_DragOrWorker_dlg() {
  2367. var dlg = $('#dragWorker_dlg');
  2368.  
  2369. dlg.find('input[name=cb1]').prop('checked', false);
  2370. dlg.find('input[name=cb2]').prop('checked', false);
  2371. dlg.find('input[name=cb2]').prop('disabled', false);
  2372. dlg.find('input[name=cb1]').prop('disabled', false);
  2373. }
  2374.  
  2375.  
  2376. function runEditEmployeeWorkingTime() {
  2377. var dlg = $('#editEmployeeWorkingTime_dlg');
  2378. var taskId = dlg.find('input[name=wtTaskId]').val();
  2379. var newTimeFromStr = dlg.find('input[name=timeFrom]').val();
  2380. var newTimeToStr = dlg.find('input[name=timeTo]').val();
  2381. editEmployeeWorkingTime_ajax(taskId, newTimeFromStr, newTimeToStr);
  2382. }
  2383.  
  2384. function runManualEditTime() {
  2385. var dlg = $('#editWorkingTime_dlg');
  2386. var wtTaskId = dlg.find('input[name=wtTaskId]').val();
  2387. var newTimeFromStr = dlg.find('input[name=timeFrom]').val();
  2388. var newTimeToStr = dlg.find('input[name=timeTo]').val();
  2389.  
  2390. if (newTimeFromStr > newTimeToStr && newTimeToStr != "00:00") {
  2391. dhtmlx.message("Laikam no jābūt mazākam kā laikam līdz");
  2392. return;
  2393. }
  2394. if (newTimeFromStr == newTimeToStr && newTimeToStr != "00:00") {
  2395. dhtmlx.message("Laiks no nevar būt vienāds ar laiku līdz");
  2396. return;
  2397. }
  2398. if (newTimeToStr == "00:00" || newTimeToStr == "24:00")
  2399. newTimeToStr = "23:59";
  2400. manuallyEditTime_ajax(wtTaskId, newTimeFromStr, newTimeToStr, true);
  2401. }
  2402.  
  2403. function resetFields_ManualWtSchedDlg() {
  2404. var dlg = $('#manualWtScheduling_dlg');
  2405. for (let dayNr = 1; dayNr <= 7; dayNr++) {
  2406. var defaultTime = "00:00";
  2407. dlg.find('input[name=sched-' + dayNr + ']').prop('checked', false);
  2408. dlg.find('input[name=timeFrom-' + dayNr + ']').val(defaultTime);
  2409. dlg.find('input[name=timeTo-' + dayNr + ']').val(defaultTime);
  2410. }
  2411. dlg.find('input[name=includeHolidays]').prop('checked', false);
  2412. dlg.find('input[name=manualWtSched_TimeFrom]').val(defaultTime);
  2413. dlg.find('input[name=manualWtSched_TimeTo]').val(defaultTime);
  2414. dlg.find('#manualWtSched_WorkingDaysCb').prop('checked', false);
  2415. dlg.find('#manualWtSched_WeekendsCb').prop('checked', false);
  2416. dlg.find('#manualWtSched_AllDaysCb').prop('checked', false);
  2417. }
  2418.  
  2419. function inputInfoForConfirmDlg(confirmTitle, confirmText) {
  2420. $('#dragWorker_dlg').find('input[name=confirmText]').val(confirmText);
  2421. $('#confirm_dlg').dialog('option', 'title', confirmTitle);
  2422. }
  2423.  
  2424. $(function () {
  2425.  
  2426. // on manual wt sched dialog checkbox clicks
  2427. $('#manualWtSched_WorkingDaysCb').change(function () {
  2428. var dlg = $('#manualWtScheduling_dlg');
  2429. if (this.checked) {
  2430. var timeFromValue = dlg.find('input[name=manualWtSched_TimeFrom]').val();
  2431. var timeToValue = dlg.find('input[name=manualWtSched_TimeTo]').val();
  2432. for (let dayNr = 1; dayNr <= 5; dayNr++) {
  2433. dlg.find('input[name=sched-' + dayNr + ']').prop('checked', true);
  2434. dlg.find('input[name=timeFrom-' + dayNr + ']').val(timeFromValue);
  2435. dlg.find('input[name=timeTo-' + dayNr + ']').val(timeToValue);
  2436. }
  2437. for (let dayNr = 6; dayNr <= 7; dayNr++) {
  2438. //dlg.find('input[name=sched-' + dayNr + ']').prop('checked', false);
  2439. }
  2440. //$('#manualWtSched_WeekendsCb').prop('checked', false);
  2441. //$('#manualWtSched_AllDaysCb').prop('checked', false);
  2442. }
  2443. else {
  2444. for (let dayNr = 1; dayNr <= 5; dayNr++) {
  2445. var defaultTime = "00:00";
  2446. dlg.find('input[name=sched-' + dayNr + ']').prop('checked', false);
  2447. dlg.find('input[name=timeFrom-' + dayNr + ']').val(defaultTime);
  2448. dlg.find('input[name=timeTo-' + dayNr + ']').val(defaultTime);
  2449. }
  2450. }
  2451. });
  2452.  
  2453. $('#manualWtSched_WeekendsCb').change(function () {
  2454. var dlg = $('#manualWtScheduling_dlg');
  2455. if (this.checked) {
  2456. var timeFromValue = dlg.find('input[name=manualWtSched_TimeFrom]').val();
  2457. var timeToValue = dlg.find('input[name=manualWtSched_TimeTo]').val();
  2458. for (let dayNr = 6; dayNr <= 7; dayNr++) {
  2459. dlg.find('input[name=sched-' + dayNr + ']').prop('checked', true);
  2460. dlg.find('input[name=timeFrom-' + dayNr + ']').val(timeFromValue);
  2461. dlg.find('input[name=timeTo-' + dayNr + ']').val(timeToValue);
  2462. }
  2463. for (let dayNr = 1; dayNr <= 5; dayNr++) {
  2464. //dlg.find('input[name=sched-' + dayNr + ']').prop('checked', false);
  2465. }
  2466. //$('#manualWtSched_WorkingDaysCb').prop('checked', false);
  2467. //$('#manualWtSched_AllDaysCb').prop('checked', false);
  2468. }
  2469. else {
  2470. for (let dayNr = 6; dayNr <= 7; dayNr++) {
  2471. var defaultTime = "00:00";
  2472. dlg.find('input[name=sched-' + dayNr + ']').prop('checked', false);
  2473. dlg.find('input[name=timeFrom-' + dayNr + ']').val(defaultTime);
  2474. dlg.find('input[name=timeTo-' + dayNr + ']').val(defaultTime);
  2475. }
  2476. }
  2477. });
  2478.  
  2479. $('#manualWtSched_AllDaysCb').change(function () {
  2480. var dlg = $('#manualWtScheduling_dlg');
  2481. if (this.checked) {
  2482. var timeFromValue = dlg.find('input[name=manualWtSched_TimeFrom]').val();
  2483. var timeToValue = dlg.find('input[name=manualWtSched_TimeTo]').val();
  2484. for (let dayNr = 1; dayNr <= 7; dayNr++) {
  2485. dlg.find('input[name=sched-' + dayNr + ']').prop('checked', true);
  2486. dlg.find('input[name=timeFrom-' + dayNr + ']').val(timeFromValue);
  2487. dlg.find('input[name=timeTo-' + dayNr + ']').val(timeToValue);
  2488. }
  2489. //$('#manualWtSched_WorkingDaysCb').prop('checked', false);
  2490. //$('#manualWtSched_WeekendsCb').prop('checked', false);
  2491. }
  2492. else {
  2493. for (let dayNr = 1; dayNr <= 7; dayNr++) {
  2494. var defaultTime = "00:00";
  2495. dlg.find('input[name=sched-' + dayNr + ']').prop('checked', false);
  2496. dlg.find('input[name=timeFrom-' + dayNr + ']').val(defaultTime);
  2497. dlg.find('input[name=timeTo-' + dayNr + ']').val(defaultTime);
  2498. }
  2499. }
  2500. });
  2501.  
  2502. manualScheduling_dlg = $("#manualScheduling_dlg").dialog({
  2503. closeOnEscape: true,
  2504. open: function (event, ui) {
  2505. $(".ui-dialog-titlebar-close", ui.dialog | ui).hide();
  2506. },
  2507. autoOpen: false,
  2508. height: 500,
  2509. width: 600,
  2510. modal: true,
  2511. buttons: {
  2512. "Plānot": runManualEmployeeScheduling,
  2513. "Atcelt": function () {
  2514. manualScheduling_dlg.dialog("close");
  2515. resetFields_ManualEmplSchedDlg();
  2516. }
  2517. }
  2518. });
  2519.  
  2520. editWorkingTime_dlg = $("#editWorkingTime_dlg").dialog({
  2521. closeOnEscape: true,
  2522. open: function (event, ui) {
  2523. $(".ui-dialog-titlebar-close", ui.dialog | ui).hide();
  2524. },
  2525. autoOpen: false,
  2526. height: 200,
  2527. width: 420,
  2528. modal: true,
  2529. buttons: {
  2530. "Labi": runManualEditTime,
  2531. "Atcelt": function () {
  2532. editWorkingTime_dlg.dialog("close");
  2533. }
  2534. }
  2535. });
  2536.  
  2537.  
  2538. editEmployeeWorkingTime_dlg = $("#editEmployeeWorkingTime_dlg").dialog({
  2539. closeOnEscape: true,
  2540. open: function (event, ui) {
  2541. $(".ui-dialog-titlebar-close", ui.dialog | ui).hide();
  2542. },
  2543. autoOpen: false,
  2544. height: 200,
  2545. width: 420,
  2546. modal: true,
  2547. buttons: {
  2548. "Labi": runEditEmployeeWorkingTime,
  2549. "Atcelt": function () {
  2550. editEmployeeWorkingTime_dlg.dialog("close");
  2551. }
  2552. }
  2553. });
  2554.  
  2555.  
  2556. editEmployeeWorkingTimeFail_dlg = $("#editEmployeeWorkingTimeFail_dlg").dialog({
  2557. closeOnEscape: true,
  2558. open: function (event, ui) {
  2559. $(".ui-dialog-titlebar-close", ui.dialog | ui).hide();
  2560. },
  2561. autoOpen: false,
  2562. height: 200,
  2563. width: 420,
  2564. modal: true,
  2565. buttons: {
  2566. "Close": function () {
  2567. editEmployeeWorkingTimeFail_dlg.dialog("close");
  2568. }
  2569. }
  2570. });
  2571.  
  2572.  
  2573. sumColumns_dlg = $("#sumColumns_dlg").dialog({
  2574. closeOnEscape: true,
  2575. open: function (event, ui) {
  2576. $(".ui-dialog-titlebar-close", ui.dialog | ui).hide();
  2577. },
  2578. autoOpen: false,
  2579. height: 430,
  2580. width: 420,
  2581. modal: true,
  2582. buttons: {
  2583. "Labi": function () {
  2584. let filterInfo = [];
  2585. let items = $('.columnItem');
  2586. let checkedCount = 0;
  2587. for (let i = 0; i < items.length; i++) {
  2588. if (items[i].children[0].checked) {
  2589. checkedCount++;
  2590. }
  2591. filterInfo.push({
  2592. colId: items[i].children[0].name,
  2593. isVisible: items[i].children[0].checked,
  2594. sortOrder: i
  2595. });
  2596. }
  2597. let oldFilter = localStorage.getItem('sumColumnsUserFilter');
  2598. if (oldFilter) {
  2599. localStorage.removeItem('sumColumnsUserFilter');
  2600. }
  2601. localStorage.setItem('sumColumnsUserFilter', mapToJson(filterInfo));
  2602. clearAndLoadSchedulingData_ajax();
  2603. //initOffset();
  2604. initOffset2();
  2605. setOffsetLevel2();
  2606. scheduler.updateView();
  2607. scheduler2.updateView();
  2608. changeSchedulerWrapperWidth();
  2609. sumColumns_dlg.dialog("close");
  2610.  
  2611. //for visible scheduler if empty data
  2612. $('#scheduler2_here').css('min-width', `${checkedCount * 95 + 270}px`);
  2613.  
  2614. setMaxWidthToTreeScheduler(checkedCount * 95 + 270);
  2615. },
  2616. "Atcelt": function () {
  2617. let items = $('.columnItem');
  2618. for (var i = 0; i < items.length; i++) {
  2619. $(items[i]).removeClass('selectedCol');
  2620. }
  2621. sumColumns_dlg.dialog("close");
  2622. }
  2623. }
  2624. });
  2625.  
  2626. correctWorkingTime_dlg = $("#correctWorkingTime_dlg").dialog({
  2627. closeOnEscape: true,
  2628. open: function (event, ui) {
  2629. $(".ui-dialog-titlebar-close", ui.dialog | ui).hide();
  2630. },
  2631. autoOpen: false,
  2632. height: 250,
  2633. width: 420,
  2634. modal: true,
  2635. buttons: {
  2636. "Jā": function () {
  2637. var dlg = $('#correctWorkingTime_dlg');
  2638. var wtTaskId = dlg.find('input[name=wtTaskId]').val();
  2639. var newTimeFromStr = dlg.find('input[name=timeFrom]').val();
  2640. var newTimeToStr = dlg.find('input[name=timeTo]').val();
  2641.  
  2642. correctWorkingTime_dlg.dialog("close");
  2643. manuallyEditTime_ajax(wtTaskId, newTimeFromStr, newTimeToStr, false);
  2644. },
  2645. "Nē": function () {
  2646. correctWorkingTime_dlg.dialog("close");
  2647. }
  2648. }
  2649. });
  2650.  
  2651. manualWtScheduling_dlg = $("#manualWtScheduling_dlg").dialog({
  2652. closeOnEscape: true,
  2653. open: function (event, ui) {
  2654. $(".ui-dialog-titlebar-close", ui.dialog | ui).hide();
  2655. },
  2656. autoOpen: false,
  2657. height: 620,
  2658. width: 600,
  2659. modal: true,
  2660. buttons: {
  2661. "Plānot": runManualWorkingTimeScheduling,
  2662. "Atcelt": function () {
  2663. manualWtScheduling_dlg.dialog("close");
  2664. resetFields_ManualWtSchedDlg();
  2665. }
  2666. }
  2667. });
  2668.  
  2669. insertJourStructure_dlg = $("#insertJourStructure_dlg").dialog({
  2670. closeOnEscape: false,
  2671. open: function (event, ui) {
  2672. $(".ui-dialog-titlebar-close", ui.dialog | ui).hide();
  2673. },
  2674. autoOpen: false,
  2675. height: 150,
  2676. width: 500,
  2677. modal: true,
  2678. buttons: {
  2679. "Labi": function () {
  2680. var dlg = $('#insertJourStructure_dlg');
  2681. var updateType = dlg.find('input[name=action]').val();
  2682. var refStructureId = dlg.find('input[name=refStructureId]').val();
  2683. var itemId = $('#insertJourStructure_dlg_itemTable').val();
  2684. isContextBlocked = true;
  2685. if (!itemId || itemId == 0) {
  2686. return;
  2687. }
  2688. requestUpdateJournalStructure_ajax(updateType, refStructureId, itemId);
  2689. insertJourStructure_dlg.dialog("close");
  2690. asyncBlockContextMenu();
  2691. },
  2692. "Atcelt": function () {
  2693. insertJourStructure_dlg.dialog("close");
  2694. }
  2695. }
  2696. });
  2697.  
  2698. employeeAbsence_dlg = $("#employeeAbsence_dlg").dialog({
  2699. closeOnEscape: false,
  2700. open: function (event, ui) {
  2701. $(".ui-dialog-titlebar-close", ui.dialog | ui).hide();
  2702. },
  2703. autoOpen: false,
  2704. height: 220,
  2705. width: 480,
  2706. modal: true,
  2707. buttons: {
  2708. "Labi": function () {
  2709. let dlg = $('#employeeAbsence_dlg');
  2710. let emplId = parseInt(dlg.find('input[name=emplId]').val());
  2711. let approveAbsence = $('#isApproved').prop("checked");
  2712.  
  2713. let dateFrom = $('.dateStart').datepicker('getDate');
  2714. let dateTo = $('.dateEnd').datepicker('getDate');
  2715. let absenceId = parseInt($('#absenceList').find(':selected').val());
  2716. if (!absenceId) {
  2717. dhtmlx.message("Nav izvēlēts prombūtnes tips");
  2718. return;
  2719. }
  2720. if ($('.dateEnd')[0].value == "00.00.0000" || $('.dateEnd')[0].value == "") {
  2721. return;
  2722. }
  2723.  
  2724. if (!isValidDate($('.dateStart')[0].value)) {
  2725. return;
  2726. }
  2727. if (!isValidDate($('.dateEnd')[0].value)) {
  2728. return;
  2729. }
  2730. var dateFromUnixTimeStamp = parseInt((new Date(dateFrom).getTime() / 1000).toFixed(0));
  2731. dateFromUnixTimeStamp = dateFromUnixTimeStamp != undefined ? dateFromUnixTimeStamp : "";
  2732. var dateToUnixTimeStamp = parseInt((new Date(dateTo).getTime() / 1000).toFixed(0));
  2733. dateToUnixTimeStamp = dateToUnixTimeStamp != undefined ? dateToUnixTimeStamp : "";
  2734. addAbsence_ajax(emplId, approveAbsence, dateFromUnixTimeStamp, dateToUnixTimeStamp, absenceId, true);
  2735. },
  2736. "Atcelt": function () {
  2737. employeeAbsence_dlg.dialog("close");
  2738. }
  2739. }
  2740. });
  2741.  
  2742. messageAbsence2A_dlg = $("#messageAbsence2A_dlg").dialog({
  2743. closeOnEscape: false,
  2744. open: function (event, ui) {
  2745. $(".ui-dialog-titlebar-close", ui.dialog | ui).hide();
  2746. },
  2747. autoOpen: false,
  2748. height: 220,
  2749. width: 300,
  2750. modal: true,
  2751. buttons: {
  2752.  
  2753. "Aizvērt": function () {
  2754. messageAbsence2A_dlg.dialog("close");
  2755. }
  2756. }
  2757. });
  2758.  
  2759. messageAbsence2B_dlg = $("#messageAbsence2B_dlg").dialog({
  2760. closeOnEscape: false,
  2761. open: function (event, ui) {
  2762. $(".ui-dialog-titlebar-close", ui.dialog | ui).hide();
  2763. },
  2764. autoOpen: false,
  2765. height: 220,
  2766. width: 300,
  2767. modal: true,
  2768. buttons: {
  2769. "Jā": function () {
  2770. let dlg = $("#messageAbsence2B_dlg");
  2771. let emplId = dlg.find('input[name=emplId]').val();
  2772. let approveAbsence = dlg.find('input[name=approveAbsence]').val();
  2773. let dateFromUnixTimeStamp = dlg.find('input[name=dateFromUnixTimeStamp]').val();
  2774. let dateToUnixTimeStamp = dlg.find('input[name=dateToUnixTimeStamp]').val();
  2775. let absenceId = dlg.find('input[name=absenceId]').val();
  2776. addAbsence_ajax(emplId, approveAbsence, dateFromUnixTimeStamp, dateToUnixTimeStamp, absenceId, false);
  2777. },
  2778.  
  2779. "Nē": function () {
  2780. messageAbsence2B_dlg.dialog("close");
  2781. }
  2782. }
  2783. });
  2784.  
  2785. messageAbsence3A_dlg = $("#messageAbsence3A_dlg").dialog({
  2786. closeOnEscape: false,
  2787. open: function (event, ui) {
  2788. $(".ui-dialog-titlebar-close", ui.dialog | ui).hide();
  2789. },
  2790. autoOpen: false,
  2791. height: 220,
  2792. width: 300,
  2793. modal: true,
  2794. buttons: {
  2795. "Aizvērt": function () {
  2796. refreshSumColumnsData_ajax();
  2797. messageAbsence2B_dlg.dialog("close");
  2798. messageAbsence3A_dlg.dialog("close");
  2799. }
  2800. }
  2801. });
  2802.  
  2803. messageAbsence3B_dlg = $("#messageAbsence3B_dlg").dialog({
  2804. closeOnEscape: false,
  2805. open: function (event, ui) {
  2806. $(".ui-dialog-titlebar-close", ui.dialog | ui).hide();
  2807. },
  2808. autoOpen: false,
  2809. height: 240,
  2810. width: 360,
  2811. modal: true,
  2812. buttons: {
  2813.  
  2814. "Aizvērt": function () {
  2815. refreshSumColumnsData_ajax();
  2816. messageAbsence2A_dlg.dialog("close");
  2817. messageAbsence2B_dlg.dialog("close");
  2818. messageAbsence3A_dlg.dialog("close");
  2819. messageAbsence3B_dlg.dialog("close");
  2820. employeeAbsence_dlg.dialog("close");
  2821. }
  2822. }
  2823. });
  2824. manualInput_dlg = $("#manualInput_dlg").dialog({
  2825. closeOnEscape: false,
  2826. open: function (event, ui) {
  2827. $(".ui-dialog-titlebar-close", ui.dialog | ui).hide();
  2828. },
  2829. autoOpen: false,
  2830. height: 150,
  2831. width: 283,
  2832. modal: true,
  2833. buttons: {
  2834. "Labi": function () {
  2835. let dlg = $('#manualInput_dlg');
  2836. let structureId = dlg.find('input[name=structureId]').val();
  2837. let sumColumnParameter = dlg.find('input[name=sumColumnParameter]').val();
  2838. let userInput = dlg.find('input[name=sumColumnValue]').val();
  2839.  
  2840. manualInputSumColumnsData_ajax(structureId, sumColumnParameter, userInput);
  2841. manualInput_dlg.dialog("close");
  2842. clearSumColumnsManualinput();
  2843. },
  2844. "Atcelt": function () {
  2845. clearSumColumnsManualinput();
  2846. manualInput_dlg.dialog("close");
  2847. }
  2848. }
  2849. });
  2850.  
  2851.  
  2852. factsEntry_dlg = $("#factsEntry_dlg").dialog({
  2853. closeOnEscape: false,
  2854. open: function (event, ui) {
  2855. $(".ui-dialog-titlebar-close", ui.dialog | ui).hide();
  2856. },
  2857. autoOpen: false,
  2858. height: 850,
  2859. width: 1500,
  2860. modal: true,
  2861. buttons: {
  2862. "Aizvērt": function () {
  2863. factsEntry_dlg.dialog("close");
  2864. }
  2865. }
  2866. });
  2867.  
  2868. deleteJourSection_dlg = $("#deleteJourSection_dlg").dialog({
  2869. closeOnEscape: false,
  2870. open: function (event, ui) {
  2871. $(".ui-dialog-titlebar-close", ui.dialog | ui).hide();
  2872. },
  2873. autoOpen: false,
  2874. height: 200,
  2875. width: 500,
  2876. modal: true,
  2877. buttons: {
  2878. "Jā": function () {
  2879. var dlg = $('#deleteJourSection_dlg');
  2880. var updateType = dlg.find('input[name=action]').val();
  2881. var sectionId = dlg.find('input[name=refStructureId]').val();
  2882. requestUpdateJournalStructure_ajax(updateType, sectionId, 0);
  2883. deleteJourSection_dlg.dialog("close");
  2884. },
  2885. "Atcelt": function () {
  2886. deleteJourSection_dlg.dialog("close");
  2887. }
  2888. }
  2889. });
  2890.  
  2891. dragWorker_dlg = $("#dragWorker_dlg").dialog({
  2892. closeOnEscape: false,
  2893. open: function (event, ui) {
  2894. $(".ui-dialog-titlebar-close", ui.dialog | ui).hide();
  2895. },
  2896. autoOpen: false,
  2897. height: 200,
  2898. width: 230,
  2899. modal: true,
  2900. buttons: {
  2901. "Labi": function () {
  2902. var dlg = $('#dragWorker_dlg');
  2903. var taskId_target = dlg.find('input[name=taskId_target]').val();
  2904. var taskId_source = dlg.find('input[name=taskId_source]').val();
  2905. var bidirect = false;
  2906. var target = scheduler.getEvent(taskId_target);
  2907. var source = scheduler.getEvent(taskId_source);
  2908. confirmTitle = "Apstiprināt pārvietošanu";
  2909.  
  2910. if (document.getElementById('exchange').checked) {
  2911. bidirect = true;
  2912. confirmText = `Vai tiešām samainīt vietām`;
  2913. confirmText += `<br>${source.EmplName} ${source.EmplSurname}, ${source.AxEmplId}, ${new Date(source.DateTimeStart).ddmmyyyy()}, ${source.WorkplacePath}`;
  2914. confirmText += `<br>ar`;
  2915. confirmText += `<br>${target.EmplName} ${target.EmplSurname}, ${target.AxEmplId}, ${new Date(target.DateTimeStart).ddmmyyyy()}, ${target.WorkplacePath}?`;
  2916. dlg.find('input[name=bidirect]').val(bidirect);
  2917. }
  2918. if (document.getElementById('replace').checked) {
  2919. dlg.find('input[name=bidirect]').val(bidirect);
  2920. confirmText = `Vai tiešām aizvietot`;
  2921. confirmText += `<br>${target.EmplName} ${target.EmplSurname}, ${target.AxEmplId}, ${new Date(target.DateTimeStart).ddmmyyyy()}, ${target.WorkplacePath}`;
  2922. confirmText += `<br>ar`;
  2923. confirmText += `<br>${source.EmplName} ${source.EmplSurname}, ${source.AxEmplId}, ${new Date(source.DateTimeStart).ddmmyyyy()}, ${source.WorkplacePath}?`;
  2924. }
  2925. if ((document.getElementById('replace').checked) && ($('#replace').prop('disabled'))) {
  2926. dlg.find('input[name=bidirect]').val(bidirect);
  2927. confirmText = `Vai tiešām mainīt`;
  2928. confirmText += `<br>${source.EmplName} ${source.EmplSurname}, ${source.AxEmplId}, ${new Date(source.DateTimeStart).ddmmyyyy()}, ${source.WorkplacePath}`;
  2929. confirmText += `<br>uz`;
  2930. confirmText += `<br>${new Date(target.DateTimeStart).ddmmyyyy()}, ${target.WorkplacePath}?`;
  2931. }
  2932.  
  2933. inputInfoForConfirmDlg(confirmTitle, confirmText);
  2934. wtEmplSchedMove_ajax(taskId_source, taskId_target, bidirect, true);
  2935. dragWorker_dlg.dialog("close");
  2936. },
  2937. "Atcelt": function () {
  2938. resetFields_DragOrWorker_dlg();
  2939. clearAndLoadSchedulingData_ajax();
  2940. dragWorker_dlg.dialog("close");
  2941. }
  2942. }
  2943. });
  2944. confirm_dlg = $("#confirm_dlg").dialog({
  2945. closeOnEscape: false,
  2946. open: function (event, ui) {
  2947. $(".ui-dialog-titlebar-close", ui.dialog | ui).hide();
  2948. },
  2949. autoOpen: false,
  2950. height: 260,
  2951. width: 730,
  2952. modal: true,
  2953. buttons: {
  2954. "Labi": function () {
  2955. var dlg = $('#dragWorker_dlg');
  2956. var taskId_target = dlg.find('input[name=taskId_target]').val();
  2957. var taskId_source = dlg.find('input[name=taskId_source]').val();
  2958. var bidirect = dlg.find('input[name=bidirect]').val();
  2959.  
  2960. wtEmplSchedMove_ajax(taskId_source, taskId_target, bidirect, false);
  2961. let sumColumnsCount = localStorage.getItem('countHeaders');
  2962. //if (sumColumnsCount && sumColumnsCount > 0) {
  2963. // refreshSumColumnsData_ajax();
  2964. //}
  2965. //clearAndLoadSchedulingData_ajax();
  2966. resetFields_DragOrWorker_dlg();
  2967. confirm_dlg.dialog("close");
  2968. },
  2969. "Atcelt": function () {
  2970. $("#confirm_dlg .info p").remove();
  2971. confirm_dlg.dialog("close");
  2972. clearAndLoadSchedulingData_ajax();
  2973. resetFields_DragOrWorker_dlg();
  2974. }
  2975. }
  2976. });
  2977.  
  2978. error_dlg = $("#error_dlg").dialog({
  2979. closeOnEscape: false,
  2980. open: function (event, ui) {
  2981. $(".ui-dialog-titlebar-close", ui.dialog | ui).hide();
  2982. },
  2983. autoOpen: false,
  2984. height: 260,
  2985. width: 730,
  2986. modal: true,
  2987. buttons: {
  2988. "Labi": function () {
  2989. clearAndLoadSchedulingData_ajax();
  2990. $("#error_dlg .info p").remove();
  2991. error_dlg.dialog("close");
  2992. }
  2993. }
  2994. });
  2995.  
  2996. deleteWorkplaceOrWorker_dlg = $("#deleteWorkplaceOrWorker_dlg").dialog({
  2997. closeOnEscape: false,
  2998. open: function (event, ui) {
  2999. $(".ui-dialog-titlebar-close", ui.dialog | ui).hide();
  3000. },
  3001. autoOpen: false,
  3002. height: 200,
  3003. width: 500,
  3004. modal: true,
  3005. buttons: {
  3006. "Jā": function () {
  3007. var dlg = $('#deleteWorkplaceOrWorker_dlg');
  3008. var callerTaskId = dlg.find('input[name=callerTaskId]').val();
  3009. var period = dlg.find('input[name=period]').val();
  3010. var action = dlg.find('input[name=action]').val();
  3011. var includeSiblings = dlg.find('input[name=includeSiblings]').val();
  3012. deleteTasks_ajax(callerTaskId, period, action, includeSiblings);
  3013. deleteWorkplaceOrWorker_dlg.dialog("close");
  3014. },
  3015. "Atcelt": function () {
  3016. deleteWorkplaceOrWorker_dlg.dialog("close");
  3017. }
  3018. }
  3019. });
  3020.  
  3021. journalStatusChange_dlg = $("#journalStatusChange_dlg").dialog({
  3022. closeOnEscape: false,
  3023. open: function (event, ui) {
  3024. $(".ui-dialog-titlebar-close", ui.dialog | ui).hide();
  3025. },
  3026. autoOpen: false,
  3027. minHeight: 200,
  3028. width: 500,
  3029. modal: true,
  3030. title: 'Žurnāla statusa maiņas rezultāts',
  3031. buttons: {
  3032. "Labi": function () {
  3033. journalStatusChange_dlg.dialog("close");
  3034. }
  3035. }
  3036. });
  3037. });
  3038.  
  3039. _EditEmployeeWorkingTimeDlg.cshtml
  3040. <div id="editEmployeeWorkingTime_dlg" title="Edit employee working time">
  3041. <div class="datums">
  3042. <label class="" for="datums">Datums:</label>
  3043. <input type="text" name="datums" value="00:00" class="text ui-widget-content">
  3044. </div>
  3045. <div class="edit-time">
  3046. <label class="" for="timeFrom">Laiks No:</label>
  3047. <input type="text" name="timeFrom" value="00:00" class="text ui-widget-content time-input">
  3048. <label class="" for="timeTo">Līdz:</label>
  3049. <input type="text" name="timeTo" value="00:00" class="text ui-widget-content time-input">
  3050. </div>
  3051. <input type="hidden" name="wtTaskId" />
  3052. </div>
  3053.  
  3054. <div id="editEmployeeWorkingTimeFail_dlg">
  3055. </div>
  3056. Show.chtml
  3057.  
  3058. <div id="schedulerView" style="display:none">
  3059. <div class="clear header-scheduler-info">
  3060. <div class="header-scheduler-journalInfo">
  3061. <label> <span class="bold">@(App_Localization.Labels.JournalNumber): </span> @Model.AxJournalId </label><a href="/Journal/Select">@(App_Localization.Labels.SwitchJournal)</a>
  3062. <label class="clear"><span class="bold">@(App_Localization.Labels.Period): </span>@Model.AxPeriodId </label>
  3063. <label class="clear"><span class="bold">@(App_Localization.Labels.StdCalendarHours): </span>@Model.AxStdCalendarHours</label>
  3064. <label class="clear"><span class="bold">@(App_Localization.Labels.JournalStatus): </span><span id="axJournalStatusId">@Model.AxJournalStatusId</span> - <span id="axJournalStatusName">@Model.AxJournalStatusName </span></label>
  3065. </div>
  3066. <div class="header-scheduler-taskInfo">
  3067. <label></label>
  3068. </div>
  3069. </div>
  3070. <div style="height:800px;width:100%;margin:0 auto;display:none" id="schedulerWrapper">
  3071. @Html.Raw(Model.Scheduler.Render())
  3072. </div>
  3073. <div style="height:800px;width:100%;margin:0 auto;display:none" id="schedulerWrapper2">
  3074. @Html.Raw(ViewBag.schedViewModel2.Scheduler.Render())
  3075. </div>
  3076. <link href="~/Content/libraries-overriding.css" rel="stylesheet" />
  3077. @Html.Partial("_ManualEmplSchedDlg")
  3078. @Html.Partial("_DragAndDropDlg")
  3079. @Html.Partial("_FactsEntryDlg")
  3080. @Html.Partial("_ManualWorkingTimeSchedDlg")
  3081. @Html.Partial("_EditWorkingTimeDlg")
  3082. @Html.Partial("_JournalStructureUpdDlg")
  3083. @Html.Partial("_SumColumnDlg")
  3084. @Html.Partial("_EmployeeAbsenceDialog")
  3085. @Html.Partial("_EditEmployeeWorkingTimeDlg")
  3086. <div>
  3087. <input type="hidden" id="load-page" value="false" />
  3088. <input type="hidden" id="freeze-scheduler" value="true" />
  3089. </div>
  3090. <input type="hidden" name="_AxJournalId" value="@Model.AxJournalId" />
  3091. <input type="hidden" name="_EmplId" value="@Model.EmplId" />
  3092. </div>
  3093. @Html.Partial("_CustomSchedulerHeader")
  3094. <div id="layoutView" style="height:760px;width:100%"></div>
  3095. @Scripts.Render("~/bundles/dhtmlxlayout")
  3096. @Scripts.Render("~/bundles/dropdownmenus")
  3097. <script type="text/javascript">
  3098. AppLabels.Employee = '@(App_Localization.Labels.Employee)';
  3099. </script>
  3100.  
  3101. Layout
  3102. <!DOCTYPE html>
  3103. <html>
  3104. <head>
  3105. <meta charset="utf-8" />
  3106. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  3107. <title>Darbavietu plānošana</title>
  3108. <script src="https://cdn.polyfill.io/v2/polyfill.min.js?features=Promise"></script>
  3109. @Styles.Render("~/Content/css")
  3110. @Scripts.Render("~/bundles/jquery")
  3111. <script>
  3112. $.browser = {};
  3113. (function () {
  3114. jQuery.browser.msie = false;
  3115. jQuery.browser.version = 0;
  3116. if (navigator.userAgent.match(/MSIE ([0-9]+)\./)) {
  3117. jQuery.browser.msie = true;
  3118. jQuery.browser.version = RegExp.$1;
  3119. }
  3120. })();
  3121. </script>
  3122. @Scripts.Render("~/bundles/jqueryui")
  3123. @Scripts.Render("~/bundles/jqueryext")
  3124. <script>
  3125. if (!window.AppLabels) {
  3126. window.AppLabels = {};
  3127. }
  3128.  
  3129. var dataTablesLangJson_lv = {
  3130. "infoEmpty": "Nav ierakstu",
  3131. "emptyTable": "Nav datu tabulā",
  3132. "zeroRecords": "Nav ierakstu, kas atbilst meklēšanas kritērijam",
  3133. "info": "_START_ līdz _END_ no _TOTAL_ ierakstiem",
  3134. "infoEmpty": "0 līdz 0 no 0 ierakstiem",
  3135. "search": "Meklēt:",
  3136. "paginate": {
  3137. "first": "Pirmais",
  3138. "last": "Pēdējais",
  3139. "next": "Nākamais",
  3140. "previous": "Iepriekšējais"
  3141. },
  3142. "lengthMenu": "Rādīt _MENU_ ierakstus"
  3143. };
  3144.  
  3145. jQuery(function ($) {
  3146. $.datepicker.regional['lv'] = {
  3147. closeText: 'Aizvērt',
  3148. prevText: 'Iepr.',
  3149. nextText: 'Nāk.',
  3150. currentText: 'šodien',
  3151. monthNames: ['Janvāris', 'Februāris', 'Marts', 'Aprīlis', 'Maijs', 'Jūnijs',
  3152. 'Jūlijs', 'Augusts', 'Septembris', 'Oktobris', 'Novembris', 'Decembris'],
  3153. monthNamesShort: ['Jan', 'Feb.', 'Mar', 'Apr', 'Mai', 'Jūn',
  3154. 'Jūl.', 'Aug', 'Sep', 'Okt', 'Nov', 'Dec'],
  3155. dayNames: ['Svētdiena', 'Pirmdiena', 'Otrdiena', 'Trešdiena', 'Ceturtdiena', 'Piektdiena', 'Sestdiena'],
  3156. dayNamesShort: ['Svētd.', 'Pirmd.', 'Otrd.', 'Trešd.', 'Ceturtd.', 'Piektd.', 'Sestd.'],
  3157. dayNamesMin: ['Sv', 'P', 'O', 'T', 'C', 'Pk', 'S'],
  3158. weekHeader: 'Ned.',
  3159. dateFormat: 'dd.mm.yy',
  3160. firstDay: 1,
  3161. isRTL: false,
  3162. showMonthAfterYear: false,
  3163. yearSuffix: ''
  3164. };
  3165. $.datepicker.setDefaults($.datepicker.regional['lv']);
  3166. });
  3167. </script>
  3168. @Scripts.Render("~/bundles/scheduler")
  3169. </head>
  3170. <body class="body">
  3171. <div class="header">
  3172. <div class="header-login">
  3173. <p>Sveiki, <span class="bold">@User.Identity.Name</span>!</p>
  3174. </div>
  3175. <div class="header-title">
  3176. <h1>DLP > Darba vietu un laika plānošana</h1>
  3177. </div>
  3178. </div>
  3179. <div class="container body-content">
  3180. @RenderBody()
  3181. </div>
  3182. @RenderSection("scripts", required: false)
  3183. </body>
  3184. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement