added datagrid table

This commit is contained in:
dhanabalan
2025-04-10 13:05:52 +05:30
parent 063e50da66
commit 57c3a876bd
6 changed files with 443 additions and 189 deletions

View File

@@ -4,7 +4,10 @@ namespace App\Filament\Resources;
use App\Filament\Resources\InvoiceValidationResource\Pages; use App\Filament\Resources\InvoiceValidationResource\Pages;
use App\Models\InvoiceValidation; use App\Models\InvoiceValidation;
use App\Models\StickerMaster;
use Filament\Actions\CreateAction;
use Filament\Forms; use Filament\Forms;
use Filament\Forms\Components\FileUpload;
use Filament\Forms\Components\Section; use Filament\Forms\Components\Section;
use Filament\Forms\Form; use Filament\Forms\Form;
use Filament\Resources\Resource; use Filament\Resources\Resource;
@@ -13,8 +16,10 @@ use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\SoftDeletingScope; use Illuminate\Database\Eloquent\SoftDeletingScope;
use Filament\Forms\Components\View; use Filament\Forms\Components\View;
use Filament\Notifications\Notification;
use Filament\Tables\Actions\Action;
use Illuminate\Support\Facades\Storage;
use Maatwebsite\Excel\Facades\Excel;
class InvoiceValidationResource extends Resource class InvoiceValidationResource extends Resource
{ {
@@ -24,24 +29,18 @@ class InvoiceValidationResource extends Resource
protected static ?string $navigationGroup = 'Invoice'; protected static ?string $navigationGroup = 'Invoice';
public $enter_pressed = false;
public static function form(Form $form): Form public static function form(Form $form): Form
{ {
return $form return $form
->schema([ ->schema([
Forms\Components\Hidden::make('sticker_master_id') // Forms\Components\Hidden::make('sticker_master_id')
//->relationship('stickerMaster', 'id') // //->relationship('stickerMaster', 'id')
->required(), // ->required(),
Section::make('') Section::make('')
->schema([ ->schema([
// FileUpload::make('excel_file')
// ->label('Choose Excel File')
// ->disk('local')
// ->columnSpan(1),
Forms\Components\Select::make('plant_id') Forms\Components\Select::make('plant_id')
->relationship('plant', 'name') ->relationship('plant', 'name')
->required(), ->required(),
@@ -57,7 +56,6 @@ class InvoiceValidationResource extends Resource
]), ]),
Forms\Components\TextInput::make('serial_number') Forms\Components\TextInput::make('serial_number')
//->required()
->reactive() ->reactive()
->columnSpan(1), ->columnSpan(1),
@@ -71,16 +69,11 @@ class InvoiceValidationResource extends Resource
]) ])
->columns(5), ->columns(5),
// View::make('livewire.invoice-data-table')
// ->label('Invoice Details')
// ->viewData([
// 'invoiceData' => fn ($get) => $get('invoice_data') ?? [], // Changed from invoiceData to invoice_data
// ])
// ->columnSpan('full'),
]); ]);
} }
public static function table(Table $table): Table public static function table(Table $table): Table
{ {
return $table return $table
@@ -98,35 +91,66 @@ class InvoiceValidationResource extends Resource
Tables\Columns\TextColumn::make('load_rate') Tables\Columns\TextColumn::make('load_rate')
->numeric() ->numeric()
->sortable(), ->sortable(),
Tables\Columns\TextColumn::make('created_at')
->dateTime()
->sortable()
->toggleable(isToggledHiddenByDefault: true),
Tables\Columns\TextColumn::make('updated_at')
->dateTime()
->sortable()
->toggleable(isToggledHiddenByDefault: true),
Tables\Columns\TextColumn::make('deleted_at')
->dateTime()
->sortable()
->toggleable(isToggledHiddenByDefault: true),
]) ])
->filters([
Tables\Filters\TrashedFilter::make(),
])
->actions([
Tables\Actions\ViewAction::make(),
Tables\Actions\EditAction::make(),
])
->bulkActions([
Tables\Actions\BulkActionGroup::make([
Tables\Actions\DeleteBulkAction::make(),
Tables\Actions\ForceDeleteBulkAction::make(),
Tables\Actions\RestoreBulkAction::make(),
]),
]);
}
->headerActions([
Tables\Actions\Action::make('Import Serial Number')
->label('Import Serial Number')
->form([
FileUpload::make('invoice_serial_number')
->label('Invoice Serial Number')
->preserveFilenames() // <- this keeps the original filename
->storeFiles(false) // prevent auto-storing, we will store manually
->disk('local') //'local' refers to the local storage disk defined in config/filesystems.php, typically pointing to storage/app.
->directory('uploads/temp'), //storage/app/uploads/temp
])
->action(function (array $data) {
$uploadedFile = $data['invoice_serial_number'];
// Get original filename
$originalName = $uploadedFile->getClientOriginalName(); // e.g. 3RA0018732.xlsx
// Store manually using storeAs to keep original name
$path = $uploadedFile->storeAs('uploads/temp', $originalName, 'local'); // returns relative path
$fullPath = Storage::disk('local')->path($path);
// Save full file path to session
session(['uploaded_invoice_path' => $fullPath]);
// session()->flash('just_uploaded_invoice', true); // 👈 add this
Notification::make()
->title('File Uploaded. Continue in Create Page.')
->success()
->send();
}),
Tables\Actions\Action::make('Import Invoice Material')
->label('Import Invoice Material')
->form([
FileUpload::make('invoice_material')
->label('Invoice Material')
->required(),
])
]);
// ->filters([
// Tables\Filters\TrashedFilter::make(),
// ])
// ->actions([
// Tables\Actions\ViewAction::make(),
// Tables\Actions\EditAction::make(),
// ])
// ->bulkActions([
// Tables\Actions\BulkActionGroup::make([
// Tables\Actions\DeleteBulkAction::make(),
// Tables\Actions\ForceDeleteBulkAction::make(),
// Tables\Actions\RestoreBulkAction::make(),
// ]),
// ]);
}
public static function getRelations(): array public static function getRelations(): array
{ {

View File

@@ -3,10 +3,14 @@
namespace App\Filament\Resources\InvoiceValidationResource\Pages; namespace App\Filament\Resources\InvoiceValidationResource\Pages;
use App\Filament\Resources\InvoiceValidationResource; use App\Filament\Resources\InvoiceValidationResource;
use App\Livewire\InvoiceDataTable;
use App\Models\InvoiceValidation;
use App\Models\StickerMaster;
use Illuminate\Contracts\View\View; use Illuminate\Contracts\View\View;
use Filament\Resources\Pages\CreateRecord; use Filament\Resources\Pages\CreateRecord;
use Filament\Notifications\Notification; use Filament\Notifications\Notification;
use Maatwebsite\Excel\Facades\Excel;
use Livewire\Livewire;
class CreateInvoiceValidation extends CreateRecord class CreateInvoiceValidation extends CreateRecord
{ {
@@ -18,103 +22,151 @@ class CreateInvoiceValidation extends CreateRecord
public $invoice_data; public $invoice_data;
public $invoiceData = [];
public $scanned_quantity; public $scanned_quantity;
public $total_quantity; public $total_quantity;
public string $invoiceNumber;
public $excel_file; public $excel_file;
public function getFormActions(): array
{
return parent::getFormActions();
}
public function processInvoice($invoiceNumber) public function processInvoice($invoiceNumber)
{ {
// Get plant_id selected in the form
$plantId = $this->form->getState()['plant_id'];
$this->invoice_number = $invoiceNumber; $filePath = session('uploaded_invoice_path');
// Check if the file is uploaded
if (!$this->excel_file) {
Notification::make()
->title('No File Uploaded')
->body("Please upload an Excel file to proceed with invoice: {$invoiceNumber}.")
->danger()
->persistent()
->send();
return;
}
$localPath = $this->excel_file->getPath();
// Check if file exists
if (!file_exists($localPath)) {
Notification::make()
->title('File Not Found')
->body("No Excel file found for invoice: {$invoiceNumber}. Please ensure the file exists in your Downloads folder.")
->danger()
->persistent()
->send();
return;
}
try {
$rows = \Maatwebsite\Excel\Facades\Excel::toArray([], $localPath)[0] ?? [];
array_shift($rows);
if (empty($rows)) {
Notification::make()
->title('Empty File')
->body('The Excel file contains no data rows')
->danger()
->send();
return;
}
$validRecords = [];
$invalidMaterials = [];
foreach ($rows as $row) {
$materialCode = $row[0] ?? null;
$serialNumber = $row[1] ?? null;
if (!\App\Models\StickerMaster::where('item_id', $materialCode)->exists()) {
$invalidMaterials[] = $materialCode;
continue;
}
$validRecords[] = [
'material_code' => $materialCode,
'serial_number' => $serialNumber,
'invoice_number' => $invoiceNumber,
'created_at' => now(),
'updated_at' => now(),
];
}
if (!empty($invalidMaterials)) {
Notification::make()
->title('Invalid Materials')
->body('These codes not found: ' . implode(', ', array_unique($invalidMaterials)))
->danger()
->send();
return;
}
\DB::table('invoice_validations')->insert($validRecords);
$this->invoice_data = $validRecords;
$this->scanned_quantity = count($validRecords);
$this->total_quantity = count($validRecords);
if (!file_exists($filePath))
{
Notification::make() Notification::make()
->title('Success') ->title('Excel File not found.')
->body(count($validRecords) . ' records inserted successfully')
->success()
->send();
} catch (\Exception $e) {
Notification::make()
->title('Error')
->body($e->getMessage())
->danger() ->danger()
->send(); ->send();
return;
}
// Extract filename without extension (e.g., "3RA0018732")
$uploadedFilename = pathinfo($filePath, PATHINFO_FILENAME);
// Compare with invoice number
if ($uploadedFilename !== $invoiceNumber) {
Notification::make()
->title("Uploaded file name does not match the invoice number.")
// ->body("Expected: {$invoiceNumber}.xlsx, but got: {$uploadedFilename}.xlsx")
->danger()
->send();
return;
}
if ($filePath && file_exists($filePath))
{
// Now you can read/process the file here
$rows = Excel::toArray(null, $filePath)[0]; //0 means excel first sheet
$materialCodes = [];
$serialNumbers = [];
foreach ($rows as $index => $row)
{
if ($index === 0) continue; // Skip header
$materialCode = trim($row[0]);
$serialNumber = trim($row[1]);
if (!empty($materialCode)) {
$materialCodes[] = $materialCode;
}
if (!empty($serialNumber)) {
$serialNumbers[] = $serialNumber;
}
}
$existingSerialNumbers = InvoiceValidation::whereIn('serial_number', $serialNumbers)->pluck('serial_number')->toArray();
// If there are duplicates, notify and stop the process
if (!empty($existingSerialNumbers)) {
Notification::make()
->title('Duplicate Serial Numbers Found')
->body('The following serial numbers already exist: ' . implode(', ', $existingSerialNumbers))
->danger()
->send();
return;
}
$uniqueCodes = array_unique($materialCodes);
$existingCodes = StickerMaster::with('item')
->get()
->pluck('item.code')
->toArray();
$missingCodes = array_diff($uniqueCodes, $existingCodes);
if (!empty($missingCodes)) {
Notification::make()
->title('Material codes do not exist in Sticker Master')
->body('Missing: ' . implode(', ', $missingCodes))
->danger()
->send();
return;
}
$inserted = 0;
foreach ($rows as $index => $row)
{
if ($index === 0) continue;
$materialCode = trim($row[0]);
$serialNumber = trim($row[1]);
if (in_array($serialNumber, $existingSerialNumbers)) {
continue; // here duplicate serial numbers are skipped and new serial numbers are inserted
}
$sticker = StickerMaster::whereHas('item', function ($query) use ($materialCode) {
$query->where('code', $materialCode); //Check if item.code matches Excel's materialCode
})->first();
if ($sticker) {
InvoiceValidation::create([
'sticker_master_id' => $sticker->id,
'serial_number' => $serialNumber,
'plant_id' => $plantId,
'invoice_number' => $invoiceNumber,
]);
$inserted++;
}
}
if ($inserted > 0)
{
Notification::make()
->title("Import Successful")
->body("$inserted records were inserted.")
->success()
->send();
// Dispatch the event to refresh the Livewire component
$this->dispatch('refreshInvoiceData', invoiceNumber: $invoiceNumber);
}
else
{
Notification::make()
->title("Import Failed")
->body("No new records were inserted.")
->danger()
->send();
return;
}
} }
} }
@@ -123,9 +175,5 @@ class CreateInvoiceValidation extends CreateRecord
return 'Scan Invoice Validation'; return 'Scan Invoice Validation';
} }
// public function render(): View
// {
// return view('filament.resources.invoice-validation-resource.pages.create-invoice-validation');
// }
} }

View File

@@ -4,6 +4,8 @@ namespace App\Filament\Resources\InvoiceValidationResource\Pages;
use App\Filament\Resources\InvoiceValidationResource; use App\Filament\Resources\InvoiceValidationResource;
use Filament\Actions; use Filament\Actions;
use Filament\Actions\Action;
use Filament\Forms\Components\FileUpload;
use Filament\Resources\Pages\ListRecords; use Filament\Resources\Pages\ListRecords;
class ListInvoiceValidations extends ListRecords class ListInvoiceValidations extends ListRecords
@@ -16,4 +18,12 @@ class ListInvoiceValidations extends ListRecords
Actions\CreateAction::make(), Actions\CreateAction::make(),
]; ];
} }
//to hide the data from the table
protected function getTableQuery(): \Illuminate\Database\Eloquent\Builder
{
return static::getResource()::getEloquentQuery()->whereRaw('1 = 0');
}
} }

View File

@@ -10,31 +10,44 @@ class InvoiceDataTable extends Component
public $invoiceData = []; public $invoiceData = [];
public string $invoiceNumber = '';
public bool $hasSearched = false;
protected $listeners = ['refreshInvoiceData' => 'loadData']; protected $listeners = ['refreshInvoiceData' => 'loadData'];
public function mount() public function loadData($invoiceNumber)
{ {
$this->loadData(); $this->invoiceNumber = $invoiceNumber;
$this->hasSearched = true;
} $this->invoiceData = InvoiceValidation::where('invoice_number', $this->invoiceNumber)
->get()
->map(function ($record) {
return [
'sticker_master_id' => $record->sticker_master_id,
'serial_number' => $record->serial_number,
'motor_scanned_status' => $record->motor_scanned_status,
'pump_scanned_status' => $record->pump_scanned_status,
'capacitor_scanned_status' => $record->capacitor_scanned_status,
'scanned_status_set' => $record->scanned_status_set,
'panel_box_supplier' => $record->panel_box_supplier,
'panel_box_serial_number' => $record->panel_box_serial_number,
'scanned_status' => $record->scanned_status,
];
})
public function loadData() ->toArray();
{
$this->invoiceData = InvoiceValidation::all()->toArray(); //Loop through and replace 'code' using related StickerMaster > Item > code
foreach ($this->invoiceData as &$row) {
$stickerMaster = \App\Models\StickerMaster::with('item')->find($row['sticker_master_id'] ?? null);
$row['code'] = $stickerMaster?->item?->code ?? 'N/A';
}
} }
public function render() public function render()
{ {
// Always fetch fresh data when Livewire re-renders (like via polling) return view('livewire.invoice-data-table');
$invoiceData = InvoiceValidation::latest()->get();
return view('livewire.invoice-data-table', [
'invoiceData' => $invoiceData,
]);
// return view('livewire.invoice-data-table', [
// 'invoiceData' => $this->invoiceData, // <--- this is important
// ]);
} }
} }

View File

@@ -1,7 +1,36 @@
<x-filament::page> {{-- <x-filament::page>
<form wire:submit.prevent="create">
{{ $this->form }} {{ $this->form }}
{{-- @livewire('invoice-data-table') --}} <livewire:invoice-data-table :invoice-data="$invoice_data" />
<livewire:invoice-data-table :invoice-data="$invoice_data" />
<x-filament::actions class="mt-4">
@foreach ($this->getFormActions() as $action)
{{ $action }}
@endforeach
</x-filament::actions>
</x-filament::page> --}}
<x-filament::page>
<form wire:submit.prevent="create" class="space-y-6">
{{-- Form Section --}}
<div class="filament-form space-y-6">
{{ $this->form }}
</div>
{{-- Livewire Component (Invoice Table) --}}
<div class="bg-white shadow rounded-xl p-4">
<livewire:invoice-data-table :invoice-data="$invoice_data" />
</div>
{{-- Actions --}}
<div class="filament-actions mt-6">
<x-filament::actions>
@foreach ($this->getFormActions() as $action)
{{ $action }}
@endforeach
</x-filament::actions>
</div>
</form>
</x-filament::page> </x-filament::page>

View File

@@ -1,4 +1,4 @@
<div wire:poll.5s> {{-- <div>
<div class="mb-4"> <div class="mb-4">
<h2 class="text-lg font-bold text-gray-800">INVOICE DATA TABLE</h2> <h2 class="text-lg font-bold text-gray-800">INVOICE DATA TABLE</h2>
<div class="mt-2"> <div class="mt-2">
@@ -6,40 +6,170 @@
</div> </div>
</div> </div>
<table class="min-w-full text-sm text-center border border-gray-300"> <div class="overflow-x-auto overflow-y-visible">
<thead class="bg-gray-100 font-bold"> <table class="min-w-[1500px] text-sm text-center border border-gray-300">
<tr> <thead class="bg-gray-100 font-bold">
<th class="border px-4 py-2 min-w-[100px]">No</th>
<th class="border px-4 py-2 min-w-[200px]">Material Code</th>
<th class="border px-4 py-2 min-w-[250px]">Serial Number</th>
<th class="border px-4 py-2 min-w-[200px]">Motor Scanned Status</th>
<th class="border px-4 py-2 min-w-[200px]">Pump Scanned Status</th>
<th class="border px-4 py-2 min-w-[250px]">Capacitor Scanned Status</th>
<th class="border px-4 py-2 min-w-[200px]">Scanned Status Set</th>
<th class="border px-4 py-2 min-w-[250px]">Panel Box Supplier</th>
<th class="border px-4 py-2 min-w-[250px]">Panel Box Serial Number</th>
<th class="border px-4 py-2 min-w-[200px]">Scanned Status</th>
</tr>
</thead>
<tbody>
@forelse ($invoiceData as $index => $row)
<tr class="border-t">
<td class="border px-4 py-2">{{ $index + 1 }}</td>
<td class="border px-4 py-2">{{ $row['material_code'] ?? 'N/A' }}</td>
<td class="border px-4 py-2">{{ $row['serial_number'] ?? 'N/A' }}</td>
<td class="border px-4 py-2">{{ $row['motor_scanned_status'] ?? 'N/A' }}</td>
<td class="border px-4 py-2">{{ $row['pump_scanned_status'] ?? 'N/A' }}</td>
<td class="border px-4 py-2">{{ $row['capacitor_scanned_status'] ?? 'N/A' }}</td>
<td class="border px-4 py-2">{{ $row['scanned_status_set'] ?? 'N/A' }}</td>
<td class="border px-4 py-2">{{ $row['panel_box_supplier'] ?? 'N/A' }}</td>
<td class="border px-4 py-2">{{ $row['panel_box_serial_number'] ?? 'N/A' }}</td>
<td class="border px-4 py-2">{{ $row['scanned_status'] ?? 'N/A' }}</td>
</tr>
@empty
<tr> <tr>
<td colspan="10" class="text-center py-4 text-gray-500">No data available.</td> <th class="border px-4 py-2 min-w-[100px]">No</th>
<th class="border px-4 py-2 min-w-[200px]">Material Code</th>
<th class="border px-4 py-2 min-w-[250px]">Serial Number</th>
<th class="border px-4 py-2 min-w-[200px]">Motor Scanned Status</th>
<th class="border px-4 py-2 min-w-[200px]">Pump Scanned Status</th>
<th class="border px-4 py-2 min-w-[250px]">Capacitor Scanned Status</th>
<th class="border px-4 py-2 min-w-[200px]">Scanned Status Set</th>
<th class="border px-4 py-2 min-w-[250px]">Panel Box Supplier</th>
<th class="border px-4 py-2 min-w-[250px]">Panel Box Serial Number</th>
<th class="border px-4 py-2 min-w-[200px]">Scanned Status</th>
</tr> </tr>
@endforelse </thead>
</tbody> <tbody>
</table> @forelse ($invoiceData as $index => $row)
<tr class="border-t">
<td class="border px-4 py-2">{{ $index + 1 }}</td>
<td class="border px-4 py-2">{{ $row['code'] ?? 'N/A' }}</td>
<td class="border px-4 py-2">{{ $row['serial_number'] ?? 'N/A' }}</td>
<td class="border px-4 py-2">{{ $row['motor_scanned_status'] ?? 'N/A' }}</td>
<td class="border px-4 py-2">{{ $row['pump_scanned_status'] ?? 'N/A' }}</td>
<td class="border px-4 py-2">{{ $row['capacitor_scanned_status'] ?? 'N/A' }}</td>
<td class="border px-4 py-2">{{ $row['scanned_status_set'] ?? 'N/A' }}</td>
<td class="border px-4 py-2">{{ $row['panel_box_supplier'] ?? 'N/A' }}</td>
<td class="border px-4 py-2">{{ $row['panel_box_serial_number'] ?? 'N/A' }}</td>
<td class="border px-4 py-2">{{ $row['scanned_status'] ?? 'N/A' }}</td>
</tr>
@empty
<tr>
<td colspan="10" class="text-center py-4 text-gray-500">No data available.</td>
</tr>
@endforelse
</tbody>
</table>
</div>
</div> </div>
<script>
window.addEventListener('load-data', event => {
Livewire.emit('loadData', event.detail.invoiceNumber);
});
</script> --}}
{{-- this is code for input box inisde the data grid --}}
{{-- <div>
<div class="mb-4">
<h2 class="text-lg font-bold text-gray-800">INVOICE DATA TABLE</h2>
<div class="mt-2">
<hr class="border-t-2 border-gray-300">
</div>
</div>
<input
type="text"
wire:model.defer="invoiceNumber"
wire:keydown.enter="loadData"
placeholder="Enter invoice number and press Enter"
class="border rounded px-3 py-2 mb-4"
/>
@if($hasSearched)
<div class="overflow-x-auto overflow-y-visible">
<table class="min-w-[1500px] text-sm text-center border border-gray-300">
<thead class="bg-gray-100 font-bold">
<tr>
<th class="border px-4 py-2 min-w-[100px]">No</th>
<th class="border px-4 py-2 min-w-[200px]">Material Code</th>
<th class="border px-4 py-2 min-w-[250px]">Serial Number</th>
<th class="border px-4 py-2 min-w-[200px]">Motor Scanned Status</th>
<th class="border px-4 py-2 min-w-[200px]">Pump Scanned Status</th>
<th class="border px-4 py-2 min-w-[250px]">Capacitor Scanned Status</th>
<th class="border px-4 py-2 min-w-[200px]">Scanned Status Set</th>
<th class="border px-4 py-2 min-w-[250px]">Panel Box Supplier</th>
<th class="border px-4 py-2 min-w-[250px]">Panel Box Serial Number</th>
<th class="border px-4 py-2 min-w-[200px]">Scanned Status</th>
</tr>
</thead>
<tbody>
@forelse ($invoiceData as $index => $row)
<tr class="border-t">
<td class="border px-4 py-2">{{ $index + 1 }}</td>
<td class="border px-4 py-2">{{ $row['code'] ?? 'N/A' }}</td>
<td class="border px-4 py-2">{{ $row['serial_number'] ?? 'N/A' }}</td>
<td class="border px-4 py-2">{{ $row['motor_scanned_status'] ?? 'N/A' }}</td>
<td class="border px-4 py-2">{{ $row['pump_scanned_status'] ?? 'N/A' }}</td>
<td class="border px-4 py-2">{{ $row['capacitor_scanned_status'] ?? 'N/A' }}</td>
<td class="border px-4 py-2">{{ $row['scanned_status_set'] ?? 'N/A' }}</td>
<td class="border px-4 py-2">{{ $row['panel_box_supplier'] ?? 'N/A' }}</td>
<td class="border px-4 py-2">{{ $row['panel_box_serial_number'] ?? 'N/A' }}</td>
<td class="border px-4 py-2">{{ $row['scanned_status'] ?? 'N/A' }}</td>
</tr>
@empty
<tr>
<td colspan="10" class="text-center py-4 text-gray-500">
No data found for invoice number <strong>{{ $invoiceNumber }}</strong>.
</td>
</tr>
@endforelse
</tbody>
</table>
</div>
@endif
</div> --}}
<div>
<div class="mb-4">
<h2 class="text-lg font-bold text-gray-800">INVOICE DATA TABLE</h2>
<div class="mt-2">
<hr class="border-t-2 border-gray-300">
</div>
</div>
@if($hasSearched)
<div class="overflow-x-auto overflow-y-visible">
<table class="min-w-[1500px] text-sm text-center border border-gray-300">
<thead class="bg-gray-100 font-bold">
<tr>
<th class="border px-4 py-2 min-w-[100px]">No</th>
<th class="border px-4 py-2 min-w-[200px]">Material Code</th>
<th class="border px-4 py-2 min-w-[250px]">Serial Number</th>
<th class="border px-4 py-2 min-w-[200px]">Motor Scanned Status</th>
<th class="border px-4 py-2 min-w-[200px]">Pump Scanned Status</th>
<th class="border px-4 py-2 min-w-[250px]">Capacitor Scanned Status</th>
<th class="border px-4 py-2 min-w-[200px]">Scanned Status Set</th>
<th class="border px-4 py-2 min-w-[250px]">Panel Box Supplier</th>
<th class="border px-4 py-2 min-w-[250px]">Panel Box Serial Number</th>
<th class="border px-4 py-2 min-w-[200px]">Scanned Status</th>
</tr>
</thead>
<tbody>
@forelse ($invoiceData as $index => $row)
<tr class="border-t">
<td class="border px-4 py-2">{{ $index + 1 }}</td>
<td class="border px-4 py-2">{{ $row['code'] ?? 'N/A' }}</td>
<td class="border px-4 py-2">{{ $row['serial_number'] ?? 'N/A' }}</td>
<td class="border px-4 py-2">{{ $row['motor_scanned_status'] ?? 'N/A' }}</td>
<td class="border px-4 py-2">{{ $row['pump_scanned_status'] ?? 'N/A' }}</td>
<td class="border px-4 py-2">{{ $row['capacitor_scanned_status'] ?? 'N/A' }}</td>
<td class="border px-4 py-2">{{ $row['scanned_status_set'] ?? 'N/A' }}</td>
<td class="border px-4 py-2">{{ $row['panel_box_supplier'] ?? 'N/A' }}</td>
<td class="border px-4 py-2">{{ $row['panel_box_serial_number'] ?? 'N/A' }}</td>
<td class="border px-4 py-2">{{ $row['scanned_status'] ?? 'N/A' }}</td>
</tr>
@empty
<tr>
<td colspan="10" class="text-center py-4 text-gray-500">
No data found for invoice number <strong>{{ $invoiceNumber }}</strong>.
</td>
</tr>
@endforelse
</tbody>
</table>
</div>
@endif
</div>