Merge pull request 'Added axn export page in invoice validation resource page' (#518) from ranjith-dev into master
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Reviewed-on: #518
This commit was merged in pull request #518.
This commit is contained in:
63
app/Filament/Exports/AxnExporter.php
Normal file
63
app/Filament/Exports/AxnExporter.php
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
<?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) {
|
||||||
|
return substr($record->serial_number, 8);
|
||||||
|
}),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,6 +3,7 @@
|
|||||||
namespace App\Filament\Resources;
|
namespace App\Filament\Resources;
|
||||||
|
|
||||||
use AlperenErsoy\FilamentExport\Actions\FilamentExportBulkAction;
|
use AlperenErsoy\FilamentExport\Actions\FilamentExportBulkAction;
|
||||||
|
use App\Filament\Exports\AxnExporter;
|
||||||
use App\Filament\Exports\InvoiceValidationExporter;
|
use App\Filament\Exports\InvoiceValidationExporter;
|
||||||
use App\Filament\Imports\InvoiceValidationImporter;
|
use App\Filament\Imports\InvoiceValidationImporter;
|
||||||
use App\Filament\Resources\InvoiceValidationResource\Pages;
|
use App\Filament\Resources\InvoiceValidationResource\Pages;
|
||||||
@@ -1141,6 +1142,13 @@ class InvoiceValidationResource extends Resource
|
|||||||
->visible(function () {
|
->visible(function () {
|
||||||
return Filament::auth()->user()->can('view export invoice');
|
return Filament::auth()->user()->can('view export invoice');
|
||||||
}),
|
}),
|
||||||
|
ExportAction::make()
|
||||||
|
->label('Export Axn')
|
||||||
|
->color('warning')
|
||||||
|
->exporter(AxnExporter::class)
|
||||||
|
->visible(function () {
|
||||||
|
return Filament::auth()->user()->can('view export axn invoice');
|
||||||
|
}),
|
||||||
])
|
])
|
||||||
|
|
||||||
->filters([
|
->filters([
|
||||||
|
|||||||
Reference in New Issue
Block a user