From ba5447c3ff4c0529d7a7d48399f1db48716a181c Mon Sep 17 00:00:00 2001 From: ibnu Date: Mon, 27 Nov 2023 20:49:18 +0700 Subject: [PATCH] update fix curva --- app/Helpers/MasterFunctionsHelper.php | 28 +++++++++------------------ 1 file changed, 9 insertions(+), 19 deletions(-) diff --git a/app/Helpers/MasterFunctionsHelper.php b/app/Helpers/MasterFunctionsHelper.php index c45954e..f1e9058 100644 --- a/app/Helpers/MasterFunctionsHelper.php +++ b/app/Helpers/MasterFunctionsHelper.php @@ -514,15 +514,6 @@ class MasterFunctionsHelper if (!Activity::where("version_gantt_id", $keyGantt['id'])->first()) return $dataFinal; - // $alreadyHasReport = DB::table('report_activity_material as a') - // ->select('a.id') - // ->join('m_activity as b', 'b.id', '=', 'a.activity_id') - // ->where('b.version_gantt_id', '=', $keyGantt['id']) - // ->exists(); - // note : delete this - // if(!$alreadyHasReport) - // return $dataFinal; - $minDate = Activity::where('version_gantt_id', $keyGantt['id'])->whereNull('parent_id')->pluck('start_date')->first(); $begin = new \DateTime($minDate); @@ -568,14 +559,6 @@ class MasterFunctionsHelper $minSevenDays = new \Datetime($dt->format("Y-m-d")); $minSevenDays = $minSevenDays->modify('-7 day')->format("Y-m-d"); $tempDate[] = array($dt->format("Y-m-d")); - // $dataPlanM = DB::table('assign_material_to_activity as ama') - // ->select('ama.activity_id', 'ama.qty_planning', 'ama.plan_date', 'ama.start_activity', 'a.bobot_planning', 'a.biaya_actual', 'a.duration', 'a.persentase_progress') - // ->join('m_activity as a', 'a.id', '=', 'ama.activity_id') - // ->where('ama.proyek_id', '=', $keyGantt['proyek_id']) - // ->where('a.version_gantt_id', '=', $keyGantt['id']) - // ->whereDate('ama.plan_date', '<=',$dt->format("Y-m-d")) - // ->whereDate('ama.plan_date', '>', $minSevenDays) - // ->get(); $activities = DB::table('m_activity AS a') ->join('assign_material_to_activity AS amta', 'amta.activity_id', '=', 'a.id') @@ -1381,6 +1364,9 @@ class MasterFunctionsHelper 'plan' => $dataTempPlan, 'actual' => $dataTempReport, ); + + $today = new DateTime(); + $date = new DateTime($dt->format("Y-m-d")); if (isset($dataPayload['period']) && $dataPayload['period'] == 'week') { $tempTtlPercentPlan += $sumPercentagePlan; $tempTtlPercentActual += $sumPercentageActual; @@ -1394,14 +1380,18 @@ class MasterFunctionsHelper $tempPercentage[] = array(round($tempTtlPercentPlan, 2), round($tempTtlPercentActual, 2)); $tempPercentagePlan[] = round($tempTtlPercentPlan, 2); $tempPercentagePlanWhr[] = ["weekly period", $tempPercentagePlan]; - $tempPercentageReal[] = round($tempTtlPercentActual, 2); + if ($date < $today) { + $tempPercentageReal[] = round($tempTtlPercentActual, 2); + } // if ($tempTtlPercentPlan >= 100 && $tempTtlPercentActual >= 100) { // break; // } } else { $tempPercentage[] = array(round($sumPercentagePlan, 2), round($sumPercentageActual, 2)); $tempPercentagePlan[] = round($sumPercentagePlan, 2); - $tempPercentageReal[] = round($sumPercentageActual, 2); + if ($date < $today) { + $tempPercentageReal[] = round($sumPercentageActual, 2); + } } $tempDate[] = array($dt->format("Y-m-d")); }