From 1cfc01dad20be6cfdf8b0a989efdd5e9db4d6bff Mon Sep 17 00:00:00 2001 From: wahyu Date: Mon, 27 Nov 2023 19:14:24 +0700 Subject: [PATCH] limit actual progress till today --- app/Helpers/MasterFunctionsHelper.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/Helpers/MasterFunctionsHelper.php b/app/Helpers/MasterFunctionsHelper.php index 9baaa80..c45954e 100644 --- a/app/Helpers/MasterFunctionsHelper.php +++ b/app/Helpers/MasterFunctionsHelper.php @@ -739,6 +739,8 @@ class MasterFunctionsHelper 'plan' => $dataTempPlan, 'actual' => $dataTempReport, ); + $today = new DateTime(); + $date = new DateTime($dt->format("Y-m-d")); if (isset($dataPayload['period']) && $dataPayload['period'] == 'week') { $tempTtlPercentPlan += $sumPercentagePlan; $tempTtlPercentActual += $sumPercentageActual; @@ -749,14 +751,18 @@ class MasterFunctionsHelper $tempPercentage[] = array(round($tempTtlPercentPlan, 2), round($tempTtlPercentActual, 2)); $tempPercentagePlan[] = round($tempTtlPercentPlan, 2); $tempPercentagePlanWhr[] = ["weekly period", $tempPercentagePlan]; + if ($date < $today) { $tempPercentageReal[] = round($tempTtlPercentActual, 2); + } if ($tempTtlPercentPlan >= 100 && $tempTtlPercentActual >= 100) { break; } } else { $tempPercentage[] = array(round($sumPercentagePlan, 2), round($sumPercentageActual, 2)); $tempPercentagePlan[] = round($sumPercentagePlan, 2); + if ($date < $today) { $tempPercentageReal[] = round($sumPercentageActual, 2); + } } } @@ -783,8 +789,6 @@ class MasterFunctionsHelper } $lastReal = $tempPercentageReal[count($tempPercentageReal) - 1]; $totalBCWP = $lastReal * $dataProject->rencana_biaya / 100; - array_pop($tempPercentageReal); - array_pop($tempPercentageReal); $dataResponse = array( "date" => $tempDate, "percentage" => $tempPercentage,