diff --git a/edit-mode/function/reportActivity.js b/edit-mode/function/reportActivity.js index eeec2b4..c555ddd 100644 --- a/edit-mode/function/reportActivity.js +++ b/edit-mode/function/reportActivity.js @@ -21,9 +21,9 @@ function resetFormAddRaMaterial() { $('#btn_add_ra_material').prop("disabled", false); } -var qtyActual = document.getElementById('volume_pekerjaan_material'); - qtyActual.addEventListener('keyup', function (e) { - qtyActual.value = formatRibuanInput(this.value); +var qtyActual = document.getElementById('volume_pekerjaan_material'); + qtyActual.addEventListener('keyup', function (e) { + qtyActual.value = formatRibuanInput(this.value); }); $(document).ready(function () { @@ -74,7 +74,38 @@ $(document).ready(function () { } }); - var tableRa = $("#table_report").DataTable({ + 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); + } + }).DataTable({ "processing": true, "serverSide": true, "ajax": { @@ -87,6 +118,7 @@ $(document).ready(function () { { data: 'material_name', name: 'material_name' }, { data: 'qty_planning', render: function (data, type) { + console.log("render", [data, type]); return data ? formatRupiah(data) : '-' } }, @@ -99,28 +131,22 @@ $(document).ready(function () { } }, { data: 'uom', name: 'uom' }, - { - data: 'start_activity', render: function (data, type) { - console.log("start", data) - return data ? formatDate(data) : '-' - } - }, - { - data: 'finish_activity', render: function (data, type) { - console.log("finish", data) - return data ? formatDate(data) : '-' - } - }, - { - data: 'status_activity', render: function (data, type) { - console.log("status", data) - const val = !data ? '-' : - data == "done" ? `${data}` : - data == "open" ? `${data}` : - `${data}` - return val - } - }, + // { + // data: 'start_activity', render: function (data, type) { + // return data ? formatDate(data) : '-' + // } + // }, + // { + // data: 'finish_activity', render: function (data, type) { + // return data ? formatDate(data) : '-' + // } + // }, + // { + // data: 'status_activity', render: function (data, type) { + // console.log("status", data) + // return val + // } + // }, { data: 'action', name: 'action', @@ -130,6 +156,7 @@ $(document).ready(function () { ] }); + var tableRaMaterialActual = $("#table_activity_material_actual").DataTable({ "processing": true, "serverSide": true, @@ -142,9 +169,9 @@ $(document).ready(function () { } }, "columns": [ - { data: 'human_resource', name: 'human_resource' }, + { data: 'human_resource', name: 'human_resource' }, { - data: 'report_date', render: function (data, type) { + data: 'report_date', render: function (data, type) { return data ? formatDate(data) : '-' } }, @@ -184,13 +211,13 @@ $(document).ready(function () { }, { data: 'uom', name: 'uom' }, { - data: 'plan_date', render: function (data, type) { + data: 'plan_date', render: function (data, type) { return data ? formatDate(data) : '-' } }, ] }); - + $('#select_ra_hr').select2({ dropdownParent: rAModal, @@ -520,7 +547,7 @@ $(document).ready(function () { // console.log(" okeee ",{ assignMaterialId, activityId, materialName }); $("#report_activity_material_title").html(`Report Activity Actual Material ${materialName}`) $("#modal_report_activity").hide(); - + $("#form_report_activity_material").show(); $("#activity_material_plan").hide(); $("#activity_material_actual").show(); @@ -642,4 +669,4 @@ $(document).ready(function () { } }); }); -}); \ No newline at end of file +}); diff --git a/edit-mode/index.html b/edit-mode/index.html index b291a4d..ef45c08 100644 --- a/edit-mode/index.html +++ b/edit-mode/index.html @@ -542,8 +542,6 @@ -