From 8f084901089d2704d205e0286272565d234f30bf Mon Sep 17 00:00:00 2001 From: ibnu Date: Sun, 3 Dec 2023 07:02:51 +0700 Subject: [PATCH] update logic duration 0 --- app/Helpers/MasterFunctionsHelper.php | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/app/Helpers/MasterFunctionsHelper.php b/app/Helpers/MasterFunctionsHelper.php index c43d887..a507ec2 100644 --- a/app/Helpers/MasterFunctionsHelper.php +++ b/app/Helpers/MasterFunctionsHelper.php @@ -534,7 +534,7 @@ class MasterFunctionsHelper ->where('version_gantt_id', $keyGantt['id']) ->whereDate('planned_start', '<=', $loopDay) ->whereDate('planned_end', '>=', $loopDay) - ->select('name', 'bobot_planning', 'biaya_actual', 'duration', 'persentase_progress', 'id') + ->select('name', 'bobot_planning', 'biaya_actual', 'duration', 'persentase_progress', 'id', 'planned_start', 'planned_end') ->get(); $dataActualM = DB::table('report_activity_material as ram') @@ -558,20 +558,29 @@ class MasterFunctionsHelper // $tempPercentageReal[] = round($tempTtlPercentActual, 2); $progressActualKomulatifWeek[] += round($tmpProgressActualWeek,2); } - $dateWeek[] = [$loopDay]; - // $tmpProgressPlanWeek = 0; - // $tmpProgressActualWeek = 0; + $dateWeek[] = [$loopDay]; } // $progressPlanKomulatifWeek[] += $tmpProgressPlanWeek; foreach ($dataPlanM as $keyPlanM) { # hitung untuk persentase progress planning + if($keyPlanM->duration == 0){ + $duration = 2; + } + // $startPlan = new DateTime($keyPlanM->planned_start); + // $endPlan = new DateTime($keyPlanM->planned_end); + // $interval = $startPlan->diff($endPlan); + + // // Mengambil hasil selisih hari + // $duration = $interval->days; + + $progressPlanWeek = $keyPlanM->bobot_planning / $duration; $dataActivityPlan[] = array( - 'progressPlanDay' => $keyPlanM->bobot_planning / $keyPlanM->duration, + 'progressPlanDay' => $progressPlanWeek, 'name' => $keyPlanM->name, 'bobot_p' => $keyPlanM->bobot_planning, 'duration' => $keyPlanM->duration ); - $tmpProgressPlanWeek += $keyPlanM->bobot_planning / $keyPlanM->duration; + $tmpProgressPlanWeek += $progressPlanWeek; } // hitung progress actual @@ -618,7 +627,7 @@ class MasterFunctionsHelper "proyek_name" => $dataProject->nama, "data" => ["date" => $dateWeek, "percentagePlan" => $progressPlanKomulatifWeek, - "percentageActual" => $progressActualKomulatifWeek, + "percentageReal" => $progressActualKomulatifWeek, "data_details" => $dataActivityPlanDate ],