From aa80e56a0ec024f66fedd9ee74a72d1cae114919 Mon Sep 17 00:00:00 2001 From: wahyu Date: Fri, 27 Oct 2023 09:51:31 +0700 Subject: [PATCH] format hr date, styling overdue --- edit-mode/function/humanResource.js | 10 ++++++++-- view-mode/function/ganttConfig.js | 18 ++++++++++++++++-- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/edit-mode/function/humanResource.js b/edit-mode/function/humanResource.js index d297fb7..75174f6 100644 --- a/edit-mode/function/humanResource.js +++ b/edit-mode/function/humanResource.js @@ -31,8 +31,14 @@ $(document).ready(function () { "columns": [ { data: 'user_name', name: 'user_name' }, { data: 'role_name', name: 'role_name' }, - { data: 'start_date', name: 'start_date' }, - { data: 'end_date', name: 'end_date' }, + { data: 'start_date', name: 'start_date', render: function (data, type) { + return data ? formatDate(data) : '-' + } + }, + { data: 'end_date', name: 'end_date', render: function (data, type) { + return data ? formatDate(data) : '-' + } + }, { data: 'action', name: 'action', diff --git a/view-mode/function/ganttConfig.js b/view-mode/function/ganttConfig.js index a3d1da6..1b62b0f 100644 --- a/view-mode/function/ganttConfig.js +++ b/view-mode/function/ganttConfig.js @@ -383,8 +383,22 @@ gantt.templates.task_class = function (start, end, task) { gantt.templates.rightside_text = function (start, end, task) { if (task.planned_end) { if (end.getTime() > task.planned_end.getTime()) { - var overdue = Math.ceil(Math.abs((end.getTime() - task.planned_end.getTime()) / (24 * 60 * 60 * 1000))); - var text = "Overdue: " + overdue + " days"; + // var overdue = Math.ceil(Math.abs((end.getTime() - task.planned_end.getTime()) / (24 * 60 * 60 * 1000))); + // var text = "Overdue: " + overdue + " days"; + // return text; + var plannedEndDate = gantt.calculateEndDate({ + start_date: task.start_date, + duration: gantt.calculateDuration({ + start_date: task.start_date, + end_date: task.planned_end + }) + }); + var overdue = gantt.calculateDuration({ + start_date: plannedEndDate, + end_date: end, + task: task + }, 'day'); + var text = "Overdue: " + overdue + " days"; return text; } }