From 09b756b35bfae39b64776d91a08b967518af7cf6 Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Sun, 4 Jan 2026 11:37:30 +0530 Subject: [PATCH] Added alert mail rule exporter file --- .../Exports/AlertMailRuleExporter.php | 73 +++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 app/Filament/Exports/AlertMailRuleExporter.php diff --git a/app/Filament/Exports/AlertMailRuleExporter.php b/app/Filament/Exports/AlertMailRuleExporter.php new file mode 100644 index 0000000..a3e9a67 --- /dev/null +++ b/app/Filament/Exports/AlertMailRuleExporter.php @@ -0,0 +1,73 @@ +label('NO') + ->state(function ($record) use (&$rowNumber) { + // Increment and return the row number + return ++$rowNumber; + }), + ExportColumn::make('module') + ->label('MODULE'), + ExportColumn::make('rule_name') + ->label('RULE NAME'), + ExportColumn::make('email') + ->label('EMAIL'), + ExportColumn::make('schedule_type') + ->label('SCHEDULE TYPE'), + ExportColumn::make('plant') + ->label('PLANT CODE') + ->formatStateUsing(function ($state) { + // $state is the plant ID from the database + if ($state == 0) { + return 'All Plants'; + } + + $plant = Plant::find($state); + return $plant ? $plant->code : 'Unknown'; + }), + ExportColumn::make('cc_emails') + ->label('CC EMAILS'), + ExportColumn::make('invoiceMaster.receiving_plant_name') + ->label('RECEIVING PLANT NAME'), + ExportColumn::make('invoiceMaster.transport_name') + ->label('TRANSPORT NAME'), + ExportColumn::make('created_at') + ->label('CREATED AT'), + ExportColumn::make('created_by') + ->label('CREATED BY'), + ExportColumn::make('updated_at') + ->label('UPDATED AT'), + ExportColumn::make('deleted_at') + ->label('DELETED AT') + ->enabledByDefault(false), + + ]; + } + + public static function getCompletedNotificationBody(Export $export): string + { + $body = 'Your alert mail rule 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; + } +} -- 2.49.1