From 063e50da6681c810994890ac8fe74ea06a37afd6 Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Tue, 8 Apr 2025 17:32:46 +0530 Subject: [PATCH] Added export functionality via migration --- .../Exports/ProductionLineStopExporter.php | 56 +++++++++++++++++++ .../Exports/ProductionPlanExporter.php | 48 ++++++++++++++++ .../Exports/ProductionQuantityExporter.php | 48 ++++++++++++++++ 3 files changed, 152 insertions(+) create mode 100644 app/Filament/Exports/ProductionLineStopExporter.php create mode 100644 app/Filament/Exports/ProductionPlanExporter.php create mode 100644 app/Filament/Exports/ProductionQuantityExporter.php diff --git a/app/Filament/Exports/ProductionLineStopExporter.php b/app/Filament/Exports/ProductionLineStopExporter.php new file mode 100644 index 0000000..4e3e6fb --- /dev/null +++ b/app/Filament/Exports/ProductionLineStopExporter.php @@ -0,0 +1,56 @@ +label('ID'), + ExportColumn::make('linestop.code') + ->label('CODE'), + ExportColumn::make('linestop.reason') + ->label('REASON'), + ExportColumn::make('from_datetime') + ->label('FROM DATETIME'), + ExportColumn::make('to_datetime') + ->label('TO DATETIME'), + ExportColumn::make('stop_hour') + ->label('STOP HOUR'), + ExportColumn::make('stop_min') + ->label('STOP MINUTE'), + ExportColumn::make('line.name') + ->label('LINE'), + ExportColumn::make('shift.name') + ->label('SHIFT'), + ExportColumn::make('plant.name') + ->label('PLANT'), + ExportColumn::make('created_at') + ->label('CREATED AT'), + ExportColumn::make('updated_at') + ->label('UPDATED AT'), + ExportColumn::make('deleted_at') + ->label('DELETED AT'), + ]; + } + + public static function getCompletedNotificationBody(Export $export): string + { + $body = 'Your production line stop export has completed and ' . number_format($export->successful_rows) . ' ' . str('row')->plural($export->successful_rows) . ' exported.'; + + if ($failedRowsCount = $export->getFailedRowsCount()) { + $body .= ' ' . number_format($failedRowsCount) . ' ' . str('row')->plural($failedRowsCount) . ' failed to export.'; + } + + return $body; + } +} diff --git a/app/Filament/Exports/ProductionPlanExporter.php b/app/Filament/Exports/ProductionPlanExporter.php new file mode 100644 index 0000000..babb706 --- /dev/null +++ b/app/Filament/Exports/ProductionPlanExporter.php @@ -0,0 +1,48 @@ +label('ID'), + ExportColumn::make('plan_quantity') + ->label('PLAN QUANTITY'), + ExportColumn::make('production_quantity') + ->label('PRODUCTION QUANTITY'), + ExportColumn::make('line.name') + ->label('LINE'), + ExportColumn::make('shift.name') + ->label('SHIFT'), + ExportColumn::make('plant.name') + ->label('PLANT'), + ExportColumn::make('created_at') + ->label('CREATED AT'), + ExportColumn::make('updated_at') + ->label('UPDATED AT'), + ExportColumn::make('deleted_at') + ->label('DELETED AT'), + ]; + } + + public static function getCompletedNotificationBody(Export $export): string + { + $body = 'Your production plan export has completed and ' . number_format($export->successful_rows) . ' ' . str('row')->plural($export->successful_rows) . ' exported.'; + + if ($failedRowsCount = $export->getFailedRowsCount()) { + $body .= ' ' . number_format($failedRowsCount) . ' ' . str('row')->plural($failedRowsCount) . ' failed to export.'; + } + + return $body; + } +} diff --git a/app/Filament/Exports/ProductionQuantityExporter.php b/app/Filament/Exports/ProductionQuantityExporter.php new file mode 100644 index 0000000..c7d3fbc --- /dev/null +++ b/app/Filament/Exports/ProductionQuantityExporter.php @@ -0,0 +1,48 @@ +label('ID'), + ExportColumn::make('item.code') + ->label('CODE'), + ExportColumn::make('serial_number') + ->label('SERIAL NUMBER'), + ExportColumn::make('line.name') + ->label('LINE'), + ExportColumn::make('shift.name') + ->label('SHIFT'), + ExportColumn::make('plant.name') + ->label('PLANT'), + ExportColumn::make('created_at') + ->label('CREATED AT'), + ExportColumn::make('updated_at') + ->label('UPDATED AT'), + ExportColumn::make('deleted_at') + ->label('DELETED AT'), + ]; + } + + public static function getCompletedNotificationBody(Export $export): string + { + $body = 'Your production quantity export has completed and ' . number_format($export->successful_rows) . ' ' . str('row')->plural($export->successful_rows) . ' exported.'; + + if ($failedRowsCount = $export->getFailedRowsCount()) { + $body .= ' ' . number_format($failedRowsCount) . ' ' . str('row')->plural($failedRowsCount) . ' failed to export.'; + } + + return $body; + } +}