From c65569b86c7c2ad534ed30d20934c2846ef29434 Mon Sep 17 00:00:00 2001 From: Wahyu Ramadhan Date: Thu, 20 Jul 2023 13:35:02 +0700 Subject: [PATCH] Add formatting --- edit-mode/function/reportActivity.js | 110 ++++++++++++++------------- 1 file changed, 56 insertions(+), 54 deletions(-) diff --git a/edit-mode/function/reportActivity.js b/edit-mode/function/reportActivity.js index 7e2c6e2..b36ccf5 100644 --- a/edit-mode/function/reportActivity.js +++ b/edit-mode/function/reportActivity.js @@ -23,9 +23,9 @@ function resetFormAddRaMaterial() { } var qtyActual = document.getElementById('volume_pekerjaan_material'); - qtyActual.addEventListener('keyup', function (e) { - qtyActual.value = formatRibuanInput(this.value); - }); +qtyActual.addEventListener('keyup', function (e) { + qtyActual.value = formatRibuanInput(this.value); +}); $(document).ready(function () { @@ -73,37 +73,37 @@ $(document).ready(function () { } }); - var tableRa = $("#table_report").on('xhr.dt', function(e, settings, json, xhr){ - $('#report-activity-information-status').attr("class", ""); - if(json?.data?.length > 0) { - let firstData = json.data[0]; - const statusReport = firstData.status_activity; - let reportStartDate = firstData.start_activity ?? "-"; - reportStartDate = reportStartDate.split(" ")[0]; - let reportFinishDate = firstData.finish_activity ?? "-"; - reportFinishDate = reportFinishDate.split(" ")[0]; - - - if(statusReport == 'on-progress') { - $('#report-activity-information-status').attr("class", "badge badge-warning"); - } else if(statusReport == 'done') { - $('#report-activity-information-status').attr("class", "badge badge-success"); - } else if(statusReport == 'open') { - $('#report-activity-information-status').attr("class", "badge badge-primary"); - } - - if(moment(reportStartDate, "YYYY-MM-DD",true).isValid()){ - reportStartDate = moment(reportStartDate, "YYYY-MM-DD").format("DD-MM-YYYY"); - } - - if(moment(reportFinishDate, "YYYY-MM-DD",true).isValid()){ - reportFinishDate = moment(reportFinishDate, "YYYY-MM-DD").format("DD-MM-YYYY"); - } - - $("#report-activity-information-status").text(statusReport ?? "-"); - $("#report-activity-information-start").text(reportStartDate); - $("#report-activity-information-end").text(reportFinishDate); - } + var tableRa = $("#table_report").on('xhr.dt', function (e, settings, json, xhr) { + $('#report-activity-information-status').attr("class", ""); + if (json?.data?.length > 0) { + let firstData = json.data[0]; + const statusReport = firstData.status_activity; + let reportStartDate = firstData.start_activity ?? "-"; + reportStartDate = reportStartDate.split(" ")[0]; + let reportFinishDate = firstData.finish_activity ?? "-"; + reportFinishDate = reportFinishDate.split(" ")[0]; + + + if (statusReport == 'on-progress') { + $('#report-activity-information-status').attr("class", "badge badge-warning"); + } else if (statusReport == 'done') { + $('#report-activity-information-status').attr("class", "badge badge-success"); + } else if (statusReport == 'open') { + $('#report-activity-information-status').attr("class", "badge badge-primary"); + } + + if (moment(reportStartDate, "YYYY-MM-DD", true).isValid()) { + reportStartDate = moment(reportStartDate, "YYYY-MM-DD").format("DD-MM-YYYY"); + } + + if (moment(reportFinishDate, "YYYY-MM-DD", true).isValid()) { + reportFinishDate = moment(reportFinishDate, "YYYY-MM-DD").format("DD-MM-YYYY"); + } + + $("#report-activity-information-status").text(statusReport ?? "-"); + $("#report-activity-information-start").text(reportStartDate); + $("#report-activity-information-end").text(reportFinishDate); + } }).on('draw.dt', function () { // This event handler will be called after the table is redrawn (after AJAX call) // Now you can hide the button here based on the statusReport @@ -125,11 +125,13 @@ $(document).ready(function () { }, "columns": [ { data: 'material_name', name: 'material_name' }, - { data: 'type', name: 'type', render: function(data, type){ - if(data == 'expense') - return "Overhead" - return "Material" - }}, + { + data: 'type', name: 'type', render: function (data, type) { + if (data == 'expense') + return "Overhead" + return "Material" + } + }, { data: 'qty_planning', render: function (data, type) { return data ? formatRupiah(data) : '-' @@ -137,7 +139,7 @@ $(document).ready(function () { }, { data: 'qty_sum', render: function (data, type) { - if(data == "-"){ + if (data == "-") { return data } return data ? formatRupiah(data) : '-' @@ -163,7 +165,7 @@ $(document).ready(function () { d.idAmi = assignMaterialId; d.idAct = activityId; d.materialName = materialName; - d.type = 'actual'; + d.type = 'actual'; } }, "columns": [ @@ -197,11 +199,11 @@ $(document).ready(function () { "data": function (d) { d.idAmi = assignMaterialId; d.idAct = activityId; - d.type = 'plan'; + d.type = 'plan'; } }, "columns": [ - { data: 'material_name', name: 'material_name'}, + { data: 'material_name', name: 'material_name' }, { data: 'qty_planning', render: function (data, type) { return data ? formatRupiah(parseInt(data)) : '-' @@ -485,25 +487,25 @@ $(document).ready(function () { $("#table_activity_material_actual").on("click", ".btn-ram-image", function () { let id = $(this).data('id'); $.ajax({ - url: `${base_url}image/${id}/report_activity`, - type:"GET", - success: function (result) { - let data = result.data; + url: `${base_url}image/${id}/report_activity`, + type: "GET", + success: function (result) { + let data = result.data; if (!data) { - gantt.alert({type: "error", text: "Failed to get report image"}); + gantt.alert({ type: "error", text: "Failed to get report image" }); return false; } - + if (data && data.image) { $("#report-image").html(``); $('#modal-report-image').modal('show'); } // kalo gambarnya banyak belum di handle... - }, - error: function (data) { - gantt.alert({type: "error", text: "Failed to get report image"}); - } - }); + }, + error: function (data) { + gantt.alert({ type: "error", text: "Failed to get report image" }); + } + }); }); $("#btn-close-material").on("click", function () {