Browse Source

Merge branch 'master' of https://git.oslog.id/ordo/adw-gantt

pull/1/head
farhantock 11 months ago
parent
commit
51c7bc3c13
  1. 9
      edit-mode/function/ganttConfig.js
  2. 8
      edit-mode/function/reportActivity.js
  3. 13
      view-mode/function/ganttConfig.js
  4. 9
      view-mode/function/ganttSettings.js
  5. 72
      view-mode/function/overlaySCurve.js
  6. 4
      view-mode/index.html

9
edit-mode/function/ganttConfig.js

@ -320,7 +320,10 @@ var allColumns = [
{ {
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);
console.log("bobot roundToTwo ", roundToTwo(bobot));
console.log("bobot toFixed ", bobot.toFixed(2));
if (bobot.toFixed(2) > 100) { if (bobot.toFixed(2) > 100) {
gantt.alert("Bobot tidak boleh lebih dari 100%!"); gantt.alert("Bobot tidak boleh lebih dari 100%!");
return; return;
} }
@ -480,10 +483,14 @@ var allColumns = [
name: "progress_actual", label: "Total Actual Progress (%)", align: "center", min_width: 150, template: function (text) { name: "progress_actual", label: "Total Actual Progress (%)", align: "center", min_width: 150, template: function (text) {
let progress = text.progress let progress = text.progress
progress = progress * 100 progress = progress * 100
console.log("progress roundToTwo ", roundToTwo(progress));
console.log("progress toFixed ", progress.toFixed(2));
if (progress.toFixed(2) > 100) { if (progress.toFixed(2) > 100) {
gantt.alert("Bobot tidak boleh lebih dari 100%!"); gantt.alert("Progress tidak boleh lebih dari 100%!");
return; return;
} }
let bobot = text.bobot_planning let bobot = text.bobot_planning
let actual = (progress * bobot) / 100 let actual = (progress * bobot) / 100
return roundToTwo(actual); return roundToTwo(actual);

8
edit-mode/function/reportActivity.js

@ -588,6 +588,10 @@ $(document).ready(function () {
assignMaterialId = $(this).data('id'); assignMaterialId = $(this).data('id');
materialName = $(this).data('material-name'); materialName = $(this).data('material-name');
var attributeString = this.outerHTML;
if (attributeString.includes('"=""')) {
materialName = materialName + '"';
}
// console.log(" okeee ",{ assignMaterialId, activityId, materialName }); // console.log(" okeee ",{ assignMaterialId, activityId, materialName });
$("#report_activity_material_title").html(`Report Activity Actual ${materialName}`) $("#report_activity_material_title").html(`Report Activity Actual ${materialName}`)
$("#modal_report_activity").hide(); $("#modal_report_activity").hide();
@ -619,6 +623,10 @@ $(document).ready(function () {
$("#table_report").on("click", ".btn-lihat-plan", function () { $("#table_report").on("click", ".btn-lihat-plan", function () {
assignMaterialId = $(this).data('id'); assignMaterialId = $(this).data('id');
materialName = $(this).data('material-name'); materialName = $(this).data('material-name');
var attributeString = this.outerHTML;
if (attributeString.includes('"=""')) {
materialName = materialName + '"';
}
// console.log(" okeee ",{ assignMaterialId, activityId, materialName }); // console.log(" okeee ",{ assignMaterialId, activityId, materialName });
$("#report_activity_material_title").html(`Report Activity Plan ${materialName}`) $("#report_activity_material_title").html(`Report Activity Plan ${materialName}`)
$("#modal_report_activity").hide(); $("#modal_report_activity").hide();

13
view-mode/function/ganttConfig.js

@ -379,7 +379,7 @@ gantt.templates.task_class = function (start, end, task) {
return classes.join(' '); return classes.join(' ');
} }
}; };
let dataOverdue = [];
gantt.templates.rightside_text = function (start, end, task) { gantt.templates.rightside_text = function (start, end, task) {
if (task.planned_end) { if (task.planned_end) {
if (end.getTime() > task.planned_end.getTime()) { if (end.getTime() > task.planned_end.getTime()) {
@ -398,6 +398,15 @@ gantt.templates.rightside_text = function (start, end, task) {
end_date: end, end_date: end,
task: task task: task
}, 'day'); }, 'day');
let found = dataOverdue.find((element) => element.id == task.id);
if (!found) {
dataOverdue.push({
id: task.id,
text: task.text,
overdue: overdue
})
}
window.parent.postMessage({ type: 'dataOverdueUpdate', dataOverdue: dataOverdue }, '*');
var text = "<b style='color: red;'>Overdue: " + overdue + " days</b>"; var text = "<b style='color: red;'>Overdue: " + overdue + " days</b>";
return text; return text;
} }
@ -493,7 +502,7 @@ var zoomConfig = {
] ]
}; };
gantt.ext.zoom.init(zoomConfig); gantt.ext.zoom.init(zoomConfig);
gantt.ext.zoom.setLevel("week"); gantt.ext.zoom.setLevel("month");
function zoomIn(){ function zoomIn(){
gantt.ext.zoom.zoomIn(); gantt.ext.zoom.zoomIn();

9
view-mode/function/ganttSettings.js

@ -77,15 +77,6 @@ $(document).ready(function() {
} }
} }
} }
else {
// default
// console.log('default');
// $('#select_dayoff option[value="0"]').prop("selected", "selected"); // Sunday
// $('#select_dayoff option[value="6"]').prop("selected", "selected"); // Saturday
// $("#select_dayoff").choices.setValue([0, 6]);
selectDayOffChoices.setChoiceByValue('0');
selectDayOffChoices.setChoiceByValue('6');
}
} }
}else{ }else{
// closeDialog('failed upload') // closeDialog('failed upload')

72
view-mode/function/overlaySCurve.js

@ -95,7 +95,7 @@ function getChartScaleRange(){
return cells; return cells;
} }
function getProgressLine(){ function getProgressLine() {
// As long as the progress data length is same with chart scale range (period) then it's fine. // As long as the progress data length is same with chart scale range (period) then it's fine.
getSCurveData(); getSCurveData();
// console.log("apa ", return_first); // console.log("apa ", return_first);
@ -105,21 +105,79 @@ function getProgressLine(){
var maxPlan = cumulativePlannedDurations[cumulativePlannedDurations.length - 1] var maxPlan = cumulativePlannedDurations[cumulativePlannedDurations.length - 1]
var maxReal = cumulativeRealDurations[cumulativeRealDurations.length - 1] var maxReal = cumulativeRealDurations[cumulativeRealDurations.length - 1]
var dates = return_first.data[0].data.date; var dates = return_first.data[0].data.date;
//jika summary s curve // Determine the appropriate data points based on the Gantt chart zoom level
var chartScaleRange = getChartScaleRange();
var zoomLevel = gantt.ext.zoom.getCurrentLevel();
// Adjust data points based on the zoom level
var plannedDurations, realDurations;
if (zoomLevel === 2) {
// Adjust data to monthly points
plannedDurations = adjustDataToZoom(dates, cumulativePlannedDurations, chartScaleRange, 2).data;
realDurations = adjustDataToZoom(dates, cumulativeRealDurations, chartScaleRange, 2).data;
dates = adjustDataToZoom(dates, cumulativeRealDurations, chartScaleRange, 2).dates;
} else if (zoomLevel === 1) {
// Adjust data to weekly points
plannedDurations = adjustDataToZoom(dates, cumulativePlannedDurations, chartScaleRange, 1).data;
realDurations = adjustDataToZoom(dates, cumulativeRealDurations, chartScaleRange, 1).data;
dates = adjustDataToZoom(dates, cumulativeRealDurations, chartScaleRange, 1).dates;
} else {
// Default: Use daily data points
plannedDurations = cumulativePlannedDurations;
realDurations = cumulativeRealDurations;
}
if (maxReal > 100 || maxPlan > 100) { if (maxReal > 100 || maxPlan > 100) {
var plannedDurations = cumulativePlannedDurations.map((item) => { plannedDurations = plannedDurations.map((item) => {
return item/maxPlan*100; return item/maxPlan*100;
}) })
var realDurations = cumulativeRealDurations.map((item) => { realDurations = realDurations.map((item) => {
return item/maxPlan*100; return item/maxReal*100;
}) })
return {planned: plannedDurations, real: realDurations, dates: dates};
} }
return {planned: cumulativePlannedDurations, real: cumulativeRealDurations, dates: dates}; return { planned: plannedDurations, real: realDurations, dates: dates };
}
function adjustDataToZoom(dates, data, chartScaleRange, zoomLevel) {
// Implement logic to adjust data points based on the Gantt chart zoom level
// For example, if zoomLevel is 'month', aggregate daily data to monthly data
// Placeholder logic: This example assumes that the chartScaleRange is in days
var newData = [];
var newDates = [];
var aggregateValue = 0;
for (var i = 0; i < data.length; i++) {
aggregateValue = data[i];
if (zoomLevel === 2 && i % 30 === 29) {
// Aggregate data for each month (assuming 30 days in a month)
newData.push(aggregateValue);
newDates.push(dates[i]);
aggregateValue = 0;
} else if (zoomLevel === 1 && (i + 1) % 7 === 0) {
// Aggregate data for each week
newData.push(aggregateValue);
newDates.push(dates[i]);
aggregateValue = 0;
}
}
// If there are remaining data points after the loop, add them to the result
if (aggregateValue > 0) {
newData.push(aggregateValue);
newDates.push(dates[data.length - 1]);
}
return {
data: newData,
dates: newDates
};
} }
function getScalePaddings(values){ function getScalePaddings(values){
let zoom = gantt.ext.zoom.getCurrentLevel();
var scale = gantt.getScale(); var scale = gantt.getScale();
var dataRange = gantt.getSubtaskDates(); var dataRange = gantt.getSubtaskDates();
// let minDate = new Date(); // let minDate = new Date();

4
view-mode/index.html

@ -12,8 +12,8 @@
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/bbbootstrap/libraries@main/choices.min.css"> <link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/bbbootstrap/libraries@main/choices.min.css">
<script src="../codebase/dhtmlxganttpro.js?v=7.1.8"></script> <script src="../codebase/dhtmlxgantt801.js?v=8.0.1"></script>
<link rel="stylesheet" href="../codebase/dhtmlxgantt.css?v=7.1.8"> <link rel="stylesheet" href="../codebase/dhtmlxgantt801.css?v=8.0.1">
<link rel="stylesheet" href="https://cdn.datatables.net/1.11.3/css/jquery.dataTables.min.css"> <link rel="stylesheet" href="https://cdn.datatables.net/1.11.3/css/jquery.dataTables.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css" <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css"
integrity="sha512-1ycn6IcaQQ40/MKBW2W4Rhis/DbILU74C1vSrLJxCq57o941Ym01SwNsOMqvEBFlcgUa6xLiPY/NS5R+E6ztJQ==" integrity="sha512-1ycn6IcaQQ40/MKBW2W4Rhis/DbILU74C1vSrLJxCq57o941Ym01SwNsOMqvEBFlcgUa6xLiPY/NS5R+E6ztJQ=="

Loading…
Cancel
Save