Some checks failed
Gemini PR Review / Gemini PR Review (pull_request) Waiting to run
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Waiting to run
Laravel Larastan / larastan (pull_request) Waiting to run
Laravel Pint / pint (pull_request) Waiting to run
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
68 lines
2.2 KiB
PHP
68 lines
2.2 KiB
PHP
<?php
|
|
|
|
namespace App\Filament\Exports;
|
|
|
|
use App\Models\Axn;
|
|
use App\Models\InvoiceValidation;
|
|
use Filament\Actions\Exports\ExportColumn;
|
|
use Filament\Actions\Exports\Exporter;
|
|
use Filament\Actions\Exports\Models\Export;
|
|
|
|
class AxnExporter extends Exporter
|
|
{
|
|
protected static ?string $model = InvoiceValidation::class;
|
|
|
|
public static function getColumns(): array
|
|
{
|
|
// static $rowNumber = 0;
|
|
|
|
return [
|
|
// ExportColumn::make('no')
|
|
// ->label('NO')
|
|
// ->state(function ($record) use (&$rowNumber) {
|
|
// // Increment and return the row number
|
|
// return ++$rowNumber;
|
|
// }),
|
|
// ExportColumn::make('plant.code')
|
|
// ->label('PLANT CODE'),
|
|
// ExportColumn::make('invoice_number')
|
|
// ->label('INVOICE NUMBER'),
|
|
ExportColumn::make('year')
|
|
->label('YEAR')
|
|
->state(function ($record) {
|
|
return substr($record->serial_number, 0, 2);
|
|
}),
|
|
ExportColumn::make('month')
|
|
->label('MONTH')
|
|
->state(function ($record) {
|
|
return substr($record->serial_number, 2, 2);
|
|
}),
|
|
ExportColumn::make('vendor')
|
|
->label('VENDOR NUMBER')
|
|
->state(function ($record) {
|
|
return substr($record->serial_number, 4, 4);
|
|
}),
|
|
ExportColumn::make('serial_number')
|
|
->label('SERIAL NUMBER')
|
|
->state(function ($record) {
|
|
$sn = $record->serial_number;
|
|
|
|
$offset = 2 + 2 + 4;
|
|
|
|
return substr($sn, $offset);
|
|
}),
|
|
];
|
|
}
|
|
|
|
public static function getCompletedNotificationBody(Export $export): string
|
|
{
|
|
$body = 'Your axn 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;
|
|
}
|
|
}
|