From cbb10e171c1fd91c6c85594ad362139398043357 Mon Sep 17 00:00:00 2001 From: wahyu Date: Mon, 28 Aug 2023 13:21:12 +0700 Subject: [PATCH] getoverdue by gantt and project --- app/Http/Controllers/ProjectController.php | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/app/Http/Controllers/ProjectController.php b/app/Http/Controllers/ProjectController.php index ffbe3fa..944b7ad 100644 --- a/app/Http/Controllers/ProjectController.php +++ b/app/Http/Controllers/ProjectController.php @@ -470,11 +470,20 @@ class ProjectController extends Controller if(!$result) return response()->json(['status'=>'failed','message'=> 'Project not found!','code'=> 404], 404); //TODO possible overdue bug - if(isset($payload['till_date'])) - $overdueActivities = Activity::where('proyek_id', $payload['id'])->whereNotNull('parent_id')->where('persentase_progress', '!=', 100)->whereDate('end_date','<=',$payload['till_date'])->orderBy('end_date', 'asc')->get(); - else - $overdueActivities = Activity::where('proyek_id', $payload['id'])->whereNotNull('parent_id')->where('persentase_progress', '!=', 100)->orderBy('end_date', 'asc')->get(); - + if(isset($payload['till_date'])) { + if (isset($payload['scurve'])) { + $overdueActivities = Activity::where('proyek_id', $payload['id'])->whereNotNull('parent_id')->where('persentase_progress', '!=', 100)->whereDate('end_date','<=',$payload['till_date'])->orderBy('end_date', 'asc')->get(); + } else { + $overdueActivities = Activity::where('version_gantt_id', $payload['gantt'])->whereNotNull('parent_id')->where('persentase_progress', '!=', 100)->whereDate('end_date','<=',$payload['till_date'])->orderBy('end_date', 'asc')->get(); + } + } + else { + if (isset($payload['scurve'])) { + $overdueActivities = Activity::where('proyek_id', $payload['id'])->whereNotNull('parent_id')->where('persentase_progress', '!=', 100)->orderBy('end_date', 'asc')->get(); + } else { + $overdueActivities = Activity::where('version_gantt_id', $payload['gantt'])->whereNotNull('parent_id')->where('persentase_progress', '!=', 100)->orderBy('end_date', 'asc')->get(); + } + } $result->overdueActivities = $overdueActivities; return response()->json(['status'=>'success','code'=> 200,'data'=>$result], 200);