From 8bd64c80d4f3e3f077b519c6d3abde63c9ceb6aa Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Mon, 16 Feb 2026 11:26:20 +0530 Subject: [PATCH] Added production plan export in production target page --- app/Exports/ProductionPlanExport.php | 61 ++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 app/Exports/ProductionPlanExport.php diff --git a/app/Exports/ProductionPlanExport.php b/app/Exports/ProductionPlanExport.php new file mode 100644 index 0000000..c464ec1 --- /dev/null +++ b/app/Exports/ProductionPlanExport.php @@ -0,0 +1,61 @@ +data = $data; + $this->dates = $dates; + } + + public function array(): array + { + return $this->data; + } + + public function headings(): array + { + $headings = [ + 'Plant Name', + 'Line Name', + 'Item Code', + ]; + + // Add dynamic headings for each date: Target / Produced + foreach ($this->dates as $date) { + $headings[] = $date . ' - Target Plan'; + $headings[] = $date . ' - Produced Quantity'; + } + + return $headings; + } + + public function map($row): array + { + $mapped = [ + $row['plant_name'] ?? '', + $row['line_name'] ?? '', + $row['item_code'] ?? '', + ]; + + // Add daily target and produced quantity for each date + foreach ($this->dates as $date) { + $mapped[] = $row['daily_target'] ?? 0; + $mapped[] = $row['produced_quantity'][$date] ?? 0; + } + + return $mapped; + } + +}