diff --git a/edit-mode/function/expenseResource.js b/edit-mode/function/expenseResource.js
new file mode 100644
index 0000000..24055f1
--- /dev/null
+++ b/edit-mode/function/expenseResource.js
@@ -0,0 +1,232 @@
+var expenseModal = $('#modal-expense > .modal-dialog > .modal-content');
+
+function resetFormAssignexpense() {
+ $('#select-expense').val(null).trigger("change");
+ $('#select-expense').find('option').remove();
+ $('#select-expense').val("");
+ $('#form-assign-expense').trigger("reset");
+ $('#btn-assign-expense').html('Assign');
+ $('#btn-assign-expense').prop("disabled", false);
+};
+
+
+var rupiah = document.getElementById('price-req-expense');
+ rupiah.addEventListener('keyup', function (e) {
+ rupiah.value = formatRibuanInput(this.value);
+ });
+
+var qty = document.getElementById('qty-req-expense');
+ qty.addEventListener('keyup', function (e) {
+ qty.value = formatRibuanInput(this.value);
+ });
+
+$(document).ready(function () {
+ var tableexpense = $("#table-expense").DataTable({
+ "processing": true,
+ "serverSide": true,
+ "ajax": {
+ "url": `${base_url}assign-material/datatables`,
+ "data": function (d) {
+ d.idact = activityId;
+ d.type = "expense";
+ }
+ },
+ "columns": [
+ { data: 'material_name', name: 'material_name' },
+ {
+ data: 'qty_planning', render: function (data, type) {
+ return data ? formatRupiah(data) : '-'
+ }
+ },
+ { data: 'uom', name: 'uom' },
+ {
+ data: 'budget', render: function (data, type) {
+ return data ? "Rp. " + formatRupiah(data) : '-'
+ }
+ },
+ {
+ data: 'plan_date', render: function (data, type) {
+ return data ? formatDate(data) : '-'
+ }
+ },
+ {
+ data: 'action',
+ name: 'action',
+ orderable: true,
+ searchable: true
+ },
+ ]
+ });
+
+ function deleteexpenseAssign(id) {
+ $.ajax({
+ url: `${base_url}assign-material/delete/${id}`,
+ type: "DELETE",
+ success: function (data) {
+ actionHappen = true;
+ gantt.alert("Delete expense Assign Success!");
+ tableexpense.draw();
+ },
+ error: function (data) {
+ gantt.alert("Delete expense Assign Failed, try again later!");
+ }
+ });
+ }
+
+ $("#modal-expense").on("click", "#show-form-expense", function () {
+ $(this).hide();
+ $("#hide-form-expense").show();
+ $("#form-assign-expense").show();
+ });
+
+ $("#modal-expense").on("click", "#hide-form-expense", function () {
+ $(this).hide();
+ resetFormAssignexpense()
+ $("#show-form-expense").show();
+ });
+
+ $('#modal-expense').on('show.bs.modal', function (event) {
+ $('#modal-expense-title').html("Other Expense " + activityName);
+ tableexpense.draw();
+ });
+
+ $('#modal-expense').on('hide.bs.modal', function (event) {
+ // $("#hide-form-expense").hide();
+ $("#show-form-expense").show();
+ console.log("there's before action change ", actionHappen);
+ if (actionHappen) {
+ console.log("there's action change ", actionHappen);
+ updateActivity(activityId);
+ }
+ resetFormAssignexpense();
+ });
+
+ $('#select-expense').select2({
+ dropdownParent: expenseModal,
+ placeholder: 'Pilih expense resource',
+ allowClear: true,
+ ajax: {
+ url: `${base_url}expense-resource/select`,
+ dataType: 'json',
+ data: function (params) {
+ var query = {
+ search: params.term,
+ type: 'public',
+ idProyek: proyekId,
+ idact: activityId
+ }
+ return query;
+ },
+ processResults: function (result) {
+ return {
+ results: $.map(result, function (item) {
+ // console.log("cek item", item)
+ return {
+ text: item.description,
+ id: item.id
+ }
+ })
+ };
+ },
+ cache: false
+ }
+ });
+
+ $("#form-assign-expense").on('submit', function (e) {
+ e.preventDefault();
+
+ $('#btn-assign-expense').html('Assign...');
+ $('#btn-assign-expense').prop("disabled", true);
+
+ // /request-expense/add
+ let desc_req_expense = $("#desc-expense").val();
+ let required_date = $("#required-date-req-expense").val();
+ let plan_date = $("#required-date-plan-expense").val();
+ let uom = $("#uom-req-expense").val();
+ let price = $("#price-req-expense").val();
+ let qty_planning = $("#qty-req-expense").val();
+ let expense_id = null;
+
+ let payload = {
+ description: desc_req_expense,
+ type: "expense",
+ fom_date: required_date,
+ required_date: required_date,
+ proyek_id: proyekId,
+ uom: uom,
+ qty: formatReplaceTitikRibuan(qty_planning),
+ price: formatReplaceTitikRibuan(price)
+ }
+ $.ajax({
+ data: JSON.stringify(payload),
+ url: `${base_url}request-material/add`,
+ type: "POST",
+ processData: false,
+ contentType: false,
+ success: function (data) {
+ if (data && data.code === 200) {
+ material_id = data.data.id;
+ resetFormAssignexpense();
+
+ let payloadAssign = {
+ proyek_id: proyekId,
+ activity_id: activityId,
+ material_id : material_id ,
+ qty_planning: qty_planning,
+ plan_date: plan_date,
+ type: "expense",
+ }
+ $.ajax({
+ data: JSON.stringify(payloadAssign),
+ url: `${base_url}assign-material/add`,
+ type: "POST",
+ processData: false,
+ contentType: false,
+ success: function (data) {
+ if (data && data.code === 200) {
+ actionHappen = true;
+ gantt.alert("Data added!");
+ tableexpense.draw();
+ resetFormAssignexpense();
+ }
+ else {
+ gantt.alert({ type: "error", text: data.message });
+ $('#btn-assign-expense').html('Assign');
+ $('#btn-assign-expense').prop("disabled", false);
+ }
+ },
+ error: function (data) {
+ gantt.alert("Assign Failed, try again later!");
+ resetFormAssignexpense();
+ }
+ });
+ }
+ else {
+ gantt.alert({ type: "error", text: data.message });
+ $('#btn-assign-expense').html('Assign');
+ $('#btn-assign-expense').prop("disabled", false);
+ }
+ },
+ error: function (data) {
+ gantt.alert("expense Request Failed, try again later!");
+ resetFormAssignexpense();
+ }
+ });
+
+ });
+
+ // delete from row
+ $("#table-expense").on("click", ".btn-expense-delete", function () {
+ let id = $(this).data('id');
+ var box = gantt.confirm({
+ text: "expense will be deleted from activity, continue?",
+ ok: "Delete",
+ cancel: "Cancel",
+ callback: function (result) {
+ if (result) {
+ deleteexpenseAssign(id);
+ }
+ }
+ });
+ });
+});
diff --git a/edit-mode/function/ganttConfig.js b/edit-mode/function/ganttConfig.js
index 34745e0..0768359 100644
--- a/edit-mode/function/ganttConfig.js
+++ b/edit-mode/function/ganttConfig.js
@@ -256,14 +256,14 @@ var allColumns = [
{ name: "start_date", label: "Start Date", align: "center", min_width: 80, editor: editor.start_date, resize: true },
{ name: "end_date", label: "Finish Date", align: "center", min_width: 80, editor: editor.end_date, resize: true },
{ name: "duration", label: "Duration", align: "center", min_width: 50, resize: true },
- { name: "rencana_biaya", label: "Cost Planning", align: "center", min_width: 100, resize: true, template: function (text) {
+ { name: "rencana_biaya", label: "Cost Planning", align: "right", min_width: 100, resize: true, template: function (text) {
if(!text.rencana_biaya){
return
}
let rencana_biaya = text.rencana_biaya
return "Rp. "+ formatRupiah(rencana_biaya)
} },
- { name: "cost_actual", label: "Cost Actual", align: "center", min_width: 100, resize: true, template: function (text) {
+ { name: "cost_actual", label: "Cost Actual", align: "right", min_width: 100, resize: true, template: function (text) {
if(!text.biaya_actual){
return
}
@@ -300,16 +300,34 @@ var allColumns = [
var assign_material = text.assign_material
if(!assign_material || !assign_material.length){
- html = `Unassigned`;
+ html = `No Material`;
}else{
if(assign_material.length > 0 ){
- html = `Assigned`;
+ html = `See Material`;
}
}
return `
${html}
`
} },
+ { name: "expenses", label: "Other Expense", align: "center", min_width: 150, resize: true, template: function (text) {
+ if(text.type=="project" || text.type=="milestone" || text.type=="header"){
+ return;
+ }
+ let html = ``;
+ var assign_expense = text.assign_expense
+
+ if(!assign_expense || !assign_expense.length){
+ html = `No Expense`;
+ }else{
+ if(assign_expense.length > 0 ){
+ html = `See Expense`;
+ }
+ }
+ return `
+ ${html}
+
`
+ } },
{ name: "tools", label: "Tools", align: "center", min_width: 150, resize: true, template: function (text) {
if(text.type=="project" || text.type=="milestone" || text.type=="header"){
return;
diff --git a/edit-mode/function/materialResource.js b/edit-mode/function/materialResource.js
index 4314080..1c69f8c 100644
--- a/edit-mode/function/materialResource.js
+++ b/edit-mode/function/materialResource.js
@@ -200,9 +200,6 @@ $(document).ready(function () {
success: function (data) {
if (data && data.code === 200) {
material_id = data.data.id;
- // actionHappen = true;
- // gantt.alert("Material Request Success!");
- // tableMaterial.draw();
resetFormAssignMaterial();
let payloadAssign = {
@@ -211,7 +208,6 @@ $(document).ready(function () {
material_id: material_id,
qty_planning: qty_planning,
plan_date: plan_date
- // budget: budget
}
$.ajax({
data: JSON.stringify(payloadAssign),
@@ -250,36 +246,6 @@ $(document).ready(function () {
}
});
- // let material_id = $("#select-material").val();
-
- // if (!material_id || material_id < 0) {
- // gantt.alert("Please choose material to assign!");
- // $('#btn-assign-material').html('Assign');
- // $('#btn-assign-material').prop("disabled", false);
- // return false
- // }
-
- // if (!qty_planning || qty_planning < 0) {
- // gantt.alert("Please input qty material!");
- // $('#btn-assign-material').html('Assign');
- // $('#btn-assign-material').prop("disabled", false);
- // return false
- // }
-
- // if(!budget || budget < 0){
- // gantt.alert("Please input price per-unit!");
- // $('#btn-assign-material').html('Assign');
- // $('#btn-assign-material').prop("disabled",false);
- // return false
- // }
-
- // if(material_id === null){
- // gantt.alert("Material Assign Failed, try again later!");
- // resetFormAssignMaterial();
- // }else{
-
- // }
-
});
// delete from row
diff --git a/edit-mode/function/reportActivity.js b/edit-mode/function/reportActivity.js
index c555ddd..47f3ef6 100644
--- a/edit-mode/function/reportActivity.js
+++ b/edit-mode/function/reportActivity.js
@@ -31,8 +31,6 @@ $(document).ready(function () {
$("#table_report tbody").on("click", ".btn-update-status", function () {
idStatus = $(this).data('id');
var dataRow = tableRa.row($(this).parents('tr')).data();
- // var data_row = table.row( $(this).parents('tr') ).data()
- console.log("data row", dataRow)
let nameMaterial = $(this).data('material-name');
let start = moment(dataRow.start_activity).format("YYYY-MM-DD");
@@ -116,9 +114,13 @@ $(document).ready(function () {
},
"columns": [
{ data: 'material_name', name: 'material_name' },
+ { data: 'type', name: 'type', render: function(data, type){
+ if(data == 'expense')
+ return "Lainnya"
+ return "Material"
+ }},
{
data: 'qty_planning', render: function (data, type) {
- console.log("render", [data, type]);
return data ? formatRupiah(data) : '-'
}
},
@@ -131,22 +133,6 @@ $(document).ready(function () {
}
},
{ data: 'uom', name: 'uom' },
- // {
- // 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',
@@ -165,6 +151,7 @@ $(document).ready(function () {
"data": function (d) {
d.idAmi = assignMaterialId;
d.idAct = activityId;
+ d.materialName = materialName;
d.type = 'actual';
}
},
@@ -238,7 +225,6 @@ $(document).ready(function () {
processResults: function (result) {
return {
results: $.map(result, function (item) {
- // console.log("cek item", item)
return {
text: item.name,
id: item.id,
@@ -269,7 +255,6 @@ $(document).ready(function () {
processResults: function (result) {
return {
results: $.map(result, function (item) {
- // console.log("cek item", item)
return {
text: item.name,
id: item.id,
@@ -311,69 +296,34 @@ $(document).ready(function () {
$("#modal_report_activity_material").on("click", "#show_form_ra_material", function () {
$(this).hide();
- // $("#hide_form_ra_material").show();
$("#form_report_activity_material").show();
});
$("#modal_report_activity_material").on("click", "#hide_form_ra_material", function () {
$(this).hide();
resetFormAddRaMaterial()
- // $("#show_form_ra_material").show();
});
- // $("#form_report_activity").on("submit", function (e) {
- // e.preventDefault();
- // var formData = new FormData(this);
- // formData.append("activity_id", activityId);
- // formData.append("gantt", true);
- // let idRa = $("#id_ra").val();
- // actionHappen = true;
- // if (idRa && idRa != "") {
- // $('#btn_add_ra').html('Updating..');
- // $('#btn_add_ra').prop("disabled", true);
- // formData.append("_method", "PUT");
- // updateRa(formData, idRa);
- // } else {
- // $('#btn_add_ra').html('Adding..');
- // $('#btn_add_ra').prop("disabled", true);
- // submitRa(formData);
- // }
- // });
-
$("#form_report_activity").on("submit", function (e) {
e.preventDefault();
- console.log("submit status")
let valEnd = $('#ra_date_end_activity').val()
let valStart = $('#ra_date_start_activity').val()
let valStatus = $('#ra_select_status').val()
const compDate = moment(valEnd).isBefore(moment(valStart))
- console.log({ valEnd, valStart, compDate })
if (valStatus == 'done' && compDate) {
gantt.alert("End Activity Date cannot be lower than Start Activity Date");
} else {
var formData = new FormData(this);
- // formData.append("assign_material_id", idStatus);
formData.append("activity_id", activityId);
actionHappen = true;
$('#btn_add_ra').html('Updating..');
$('#btn_add_ra').prop("disabled", true);
submitStatus(formData);
-
- // if (idRa && idRa != "") {
- // $('#btn_add_ra').html('Updating..');
- // $('#btn_add_ra').prop("disabled", true);
- // formData.append("_method", "PUT");
- // updateRa(formData, idRa);
- // } else {
- // $('#btn_add_ra').html('Adding..');
- // $('#btn_add_ra').prop("disabled", true);
- // submitStatus(formData, idStatus);
- // }
}
@@ -383,9 +333,7 @@ $(document).ready(function () {
e.preventDefault();
var formData = new FormData(this);
formData.append("activity_id", activityId);
- // formData.append("assign_material_id", assignMaterialId)
- // formData.append("gantt", true);
- console.log("test nih ", formData);
+ formData.append("assign_material_id", assignMaterialId);
let idRa = $("#id_ra_material").val();
actionHappen = true;
if (idRa && idRa != "") {
@@ -456,7 +404,7 @@ $(document).ready(function () {
}
}
- async function submitRaMaterial(formData) {
+ async function submitRaMaterial(formData, id) {
let qty_actual = $("#volume_pekerjaan_material").val();
formData.set('qty', qty_actual);
const result = await axiosInstance
@@ -545,7 +493,7 @@ $(document).ready(function () {
materialName = $(this).data('material-name');
// console.log(" okeee ",{ assignMaterialId, activityId, materialName });
- $("#report_activity_material_title").html(`Report Activity Actual Material ${materialName}`)
+ $("#report_activity_material_title").html(`Report Activity Actual ${materialName}`)
$("#modal_report_activity").hide();
$("#form_report_activity_material").show();
@@ -576,7 +524,7 @@ $(document).ready(function () {
assignMaterialId = $(this).data('id');
materialName = $(this).data('material-name');
// console.log(" okeee ",{ assignMaterialId, activityId, materialName });
- $("#report_activity_material_title").html(`Report Activity Plan Material ${materialName}`)
+ $("#report_activity_material_title").html(`Report Activity Plan ${materialName}`)
$("#modal_report_activity").hide();
// $("#show_form_ra_material").hide();
$("#activity_material_plan").show();
@@ -591,15 +539,6 @@ $(document).ready(function () {
'margin-top': '40px',
});
tableRaMaterialPlan.draw();
-
- // $(".modal-dialog .modal-lg").css({
- // // 'opacity': '3',
- // 'padding-top': '20px',
- // });
-
- // }, 1000);
-
- // tableInputProgress.draw();
});
function deleteRa(id) {
diff --git a/edit-mode/index.html b/edit-mode/index.html
index d30cd32..29860a5 100644
--- a/edit-mode/index.html
+++ b/edit-mode/index.html
@@ -324,6 +324,73 @@
+
+
+
+
+
+
+
+
+
+ Description |
+ QTY |
+ UOM |
+ Price |
+ Planning Date |
+ Actions |
+
+
+
+
+
+
+
+
+
+
+