Browse Source

solve conflict and rename Volume Actual

pull/1/head
wahyuun 1 year ago
parent
commit
180d06073d
  1. 217
      edit-mode/function/activityLocation.js
  2. 12
      edit-mode/function/expenseResource.js
  3. 198
      edit-mode/function/function.js
  4. 53
      edit-mode/function/ganttConfig.js
  5. 18
      edit-mode/function/ganttEvent.js
  6. 37
      edit-mode/function/ganttSettings.js
  7. 23
      edit-mode/function/humanResource.js
  8. 22
      edit-mode/function/materialResource.js
  9. 21
      edit-mode/function/milestone.js
  10. 151
      edit-mode/function/reportActivity.js
  11. 135
      edit-mode/function/restActivityLink.js
  12. 31
      edit-mode/index.html
  13. 30
      view-mode/function/function.js
  14. 30
      view-mode/function/ganttEvent.js
  15. 153
      view-mode/function/overlaySCurve.js
  16. 108
      view-mode/function/reportActivity.js
  17. 15
      view-mode/function/restActivityLink.js

217
edit-mode/function/activityLocation.js

@ -5,36 +5,29 @@ let long = 106.559242;
let zoom = 10; let zoom = 10;
let currentIdAct = 0; let currentIdAct = 0;
let map = L.map('map_activity').setView([lat, long], zoom); let map = L.map('map_activity').setView([lat, long], zoom);
let drawnItems = new L.FeatureGroup().addTo(map);
let inter = 5; let inter = 5;
let circLat = "", let circLat = "",
circLong = ""; circLong = "";
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors' attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
}).addTo(map); }).addTo(map);
let drawnItem = L.featureGroup().addTo(map);
var drawControl = new L.Control.Draw({ var drawControl = new L.Control.Draw({
draw: { draw: {
circlemarker: false, circlemarker: false,
circle:false, circle: false,
polyline: false polyline: false
}, },
edit:{
featureGroup:drawnItem,
edit:false,
delete:false
}
}); });
var drawnControlEdit = new L.Control.Draw({ var drawnControlEdit = new L.Control.Draw({
draw: false, draw: false,
edit:{ edit: {
featureGroup:drawnItem, featureGroup: drawnItems,
delete:true delete: true
} }
}); });
@ -42,39 +35,72 @@ map.addControl(drawControl);
// add searching location (nominatim) on map // add searching location (nominatim) on map
L.Control.geocoder().addTo(map); L.Control.geocoder().addTo(map);
function addDrawnLayer(layer) {
drawnItems.addLayer(layer);
}
function openActivityMap(id) function updateCurrentGeoJson() {
{ let shapes = [];
drawnItems.eachLayer(function (layer) {
let geojson = layer.toGeoJSON();
if (layer instanceof L.Circle) {
geojson.properties.radius = layer.getRadius();
}
shapes.push(geojson);
});
currentGeoJson = {
type: 'FeatureCollection',
features: shapes
};
}
function openActivityMap(id) {
currentIdAct = id; currentIdAct = id;
map.invalidateSize(); map.invalidateSize();
$.ajax({ $.ajax({
url: `${base_url}task/edit/${id}`, url: `${base_url}task/edit/${id}`,
type:"get", type: "get",
success: function (data) { success: function (data) {
let dataRes = data.data let dataRes = data.data
// console.log("cek data", data); // console.log("cek data", data);
drawnItem.clearLayers(); drawnItems.clearLayers();
if(dataRes.geom){ if (dataRes.geom) {
let datageojson = JSON.parse(dataRes.geom); let datageojson = JSON.parse(dataRes.geom);
currentGeoJson = datageojson currentGeoJson = datageojson
// console.log("cek data geojson", datageojson); // console.log("cek data geojson", datageojson);
if(datageojson.properties.radius){ if (datageojson.type === 'FeatureCollection') {
let radius = datageojson.properties.radius datageojson.features.forEach(feature => {
let lGeoJson = L.geoJson(datageojson); let lGeoJson = L.geoJSON(feature);
let layers = lGeoJson.getLayers(); let layers = lGeoJson.getLayers();
let latlon = layers[0].getLatLng(); layers.forEach(layer => {
let newCircle = L.circle([latlon.lat,latlon.lng], {radius: radius}); let radius = layer.feature.properties.radius;
drawnItem.addLayer(newCircle); if (radius) {
// console.log("cek layers", layers[0]); let latlon = layer.getLatLng();
}else{ let circle = L.circle([latlon.lat, latlon.lng], { radius: radius });
let lGeoJson = L.geoJson(datageojson); addDrawnLayer(circle);
let layers = lGeoJson.getLayers(); }
drawnItem.addLayer(layers[0]); else {
addDrawnLayer(layer)
}
});
});
} else {
if (datageojson.properties.radius) {
let radius = datageojson.properties.radius
let lGeoJson = L.geoJson(datageojson);
let layers = lGeoJson.getLayers();
let latlon = layers[0].getLatLng();
let newCircle = L.circle([latlon.lat, latlon.lng], { radius: radius });
addDrawnLayer(newCircle)
// console.log("cek layers", layers[0]);
} else {
let lGeoJson = L.geoJson(datageojson);
let layers = lGeoJson.getLayers();
addDrawnLayer(layers[0])
}
} }
actionLocationAc = "edit"; actionLocationAc = "edit";
drawControl.remove();
map.addControl(drawnControlEdit); map.addControl(drawnControlEdit);
}else{ } else {
currentGeoJson = ""; currentGeoJson = "";
actionLocationAc = "add"; actionLocationAc = "add";
drawnControlEdit.remove(); drawnControlEdit.remove();
@ -89,7 +115,7 @@ function openActivityMap(id)
} }
$('#modal_activity_location').on('hide.bs.modal', function (event) { $('#modal_activity_location').on('hide.bs.modal', function (event) {
currentGeoJson ="" currentGeoJson = ""
currentIdAct = 0; currentIdAct = 0;
actionLocationAc = "add"; actionLocationAc = "add";
drawnControlEdit.remove(); drawnControlEdit.remove();
@ -100,7 +126,7 @@ $('#modal_activity_location').on('hide.bs.modal', function (event) {
// map initialization // map initialization
$(document).ready(function () { $(document).ready(function () {
let intervalMap = setInterval(function () { let intervalMap = setInterval(function () {
if(inter=0){ if (inter = 0) {
clearInterval(intervalMap) clearInterval(intervalMap)
} }
map.invalidateSize(); map.invalidateSize();
@ -113,7 +139,7 @@ $(document).ready(function () {
if (type === 'marker') { if (type === 'marker') {
let latlong = layer.getLatLng(); let latlong = layer.getLatLng();
// console.log("cek latlong", latlong); // console.log("cek latlong", latlong);
circLat = latlong.lat circLat = latlong.lat
circLong = latlong.lng circLong = latlong.lng
$("#modal_radius").modal("show"); $("#modal_radius").modal("show");
// Do marker specific actions // Do marker specific actions
@ -127,22 +153,22 @@ $(document).ready(function () {
// console.log("cek layer", layer.toGeoJSON()); // console.log("cek layer", layer.toGeoJSON());
// layer.bindTooltip("cek"); // layer.bindTooltip("cek");
// Do whatever else you need to. (save to db; add to map etc) // Do whatever else you need to. (save to db; add to map etc)
drawnItem.addLayer(layer); addDrawnLayer(layer);
drawControl.remove(); updateCurrentGeoJson();
map.addControl(drawnControlEdit); map.addControl(drawnControlEdit);
// map.addLayer(layer); // map.addLayer(layer);
}); });
map.on(L.Draw.Event.DELETED, function (e) { map.on(L.Draw.Event.DELETED, function (e) {
var type = e.layerType, var type = e.layerType;
layer = e.layer; let layers = e.layers.getLayers();
layers.forEach(layer => {
drawnItems.removeLayer(layer);
});
updateCurrentGeoJson()
// console.log("cek layer", layer.toGeoJSON()); // console.log("cek layer", layer.toGeoJSON());
// Do whatever else you need to. (save to db; add to map etc) // Do whatever else you need to. (save to db; add to map etc)
currentGeoJson = "";
drawnItem.removeLayer(layer);
drawnControlEdit.remove();
map.addControl(drawControl);
// map.addLayer(layer); // map.addLayer(layer);
}); });
@ -150,103 +176,132 @@ $(document).ready(function () {
// var type = e.layerType, // var type = e.layerType,
// layer = e.layer; // layer = e.layer;
let layers = e.layers.getLayers(); let layers = e.layers.getLayers();
let layer = layers[0] layers.forEach(layer => {
let geoJson = layers[0].toGeoJSON(); let geoJson = layer.toGeoJSON();
if(layer instanceof L.Circle){ if (layer instanceof L.Circle) {
geoJson.properties.radius = layer.getRadius(); geoJson.properties.radius = layer.getRadius();
currentGeoJson = geoJson }
}else{ updateCurrentGeoJson();
currentGeoJson = geoJson });
}
// console.log("cek layer", layers[0].toGeoJSON()); // console.log("cek layer", layers[0].toGeoJSON());
// console.log("cek layer", layer.toGeoJSON()); // console.log("cek layer", layer.toGeoJSON());
// Do whatever else you need to. (save to db; add to map etc) // Do whatever else you need to. (save to db; add to map etc)
// drawnItem.removeLayer(layer);
// drawnControlEdit.remove(); // drawnControlEdit.remove();
// map.addControl(drawControl); // map.addControl(drawControl);
// map.addLayer(layer); // map.addLayer(layer);
}); });
$("#modal_activity_location").on("click", "#btn_save_location", function() { $("#modal_activity_location").on("click", "#btn_save_location", function () {
if(currentGeoJson==""){ if (currentGeoJson == "") {
gantt.confirm({ gantt.confirm({
text: "Lokasi belum ditentukan!, lanjutkan?", text: "Lokasi belum ditentukan!, lanjutkan?",
ok:"Submit", ok: "Submit",
cancel:"Cancel", cancel: "Cancel",
callback: function(result){ callback: function (result) {
if(!result){ if (!result) {
return false return false
}else{ } else {
submitLocation(); submitShapes();
} }
} }
}); });
}else{ } else {
submitLocation() submitShapes();
} }
}); });
function submitLocation() function submitShapes() {
{ let payload
if (currentGeoJson && currentGeoJson != "") {
payload = {
geom: JSON.stringify(currentGeoJson),
}
} else {
payload = {
geom: null,
}
}
$.ajax({
data: JSON.stringify(payload),
url: `${base_url}task/update-regular/${currentIdAct}`,
type: "PUT",
processData: false,
contentType: false,
success: function (data) {
$("#modal_activity_location").modal("hide");
currentGeoJson = ""
currentIdAct = 0;
gantt.alert("Activity Location successfully updated!");
},
error: function (data) {
$("#modal_activity_location").modal("hide");
currentGeoJson = ""
currentIdAct = 0;
gantt.alert("Activity Location failed updated!, try again later!");
}
});
}
function submitLocation() {
let payload let payload
if(currentGeoJson && currentGeoJson!=""){ if (currentGeoJson && currentGeoJson != "") {
payload = { payload = {
geom: JSON.stringify(currentGeoJson), geom: JSON.stringify(currentGeoJson),
} }
}else{ } else {
payload = { payload = {
geom: null, geom: null,
} }
} }
$.ajax({ $.ajax({
data: JSON.stringify(payload), data: JSON.stringify(payload),
url: `${base_url}task/update-regular/${currentIdAct}`, url: `${base_url}task/update-regular/${currentIdAct}`,
type: "PUT", type: "PUT",
processData: false, processData: false,
contentType: false, contentType: false,
success: function (data) { success: function (data) {
$("#modal_activity_location").modal("hide"); $("#modal_activity_location").modal("hide");
currentGeoJson ="" currentGeoJson = ""
currentIdAct = 0; currentIdAct = 0;
gantt.alert("Activity Location successfully updated!"); gantt.alert("Activity Location successfully updated!");
}, },
error: function (data) { error: function (data) {
$("#modal_activity_location").modal("hide"); $("#modal_activity_location").modal("hide");
currentGeoJson ="" currentGeoJson = ""
currentIdAct = 0; currentIdAct = 0;
gantt.alert("Activity Location failed updated!, try again later!"); gantt.alert("Activity Location failed updated!, try again later!");
} }
}); });
} }
$("#modal_radius").on("click", "#btn_save_radius", function() { $("#modal_radius").on("click", "#btn_save_radius", function () {
let radius = $("#buffer_radius").val(); let radius = $("#buffer_radius").val();
if(radius <= 0){ if (radius <= 0) {
gantt.alert("radius buffer tidak boleh kurang dari atau sama dengan 0!!"); gantt.alert("radius buffer tidak boleh kurang dari atau sama dengan 0!!");
}else{ } else {
submitCircle(radius); submitCircle(radius);
} }
}); });
}); });
function submitCircle(radius) function submitCircle(radius) {
{ let circle = L.circle([circLat, circLong], { radius: radius });
let circle = L.circle([circLat,circLong], {radius: radius});
let geojsoncircle = circle.toGeoJSON(); let geojsoncircle = circle.toGeoJSON();
geojsoncircle.properties.radius = radius geojsoncircle.properties.radius = radius
currentGeoJson = geojsoncircle currentGeoJson = geojsoncircle
// console.log("geojsoncircle", geojsoncircle); addDrawnLayer(circle);
drawnItem.addLayer(circle); updateCurrentGeoJson();
drawControl.remove();
map.addControl(drawnControlEdit); map.addControl(drawnControlEdit);
$("#modal_radius").modal('hide'); $("#modal_radius").modal('hide');
} }
$('#modal_radius').on('hide.bs.modal', function (event) { $('#modal_radius').on('hide.bs.modal', function (event) {
circLat = 0 circLat = 0
circLong = 0 circLong = 0
$("#buffer_radius").val(""); $("#buffer_radius").val("");
}); });

12
edit-mode/function/expenseResource.js

@ -4,6 +4,7 @@ function resetFormAssignexpense() {
$('#select-expense').val(null).trigger("change"); $('#select-expense').val(null).trigger("change");
$('#select-expense').find('option').remove(); $('#select-expense').find('option').remove();
$('#select-expense').val(""); $('#select-expense').val("");
$('#uom-req-expense').val(null).trigger('change');
$('#form-assign-expense').trigger("reset"); $('#form-assign-expense').trigger("reset");
$('#btn-assign-expense').html('Assign'); $('#btn-assign-expense').html('Assign');
$('#btn-assign-expense').prop("disabled", false); $('#btn-assign-expense').prop("disabled", false);
@ -59,6 +60,7 @@ $(document).ready(function () {
}); });
function deleteexpenseAssign(id) { function deleteexpenseAssign(id) {
searchReport(id);
$.ajax({ $.ajax({
url: `${base_url}assign-material/delete/${id}`, url: `${base_url}assign-material/delete/${id}`,
type: "DELETE", type: "DELETE",
@ -131,7 +133,15 @@ $(document).ready(function () {
cache: false cache: false
} }
}); });
// $('#required-date-req-expense').datepicker({
// format: 'dd-mm-yyyy', // Set the desired format
// autoclose: true // Close the datepicker when a date is selected
// });
//
// $('#required-date-plan-expense').datepicker({
// format: 'dd-mm-yyyy', // Set the desired format
// autoclose: true // Close the datepicker when a date is selected
// });
$("#form-assign-expense").on('submit', function (e) { $("#form-assign-expense").on('submit', function (e) {
e.preventDefault(); e.preventDefault();

198
edit-mode/function/function.js

@ -14,6 +14,46 @@ function getUrlParameter(sParam) {
return false; 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) => { const formatNumber = (angka) => {
var number_string = angka.replace(/[^,\d]/g, '').toString(), var number_string = angka.replace(/[^,\d]/g, '').toString(),
split = number_string.split(','), split = number_string.split(','),
@ -212,6 +252,7 @@ function updateActivity(id) {
gantt.getTask(id).assign_hr = data.assign_hr; gantt.getTask(id).assign_hr = data.assign_hr;
gantt.getTask(id).assign_material = data.assign_material; gantt.getTask(id).assign_material = data.assign_material;
gantt.getTask(id).assign_tools = data.assign_tools; gantt.getTask(id).assign_tools = data.assign_tools;
gantt.getTask(id).assign_expense = data.assign_expense;
gantt.getTask(id).bobot_planning = data.bobot_planning; gantt.getTask(id).bobot_planning = data.bobot_planning;
gantt.getTask(id).rencana_biaya = data.rencana_biaya; gantt.getTask(id).rencana_biaya = data.rencana_biaya;
gantt.getTask(id).biaya_actual = data.biaya_actual; gantt.getTask(id).biaya_actual = data.biaya_actual;
@ -339,7 +380,7 @@ function initializationColumn() {
if (data.status == "not yet have") { if (data.status == "not yet have") {
addShowHideColumn(); addShowHideColumn();
} else if (data.status == "not have access") { } else if (data.status == "not have access") {
gantt.config.columns = createColumnsConfig(columnShows);
} else { } else {
setUpForShowHideColumn(data); setUpForShowHideColumn(data);
} }
@ -366,6 +407,36 @@ function setGanttOpen() {
localStorage.setItem('ganttOpen', JSON.stringify(ganttOpen)); localStorage.setItem('ganttOpen', JSON.stringify(ganttOpen));
} }
function compareData(data){
expandTask();
var allTasks = [];
var taskCount = gantt.getTaskCount();
for (var i = 0; i < taskCount; i++) {
var task = gantt.getTaskByIndex(i);
allTasks.push(task);
}
allTasks.forEach((task, index) => {
if (task.progress > 0 && task.progress < 1) {
// task.end_date = moment().format('YYYY-MM-DD HH:mm:ss');
// task.end_date = new Date();
}
if (task.start_date != data.data[index].start_date) {
gantt.getTask(task.id).start_date = task.start_date;
}
if (task.end_date != data.data[index].end_date) {
gantt.getTask(task.id).end_date = task.end_date;
}
if (task.planned_start != data.data[index].planned_start) {
gantt.getTask(task.id).planned_start = task.planned_start;
}
if (task.planned_end != data.data[index].planned_end) {
gantt.getTask(task.id).planned_end = task.planned_end;
}
gantt.updateTask(task.id);
});
}
function getGanttOpen() { function getGanttOpen() {
let ganttOpen = localStorage.getItem('ganttOpen'); let ganttOpen = localStorage.getItem('ganttOpen');
if (ganttOpen) { if (ganttOpen) {
@ -513,7 +584,7 @@ function submitShowHideColumn(allColumn) {
version_gantt_id: ganttId, version_gantt_id: ganttId,
columns: allColumn columns: allColumn
} }
gantt.config.columns = createColumnsConfig(allColumn);
$.ajax({ $.ajax({
data: JSON.stringify(payload), data: JSON.stringify(payload),
url: `${base_url}gantt-show-hide/add`, url: `${base_url}gantt-show-hide/add`,
@ -537,7 +608,12 @@ function setUpForShowHideColumn(data) {
columns.map((val, index) => { columns.map((val, index) => {
configColumn[val.column_name] = val.show configColumn[val.column_name] = val.show
}); });
if (!isBaselineSet) {
// configColumn.planned_start = undefined;
// configColumn.planned_end = undefined;
// configColumn.planned_duration = undefined;
// configColumn.baseline_progress = undefined;
}
gantt.config.columns = createColumnsConfig(configColumn); gantt.config.columns = createColumnsConfig(configColumn);
gantt.render(); gantt.render();
@ -555,10 +631,10 @@ function updateShowHideColumn(data) {
processData: false, processData: false,
contentType: false, contentType: false,
success: function (data) { success: function (data) {
console.log(data); // console.log(data);
}, },
error: function (data) { error: function (data) {
console.log(data); // console.log(data);
} }
}); });
} }
@ -569,6 +645,8 @@ function colAjaxReq(type) {
type: "GET", type: "GET",
success: function (data) { success: function (data) {
let ganttColumnsByType = data.data; let ganttColumnsByType = data.data;
// console.log("ini gantt field ", ganttColumnsByType);
// console.log("ini column ", gantt.config.columns);
let isFound = false; let isFound = false;
x = gantt.config.columns.filter((val) => { x = gantt.config.columns.filter((val) => {
isFound = ganttColumnsByType.find(obj => { isFound = ganttColumnsByType.find(obj => {
@ -576,6 +654,10 @@ function colAjaxReq(type) {
}); });
if (isFound) if (isFound)
return val; return val;
if (isFound == false){
// console.log("ini gantt field !isFound ", val);
}
}); });
gantt.config.columns = x.filter(item => item); gantt.config.columns = x.filter(item => item);
allColumns = gantt.config.columns; allColumns = gantt.config.columns;
@ -633,7 +715,107 @@ function expandTask() {
gantt.render(); gantt.render();
} }
function resetActivity() { // Function to get the earliest planned start date among all tasks
localStorage.setItem('batchEntity', ''); function getEarliestTaskDate() {
gantt.alert("Actiivity Saved"); var earliestDate = null;
gantt.eachTask(function (task) {
var taskStartDate = task.planned_start || task.start_date;
if (!earliestDate || task.planned_start < earliestDate) {
earliestDate = taskStartDate;
if (task.start_date < earliestDate) {
earliestDate = task.start_date;
}
}
});
return earliestDate;
}
// Function to get the latest planned end date among all tasks
function getLatestTaskDate() {
var latestDate = null;
gantt.eachTask(function (task) {
var taskEndDate = task.planned_end || task.end_date;
if (!latestDate || task.planned_end > latestDate) {
latestDate = taskEndDate;
if (task.end_date > latestDate) {
latestDate = task.end_date;
}
}
});
return latestDate;
}
function batchUpdate(){
let data = localStorage.getItem('batchEntity');
$("body").addClass("loading");
return gantt.ajax.post({
headers: {
"Content-Type": "application/json",
"Authorization": `Bearer ${token}`
},
url: base_url + "activity/batch-update/" + ganttId,
data: data
}).then(function (response) {
$("body").removeClass("loading");
localStorage.setItem('batchEntity', '');
$("#save-activity").hide();
$("#save-separator").hide();
sendStorage();
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();
if (batchEntity && batchEntity != '') {
event.preventDefault()
return event.returnValue = 'You have unsaved changes. Are you sure you want to leave this page?';
}
});
function sendStorage(){
const batchEntityData = localStorage.getItem('batchEntity');
window.parent.postMessage({ batchEntity: batchEntityData }, '*');
}
function updateLinksLag(data) {
data.data.forEach(task => {
data.links.forEach(link => {
if (link.target == task.id && task.actual_start != null) {
let predecessor = data.data.find(item => item.id == link.source);
if (predecessor) {
let lag;
if (isBaselineSet) {
switch (link.type) {
case "0": // FS
lag = gantt.calculateDuration(new Date(predecessor.end_date), new Date(task.start_date));
break;
case "1": // SS
lag = gantt.calculateDuration(new Date(predecessor.start_date), new Date(task.start_date));
break;
case "2": // FF
lag = gantt.calculateDuration(new Date(predecessor.end_date), new Date(task.end_date));
break;
case "3": // SF
lag = gantt.calculateDuration(new Date(predecessor.start_date), new Date(task.end_date));
break;
default:
// Handle an unknown link type if needed
break;
}
link.lag = lag;
}
}
}
});
});
} }

53
edit-mode/function/ganttConfig.js

@ -10,6 +10,8 @@ let userToVersionGanttId = 0
let activityId = 0; let activityId = 0;
let actionHappen = false; let actionHappen = false;
let activityName = ""; let activityName = "";
let activityEarlyStart;
let activityEarlyFinish;
let token = getUrlParameter("token"); let token = getUrlParameter("token");
let forceDurationUpdateTriggered = false; let forceDurationUpdateTriggered = false;
let editEndDateDurationTriggered = false; let editEndDateDurationTriggered = false;
@ -22,7 +24,12 @@ const axiosInstance = axios.create({
"Content-type": "application/json" "Content-type": "application/json"
} }
}); });
const axiosInstanceMultipart = axios.create({
headers: {
"Content-Type": "multipart/form-data",
"Authorization": `Bearer ${token}`,
}
});
axiosInstance.interceptors.request.use(async (config) => { axiosInstance.interceptors.request.use(async (config) => {
try { try {
$("body").addClass("loading"); $("body").addClass("loading");
@ -172,6 +179,8 @@ const editor = {
planned_start: { type: "date", map_to: "planned_start", min: new Date(2018, 0, 1) }, planned_start: { type: "date", map_to: "planned_start", min: new Date(2018, 0, 1) },
planned_end: { type: "end_date", map_to: "planned_end", min: new Date(2018, 0, 1) }, planned_end: { type: "end_date", map_to: "planned_end", min: new Date(2018, 0, 1) },
planned_duration: { type: "duration", map_to: "planned_duration", min: 0, max: 365, formatter: formatter }, planned_duration: { type: "duration", map_to: "planned_duration", min: 0, max: 365, formatter: formatter },
// early_start: { type: "date", map_to: "planned_start", min: new Date(2018, 0, 1) },
// early_end: { type: "end_date", map_to: "planned_start", min: new Date(2018, 0, 1) },
duration: { type: "duration", map_to: "duration", min: 0, max: 365, formatter: formatter }, duration: { type: "duration", map_to: "duration", min: 0, max: 365, formatter: formatter },
cost: { type: "number", map_to: "rencana_biaya", min: 0 }, cost: { type: "number", map_to: "rencana_biaya", min: 0 },
costActual: { type: "number", map_to: "biaya_actual", min: 0 }, costActual: { type: "number", map_to: "biaya_actual", min: 0 },
@ -266,28 +275,48 @@ function createColumnsConfig(selectedColumns) {
} }
var allColumns = [ var allColumns = [
{ name: "action", label: colHeader, align: "left", min_width: 115, template: colContent, resize: true }, { name: "action", label: colHeader, align: "left", min_width: 115, template: colContent, resize: true },
{ name: "kode_sortname", label: "Kode / Sortname", align: "center", min_width: 120, editor: editor.kode_sortname, resize: true }, { name: "kode_sortname", label: "Kode / Sortname", align: "center", min_width: 120, editor: editor.kode_sortname, resize: true },
{ name: "text", label: "Activity", tree: true, min_width: 150, editor: editor.text, resize: true }, { name: "text", label: "Activity", tree: true, min_width: 150, editor: editor.text, resize: true },
{ {
name: "planned_start", label: "Baseline Start", align: "center", min_width: 80, editor: editor.planned_start, resize: true, template: function (text) { name: "planned_start", label: "Baseline Start", align: "center", min_width: 80, editor: editor.planned_start, resize: true, template: function (text) {
if (!text.planned_start) { if (!text.planned_start) {
return text.start_date; return moment(text.start_date).format("DD-MM-YYYY");
} }
return text.planned_start; return moment(text.planned_start).format("DD-MM-YYYY");
} }
}, },
{ name: "start_date", label: "Actual Start", align: "center", min_width: 80, editor: editor.start_date, resize: true },
{ {
name: "planned_end", label: "Baseline Finish", align: "center", min_width: 80, editor: editor.planned_end, resize: true, template: function (text) { name: "planned_end", label: "Baseline Finish", align: "center", min_width: 80, editor: editor.planned_end, resize: true, template: function (text) {
if (!text.planned_end) { if (!text.planned_end) {
return text.end_date; return moment(text.end_date).format("DD-MM-YYYY");
} }
return text.planned_end; return moment(text.planned_end).format("DD-MM-YYYY");
} }
}, },
{ name: "end_date", label: "Actual Finish", align: "center", min_width: 80, editor: editor.end_date, resize: true }, { name: "start_date", label: "Early Start", align: "center", min_width: 80, editor: editor.start_date, resize: true, template: function (text) {
return moment(text.start_date).format("DD-MM-YYYY");
}
},
{ name: "end_date", label: "Early Finish", align: "center", min_width: 80, editor: editor.end_date, resize: true, template: function (text) {
return moment(text.end_date).format("DD-MM-YYYY");
}
},
{ name: "actual_start", label: "Actual Start", align: "center", min_width: 80, resize: true, template: function (text) {
if (!text.actual_start) {
return '';
}
return moment(text.actual_start).format("DD-MM-YYYY");
}
},
{ name: "actual_end", label: "Actual Finish", align: "center", min_width: 80, resize: true, template: function (text) {
if (!text.actual_end) {
return '';
}
return moment(text.actual_end).format("DD-MM-YYYY");
}
},
{ {
name: "bobot_planning", label: "Bobot (%)", align: "center", editor: editor.bobot_planning, resize: true, min_width: 115, template: function (text) { name: "bobot_planning", label: "Bobot (%)", align: "center", editor: editor.bobot_planning, resize: true, min_width: 115, template: function (text) {
let bobot = parseFloat(text.bobot_planning); let bobot = parseFloat(text.bobot_planning);
@ -344,7 +373,7 @@ var allColumns = [
}) })
return plannedDuration; return plannedDuration;
}}, }},
{ name: "duration", label: "Actual Duration (Day)", align: "center", min_width: 50, resize: true, editor: editor.duration }, { name: "duration", label: "Duration (Day)", align: "center", min_width: 50, resize: true, editor: editor.duration },
{ {
name: "rencana_biaya", label: "Cost Planning", align: "right", 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) { if (!text.rencana_biaya) {
@ -512,6 +541,8 @@ let columnShows = {
planned_start: false, planned_start: false,
planned_end: false, planned_end: false,
planned_duration: false, planned_duration: false,
actual_start: false,
actual_end: false,
duration: true, duration: true,
rencana_biaya: true, rencana_biaya: true,
cost_actual: true, cost_actual: true,
@ -538,6 +569,8 @@ gantt.config.columns = createColumnsConfig({
planned_start: true, planned_start: true,
planned_end: true, planned_end: true,
planned_duration: true, planned_duration: true,
actual_start: true,
actual_end: true,
duration: true, duration: true,
rencana_biaya: true, rencana_biaya: true,
cost_actual: true, cost_actual: true,
@ -630,7 +663,7 @@ gantt.templates.rightside_text = function (start, end, task) {
end_date: end, end_date: end,
task: task task: task
}, 'day'); }, 'day');
var text = "<b>Overdue: " + overdue + " days</b>"; var text = "<b style='color: red;'>Overdue: " + overdue + " days</b>";
return text; return text;
} }
} }

18
edit-mode/function/ganttEvent.js

@ -10,12 +10,15 @@ gantt.attachEvent("onAfterTaskAdd", function (id, item) {
gantt.updateTask(parentId); gantt.updateTask(parentId);
} }
} }
updateRange();
}); });
gantt.attachEvent("onTaskRowClick", function (id, row) { gantt.attachEvent("onTaskRowClick", function (id, row) {
activityId = id; activityId = id;
var activity = gantt.getTaskBy("id", id); var activity = gantt.getTaskBy("id", id);
activityName = activity[0]?.name; activityName = activity[0]?.name;
activityEarlyStart = new Date(activity[0]?.start_date);
activityEarlyFinish = new Date(activity[0]?.end_date);
}); });
gantt.ext.inlineEditors.attachEvent("onBeforeEditStart", function (state) { gantt.ext.inlineEditors.attachEvent("onBeforeEditStart", function (state) {
@ -40,7 +43,16 @@ gantt.ext.inlineEditors.attachEvent("onBeforeEditStart", function (state) {
} }
return true return true
}); });
function updateRange(){
var range = gantt.getSubtaskDates();
var chart = gantt.getState();
if(range.start_date.valueOf() <= chart.min_date.valueOf() || range.end_date.valueOf() >= chart.max_date.valueOf()){
gantt.config.start_date = gantt.date.add(range.start_date, -1, "day");
gantt.config.end_date = gantt.date.add(range.end_date, 2, "day");
gantt.render();
}
}
gantt.attachEvent("onAfterTaskUpdate", updateRange);
gantt.attachEvent("onBeforeTaskUpdate", function (id, new_item) { gantt.attachEvent("onBeforeTaskUpdate", function (id, new_item) {
// format progress // format progress
let progress = new_item.progress; let progress = new_item.progress;
@ -168,11 +180,11 @@ gantt.attachEvent("onGanttScroll", function (left, top){
var max_allowed_date = gantt.date.add(gantt.config.end_date, -1, "day"); var max_allowed_date = gantt.date.add(gantt.config.end_date, -1, "day");
var repaint = false; var repaint = false;
if (+left_date <= +min_allowed_date){ if (earliest && +left_date <= +min_allowed_date && +left_date >= +earliest){
gantt.config.start_date = gantt.date.add(gantt.config.start_date, -1, "day"); gantt.config.start_date = gantt.date.add(gantt.config.start_date, -1, "day");
repaint = true; repaint = true;
} }
if (+right_date >= +max_allowed_date){ if (latest && +right_date >= +max_allowed_date && +right_date <= +latest){
gantt.config.end_date = gantt.date.add(gantt.config.end_date, 1, "day"); gantt.config.end_date = gantt.date.add(gantt.config.end_date, 1, "day");
repaint = true; repaint = true;
} }

37
edit-mode/function/ganttSettings.js

@ -136,13 +136,21 @@ $(document).ready(function () {
}); });
$("#save-activity").on('click', function (event) { $("#save-activity").on('click', function (event) {
resetActivity(); batchUpdate();
}); });
$("#gantt-synchronize").on('click', function (event) { $("#gantt-synchronize").on('click', function (event) {
setSynchronize(); setSynchronize();
}); });
$("#compare-data").on('click', function (event) {
compareData(ganttTask);
});
$("#update-schedule").on('click', function (event) {
updateSchedule();
});
initHolidays(); initHolidays();
initGanttSettings(); initGanttSettings();
}); });
@ -350,7 +358,7 @@ function setBaseline() {
}); });
} }
async function setBaselineAPI() { async function importUpdate() {
expandTask(); expandTask();
var allTasks = []; var allTasks = [];
var taskCount = gantt.getTaskCount(); var taskCount = gantt.getTaskCount();
@ -381,6 +389,10 @@ async function setBaselineAPI() {
text: "Update import gagal" text: "Update import gagal"
}); });
}); });
}
async function setBaselineAPI() {
await importUpdate();
const res = await axiosInstance const res = await axiosInstance
.get(ACTIVITY_SET_BASELINE_URL, HEADER) .get(ACTIVITY_SET_BASELINE_URL, HEADER)
.then(res => res) .then(res => res)
@ -435,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() { async function setSynchronizeAPI() {
const res = await axiosInstance const res = await axiosInstance
.get(ACTIVITY_SYNCHRONIZE_REPORT_URL, HEADER) .get(ACTIVITY_SYNCHRONIZE_REPORT_URL, HEADER)

23
edit-mode/function/humanResource.js

@ -7,6 +7,8 @@ function resetFormAssign() {
$('#select-hr').val(null).trigger("change"); $('#select-hr').val(null).trigger("change");
$('#select-hr').find('option').remove(); $('#select-hr').find('option').remove();
$('#select-hr').val(""); $('#select-hr').val("");
$("#hr-start-date").val("");
$("#hr-end-date").val("");
$("#hr_role").val(""); $("#hr_role").val("");
// $("#hide-form-hr").hide(); // $("#hide-form-hr").hide();
// $("#show-form-hr").show(); // $("#show-form-hr").show();
@ -29,6 +31,8 @@ $(document).ready(function () {
"columns": [ "columns": [
{ data: 'user_name', name: 'user_name' }, { data: 'user_name', name: 'user_name' },
{ data: 'role_name', name: 'role_name' }, { data: 'role_name', name: 'role_name' },
{ data: 'start_date', name: 'start_date' },
{ data: 'end_date', name: 'end_date' },
{ {
data: 'action', data: 'action',
name: 'action', name: 'action',
@ -149,6 +153,21 @@ $(document).ready(function () {
}); });
$("#hr-start-date").on('change', (e) => {
let start_date = new Date($("#hr-start-date").val());
if (start_date < activityEarlyStart || start_date > activityEarlyFinish) {
gantt.alert("Start date should be inside activity date range !");
$("#hr-start-date").val("");
}
})
$("#hr-end-date").on('change', (e) => {
let end_date = new Date($("#hr-end-date").val());
if (end_date < activityEarlyStart || end_date > activityEarlyFinish) {
gantt.alert("End date should be inside activity date range !");
$("#hr-end-date").val("");
}
})
$("#form-assign-hr").on('submit', function (e) { $("#form-assign-hr").on('submit', function (e) {
e.preventDefault(); e.preventDefault();
@ -158,6 +177,8 @@ $(document).ready(function () {
// var formData = new FormData(this); // var formData = new FormData(this);
let users = $("#select-hr").val(); let users = $("#select-hr").val();
let start_date = $("#hr-start-date").val();
let end_date = $("#hr-end-date").val();
let user_id = []; let user_id = [];
let user_role = []; let user_role = [];
users.map((item)=>{ users.map((item)=>{
@ -175,6 +196,8 @@ $(document).ready(function () {
let payload = { let payload = {
user_id: user_id, user_id: user_id,
start_date: start_date,
end_date: end_date,
role_proyek_id: user_role, role_proyek_id: user_role,
version_gantt_id: ganttId, version_gantt_id: ganttId,
proyek_id: proyekId, proyek_id: proyekId,

22
edit-mode/function/materialResource.js

@ -4,6 +4,8 @@ function resetFormAssignMaterial() {
$('#select-material').val(null).trigger("change"); $('#select-material').val(null).trigger("change");
$('#select-material').find('option').remove(); $('#select-material').find('option').remove();
$('#select-material').val(""); $('#select-material').val("");
$('#uom-req-material').val(null).trigger('change');
$('#select-material-integration').val(null).trigger('change');
$('#form-assign-material').trigger("reset"); $('#form-assign-material').trigger("reset");
$('#btn-assign-material').html('Assign'); $('#btn-assign-material').html('Assign');
$('#btn-assign-material').prop("disabled", false); $('#btn-assign-material').prop("disabled", false);
@ -59,6 +61,7 @@ $(document).ready(function () {
}); });
function deleteMaterialAssign(id) { function deleteMaterialAssign(id) {
searchReport(id);
$.ajax({ $.ajax({
url: `${base_url}assign-material/delete/${id}`, url: `${base_url}assign-material/delete/${id}`,
type: "DELETE", type: "DELETE",
@ -164,13 +167,24 @@ $(document).ready(function () {
results: dataIntegrasiMaterial results: dataIntegrasiMaterial
}; };
}, error: function (jqXHR, textStatus, errorThrown) { }, error: function (jqXHR, textStatus, errorThrown) {
gantt.alert(`Status: ${textStatus}`); // console.log("textStatus ", textStatus);
gantt.alert(`Error thrown: ${errorThrown}`); if (textStatus != "abort") {
gantt.alert(`Error accessing URL: ${adwIntegrationUrl}/request-material/get-material-integration`); // gantt.alert(`Status: ${textStatus}`);
gantt.alert(`Data Not Found`);
// gantt.alert(`Error accessing URL: ${adwIntegrationUrl}/request-material/get-material-integration`);
}
} }
} }
}); });
// $('#required-date-req-material').datepicker({
// format: 'dd-mm-yyyy', // Set the desired format
// autoclose: true // Close the datepicker when a date is selected
// });
//
// $('#required-date-plan-material').datepicker({
// format: 'dd-mm-yyyy', // Set the desired format
// autoclose: true // Close the datepicker when a date is selected
// });
$("#form-assign-material").on('submit', function (e) { $("#form-assign-material").on('submit', function (e) {
e.preventDefault(); e.preventDefault();

21
edit-mode/function/milestone.js

@ -70,6 +70,15 @@ $(document).ready(function () {
$("#name_milestone").val(data.text); $("#name_milestone").val(data.text);
}); });
$('#due_milestone').datepicker({
format: 'dd-mm-yyyy', // Set the desired format
autoclose: true // Close the datepicker when a date is selected
});
$('#deadline_milestone').datepicker({
format: 'dd-mm-yyyy', // Set the desired format
autoclose: true // Close the datepicker when a date is selected
});
$('#modal-material').on('show.bs.modal', function (event) { $('#modal-material').on('show.bs.modal', function (event) {
@ -88,8 +97,8 @@ $(document).ready(function () {
console.log("cek data form", data); console.log("cek data form", data);
let parent = data.milestone_parent; let parent = data.milestone_parent;
var taskId = 0; var taskId = 0;
var start = moment(data.due_date, "YYYY-MM-DD"); var start = moment(data.due_date, "DD-MM-YYYY");
var end = moment(data.deadline, "YYYY-MM-DD"); var end = moment(data.deadline, "DD-MM-YYYY");
let duration = moment.duration(start.diff(end)).asDays(); let duration = moment.duration(start.diff(end)).asDays();
let nameMilestone = data.status!="" ? data.status : data.id_milestone let nameMilestone = data.status!="" ? data.status : data.id_milestone
// console.log("cek duration", Math.abs(duration)); // console.log("cek duration", Math.abs(duration));
@ -97,8 +106,8 @@ $(document).ready(function () {
taskId = gantt.addTask({ taskId = gantt.addTask({
id: Math.floor(Math.random() * 1000) + 5000, id: Math.floor(Math.random() * 1000) + 5000,
text: nameMilestone, text: nameMilestone,
start_date: data.due_date, start_date: start.format("YYYY-MM-DD"),
end_date: data.deadline, end_date: end.format("YYYY-MM-DD"),
duration: Math.abs(duration), duration: Math.abs(duration),
type: "milestone", type: "milestone",
type_activity:"milestone" type_activity:"milestone"
@ -107,8 +116,8 @@ $(document).ready(function () {
taskId = gantt.addTask({ taskId = gantt.addTask({
id: Math.floor(Math.random() * 1000) + 5000, id: Math.floor(Math.random() * 1000) + 5000,
text: nameMilestone, text: nameMilestone,
start_date: data.due_date, start_date: start.format("YYYY-MM-DD"),
end_date: data.deadline, end_date: end.format("YYYY-MM-DD"),
duration: Math.abs(duration), duration: Math.abs(duration),
type: "milestone", type: "milestone",
type_activity:"milestone" type_activity:"milestone"

151
edit-mode/function/reportActivity.js

@ -62,7 +62,15 @@ $(document).ready(function () {
$('#ra_date_end_activity').prop('disabled', true); $('#ra_date_end_activity').prop('disabled', true);
} }
}); });
// $('#ra_date_start_activity').datepicker({
// format: 'dd-mm-yyyy', // Set the desired format
// autoclose: true // Close the datepicker when a date is selected
// });
//
// $('#ra_date_end_activity').datepicker({
// format: 'dd-mm-yyyy', // Set the desired format
// autoclose: true // Close the datepicker when a date is selected
// });
$("#ra_date_end_activity").on("change", function () { $("#ra_date_end_activity").on("change", function () {
let valEnd = $(this).val() let valEnd = $(this).val()
let valStart = $('#ra_date_start_activity').val() let valStart = $('#ra_date_start_activity').val()
@ -166,6 +174,9 @@ $(document).ready(function () {
d.idAct = activityId; d.idAct = activityId;
d.materialName = materialName; d.materialName = materialName;
d.type = 'actual'; d.type = 'actual';
},
"error": function (xhr, error, code) {
console.log(xhr, error, code);
} }
}, },
"columns": [ "columns": [
@ -180,6 +191,11 @@ $(document).ready(function () {
return data ? formatRupiah(data) : '-' return data ? formatRupiah(data) : '-'
} }
}, },
{
data: 'qty_planning', render: function (data, type) {
return data ? formatRupiah(data) : '-'
}
},
{ data: 'description', name: 'description' }, { data: 'description', name: 'description' },
{ {
data: 'action', data: 'action',
@ -190,33 +206,32 @@ $(document).ready(function () {
], ],
"order": [[1, 'asc']], "order": [[1, 'asc']],
}); });
// var tableRaMaterialPlan = $("#table_activity_material_plan").DataTable({
var tableRaMaterialPlan = $("#table_activity_material_plan").DataTable({ // "processing": true,
"processing": true, // "serverSide": true,
"serverSide": true, // "ajax": {
"ajax": { // "url": `${base_url}report-activity-material/datatables`,
"url": `${base_url}report-activity-material/datatables`, // "data": function (d) {
"data": function (d) { // d.idAmi = assignMaterialId;
d.idAmi = assignMaterialId; // d.idAct = activityId;
d.idAct = activityId; // d.type = 'plan';
d.type = 'plan'; // }
} // },
}, // "columns": [
"columns": [ // { data: 'material_name', name: 'material_name' },
{ data: 'material_name', name: 'material_name' }, // {
{ // data: 'qty_planning', render: function (data, type) {
data: 'qty_planning', render: function (data, type) { // return data ? formatRupiah(parseInt(data)) : '-'
return data ? formatRupiah(parseInt(data)) : '-' // }
} // },
}, // { data: 'uom', name: 'uom' },
{ data: 'uom', name: 'uom' }, // {
{ // data: 'plan_date', render: function (data, type) {
data: 'plan_date', render: function (data, type) { // return data ? formatDate(data) : '-'
return data ? formatDate(data) : '-' // }
} // },
}, // ]
] // });
});
$('#select_ra_hr').select2({ $('#select_ra_hr').select2({
@ -341,10 +356,15 @@ $(document).ready(function () {
}); });
$('#ra_date_material').datepicker({
format: 'dd-mm-yyyy', // Set the desired format
autoclose: true // Close the datepicker when a date is selected
});
$("#form_report_activity_material").on("submit", function (e) { $("#form_report_activity_material").on("submit", function (e) {
e.preventDefault(); e.preventDefault();
var formData = new FormData(this); var formData = new FormData(this);
let formattedDate = moment(formData.get("report_date"), "DD-MM-YYYY").format("YYYY-MM-DD");
formData.set('report_date', formattedDate);
formData.append("activity_id", activityId); formData.append("activity_id", activityId);
formData.append("assign_material_id", assignMaterialId); formData.append("assign_material_id", assignMaterialId);
let idRa = $("#id_ra_material").val(); let idRa = $("#id_ra_material").val();
@ -362,6 +382,13 @@ $(document).ready(function () {
}); });
async function submitStatus(formData) { async function submitStatus(formData) {
let activityId = formData.get("activity_id");
let statusActivity = formData.get("status_activity");
let task = gantt.getTask(activityId);
if (statusActivity != "done") {
task.actual_start = null;
task.actual_end = null;
}
const result = await axiosInstance const result = await axiosInstance
.post(`${base_url}report-activity-material/update-status`, formData) .post(`${base_url}report-activity-material/update-status`, formData)
.then(res => res) .then(res => res)
@ -417,24 +444,55 @@ $(document).ready(function () {
} }
} }
async function submitRaMaterial(formData, id) { async function submitRaMaterial(formData, force) {
let qty_actual = $("#volume_pekerjaan_material").val(); try {
formData.set('qty', qty_actual); if (force) {
const result = await axiosInstance formData.append("force", force);
.post(`${base_url}report-activity-material/add`, formData) }
.then(res => res) const qty_actual = $("#volume_pekerjaan_material").val();
.catch((error) => error.response); formData.set('qty', qty_actual);
const result = await axiosInstance
// console.log("cek result", result); .post(`${base_url}report-activity-material/add`, formData);
const reportId = result.data.data.report_id;
try {
const image = formData.get("files");
const imageFormData = new FormData();
imageFormData.append("ref_id", reportId);
imageFormData.append("category", "report_activity");
imageFormData.append("files", image, image.name);
if (image.name && image.size) {
const resultImage = await axiosInstanceMultipart.post(`${base_url}image/upload`, imageFormData);
}
if (result && result.status == 200) { if (result.status === 200) {
gantt.alert("Add report activity material Success!"); gantt.alert("Add report activity material Success!");
resetFormAddRaMaterial(); resetFormAddRaMaterial();
tableRaMaterialActual.draw(); tableRaMaterialActual.draw();
} else { } else {
resetFormAddRaMaterial(); throw new Error("Add report activity material failed.");
}
} catch (error) {
throw new Error("Image upload failed.");
}
} catch (error) {
$("body").removeClass("loading"); $("body").removeClass("loading");
gantt.alert("Add report activity material failed, try again later!"); if (error.response.status == 400) {
gantt.confirm({
text: error.response.data.message,
ok: "Add",
cancel: "Cancel",
callback: function (result) {
if (result) {
submitRaMaterial(formData, true);
}
}
});
} else {
resetFormAddRaMaterial();
gantt.alert("Add report activity material failed.");
}
} }
} }
@ -503,7 +561,7 @@ $(document).ready(function () {
// kalo gambarnya banyak belum di handle... // kalo gambarnya banyak belum di handle...
}, },
error: function (data) { error: function (data) {
gantt.alert({ type: "error", text: "Failed to get report image" }); gantt.alert({ type: "error", text: "Image not found !" });
} }
}); });
}); });
@ -596,6 +654,7 @@ $(document).ready(function () {
} }
function deleteRaMaterial(id) { function deleteRaMaterial(id) {
searchReport(assignMaterialId, false);
$.ajax({ $.ajax({
url: `${base_url}report-activity-material/delete/${id}`, url: `${base_url}report-activity-material/delete/${id}`,
type: "DELETE", type: "DELETE",

135
edit-mode/function/restActivityLink.js

@ -1,4 +1,7 @@
let geom = []; let geom = [];
let latest;
let earliest;
let ganttTask;
$("body").addClass("loading"); $("body").addClass("loading");
gantt.ajax.get({ gantt.ajax.get({
url: `${base_url}activity/${ganttId}/${proyekId}/get`, url: `${base_url}activity/${ganttId}/${proyekId}/get`,
@ -8,6 +11,14 @@ gantt.ajax.get({
} }
}).then(function (xhr) { }).then(function (xhr) {
$("body").removeClass("loading"); $("body").removeClass("loading");
let batchEntity = localStorage.getItem('batchEntity');
if (!batchEntity || batchEntity == '') {
$("#save-activity").hide();
$("#save-separator").hide();
} else {
$("#save-activity").show();
$("#save-separator").show();
}
let data = {}; let data = {};
let response = xhr.responseText; let response = xhr.responseText;
let obj = JSON.parse(response); let obj = JSON.parse(response);
@ -30,9 +41,13 @@ gantt.ajax.get({
}) })
}); });
gantt.silent(function () { gantt.silent(function () {
// updateLinksLag(data);
ganttTask = data;
gantt.parse(data); gantt.parse(data);
getGanttOpen(); getGanttOpen();
gantt.parse(data); gantt.parse(data);
earliest = getEarliestTaskDate();
latest = getLatestTaskDate();
}); });
}).catch(function (error) { }).catch(function (error) {
$("body").removeClass("loading"); $("body").removeClass("loading");
@ -60,6 +75,14 @@ function refresData(id) {
} }
}).then(function (xhr) { }).then(function (xhr) {
$("body").removeClass("loading"); $("body").removeClass("loading");
let batchEntity = localStorage.getItem('batchEntity');
if (!batchEntity || batchEntity == '') {
$("#save-activity").hide();
$("#save-separator").hide();
} else {
$("#save-activity").show();
$("#save-separator").show();
}
gantt.clearAll(); gantt.clearAll();
let data = {}; let data = {};
let response = xhr.responseText; let response = xhr.responseText;
@ -74,9 +97,13 @@ function refresData(id) {
}) })
}); });
gantt.silent(function () { gantt.silent(function () {
// updateLinksLag(data);
ganttTask = data;
gantt.parse(data); gantt.parse(data);
getGanttOpen(); getGanttOpen();
gantt.parse(data); gantt.parse(data);
earliest = getEarliestTaskDate();
latest = getLatestTaskDate();
}); });
if (id) { if (id) {
if (gantt.isTaskExists(id)) { if (gantt.isTaskExists(id)) {
@ -154,6 +181,11 @@ var dp = gantt.createDataProcessor(function (entity, action, data, id) {
// data['start_date'] = startDate.format("YYYY-MM-DD")+" 00:00:00+07"; // data['start_date'] = startDate.format("YYYY-MM-DD")+" 00:00:00+07";
let endDate = moment(data.end_date, "YYYY-MM-DD"); let endDate = moment(data.end_date, "YYYY-MM-DD");
let configStart = moment(gantt.config.start_date);
let configEnd = moment(gantt.config.end_date);
if (startDate >= configEnd || startDate <= configStart || endDate >= configEnd || endDate <= configStart) {
// location.reload();
}
if (startDate > endDate) { if (startDate > endDate) {
gantt.alert({ gantt.alert({
title: "Peringatan", title: "Peringatan",
@ -176,56 +208,59 @@ var dp = gantt.createDataProcessor(function (entity, action, data, id) {
}); });
} }
data['geom'] = geom.find(obj => obj.activity_id == id)?.geom; data['geom'] = geom.find(obj => obj.activity_id == id)?.geom;
// let existingEntity = localStorage.getItem('batchEntity'); let existingEntity = localStorage.getItem('batchEntity');
// if (existingEntity) { if (existingEntity) {
// existingEntity = JSON.parse(existingEntity); existingEntity = JSON.parse(existingEntity);
// // Now batchEntity is an object containing your data, and you can access its properties like batchEntity.entity and batchEntity.data // Now batchEntity is an object containing your data, and you can access its properties like batchEntity.entity and batchEntity.data
// } }
// let batchEntity = { let batchEntity = {
// entity: entity, entity: entity,
// data: data data: data
// }; };
// let toBeSet = [] let toBeSet = []
// if (existingEntity) { if (existingEntity) {
// toBeSet = [...existingEntity, batchEntity] toBeSet = [...existingEntity, batchEntity]
// } else { } else {
// toBeSet = [batchEntity] toBeSet = [batchEntity]
// } }
// localStorage.setItem('batchEntity', JSON.stringify(toBeSet)); localStorage.setItem('batchEntity', JSON.stringify(toBeSet));
$("body").addClass("loading"); $("#save-activity").show();
return gantt.ajax.put({ $("#save-separator").show();
headers: { sendStorage();
"Content-Type": "application/json", // $("body").addClass("loading");
"Authorization": `Bearer ${token}` // return gantt.ajax.put({
}, // headers: {
url: base_url + entity + "/" + id, // "Content-Type": "application/json",
data: JSON.stringify(data) // "Authorization": `Bearer ${token}`
}).then(function (response) { // },
$("body").removeClass("loading"); // url: base_url + entity + "/" + id,
if (entity == "task") { // data: JSON.stringify(data)
let parent = data.parent; // }).then(function (response) {
let responseText = JSON.parse(response.responseText) // $("body").removeClass("loading");
let resData = responseText // if (entity == "task") {
let updateBobot = resData.update_bobot || false // let parent = data.parent;
if (updateBobot) { // let responseText = JSON.parse(response.responseText)
if (parent && parent > 0) { // let resData = responseText
updateActivity(parent); // let updateBobot = resData.update_bobot || false
} // if (updateBobot) {
} else if (parent && parent > 0) { // if (parent && parent > 0) {
updateActivity(parent); // updateActivity(parent);
} // }
if (!parent) { // } else if (parent && parent > 0) {
refresData(); // updateActivity(parent);
} // }
} // if (!parent) {
}).catch(function (error) { // refresData();
$("body").removeClass("loading"); // }
gantt.alert({ // }
title: "Peringatan", // }).catch(function (error) {
type: "alert-error", // $("body").removeClass("loading");
text: "Update activity gagal" // gantt.alert({
}); // title: "Peringatan",
}); // type: "alert-error",
// text: "Update activity gagal"
// });
// });
break; break;
case "delete": case "delete":

31
edit-mode/index.html

@ -87,18 +87,24 @@
<button title="Dashboard Project" class="btn btn-sm btn-icon-toolbar" id="dashboard-project"><i <button title="Dashboard Project" class="btn btn-sm btn-icon-toolbar" id="dashboard-project"><i
class="fa fa-chart-line icon-toolbar"></i></button> class="fa fa-chart-line icon-toolbar"></i></button>
<span class="icon-toolbar-separator">|</span> <span class="icon-toolbar-separator">|</span>
<!-- <button title="Save" class="btn btn-sm btn-icon-toolbar" id="save-activity"><i <button title="Save" class="btn btn-sm btn-icon-toolbar" id="save-activity"><i
class="fa fa-save icon-toolbar"></i></button> class="fa fa-save icon-toolbar"></i></button>
<span class="icon-toolbar-separator">|</span> --> <span class="icon-toolbar-separator"id="save-separator">|</span>
<button title="Synchronize to Report Activity" class="btn btn-sm btn-icon-toolbar" id="gantt-synchronize"><i <button title="Synchronize to Report Activity" class="btn btn-sm btn-icon-toolbar" id="gantt-synchronize"><i
class="fa fa-sync icon-toolbar"></i></button> class="fa fa-sync icon-toolbar"></i></button>
<span class="icon-toolbar-separator">|</span> <span class="icon-toolbar-separator">|</span>
<button title="Update Schedule" class="btn btn-sm btn-icon-toolbar" id="update-schedule"><i
class="fa fa-upload icon-toolbar"></i></button>
<span class="icon-toolbar-separator">|</span>
<button title="Set Baseline" class="btn btn-sm btn-icon-toolbar" id="gantt-baseline"><i <button title="Set Baseline" class="btn btn-sm btn-icon-toolbar" id="gantt-baseline"><i
class="fa fa-grip-lines icon-toolbar"></i></button> class="fa fa-grip-lines icon-toolbar"></i></button>
<span class="icon-toolbar-separator">|</span> <span class="icon-toolbar-separator">|</span>
<button title="Show / Hide Columns" class="btn btn-sm btn-icon-toolbar" id="gantt_toggle_columns_btn" <button title="Show / Hide Columns" class="btn btn-sm btn-icon-toolbar" id="gantt_toggle_columns_btn"
onclick="gantt.$showDropdown(this)"><i class="fa fa-columns icon-toolbar"></i></button> onclick="gantt.$showDropdown(this)"><i class="fa fa-columns icon-toolbar"></i></button>
<span class="icon-toolbar-separator">|</span> <span class="icon-toolbar-separator">|</span>
<button title="Gantt Compare" class="btn btn-sm btn-icon-toolbar" id="compare-data"><i
class="fa fa-columns icon-toolbar"></i></button>
<span class="icon-toolbar-separator">|</span>
<button title="Gantt Settings" class="btn btn-sm btn-icon-toolbar" id="gantt_setting_btn"><i <button title="Gantt Settings" class="btn btn-sm btn-icon-toolbar" id="gantt_setting_btn"><i
class="fa fa-cog icon-toolbar"></i></button> class="fa fa-cog icon-toolbar"></i></button>
<span class="icon-toolbar-separator">|</span> <span class="icon-toolbar-separator">|</span>
@ -132,11 +138,19 @@
<div class="modal-body"> <div class="modal-body">
<form id="form-assign-hr"> <form id="form-assign-hr">
<div class="form-row"> <div class="form-row">
<div class="col-md-10 form-group"> <div class="col-md-7 form-group">
<label>Human Resource</label> <label>Human Resource</label>
<select id="select-hr" name="user_id[]" multiple="multiple" class="form-control form-control-sm" style="width:100%;"></select> <select id="select-hr" name="user_id[]" multiple="multiple" class="form-control form-control-sm" style="width:100%;"></select>
</div> </div>
<div class="col-md-2 form-group">
<label>Start Date</label>
<input type="date" id="hr-start-date" class="form-control form-control-sm" />
</div>
<div class="col-md-2 form-group"> <div class="col-md-2 form-group">
<label>End Date</label>
<input type="date" id="hr-end-date" class="form-control form-control-sm" />
</div>
<div class="col-md-1 form-group">
<button style="margin-top: 31px;" id="btn-assign-hr" type="submit" <button style="margin-top: 31px;" id="btn-assign-hr" type="submit"
class="btn btn-sm btn-primary">Assign</button> class="btn btn-sm btn-primary">Assign</button>
</div> </div>
@ -156,6 +170,8 @@
<tr> <tr>
<th scope="col">User</th> <th scope="col">User</th>
<th scope="col">Role</th> <th scope="col">Role</th>
<th scope="col">Start Date</th>
<th scope="col">End Date</th>
<th scope="col">Actions</th> <th scope="col">Actions</th>
</tr> </tr>
</thead> </thead>
@ -383,7 +399,7 @@
<th scope="col">QTY</th> <th scope="col">QTY</th>
<th scope="col">UOM</th> <th scope="col">UOM</th>
<th scope="col">Price</th> <th scope="col">Price</th>
<th scope="col">Planning Date</th> <th scope="col">Will Be Used At</th>
<th scope="col">Actions</th> <th scope="col">Actions</th>
</tr> </tr>
</thead> </thead>
@ -602,11 +618,11 @@
<div class="form-row"> <div class="form-row">
<div class="col-md-6 form-group"> <div class="col-md-6 form-group">
<label>Due Date</label> <label>Due Date</label>
<input id="due_milestone" type="date" name="due_date" class="form-control form-control-sm" /> <input id="due_milestone" type="text" name="due_date" class="form-control form-control-sm" />
</div> </div>
<div class="col-md-6 form-group"> <div class="col-md-6 form-group">
<label>Deadline</label> <label>Deadline</label>
<input id="deadline_milestone" type="date" name="deadline" class="form-control form-control-sm" /> <input id="deadline_milestone" type="text" name="deadline" class="form-control form-control-sm" />
</div> </div>
</div> </div>
</div> </div>
@ -723,7 +739,7 @@
</div> </div>
<div class="col-md-2 form-group"> <div class="col-md-2 form-group">
<label>Report Date</label> <label>Report Date</label>
<input type="date" id="ra_date_material" name="report_date" class="form-control form-control-sm" <input type="text" id="ra_date_material" name="report_date" class="form-control form-control-sm"
required /> required />
</div> </div>
<div class="col-md-2 form-group"> <div class="col-md-2 form-group">
@ -769,6 +785,7 @@
<th scope="col">Human Resource</th> <th scope="col">Human Resource</th>
<th scope="col">Report Date</th> <th scope="col">Report Date</th>
<th scope="col">Volume Actual</th> <th scope="col">Volume Actual</th>
<th scope="col">Volume Plan</th>
<th scope="col">Keterangan</th> <th scope="col">Keterangan</th>
<th scope="col">Actions</th> <th scope="col">Actions</th>
</tr> </tr>

30
view-mode/function/function.js

@ -522,3 +522,33 @@ function replaceAll(str, find, replace) {
} }
return str return str
} }
// Function to get the earliest planned start date among all tasks
function getEarliestTaskDate() {
var earliestDate = null;
gantt.eachTask(function (task) {
var taskStartDate = task.planned_start || task.start_date;
if (!earliestDate || task.planned_start < earliestDate) {
earliestDate = taskStartDate;
if (task.start_date < earliestDate) {
earliestDate = task.start_date;
}
}
});
return earliestDate;
}
// Function to get the latest planned end date among all tasks
function getLatestTaskDate() {
var latestDate = null;
gantt.eachTask(function (task) {
var taskEndDate = task.planned_end || task.end_date;
if (!latestDate || task.planned_end > latestDate) {
latestDate = taskEndDate;
if (task.end_date > latestDate) {
latestDate = task.end_date;
}
}
});
return latestDate;
}

30
view-mode/function/ganttEvent.js

@ -98,3 +98,33 @@ gantt.attachEvent("onGanttRender", function(){
gantt.config.readonly = true; gantt.config.readonly = true;
} }
}); });
gantt.attachEvent("onGanttScroll", function (left, top){
var left_date = gantt.dateFromPos(left)
var right_date = gantt.dateFromPos(left + gantt.$task.offsetWidth)
let taskCount = gantt.getTaskCount();
if (taskCount > 0) {
gantt.config.start_date = gantt.config.start_date || gantt.getState().min_date;
gantt.config.end_date = gantt.config.end_date || gantt.getState().max_date;
var min_allowed_date = gantt.date.add(gantt.config.start_date, 1, "day");
var max_allowed_date = gantt.date.add(gantt.config.end_date, -1, "day");
var repaint = false;
if (earliest && +left_date <= +min_allowed_date && +left_date >= +earliest){
gantt.config.start_date = gantt.date.add(gantt.config.start_date, -1, "day");
repaint = true;
}
if (latest && +right_date >= +max_allowed_date && +right_date <= +latest){
gantt.config.end_date = gantt.date.add(gantt.config.end_date, 1, "day");
repaint = true;
}
if (repaint) {
setTimeout(function(){
gantt.render()
},20)
}
}
});

153
view-mode/function/overlaySCurve.js

@ -13,59 +13,56 @@ function callback(response) {
return_first = response; return_first = response;
} }
function getSCurveData(){ function messageListener(event) {
if (event.data && event.data.action === 'sendUrl') {
const parentUrl = event.data.url;
// Send a message to the parent window requesting the URL // Split the remaining path by "/"
window.parent.postMessage({ action: 'getUrl' }, '*'); parts = parentUrl.split("/");
if (parts[7] && parts[7] == "1") {
// Listen for messages from the parent window $.ajax({
window.addEventListener('message', function(event) { headers: {
if (event.data && event.data.action === 'sendUrl') { "Content-Type": "application/json",
const parentUrl = event.data.url; "Authorization": `Bearer ${token}`
},
// Remove the base URL and hash url: `${base_url}project/calculate-s-curve`,
const path = parentUrl.replace("https://adw.ospro.id/#/dashboard-project/", ""); type: "POST",
data: JSON.stringify(sCurvePayload),
success: function (data) {
callback(data)
window.removeEventListener('message', messageListener);
}
});
$.ajax({
headers: {
"Content-Type": "application/json",
"Authorization": `Bearer ${token}`
},
url: `${base_url}project/s-curve-command`,
type: "POST",
data: JSON.stringify(sCurvePayload),
});
} else {
$.ajax({
headers: {
"Content-Type": "application/json",
"Authorization": `Bearer ${token}`
},
url: `${base_url}project/get-s-curve`,
type: "POST",
data: JSON.stringify(sCurvePayload),
success: function (data) {
callback(data)
window.removeEventListener('message', messageListener);
}
});
}
}
}
// Split the remaining path by "/" function getSCurveData() {
parts = path.split("/"); window.parent.postMessage({ action: 'getUrl' }, '*');
if (parts[2] && parts[2] == "1") { window.addEventListener('message', messageListener);
$.ajax({
headers: {
"Content-Type": "application/json",
"Authorization": `Bearer ${token}`
},
url: `${base_url}project/calculate-s-curve`,
type: "POST",
data:JSON.stringify(sCurvePayload),
success: function (data) {
callback(data)
}
});
$.ajax({
headers: {
"Content-Type": "application/json",
"Authorization": `Bearer ${token}`
},
url: `${base_url}project/s-curve-command`,
type: "POST",
data:JSON.stringify(sCurvePayload),
});
} else {
$.ajax({
headers: {
"Content-Type": "application/json",
"Authorization": `Bearer ${token}`
},
url: `${base_url}project/get-s-curve`,
type: "POST",
data:JSON.stringify(sCurvePayload),
success: function (data) {
callback(data)
}
});
}
}
});
}; };
function toggleOverlay() { function toggleOverlay() {
@ -118,12 +115,31 @@ function getProgressLine(){
return {planned: cumulativePlannedDurations, real: cumulativeRealDurations, dates: dates}; return {planned: cumulativePlannedDurations, real: cumulativeRealDurations, dates: dates};
} }
function getScalePaddings(){ function getScalePaddings(values){
var scale = gantt.getScale(); var scale = gantt.getScale();
var dataRange = gantt.getSubtaskDates(); var dataRange = gantt.getSubtaskDates();
// let minDate = new Date();
// let maxDate = new Date();
let minValueDate = new Date(values.dates[0]);
let maxValueDate = new Date(values.dates[values.dates.length -1]);
// gantt.eachTask(function(task){
// let plannedEarlier = task.planned_start < task.start_date;
// let plannedLater = task.planned_end > task.end_date;
// if (plannedEarlier) {
// minDate = new Date(Math.min(minDate.getTime(), task.planned_start.getTime()));
// } else {
// minDate = new Date(Math.min(minDate.getTime(), task.start_date.getTime()));
// }
// if (plannedLater) {
// maxDate = new Date(Math.max(maxDate.getTime(), task.planned_end.getTime()));
// } else {
// maxDate = new Date(Math.max(maxDate.getTime(), task.end_date.getTime()));
// }
// })
var chartScale = getChartScaleRange();
var newWidth = scale.col_width;
var padding = { var padding = {
left:0, left:0,
right:0 right:0
@ -132,8 +148,8 @@ function getScalePaddings(){
if(dataRange.start_date){ if(dataRange.start_date){
var yScaleLabelsWidth = 48; var yScaleLabelsWidth = 48;
// fine tune values in order to align chart with the scale range // fine tune values in order to align chart with the scale range
padding.left = gantt.posFromDate(dataRange.start_date) - yScaleLabelsWidth; padding.left = gantt.posFromDate(minValueDate);
padding.right = scale.full_width - gantt.posFromDate(dataRange.end_date) - yScaleLabelsWidth; padding.right = scale.full_width - gantt.posFromDate(maxValueDate);
padding.top = gantt.config.row_height - 12; padding.top = gantt.config.row_height - 12;
padding.bottom = gantt.config.row_height - 12; padding.bottom = gantt.config.row_height - 12;
} }
@ -145,19 +161,22 @@ var lineOverlay = overlayControl.addOverlay(function(container) {
var values = getProgressLine(); var values = getProgressLine();
var scaleLabels = []; var scaleLabels = [];
if(parts[2] && parts[2] == '1'){ // if(parts[2] && parts[2] == '1'){
// values.dates.forEach(function(date){
// var dateScale = new Date(date);
// scaleLabels.push(dateToStr(dateScale));
// })
// } else {
// var chartScale = getChartScaleRange();
// chartScale.forEach(function(date){
// scaleLabels.push(dateToStr(date));
// });
// }
values.dates.forEach(function(date){ values.dates.forEach(function(date){
var dateScale = new Date(date); var dateScale = new Date(date);
scaleLabels.push(dateToStr(dateScale)); scaleLabels.push(dateToStr(dateScale));
}) })
} else {
var chartScale = getChartScaleRange();
chartScale.forEach(function(date){
scaleLabels.push(dateToStr(date));
});
}
var canvas = document.createElement("canvas"); var canvas = document.createElement("canvas");
container.appendChild(canvas); container.appendChild(canvas);
canvas.style.height = container.offsetHeight + "px"; canvas.style.height = container.offsetHeight + "px";
@ -193,13 +212,13 @@ var lineOverlay = overlayControl.addOverlay(function(container) {
responsive: true, responsive: true,
maintainAspectRatio: false, maintainAspectRatio: false,
layout: { layout: {
padding: getScalePaddings() padding: getScalePaddings(values)
}, },
onResize: function(chart, newSize) { onResize: function(chart, newSize) {
var dataRange = gantt.getSubtaskDates(); var dataRange = gantt.getSubtaskDates();
if(dataRange.start_date){ if(dataRange.start_date){
// align chart with the scale range // align chart with the scale range
chart.options.layout.padding = getScalePaddings(); chart.options.layout.padding = getScalePaddings(values);
} }
}, },
legend: { legend: {

108
view-mode/function/reportActivity.js

@ -79,60 +79,60 @@ $(document).ready(function () {
] ]
}); });
var tableRaMaterialActual = $("#table_activity_material_actual").DataTable({ // var tableRaMaterialActual = $("#table_activity_material_actual").DataTable({
"processing": true, // "processing": true,
"serverSide": true, // "serverSide": true,
"ajax": { // "ajax": {
"url": `${base_url}report-activity-material/datatables`, // "url": `${base_url}report-activity-material/datatables`,
"data": function (d) { // "data": function (d) {
d.idAmi = assignMaterialId; // d.idAmi = assignMaterialId;
d.idAct = activityId; // d.idAct = activityId;
d.type = 'actual'; // d.type = 'actual';
} // }
}, // },
"columns": [ // "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) : '-' // return data ? formatDate(data) : '-'
} // }
}, // },
{ // {
data: 'qty', render: function (data, type) { // data: 'qty', render: function (data, type) {
return data ? formatRupiah(data) : '-' // return data ? formatRupiah(data) : '-'
} // }
}, // },
{ data: 'description', name: 'description' }, // { data: 'description', name: 'description' },
], // ],
"order": [[1, 'asc']], // "order": [[1, 'asc']],
}); // });
var tableRaMaterialPlan = $("#table_activity_material_plan").DataTable({ // var tableRaMaterialPlan = $("#table_activity_material_plan").DataTable({
"processing": true, // "processing": true,
"serverSide": true, // "serverSide": true,
"ajax": { // "ajax": {
"url": `${base_url}report-activity-material/datatables`, // "url": `${base_url}report-activity-material/datatables`,
"data": function (d) { // "data": function (d) {
d.idAmi = assignMaterialId; // d.idAmi = assignMaterialId;
d.idAct = activityId; // d.idAct = activityId;
d.type = 'plan'; // d.type = 'plan';
} // }
}, // },
"columns": [ // "columns": [
{ data: 'material_name', name: 'material_name'}, // { data: 'material_name', name: 'material_name'},
{ // {
data: 'qty_planning', render: function (data, type) { // data: 'qty_planning', render: function (data, type) {
return data ? formatRupiah(parseInt(data)) : '-' // return data ? formatRupiah(parseInt(data)) : '-'
} // }
}, // },
{ data: 'uom', name: 'uom' }, // { data: 'uom', name: 'uom' },
{ // {
data: 'plan_date', render: function (data, type) { // data: 'plan_date', render: function (data, type) {
return data ? formatDate(data) : '-' // return data ? formatDate(data) : '-'
} // }
}, // },
] // ]
}); // });
$('#modal_report_activity').on('show.bs.modal', function (event) { $('#modal_report_activity').on('show.bs.modal', function (event) {
$("#report_activity_title").html(`Report Activity ${activityName}`) $("#report_activity_title").html(`Report Activity ${activityName}`)

15
view-mode/function/restActivityLink.js

@ -1,14 +1,13 @@
var parts = []; var parts = [];
let latest;
let earliest;
window.parent.postMessage({ action: 'getUrl' }, '*'); window.parent.postMessage({ action: 'getUrl' }, '*');
window.addEventListener('message', function(event) { window.addEventListener('message', function(event) {
if (event.data && event.data.action === 'sendUrl') { if (event.data && event.data.action === 'sendUrl') {
const parentUrl = event.data.url; const parentUrl = event.data.url;
// Remove the base URL and hash
const path = parentUrl.replace("https://adw.ospro.id/#/dashboard-project/", "");
// Split the remaining path by "/" // Split the remaining path by "/"
parts = path.split("/"); parts = parentUrl.split("/");
} }
}); });
gantt.ajax.get({ gantt.ajax.get({
@ -37,9 +36,11 @@ gantt.ajax.get({
} }
} }
if(!parts[2]){ if(!parts[7]){
gantt.silent(function () { gantt.silent(function () {
gantt.parse(data); gantt.parse(data);
earliest = getEarliestTaskDate();
latest = getLatestTaskDate();
}); });
} }
}); });
@ -59,9 +60,11 @@ function refresData(id){
data['data'] = obj.data.data; data['data'] = obj.data.data;
data['links'] = obj.data.links; data['links'] = obj.data.links;
// console.log("data parse wrong", data); // console.log("data parse wrong", data);
if(!parts[2]){ if(!parts[7]){
gantt.silent(function () { gantt.silent(function () {
gantt.parse(data); gantt.parse(data);
earliest = getEarliestTaskDate();
latest = getLatestTaskDate();
}); });
} }
if(id){ if(id){

Loading…
Cancel
Save