diff --git a/app/Filament/Pages/ProductionTarget.php b/app/Filament/Pages/ProductionTarget.php index 1a5a68f0..ca8c7a31 100644 --- a/app/Filament/Pages/ProductionTarget.php +++ b/app/Filament/Pages/ProductionTarget.php @@ -208,6 +208,8 @@ class ProductionTarget extends Page } $this->dispatch('loadData1' ,$plantId, $lineId, $year, $month); + + $this->dispatch('loadDataMonthly' ,$plantId, $lineId, $year, $month); } public static function canAccess(): bool diff --git a/app/Livewire/ProductionTargetPlan.php b/app/Livewire/ProductionTargetPlan.php index 40117983..93d16c35 100644 --- a/app/Livewire/ProductionTargetPlan.php +++ b/app/Livewire/ProductionTargetPlan.php @@ -20,6 +20,8 @@ class ProductionTargetPlan extends Component public $dates = []; + public $monthlyRecords; + public $leaveDates = []; public $productionPlanDates = ''; @@ -27,6 +29,7 @@ class ProductionTargetPlan extends Component protected $listeners = [ 'loadData' => 'loadProductionData', 'loadData1' => 'exportProductionData', + 'loadDataMonthly' => 'loadMonthlyPlan', ]; public function getMonthDates($month, $year) @@ -625,6 +628,19 @@ class ProductionTargetPlan extends Component $this->records = $records; } + public function loadMonthlyPlan($year, $month, $plantId, $lineId){ + $this->monthlyRecords = ProductionPlan::query() + ->selectRaw(' + plant_id, + line_id, + SUM(plan_quantity) as monthly_plan + ') + ->whereYear('created_at', $year) + ->whereMonth('created_at', $month) + ->groupBy('plant_id', 'line_id') + ->get(); + } + public function exportProductionData() { diff --git a/resources/views/livewire/production-target-plan.blade.php b/resources/views/livewire/production-target-plan.blade.php index 696c417b..f3614cb9 100644 --- a/resources/views/livewire/production-target-plan.blade.php +++ b/resources/views/livewire/production-target-plan.blade.php @@ -1,4 +1,63 @@
| No | +Plant | +Line | ++ Monthly Plan Quantity + | +
|---|---|---|---|
| + {{ $index + 1 }} + | + ++ {{ $record['plant_name'] }} + | + ++ {{ $record['line_name'] }} + | + ++ {{ $this->loadMonthlyPlan( + $year, + $month, + $record['plant_id'], + $record['line_id'] + ) }} + | + +
| + No monthly production plan data found. + | +|||