From ce46b3b61c88f54b707ec3b30e5635f95e15dd5d Mon Sep 17 00:00:00 2001 From: Wahyu Ramadhan Date: Thu, 6 Jul 2023 11:40:16 +0700 Subject: [PATCH 1/2] Fix ftth & fix scurve duration span --- app/Console/Commands/CalculateSCurve.php | 2 -- app/Helpers/MasterFunctionsHelper.php | 6 +++--- app/Models/HierarchyFtth.php | 11 +++++++++++ 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/app/Console/Commands/CalculateSCurve.php b/app/Console/Commands/CalculateSCurve.php index 72a2e37..2d005d7 100644 --- a/app/Console/Commands/CalculateSCurve.php +++ b/app/Console/Commands/CalculateSCurve.php @@ -25,7 +25,5 @@ class CalculateSCurve extends Command $project->scurve = json_encode($data); $project->calculation_status = true; $project->save(); - - return $data; } } diff --git a/app/Helpers/MasterFunctionsHelper.php b/app/Helpers/MasterFunctionsHelper.php index b93588d..9108ceb 100644 --- a/app/Helpers/MasterFunctionsHelper.php +++ b/app/Helpers/MasterFunctionsHelper.php @@ -473,11 +473,11 @@ class MasterFunctionsHelper { $minDate = $dataProject->mulai_proyek; - $begin = new \DateTime($minDate.' Monday'); + $begin = new \DateTime($minDate); $begin->modify('last Monday'); if(isset($dataPayload['end_date'])){ $maxDate = $dataPayload['end_date']; - $end = new \DateTime($maxDate. ' Friday'); + $end = new \DateTime($maxDate); $end->modify('next Friday'); $end->modify('next Friday'); /* $interval = \DateInterval::createFromDateString('1 day'); */ // should be using this but its bugged @@ -488,7 +488,7 @@ class MasterFunctionsHelper { // ->join('m_activity as a', 'a.id', '=', 'ama.activity_id') // ->max("plan_date"); // plan date overlapped with assign_material_to_activity's, it should be m_activity's $maxDate = $dataProject->akhir_proyek; - $end = new \DateTime($maxDate. ' Friday'); + $end = new \DateTime($maxDate); $end->modify('next Friday'); $end->modify('next Friday'); $interval = new \DateInterval('P7D'); diff --git a/app/Models/HierarchyFtth.php b/app/Models/HierarchyFtth.php index 34fd7d3..fae503c 100644 --- a/app/Models/HierarchyFtth.php +++ b/app/Models/HierarchyFtth.php @@ -14,4 +14,15 @@ class HierarchyFtth extends Model protected $fillable = [ 'name', 'parent_id', 'project_id', 'created_at', 'updated_at', 'progress', 'bobot_planning' ]; + + public static function boot() { + parent::boot(); + + static::deleted(function($data) { + $ftths = HierarchyFtth::where('parent_id', $data->id)->get(); + foreach ($ftths as $ftth) { + $ftth->delete(); + } + }); + } } From 4b667994bbfb7fb2e0507165f13dd3ac6018467c Mon Sep 17 00:00:00 2001 From: Wahyu Ramadhan Date: Fri, 7 Jul 2023 09:24:44 +0700 Subject: [PATCH 2/2] Fix date instance --- app/Http/Controllers/ActivityController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Http/Controllers/ActivityController.php b/app/Http/Controllers/ActivityController.php index c31e50b..f5cf99d 100644 --- a/app/Http/Controllers/ActivityController.php +++ b/app/Http/Controllers/ActivityController.php @@ -399,7 +399,7 @@ class ActivityController extends Controller } $projectStart = Project::select('mulai_proyek')->where('id', $projectId)->first(); foreach ($data['activities'] as $i => $activity_row) { - $startDate = \DateTime::createFromFormat('Y-m-d H:i:s.uP', $projectStart->mulai_proyek); + $startDate = new \DateTime($projectStart->mulai_proyek); $endDate = clone $startDate; $endDate->modify('-1 day'); $daysRemaining = $activity_row['duration'];