1
0
forked from poc/pds

Added view rights against plant on import and export

This commit is contained in:
dhanabalan
2026-01-13 16:13:00 +05:30
parent 79a09e3a59
commit 49ab5b14ed
2 changed files with 64 additions and 62 deletions

View File

@@ -10,7 +10,9 @@ use Filament\Actions\Exports\Models\Export;
class EbReadingExporter extends Exporter class EbReadingExporter extends Exporter
{ {
protected static ?string $model = EbReading::class; protected static ?string $model = EbReading::class;
static $rowNumber = 0;
public static $rowNumber = 0;
public static function getColumns(): array public static function getColumns(): array
{ {
return [ return [
@@ -20,8 +22,8 @@ class EbReadingExporter extends Exporter
// Increment and return the row number // Increment and return the row number
return ++$rowNumber; return ++$rowNumber;
}), }),
ExportColumn::make('plant.name') ExportColumn::make('plant.code')
->label('PLANT'), ->label('PLANT CODE'),
ExportColumn::make('lcd_segment_check') ExportColumn::make('lcd_segment_check')
->label('LCD SEGMENT CHECK'), ->label('LCD SEGMENT CHECK'),
ExportColumn::make('meter_serial_no') ExportColumn::make('meter_serial_no')
@@ -129,10 +131,10 @@ class EbReadingExporter extends Exporter
public static function getCompletedNotificationBody(Export $export): string public static function getCompletedNotificationBody(Export $export): string
{ {
$body = 'Your eb reading export has completed and ' . number_format($export->successful_rows) . ' ' . str('row')->plural($export->successful_rows) . ' exported.'; $body = 'Your eb reading export has completed and '.number_format($export->successful_rows).' '.str('row')->plural($export->successful_rows).' exported.';
if ($failedRowsCount = $export->getFailedRowsCount()) { if ($failedRowsCount = $export->getFailedRowsCount()) {
$body .= ' ' . number_format($failedRowsCount) . ' ' . str('row')->plural($failedRowsCount) . ' failed to export.'; $body .= ' '.number_format($failedRowsCount).' '.str('row')->plural($failedRowsCount).' failed to export.';
} }
return $body; return $body;

View File

@@ -16,10 +16,10 @@ class EbReadingImporter extends Importer
return [ return [
ImportColumn::make('plant') ImportColumn::make('plant')
->requiredMapping() ->requiredMapping()
->exampleHeader('Plant Name') ->exampleHeader('Plant Code')
->example('Ransar Industries-I') ->example('1000')
->label('Plant Name') ->label('Plant Code')
->relationship(resolveUsing:'name') ->relationship(resolveUsing: 'code')
->rules(['required']), ->rules(['required']),
ImportColumn::make('lcd_segment_check') ImportColumn::make('lcd_segment_check')
->label('LCD Segment Check') ->label('LCD Segment Check')
@@ -227,15 +227,15 @@ class EbReadingImporter extends Importer
// 'email' => $this->data['email'], // 'email' => $this->data['email'],
// ]); // ]);
return new EbReading(); return new EbReading;
} }
public static function getCompletedNotificationBody(Import $import): string public static function getCompletedNotificationBody(Import $import): string
{ {
$body = 'Your eb reading import has completed and ' . number_format($import->successful_rows) . ' ' . str('row')->plural($import->successful_rows) . ' imported.'; $body = 'Your eb reading import has completed and '.number_format($import->successful_rows).' '.str('row')->plural($import->successful_rows).' imported.';
if ($failedRowsCount = $import->getFailedRowsCount()) { if ($failedRowsCount = $import->getFailedRowsCount()) {
$body .= ' ' . number_format($failedRowsCount) . ' ' . str('row')->plural($failedRowsCount) . ' failed to import.'; $body .= ' '.number_format($failedRowsCount).' '.str('row')->plural($failedRowsCount).' failed to import.';
} }
return $body; return $body;