From 94fbcb1af89916d898964f28c52f9310de3d4bb7 Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Mon, 12 Oct 2026 14:13:02 +0530 Subject: [PATCH] Added plant and line in non production plan grid --- app/Livewire/ProductionNonPlanned.php | 60 ++++++++++++++++--- .../livewire/production-non-planned.blade.php | 4 ++ 2 files changed, 55 insertions(+), 9 deletions(-) diff --git a/app/Livewire/ProductionNonPlanned.php b/app/Livewire/ProductionNonPlanned.php index 4f5eb9fb..62f34ee2 100644 --- a/app/Livewire/ProductionNonPlanned.php +++ b/app/Livewire/ProductionNonPlanned.php @@ -2,11 +2,13 @@ namespace App\Livewire; +use App\Exports\ProductionNonPlanExport; use App\Models\ProductionPlan; use App\Models\QualityValidation; -use Carbon\Carbon; +use Illuminate\Support\Carbon; use Illuminate\Support\Facades\DB; use Livewire\Component; +use Maatwebsite\Excel\Facades\Excel; class ProductionNonPlanned extends Component { @@ -20,8 +22,6 @@ class ProductionNonPlanned extends Component public int $nonPlannedQuantity = 0; - // public $dates = []; - public $monthlyRecords = []; public $efficiency = []; @@ -37,7 +37,8 @@ class ProductionNonPlanned extends Component protected $listeners = [ 'loadData' => 'loadProductionData', - 'loadDataCategory' => 'loadProductionCategoryData' + 'loadDataCategory' => 'loadProductionCategoryData', + 'loadDataExport' => 'exportNonPlannedData' ]; public function loadProductionData($date, $plantId, $lineId) @@ -116,6 +117,18 @@ class ProductionNonPlanned extends Component '=', 'sticker_masters.item_id' ) + ->join( + 'plants', + 'plants.id', + '=', + 'quality_validations.plant_id' + ) + ->join( + 'lines', + 'lines.id', + '=', + 'quality_validations.line_id' + ) ->where('quality_validations.plant_id', $plantId) ->where('quality_validations.line_id', $lineId) ->where('quality_validations.created_at', '>=', $startDate) @@ -130,6 +143,8 @@ class ProductionNonPlanned extends Component $nonPlannedData = $nonPlannedQuery ->selectRaw(" + plants.name as plant_name, + lines.name as line_name, sticker_masters.item_id, items.code as item_code, items.description as item_description, @@ -137,6 +152,8 @@ class ProductionNonPlanned extends Component COUNT(*) as total_qty ") ->groupBy( + 'plants.name', + 'lines.name', 'sticker_masters.item_id', 'items.code', 'items.description', @@ -228,6 +245,18 @@ class ProductionNonPlanned extends Component '=', 'sticker_masters.item_id' ) + ->join( + 'plants', + 'plants.id', + '=', + 'quality_validations.plant_id' + ) + ->join( + 'lines', + 'lines.id', + '=', + 'quality_validations.line_id' + ) ->where('quality_validations.plant_id', $plantId) ->where('quality_validations.line_id', $lineId) ->where('items.category', $category) @@ -243,6 +272,8 @@ class ProductionNonPlanned extends Component $nonPlannedData = $nonPlannedQuery ->selectRaw(" + plants.name as plant_name, + lines.name as line_name, sticker_masters.item_id, items.code as item_code, items.description as item_description, @@ -250,6 +281,8 @@ class ProductionNonPlanned extends Component COUNT(*) as total_qty ") ->groupBy( + 'plants.name', + 'lines.name', 'sticker_masters.item_id', 'items.code', 'items.description', @@ -264,15 +297,24 @@ class ProductionNonPlanned extends Component $this->nonPlannedQuantity = (int) $nonPlannedData->sum('total_qty'); } + public function exportNonPlannedData() + { + $selectedDate = Carbon::parse($this->date)->toDateString(); + + $startDate = Carbon::parse($selectedDate)->setTime(8, 0, 0); + $endDate = $startDate->copy()->addDay(); + return Excel::download( + new ProductionNonPlanExport($this->nonPlannedRecords, $startDate->toDateTimeString(), + $endDate->toDateTimeString()), + 'production_non_plan_data.xlsx' + ); + } + public function render() { // return view('livewire.production-non-planned'); return view('livewire.production-non-planned', [ - 'records' => $this->records, - 'monthlyRecords' => $this->monthlyRecords, - 'monthlyActualRecords' => $this->monthlyActualQuantity, - 'monthlyEfficiency' => $this->efficiency, - 'dates' => $this->dates, + 'records' => $this->nonPlannedRecords, ]); } } diff --git a/resources/views/livewire/production-non-planned.blade.php b/resources/views/livewire/production-non-planned.blade.php index 440e2b6f..7b1fabd6 100644 --- a/resources/views/livewire/production-non-planned.blade.php +++ b/resources/views/livewire/production-non-planned.blade.php @@ -9,6 +9,8 @@ No + Plant + Line Item Code Category Non Planned Quantity @@ -18,6 +20,8 @@ @foreach ($nonPlannedRecords as $index => $item) {{ $index + 1 }} + {{ $item['plant_name'] }} + {{ $item['line_name'] }} {{ $item['item_code'] }} {{ $item['item_category'] }} {{ $item['total_qty'] }} -- 2.49.1