From e75d5e8925649d1ab6e98afdbd6324a7a3fb0be2 Mon Sep 17 00:00:00 2001 From: Wahyu Ramadhan Date: Mon, 15 May 2023 10:58:21 +0700 Subject: [PATCH 1/3] Extending DatePeriod --- app/Helpers/MasterFunctionsHelper.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/Helpers/MasterFunctionsHelper.php b/app/Helpers/MasterFunctionsHelper.php index a5092cf..17135fa 100644 --- a/app/Helpers/MasterFunctionsHelper.php +++ b/app/Helpers/MasterFunctionsHelper.php @@ -6,6 +6,7 @@ use App\Models\Activity; use App\Models\Project; use App\Models\VersionGantt; use Illuminate\Support\Facades\DB; +use Illuminate\Support\Facades\Log; class MasterFunctionsHelper { @@ -102,7 +103,8 @@ class MasterFunctionsHelper { $begin = new \DateTime($minDate.' Monday'); if(isset($dataPayload['end_date'])){ $maxDate = $dataPayload['end_date']; - $end = new \DateTime($maxDate); + $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 { @@ -112,6 +114,7 @@ class MasterFunctionsHelper { ->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); From fbf20963a02073419cc3d5fee3918f813aef1f92 Mon Sep 17 00:00:00 2001 From: Wahyu Ramadhan Date: Mon, 15 May 2023 14:16:35 +0700 Subject: [PATCH 2/3] Handling empty gantt --- app/Helpers/MasterFunctionsHelper.php | 6 ++++++ app/Http/Controllers/DashboardBoDController.php | 8 ++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/app/Helpers/MasterFunctionsHelper.php b/app/Helpers/MasterFunctionsHelper.php index 17135fa..ebd59b3 100644 --- a/app/Helpers/MasterFunctionsHelper.php +++ b/app/Helpers/MasterFunctionsHelper.php @@ -35,10 +35,16 @@ class MasterFunctionsHelper { public function getLatestGantt($id){ $maxGanttId = VersionGantt::where("proyek_id", $id)->max("id"); + if(!$maxGanttId){ + $data = array( + "proyek_id" => $id + ); + } else { $data = array( "last_gantt_id" => $maxGanttId, "proyek_id" => $id ); + } return $data; } diff --git a/app/Http/Controllers/DashboardBoDController.php b/app/Http/Controllers/DashboardBoDController.php index cf32a27..273d568 100644 --- a/app/Http/Controllers/DashboardBoDController.php +++ b/app/Http/Controllers/DashboardBoDController.php @@ -319,8 +319,12 @@ class DashboardBoDController extends Controller $project->pm = User::find($project->pm_id); /* $project->header = Activity::where('proyek_id', $project->id)->where('version_gantt_id', $lastGantt['last_gantt_id'])->whereNull('parent_id')->first(); */ - $project->scurve = MasterFunctionsHelper::getSCurve($project->id); - $project->manPowers = UserToVersionGantt::where('version_gantt_id', $lastGantt['last_gantt_id'])->count(); + if(!isset($lastGantt['last_gantt_id'])){ + $project->manPowers = 0; + } else { + $project->manPowers = UserToVersionGantt::where('version_gantt_id', $lastGantt['last_gantt_id'])->count(); + $project->scurve = MasterFunctionsHelper::getSCurve($project->id); + } $project->lastGanttId = MasterFunctionsHelper::getLatestGantt($project->id); } From 564cfcbf6e707aa3411c28c318aac5b48234f6ab Mon Sep 17 00:00:00 2001 From: Wahyu Ramadhan Date: Tue, 16 May 2023 09:39:09 +0700 Subject: [PATCH 3/3] Fix end date formatting --- app/Http/Controllers/ActivityController.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app/Http/Controllers/ActivityController.php b/app/Http/Controllers/ActivityController.php index 74dca42..361826d 100644 --- a/app/Http/Controllers/ActivityController.php +++ b/app/Http/Controllers/ActivityController.php @@ -396,14 +396,13 @@ class ActivityController extends Controller } foreach ($data['activities'] as $i => $activity_row) { $startDate = \DateTime::createFromFormat('d-m-y', $activity_row['start_date']); - $endDate = \DateTime::createFromFormat('d-m-y', $activity_row['end_date']); - + $endDate = \DateTime::createFromFormat('d-m-y H:i:sO', $activity_row['end_date']); $input['name'] = $activity_row['name']; $input['proyek_id'] = $projectId; $input['version_gantt_id'] = $data['ganttId']; $input['parent_id'] = null; $input['start_date'] = $startDate->format('Y-m-d'); - $input['end_date'] = $endDate->format('Y-m-d'); + $input['end_date'] = $endDate->format('Y-m-d H:i:sO'); $input['duration'] = $activity_row['duration']; $input['bobot_planning'] = $activity_row['weight']; $input['persentase_progress'] = 0;