From af307f413bb0b0f3370080b45351cb9fa16ad6e4 Mon Sep 17 00:00:00 2001 From: wahyuun Date: Mon, 23 Oct 2023 11:34:46 +0700 Subject: [PATCH 1/3] update Logic Presence --- app/Http/Controllers/PresenceController.php | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/app/Http/Controllers/PresenceController.php b/app/Http/Controllers/PresenceController.php index 17843f4..5b2199b 100644 --- a/app/Http/Controllers/PresenceController.php +++ b/app/Http/Controllers/PresenceController.php @@ -135,13 +135,23 @@ class PresenceController extends Controller $checkLocation = $this->checkLocation($request); $statusBoundary = false; $date = date_create($request->time); + $statusRestriction = HumanResource::select('status_boundary')->where('id', $request->user_id)->first(); // assign and in boundary - if(count($checkLocation) > 0 && $checkLocation[0]['boundary']){ - $statusBoundary = true; + if (count($checkLocation) > 0 && $statusRestriction->status_boundary == true) + { + if ($checkLocation[0]['boundary'] == true) + { + $statusBoundary = true; + } else { + $statusBoundary = false; + } } - $statusRestriction = HumanResource::select('status_boundary')->where('id', $request->user_id)->first(); - if (!$statusRestriction->status_boundary) { - $statusBoundary = true; + // assign and not in boundary or in boundary + else { + if ($checkLocation[0]['boundary'] == true || $checkLocation[0]['boundary'] == false) + { + $statusBoundary = true; + } } // not assign if(!$checkLocation[0]['status_assign'] && $checkLocation[0]['boundary'] == false && $statusBoundary == false){ From 0ceffeeb5fa82b68ce70c433d97dbeec12547741 Mon Sep 17 00:00:00 2001 From: wahyu Date: Mon, 23 Oct 2023 13:03:32 +0700 Subject: [PATCH 2/3] add filter scurve --- app/Helpers/MasterFunctionsHelper.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/Helpers/MasterFunctionsHelper.php b/app/Helpers/MasterFunctionsHelper.php index ae74952..20ca4fb 100644 --- a/app/Helpers/MasterFunctionsHelper.php +++ b/app/Helpers/MasterFunctionsHelper.php @@ -555,6 +555,7 @@ class MasterFunctionsHelper ->join('assign_material_to_activity AS amta', 'amta.activity_id', '=', 'a.id') ->where('a.type_activity', 'task') ->where('a.bobot_planning', '>', 0) + ->where('a.proyek_id', '=', $projectId) ->whereDate('amta.plan_date', '<=', $dt->format("Y-m-d")) ->whereDate('amta.plan_date', '>', $minSevenDays) ->select('a.bobot_planning', 'a.biaya_actual', 'a.duration', 'a.persentase_progress', 'a.id'); @@ -563,6 +564,7 @@ class MasterFunctionsHelper ->join('assign_hr_to_activity AS ahta', 'ahta.activity_id', '=', 'a.id') ->where('a.type_activity', 'task') ->where('a.bobot_planning', '>', 0) + ->where('a.proyek_id', '=', $projectId) ->whereDate('a.start_date', '<=', $dt->format("Y-m-d")) ->whereDate('a.start_date', '>', $minSevenDays) ->select('a.bobot_planning', 'a.biaya_actual', 'a.duration', 'a.persentase_progress', 'a.id') From 95b78bda1d61ce0a6afc95b1e38771ebafb21917 Mon Sep 17 00:00:00 2001 From: wahyu Date: Mon, 23 Oct 2023 14:28:21 +0700 Subject: [PATCH 3/3] zero division handling --- app/Helpers/MasterFunctionsHelper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Helpers/MasterFunctionsHelper.php b/app/Helpers/MasterFunctionsHelper.php index 20ca4fb..1bed1bb 100644 --- a/app/Helpers/MasterFunctionsHelper.php +++ b/app/Helpers/MasterFunctionsHelper.php @@ -375,7 +375,7 @@ class MasterFunctionsHelper // } - $totalACWP += $keyActualM->biaya_actual / $keyActualM->duration; + $totalACWP += $keyActualM->duration > 0 ? $keyActualM->biaya_actual / $keyActualM->duration : 0; } catch (\DivisionByZeroError $e) { return response()->json(['message' => $e->getMessage()]); }