diff --git a/app/Http/Controllers/ProjectController.php b/app/Http/Controllers/ProjectController.php index 023d3fd..e9b1125 100644 --- a/app/Http/Controllers/ProjectController.php +++ b/app/Http/Controllers/ProjectController.php @@ -355,6 +355,9 @@ class ProjectController extends Controller foreach ($allGantt as $keyGantt) { $dataProject = Project::find($keyGantt['proyek_id']); $dataHeader = Activity::where('type_activity', 'header')->where("proyek_id", $keyGantt['proyek_id'])->where("version_gantt_id", $keyGantt['last_gantt_id'])->first(); + if(isset($dataPayload['end_date']) && $dataPayload['end_date'] > $dataProject->akhir_proyek){ + $dataPayload['end_date'] = $dataProject->akhir_proyek; + } if($dataHeader){ $totalRencanaBudget = Activity::where('parent_id', $dataHeader->id)->where("proyek_id", $keyGantt['proyek_id'])->where("version_gantt_id", $keyGantt['last_gantt_id'])->sum("rencana_biaya"); @@ -501,6 +504,14 @@ class ProjectController extends Controller if(isset($dataPayload['period']) && $dataPayload['period'] == 'week'){ $tempTtlPercentPlan+= $sumPercentagePlan; $tempTtlPercentActual+= $sumPercentageActual; + + if($tempTtlPercentPlan >= 100 || $tempTtlPercentActual >= 100){ + if($tempTtlPercentActual >= 100) + $tempTtlPercentActual = 100; + if($tempTtlPercentPlan >= 100) + $tempTtlPercentPlan = 100; + } + $currentACWP += $totalACWP; $currentBCWP += $totalBCWP; @@ -508,6 +519,9 @@ class ProjectController extends Controller $tempPercentagePlan[] = round($tempTtlPercentPlan, 2); $tempPercentagePlanWhr[] = ["weekly period", $tempPercentagePlan]; $tempPercentageReal[] = round($tempTtlPercentActual, 2); + if($tempTtlPercentPlan >= 100 && $tempTtlPercentActual >= 100){ + break; + } }else{ $tempPercentage[] = array(round($sumPercentagePlan,2), round($sumPercentageActual,2)); $tempPercentagePlan[] = round($sumPercentagePlan, 2); @@ -517,7 +531,6 @@ class ProjectController extends Controller } /* print_r($tempDate); exit(); */ - try { if(round($totalACWP,0) > $totalRencanaBudget){ $estimatedCost = round($totalACWP,0)+0;