16 Commits

Author SHA1 Message Date
dhanabalan
73df86f269 Updated import validation functionality 2025-05-06 12:44:52 +05:30
dhanabalan
b0149f6d61 Updated import validation functionality 2025-05-06 12:42:53 +05:30
dhanabalan
eb81eed835 Updated import validation functionality 2025-05-06 12:41:34 +05:30
dhanabalan
daf81cd0c0 Added import validation functionality 2025-05-06 12:38:06 +05:30
dhanabalan
4108a438c7 Updated import validation functionality 2025-05-06 12:35:20 +05:30
dhanabalan
f698909cd2 Added import validation functionality 2025-05-06 12:32:22 +05:30
dhanabalan
75f97e7a2b Restrict duplicate warning on update 2025-05-06 12:26:42 +05:30
dhanabalan
a189c58352 Removed 'lines' hasMany relations 2025-05-06 12:21:20 +05:30
dhanabalan
43180d77b2 Added hasMany relation 2025-05-06 12:19:47 +05:30
dhanabalan
f08714e2a3 Added hasMany relations 2025-05-06 12:17:49 +05:30
dhanabalan
af5a107295 Updated hasMany relation 2025-05-06 12:13:28 +05:30
dhanabalan
21b0276cfd Notification duration changed and RegEx pattern changed isMarkM or isMarkP or isMarkC or isMarkPs and Added invalid quantity material qr format warning and Restricted duplicate material qr 2025-05-06 12:12:24 +05:30
dhanabalan
504b110ff3 Converted from durations to seconds to Notifications 2025-05-06 11:31:29 +05:30
dhanabalan
2477b88ea5 Removed searchable func. and added filters func. to view report 2025-05-06 11:17:53 +05:30
dhanabalan
0a1c222372 Disable by default to 'deleted_at' column 2025-05-06 11:11:53 +05:30
dhanabalan
ed97baae03 Column position change and disable by default to 'deleted_at' column 2025-05-06 11:10:58 +05:30
16 changed files with 507 additions and 77 deletions

View File

@@ -16,22 +16,22 @@ class InvoiceValidationExporter extends Exporter
return [
ExportColumn::make('id')
->label('ID'),
ExportColumn::make('stickerMaster.item.code')
->label('ITEM CODE'),
ExportColumn::make('plant.name')
->label('PLANT'),
ExportColumn::make('invoice_number')
->label('INVOICE NUMBER'),
ExportColumn::make('serial_number')
->label('SERIAL NUMBER'),
ExportColumn::make('stickerMaster.item.code')
->label('ITEM CODE'),
ExportColumn::make('motor_scanned_status')
->label('MOTOR SCANNED STATUS'),
ExportColumn::make('pump_scanned_status')
->label('PUMP SCANNED STATUS'),
ExportColumn::make('scanned_status_set')
->label('PUMPSET SCANNED STATUS'),
ExportColumn::make('capacitor_scanned_status')
->label('CAPACITOR SCANNED STATUS'),
ExportColumn::make('scanned_status_set')
->label('SCANNED STATUS SET'),
ExportColumn::make('scanned_status')
->label('SCANNED STATUS'),
ExportColumn::make('panel_box_supplier')
@@ -53,6 +53,7 @@ class InvoiceValidationExporter extends Exporter
->label('UPDATED AT'),
//->dateTimeFormat('d-m-Y H:i:s'),
ExportColumn::make('deleted_at')
->enabledByDefault(false)
->label('DELETED AT'),
//->dateTimeFormat('d-m-Y H:i:s'),
ExportColumn::make('operator_id')

View File

@@ -69,6 +69,7 @@ class StickerMasterExporter extends Exporter
ExportColumn::make('updated_at')
->label('UPDATED AT'),
ExportColumn::make('deleted_at')
->enabledByDefault(false)
->label('DELETED AT'),
];
}

View File

@@ -3,10 +3,13 @@
namespace App\Filament\Imports;
use App\Models\Block;
use App\Models\Plant;
use Filament\Actions\Imports\Exceptions\RowImportFailedException;
use Filament\Actions\Imports\ImportColumn;
use Filament\Actions\Imports\Importer;
use Filament\Actions\Imports\Models\Import;
use Notification;
use Str;
class BlockImporter extends Importer
{
@@ -33,15 +36,23 @@ class BlockImporter extends Importer
public function resolveRecord(): ?Block
{
$plant = \App\Models\Plant::where('name', $this->data['plant'])->first();
$warnMsg = [];
$plant = Plant::where('name', $this->data['plant'])->first();
if (!$plant) {
return null;
$warnMsg[] = "Plant not found";
// $warnMsg[] = "Plant '" . $this->data['plant'] . "' not found";
}
if (Str::length($this->data['name']) < 0) {
$warnMsg[] = "Block name not found";
}
if (!empty($warnMsg)) {
throw new RowImportFailedException(implode(', ', $warnMsg));
}
return Block::updateOrCreate([
'name' => $this->data['name'],
'plant_id' => $plant->id
]
);
'name' => $this->data['name'],
'plant_id' => $plant->id
]);
// return Block::firstOrNew([
// // Update existing records, matching them by `$this->data['column_name']`
// 'email' => $this->data['email'],

View File

@@ -3,9 +3,11 @@
namespace App\Filament\Imports;
use App\Models\Company;
use Filament\Actions\Imports\Exceptions\RowImportFailedException;
use Filament\Actions\Imports\ImportColumn;
use Filament\Actions\Imports\Importer;
use Filament\Actions\Imports\Models\Import;
use Str;
class CompanyImporter extends Importer
{
@@ -25,6 +27,9 @@ class CompanyImporter extends Importer
public function resolveRecord(): ?Company
{
if (Str::length($this->data['name']) < 0) {
throw new RowImportFailedException("Company name not found");
}
return Company::updateOrCreate([
'name' => $this->data['name']
]

View File

@@ -3,9 +3,12 @@
namespace App\Filament\Imports;
use App\Models\Line;
use App\Models\Plant;
use Filament\Actions\Imports\Exceptions\RowImportFailedException;
use Filament\Actions\Imports\ImportColumn;
use Filament\Actions\Imports\Importer;
use Filament\Actions\Imports\Models\Import;
use Str;
class LineImporter extends Importer
{
@@ -38,9 +41,19 @@ class LineImporter extends Importer
public function resolveRecord(): ?Line
{
$plant = \App\Models\Plant::where('name', $this->data['plant'])->first();
$warnMsg = [];
$plant = Plant::where('name', $this->data['plant'])->first();
if (!$plant) {
return null;
$warnMsg[] = "Plant '" . $this->data['plant'] . "' not found";
}
if (Str::length($this->data['name']) < 0) {
$warnMsg[] = "Line name not found";
}
if (Str::length($this->data['type']) < 0) {
$warnMsg[] = "Line type not found";
}
if (!empty($warnMsg)) {
throw new RowImportFailedException(implode(', ', $warnMsg));
}
return Line::updateOrCreate([
'name' => $this->data['name'],

View File

@@ -3,9 +3,12 @@
namespace App\Filament\Imports;
use App\Models\LineStop;
use App\Models\Plant;
use Filament\Actions\Imports\Exceptions\RowImportFailedException;
use Filament\Actions\Imports\ImportColumn;
use Filament\Actions\Imports\Importer;
use Filament\Actions\Imports\Models\Import;
use Str;
class LineStopImporter extends Importer
{
@@ -31,6 +34,16 @@ class LineStopImporter extends Importer
public function resolveRecord(): ?LineStop
{
$warnMsg = [];
if (Str::length($this->data['code']) < 6 || !ctype_alnum($this->data['code'])) {
$warnMsg[] = "Invalid line stop code found";
}
if (Str::length($this->data['reason']) < 5) {
$warnMsg[] = "Invalid line stop reason found";
}
if (!empty($warnMsg)) {
throw new RowImportFailedException(implode(', ', $warnMsg));
}
return LineStop::updateOrCreate([
'code' => $this->data['code']
],

View File

@@ -2,10 +2,13 @@
namespace App\Filament\Imports;
use App\Models\Company;
use App\Models\Plant;
use Filament\Actions\Imports\Exceptions\RowImportFailedException;
use Filament\Actions\Imports\ImportColumn;
use Filament\Actions\Imports\Importer;
use Filament\Actions\Imports\Models\Import;
use Str;
class PlantImporter extends Importer
{
@@ -45,17 +48,33 @@ class PlantImporter extends Importer
public function resolveRecord(): ?Plant
{
$company = \App\Models\Company::where('name', $this->data['company'])->first();
$warnMsg = [];
$company = Company::where('name', $this->data['company'])->first();
if (!$company) {
return null;
$warnMsg[] = "Company name not found";
}
if (Str::length($this->data['name']) < 0) {
$warnMsg[] = "Plant name not found";
}
if (Str::length($this->data['code']) < 4 || !is_numeric($this->data['code']) || !preg_match('/^[1-9]\d{3,}$/', $this->data['code'])) {
$warnMsg[] = "Invalid plant code found";
}
if (Str::length($this->data['address']) < 3) {
$warnMsg[] = "Invalid address found";
}
if (!empty($warnMsg)) {
throw new RowImportFailedException(implode(', ', $warnMsg));
}
$plantCN = \App\Models\Plant::where('code', $this->data['code'])->where('name', $this->data['name'])->first();
$plantCN = Plant::where('code', $this->data['code'])->where('name', $this->data['name'])->first();
if (!$plantCN) {
$plantCode = \App\Models\Plant::where('code', $this->data['code'])->first();
$plantName = \App\Models\Plant::where('name', $this->data['name'])->first();
if ($plantCode || $plantName) {
return null;
$plantCode = Plant::where('code', $this->data['code'])->first();
$plantName = Plant::where('name', $this->data['name'])->first();
if ($plantName) {
throw new RowImportFailedException("Duplicate plant name found");
}
else if ($plantCode) {
throw new RowImportFailedException("Duplicate plant code found");
}
}

View File

@@ -2,10 +2,14 @@
namespace App\Filament\Imports;
use App\Models\Item;
use App\Models\Plant;
use App\Models\StickerMaster;
use Filament\Actions\Imports\Exceptions\RowImportFailedException;
use Filament\Actions\Imports\ImportColumn;
use Filament\Actions\Imports\Importer;
use Filament\Actions\Imports\Models\Import;
use Str;
class StickerMasterImporter extends Importer
{
@@ -178,47 +182,104 @@ class StickerMasterImporter extends Importer
public function resolveRecord(): ?StickerMaster
{
$item = \App\Models\Item::where('code', $this->data['item'])->first();
$plant = \App\Models\Plant::where('name', $this->data['plant'])->first();
if (!$plant || !$item) {
// Optionally handle missing plant/block
return null;
$warnMsg = [];
$plant = Plant::where('name', $this->data['plant'])->first();
if (!$plant) {
$warnMsg[] = "Plant not found";
}
$item = Item::where('code', $this->data['item'])->where('plant_id', $plant->id)->first();
if (!$item) {
$warnMsg[] = "Item code not found";
}
if (Str::length($this->data['serial_number_motor']) > 0 && $this->data['serial_number_motor'] != '1') {
$warnMsg[] = "Serial number motor must be 1 or empty";
}
if (Str::length($this->data['serial_number_pump']) > 0 && $this->data['serial_number_pump'] != '1') {
$warnMsg[] = "Serial number pump must be 1 or empty";
}
if (Str::length($this->data['serial_number_pumpset']) > 0 && $this->data['serial_number_pumpset'] != '1') {
$warnMsg[] = "Serial number pumpset must be 1 or empty";
}
if (Str::length($this->data['pack_slip_motor']) > 0 && $this->data['pack_slip_motor'] != '1') {
$warnMsg[] = "Pack slip motor must be 1 or empty";
}
if (Str::length($this->data['pack_slip_pump']) > 0 && $this->data['pack_slip_pump'] != '1') {
$warnMsg[] = "Pack slip pump must be 1 or empty";
}
if (Str::length($this->data['pack_slip_pumpset']) > 0 && $this->data['pack_slip_pumpset'] != '1') {
$warnMsg[] = "Pack slip pumpset must be 1 or empty";
}
if (Str::length($this->data['name_plate_motor']) > 0 && $this->data['name_plate_motor'] != '1') {
$warnMsg[] = "Name plate motor must be 1 or empty";
}
if (Str::length($this->data['name_plate_pump']) > 0 && $this->data['name_plate_pump'] != '1') {
$warnMsg[] = "Name plate pump must be 1 or empty";
}
if (Str::length($this->data['name_plate_pumpset']) > 0 && $this->data['name_plate_pumpset'] != '1') {
$warnMsg[] = "Name plate pumpset must be 1 or empty";
}
if (Str::length($this->data['tube_sticker_motor']) > 0 && $this->data['tube_sticker_motor'] != '1') {
$warnMsg[] = "Tube sticker motor must be 1 or empty";
}
if (Str::length($this->data['tube_sticker_pump']) > 0 && $this->data['tube_sticker_pump'] != '1') {
$warnMsg[] = "Tube sticker pump must be 1 or empty";
}
if (Str::length($this->data['tube_sticker_pumpset']) > 0 && $this->data['tube_sticker_pumpset'] != '1') {
$warnMsg[] = "Tube sticker pumpset must be 1 or empty";
}
if (Str::length($this->data['warranty_card']) > 0 && $this->data['warranty_card'] != '1') {
$warnMsg[] = "Warranty card must be 1 or empty";
}
if (Str::length($this->data['panel_box_code']) > 0 && (Str::length($this->data['panel_box_code']) < 6 || !ctype_alnum($this->data['panel_box_code']))) {
$warnMsg[] = "Invalid panel box code found";
}
if (!is_numeric($this->data['load_rate']) || $this->data['load_rate'] < 0) {
$warnMsg[] = "Load rate must be greater than or equal to 0";
}
if (Str::length($this->data['bundle_quantity']) > 0 && (!is_numeric($this->data['bundle_quantity']) || $this->data['bundle_quantity'] <= 1)) {
$warnMsg[] = "Bundle quantity must be greater than or equal to '2' or empty";
}
if (Str::length($this->data['material_type']) > 0 && $this->data['material_type'] != '1' && $this->data['material_type'] != '2' && $this->data['material_type'] != '3') { //($this->data['material_type'] != null) &&
$warnMsg[] = "Material type must be 1 or 2 or 3 or empty";
}
if (!empty($warnMsg)) {
throw new RowImportFailedException(implode(', ', $warnMsg));
}
return StickerMaster::updateOrCreate([
'item_id' => $item->id,
'plant_id' => $plant->id
],
[
'serial_number_motor' => $this->data['serial_number_motor'],
'serial_number_pump' => $this->data['serial_number_pump'],
'serial_number_pumpset' => $this->data['serial_number_pumpset'],
'pack_slip_motor' => $this->data['pack_slip_motor'],
'pack_slip_pump' => $this->data['pack_slip_pump'],
'pack_slip_pumpset' => $this->data['pack_slip_pumpset'],
'name_plate_motor' => $this->data['name_plate_motor'],
'name_plate_pump' => $this->data['name_plate_pump'],
'name_plate_pumpset' => $this->data['name_plate_pumpset'],
'tube_sticker_motor' => $this->data['tube_sticker_motor'],
'tube_sticker_pump' => $this->data['tube_sticker_pump'],
'tube_sticker_pumpset' => $this->data['tube_sticker_pumpset'],
'warranty_card' => $this->data['warranty_card'],
'part_validation1' => $this->data['part_validation1'],
'part_validation2' => $this->data['part_validation2'],
'part_validation3' => $this->data['part_validation3'],
'part_validation4' => $this->data['part_validation4'],
'part_validation5' => $this->data['part_validation5'],
'panel_box_code' => $this->data['panel_box_code'],
'load_rate' => $this->data['load_rate'],
'bundle_quantity' => $this->data['bundle_quantity'],
'material_type' => $this->data['material_type']
]
);
'item_id' => $item->id,
'plant_id' => $plant->id
],
[
'serial_number_motor' => $this->data['serial_number_motor'],
'serial_number_pump' => $this->data['serial_number_pump'],
'serial_number_pumpset' => $this->data['serial_number_pumpset'],
'pack_slip_motor' => $this->data['pack_slip_motor'],
'pack_slip_pump' => $this->data['pack_slip_pump'],
'pack_slip_pumpset' => $this->data['pack_slip_pumpset'],
'name_plate_motor' => $this->data['name_plate_motor'],
'name_plate_pump' => $this->data['name_plate_pump'],
'name_plate_pumpset' => $this->data['name_plate_pumpset'],
'tube_sticker_motor' => $this->data['tube_sticker_motor'],
'tube_sticker_pump' => $this->data['tube_sticker_pump'],
'tube_sticker_pumpset' => $this->data['tube_sticker_pumpset'],
'warranty_card' => $this->data['warranty_card'],
'part_validation1' => $this->data['part_validation1'],
'part_validation2' => $this->data['part_validation2'],
'part_validation3' => $this->data['part_validation3'],
'part_validation4' => $this->data['part_validation4'],
'part_validation5' => $this->data['part_validation5'],
'panel_box_code' => $this->data['panel_box_code'],
'load_rate' => $this->data['load_rate'],
'bundle_quantity' => $this->data['bundle_quantity'],
'material_type' => $this->data['material_type']
]);
// return StickerMaster::firstOrNew([
// // Update existing records, matching them by `$this->data['column_name']`
// 'email' => $this->data['email'],
// ]);
return new StickerMaster();
// return new StickerMaster();
}
public static function getCompletedNotificationBody(Import $import): string

View File

@@ -6,6 +6,7 @@ use AlperenErsoy\FilamentExport\Actions\FilamentExportBulkAction;
use App\Filament\Exports\InvoiceValidationExporter;
use App\Filament\Resources\InvoiceValidationResource\Pages;
use App\Models\InvoiceValidation;
use App\Models\Item;
use App\Models\Plant;
use App\Models\StickerMaster;
use Auth;
@@ -14,6 +15,7 @@ use Filament\Actions\CreateAction;
use Filament\Facades\Filament;
use Filament\Forms;
use Filament\Forms\Components\Actions\Action as ActionsAction;
use Filament\Forms\Components\DateTimePicker;
use Filament\Forms\Components\FileUpload;
use Filament\Forms\Components\Section;
use Filament\Forms\Components\Select;
@@ -30,6 +32,7 @@ use Filament\Forms\Components\View;
use Filament\Notifications\Notification;
use Filament\Tables\Actions\Action;
use Filament\Tables\Actions\ExportAction;
use Filament\Tables\Filters\Filter;
use Illuminate\Support\Facades\Storage;
use Maatwebsite\Excel\Facades\Excel;
use Livewire\Livewire;
@@ -193,6 +196,7 @@ class InvoiceValidationResource extends Resource
public static function table(Table $table): Table
{
return $table
->query(InvoiceValidation::query())
->columns([
Tables\Columns\TextColumn::make('id')
->label('ID')
@@ -200,16 +204,13 @@ class InvoiceValidationResource extends Resource
->sortable(),
Tables\Columns\TextColumn::make('invoice_number')
->label('Invoice Number')
->sortable()
->searchable(),
->sortable(), //->searchable()
Tables\Columns\TextColumn::make('stickerMaster.item.code')
->label('Material Code')
->sortable()
->searchable(),
->sortable(), //->searchable()
Tables\Columns\TextColumn::make('serial_number')
->label('Serial Number')
->sortable()
->searchable(),
->sortable(), //->searchable()
Tables\Columns\TextColumn::make('motor_scanned_status')
->label('Motor Scanned Status')
->sortable(),
@@ -267,7 +268,6 @@ class InvoiceValidationResource extends Resource
->toggleable(isToggledHiddenByDefault: true),
])
->headerActions([
// Action::make('plant_id')
@@ -899,7 +899,122 @@ class InvoiceValidationResource extends Resource
->filters([
Tables\Filters\TrashedFilter::make(),
Filter::make('advanced_filters')
->label('Advanced Filters')
->form([
Select::make('Plant')
->label('Select Plant')
->nullable()
->options(function () {
return Plant::pluck('name', 'id');
})
->reactive()
->afterStateUpdated(function ($state, callable $set, callable $get): void {
$set('sticker_master_id', null);
}),
TextInput::make('invoice_number')
->label('Invoice Number')
->placeholder(placeholder: 'Enter Invoice Number'),
TextInput::make('serial_number')
->label('Serial Number')
->placeholder(placeholder: 'Enter Serial Number'),
Select::make('sticker_master_id')
->label('Search by Item Code')
->nullable()
->options(function (callable $get) {
$pId = $get('Plant');
// if (empty($pId)) {
// return [];
// }
return Item::whereHas('stickerMasters', function ($query) use ($pId) {
if ($pId) {
$query->where('plant_id', $pId);
}
$query->whereHas('invoiceValidations');
})->pluck('code', 'id');
})
->searchable()
->reactive(),
DateTimePicker::make(name: 'created_from')
->label('Created From')
->placeholder(placeholder: 'Select From DateTime')
->reactive()
->native(false),
DateTimePicker::make('created_to')
->label('Created To')
->placeholder(placeholder: 'Select To DateTime')
->reactive()
->native(false),
])
->query(function ($query, array $data) {
// Hide all records initially if no filters are applied
if (empty($data['Plant']) && empty($data['invoice_number']) && empty($data['serial_number']) && empty($data['created_from']) && empty($data['created_to']) && empty($data['sticker_master_id'])) {
return $query->whereRaw('1 = 0');
}
if (!empty($data['Plant'])) { //$plant = $data['Plant'] ?? null
$query->where('plant_id', $data['Plant']);
}
if (!empty($data['invoice_number'])) {
$query->where('invoice_number', 'like', '%' . $data['invoice_number'] . '%');
}
if (!empty($data['serial_number'])) {
$query->where('serial_number', 'like', '%' . $data['serial_number'] . '%');
}
if (!empty($data['created_from'])) {
$query->where('created_at', '>=', $data['created_from']);
}
if (!empty($data['created_to'])) {
$query->where('created_at', '<=', $data['created_to']);
}
if (!empty($data['sticker_master_id'])) {
$stickerMasterIds = StickerMaster::where('item_id', $data['sticker_master_id'])
->pluck('id')
->toArray();
if (!empty($stickerMasterIds)) {
$query->whereIn('sticker_master_id', $stickerMasterIds);
}
}
})
->indicateUsing(function (array $data) {
$indicators = [];
if (!empty($data['Plant'])) {
$indicators[] = 'Plant: ' . Plant::where('id', $data['Plant'])->value('name');
}
if (!empty($data['invoice_number'])) {
$indicators[] = 'Invoice Number: ' . $data['invoice_number'];
}
if (!empty($data['serial_number'])) {
$indicators[] = 'Serial Number: ' . $data['serial_number'];
}
if (!empty($data['created_from'])) {
$indicators[] = 'From: ' . $data['created_from'];
}
if (!empty($data['created_to'])) {
$indicators[] = 'To: ' . $data['created_to'];
}
if (!empty($data['sticker_master_id'])) {
$itemCode = Item::find($data['sticker_master_id'])->code ?? 'Unknown';
$indicators[] = 'Item Code: ' . $itemCode;
}
return $indicators;
})
])
->filtersFormMaxHeight('280px')
->actions([
Tables\Actions\ViewAction::make(),
Tables\Actions\EditAction::make(),

View File

@@ -87,6 +87,7 @@ class CreateInvoiceValidation extends CreateRecord
Notification::make()
->title("New invoice detected.")
->info()
->seconds(1)
->send();
$this->form->fill([
@@ -121,6 +122,7 @@ class CreateInvoiceValidation extends CreateRecord
->title("Completed: Material Invoice")
->body("Material invoice '$invoiceNumber' completed the scanning process.<br>Scan the next 'Material Invoice' to proceed!")
->warning()
->seconds(2)
->send();
$filename = $invoiceNumber . '.xlsx';
@@ -147,7 +149,7 @@ class CreateInvoiceValidation extends CreateRecord
if($updateStatus === '1')
{
//dd('Material invoice update in progress...');
//'Material invoice update in progress...';
$filename = $invoiceNumber . '.xlsx';
$directory = 'uploads/temp';
$disk = Storage::disk('local');
@@ -165,6 +167,7 @@ class CreateInvoiceValidation extends CreateRecord
->title('Records Not Found')
->body("Import the valid updated 'Material Invoice' file to proceed..!")
->danger()
->seconds(2)
->send();
if ($disk->exists($filePath)) {
@@ -227,6 +230,7 @@ class CreateInvoiceValidation extends CreateRecord
->title('Invalid Material Invoice')
->danger() // This makes the notification red to indicate an error
->body('Uploaded Excel sheet is empty or<br>contains no valid data.')
->seconds(2)
->send();
if ($disk->exists($filePath)) {
$disk->delete($filePath);
@@ -241,6 +245,7 @@ class CreateInvoiceValidation extends CreateRecord
->title('Invalid: Item Codes')
->body('The following item codes should contain minimum 6 digit alpha numeric values:<br>' . implode(', ', $uniqueInvalidCodes))
->danger()
->seconds(2)
->send();
if ($disk->exists($filePath)) {
@@ -256,6 +261,7 @@ class CreateInvoiceValidation extends CreateRecord
->title('Missing Material Quantity')
->body("The following item codes doesn't have valid material quantity:<br>" . implode(', ', $uniqueMissingQuanCodes))
->danger()
->seconds(2)
->send();
if ($disk->exists($filePath)) {
@@ -271,6 +277,7 @@ class CreateInvoiceValidation extends CreateRecord
->title('Invalid Material Quantity')
->body("The following item codes doesn't have valid material quantity:<br>" . implode(', ', $uniqueInvalidMatQuan))
->danger()
->seconds(2)
->send();
if ($disk->exists($filePath)) {
@@ -302,6 +309,7 @@ class CreateInvoiceValidation extends CreateRecord
->title('Unknown: Item Codes')
->body($message)
->danger()
->seconds(2)
->send();
if ($disk->exists($filePath)) {
@@ -331,6 +339,7 @@ class CreateInvoiceValidation extends CreateRecord
->title('Unknown: Item Codes')
->body($message)
->danger()
->seconds(2)
->send();
if ($disk->exists($filePath)) {
@@ -355,6 +364,7 @@ class CreateInvoiceValidation extends CreateRecord
->title('Invalid: Item Codes')
->body($message)
->danger()
->seconds(2)
->send();
if ($disk->exists($filePath)) {
@@ -419,6 +429,7 @@ class CreateInvoiceValidation extends CreateRecord
->title('Invalid Bundle Quantity')
->body("$message<br>$codeList")
->danger()
->seconds(2)
->send();
};
@@ -663,12 +674,14 @@ class CreateInvoiceValidation extends CreateRecord
Notification::make()
->title("Material invoice successfully updatad.")
->success()
->seconds(1)
->send();
Notification::make()
->title("Start the scanning process!")
->body("'$inserted' new material invoice records were inserted.")
->info()
// ->success()
->seconds(1)
->send();
// Update total quantity in the form
@@ -705,6 +718,7 @@ class CreateInvoiceValidation extends CreateRecord
->title("Update Failed: Material Invoice")
->body("No new records were inserted for Material Invoice : '$invoiceNumber'.")
->danger()
->seconds(2)
->send();
$totalQuantity = InvoiceValidation::where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->count();
@@ -732,6 +746,7 @@ class CreateInvoiceValidation extends CreateRecord
->title('Updated Invoice Not Found')
->body("Import the updated 'Material Invoice' file to proceed..!")
->danger()
->seconds(2)
->send();
$this->form->fill([
@@ -766,6 +781,7 @@ class CreateInvoiceValidation extends CreateRecord
->title("Completed: Serial Invoice")
->body("Serial invoice '$invoiceNumber' completed the scanning process.<br>Scan the next 'Serial Invoice' to proceed.!")
->warning()
->seconds(2)
->send();
$filename = $invoiceNumber . '.xlsx';
@@ -784,6 +800,7 @@ class CreateInvoiceValidation extends CreateRecord
Notification::make()
->title("Start the scanning process!")
->info()
->seconds(1)
->send();
$this->dispatch('refreshInvoiceData', invoiceNumber: $invoiceNumber, plantId: $plantId);
@@ -799,7 +816,7 @@ class CreateInvoiceValidation extends CreateRecord
if ($fullPath && file_exists($fullPath))
{
// /home/iot-dev/projects/pds/storage/app/private/uploads/temp/3RA0018735.xlsx
// dd('Serial invoice update in progress...');
// 'Serial invoice update in progress...'
// Now you can read/process the file here
$rows = Excel::toArray(null, $fullPath)[0];
@@ -810,6 +827,7 @@ class CreateInvoiceValidation extends CreateRecord
->title('Records Not Found')
->body("Import the valid updated 'Serial Invoice' file to proceed..!")
->danger()
->seconds(2)
->send();
if ($disk->exists($filePath)) {
@@ -880,6 +898,7 @@ class CreateInvoiceValidation extends CreateRecord
->title('Invalid Serial Invoice')
->danger() // This makes the notification red to indicate an error
->body('Uploaded excel sheet is empty or<br>contains no valid data.')
->seconds(2)
->send();
if ($disk->exists($filePath)) {
@@ -895,6 +914,7 @@ class CreateInvoiceValidation extends CreateRecord
->title('Invalid: Item Codes')
->body('The following item codes should contain minimum 6 digit alpha numeric values:<br>' . implode(', ', $uniqueInvalidCodes))
->danger()
->seconds(2)
->send();
if ($disk->exists($filePath)) {
@@ -926,6 +946,7 @@ class CreateInvoiceValidation extends CreateRecord
->title('Unknown: Item Codes')
->body($message)
->danger()
->seconds(2)
->send();
if ($disk->exists($filePath)) {
@@ -955,6 +976,7 @@ class CreateInvoiceValidation extends CreateRecord
->title('Unknown: Item Codes')
->body($message)
->danger()
->seconds(2)
->send();
if ($disk->exists($filePath)) {
@@ -978,6 +1000,7 @@ class CreateInvoiceValidation extends CreateRecord
->title('Invalid: Item Codes')
->body($message)
->danger()
->seconds(2)
->send();
if ($disk->exists($filePath)) {
@@ -1001,6 +1024,7 @@ class CreateInvoiceValidation extends CreateRecord
->title('Invalid: Item Codes')
->body($message)
->danger()
->seconds(2)
->send();
if ($disk->exists($filePath)) {
@@ -1016,6 +1040,7 @@ class CreateInvoiceValidation extends CreateRecord
->title('Missing Serial Numbers')
->body("The following item codes doesn't have valid serial number:<br>" . implode(', ', $uniqueMissingSerials))
->danger()
->seconds(2)
->send();
if ($disk->exists($filePath)) {
@@ -1031,6 +1056,7 @@ class CreateInvoiceValidation extends CreateRecord
->title('Invalid Serial Numbers')
->body('The following serial numbers should contain minimum 9 digit alpha numeric values:<br>' . implode(', ', $uniqueInvalidSerCodes))
->danger()
->seconds(2)
->send();
if ($disk->exists($filePath)) {
@@ -1046,6 +1072,7 @@ class CreateInvoiceValidation extends CreateRecord
->title('Duplicate Serial Numbers')
->body('The following serial numbers are already exist in invoice excel:<br>' . implode(', ', $uniqueDupSerCodes))
->danger()
->seconds(2)
->send();
if ($disk->exists($filePath)) {
@@ -1116,6 +1143,7 @@ class CreateInvoiceValidation extends CreateRecord
Notification::make()
->title("Serial invoice successfully updated.")
->success()
->seconds(1)
->send();
Notification::make()
@@ -1123,6 +1151,7 @@ class CreateInvoiceValidation extends CreateRecord
->body("'$inserted' new serial invoice records were inserted.")
->info()
// ->success()
->seconds(1)
->send();
// Update total quantity in the form
@@ -1160,6 +1189,7 @@ class CreateInvoiceValidation extends CreateRecord
->title("Update Failed: Serial Invoice")
->body("No new records were inserted for Serial Invoice : '$invoiceNumber'.")
->danger()
->seconds(2)
->send();
$totalQuantity = InvoiceValidation::where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->count();
@@ -1186,6 +1216,7 @@ class CreateInvoiceValidation extends CreateRecord
->title('Updated Invoice Not Found')
->body("Import the updated 'Serial Invoice' file to proceed..!")
->danger()
->seconds(2)
->send();
$this->form->fill([
@@ -1217,12 +1248,14 @@ class CreateInvoiceValidation extends CreateRecord
// Notification::make()
// ->title('File exists.')
// ->success()
// ->seconds(2)
// ->send();
} else {
Notification::make()
->title('Invoice Not Found')
->body("Import the scanned 'Invoice' file to proceed..!")
->danger()
->seconds(2)
->send();
$this->form->fill([
@@ -1241,6 +1274,7 @@ class CreateInvoiceValidation extends CreateRecord
Notification::make()
->title('Invoice file doesn\'t exist.')
->danger()
->seconds(2)
->send();
return;
}
@@ -1253,6 +1287,7 @@ class CreateInvoiceValidation extends CreateRecord
Notification::make()
->title("Uploaded file name does not match the invoice number.")
->danger()
->seconds(2)
->send();
return;
}
@@ -1280,6 +1315,7 @@ class CreateInvoiceValidation extends CreateRecord
->title('Records Not Found')
->body("Import the valid 'Invoice' file to proceed..!")
->danger()
->seconds(2)
->send();
if ($disk->exists($filePath)) {
@@ -1384,6 +1420,7 @@ class CreateInvoiceValidation extends CreateRecord
->title('Invalid Material Invoice')
->danger() // This makes the notification red to indicate an error
->body('Uploaded Excel sheet is empty or<br>contains no valid data.')
->seconds(2)
->send();
if ($disk->exists($filePath)) {
$disk->delete($filePath);
@@ -1398,6 +1435,7 @@ class CreateInvoiceValidation extends CreateRecord
->title('Invalid: Item Codes')
->body('The following item codes should contain minimum 6 digit alpha numeric values:<br>' . implode(', ', $uniqueInvalidCodes))
->danger()
->seconds(2)
->send();
if ($disk->exists($filePath)) {
@@ -1413,6 +1451,7 @@ class CreateInvoiceValidation extends CreateRecord
->title('Missing Material Quantity')
->body("The following item codes doesn't have valid material quantity:<br>" . implode(', ', $uniqueMissingQuanCodes))
->danger()
->seconds(2)
->send();
if ($disk->exists($filePath)) {
@@ -1428,6 +1467,7 @@ class CreateInvoiceValidation extends CreateRecord
->title('Invalid Material Quantity')
->body("The following item codes doesn't have valid material quantity:<br>" . implode(', ', $uniqueInvalidMatQuan))
->danger()
->seconds(2)
->send();
if ($disk->exists($filePath)) {
@@ -1459,6 +1499,7 @@ class CreateInvoiceValidation extends CreateRecord
->title('Unknown: Item Codes')
->body($message)
->danger()
->seconds(2)
->send();
if ($disk->exists($filePath)) {
@@ -1488,6 +1529,7 @@ class CreateInvoiceValidation extends CreateRecord
->title('Unknown: Item Codes')
->body($message)
->danger()
->seconds(2)
->send();
if ($disk->exists($filePath)) {
@@ -1511,6 +1553,7 @@ class CreateInvoiceValidation extends CreateRecord
->title('Invalid: Item Codes')
->body($message)
->danger()
->seconds(2)
->send();
if ($disk->exists($filePath)) {
@@ -1569,6 +1612,7 @@ class CreateInvoiceValidation extends CreateRecord
->title('Invalid Bundle Quantity')
->body("$message<br>$codeList")
->danger()
->seconds(2)
->send();
};
@@ -1701,6 +1745,7 @@ class CreateInvoiceValidation extends CreateRecord
->body("'$inserted' material invoice records were inserted.")
->info()
// ->success()
->seconds(1)
->send();
// Update total quantity in the form
@@ -1738,6 +1783,7 @@ class CreateInvoiceValidation extends CreateRecord
->title("Import Failed: Material Invoice")
->body("No new records were inserted for Material Invoice: '$invoiceNumber'.")
->danger()
->seconds(2)
->send();
$totalQuantity = InvoiceValidation::where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->count();
@@ -1818,6 +1864,7 @@ class CreateInvoiceValidation extends CreateRecord
->title('Invalid Serial Invoice')
->danger() // This makes the notification red to indicate an error
->body('Uploaded excel sheet is empty or<br>contains no valid data.')
->seconds(2)
->send();
if ($disk->exists($filePath)) {
@@ -1833,6 +1880,7 @@ class CreateInvoiceValidation extends CreateRecord
->title('Invalid: Item Codes')
->body('The following item codes should contain minimum 6 digit alpha numeric values:<br>' . implode(', ', $uniqueInvalidCodes))
->danger()
->seconds(2)
->send();
if ($disk->exists($filePath)) {
@@ -1874,6 +1922,7 @@ class CreateInvoiceValidation extends CreateRecord
->title('Unknown: Item Codes')
->body($message)
->danger()
->seconds(2)
->send();
if ($disk->exists($filePath)) {
@@ -1903,6 +1952,7 @@ class CreateInvoiceValidation extends CreateRecord
->title('Unknown: Item Codes')
->body($message)
->danger()
->seconds(2)
->send();
if ($disk->exists($filePath)) {
@@ -1926,6 +1976,7 @@ class CreateInvoiceValidation extends CreateRecord
->title('Invalid: Item Codes')
->body($message)
->danger()
->seconds(2)
->send();
if ($disk->exists($filePath)) {
@@ -1949,6 +2000,7 @@ class CreateInvoiceValidation extends CreateRecord
->title('Invalid: Item Codes')
->body($message)
->danger()
->seconds(2)
->send();
if ($disk->exists($filePath)) {
@@ -1964,6 +2016,7 @@ class CreateInvoiceValidation extends CreateRecord
->title('Missing Serial Numbers')
->body("The following item codes doesn't have valid serial number:<br>" . implode(', ', $uniqueMissingSerials))
->danger()
->seconds(2)
->send();
if ($disk->exists($filePath)) {
@@ -1979,6 +2032,7 @@ class CreateInvoiceValidation extends CreateRecord
->title('Invalid Serial Numbers')
->body('The following serial numbers should contain minimum 9 digit alpha numeric values:<br>' . implode(', ', $uniqueInvalidSerCodes))
->danger()
->seconds(2)
->send();
if ($disk->exists($filePath)) {
@@ -1994,6 +2048,7 @@ class CreateInvoiceValidation extends CreateRecord
->title('Duplicate Serial Numbers')
->body('The following serial numbers are already exist in invoice excel:<br>' . implode(', ', $uniqueDupSerCodes))
->danger()
->seconds(2)
->send();
if ($disk->exists($filePath)) {
@@ -2010,6 +2065,7 @@ class CreateInvoiceValidation extends CreateRecord
->title('Duplicate Serial Numbers')
->body('The following serial numbers are already exist in database:<br>' . implode(', ', $existingSerialNumbers))
->danger()
->seconds(2)
->send();
if ($disk->exists($filePath)) {
@@ -2053,6 +2109,7 @@ class CreateInvoiceValidation extends CreateRecord
->body("'$inserted' serial invoice records were inserted.")
->info()
// ->success()
->seconds(1)
->send();
// Update total quantity in the form
@@ -2090,6 +2147,7 @@ class CreateInvoiceValidation extends CreateRecord
->title("Import Failed: Serial Invoice")
->body("No new records were inserted for Serial Invoice : '$invoiceNumber'.")
->danger()
->seconds(2)
->send();
$totalQuantity = InvoiceValidation::where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->count();
@@ -2116,6 +2174,7 @@ class CreateInvoiceValidation extends CreateRecord
->title('Invoice Type Not Found')
->body("Import the valid 'Invoice' file to proceed..!")
->danger()
->seconds(2)
->send();
if ($disk->exists($filePath)) {
@@ -2157,6 +2216,7 @@ class CreateInvoiceValidation extends CreateRecord
public function processSerialNumber($serNo)
{
$serNo = trim($serNo);
$user = Filament::auth()->user();
$operatorName = $user->name;
@@ -2177,6 +2237,7 @@ class CreateInvoiceValidation extends CreateRecord
->title('Invoice Not Found')
->body("Invoice file '$invoiceNumber' doesn't exist.<br>Scan the valid 'Invoice' file to proceed!")
->danger()
->seconds(2)
->send();
$this->form->fill([
@@ -2200,6 +2261,7 @@ class CreateInvoiceValidation extends CreateRecord
->title('Completed: Material Invoice')
->body("Material invoice '$invoiceNumber' completed the scanning process.<br>Scan the next 'Material Invoice' to proceed!")
->warning()
->seconds(2)
->send();
$this->form->fill([
@@ -2250,6 +2312,7 @@ class CreateInvoiceValidation extends CreateRecord
$batchNumber = $matches['batch_number'];
$serialNumber = $matches['batch_id'] . '-' . $matches['batch_count'];
$curScanQty = $matches['batch_quantity'];
$serNo = null;
if(empty($matches['batch_id']) || !$matches['batch_id'])
{
@@ -2257,6 +2320,7 @@ class CreateInvoiceValidation extends CreateRecord
->danger()
->title('Invalid Material QR Format')
->body('Scan valid Material QR code proceed!<br>Sample formats are:<br>123456|12345|12345678|1/1 (or)<br>123456|12345|12345678|1 (or)<br>123456|12345678-1')
->seconds(2)
->send();
$this->form->fill([
@@ -2275,6 +2339,7 @@ class CreateInvoiceValidation extends CreateRecord
->danger()
->title('Invalid Material QR Format')
->body('Scan valid Material QR code proceed!<br>Sample formats are:<br>123456|12345|12345678|1/1 (or)<br>123456|12345|12345678|1 (or)<br>123456|12345678-1')
->seconds(2)
->send();
$this->form->fill([
@@ -2293,6 +2358,7 @@ class CreateInvoiceValidation extends CreateRecord
->danger()
->title('Invalid Material QR Format')
->body('Scan valid Material QR code proceed!<br>Sample formats are:<br>123456|12345|12345678|1/1 (or)<br>123456|12345|12345678|1 (or)<br>123456|12345678-1')
->seconds(2)
->send();
$this->form->fill([
@@ -2310,6 +2376,7 @@ class CreateInvoiceValidation extends CreateRecord
$this->currentItemCode = $itemCode;
$batchNumber = $matches['batch_number'];
$serialNumber = $matches['batch_id'] . '-' . $matches['batch_count'];
$serNo = null;
if(empty($matches['batch_id']) || !$matches['batch_id'])
{
@@ -2317,6 +2384,7 @@ class CreateInvoiceValidation extends CreateRecord
->danger()
->title('Invalid Material QR Format')
->body('Scan valid Material QR code proceed!<br>Sample formats are:<br>123456|12345|12345678|1/1 (or)<br>123456|12345|12345678|1 (or)<br>123456|12345678-1')
->seconds(2)
->send();
$this->form->fill([
@@ -2335,6 +2403,7 @@ class CreateInvoiceValidation extends CreateRecord
->danger()
->title('Invalid Material QR Format')
->body('Scan valid Material QR code proceed!<br>Sample formats are:<br>123456|12345|12345678|1/1 (or)<br>123456|12345|12345678|1 (or)<br>123456|12345678-1')
->seconds(2)
->send();
$this->form->fill([
@@ -2352,6 +2421,7 @@ class CreateInvoiceValidation extends CreateRecord
$this->currentItemCode = $itemCode;
$batchNumber = null; // batch_number not present in this pattern
$serialNumber = $matches['batch_id'] . '-' . $matches['batch_count'];
$serNo = null;
if(empty($matches['batch_id']) || !$matches['batch_id'])
{
@@ -2359,6 +2429,7 @@ class CreateInvoiceValidation extends CreateRecord
->danger()
->title('Invalid Material QR Format')
->body('Scan valid Material QR code proceed!<br>Sample formats are:<br>123456|12345|12345678|1/1 (or)<br>123456|12345|12345678|1 (or)<br>123456|12345678-1')
->seconds(2)
->send();
$this->form->fill([
@@ -2377,6 +2448,7 @@ class CreateInvoiceValidation extends CreateRecord
->danger()
->title('Invalid Material QR Format')
->body('Scan valid Material QR code proceed!<br>Sample formats are:<br>123456|12345|12345678|1/1 (or)<br>123456|12345|12345678|1 (or)<br>123456|12345678-1')
->seconds(2)
->send();
$this->form->fill([
@@ -2400,6 +2472,7 @@ class CreateInvoiceValidation extends CreateRecord
->danger()
->title('Invalid Material QR Format')
->body('Scan valid Material QR code proceed!<br>Sample formats are:<br>123456|12345|12345678|1/1 (or)<br>123456|12345|12345678|1 (or)<br>123456|12345678-1')
->seconds(1)
->send();
$this->form->fill([
@@ -2423,6 +2496,7 @@ class CreateInvoiceValidation extends CreateRecord
->title('Unknown: Item Code')
->body("Item code '$itemCode' not found in database.")
->danger()
->seconds(2)
->send();
$this->form->fill([
@@ -2445,6 +2519,7 @@ class CreateInvoiceValidation extends CreateRecord
->title('Unknown: Item Code')
->body("Item code '$itemCode' not found in database for choosed plant.")
->danger()
->seconds(2)
->send();
$this->form->fill([
@@ -2466,6 +2541,7 @@ class CreateInvoiceValidation extends CreateRecord
->title('Invalid: Item Code')
->body("Item code '$itemCode' doesn't have a valid material type.")
->danger()
->seconds(2)
->send();
$this->form->fill([
@@ -2492,6 +2568,7 @@ class CreateInvoiceValidation extends CreateRecord
->title('Unknown: Item Code')
->body("Item code '$itemCode' doesn't exist in invoice.")
->danger()
->seconds(2)
->send();
$this->form->fill([
@@ -2517,6 +2594,7 @@ class CreateInvoiceValidation extends CreateRecord
->title('Item Code Limit Exceeds')
->body("Scanned item code '$itemCode' already reached its scanning quantity for the invoice '$invoiceNumber'.")
->danger()
->seconds(2)
->send();
$this->form->fill([
@@ -2537,6 +2615,7 @@ class CreateInvoiceValidation extends CreateRecord
->title('Duplicate: Material QR')
->body("Scanned 'Material QR' already completed the scanning process.")
->danger()
->seconds(2)
->send();
$this->form->fill([
@@ -2552,6 +2631,26 @@ class CreateInvoiceValidation extends CreateRecord
if($hasQuanTyp)
{
if(!is_numeric($curScanQty))
{
Notification::make()
->danger()
->title('Invalid Quantity Material QR Format')
->body('Scan valid Quantity Material QR code proceed!<br>Ex:123456|12345|12345678|1/1')
->seconds(2)
->send();
$this->form->fill([
'plant_id' => $plantId,
'invoice_number' => $invoiceNumber,
'serial_number' => null,
'total_quantity' => $totQuan,
'update_invoice' => false,
'scanned_quantity'=> $scanMQuan,
]);
return;
}
$createdDt = $record->created_at;
$stickMasterId = $record->sticker_master_id;
$curExistQty = $record->quantity;
@@ -2599,6 +2698,7 @@ class CreateInvoiceValidation extends CreateRecord
->title('Item Code Limit Exceeds')
->body("Scanned item code '$itemCode' has '$curScanQty' quantity.<br>But, '$curExistQty' quantity only available for the invoice '$invoiceNumber'.")
->danger()
->seconds(2)
->send();
$this->form->fill([
@@ -2614,6 +2714,32 @@ class CreateInvoiceValidation extends CreateRecord
}
else
{
if(str_contains($serialNumber, '|'))
{
$itemCode = null;
$this->currentItemCode = '';
$batchNumber = null;
$serNo = null;
$serialNumber = null;
Notification::make()
->title('Duplicate: Material QR')
->body("Scanned 'Material QR' already completed the scanning process.")
->danger()
->seconds(2)
->send();
$this->form->fill([
'plant_id' => $plantId,
'invoice_number' => $invoiceNumber,
'serial_number' => null,
'total_quantity' => $totQuan,
'update_invoice' => false,
'scanned_quantity'=> $scanMQuan,
]);
return;
}
$record->serial_number = $serialNumber;
// if($batchNumber && !empty($batchNumber)) {}
$record->batch_number = $batchNumber;
@@ -2626,6 +2752,7 @@ class CreateInvoiceValidation extends CreateRecord
->title('Success: Material QR')
->body("'Material QR' scanned status updated, Scan next QR.")
->success()
->seconds(2)
->send();
$totQuan = InvoiceValidation::where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->count();
@@ -2638,6 +2765,7 @@ class CreateInvoiceValidation extends CreateRecord
->title('Completed: Material Invoice')
->body("Material invoice '$invoiceNumber' completed the scanning process.<br>Scan the next 'Material Invoice' to proceed!")
->success()
->seconds(2)
->send();
$this->form->fill([
@@ -2682,6 +2810,7 @@ class CreateInvoiceValidation extends CreateRecord
->title('Completed: Serial Invoice')
->body("Serial invoice '$invoiceNumber' completed the scanning process.<br>Scan the next 'Serial Invoice' to proceed!")
->warning()
->seconds(2)
->send();
$this->form->fill([
@@ -2719,11 +2848,12 @@ class CreateInvoiceValidation extends CreateRecord
$this->dispatch( 'refreshInvoiceData', invoiceNumber: $invoiceNumber, plantId: $plantId);
}
if (!preg_match('/^([a-zA-Z0-9]{6,})\|([a-zA-Z0-9]{8,})(?:\/[MmPpCc])?$/', $serNo, $matches)) {
if (!preg_match('/^([a-zA-Z0-9]{6,})\|([1-9][a-zA-Z0-9]{8,})(?:\/[MmPpCc])?$/', $serNo, $matches)) {
Notification::make()
->danger()
->title('Invalid Serial QR Format')
->body('Scan valid Serial QR code proceed!<br>Sample formats are:<br>123456|1234567890123/M (or)<br>123456|1234567890123/P (or)<br>123456|1234567890123/C (or)<br>123456|1234567890123')
->seconds(2)
->send();
$this->form->fill([
@@ -2737,16 +2867,21 @@ class CreateInvoiceValidation extends CreateRecord
return;
}
if (preg_match('/^([a-zA-Z0-9]+)\|([a-zA-Z0-9]+(?:\/[MmPpCc]?)?)$/', $serNo, $matches))
//'/^([a-zA-Z0-9]+)\|([a-zA-Z0-9]+(?:\/[MmPpCc]?)?)$/'
if (preg_match('/^([a-zA-Z0-9]{6,})\|([1-9][a-zA-Z0-9]{8,})(?:\/[MmPpCc])?$/', $serNo, $matches))
{
$itemCode = $matches[1];
$serialNumber = $matches[2];
// Check if it ends with /M, /P, /C etc.
$isMarkM = preg_match('/\/[Mm]$/', $serialNumber);
$isMarkP = preg_match('/\/[Pp]$/', $serialNumber);
$isMarkC = preg_match('/\/[Cc]$/', $serialNumber);
// // Check if it ends with /M, /P, /C etc.
// $isMarkM = preg_match('/\/[Mm]$/', $serialNumber);
// $isMarkP = preg_match('/\/[Pp]$/', $serialNumber);
// $isMarkC = preg_match('/\/[Cc]$/', $serialNumber);
$isMarkM = preg_match('/^([a-zA-Z0-9]{6,})\|([1-9][a-zA-Z0-9]{8,})\/[Mm]?$/', $serNo) ? true : false;
$isMarkP = preg_match('/^([a-zA-Z0-9]{6,})\|([1-9][a-zA-Z0-9]{8,})\/[Pp]?$/', $serNo) ? true : false;
$isMarkC = preg_match('/^([a-zA-Z0-9]{6,})\|([1-9][a-zA-Z0-9]{8,})\/[Cc]?$/', $serNo) ? true : false;
$isMarkPs = (!$isMarkM && !$isMarkP && !$isMarkC) ? true : false;
//dd($serialNumber, $isMarkM, $isMarkP, $isMarkC, $isMarkPs);
$serialNumber = preg_replace('/\/[MmPpCc]$/', '', $serialNumber);
@@ -2757,6 +2892,7 @@ class CreateInvoiceValidation extends CreateRecord
->title('Serial Number Not Found')
->body("Serial '$serialNumber' not found in database for choosed plant.")
->danger()
->seconds(2)
->send();
$this->form->fill([
@@ -2778,6 +2914,7 @@ class CreateInvoiceValidation extends CreateRecord
->title('Unknown: Serial Number')
->body("Serial '$serialNumber' not found in invoice.")
->danger()
->seconds(2)
->send();
$this->form->fill([
@@ -2803,6 +2940,7 @@ class CreateInvoiceValidation extends CreateRecord
->title('Unknown: Item Code')
->body("Item code '$itemCode' with serial number '$serialNumber' not found.")
->danger()
->seconds(2)
->send();
$this->form->fill([
@@ -2832,6 +2970,7 @@ class CreateInvoiceValidation extends CreateRecord
->title('Invalid: Item Code')
->body("Scanned 'Item Code' doesn't have valid package type to proceed!")
->danger()
->seconds(2)
->send();
$this->form->fill([
@@ -2852,6 +2991,7 @@ class CreateInvoiceValidation extends CreateRecord
->title('Unknown: Motor QR')
->body("Scanned 'Item Code' doesn't have 'Motor' QR to proceed!")
->danger()
->seconds(2)
->send();
$this->form->fill([
@@ -2870,6 +3010,7 @@ class CreateInvoiceValidation extends CreateRecord
->title('Duplicate: Motor QR')
->body("Scanned 'Motor' serial number already completed the scanning process.")
->danger()
->seconds(2)
->send();
$this->form->fill([
@@ -2913,6 +3054,7 @@ class CreateInvoiceValidation extends CreateRecord
->title('Success: Motor QR')
->body("'Motor' QR scanned status updated, Scan next QR.")
->success()
->seconds(2)
->send();
$scannedQuantity = InvoiceValidation::where('invoice_number', $invoiceNumber)->where('scanned_status', 'Scanned')->where('plant_id', $plantId)->count();
@@ -2931,6 +3073,7 @@ class CreateInvoiceValidation extends CreateRecord
->title('Completed: Serial Invoice')
->body("Serial invoice '$invoiceNumber' completed the scanning process.<br>Scan the next 'Serial Invoice' to proceed!")
->success()
->seconds(2)
->send();
$filename = $invoiceNumber . '.xlsx';
@@ -2958,6 +3101,7 @@ class CreateInvoiceValidation extends CreateRecord
->title('Unknown: Pump QR')
->body("Scanned 'Item Code' doesn't have 'Pump' QR to proceed!")
->danger()
->seconds(2)
->send();
$this->form->fill([
@@ -2976,6 +3120,7 @@ class CreateInvoiceValidation extends CreateRecord
->title('Duplicate: Pump QR')
->body("Scanned 'Pump' serial number already completed the scanning process.")
->danger()
->seconds(2)
->send();
$this->form->fill([
@@ -3019,6 +3164,7 @@ class CreateInvoiceValidation extends CreateRecord
->title('Success: Pump QR')
->body("'Pump' QR scanned status updated, Scan next QR.")
->success()
->seconds(2)
->send();
$scannedQuantity = InvoiceValidation::where('invoice_number', $invoiceNumber)->where('scanned_status', 'Scanned')->where('plant_id', $plantId)->count();
@@ -3037,6 +3183,7 @@ class CreateInvoiceValidation extends CreateRecord
->title('Completed: Serial Invoice')
->body("Serial invoice '$invoiceNumber' completed the scanning process.<br>Scan the next 'Serial Invoice' to proceed!")
->success()
->seconds(2)
->send();
$filename = $invoiceNumber . '.xlsx';
@@ -3066,6 +3213,7 @@ class CreateInvoiceValidation extends CreateRecord
// ->body("Panel Box Code is not available for Item Code : '$itemCode'.")
->body("Scanned 'Item Code' doesn't have 'Panel Box Code' to proceed!")
->danger()
->seconds(2)
->send();
$this->form->fill([
@@ -3084,6 +3232,7 @@ class CreateInvoiceValidation extends CreateRecord
->title('Duplicate: Capacitor QR')
->body("Scanned 'Capacitor' serial number already completed the scanning process.")
->danger()
->seconds(2)
->send();
$this->form->fill([
@@ -3122,6 +3271,7 @@ class CreateInvoiceValidation extends CreateRecord
->title('Unknown: Pump Set QR')
->body("Scanned 'Item Code' doesn't have 'Pump Set' QR to proceed!")
->danger()
->seconds(2)
->send();
$this->form->fill([
@@ -3140,6 +3290,7 @@ class CreateInvoiceValidation extends CreateRecord
->title('Duplicate: Pump Set QR')
->body("Scanned 'Pump Set' serial number already completed the scanning process.")
->danger()
->seconds(2)
->send();
$this->form->fill([
@@ -3183,6 +3334,7 @@ class CreateInvoiceValidation extends CreateRecord
->title('Success: Pump Set QR')
->body("'Pump Set' QR scanned status updated, Scan next QR.")
->success()
->seconds(2)
->send();
$scannedQuantity = InvoiceValidation::where('invoice_number', $invoiceNumber)->where('scanned_status', 'Scanned')->where('plant_id', $plantId)->count();
@@ -3201,6 +3353,7 @@ class CreateInvoiceValidation extends CreateRecord
->title('Completed: Serial Invoice')
->body("Serial invoice '$invoiceNumber' completed the scanning process.<br>Scan the next 'Serial Invoice' to proceed!")
->success()
->seconds(2)
->send();
$filename = $invoiceNumber . '.xlsx';

View File

@@ -19,6 +19,7 @@ use Illuminate\Database\Eloquent\SoftDeletingScope;
use Filament\Forms\Get;
use Filament\Tables\Actions\ExportAction;
use Filament\Tables\Actions\ImportAction;
// use Illuminate\Validation\Rule;
class StickerMasterResource extends Resource
{
@@ -78,6 +79,11 @@ class StickerMasterResource extends Resource
->pluck('code', 'id')
->toArray();
})
// ->rule(function (callable $get) {
// return Rule::unique('items', 'code')
// ->where('plant_id', $get('plant_id'))
// ->ignore($get('id')); // Ignore current record during updates
// })
->required()
->nullable()
->searchable()
@@ -129,7 +135,10 @@ class StickerMasterResource extends Resource
$duplicateSticker = StickerMaster::where('plant_id', $plantId)
->where('item_id', $itemId)
->exists();
$set('item_error', $duplicateSticker ? 'Item Code already exists for the selected plant.' : null);
if(!$get('id'))
{
$set('item_error', $duplicateSticker ? 'Item Code already exists for the selected plant.' : null);
}
})
->extraAttributes(fn ($get) => [
'class' => $get('item_error') ? 'border-red-500' : '',

View File

@@ -196,7 +196,8 @@ class InvoiceDataTable extends Component
->title('Invalid Panel Box QR Format:')
->body('Scan the valid panel box QR code to proceed!')
->danger()
->duration(3000)
// ->duration(3000)
->seconds(2)
->send();
return;
}
@@ -216,7 +217,8 @@ class InvoiceDataTable extends Component
->title('Unknown: Panel Box Code')
->body("Unknown panel box code: $itemCode found for item code: $this->currentItemCode")
->danger()
->duration(4000)
// ->duration(4000)
->seconds(2)
->send();
$this->capacitorInput = '';
return;
@@ -304,7 +306,7 @@ class InvoiceDataTable extends Component
// ->title("Panel box code scanned: $itemCode")
->body("'Capacitor' QR scanned status updated, Scan next QR.")
->success()
->duration(3000)
->seconds(2)
->send();
$totalQuantity = InvoiceValidation::where('invoice_number', $matchingValidation->invoice_number)->where('plant_id', $this->plantId)->count();
@@ -323,6 +325,7 @@ class InvoiceDataTable extends Component
->title('Completed: Serial Invoice')
->body("Serial invoice '$matchingValidation->invoice_number' completed the scanning process.<br>Scan the next 'Serial Invoice' to proceed!")
->success()
->seconds(2)
->send();
$this->loadCompletedData($matchingValidation->invoice_number, $matchingValidation->plant_id);
}

View File

@@ -26,8 +26,8 @@ class Block extends Model
return $this->hasMany(Shift::class);
}
public function lines(): HasMany
{
return $this->hasMany(Line::class);
}
// public function lines(): HasMany
// {
// return $this->hasMany(Line::class);
// }
}

View File

@@ -14,4 +14,9 @@ class LineStop extends Model
"code",
"reason",
];
public function productionLineStops()
{
return $this->hasMany(ProductionLineStop::class, 'linestop_id');
}
}

View File

@@ -37,4 +37,24 @@ class Plant extends Model
{
return $this->hasMany(Line::class, 'plant_id', 'id'); // Ensure 'plant_id' is the foreign key in 'lines' table
}
public function items(): HasMany
{
return $this->hasMany(Item::class);
}
public function stickersMasters(): HasMany
{
return $this->hasMany(StickerMaster::class);
}
public function invoiceValidations()
{
return $this->hasMany(InvoiceValidation::class, 'sticker_master_id');
}
public function qualityValidations()
{
return $this->hasMany(QualityValidation::class, 'sticker_master_id');
}
}

View File

@@ -40,6 +40,7 @@ class StickerMaster extends Model
public function item()
{
return $this->belongsTo(Item::class, 'item_id', 'id');
// return $this->belongsTo(Item::class);
}
public function plant(): BelongsTo
@@ -54,6 +55,6 @@ class StickerMaster extends Model
public function invoiceValidations()
{
return $this->hasMany(InvoiceValidation::class);
return $this->hasMany(InvoiceValidation::class, 'sticker_master_id');
}
}