From e7dd76c5a5d7c4185088729b1c60057164d32eb0 Mon Sep 17 00:00:00 2001 From: ibnu Date: Tue, 5 Dec 2023 11:22:44 +0700 Subject: [PATCH] update fix diff today, and fix round progress hirarchy, and fix estimated finish --- .../Commands/CalculateProgressGantt.php | 2 +- app/Helpers/MasterFunctionsHelper.php | 40 ++++++++++--------- app/Http/Controllers/ProjectController.php | 32 ++++++++++----- 3 files changed, 45 insertions(+), 29 deletions(-) diff --git a/app/Console/Commands/CalculateProgressGantt.php b/app/Console/Commands/CalculateProgressGantt.php index 5ac1e5f..f3b40c9 100644 --- a/app/Console/Commands/CalculateProgressGantt.php +++ b/app/Console/Commands/CalculateProgressGantt.php @@ -22,7 +22,7 @@ class CalculateProgressGantt extends Command $data = MasterFunctionsHelper::calculateSCurveForProgressTree($hierarchy_id); $hierarchy->bobot_planning = 100; - $hierarchy->progress =((int) end($data[0]['data']['percentageReal']) / (int) end($data[0]['data']['percentagePlan'])) * 100; + $hierarchy->progress =round(((int) end($data[0]['data']['percentageReal']) / (int) end($data[0]['data']['percentagePlan'])) * 100, 2); $hierarchy->save(); } } diff --git a/app/Helpers/MasterFunctionsHelper.php b/app/Helpers/MasterFunctionsHelper.php index acf3f69..805c01d 100644 --- a/app/Helpers/MasterFunctionsHelper.php +++ b/app/Helpers/MasterFunctionsHelper.php @@ -468,9 +468,9 @@ class MasterFunctionsHelper } if ($dataHeader) { - $totalRencanaBudget = Activity::where('parent_id', $dataHeader->id)->where("proyek_id", $keyGantt['proyek_id'])->where("version_gantt_id", $keyGantt['id'])->sum("rencana_biaya"); + // $totalRencanaBudget = Activity::where('parent_id', $dataHeader->id)->where("proyek_id", $keyGantt['proyek_id'])->where("version_gantt_id", $keyGantt['id'])->sum("rencana_biaya"); } else { - $totalRencanaBudget = Activity::whereNull('parent_id')->where("proyek_id", $keyGantt['proyek_id'])->where("version_gantt_id", $keyGantt['id'])->sum("rencana_biaya"); + // $totalRencanaBudget = Activity::whereNull('parent_id')->where("proyek_id", $keyGantt['proyek_id'])->where("version_gantt_id", $keyGantt['id'])->sum("rencana_biaya"); } if (!Activity::where("version_gantt_id", $keyGantt['id'])->first()) @@ -506,16 +506,16 @@ class MasterFunctionsHelper } $period = new \DatePeriod($begin, $interval, $end); - $arr_ActualM = []; + // $arr_ActualM = []; $tempDate = []; - $tempPercentagePlan = []; - $tempPercentagePlanWhr = []; - $tempPercentageReal = []; - $tempTtlPercentPlan = 0; - $tempTtlPercentActual = 0; + // $tempPercentagePlan = []; + // $tempPercentagePlanWhr = []; + // $tempPercentageReal = []; + // $tempTtlPercentPlan = 0; + // $tempTtlPercentActual = 0; - $currentACWP = 0; - $currentBCWP = 0; + // $currentACWP = 0; + // $currentBCWP = 0; $dataActivityPlanDate = []; $progressPlanKomulatifWeek = []; $progressActualKomulatifWeek = []; @@ -551,11 +551,15 @@ class MasterFunctionsHelper $dataActivityPlan = []; $dataActivityActual = []; - $today = new DateTime(); + $today = date('Y-m-d'); + $statusCutOfDate = false; + // if (new \DateTime($loopDay) < $today) { + // $statusCutOfDate = true; + // } if (new \DateTime($loopDay) == new \DateTime($loopDay . ' Friday')){ $progressPlanKomulatifWeek[] += round($tmpProgressPlanWeek,2); - if (new \DateTime($loopDay) < $today) { + if (new \DateTime($loopDay . ' Friday') <= new \DateTime($today . ' Friday')) { // $tempPercentageReal[] = round($tempTtlPercentActual, 2); $progressActualKomulatifWeek[] += round($tmpProgressActualWeek,2); } @@ -599,7 +603,7 @@ class MasterFunctionsHelper // $progressActualWeek = ((((($keyActualM->qty_actual / $keyActualM->sum_qty_actual) * 100) / $keyActualM->qty_plan)*100)*$keyActualM->bobot_planning)/100; // jika total report > dari planning if($keyActualM->sum_qty_actual > $keyActualM->qty_plan){ - $progressActualWeek = (($keyActualM->qty_actual / $keyActualM->sum_qty_actual) * 100) *$keyActualM->bobot_planning/100; + $progressActualWeek = ($keyActualM->qty_actual / $keyActualM->sum_qty_actual) * $keyActualM->bobot_planning; }else{ // jika total report < dari planning // $progressActualWeek = ((($keyActualM->qty_actual / $keyActualM->sum_qty_actual) * 100) / $keyActualM->qty_plan)*$keyActualM->bobot_planning; @@ -1431,11 +1435,11 @@ class MasterFunctionsHelper $dataActivityPlan = []; $dataActivityActual = []; - $today = new DateTime(); + $today = date('Y-m-d'); if (new \DateTime($loopDay) == new \DateTime($loopDay . ' Friday')){ $progressPlanKomulatifWeek[] += round($tmpProgressPlanWeek,2); - if (new \DateTime($loopDay) < $today) { + if (new \DateTime($loopDay . ' Friday') <= new \DateTime($today . ' Friday')) { // $tempPercentageReal[] = round($tempTtlPercentActual, 2); $progressActualKomulatifWeek[] += round($tmpProgressActualWeek,2); } @@ -1681,11 +1685,11 @@ class MasterFunctionsHelper $dataActivityPlan = []; $dataActivityActual = []; - $today = new DateTime(); + $today = date('Y-m-d'); if (new \DateTime($loopDay) == new \DateTime($loopDay . ' Friday')){ - $progressPlanKomulatifWeek[] += round($tmpProgressPlanWeek,2); - if (new \DateTime($loopDay) < $today) { + $progressPlanKomulatifWeek[] += round($tmpProgressPlanWeek,2); + if (new \DateTime($loopDay . ' Friday') <= new \DateTime($today . ' Friday')) { // $tempPercentageReal[] = round($tempTtlPercentActual, 2); $progressActualKomulatifWeek[] += round($tmpProgressActualWeek,2); } diff --git a/app/Http/Controllers/ProjectController.php b/app/Http/Controllers/ProjectController.php index 737c648..66f4724 100644 --- a/app/Http/Controllers/ProjectController.php +++ b/app/Http/Controllers/ProjectController.php @@ -538,16 +538,26 @@ class ProjectController extends Controller $actualStartExist = Activity::where('proyek_id', $id)->whereNotNull('actual_start')->exists(); if($result['type_proyek_id'] === 9) { - $actualEndExist = Activity::where('proyek_id', $id)->exists(); - $query = Activity::where('proyek_id', $id); + // $actualEndExist = Activity::where('proyek_id', $id)->exists(); + // $query = Activity::where('proyek_id', $id); + $maxEndDate = Activity::where('proyek_id', $id)->select('end_date') + ->orderBy('end_date', 'desc') + ->first(); + }else{ - $actualEndExist = Activity::where('version_gantt_id', $ganttId)->exists(); + // $actualEndExist = Activity::where('version_gantt_id', $ganttId)->exists(); + $maxEndDate = Activity::where('version_gantt_id', $ganttId)->select('end_date') + ->orderBy('end_date', 'desc') + ->first(); $query = Activity::where('version_gantt_id', $ganttId); } } else { $result->header = Activity::whereNull('parent_id')->where("proyek_id", $id)->where("version_gantt_id", $ganttId)->first(); $actualStartExist = Activity::where('version_gantt_id', $ganttId)->whereNotNull('actual_start')->exists(); - $actualEndExist = Activity::where('version_gantt_id', $ganttId)->exists(); + // $actualEndExist = Activity::where('version_gantt_id', $ganttId)->exists(); + $maxEndDate = Activity::where('version_gantt_id', $ganttId)->select('end_date') + ->orderBy('end_date', 'desc') + ->first(); $query = Activity::where('version_gantt_id', $ganttId); } @@ -556,11 +566,13 @@ class ProjectController extends Controller } else { $startDate = $query->orderBy('start_date')->value('start_date'); } - if($actualEndExist) - { - $maxEndDate = $query->max('id'); - $endDate = $query->where('id',$maxEndDate)->first()->end_date; - } + // if($actualEndExist) + // { + // // $maxEndDate = $query->max('id'); + // // get last end_date + // // $endDate = $query->where('id',$maxEndDate)->first()->end_date; + + // } $plannedStart = Activity::where('version_gantt_id', $ganttId) ->orderBy('planned_start') @@ -569,7 +581,7 @@ class ProjectController extends Controller ->orderByDesc('planned_end') ->value('planned_end'); $result->header->start_date = $startDate; - $result->header->end_date = $endDate; + $result->header->end_date = $maxEndDate->end_date; $result->header->planned_start = $plannedStart; $result->header->planned_end = $plannedEnd; return response()->json(['status'=>'success','code'=> 200,'data'=>$result, 'gantt'=>$ganttId], 200);