|
|
|
@ -14,6 +14,46 @@ function getUrlParameter(sParam) {
|
|
|
|
|
return false; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
function searchReport(id, updateActual = true) { |
|
|
|
|
var payload = { |
|
|
|
|
"columns": [ |
|
|
|
|
{ |
|
|
|
|
"name": "assign_material_id", |
|
|
|
|
"logic_operator": "=", |
|
|
|
|
"value": id, |
|
|
|
|
"operator": "AND" |
|
|
|
|
} |
|
|
|
|
], |
|
|
|
|
// "joins": [{ "name": "m_proyek", "column_join": "proyek_id", "column_results": ["kode_sortname", "nama"] }],
|
|
|
|
|
} |
|
|
|
|
$.ajax({ |
|
|
|
|
data: JSON.stringify(payload), |
|
|
|
|
url: `${base_url}report-activity-material/search`, |
|
|
|
|
type: "POST", |
|
|
|
|
success: function (data) { |
|
|
|
|
if (updateActual) { |
|
|
|
|
data.data.forEach(element => { |
|
|
|
|
let activityId = element.activity_id; |
|
|
|
|
let task = gantt.getTask(activityId); |
|
|
|
|
task.actual_start = null; |
|
|
|
|
task.actual_end = null; |
|
|
|
|
}); |
|
|
|
|
} else { |
|
|
|
|
if (data.data.length == 1) { |
|
|
|
|
let activityId = data.data[0].activity_id; |
|
|
|
|
let task = gantt.getTask(activityId); |
|
|
|
|
task.actual_start = null; |
|
|
|
|
task.actual_end = null; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
actionHappen = true; |
|
|
|
|
}, |
|
|
|
|
error: function (data) { |
|
|
|
|
// gantt.alert("Failed to get the data.");
|
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const formatNumber = (angka) => { |
|
|
|
|
var number_string = angka.replace(/[^,\d]/g, '').toString(), |
|
|
|
|
split = number_string.split(','), |
|
|
|
@ -212,6 +252,7 @@ function updateActivity(id) {
|
|
|
|
|
gantt.getTask(id).assign_hr = data.assign_hr; |
|
|
|
|
gantt.getTask(id).assign_material = data.assign_material; |
|
|
|
|
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).rencana_biaya = data.rencana_biaya; |
|
|
|
|
gantt.getTask(id).biaya_actual = data.biaya_actual; |
|
|
|
@ -339,7 +380,7 @@ function initializationColumn() {
|
|
|
|
|
if (data.status == "not yet have") { |
|
|
|
|
addShowHideColumn(); |
|
|
|
|
} else if (data.status == "not have access") { |
|
|
|
|
|
|
|
|
|
gantt.config.columns = createColumnsConfig(columnShows); |
|
|
|
|
} else { |
|
|
|
|
setUpForShowHideColumn(data); |
|
|
|
|
} |
|
|
|
@ -366,6 +407,36 @@ function setGanttOpen() {
|
|
|
|
|
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() { |
|
|
|
|
let ganttOpen = localStorage.getItem('ganttOpen'); |
|
|
|
|
if (ganttOpen) { |
|
|
|
@ -513,7 +584,7 @@ function submitShowHideColumn(allColumn) {
|
|
|
|
|
version_gantt_id: ganttId, |
|
|
|
|
columns: allColumn |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
gantt.config.columns = createColumnsConfig(allColumn); |
|
|
|
|
$.ajax({ |
|
|
|
|
data: JSON.stringify(payload), |
|
|
|
|
url: `${base_url}gantt-show-hide/add`, |
|
|
|
@ -537,7 +608,12 @@ function setUpForShowHideColumn(data) {
|
|
|
|
|
columns.map((val, index) => { |
|
|
|
|
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.render(); |
|
|
|
@ -555,10 +631,10 @@ function updateShowHideColumn(data) {
|
|
|
|
|
processData: false, |
|
|
|
|
contentType: false, |
|
|
|
|
success: function (data) { |
|
|
|
|
console.log(data); |
|
|
|
|
// console.log(data);
|
|
|
|
|
}, |
|
|
|
|
error: function (data) { |
|
|
|
|
console.log(data); |
|
|
|
|
// console.log(data);
|
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
@ -569,6 +645,8 @@ function colAjaxReq(type) {
|
|
|
|
|
type: "GET", |
|
|
|
|
success: function (data) { |
|
|
|
|
let ganttColumnsByType = data.data; |
|
|
|
|
// console.log("ini gantt field ", ganttColumnsByType);
|
|
|
|
|
// console.log("ini column ", gantt.config.columns);
|
|
|
|
|
let isFound = false; |
|
|
|
|
x = gantt.config.columns.filter((val) => { |
|
|
|
|
isFound = ganttColumnsByType.find(obj => { |
|
|
|
@ -576,6 +654,10 @@ function colAjaxReq(type) {
|
|
|
|
|
}); |
|
|
|
|
if (isFound) |
|
|
|
|
return val; |
|
|
|
|
if (isFound == false){ |
|
|
|
|
// console.log("ini gantt field !isFound ", val);
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
}); |
|
|
|
|
gantt.config.columns = x.filter(item => item); |
|
|
|
|
allColumns = gantt.config.columns; |
|
|
|
@ -633,7 +715,107 @@ function expandTask() {
|
|
|
|
|
gantt.render(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function resetActivity() { |
|
|
|
|
// 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; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
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', ''); |
|
|
|
|
gantt.alert("Actiivity Saved"); |
|
|
|
|
$("#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; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
} |