From 293971554c88f4b2002004da369a774a173bd3a8 Mon Sep 17 00:00:00 2001 From: Wahyu Ramadhan Date: Tue, 6 Jun 2023 15:58:47 +0700 Subject: [PATCH] Reversing the s curve --- app/Helpers/MasterFunctionsHelper.php | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/app/Helpers/MasterFunctionsHelper.php b/app/Helpers/MasterFunctionsHelper.php index d7b3536..f8d1c9f 100644 --- a/app/Helpers/MasterFunctionsHelper.php +++ b/app/Helpers/MasterFunctionsHelper.php @@ -120,11 +120,22 @@ class MasterFunctionsHelper { $minDate = Activity::where('version_gantt_id', $keyGantt['id'])->whereNull('parent_id')->pluck('start_date')->first(); $begin = new \DateTime($minDate.' Monday'); - $maxDate = date('Y-m-d'); - $end = new \DateTime($maxDate. ' Friday'); - // $end->modify('next Friday'); - /* $interval = \DateInterval::createFromDateString('1 day'); */ // should be using this but its bugged - $interval = new \DateInterval('P7D'); + if(isset($dataPayload['end_date'])){ + $maxDate = $dataPayload['end_date']; + $end = new \DateTime($maxDate. ' Friday'); + $end->modify('next Friday'); + /* $interval = \DateInterval::createFromDateString('1 day'); */ // should be using this but its bugged + $interval = new \DateInterval('P7D'); + } else { + $maxDate = DB::table('assign_material_to_activity as ama') + ->where("ama.proyek_id", $keyGantt['proyek_id']) + ->join('m_activity as a', 'a.id', '=', 'ama.activity_id') + ->where('a.version_gantt_id', '=', $keyGantt['id']) + ->max("plan_date"); // plan date overlapped with assign_material_to_activity's, it should be m_activity's + $end = new \DateTime($maxDate. ' Friday'); + $end->modify('next Friday'); + $interval = new \DateInterval('P7D'); + } $period = new \DatePeriod($begin, $interval, $end); $arr_ActualM = [];