From 80547e2e0409e0893459efdf895d43a537059236 Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Thu, 1 Oct 2026 18:09:23 +0530 Subject: [PATCH] Added efficiency in target plan --- app/Livewire/ProductionTargetPlan.php | 13 +++++++++---- .../views/livewire/production-target-plan.blade.php | 2 +- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/app/Livewire/ProductionTargetPlan.php b/app/Livewire/ProductionTargetPlan.php index 9b6e89da..3b452a70 100644 --- a/app/Livewire/ProductionTargetPlan.php +++ b/app/Livewire/ProductionTargetPlan.php @@ -23,6 +23,8 @@ class ProductionTargetPlan extends Component public $monthlyRecords = []; + public $efficiency = []; + public $monthlyActualQuantity = []; public $leaveDates = []; @@ -645,12 +647,14 @@ class ProductionTargetPlan extends Component $this->monthlyActualQuantity = ProductionPlan::where('plant_id', $plantId) ->where('line_id', $lineId) - ->whereBetween('created_at', [ - Carbon::create($year, $month, 1)->startOfMonth(), - now(), - ]) + ->whereYear('created_at', $year) + ->whereMonth('created_at', $month) ->count(); + $this->efficiency = $this->monthlyRecords > 0 + ? ($this->monthlyActualQuantity / $this->monthlyRecords) * 100 + : 0; + //$this->monthlyRecords = $plans->sum('plan_quantity'); } @@ -669,6 +673,7 @@ class ProductionTargetPlan extends Component 'records' => $this->records, 'monthlyRecords' => $this->monthlyRecords, 'monthlyActualRecords' => $this->monthlyActualQuantity, + 'monthlyEfficiency' => $this->efficiency, 'dates' => $this->dates, ]); } diff --git a/resources/views/livewire/production-target-plan.blade.php b/resources/views/livewire/production-target-plan.blade.php index 75ed892b..2488eca0 100644 --- a/resources/views/livewire/production-target-plan.blade.php +++ b/resources/views/livewire/production-target-plan.blade.php @@ -48,7 +48,7 @@ {{ $monthlyActualQuantity ?? 0 }} - {{ $monthlyRecords ?? 0 }} + {{ number_format($efficiency ?? 0, 2) }}%