diff --git a/edit-mode/function/expenseResource.js b/edit-mode/function/expenseResource.js index d27ad63..602ca20 100644 --- a/edit-mode/function/expenseResource.js +++ b/edit-mode/function/expenseResource.js @@ -75,37 +75,6 @@ $(document).ready(function () { }); } - function searchReport(id) { - var payload = { - "columns": [ - { - "name": "assign_material_id", - "logic_operator": "=", - "value": id, - "operator": "AND" - } - ], - // "joins": [{ "name": "m_proyek", "column_join": "proyek_id", "column_results": ["kode_sortname", "nama"] }], - } - $.ajax({ - data: JSON.stringify(payload), - url: `${base_url}report-activity-material/search`, - type: "POST", - success: function (data) { - data.data.forEach(element => { - let activityId = element.activity_id; - let task = gantt.getTask(activityId); - task.actual_start = null; - task.actual_end = null; - }); - actionHappen = true; - }, - error: function (data) { - // gantt.alert("Failed to get the data."); - } - }); - } - $("#modal-expense").on("click", "#show-form-expense", function () { $(this).hide(); $("#hide-form-expense").show(); diff --git a/edit-mode/function/function.js b/edit-mode/function/function.js index bc3426d..c91369b 100644 --- a/edit-mode/function/function.js +++ b/edit-mode/function/function.js @@ -14,6 +14,46 @@ function getUrlParameter(sParam) { return false; }; + function searchReport(id, updateActual = true) { + var payload = { + "columns": [ + { + "name": "assign_material_id", + "logic_operator": "=", + "value": id, + "operator": "AND" + } + ], + // "joins": [{ "name": "m_proyek", "column_join": "proyek_id", "column_results": ["kode_sortname", "nama"] }], + } + $.ajax({ + data: JSON.stringify(payload), + url: `${base_url}report-activity-material/search`, + type: "POST", + success: function (data) { + if (updateActual) { + data.data.forEach(element => { + let activityId = element.activity_id; + let task = gantt.getTask(activityId); + task.actual_start = null; + task.actual_end = null; + }); + } else { + if (data.data.length == 1) { + let activityId = data.data[0].activity_id; + let task = gantt.getTask(activityId); + task.actual_start = null; + task.actual_end = null; + } + } + actionHappen = true; + }, + error: function (data) { + // gantt.alert("Failed to get the data."); + } + }); + } + const formatNumber = (angka) => { var number_string = angka.replace(/[^,\d]/g, '').toString(), split = number_string.split(','), @@ -733,27 +773,6 @@ function batchUpdate(){ }); } -function updateSchedule() { - $("body").addClass("loading"); - return gantt.ajax.get({ - headers: { - "Content-Type": "application/json", - "Authorization": `Bearer ${token}` - }, - url: base_url + "activity/update-schedule/" + ganttId - }).then(function (response) { - $("body").removeClass("loading"); - refresData(); - }).catch(function (error) { - $("body").removeClass("loading") - gantt.alert({ - title: "Peringatan", - type: "alert-error", - text: "Update activity gagal" - }); - }); -} - $(window).on('beforeunload', function(event) { let batchEntity = localStorage.getItem('batchEntity'); sendStorage(); diff --git a/edit-mode/function/ganttSettings.js b/edit-mode/function/ganttSettings.js index e941046..86cc8e9 100644 --- a/edit-mode/function/ganttSettings.js +++ b/edit-mode/function/ganttSettings.js @@ -447,6 +447,27 @@ function setSynchronize() { }); } +function updateSchedule() { + $("body").addClass("loading"); + return gantt.ajax.get({ + headers: { + "Content-Type": "application/json", + "Authorization": `Bearer ${token}` + }, + url: base_url + "activity/update-schedule/" + ganttId + }).then(function (response) { + $("body").removeClass("loading"); + window.location.reload(); + }).catch(function (error) { + $("body").removeClass("loading") + gantt.alert({ + title: "Peringatan", + type: "alert-error", + text: "Update activity gagal" + }); + }); +} + async function setSynchronizeAPI() { const res = await axiosInstance .get(ACTIVITY_SYNCHRONIZE_REPORT_URL, HEADER) diff --git a/edit-mode/function/reportActivity.js b/edit-mode/function/reportActivity.js index 29cc50b..e9d58aa 100644 --- a/edit-mode/function/reportActivity.js +++ b/edit-mode/function/reportActivity.js @@ -654,6 +654,7 @@ $(document).ready(function () { } function deleteRaMaterial(id) { + searchReport(assignMaterialId, false); $.ajax({ url: `${base_url}report-activity-material/delete/${id}`, type: "DELETE",