diff --git a/app/Filament/Resources/InvoiceValidationResource/Pages/CreateInvoiceValidation.php b/app/Filament/Resources/InvoiceValidationResource/Pages/CreateInvoiceValidation.php
index faffbe6c2..0b627e137 100644
--- a/app/Filament/Resources/InvoiceValidationResource/Pages/CreateInvoiceValidation.php
+++ b/app/Filament/Resources/InvoiceValidationResource/Pages/CreateInvoiceValidation.php
@@ -3,27 +3,22 @@
namespace App\Filament\Resources\InvoiceValidationResource\Pages;
use App\Filament\Resources\InvoiceValidationResource;
-use App\Filament\Widgets\ItemOverview;
use App\Imports\ExcelImport;
-use App\Livewire\InvoiceDataTable;
+use App\Mail\InvalidSerialMail;
+use App\Models\AlertMailRule;
use App\Models\InvoiceValidation;
use App\Models\Item;
use App\Models\Plant;
use App\Models\StickerMaster;
use Filament\Facades\Filament;
-use Filament\Pages\Concerns\ExposesTableToWidgets;
-use Illuminate\Contracts\View\View;
-use Filament\Resources\Pages\CreateRecord;
use Filament\Notifications\Notification;
-use Illuminate\Support\Facades\Storage;
+use Filament\Pages\Concerns\ExposesTableToWidgets;
+use Filament\Resources\Pages\CreateRecord;
use Illuminate\Support\Collection;
-use Maatwebsite\Excel\Facades\Excel;
-use Livewire\Livewire;
-use Str;
use Illuminate\Support\Facades\Mail;
-use App\Mail\InvalidSerialMail;
-use Illuminate\Support\Facades\Log;
-use App\Models\AlertMailRule;
+use Illuminate\Support\Facades\Storage;
+use Maatwebsite\Excel\Facades\Excel;
+use Str;
class CreateInvoiceValidation extends CreateRecord
{
@@ -75,27 +70,24 @@ class CreateInvoiceValidation extends CreateRecord
$scanSQuan = InvoiceValidation::where('invoice_number', $this->invoiceNumber)->where('scanned_status', 'Scanned')->where('plant_id', $this->plantId)->count();
$this->dispatch('playNotificationSound');
- if ($totQuan == $scanSQuan)
- {
+ if ($totQuan == $scanSQuan) {
$this->form->fill([
'plant_id' => $this->plantId,
'invoice_number' => null,
'serial_number' => null,
'total_quantity' => 0,
'update_invoice' => false,
- 'scanned_quantity'=> 0
+ 'scanned_quantity' => 0,
]);
$this->dispatch('refreshCompletedInvoice', invoiceNumber: $this->invoiceNumber, plantId: $this->plantId, isSerial: true);
- }
- else
- {
+ } else {
$this->form->fill([
'plant_id' => $this->plantId,
'invoice_number' => $this->invoiceNumber,
'serial_number' => null,
'total_quantity' => $totQuan,
'update_invoice' => false,
- 'scanned_quantity'=> $scanSQuan
+ 'scanned_quantity' => $scanSQuan,
]);
$this->dispatch('refreshInvoiceData', invoiceNumber: $this->invoiceNumber, plantId: $this->plantId, onCapFocus: false);
}
@@ -120,25 +112,25 @@ class CreateInvoiceValidation extends CreateRecord
$this->plantId = $plantId;
- //$plant = Plant::find($plantId);
- //$plantCode = $plant ? $plant->code : null;
+ // $plant = Plant::find($plantId);
+ // $plantCode = $plant ? $plant->code : null;
- //..GET SERIAL INVOICE API
+ // ..GET SERIAL INVOICE API
- //..
+ // ..
$updateStatus = $this->form->getState()['update_invoice'] ?? null;
$this->invoiceNumber = trim($this->form->getState()['invoice_number']) ?? $invoiceNumber;
$invoiceType = null;
- //$this->invoiceNumber = $this->invoiceNumber ?? $invoiceNumber;
+ // $this->invoiceNumber = $this->invoiceNumber ?? $invoiceNumber;
$invoiceExist = InvoiceValidation::where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->exists();
- if (!$invoiceExist) {
+ if (! $invoiceExist) {
Notification::make()
- ->title("New invoice detected.")
+ ->title('New invoice detected.')
->info()
->seconds(1)
->send();
@@ -149,45 +141,41 @@ class CreateInvoiceValidation extends CreateRecord
'invoice_number' => $invoiceNumber,
'serial_number' => null,
'total_quantity' => 0,
- 'scanned_quantity'=> 0,
+ 'scanned_quantity' => 0,
]);
$this->dispatch('refreshEmptyInvoice', invoiceNumber: $invoiceNumber, plantId: $plantId);
- }
- else
- {
+ } else {
$totQuan = InvoiceValidation::where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->count();
$scanSQuan = InvoiceValidation::where('invoice_number', $invoiceNumber)->where('scanned_status', 'Scanned')->where('plant_id', $plantId)->count();
- $totMQuan = InvoiceValidation::where('invoice_number', $invoiceNumber)->whereNotNull('quantity')->where('plant_id', $plantId)->count(); //->where('quantity', '!=', '')
+ $totMQuan = InvoiceValidation::where('invoice_number', $invoiceNumber)->whereNotNull('quantity')->where('plant_id', $plantId)->count(); // ->where('quantity', '!=', '')
$scanMQuan = InvoiceValidation::where('invoice_number', $invoiceNumber)->whereNotNull('serial_number')->where('serial_number', '!=', '')->where('plant_id', $plantId)->count();
- if ($totMQuan > 0)
- {
+ if ($totMQuan > 0) {
$this->form->fill([
'plant_id' => $plantId,
'invoice_number' => $invoiceNumber,
'serial_number' => null,
'total_quantity' => $totQuan,
- 'scanned_quantity'=> $scanMQuan,
+ 'scanned_quantity' => $scanMQuan,
]);
- if ($totQuan == $scanMQuan)
- {
+ if ($totQuan == $scanMQuan) {
Notification::make()
- ->title("Completed: Material Invoice")
+ ->title('Completed: Material Invoice')
->body("Material invoice '$invoiceNumber' completed the scanning process.
Scan the next 'Material Invoice' to proceed!")
->warning()
->seconds(2)
->send();
$this->dispatch('playNotificationSound');
- $filename = $invoiceNumber . '.xlsx';
+ $filename = $invoiceNumber.'.xlsx';
$directory = 'uploads/temp';
$disk = Storage::disk('local');
- $filePath = $directory . '/' . $filename;
- //$fullPath = null;
+ $filePath = $directory.'/'.$filename;
+ // $fullPath = null;
if ($disk->exists($filePath)) {
- //$fullPath = $disk->path($filePath);
+ // $fullPath = $disk->path($filePath);
$disk->delete($filePath);
}
@@ -197,15 +185,13 @@ class CreateInvoiceValidation extends CreateRecord
'serial_number' => null,
'total_quantity' => 0,
'update_invoice' => false,
- 'scanned_quantity'=> 0
+ 'scanned_quantity' => 0,
]);
$this->dispatch('refreshCompletedInvoice', invoiceNumber: $invoiceNumber, plantId: $plantId, isSerial: false);
- }
- else
- {
+ } else {
Notification::make()
- ->title("Start the scanning process!")
+ ->title('Start the scanning process!')
->info()
->seconds(1)
->send();
@@ -214,22 +200,19 @@ class CreateInvoiceValidation extends CreateRecord
// $this->dispatch( (!empty($hasRecords) && $hasRecords) ? 'refreshMaterialInvoiceData' : 'refreshInvoiceData', invoiceNumber: $invoiceNumber, plantId: $plantId, onCapFocus: false); //$this->invoiceNumber
$this->dispatch('refreshMaterialInvoiceData', invoiceNumber: $invoiceNumber, plantId: $plantId);
- if ($updateStatus == '1')
- {
- //'Material invoice update in progress...';
- $filename = $invoiceNumber . '.xlsx';
+ if ($updateStatus == '1') {
+ // 'Material invoice update in progress...';
+ $filename = $invoiceNumber.'.xlsx';
$directory = 'uploads/temp';
$disk = Storage::disk('local');
- $filePath = $directory . '/' . $filename;
+ $filePath = $directory.'/'.$filename;
$fullPath = $disk->path($filePath);
- if ($fullPath && file_exists($fullPath))
- {
+ if ($fullPath && file_exists($fullPath)) {
// Now you can read/process the file here
$rows = Excel::toArray(null, $fullPath)[0];
- if ((count($rows) - 1) <= 0)
- {
+ if ((count($rows) - 1) <= 0) {
Notification::make()
->title('Records Not Found')
->body("Import the valid updated 'Material Invoice' file to proceed..!")
@@ -241,6 +224,7 @@ class CreateInvoiceValidation extends CreateRecord
if ($disk->exists($filePath)) {
$disk->delete($filePath);
}
+
return;
}
@@ -251,9 +235,10 @@ class CreateInvoiceValidation extends CreateRecord
$hasQuanTypIds = [];
$validRowsFound = false;
- foreach ($rows as $index => $row)
- {
- if ($index == 0) continue; // Skip header
+ foreach ($rows as $index => $row) {
+ if ($index == 0) {
+ continue;
+ } // Skip header
$materialCode = trim($row[0]);
$materialQuantity = trim($row[1]);
@@ -262,48 +247,38 @@ class CreateInvoiceValidation extends CreateRecord
continue;
}
- if (!empty($materialCode)) {
- if (Str::length($materialCode) < 6 || !ctype_alnum($materialCode))
- {
+ if (! empty($materialCode)) {
+ if (Str::length($materialCode) < 6 || ! ctype_alnum($materialCode)) {
$invalidMatCodes[] = $materialCode;
- }
- else
- {
+ } else {
if (empty($materialQuantity)) {
$missingQuantities[] = $materialCode;
- }
- else if (!is_numeric($materialQuantity))
- {
+ } elseif (! is_numeric($materialQuantity)) {
$invalidMatQuan[] = $materialCode;
- }
- else if ($materialQuantity == 0)
- {
+ } elseif ($materialQuantity == 0) {
$invalidMatQuan[] = $materialCode;
- }
- else
- {
+ } else {
$materialCodes[] = $materialCode;
$validRowsFound = true;
}
}
- }
- else
- {
+ } else {
continue;
}
}
$uniqueInvalidCodes = array_unique($invalidMatCodes);
- if (!empty($uniqueInvalidCodes)) {
+ if (! empty($uniqueInvalidCodes)) {
Notification::make()
->title('Invalid: Item Codes')
- ->body('The following item codes should contain minimum 6 digit alpha numeric values:
' . implode(', ', $uniqueInvalidCodes))
+ ->body('The following item codes should contain minimum 6 digit alpha numeric values:
'.implode(', ', $uniqueInvalidCodes))
->danger()
->seconds(2)
->send();
$this->dispatch('playWarnSound');
+
// if ($disk->exists($filePath)) {
// $disk->delete($filePath);
// }
@@ -312,15 +287,16 @@ class CreateInvoiceValidation extends CreateRecord
$uniqueMissingQuanCodes = array_unique($missingQuantities);
- if (!empty($uniqueMissingQuanCodes)) {
+ if (! empty($uniqueMissingQuanCodes)) {
Notification::make()
->title('Missing Material Quantity')
- ->body("The following item codes doesn't have valid material quantity:
" . implode(', ', $uniqueMissingQuanCodes))
+ ->body("The following item codes doesn't have valid material quantity:
".implode(', ', $uniqueMissingQuanCodes))
->danger()
->seconds(2)
->send();
$this->dispatch('playWarnSound');
+
// if ($disk->exists($filePath)) {
// $disk->delete($filePath);
// }
@@ -329,22 +305,23 @@ class CreateInvoiceValidation extends CreateRecord
$uniqueInvalidMatQuan = array_unique($invalidMatQuan);
- if (!empty($uniqueInvalidMatQuan)) {
+ if (! empty($uniqueInvalidMatQuan)) {
Notification::make()
->title('Invalid Material Quantity')
- ->body("The following item codes doesn't have valid material quantity:
" . implode(', ', $uniqueInvalidMatQuan))
+ ->body("The following item codes doesn't have valid material quantity:
".implode(', ', $uniqueInvalidMatQuan))
->danger()
->seconds(2)
->send();
$this->dispatch('playWarnSound');
+
// if ($disk->exists($filePath)) {
// $disk->delete($filePath);
// }
return;
}
- if (!$validRowsFound) {
+ if (! $validRowsFound) {
Notification::make()
->title('Invalid Material Invoice')
->danger() // This makes the notification red to indicate an error
@@ -356,12 +333,13 @@ class CreateInvoiceValidation extends CreateRecord
if ($disk->exists($filePath)) {
$disk->delete($filePath);
}
+
return;
}
$uniqueCodes = array_unique($materialCodes);
- //itemNotFound
+ // itemNotFound
$matchedItems = StickerMaster::with('item')
->whereHas('item', function ($query) use ($uniqueCodes) {
$query->whereIn('code', $uniqueCodes);
@@ -372,11 +350,10 @@ class CreateInvoiceValidation extends CreateRecord
$missingCodes = array_diff($uniqueCodes, $matchedCodes);
- if (!empty($missingCodes))
- {
+ if (! empty($missingCodes)) {
$missingCount = count($missingCodes);
- $message = $missingCount > 10 ? "'$missingCount' item codes are not found in database." : 'The following item codes are not found in database:
' . implode(', ', $missingCodes);
+ $message = $missingCount > 10 ? "'$missingCount' item codes are not found in database." : 'The following item codes are not found in database:
'.implode(', ', $missingCodes);
Notification::make()
->title('Unknown: Item Codes')
@@ -392,7 +369,7 @@ class CreateInvoiceValidation extends CreateRecord
return;
}
- //plantNotFound
+ // plantNotFound
$matchedItems = StickerMaster::with('item')
->whereHas('item', function ($query) use ($uniqueCodes, $plantId) {
$query->whereIn('code', $uniqueCodes)->where('plant_id', $plantId);
@@ -403,11 +380,10 @@ class CreateInvoiceValidation extends CreateRecord
$missingCodes = array_diff($uniqueCodes, $matchedCodes);
- if (!empty($missingCodes))
- {
+ if (! empty($missingCodes)) {
$missingCount = count($missingCodes);
- $message = $missingCount > 10 ? "'$missingCount' item codes are not found in database for choosed plant." : 'The following item codes are not found in database for choosed plant:
' . implode(', ', $missingCodes);
+ $message = $missingCount > 10 ? "'$missingCount' item codes are not found in database for choosed plant." : 'The following item codes are not found in database for choosed plant:
'.implode(', ', $missingCodes);
Notification::make()
->title('Unknown: Item Codes')
@@ -424,23 +400,21 @@ class CreateInvoiceValidation extends CreateRecord
}
$invalidCodes = $matchedItems
- ->filter(fn ($sticker) => empty($sticker->material_type)) //filter invalid
- ->pluck('item.code')
- ->toArray();
+ ->filter(fn ($sticker) => empty($sticker->material_type)) // filter invalid
+ ->pluck('item.code')
+ ->toArray();
-
- if (!empty($invalidCodes))
- {
+ if (! empty($invalidCodes)) {
$missingCount = count($invalidCodes);
- $message = $missingCount > 10 ? "'$missingCount' Serial Invoice item codes found." : "'Serial Invoice' item codes found:
" . implode(', ', $invalidCodes);
+ $message = $missingCount > 10 ? "'$missingCount' Serial Invoice item codes found." : "'Serial Invoice' item codes found:
".implode(', ', $invalidCodes);
Notification::make()
- ->title('Invalid: Item Codes')
- ->body($message)
- ->danger()
- ->seconds(2)
- ->send();
+ ->title('Invalid: Item Codes')
+ ->body($message)
+ ->danger()
+ ->seconds(2)
+ ->send();
$this->dispatch('playWarnSound');
// if ($disk->exists($filePath)) {
@@ -454,19 +428,18 @@ class CreateInvoiceValidation extends CreateRecord
$notDivisibleCodes = [];
$hasQuanTyp = false;
- foreach ($matchedItems as $sticker)
- {
+ foreach ($matchedItems as $sticker) {
$code = $sticker->item->code;
$materialType = $sticker->material_type;
- if ($materialType == 2)
- {
+ if ($materialType == 2) {
$bundleQty = $sticker->bundle_quantity ?? 0;
$totalExcelQty = 0;
- foreach ($rows as $index => $row)
- {
- if ($index == 0) continue; // Skip header
+ foreach ($rows as $index => $row) {
+ if ($index == 0) {
+ continue;
+ } // Skip header
$excelCode = trim($row[0]);
$excelMatQty = trim($row[1]);
@@ -482,21 +455,21 @@ class CreateInvoiceValidation extends CreateRecord
if ($totalExcelQty == 0) {
$zeroQtyCodes[] = $code;
- } else if (!is_numeric($totalExcelQty)) {
+ } elseif (! is_numeric($totalExcelQty)) {
$nonNumericQtyCodes[] = $code; // Here you may want to check divisibility condition too
- } else if ($bundleQty != 0 && $totalExcelQty % $bundleQty != 0) {
+ } elseif ($bundleQty != 0 && $totalExcelQty % $bundleQty != 0) {
$notDivisibleCodes[] = $code;
}
- }
- else if ($materialType == 3)
- {
+ } elseif ($materialType == 3) {
$hasQuanTyp = true;
$hasQuanTypIds[] = $sticker->id;
}
}
- $showValidationNotification = function(array $codes, string $message) {
- if (count($codes) == 0) return;
+ $showValidationNotification = function (array $codes, string $message) {
+ if (count($codes) == 0) {
+ return;
+ }
$uniqueCodes = array_unique($codes);
$codeList = implode(', ', $uniqueCodes);
@@ -507,42 +480,36 @@ class CreateInvoiceValidation extends CreateRecord
->danger()
->seconds(2)
->send();
- $this->dispatch('playWarnSound');
+ $this->dispatch('playWarnSound');
};
- $showValidationNotification($nonNumericQtyCodes, "The following item codes contains invalid bundle quantity:");
+ $showValidationNotification($nonNumericQtyCodes, 'The following item codes contains invalid bundle quantity:');
$showValidationNotification($zeroQtyCodes, "The following item codes quantity should be greater than '0':");
- $showValidationNotification($notDivisibleCodes, "The following item codes quantity is not divisible by bundle quantity.");
+ $showValidationNotification($notDivisibleCodes, 'The following item codes quantity is not divisible by bundle quantity.');
if ($nonNumericQtyCodes || $zeroQtyCodes || $notDivisibleCodes) {
// if ($disk->exists($filePath)) {
// $disk->delete($filePath);
// }
return;
- }
- else
- {
+ } else {
$oldQuan = InvoiceValidation::where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->count();
$newQuan = -1;
$inserted = 0;
- foreach ($matchedItems as $sticker)
- {
- if ($newQuan == -1 && !$hasQuanTyp)
- {
- InvoiceValidation::where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->where(function($query) {
+ foreach ($matchedItems as $sticker) {
+ if ($newQuan == -1 && ! $hasQuanTyp) {
+ InvoiceValidation::where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->where(function ($query) {
$query->whereNull('serial_number')->orWhere('serial_number', '');
})
- ->forceDelete(); //->delete();
+ ->forceDelete(); // ->delete();
$newQuan = InvoiceValidation::where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->count();
- }
- else if ($newQuan == -1 && $hasQuanTyp)
- {
- InvoiceValidation::where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->where(function($query) {
+ } elseif ($newQuan == -1 && $hasQuanTyp) {
+ InvoiceValidation::where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->where(function ($query) {
$query->whereNull('serial_number')->orWhere('serial_number', '');
})->whereNotIn('sticker_master_id', $hasQuanTypIds)
- ->forceDelete(); //->delete();
+ ->forceDelete(); // ->delete();
$newQuan = InvoiceValidation::where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->count();
}
@@ -551,13 +518,13 @@ class CreateInvoiceValidation extends CreateRecord
$materialType = $sticker->material_type;
// $sticker = StickerMaster::where('plant_id', $plantId)->whereHas('item', function ($query) use ($code) { $query->where('plant_id', $this->plantId)->where('code', $code); })->first();
- if ($materialType == 1)
- {
+ if ($materialType == 1) {
$totalExcelQty = 0;
- foreach ($rows as $index => $row)
- {
- if ($index == 0) continue; // Skip header
+ foreach ($rows as $index => $row) {
+ if ($index == 0) {
+ continue;
+ } // Skip header
$excelCode = trim($row[0]);
$excelMatQty = trim($row[1]);
@@ -573,32 +540,29 @@ class CreateInvoiceValidation extends CreateRecord
$existQty = InvoiceValidation::where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->where('sticker_master_id', $sticker->id)->count();
- if ($existQty < $totalExcelQty)
- {
+ if ($existQty < $totalExcelQty) {
$newQty = $totalExcelQty - $existQty;
- for ($i = 0; $i < $newQty; $i++)
- {
+ for ($i = 0; $i < $newQty; $i++) {
if ($sticker) {
InvoiceValidation::create([
'sticker_master_id' => $sticker->id,
'plant_id' => $plantId,
'invoice_number' => $invoiceNumber,
'quantity' => 1,
- 'operator_id'=> $operatorName,
+ 'operator_id' => $operatorName,
]);
$inserted++;
}
}
}
- }
- else if ($materialType == 2)
- {
+ } elseif ($materialType == 2) {
$bundleQty = $sticker->bundle_quantity;
$totalExcelQty = 0;
- foreach ($rows as $index => $row)
- {
- if ($index == 0) continue; // Skip header
+ foreach ($rows as $index => $row) {
+ if ($index == 0) {
+ continue;
+ } // Skip header
$excelCode = trim($row[0]);
$excelMatQty = trim($row[1]);
@@ -614,33 +578,30 @@ class CreateInvoiceValidation extends CreateRecord
$existQty = InvoiceValidation::where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->where('sticker_master_id', $sticker->id)->count();
- //for ($i = 0; $i < ($totalExcelQty/$bundleQty); $i++)
- $newTotQty = $totalExcelQty/$bundleQty;
- if ($existQty < $newTotQty)
- {
+ // for ($i = 0; $i < ($totalExcelQty/$bundleQty); $i++)
+ $newTotQty = $totalExcelQty / $bundleQty;
+ if ($existQty < $newTotQty) {
$newQty = $newTotQty - $existQty;
- for ($i = 0; $i < $newQty; $i++)
- {
+ for ($i = 0; $i < $newQty; $i++) {
if ($sticker) {
InvoiceValidation::create([
'sticker_master_id' => $sticker->id,
'plant_id' => $plantId,
'invoice_number' => $invoiceNumber,
'quantity' => $bundleQty,
- 'operator_id'=> $operatorName,
+ 'operator_id' => $operatorName,
]);
$inserted++;
}
}
}
- }
- else if ($materialType == 3)
- {
+ } elseif ($materialType == 3) {
$totalExcelQty = 0;
- foreach ($rows as $index => $row)
- {
- if ($index == 0) continue; // Skip header
+ foreach ($rows as $index => $row) {
+ if ($index == 0) {
+ continue;
+ } // Skip header
$excelCode = trim($row[0]);
$excelMatQty = trim($row[1]);
@@ -654,16 +615,16 @@ class CreateInvoiceValidation extends CreateRecord
}
}
- $existEmpRecQty = InvoiceValidation::where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->where(function($query) {
+ $existEmpRecQty = InvoiceValidation::where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->where(function ($query) {
$query->whereNull('serial_number')->orWhere('serial_number', '');
})->where('sticker_master_id', $sticker->id)->first();
$existEmpQty = $existEmpRecQty ? $existEmpRecQty->quantity : 0;
- $existComQty = InvoiceValidation::where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->where(function($query) {
+ $existComQty = InvoiceValidation::where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->where(function ($query) {
$query->whereNotNull('serial_number')->where('serial_number', '!=', '');
})
- ->where('sticker_master_id', $sticker->id)
- ->sum(column: 'quantity');
+ ->where('sticker_master_id', $sticker->id)
+ ->sum(column: 'quantity');
$existComQty = $existComQty ? $existComQty : 0;
// 8 = 3 + 5 // 8 = 5 + 3 // 8 = 0 + 8 // 8 = 8 + 0
@@ -675,68 +636,64 @@ class CreateInvoiceValidation extends CreateRecord
// 8 <= 7 // 8 <= 7 // 8 <= 7 // 8 <= 7
// 0 <= 5
- if ($existQty <= $totalExcelQty)
- {
+ if ($existQty <= $totalExcelQty) {
// 6 = 11 - 5 // 5 = 8 - 3 // 3 = 11 - 8 // 9 = 9 - 0
// 5 = 5 - 0
$newInsQty = $totalExcelQty - $existComQty;
// 3 > 0 // 5 > 0 // 0 > 0 // 8 > 0
// 0 > 0
- if ($existEmpQty > 0) // update
- {
+ if ($existEmpQty > 0) { // update
// 3 = 6 // 5 = 5 // 0 = 3 // 8 = 9
// 0 = 5
- if ($existEmpQty == $newInsQty) { continue; }
+ if ($existEmpQty == $newInsQty) {
+ continue;
+ }
// $existEmpRecQty->delete();
$existEmpRecQty->update([
'quantity' => $newInsQty,
- 'operator_id'=> $operatorName,
+ 'operator_id' => $operatorName,
'updated_at' => now(),
]);
$newQuan--;
$inserted++;
- }
- else if ($newInsQty > 0) // if ($sticker) // create
- {
+ } elseif ($newInsQty > 0) { // if ($sticker) // create
InvoiceValidation::create([
'sticker_master_id' => $sticker->id,
'plant_id' => $plantId,
'invoice_number' => $invoiceNumber,
'quantity' => $newInsQty,
- 'operator_id'=> $operatorName,
+ 'operator_id' => $operatorName,
]);
$inserted++;
}
}
// 8 > 7 // 8 > 7 // 8 > 7 // 8 > 7
- else
- {
+ else {
// 2 = 7 - 5 // 4 = 7 - 3 // -1 = 7 - 8 // 7 = 7 - 0
$newInsQty = $totalExcelQty - $existComQty;
// 3 > 0 // 5 > 0 // 0 > 0 // 8 > 0
- if ($existEmpQty > 0) // update
- {
+ if ($existEmpQty > 0) { // update
// 3 = 2 // 5 = 4 // 0 = -1 // 8 = 7
- if ($existEmpQty == $newInsQty) { continue; }
+ if ($existEmpQty == $newInsQty) {
+ continue;
+ }
// $existEmpRecQty->delete();
$existEmpRecQty->update([
'quantity' => $newInsQty,
- 'operator_id'=> $operatorName,
+ 'operator_id' => $operatorName,
'updated_at' => now(),
]);
$newQuan--;
$inserted++;
- }
- else if ($newInsQty > 0) // create
- {
+ } elseif ($newInsQty > 0) { // create
InvoiceValidation::create([
'sticker_master_id' => $sticker->id,
'plant_id' => $plantId,
'invoice_number' => $invoiceNumber,
'quantity' => $newInsQty,
- 'operator_id'=> $operatorName,
+ 'operator_id' => $operatorName,
]);
$inserted++;
}
@@ -744,16 +701,15 @@ class CreateInvoiceValidation extends CreateRecord
}
}
- if ($inserted > 0 || $oldQuan != $newQuan)
- {
+ if ($inserted > 0 || $oldQuan != $newQuan) {
Notification::make()
- ->title("Material invoice successfully updated.")
+ ->title('Material invoice successfully updated.')
->success()
->seconds(1)
->send();
Notification::make()
- ->title("Start the scanning process!")
+ ->title('Start the scanning process!')
->body("'$inserted' new material invoice records were inserted.")
->info()
// ->success()
@@ -769,30 +725,25 @@ class CreateInvoiceValidation extends CreateRecord
'invoice_number' => $invoiceNumber,
'serial_number' => null,
'total_quantity' => $totalQuantity,
- 'scanned_quantity'=> $scannedQuantity,
+ 'scanned_quantity' => $scannedQuantity,
]);
- if ($totalQuantity == $scannedQuantity)
- {
+ if ($totalQuantity == $scannedQuantity) {
if ($disk->exists($filePath)) {
$disk->delete($filePath);
}
$this->dispatch('refreshCompletedInvoice', invoiceNumber: $invoiceNumber, plantId: $plantId, isSerial: false);
- }
- else
- {
+ } else {
// if ($disk->exists($filePath)) {
// $disk->delete($filePath);
// }
$this->dispatch('refreshMaterialInvoiceData', invoiceNumber: $invoiceNumber, plantId: $plantId);
}
- }
- else
- {
+ } else {
Notification::make()
- ->title("Update Failed: Material Invoice")
+ ->title('Update Failed: Material Invoice')
->body("No new records were inserted for Material Invoice : '$invoiceNumber'.")
->danger()
->seconds(2)
@@ -806,7 +757,7 @@ class CreateInvoiceValidation extends CreateRecord
'invoice_number' => $invoiceNumber,
'serial_number' => null,
'total_quantity' => $totalQuantity,
- 'scanned_quantity'=> $scannedQuantity,
+ 'scanned_quantity' => $scannedQuantity,
]);
// if ($disk->exists($filePath)) {
@@ -814,12 +765,11 @@ class CreateInvoiceValidation extends CreateRecord
// }
$this->dispatch('refreshEmptyInvoice', invoiceNumber: $invoiceNumber, plantId: $plantId);
+
return;
}
}
- }
- else
- {
+ } else {
Notification::make()
->title('Updated Invoice Not Found')
->body("Import the updated 'Material Invoice' file to proceed..!")
@@ -833,44 +783,43 @@ class CreateInvoiceValidation extends CreateRecord
'invoice_number' => $invoiceNumber,
'serial_number' => null,
'total_quantity' => 0,
- 'scanned_quantity'=> 0,
+ 'scanned_quantity' => 0,
]);
$this->dispatch('refreshEmptyInvoice', invoiceNumber: $invoiceNumber, plantId: $plantId);
+
return;
}
}
}
+
return;
- }
- else
- {
+ } else {
$this->form->fill([
'plant_id' => $plantId,
'invoice_number' => $invoiceNumber,
'serial_number' => null,
'total_quantity' => $totQuan,
- 'scanned_quantity'=> $scanSQuan,
+ 'scanned_quantity' => $scanSQuan,
]);
- //$hasRecords = InvoiceValidation::where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->first()->stickerMasterRelation->material_type ?? null;
+ // $hasRecords = InvoiceValidation::where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->first()->stickerMasterRelation->material_type ?? null;
// $this->dispatch('refreshInvoiceData', invoiceNumber: $invoiceNumber, plantId: $plantId, onCapFocus: false);
- if ($totQuan == $scanSQuan)
- {
+ if ($totQuan == $scanSQuan) {
Notification::make()
- ->title("Completed: Serial Invoice")
+ ->title('Completed: Serial Invoice')
->body("Serial invoice '$invoiceNumber' completed the scanning process.
Scan the next 'Serial Invoice' to proceed..!")
->warning()
->seconds(3)
->send();
$this->dispatch('playNotificationSound');
- $filename = $invoiceNumber . '.xlsx';
+ $filename = $invoiceNumber.'.xlsx';
$directory = 'uploads/temp';
$disk = Storage::disk('local');
- $filePath = $directory . '/' . $filename;
- //$fullPath = null;
+ $filePath = $directory.'/'.$filename;
+ // $fullPath = null;
if ($disk->exists($filePath)) {
- //$fullPath = $disk->path($filePath);
+ // $fullPath = $disk->path($filePath);
$disk->delete($filePath);
}
@@ -880,40 +829,35 @@ class CreateInvoiceValidation extends CreateRecord
'serial_number' => null,
'total_quantity' => 0,
'update_invoice' => false,
- 'scanned_quantity'=> 0
+ 'scanned_quantity' => 0,
]);
$this->dispatch('refreshCompletedInvoice', invoiceNumber: $invoiceNumber, plantId: $plantId, isSerial: true);
- }
- else
- {
+ } else {
Notification::make()
- ->title("Start the scanning process!")
+ ->title('Start the scanning process!')
->info()
->seconds(1)
->send();
$this->dispatch('playNotificationSound');
$this->dispatch('refreshInvoiceData', invoiceNumber: $invoiceNumber, plantId: $plantId, onCapFocus: false);
- if ($updateStatus == '1')
- {
- $filename = $invoiceNumber . '.xlsx';
+ if ($updateStatus == '1') {
+ $filename = $invoiceNumber.'.xlsx';
$directory = 'uploads/temp';
$disk = Storage::disk('local');
- $filePath = $directory . '/' . $filename;
+ $filePath = $directory.'/'.$filename;
$fullPath = $disk->path($filePath);
// Check if file exists //if ($disk->exists($filePath))
- if ($fullPath && file_exists($fullPath))
- {
+ if ($fullPath && file_exists($fullPath)) {
// /home/iot-dev/projects/pds/storage/app/private/uploads/temp/3RA0018735.xlsx
// 'Serial invoice update in progress...'
// Now you can read/process the file here
$rows = Excel::toArray(null, $fullPath)[0];
- if ((count($rows) - 1) <= 0)
- {
+ if ((count($rows) - 1) <= 0) {
Notification::make()
->title('Records Not Found')
->body("Import the valid updated 'Serial Invoice' file to proceed..!")
@@ -925,6 +869,7 @@ class CreateInvoiceValidation extends CreateRecord
if ($disk->exists($filePath)) {
$disk->delete($filePath);
}
+
return;
}
@@ -936,66 +881,55 @@ class CreateInvoiceValidation extends CreateRecord
$serialNumbers = [];
$validRowsFound = false;
- foreach ($rows as $index => $row)
- {
- if ($index == 0) continue; // Skip header
+ foreach ($rows as $index => $row) {
+ if ($index == 0) {
+ continue;
+ } // Skip header
$materialCode = trim($row[0]);
$serialNumber = trim($row[1]);
- if (empty($materialCode) && empty($serialNumber))
- {
+ if (empty($materialCode) && empty($serialNumber)) {
continue;
}
- if (!empty($materialCode))
- {
- if (Str::length($materialCode) < 6 || !ctype_alnum($materialCode))
- {
+ if (! empty($materialCode)) {
+ if (Str::length($materialCode) < 6 || ! ctype_alnum($materialCode)) {
$invalidMatCodes[] = $materialCode;
+
continue;
- }
- else
- {
+ } else {
if (empty($serialNumber)) {
$missingSerials[] = $materialCode;
- }
- else if (Str::length($serialNumber) < 9 || !ctype_alnum($serialNumber))
- {
+ } elseif (Str::length($serialNumber) < 9 || ! ctype_alnum($serialNumber)) {
$invalidSerCodes[] = $serialNumber;
- }
- else
- {
- if (in_array($serialNumber, $serialNumbers))
- {
+ } else {
+ if (in_array($serialNumber, $serialNumbers)) {
$duplicateSerials[] = $serialNumber;
- }
- else
- {
+ } else {
$serialNumbers[] = $serialNumber;
$materialCodes[] = $materialCode;
$validRowsFound = true;
}
}
}
- }
- else
- {
+ } else {
continue;
}
}
$uniqueInvalidCodes = array_unique($invalidMatCodes);
- if (!empty($uniqueInvalidCodes)) {
+ if (! empty($uniqueInvalidCodes)) {
Notification::make()
->title('Invalid: Item Codes')
- ->body('The following item codes should contain minimum 6 digit alpha numeric values:
' . implode(', ', $uniqueInvalidCodes))
+ ->body('The following item codes should contain minimum 6 digit alpha numeric values:
'.implode(', ', $uniqueInvalidCodes))
->danger()
->seconds(3)
->send();
$this->dispatch('playWarnSound');
+
// if ($disk->exists($filePath)) {
// $disk->delete($filePath);
// }
@@ -1004,15 +938,16 @@ class CreateInvoiceValidation extends CreateRecord
$uniqueMissingSerials = array_unique($missingSerials);
- if (!empty($uniqueMissingSerials)) {
+ if (! empty($uniqueMissingSerials)) {
Notification::make()
->title('Missing Serial Numbers')
- ->body("The following item codes doesn't have valid serial number:
" . implode(', ', $uniqueMissingSerials))
+ ->body("The following item codes doesn't have valid serial number:
".implode(', ', $uniqueMissingSerials))
->danger()
->seconds(3)
->send();
$this->dispatch('playWarnSound');
+
// if ($disk->exists($filePath)) {
// $disk->delete($filePath);
// }
@@ -1021,15 +956,16 @@ class CreateInvoiceValidation extends CreateRecord
$uniqueInvalidSerCodes = array_unique($invalidSerCodes);
- if (!empty($uniqueInvalidSerCodes)) {
+ if (! empty($uniqueInvalidSerCodes)) {
Notification::make()
->title('Invalid Serial Numbers')
- ->body('The following serial numbers should contain minimum 9 digit alpha numeric values:
' . implode(', ', $uniqueInvalidSerCodes))
+ ->body('The following serial numbers should contain minimum 9 digit alpha numeric values:
'.implode(', ', $uniqueInvalidSerCodes))
->danger()
->seconds(3)
->send();
$this->dispatch('playWarnSound');
+
// if ($disk->exists($filePath)) {
// $disk->delete($filePath);
// }
@@ -1038,22 +974,23 @@ class CreateInvoiceValidation extends CreateRecord
$uniqueDupSerCodes = array_unique($duplicateSerials);
- if (!empty($uniqueDupSerCodes)) {
+ if (! empty($uniqueDupSerCodes)) {
Notification::make()
->title('Duplicate Serial Numbers')
- ->body('The following serial numbers are already exist in invoice excel:
' . implode(', ', $uniqueDupSerCodes))
+ ->body('The following serial numbers are already exist in invoice excel:
'.implode(', ', $uniqueDupSerCodes))
->danger()
->seconds(3)
->send();
$this->dispatch('playWarnSound');
+
// if ($disk->exists($filePath)) {
// $disk->delete($filePath);
// }
return;
}
- if (!$validRowsFound) {
+ if (! $validRowsFound) {
Notification::make()
->title('Invalid Serial Invoice')
->danger() // This makes the notification red to indicate an error
@@ -1065,12 +1002,13 @@ class CreateInvoiceValidation extends CreateRecord
if ($disk->exists($filePath)) {
$disk->delete($filePath);
}
+
return;
}
$uniqueCodes = array_unique($materialCodes);
- //itemNotFound
+ // itemNotFound
$matchedItems = StickerMaster::with('item')
->whereHas('item', function ($query) use ($uniqueCodes) {
$query->whereIn('code', $uniqueCodes);
@@ -1081,11 +1019,10 @@ class CreateInvoiceValidation extends CreateRecord
$missingCodes = array_diff($uniqueCodes, $matchedCodes);
- if (!empty($missingCodes))
- {
+ if (! empty($missingCodes)) {
$missingCount = count($missingCodes);
- $message = $missingCount > 10 ? "'$missingCount' item codes are not found in database." : 'The following item codes are not found in database:
' . implode(', ', $missingCodes); //->where('plant_id', $plantId)
+ $message = $missingCount > 10 ? "'$missingCount' item codes are not found in database." : 'The following item codes are not found in database:
'.implode(', ', $missingCodes); // ->where('plant_id', $plantId)
Notification::make()
->title('Unknown: Item Codes')
@@ -1102,7 +1039,7 @@ class CreateInvoiceValidation extends CreateRecord
return;
}
- //plantNotFound
+ // plantNotFound
$matchedItems = StickerMaster::with('item')
->whereHas('item', function ($query) use ($uniqueCodes, $plantId) {
$query->whereIn('code', $uniqueCodes)->where('plant_id', $plantId);
@@ -1113,11 +1050,10 @@ class CreateInvoiceValidation extends CreateRecord
$missingCodes = array_diff($uniqueCodes, $matchedCodes);
- if (!empty($missingCodes))
- {
+ if (! empty($missingCodes)) {
$missingCount = count($missingCodes);
- $message = $missingCount > 10 ? "'$missingCount' item codes are not found in database for choosed plant." : 'The following item codes are not found in database for choosed plant:
' . implode(', ', $missingCodes);
+ $message = $missingCount > 10 ? "'$missingCount' item codes are not found in database for choosed plant." : 'The following item codes are not found in database for choosed plant:
'.implode(', ', $missingCodes);
Notification::make()
->title('Unknown: Item Codes')
@@ -1134,15 +1070,14 @@ class CreateInvoiceValidation extends CreateRecord
}
$invalidCodes = $matchedItems
- ->filter(fn ($sticker) => !empty($sticker->material_type)) //filter invalid
- ->pluck('item.code')
- ->toArray();
+ ->filter(fn ($sticker) => ! empty($sticker->material_type)) // filter invalid
+ ->pluck('item.code')
+ ->toArray();
- if (!empty($invalidCodes))
- {
+ if (! empty($invalidCodes)) {
$missingCount = count($invalidCodes);
- $message = $missingCount > 10 ? "'$missingCount' Material Invoice item codes found." : "'Material Invoice' item codes found:
" . implode(', ', $invalidCodes);
+ $message = $missingCount > 10 ? "'$missingCount' Material Invoice item codes found." : "'Material Invoice' item codes found:
".implode(', ', $invalidCodes);
Notification::make()
->title('Invalid: Item Codes')
@@ -1159,15 +1094,14 @@ class CreateInvoiceValidation extends CreateRecord
}
$missPackCodes = $matchedItems
- ->filter(fn ($sticker) => empty($sticker->tube_sticker_motor) && empty($sticker->pack_slip_motor) && empty($sticker->tube_sticker_pump) && empty($sticker->pack_slip_pump) && empty($sticker->tube_sticker_pumpset) && empty($sticker->pack_slip_pumpset) && empty($sticker->panel_box_code)) //filter invalid
- ->pluck('item.code')
- ->toArray();
+ ->filter(fn ($sticker) => empty($sticker->tube_sticker_motor) && empty($sticker->pack_slip_motor) && empty($sticker->tube_sticker_pump) && empty($sticker->pack_slip_pump) && empty($sticker->tube_sticker_pumpset) && empty($sticker->pack_slip_pumpset) && empty($sticker->panel_box_code)) // filter invalid
+ ->pluck('item.code')
+ ->toArray();
- if (!empty($missPackCodes))
- {
+ if (! empty($missPackCodes)) {
$missingCount = count($missPackCodes);
- $message = $missingCount > 10 ? "'$missingCount' item codes doesn't have valid package type to proceed!" : "The following 'Item Code' doesn't have valid package type:
" . implode(', ', $missPackCodes);
+ $message = $missingCount > 10 ? "'$missingCount' item codes doesn't have valid package type to proceed!" : "The following 'Item Code' doesn't have valid package type:
".implode(', ', $missPackCodes);
Notification::make()
->title('Invalid: Item Codes')
@@ -1187,29 +1121,28 @@ class CreateInvoiceValidation extends CreateRecord
$newQuan = 0;
$inserted = 0;
- foreach ($rows as $index => $row)
- {
- if ($index == 0) // Skip header;
- {
+ foreach ($rows as $index => $row) {
+ if ($index == 0) { // Skip header;
InvoiceValidation::where('invoice_number', $invoiceNumber)
- ->where(function($query) {
+ ->where(function ($query) {
$query->whereNull('motor_scanned_status')->orWhere('motor_scanned_status', '');
})
- ->where(function($query) {
+ ->where(function ($query) {
$query->whereNull('pump_scanned_status')->orWhere('pump_scanned_status', '');
})
- ->where(function($query) {
+ ->where(function ($query) {
$query->whereNull('capacitor_scanned_status')->orWhere('capacitor_scanned_status', '');
})
- ->where(function($query) {
+ ->where(function ($query) {
$query->whereNull('scanned_status_set')->orWhere('scanned_status_set', '');
})
- ->where(function($query) {
+ ->where(function ($query) {
$query->whereNull('scanned_status')->orWhere('scanned_status', '');
})
- ->forceDelete(); //->delete();
+ ->forceDelete(); // ->delete();
$newQuan = InvoiceValidation::where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->count();
+
continue;
}
@@ -1220,13 +1153,15 @@ class CreateInvoiceValidation extends CreateRecord
continue;
}
- $sNoExist = InvoiceValidation::where('serial_number', $serialNumber)->where('plant_id', $plantId)->exists(); //->pluck('serial_number')
+ $sNoExist = InvoiceValidation::where('serial_number', $serialNumber)->where('plant_id', $plantId)->exists(); // ->pluck('serial_number')
- if ($sNoExist) { continue; }
+ if ($sNoExist) {
+ continue;
+ }
$sticker = StickerMaster::where('plant_id', $plantId)->whereHas('item', function ($query) use ($materialCode) {
- $query->where('plant_id', $this->plantId)->where('code', $materialCode); //Check if item.code matches Excel's materialCode
- })->first();
+ $query->where('plant_id', $this->plantId)->where('code', $materialCode); // Check if item.code matches Excel's materialCode
+ })->first();
if ($sticker) {
InvoiceValidation::create([
@@ -1234,22 +1169,21 @@ class CreateInvoiceValidation extends CreateRecord
'plant_id' => $plantId,
'invoice_number' => $invoiceNumber,
'serial_number' => $serialNumber,
- 'operator_id'=> $operatorName,
+ 'operator_id' => $operatorName,
]);
$inserted++;
}
}
- if ($inserted > 0 || $oldQuan != $newQuan)
- {
+ if ($inserted > 0 || $oldQuan != $newQuan) {
Notification::make()
- ->title("Serial invoice successfully updated.")
+ ->title('Serial invoice successfully updated.')
->success()
->seconds(1)
->send();
Notification::make()
- ->title("Start the scanning process!")
+ ->title('Start the scanning process!')
->body("'$inserted' new serial invoice records were inserted.")
->info()
// ->success()
@@ -1266,19 +1200,16 @@ class CreateInvoiceValidation extends CreateRecord
'invoice_number' => $invoiceNumber,
'serial_number' => null,
'total_quantity' => $totalQuantity,
- 'scanned_quantity'=> $scannedQuantity,
+ 'scanned_quantity' => $scannedQuantity,
]);
- if ($totalQuantity == $scannedQuantity)
- {
+ if ($totalQuantity == $scannedQuantity) {
if ($disk->exists($filePath)) {
$disk->delete($filePath);
}
$this->dispatch('refreshCompletedInvoice', invoiceNumber: $invoiceNumber, plantId: $plantId, isSerial: true);
- }
- else
- {
+ } else {
// if ($disk->exists($filePath)) {
// $disk->delete($filePath);
// }
@@ -1287,11 +1218,9 @@ class CreateInvoiceValidation extends CreateRecord
// $this->dispatch( (!empty($hasRecords) && $hasRecords) ? 'refreshMaterialInvoiceData' : 'refreshInvoiceData', invoiceNumber: $invoiceNumber, plantId: $plantId, onCapFocus: false); //$this->invoiceNumber
$this->dispatch('refreshInvoiceData', invoiceNumber: $invoiceNumber, plantId: $plantId, onCapFocus: false);
}
- }
- else
- {
+ } else {
Notification::make()
- ->title("Update Failed: Serial Invoice")
+ ->title('Update Failed: Serial Invoice')
->body("No new records were inserted for Serial Invoice : '$invoiceNumber'.")
->danger()
->seconds(3)
@@ -1305,7 +1234,7 @@ class CreateInvoiceValidation extends CreateRecord
'invoice_number' => $invoiceNumber,
'serial_number' => null,
'total_quantity' => $totalQuantity,
- 'scanned_quantity'=> $scannedQuantity,
+ 'scanned_quantity' => $scannedQuantity,
]);
// if ($disk->exists($filePath)) {
@@ -1313,11 +1242,10 @@ class CreateInvoiceValidation extends CreateRecord
// }
$this->dispatch('refreshEmptyInvoice', invoiceNumber: $invoiceNumber, plantId: $plantId);
+
return;
}
- }
- else
- {
+ } else {
Notification::make()
->title('Updated Invoice Not Found')
->body("Import the updated 'Serial Invoice' file to proceed..!")
@@ -1332,27 +1260,29 @@ class CreateInvoiceValidation extends CreateRecord
'invoice_number' => $invoiceNumber,
'serial_number' => null,
'total_quantity' => 0,
- 'scanned_quantity'=> 0,
+ 'scanned_quantity' => 0,
]);
$this->dispatch('refreshEmptyInvoice', invoiceNumber: $invoiceNumber, plantId: $plantId);
+
return;
}
}
}
+
return;
}
}
- $filename = $invoiceNumber . '.xlsx';
+ $filename = $invoiceNumber.'.xlsx';
$directory = 'uploads/temp';
$disk = Storage::disk('local');
- $filePath = $directory . '/' . $filename;
- $fullPath = null; //$fullPath = $disk->path($filePath);
+ $filePath = $directory.'/'.$filename;
+ $fullPath = null; // $fullPath = $disk->path($filePath);
// Check if file exists
if ($disk->exists($filePath)) {
$fullPath = $disk->path($filePath);
- //$fullPath = session('uploaded_invoice_path');
+ // $fullPath = session('uploaded_invoice_path');
// Notification::make()
// ->title('File exists.')
// ->success()
@@ -1371,21 +1301,22 @@ class CreateInvoiceValidation extends CreateRecord
'invoice_number' => $invoiceNumber,
'serial_number' => null,
'total_quantity' => 0,
- 'scanned_quantity'=> 0,
+ 'scanned_quantity' => 0,
]);
$this->dispatch('refreshEmptyInvoice', invoiceNumber: $invoiceNumber, plantId: $plantId);
+
return;
}
- if (!file_exists($fullPath))
- {
+ if (! file_exists($fullPath)) {
Notification::make()
->title('Invoice file doesn\'t exist.')
->danger()
->seconds(3)
->send();
- $this->dispatch('playWarnSound');
- return;
+ $this->dispatch('playWarnSound');
+
+ return;
}
@@ -1395,16 +1326,16 @@ class CreateInvoiceValidation extends CreateRecord
// Compare with invoice number
if ($uploadedFilename != $invoiceNumber) {
Notification::make()
- ->title("Uploaded file name does not match the invoice number.")
+ ->title('Uploaded file name does not match the invoice number.')
->danger()
->seconds(3)
->send();
- $this->dispatch('playWarnSound');
+ $this->dispatch('playWarnSound');
+
return;
}
- if ($fullPath && file_exists($fullPath))
- {
+ if ($fullPath && file_exists($fullPath)) {
// Now you can read/process the file here
$rows = Excel::toArray(null, $fullPath)[0];
// $collection = Excel::toCollection(null, $fullPath);
@@ -1420,8 +1351,7 @@ class CreateInvoiceValidation extends CreateRecord
// // Get the rows
// $rows = $excelImport->getRows();
- if ((count($rows) - 1) <= 0)
- {
+ if ((count($rows) - 1) <= 0) {
Notification::make()
->title('Records Not Found')
->body("Import the valid 'Invoice' file to proceed..!")
@@ -1433,61 +1363,52 @@ class CreateInvoiceValidation extends CreateRecord
if ($disk->exists($filePath)) {
$disk->delete($filePath);
}
+
return;
}
- foreach ($rows as $index => $row)
- {
- if ($index == 0) continue;
+ foreach ($rows as $index => $row) {
+ if ($index == 0) {
+ continue;
+ }
$materialCode = trim($row[0]);
- if (!empty($materialCode)) {
- if (Str::length($materialCode) < 6)
- {
+ if (! empty($materialCode)) {
+ if (Str::length($materialCode) < 6) {
continue;
- }
- else
- {
+ } else {
$sticker = StickerMaster::where('plant_id', $plantId)->whereHas('item', function ($query) use ($materialCode) {
- $query->where('plant_id', $this->plantId)->where('code', $materialCode); //Check if item.code matches Excel's materialCode
- });
- if ($sticker->exists())
- {
- if ($sticker->first()->material_type && !empty($sticker->first()->material_type))
- {
- $invoiceType = "M";
+ $query->where('plant_id', $this->plantId)->where('code', $materialCode); // Check if item.code matches Excel's materialCode
+ });
+ if ($sticker->exists()) {
+ if ($sticker->first()->material_type && ! empty($sticker->first()->material_type)) {
+ $invoiceType = 'M';
+ break;
+ } else {
+ $invoiceType = 'S';
break;
}
- else
- {
- $invoiceType = "S";
- break;
- }
- }
- else
- {
+ } else {
continue;
}
}
- }
- else
- {
+ } else {
continue;
}
}
- if ($invoiceType == 'M')
- {
+ if ($invoiceType == 'M') {
$invalidMatCodes = [];
$materialCodes = [];
$missingQuantities = [];
$invalidMatQuan = [];
$validRowsFound = false;
- foreach ($rows as $index => $row)
- {
- if ($index == 0) continue; // Skip header
+ foreach ($rows as $index => $row) {
+ if ($index == 0) {
+ continue;
+ } // Skip header
$materialCode = trim($row[0]);
$materialQuantity = trim($row[1]);
@@ -1496,48 +1417,38 @@ class CreateInvoiceValidation extends CreateRecord
continue;
}
- if (!empty($materialCode)) {
- if (Str::length($materialCode) < 6 || !ctype_alnum($materialCode))
- {
+ if (! empty($materialCode)) {
+ if (Str::length($materialCode) < 6 || ! ctype_alnum($materialCode)) {
$invalidMatCodes[] = $materialCode;
- }
- else
- {
+ } else {
if (empty($materialQuantity)) {
$missingQuantities[] = $materialCode;
- }
- else if (!is_numeric($materialQuantity))
- {
+ } elseif (! is_numeric($materialQuantity)) {
$invalidMatQuan[] = $materialCode;
- }
- else if ($materialQuantity == 0)
- {
+ } elseif ($materialQuantity == 0) {
$invalidMatQuan[] = $materialCode;
- }
- else
- {
+ } else {
$materialCodes[] = $materialCode;
$validRowsFound = true;
}
}
- }
- else
- {
+ } else {
continue;
}
}
$uniqueInvalidCodes = array_unique($invalidMatCodes);
- if (!empty($uniqueInvalidCodes)) {
+ if (! empty($uniqueInvalidCodes)) {
Notification::make()
->title('Invalid: Item Codes')
- ->body('The following item codes should contain minimum 6 digit alpha numeric values:
' . implode(', ', $uniqueInvalidCodes))
+ ->body('The following item codes should contain minimum 6 digit alpha numeric values:
'.implode(', ', $uniqueInvalidCodes))
->danger()
->seconds(2)
->send();
$this->dispatch('playWarnSound');
+
// if ($disk->exists($filePath)) {
// $disk->delete($filePath);
// }
@@ -1546,15 +1457,16 @@ class CreateInvoiceValidation extends CreateRecord
$uniqueMissingQuanCodes = array_unique($missingQuantities);
- if (!empty($uniqueMissingQuanCodes)) {
+ if (! empty($uniqueMissingQuanCodes)) {
Notification::make()
->title('Missing Material Quantity')
- ->body("The following item codes doesn't have valid material quantity:
" . implode(', ', $uniqueMissingQuanCodes))
+ ->body("The following item codes doesn't have valid material quantity:
".implode(', ', $uniqueMissingQuanCodes))
->danger()
->seconds(2)
->send();
$this->dispatch('playWarnSound');
+
// if ($disk->exists($filePath)) {
// $disk->delete($filePath);
// }
@@ -1563,22 +1475,23 @@ class CreateInvoiceValidation extends CreateRecord
$uniqueInvalidMatQuan = array_unique($invalidMatQuan);
- if (!empty($uniqueInvalidMatQuan)) {
+ if (! empty($uniqueInvalidMatQuan)) {
Notification::make()
->title('Invalid Material Quantity')
- ->body("The following item codes doesn't have valid material quantity:
" . implode(', ', $uniqueInvalidMatQuan))
+ ->body("The following item codes doesn't have valid material quantity:
".implode(', ', $uniqueInvalidMatQuan))
->danger()
->seconds(2)
->send();
$this->dispatch('playWarnSound');
+
// if ($disk->exists($filePath)) {
// $disk->delete($filePath);
// }
return;
}
- if (!$validRowsFound) {
+ if (! $validRowsFound) {
Notification::make()
->title('Invalid Material Invoice')
->danger() // This makes the notification red to indicate an error
@@ -1590,12 +1503,13 @@ class CreateInvoiceValidation extends CreateRecord
if ($disk->exists($filePath)) {
$disk->delete($filePath);
}
+
return;
}
$uniqueCodes = array_unique($materialCodes);
- //itemNotFound
+ // itemNotFound
$matchedItems = StickerMaster::with('item')
->whereHas('item', function ($query) use ($uniqueCodes) {
$query->whereIn('code', $uniqueCodes);
@@ -1606,11 +1520,10 @@ class CreateInvoiceValidation extends CreateRecord
$missingCodes = array_diff($uniqueCodes, $matchedCodes);
- if (!empty($missingCodes))
- {
+ if (! empty($missingCodes)) {
$missingCount = count($missingCodes);
- $message = $missingCount > 10 ? "'$missingCount' item codes are not found in database." : 'The following item codes are not found in database:
' . implode(', ', $missingCodes);
+ $message = $missingCount > 10 ? "'$missingCount' item codes are not found in database." : 'The following item codes are not found in database:
'.implode(', ', $missingCodes);
Notification::make()
->title('Unknown: Item Codes')
@@ -1618,7 +1531,7 @@ class CreateInvoiceValidation extends CreateRecord
->danger()
->seconds(2)
->send();
- $this->dispatch('playWarnSound');
+ $this->dispatch('playWarnSound');
// if ($disk->exists($filePath)) {
// $disk->delete($filePath);
@@ -1626,7 +1539,7 @@ class CreateInvoiceValidation extends CreateRecord
return;
}
- //plantNotFound
+ // plantNotFound
$matchedItems = StickerMaster::with('item')
->whereHas('item', function ($query) use ($uniqueCodes, $plantId) {
$query->whereIn('code', $uniqueCodes)->where('plant_id', $plantId);
@@ -1637,11 +1550,10 @@ class CreateInvoiceValidation extends CreateRecord
$missingCodes = array_diff($uniqueCodes, $matchedCodes);
- if (!empty($missingCodes))
- {
+ if (! empty($missingCodes)) {
$missingCount = count($missingCodes);
- $message = $missingCount > 10 ? "'$missingCount' item codes are not found in database for choosed plant." : 'The following item codes are not found in database for choosed plant:
' . implode(', ', $missingCodes);
+ $message = $missingCount > 10 ? "'$missingCount' item codes are not found in database for choosed plant." : 'The following item codes are not found in database for choosed plant:
'.implode(', ', $missingCodes);
Notification::make()
->title('Unknown: Item Codes')
@@ -1650,6 +1562,7 @@ class CreateInvoiceValidation extends CreateRecord
->seconds(2)
->send();
$this->dispatch('playWarnSound');
+
// if ($disk->exists($filePath)) {
// $disk->delete($filePath);
// }
@@ -1657,15 +1570,14 @@ class CreateInvoiceValidation extends CreateRecord
}
$invalidCodes = $matchedItems
- ->filter(fn ($sticker) => empty($sticker->material_type)) //filter invalid
- ->pluck('item.code')
- ->toArray();
+ ->filter(fn ($sticker) => empty($sticker->material_type)) // filter invalid
+ ->pluck('item.code')
+ ->toArray();
- if (!empty($invalidCodes))
- {
+ if (! empty($invalidCodes)) {
$missingCount = count($invalidCodes);
- $message = $missingCount > 10 ? "'$missingCount' Serial Invoice item codes found." : "'Serial Invoice' item codes found:
" . implode(', ', $invalidCodes);
+ $message = $missingCount > 10 ? "'$missingCount' Serial Invoice item codes found." : "'Serial Invoice' item codes found:
".implode(', ', $invalidCodes);
Notification::make()
->title('Invalid: Item Codes')
@@ -1673,7 +1585,7 @@ class CreateInvoiceValidation extends CreateRecord
->danger()
->seconds(2)
->send();
- $this->dispatch('playWarnSound');
+ $this->dispatch('playWarnSound');
// if ($disk->exists($filePath)) {
// $disk->delete($filePath);
@@ -1685,19 +1597,18 @@ class CreateInvoiceValidation extends CreateRecord
$zeroQtyCodes = [];
$notDivisibleCodes = [];
- foreach ($matchedItems as $sticker)
- {
+ foreach ($matchedItems as $sticker) {
$code = $sticker->item->code;
$materialType = $sticker->material_type;
- if ($materialType == 2)
- {
+ if ($materialType == 2) {
$bundleQty = $sticker->bundle_quantity ?? 0;
$totalExcelQty = 0;
- foreach ($rows as $index => $row)
- {
- if ($index == 0) continue; // Skip header
+ foreach ($rows as $index => $row) {
+ if ($index == 0) {
+ continue;
+ } // Skip header
$excelCode = trim($row[0]);
$excelMatQty = trim($row[1]);
@@ -1713,16 +1624,18 @@ class CreateInvoiceValidation extends CreateRecord
if ($totalExcelQty == 0) {
$zeroQtyCodes[] = $code;
- } else if (!is_numeric($totalExcelQty)) {
+ } elseif (! is_numeric($totalExcelQty)) {
$nonNumericQtyCodes[] = $code; // Here you may want to check divisibility condition too
- } else if ($bundleQty != 0 && $totalExcelQty % $bundleQty != 0) {
+ } elseif ($bundleQty != 0 && $totalExcelQty % $bundleQty != 0) {
$notDivisibleCodes[] = $code;
}
}
}
- $showValidationNotification = function(array $codes, string $message) {
- if (count($codes) == 0) return;
+ $showValidationNotification = function (array $codes, string $message) {
+ if (count($codes) == 0) {
+ return;
+ }
$uniqueCodes = array_unique($codes);
$codeList = implode(', ', $uniqueCodes);
@@ -1733,36 +1646,32 @@ class CreateInvoiceValidation extends CreateRecord
->danger()
->seconds(2)
->send();
- $this->dispatch('playWarnSound');
+ $this->dispatch('playWarnSound');
};
- $showValidationNotification($nonNumericQtyCodes, "The following item codes contains invalid bundle quantity:");
+ $showValidationNotification($nonNumericQtyCodes, 'The following item codes contains invalid bundle quantity:');
$showValidationNotification($zeroQtyCodes, "The following item codes quantity should be greater than '0':");
- $showValidationNotification($notDivisibleCodes, "The following item codes quantity is not divisible by bundle quantity.");
-
+ $showValidationNotification($notDivisibleCodes, 'The following item codes quantity is not divisible by bundle quantity.');
if ($nonNumericQtyCodes || $zeroQtyCodes || $notDivisibleCodes) {
// if ($disk->exists($filePath)) {
// $disk->delete($filePath);
// }
return;
- }
- else
- {
+ } else {
$inserted = 0;
- foreach ($matchedItems as $sticker)
- {
+ foreach ($matchedItems as $sticker) {
$code = $sticker->item->code;
$materialType = $sticker->material_type;
// $sticker = StickerMaster::where('plant_id', $plantId)->whereHas('item', function ($query) use ($code) { $query->where('plant_id', $this->plantId)->where('code', $code); })->first();
- if ($materialType == 1)
- {
+ if ($materialType == 1) {
$totalExcelQty = 0;
- foreach ($rows as $index => $row)
- {
- if ($index == 0) continue; // Skip header
+ foreach ($rows as $index => $row) {
+ if ($index == 0) {
+ continue;
+ } // Skip header
$excelCode = trim($row[0]);
$excelMatQty = trim($row[1]);
@@ -1776,28 +1685,26 @@ class CreateInvoiceValidation extends CreateRecord
}
}
- for ($i = 0; $i < $totalExcelQty; $i++)
- {
+ for ($i = 0; $i < $totalExcelQty; $i++) {
if ($sticker) {
InvoiceValidation::create([
'sticker_master_id' => $sticker->id,
'plant_id' => $plantId,
'invoice_number' => $invoiceNumber,
'quantity' => 1,
- 'operator_id'=> $operatorName,
+ 'operator_id' => $operatorName,
]);
$inserted++;
}
}
- }
- else if ($materialType == 2)
- {
+ } elseif ($materialType == 2) {
$bundleQty = $sticker->bundle_quantity;
$totalExcelQty = 0;
- foreach ($rows as $index => $row)
- {
- if ($index == 0) continue; // Skip header
+ foreach ($rows as $index => $row) {
+ if ($index == 0) {
+ continue;
+ } // Skip header
$excelCode = trim($row[0]);
$excelMatQty = trim($row[1]);
@@ -1811,27 +1718,25 @@ class CreateInvoiceValidation extends CreateRecord
}
}
- for ($i = 0; $i < ($totalExcelQty/$bundleQty); $i++)
- {
+ for ($i = 0; $i < ($totalExcelQty / $bundleQty); $i++) {
if ($sticker) {
InvoiceValidation::create([
'sticker_master_id' => $sticker->id,
'plant_id' => $plantId,
'invoice_number' => $invoiceNumber,
'quantity' => $bundleQty,
- 'operator_id'=> $operatorName,
+ 'operator_id' => $operatorName,
]);
$inserted++;
}
}
- }
- else if ($materialType == 3)
- {
+ } elseif ($materialType == 3) {
$totalExcelQty = 0;
- foreach ($rows as $index => $row)
- {
- if ($index == 0) continue; // Skip header
+ foreach ($rows as $index => $row) {
+ if ($index == 0) {
+ continue;
+ } // Skip header
$excelCode = trim($row[0]);
$excelMatQty = trim($row[1]);
@@ -1851,17 +1756,16 @@ class CreateInvoiceValidation extends CreateRecord
'plant_id' => $plantId,
'invoice_number' => $invoiceNumber,
'quantity' => $totalExcelQty,
- 'operator_id'=> $operatorName,
+ 'operator_id' => $operatorName,
]);
$inserted++;
}
}
}
- if ($inserted > 0)
- {
+ if ($inserted > 0) {
Notification::make()
- ->title("Start the scanning process!")
+ ->title('Start the scanning process!')
->body("'$inserted' material invoice records were inserted.")
->info()
// ->success()
@@ -1876,19 +1780,16 @@ class CreateInvoiceValidation extends CreateRecord
'invoice_number' => $invoiceNumber,
'serial_number' => null,
'total_quantity' => $totalQuantity,
- 'scanned_quantity'=> $scannedQuantity,
+ 'scanned_quantity' => $scannedQuantity,
]);
- if ($totalQuantity == $scannedQuantity)
- {
+ if ($totalQuantity == $scannedQuantity) {
if ($disk->exists($filePath)) {
$disk->delete($filePath);
}
$this->dispatch('refreshCompletedInvoice', invoiceNumber: $invoiceNumber, plantId: $plantId, isSerial: false);
- }
- else
- {
+ } else {
// if ($disk->exists($filePath)) {
// $disk->delete($filePath);
// }
@@ -1897,11 +1798,9 @@ class CreateInvoiceValidation extends CreateRecord
// $this->dispatch( (!empty($hasRecords) && $hasRecords) ? 'refreshMaterialInvoiceData' : 'refreshInvoiceData', invoiceNumber: $invoiceNumber, plantId: $plantId, onCapFocus: false); //$this->invoiceNumber
$this->dispatch('refreshMaterialInvoiceData', invoiceNumber: $invoiceNumber, plantId: $plantId);
}
- }
- else
- {
+ } else {
Notification::make()
- ->title("Import Failed: Material Invoice")
+ ->title('Import Failed: Material Invoice')
->body("No new records were inserted for Material Invoice: '$invoiceNumber'.")
->danger()
->seconds(2)
@@ -1914,7 +1813,7 @@ class CreateInvoiceValidation extends CreateRecord
'invoice_number' => $invoiceNumber,
'serial_number' => null,
'total_quantity' => $totalQuantity,
- 'scanned_quantity'=> $scannedQuantity,
+ 'scanned_quantity' => $scannedQuantity,
]);
// if ($disk->exists($filePath)) {
@@ -1922,12 +1821,11 @@ class CreateInvoiceValidation extends CreateRecord
// }
$this->dispatch('refreshEmptyInvoice', invoiceNumber: $invoiceNumber, plantId: $plantId);
+
return;
}
}
- }
- else if ($invoiceType == 'S')
- {
+ } elseif ($invoiceType == 'S') {
$invalidMatCodes = [];
$materialCodes = [];
$missingSerials = [];
@@ -1936,9 +1834,10 @@ class CreateInvoiceValidation extends CreateRecord
$serialNumbers = [];
$validRowsFound = false;
- foreach ($rows as $index => $row)
- {
- if ($index == 0) continue; // Skip header
+ foreach ($rows as $index => $row) {
+ if ($index == 0) {
+ continue;
+ } // Skip header
$materialCode = trim($row[0]);
$serialNumber = trim($row[1]);
@@ -1947,23 +1846,17 @@ class CreateInvoiceValidation extends CreateRecord
continue;
}
- if (!empty($materialCode)) {
- if (Str::length($materialCode) < 6 || !ctype_alnum($materialCode))
- {
+ if (! empty($materialCode)) {
+ if (Str::length($materialCode) < 6 || ! ctype_alnum($materialCode)) {
$invalidMatCodes[] = $materialCode;
+
continue;
- }
- else
- {
+ } else {
if (empty($serialNumber)) {
$missingSerials[] = $materialCode;
- }
- else if (Str::length($serialNumber) < 9 || !ctype_alnum($serialNumber))
- {
+ } elseif (Str::length($serialNumber) < 9 || ! ctype_alnum($serialNumber)) {
$invalidSerCodes[] = $serialNumber;
- }
- else
- {
+ } else {
if (in_array($serialNumber, $serialNumbers)) {
$duplicateSerials[] = $serialNumber;
} else {
@@ -1973,23 +1866,21 @@ class CreateInvoiceValidation extends CreateRecord
}
}
}
- }
- else
- {
+ } else {
continue;
}
}
$uniqueInvalidCodes = array_unique($invalidMatCodes);
- if (!empty($uniqueInvalidCodes)) {
+ if (! empty($uniqueInvalidCodes)) {
Notification::make()
- ->title('Invalid: Item Codes')
- ->body('The following item codes should contain minimum 6 digit alpha numeric values:
' . implode(', ', $uniqueInvalidCodes))
- ->danger()
- ->seconds(3)
- ->send();
- $this->dispatch('playWarnSound');
+ ->title('Invalid: Item Codes')
+ ->body('The following item codes should contain minimum 6 digit alpha numeric values:
'.implode(', ', $uniqueInvalidCodes))
+ ->danger()
+ ->seconds(3)
+ ->send();
+ $this->dispatch('playWarnSound');
// if ($disk->exists($filePath)) {
// $disk->delete($filePath);
@@ -1999,14 +1890,14 @@ class CreateInvoiceValidation extends CreateRecord
$uniqueMissingSerials = array_unique($missingSerials);
- if (!empty($uniqueMissingSerials)) {
+ if (! empty($uniqueMissingSerials)) {
Notification::make()
- ->title('Missing Serial Numbers')
- ->body("The following item codes doesn't have valid serial number:
" . implode(', ', $uniqueMissingSerials))
- ->danger()
- ->seconds(3)
- ->send();
- $this->dispatch('playWarnSound');
+ ->title('Missing Serial Numbers')
+ ->body("The following item codes doesn't have valid serial number:
".implode(', ', $uniqueMissingSerials))
+ ->danger()
+ ->seconds(3)
+ ->send();
+ $this->dispatch('playWarnSound');
// if ($disk->exists($filePath)) {
// $disk->delete($filePath);
@@ -2016,14 +1907,14 @@ class CreateInvoiceValidation extends CreateRecord
$uniqueInvalidSerCodes = array_unique($invalidSerCodes);
- if (!empty($uniqueInvalidSerCodes)) {
+ if (! empty($uniqueInvalidSerCodes)) {
Notification::make()
- ->title('Invalid Serial Numbers')
- ->body('The following serial numbers should contain minimum 9 digit alpha numeric values:
' . implode(', ', $uniqueInvalidSerCodes))
- ->danger()
- ->seconds(3)
- ->send();
- $this->dispatch('playWarnSound');
+ ->title('Invalid Serial Numbers')
+ ->body('The following serial numbers should contain minimum 9 digit alpha numeric values:
'.implode(', ', $uniqueInvalidSerCodes))
+ ->danger()
+ ->seconds(3)
+ ->send();
+ $this->dispatch('playWarnSound');
// if ($disk->exists($filePath)) {
// $disk->delete($filePath);
@@ -2033,14 +1924,14 @@ class CreateInvoiceValidation extends CreateRecord
$uniqueDupSerCodes = array_unique($duplicateSerials);
- if (!empty($uniqueDupSerCodes)) {
+ if (! empty($uniqueDupSerCodes)) {
Notification::make()
->title('Duplicate Serial Numbers')
- ->body('The following serial numbers are already exist in invoice excel:
' . implode(', ', $uniqueDupSerCodes))
+ ->body('The following serial numbers are already exist in invoice excel:
'.implode(', ', $uniqueDupSerCodes))
->danger()
->seconds(3)
->send();
- $this->dispatch('playWarnSound');
+ $this->dispatch('playWarnSound');
// if ($disk->exists($filePath)) {
// $disk->delete($filePath);
@@ -2048,7 +1939,7 @@ class CreateInvoiceValidation extends CreateRecord
return;
}
- if (!$validRowsFound) {
+ if (! $validRowsFound) {
Notification::make()
->title('Invalid Serial Invoice')
->danger() // This makes the notification red to indicate an error
@@ -2060,12 +1951,13 @@ class CreateInvoiceValidation extends CreateRecord
if ($disk->exists($filePath)) {
$disk->delete($filePath);
}
+
return;
}
$uniqueCodes = array_unique($materialCodes);
- //itemNotFound
+ // itemNotFound
$matchedItems = StickerMaster::with('item')
->whereHas('item', function ($query) use ($uniqueCodes) {
$query->whereIn('code', $uniqueCodes);
@@ -2086,11 +1978,10 @@ class CreateInvoiceValidation extends CreateRecord
$missingCodes = array_diff($uniqueCodes, $matchedCodes);
- if (!empty($missingCodes))
- {
+ if (! empty($missingCodes)) {
$missingCount = count($missingCodes);
- $message = $missingCount > 10 ? "'$missingCount' item codes are not found in database." : 'The following item codes are not found in database:
' . implode(', ', $missingCodes);
+ $message = $missingCount > 10 ? "'$missingCount' item codes are not found in database." : 'The following item codes are not found in database:
'.implode(', ', $missingCodes);
Notification::make()
->title('Unknown: Item Codes')
@@ -2098,7 +1989,7 @@ class CreateInvoiceValidation extends CreateRecord
->danger()
->seconds(3)
->send();
- $this->dispatch('playWarnSound');
+ $this->dispatch('playWarnSound');
// if ($disk->exists($filePath)) {
// $disk->delete($filePath);
@@ -2106,7 +1997,7 @@ class CreateInvoiceValidation extends CreateRecord
return;
}
- //plantNotFound
+ // plantNotFound
$matchedItems = StickerMaster::with('item')
->whereHas('item', function ($query) use ($uniqueCodes, $plantId) {
$query->whereIn('code', $uniqueCodes)->where('plant_id', $plantId);
@@ -2117,11 +2008,10 @@ class CreateInvoiceValidation extends CreateRecord
$missingCodes = array_diff($uniqueCodes, $matchedCodes);
- if (!empty($missingCodes))
- {
+ if (! empty($missingCodes)) {
$missingCount = count($missingCodes);
- $message = $missingCount > 10 ? "'$missingCount' item codes are not found in database for choosed plant." : 'The following item codes are not found in database for choosed plant:
' . implode(', ', $missingCodes);
+ $message = $missingCount > 10 ? "'$missingCount' item codes are not found in database for choosed plant." : 'The following item codes are not found in database for choosed plant:
'.implode(', ', $missingCodes);
Notification::make()
->title('Unknown: Item Codes')
@@ -2131,6 +2021,7 @@ class CreateInvoiceValidation extends CreateRecord
->send();
$this->dispatch('playWarnSound');
+
// if ($disk->exists($filePath)) {
// $disk->delete($filePath);
// }
@@ -2138,15 +2029,14 @@ class CreateInvoiceValidation extends CreateRecord
}
$invalidCodes = $matchedItems
- ->filter(fn ($sticker) => !empty($sticker->material_type)) //filter invalid
- ->pluck('item.code')
- ->toArray();
+ ->filter(fn ($sticker) => ! empty($sticker->material_type)) // filter invalid
+ ->pluck('item.code')
+ ->toArray();
- if (!empty($invalidCodes))
- {
+ if (! empty($invalidCodes)) {
$missingCount = count($invalidCodes);
- $message = $missingCount > 10 ? "'$missingCount' Material Invoice item codes found." : "'Material Invoice' item codes found:
" . implode(', ', $invalidCodes);
+ $message = $missingCount > 10 ? "'$missingCount' Material Invoice item codes found." : "'Material Invoice' item codes found:
".implode(', ', $invalidCodes);
Notification::make()
->title('Invalid: Item Codes')
@@ -2156,6 +2046,7 @@ class CreateInvoiceValidation extends CreateRecord
->send();
$this->dispatch('playWarnSound');
+
// if ($disk->exists($filePath)) {
// $disk->delete($filePath);
// }
@@ -2163,15 +2054,14 @@ class CreateInvoiceValidation extends CreateRecord
}
$missPackCodes = $matchedItems
- ->filter(fn ($sticker) => empty($sticker->tube_sticker_motor) && empty($sticker->pack_slip_motor) && empty($sticker->tube_sticker_pump) && empty($sticker->pack_slip_pump) && empty($sticker->tube_sticker_pumpset) && empty($sticker->pack_slip_pumpset) && empty($sticker->panel_box_code))
- ->pluck('item.code')
- ->toArray();
+ ->filter(fn ($sticker) => empty($sticker->tube_sticker_motor) && empty($sticker->pack_slip_motor) && empty($sticker->tube_sticker_pump) && empty($sticker->pack_slip_pump) && empty($sticker->tube_sticker_pumpset) && empty($sticker->pack_slip_pumpset) && empty($sticker->panel_box_code))
+ ->pluck('item.code')
+ ->toArray();
- if (!empty($missPackCodes))
- {
+ if (! empty($missPackCodes)) {
$missingCount = count($missPackCodes);
- $message = $missingCount > 10 ? "'$missingCount' item codes doesn't have valid package type to proceed!" : "The following 'Item Code' doesn't have valid package type:
" . implode(', ', $missPackCodes);
+ $message = $missingCount > 10 ? "'$missingCount' item codes doesn't have valid package type to proceed!" : "The following 'Item Code' doesn't have valid package type:
".implode(', ', $missPackCodes);
Notification::make()
->title('Invalid: Item Codes')
@@ -2181,6 +2071,7 @@ class CreateInvoiceValidation extends CreateRecord
->send();
$this->dispatch('playWarnSound');
+
// if ($disk->exists($filePath)) {
// $disk->delete($filePath);
// }
@@ -2190,15 +2081,16 @@ class CreateInvoiceValidation extends CreateRecord
$existingSerialNumbers = InvoiceValidation::whereIn('serial_number', $serialNumbers)->where('plant_id', $plantId)->pluck('serial_number')->toArray();
// If there are duplicates, notify and stop the process
- if (!empty($existingSerialNumbers)) {
+ if (! empty($existingSerialNumbers)) {
Notification::make()
->title('Duplicate Serial Numbers')
- ->body('The following serial numbers are already exist in database:
' . implode(', ', $existingSerialNumbers))
+ ->body('The following serial numbers are already exist in database:
'.implode(', ', $existingSerialNumbers))
->danger()
->seconds(3)
->send();
$this->dispatch('playWarnSound');
+
// if ($disk->exists($filePath)) {
// $disk->delete($filePath);
// }
@@ -2206,9 +2098,10 @@ class CreateInvoiceValidation extends CreateRecord
}
$inserted = 0;
- foreach ($rows as $index => $row)
- {
- if ($index == 0) continue;
+ foreach ($rows as $index => $row) {
+ if ($index == 0) {
+ continue;
+ }
$materialCode = trim($row[0]);
$serialNumber = trim($row[1]);
@@ -2218,8 +2111,8 @@ class CreateInvoiceValidation extends CreateRecord
}
$sticker = StickerMaster::where('plant_id', $plantId)->whereHas('item', function ($query) use ($materialCode) {
- $query->where('plant_id', $this->plantId)->where('code', $materialCode); //Check if item.code matches Excel's materialCode
- })->first();
+ $query->where('plant_id', $this->plantId)->where('code', $materialCode); // Check if item.code matches Excel's materialCode
+ })->first();
if ($sticker) {
InvoiceValidation::create([
@@ -2227,16 +2120,15 @@ class CreateInvoiceValidation extends CreateRecord
'plant_id' => $plantId,
'invoice_number' => $invoiceNumber,
'serial_number' => $serialNumber,
- 'operator_id'=> $operatorName,
+ 'operator_id' => $operatorName,
]);
$inserted++;
}
}
- if ($inserted > 0)
- {
+ if ($inserted > 0) {
Notification::make()
- ->title("Start the scanning process!")
+ ->title('Start the scanning process!')
->body("'$inserted' serial invoice records were inserted.")
->info()
// ->success()
@@ -2252,19 +2144,16 @@ class CreateInvoiceValidation extends CreateRecord
'invoice_number' => $invoiceNumber,
'serial_number' => null,
'total_quantity' => $totalQuantity,
- 'scanned_quantity'=> $scannedQuantity,
+ 'scanned_quantity' => $scannedQuantity,
]);
- if ($totalQuantity == $scannedQuantity)
- {
+ if ($totalQuantity == $scannedQuantity) {
if ($disk->exists($filePath)) {
$disk->delete($filePath);
}
$this->dispatch('refreshCompletedInvoice', invoiceNumber: $invoiceNumber, plantId: $plantId, isSerial: true);
- }
- else
- {
+ } else {
// if ($disk->exists($filePath)) {
// $disk->delete($filePath);
// }
@@ -2273,16 +2162,14 @@ class CreateInvoiceValidation extends CreateRecord
// $this->dispatch( (!empty($hasRecords) && $hasRecords) ? 'refreshMaterialInvoiceData' : 'refreshInvoiceData', invoiceNumber: $invoiceNumber, plantId: $plantId, onCapFocus: false); //$this->invoiceNumber
$this->dispatch('refreshInvoiceData', invoiceNumber: $invoiceNumber, plantId: $plantId, onCapFocus: false);
}
- }
- else
- {
+ } else {
Notification::make()
- ->title("Import Failed: Serial Invoice")
+ ->title('Import Failed: Serial Invoice')
->body("No new records were inserted for Serial Invoice : '$invoiceNumber'.")
->danger()
->seconds(3)
->send();
- $this->dispatch('playWarnSound');
+ $this->dispatch('playWarnSound');
$totalQuantity = InvoiceValidation::where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->count();
$scannedQuantity = InvoiceValidation::where('invoice_number', $invoiceNumber)->where('scanned_status', 'Scanned')->where('plant_id', $plantId)->count();
@@ -2291,7 +2178,7 @@ class CreateInvoiceValidation extends CreateRecord
'invoice_number' => $invoiceNumber,
'serial_number' => null,
'total_quantity' => $totalQuantity,
- 'scanned_quantity'=> $scannedQuantity,
+ 'scanned_quantity' => $scannedQuantity,
]);
// if ($disk->exists($filePath)) {
@@ -2299,18 +2186,17 @@ class CreateInvoiceValidation extends CreateRecord
// }
$this->dispatch('refreshEmptyInvoice', invoiceNumber: $invoiceNumber, plantId: $plantId);
+
return;
}
- }
- else
- {
+ } else {
Notification::make()
->title('Invoice Type Not Found')
->body("Import the valid 'Invoice' file to proceed..!")
->danger()
->seconds(3)
->send();
- $this->dispatch('playWarnSound');
+ $this->dispatch('playWarnSound');
// if ($disk->exists($filePath)) {
// $disk->delete($filePath);
@@ -2325,32 +2211,23 @@ class CreateInvoiceValidation extends CreateRecord
$this->plantId = $this->form->getState()['plant_id'] ?? '';
$this->invoiceNumber = $this->form->getState()['invoice_number'] ?? '';
- if (!empty($this->invoiceNumber)) {
+ if (! empty($this->invoiceNumber)) {
$hasInvoice = InvoiceValidation::where('invoice_number', $this->invoiceNumber)->where('plant_id', $this->plantId)->first();
- if (empty($hasInvoice) || !$hasInvoice)
- {
+ if (empty($hasInvoice) || ! $hasInvoice) {
$this->dispatch('refreshEmptyInvoice', invoiceNumber: $this->invoiceNumber, plantId: $this->plantId);
- }
- else
- {
+ } else {
$totalQuantity = InvoiceValidation::where('invoice_number', $this->invoiceNumber)->where('plant_id', $this->plantId)->count();
$scannedQuantity = InvoiceValidation::where('invoice_number', $this->invoiceNumber)->where('scanned_status', 'Scanned')->where('plant_id', $this->plantId)->count();
- if ($totalQuantity == $scannedQuantity)
- {
+ if ($totalQuantity == $scannedQuantity) {
$this->dispatch('refreshCompletedInvoice', invoiceNumber: $this->invoiceNumber, plantId: $this->plantId, isSerial: true);
- }
- else
- {
+ } else {
$hasRecords = $hasInvoice->stickerMasterRelation->material_type ?? null;
- //$this->dispatch( (!empty($hasRecords) && $hasRecords) ? 'refreshMaterialInvoiceData' : 'refreshInvoiceData', invoiceNumber: $this->invoiceNumber, plantId: $this->plantId);
+ // $this->dispatch( (!empty($hasRecords) && $hasRecords) ? 'refreshMaterialInvoiceData' : 'refreshInvoiceData', invoiceNumber: $this->invoiceNumber, plantId: $this->plantId);
- if (!empty($hasRecords) && $hasRecords)
- {
+ if (! empty($hasRecords) && $hasRecords) {
$this->dispatch('refreshMaterialInvoiceData', invoiceNumber: $this->invoiceNumber, plantId: $this->plantId);
- }
- else
- {
+ } else {
$this->dispatch('refreshInvoiceData', invoiceNumber: $this->invoiceNumber, plantId: $this->plantId, onCapFocus: false);
}
}
@@ -2358,13 +2235,14 @@ class CreateInvoiceValidation extends CreateRecord
}
}
- public function getMail(){
+ public function getMail()
+ {
$plantId = $this->form->getState()['plant_id'];
$this->plantId = $plantId;
$mInvoiceType = 'Serial';
$mPlantName = Plant::where('id', $plantId)->value('name');
$emails = AlertMailRule::where('plant', $plantId)
- //->where('plant', $plantName)
+ // ->where('plant', $plantName)
->where('module', 'InvoiceValidation')
->where('rule_name', 'InvoiceMail')
->where(function ($query) {
@@ -2375,10 +2253,10 @@ class CreateInvoiceValidation extends CreateRecord
->toArray();
return [
- 'plant_id' => $plantId,
- 'plant_name' => $mPlantName,
+ 'plant_id' => $plantId,
+ 'plant_name' => $mPlantName,
'invoice_type' => $mInvoiceType,
- 'emails' => $emails,
+ 'emails' => $emails,
];
}
@@ -2397,11 +2275,10 @@ class CreateInvoiceValidation extends CreateRecord
$totQuan = InvoiceValidation::where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->count();
$scanSQuan = InvoiceValidation::where('invoice_number', $invoiceNumber)->where('scanned_status', 'Scanned')->where('plant_id', $plantId)->count();
- $totMQuan = InvoiceValidation::where('invoice_number', $invoiceNumber)->whereNotNull('quantity')->where('plant_id', $plantId)->count(); //->where('quantity', '!=', '')
+ $totMQuan = InvoiceValidation::where('invoice_number', $invoiceNumber)->whereNotNull('quantity')->where('plant_id', $plantId)->count(); // ->where('quantity', '!=', '')
$scanMQuan = InvoiceValidation::where('invoice_number', $invoiceNumber)->whereNotNull('serial_number')->where('serial_number', '!=', '')->where('plant_id', $plantId)->count();
- if ($totQuan <= 0)
- {
+ if ($totQuan <= 0) {
Notification::make()
->title('Invoice Not Found')
->body("Invoice file '$invoiceNumber' doesn't exist.
Scan the valid 'Invoice' file to proceed!")
@@ -2414,19 +2291,16 @@ class CreateInvoiceValidation extends CreateRecord
'plant_id' => $plantId,
'invoice_number' => $invoiceNumber,
'serial_number' => null,
- 'total_quantity' => 0, //$totQuan
+ 'total_quantity' => 0, // $totQuan
'update_invoice' => false,
- 'scanned_quantity'=> 0, //($totMQuan > 0) ? $scanMQuan : $scanSQuan
+ 'scanned_quantity' => 0, // ($totMQuan > 0) ? $scanMQuan : $scanSQuan
]);
$this->dispatch('refreshEmptyInvoice', invoiceNumber: $invoiceNumber, plantId: $plantId);
+
return;
- }
- else
- {
- if ($totMQuan > 0)
- {
- if ($totQuan == $scanMQuan)
- {
+ } else {
+ if ($totMQuan > 0) {
+ if ($totQuan == $scanMQuan) {
Notification::make()
->title('Completed: Material Invoice')
->body("Material invoice '$invoiceNumber' completed the scanning process.
Scan the next 'Material Invoice' to proceed!")
@@ -2435,13 +2309,13 @@ class CreateInvoiceValidation extends CreateRecord
->send();
$this->dispatch('playNotificationSound');
- $filename = $invoiceNumber . '.xlsx';
+ $filename = $invoiceNumber.'.xlsx';
$directory = 'uploads/temp';
$disk = Storage::disk('local');
- $filePath = $directory . '/' . $filename;
- //$fullPath = null;
+ $filePath = $directory.'/'.$filename;
+ // $fullPath = null;
if ($disk->exists($filePath)) {
- //$fullPath = $disk->path($filePath);
+ // $fullPath = $disk->path($filePath);
$disk->delete($filePath);
}
@@ -2451,23 +2325,22 @@ class CreateInvoiceValidation extends CreateRecord
'serial_number' => null,
'total_quantity' => 0,
'update_invoice' => false,
- 'scanned_quantity'=> 0
+ 'scanned_quantity' => 0,
]);
$this->dispatch('refreshCompletedInvoice', invoiceNumber: $invoiceNumber, plantId: $plantId, isSerial: false);
+
return;
- }
- else
- {
+ } else {
$this->form->fill([
'plant_id' => $plantId,
'invoice_number' => $invoiceNumber,
'serial_number' => null,
'total_quantity' => $totQuan,
'update_invoice' => false,
- 'scanned_quantity'=> $scanMQuan,
+ 'scanned_quantity' => $scanMQuan,
]);
- //$hasRecords = InvoiceValidation::where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->first()->stickerMasterRelation->material_type ?? null;
+ // $hasRecords = InvoiceValidation::where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->first()->stickerMasterRelation->material_type ?? null;
$this->dispatch('refreshMaterialInvoiceData', invoiceNumber: $invoiceNumber, plantId: $plantId);
}
@@ -2482,12 +2355,11 @@ class CreateInvoiceValidation extends CreateRecord
$itemCode = $matches['item_code'];
$this->currentItemCode = $itemCode;
$batchNumber = $matches['batch_number'];
- $serialNumber = $matches['batch_id'] . '-' . $matches['batch_count'];
+ $serialNumber = $matches['batch_id'].'-'.$matches['batch_count'];
$curScanQty = $matches['batch_quantity'];
$serNo = null;
- if (empty($matches['batch_id']) || !$matches['batch_id'])
- {
+ if (empty($matches['batch_id']) || ! $matches['batch_id']) {
Notification::make()
->danger()
->title('Invalid Material QR Format')
@@ -2496,61 +2368,18 @@ class CreateInvoiceValidation extends CreateRecord
->send();
$this->dispatch('playWarnSound');
- //.Mail
+ // .Mail
$mailData = $this->getMail();
$mPlantName = $mailData['plant_name'];
$emails = $mailData['emails'];
$mInvoiceType = 'Material';
- if (!empty($emails))
- {
- Mail::to($emails)->send(
- new InvalidSerialMail($mSerNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode,'InvalidMaterialFormat')
- );
- }
- else
- {
- \Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
- }
-
- $this->form->fill([
- 'plant_id' => $plantId,
- 'invoice_number' => $invoiceNumber,
- 'serial_number' => null,
- 'total_quantity' => $totQuan,
- 'update_invoice' => false,
- 'scanned_quantity'=> $scanMQuan,
- ]);
- return;
- }
- else if (empty($matches['batch_count']) || !$matches['batch_count'])
- {
- Notification::make()
- ->danger()
- ->title('Invalid Material QR Format')
- ->body('Scan valid Material QR code proceed!
Sample formats are:
123456|12345|12345678|1/1 (or)
123456|12345|12345678|1 (or)
123456|12345678-1')
- ->seconds(2)
- ->send();
- $this->dispatch('playWarnSound');
-
-
- //.Mail
-
- $mailData = $this->getMail();
- $mPlantName = $mailData['plant_name'];
- $emails = $mailData['emails'];
- $mInvoiceType = 'Material';
-
- if (!empty($emails))
- {
- //Mail::to($emails)->send(new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType));
+ if (! empty($emails)) {
Mail::to($emails)->send(
new InvalidSerialMail($mSerNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, 'InvalidMaterialFormat')
);
- }
- else
- {
+ } else {
\Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
}
@@ -2560,12 +2389,11 @@ class CreateInvoiceValidation extends CreateRecord
'serial_number' => null,
'total_quantity' => $totQuan,
'update_invoice' => false,
- 'scanned_quantity'=> $scanMQuan,
+ 'scanned_quantity' => $scanMQuan,
]);
+
return;
- }
- else if (!is_numeric($curScanQty))
- {
+ } elseif (empty($matches['batch_count']) || ! $matches['batch_count']) {
Notification::make()
->danger()
->title('Invalid Material QR Format')
@@ -2574,23 +2402,19 @@ class CreateInvoiceValidation extends CreateRecord
->send();
$this->dispatch('playWarnSound');
-
- //.Mail
+ // .Mail
$mailData = $this->getMail();
$mPlantName = $mailData['plant_name'];
$emails = $mailData['emails'];
$mInvoiceType = 'Material';
- if (!empty($emails))
- {
- //Mail::to($emails)->send(new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType));
+ if (! empty($emails)) {
+ // Mail::to($emails)->send(new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType));
Mail::to($emails)->send(
new InvalidSerialMail($mSerNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, 'InvalidMaterialFormat')
);
- }
- else
- {
+ } else {
\Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
}
@@ -2600,19 +2424,54 @@ class CreateInvoiceValidation extends CreateRecord
'serial_number' => null,
'total_quantity' => $totQuan,
'update_invoice' => false,
- 'scanned_quantity'=> $scanMQuan,
+ 'scanned_quantity' => $scanMQuan,
]);
+
+ return;
+ } elseif (! is_numeric($curScanQty)) {
+ Notification::make()
+ ->danger()
+ ->title('Invalid Material QR Format')
+ ->body('Scan valid Material QR code proceed!
Sample formats are:
123456|12345|12345678|1/1 (or)
123456|12345|12345678|1 (or)
123456|12345678-1')
+ ->seconds(2)
+ ->send();
+ $this->dispatch('playWarnSound');
+
+ // .Mail
+
+ $mailData = $this->getMail();
+ $mPlantName = $mailData['plant_name'];
+ $emails = $mailData['emails'];
+ $mInvoiceType = 'Material';
+
+ if (! empty($emails)) {
+ // Mail::to($emails)->send(new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType));
+ Mail::to($emails)->send(
+ new InvalidSerialMail($mSerNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, 'InvalidMaterialFormat')
+ );
+ } else {
+ \Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
+ }
+
+ $this->form->fill([
+ 'plant_id' => $plantId,
+ 'invoice_number' => $invoiceNumber,
+ 'serial_number' => null,
+ 'total_quantity' => $totQuan,
+ 'update_invoice' => false,
+ 'scanned_quantity' => $scanMQuan,
+ ]);
+
return;
}
- } else if (preg_match($pattern2, $serNo, $matches)) {
+ } elseif (preg_match($pattern2, $serNo, $matches)) {
$itemCode = $matches['item_code'];
$this->currentItemCode = $itemCode;
$batchNumber = $matches['batch_number'];
- $serialNumber = $matches['batch_id'] . '-' . $matches['batch_count'];
+ $serialNumber = $matches['batch_id'].'-'.$matches['batch_count'];
$serNo = null;
- if (empty($matches['batch_id']) || !$matches['batch_id'])
- {
+ if (empty($matches['batch_id']) || ! $matches['batch_id']) {
Notification::make()
->danger()
->title('Invalid Material QR Format')
@@ -2620,21 +2479,18 @@ class CreateInvoiceValidation extends CreateRecord
->seconds(2)
->send();
$this->dispatch('playWarnSound');
- //.Mail
+ // .Mail
$mailData = $this->getMail();
$mPlantName = $mailData['plant_name'];
$emails = $mailData['emails'];
$mInvoiceType = 'Material';
- if (!empty($emails))
- {
+ if (! empty($emails)) {
Mail::to($emails)->send(
new InvalidSerialMail($mSerNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, 'InvalidMaterialFormat')
);
- }
- else
- {
+ } else {
\Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
}
@@ -2644,12 +2500,11 @@ class CreateInvoiceValidation extends CreateRecord
'serial_number' => null,
'total_quantity' => $totQuan,
'update_invoice' => false,
- 'scanned_quantity'=> $scanMQuan,
+ 'scanned_quantity' => $scanMQuan,
]);
+
return;
- }
- else if (empty($matches['batch_count']) || !$matches['batch_count'])
- {
+ } elseif (empty($matches['batch_count']) || ! $matches['batch_count']) {
Notification::make()
->danger()
->title('Invalid Material QR Format')
@@ -2663,14 +2518,11 @@ class CreateInvoiceValidation extends CreateRecord
$emails = $mailData['emails'];
$mInvoiceType = 'Material';
- if (!empty($emails))
- {
+ if (! empty($emails)) {
Mail::to($emails)->send(
new InvalidSerialMail($mSerNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, 'InvalidMaterialFormat')
);
- }
- else
- {
+ } else {
\Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
}
@@ -2680,19 +2532,19 @@ class CreateInvoiceValidation extends CreateRecord
'serial_number' => null,
'total_quantity' => $totQuan,
'update_invoice' => false,
- 'scanned_quantity'=> $scanMQuan,
+ 'scanned_quantity' => $scanMQuan,
]);
+
return;
}
- } else if (preg_match($pattern3, $serNo, $matches)) {
+ } elseif (preg_match($pattern3, $serNo, $matches)) {
$itemCode = $matches['item_code'];
$this->currentItemCode = $itemCode;
$batchNumber = null; // batch_number not present in this pattern
- $serialNumber = $matches['batch_id'] . '-' . $matches['batch_count'];
+ $serialNumber = $matches['batch_id'].'-'.$matches['batch_count'];
$serNo = null;
- if (empty($matches['batch_id']) || !$matches['batch_id'])
- {
+ if (empty($matches['batch_id']) || ! $matches['batch_id']) {
Notification::make()
->danger()
->title('Invalid Material QR Format')
@@ -2701,21 +2553,18 @@ class CreateInvoiceValidation extends CreateRecord
->send();
$this->dispatch('playWarnSound');
- //.Mail
+ // .Mail
$mailData = $this->getMail();
$mPlantName = $mailData['plant_name'];
$emails = $mailData['emails'];
$mInvoiceType = 'Material';
- if (!empty($emails))
- {
+ if (! empty($emails)) {
Mail::to($emails)->send(
new InvalidSerialMail($mSerNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, 'InvalidMaterialFormat')
);
- }
- else
- {
+ } else {
\Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
}
@@ -2725,12 +2574,11 @@ class CreateInvoiceValidation extends CreateRecord
'serial_number' => null,
'total_quantity' => $totQuan,
'update_invoice' => false,
- 'scanned_quantity'=> $scanMQuan,
+ 'scanned_quantity' => $scanMQuan,
]);
+
return;
- }
- else if (empty($matches['batch_count']) || !$matches['batch_count'])
- {
+ } elseif (empty($matches['batch_count']) || ! $matches['batch_count']) {
Notification::make()
->danger()
->title('Invalid Material QR Format')
@@ -2738,21 +2586,18 @@ class CreateInvoiceValidation extends CreateRecord
->seconds(2)
->send();
$this->dispatch('playWarnSound');
- //.Mail
+ // .Mail
$mailData = $this->getMail();
$mPlantName = $mailData['plant_name'];
$emails = $mailData['emails'];
$mInvoiceType = 'Material';
- if (!empty($emails))
- {
+ if (! empty($emails)) {
Mail::to($emails)->send(
new InvalidSerialMail($mSerNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, 'InvalidMaterialFormat')
);
- }
- else
- {
+ } else {
\Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
}
@@ -2762,12 +2607,12 @@ class CreateInvoiceValidation extends CreateRecord
'serial_number' => null,
'total_quantity' => $totQuan,
'update_invoice' => false,
- 'scanned_quantity'=> $scanMQuan,
+ 'scanned_quantity' => $scanMQuan,
]);
+
return;
}
- }
- else {
+ } else {
$itemCode = null;
$this->currentItemCode = '';
$batchNumber = null;
@@ -2783,24 +2628,20 @@ class CreateInvoiceValidation extends CreateRecord
$this->dispatch('playWarnSound');
+ // .Mail
- //.Mail
+ $mailData = $this->getMail();
+ $mPlantName = $mailData['plant_name'];
+ $emails = $mailData['emails'];
+ $mInvoiceType = 'Material';
- $mailData = $this->getMail();
- $mPlantName = $mailData['plant_name'];
- $emails = $mailData['emails'];
- $mInvoiceType = 'Material';
-
- if (!empty($emails))
- {
- Mail::to($emails)->send(
- new InvalidSerialMail($mSerNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, 'InvalidMaterialFormat')
- );
- }
- else
- {
- \Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
- }
+ if (! empty($emails)) {
+ Mail::to($emails)->send(
+ new InvalidSerialMail($mSerNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, 'InvalidMaterialFormat')
+ );
+ } else {
+ \Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
+ }
$this->form->fill([
'plant_id' => $plantId,
@@ -2808,8 +2649,9 @@ class CreateInvoiceValidation extends CreateRecord
'serial_number' => null,
'total_quantity' => $totQuan,
'update_invoice' => false,
- 'scanned_quantity'=> $scanMQuan,
+ 'scanned_quantity' => $scanMQuan,
]);
+
return;
}
@@ -2817,14 +2659,13 @@ class CreateInvoiceValidation extends CreateRecord
$record = StickerMaster::whereHas('item', function ($query) {
$query->where('code', $this->currentItemCode);
});
- if ($record->count() <= 0)
- {
+ if ($record->count() <= 0) {
Notification::make()
- ->title('Unknown: Item Code')
- ->body("Item code '$itemCode' not found in database.")
- ->danger()
- ->seconds(2)
- ->send();
+ ->title('Unknown: Item Code')
+ ->body("Item code '$itemCode' not found in database.")
+ ->danger()
+ ->seconds(2)
+ ->send();
$this->dispatch('playWarnSound');
$mailData = $this->getMail();
@@ -2832,14 +2673,11 @@ class CreateInvoiceValidation extends CreateRecord
$emails = $mailData['emails'];
$mInvoiceType = 'Material';
- if (!empty($emails))
- {
+ if (! empty($emails)) {
Mail::to($emails)->send(
new InvalidSerialMail($mSerNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, 'ItemNotFound')
);
- }
- else
- {
+ } else {
\Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
}
@@ -2849,22 +2687,22 @@ class CreateInvoiceValidation extends CreateRecord
'serial_number' => null,
'total_quantity' => $totQuan,
'update_invoice' => false,
- 'scanned_quantity'=> $scanMQuan,
+ 'scanned_quantity' => $scanMQuan,
]);
+
return;
}
$record = StickerMaster::where('plant_id', $plantId)->whereHas('item', function ($query) {
$query->where('code', $this->currentItemCode);
});
- if ($record->count() <= 0)
- {
+ if ($record->count() <= 0) {
Notification::make()
- ->title('Unknown: Item Code')
- ->body("Item code '$itemCode' not found in database for choosed plant.")
- ->danger()
- ->seconds(2)
- ->send();
+ ->title('Unknown: Item Code')
+ ->body("Item code '$itemCode' not found in database for choosed plant.")
+ ->danger()
+ ->seconds(2)
+ ->send();
$this->dispatch('playWarnSound');
$mailData = $this->getMail();
@@ -2872,14 +2710,11 @@ class CreateInvoiceValidation extends CreateRecord
$emails = $mailData['emails'];
$mInvoiceType = 'Material';
- if (!empty($emails))
- {
+ if (! empty($emails)) {
Mail::to($emails)->send(
new InvalidSerialMail($mSerNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, 'ItemNotFoundDB')
);
- }
- else
- {
+ } else {
\Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
}
@@ -2889,21 +2724,21 @@ class CreateInvoiceValidation extends CreateRecord
'serial_number' => null,
'total_quantity' => $totQuan,
'update_invoice' => false,
- 'scanned_quantity'=> $scanMQuan,
+ 'scanned_quantity' => $scanMQuan,
]);
+
return;
}
$record = StickerMaster::where('plant_id', $plantId)->where('item_id', Item::where('plant_id', $plantId)->where('code', $itemCode)->first()->id)->first();
- if (empty($record->material_type) || !$record->material_type)
- {
+ if (empty($record->material_type) || ! $record->material_type) {
Notification::make()
- ->title('Invalid: Item Code')
- ->body("Item code '$itemCode' doesn't have a valid material type.")
- ->danger()
- ->seconds(2)
- ->send();
+ ->title('Invalid: Item Code')
+ ->body("Item code '$itemCode' doesn't have a valid material type.")
+ ->danger()
+ ->seconds(2)
+ ->send();
$this->dispatch('playWarnSound');
$mailData = $this->getMail();
@@ -2911,14 +2746,11 @@ class CreateInvoiceValidation extends CreateRecord
$emails = $mailData['emails'];
$mInvoiceType = 'Material';
- if (!empty($emails))
- {
+ if (! empty($emails)) {
Mail::to($emails)->send(
new InvalidSerialMail($mSerNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, 'ItemNotValidMaterialType')
);
- }
- else
- {
+ } else {
\Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
}
@@ -2928,8 +2760,9 @@ class CreateInvoiceValidation extends CreateRecord
'serial_number' => null,
'total_quantity' => $totQuan,
'update_invoice' => false,
- 'scanned_quantity'=> $scanMQuan,
+ 'scanned_quantity' => $scanMQuan,
]);
+
return;
}
@@ -2941,13 +2774,13 @@ class CreateInvoiceValidation extends CreateRecord
$query->where('plant_id', $this->plantId)->where('code', $itemCode);
})
->first();
- if (!$record) {
+ if (! $record) {
Notification::make()
- ->title('Unknown: Item Code')
- ->body("Item code '$itemCode' doesn't exist in invoice.")
- ->danger()
- ->seconds(2)
- ->send();
+ ->title('Unknown: Item Code')
+ ->body("Item code '$itemCode' doesn't exist in invoice.")
+ ->danger()
+ ->seconds(2)
+ ->send();
$this->dispatch('playWarnSound');
$mailData = $this->getMail();
@@ -2955,14 +2788,11 @@ class CreateInvoiceValidation extends CreateRecord
$emails = $mailData['emails'];
$mInvoiceType = 'Material';
- if (!empty($emails))
- {
+ if (! empty($emails)) {
Mail::to($emails)->send(
new InvalidSerialMail($mSerNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, 'ItemNotInvoice')
);
- }
- else
- {
+ } else {
\Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
}
@@ -2972,40 +2802,38 @@ class CreateInvoiceValidation extends CreateRecord
'serial_number' => null,
'total_quantity' => $totQuan,
'update_invoice' => false,
- 'scanned_quantity'=> $scanMQuan,
+ 'scanned_quantity' => $scanMQuan,
]);
+
return;
}
// ->whereNotNull('serial_number')->where('serial_number', '!=', '')
- $record = InvoiceValidation::where('invoice_number', $invoiceNumber)->where(function($query) {
+ $record = InvoiceValidation::where('invoice_number', $invoiceNumber)->where(function ($query) {
$query->whereNull('serial_number')->orWhere('serial_number', '');
})->where('plant_id', $plantId)->whereHas('stickerMasterRelation.item', function ($query) use ($itemCode) {
- $query->where('plant_id', $this->plantId)->where('code', $itemCode);
- })
+ $query->where('plant_id', $this->plantId)->where('code', $itemCode);
+ })
->first();
- if (!$record) {
+ if (! $record) {
Notification::make()
->title('Item Code Limit Exceeds')
->body("Scanned item code '$itemCode' already reached its scanning quantity for the invoice '$invoiceNumber'.")
->danger()
->seconds(2)
->send();
- $this->dispatch('playWarnSound');
+ $this->dispatch('playWarnSound');
$mailData = $this->getMail();
$mPlantName = $mailData['plant_name'];
$emails = $mailData['emails'];
$mInvoiceType = 'Material';
- if (!empty($emails))
- {
+ if (! empty($emails)) {
Mail::to($emails)->send(
new InvalidSerialMail($mSerNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, 'Item')
);
- }
- else
- {
+ } else {
\Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
}
@@ -3015,21 +2843,21 @@ class CreateInvoiceValidation extends CreateRecord
'serial_number' => null,
'total_quantity' => $totQuan,
'update_invoice' => false,
- 'scanned_quantity'=> $scanMQuan,
+ 'scanned_quantity' => $scanMQuan,
]);
+
return;
}
$dupRecord = InvoiceValidation::where('serial_number', $serialNumber)->where('plant_id', $plantId)->first();
- if ($dupRecord)
- {
+ if ($dupRecord) {
Notification::make()
->title('Duplicate: Material QR')
->body("Scanned 'Material QR' already completed the scanning process.")
->danger()
->seconds(2)
->send();
- $this->dispatch('playWarnSound');
+ $this->dispatch('playWarnSound');
$this->form->fill([
'plant_id' => $plantId,
@@ -3037,22 +2865,21 @@ class CreateInvoiceValidation extends CreateRecord
'serial_number' => null,
'total_quantity' => $totQuan,
'update_invoice' => false,
- 'scanned_quantity'=> $scanMQuan,
+ 'scanned_quantity' => $scanMQuan,
]);
+
return;
}
- if ($hasQuanTyp)
- {
- if (!is_numeric($curScanQty))
- {
+ if ($hasQuanTyp) {
+ if (! is_numeric($curScanQty)) {
Notification::make()
->danger()
->title('Invalid Quantity Material QR Format')
->body('Scan valid Quantity Material QR code proceed!
Ex:123456|12345|12345678|1/1')
->seconds(2)
->send();
- $this->dispatch('playWarnSound');
+ $this->dispatch('playWarnSound');
$this->form->fill([
'plant_id' => $plantId,
@@ -3060,8 +2887,9 @@ class CreateInvoiceValidation extends CreateRecord
'serial_number' => null,
'total_quantity' => $totQuan,
'update_invoice' => false,
- 'scanned_quantity'=> $scanMQuan,
+ 'scanned_quantity' => $scanMQuan,
]);
+
return;
}
@@ -3070,8 +2898,7 @@ class CreateInvoiceValidation extends CreateRecord
$curExistQty = $record->quantity;
// $curScanQty = 2;
- if ($curExistQty > $curScanQty) // 5 > 2
- {
+ if ($curExistQty > $curScanQty) { // 5 > 2
$record->quantity = $curExistQty - $curScanQty; // 5 - 2
$record->operator_id = $operatorName;
// $record->updated_at = now();
@@ -3085,11 +2912,9 @@ class CreateInvoiceValidation extends CreateRecord
'batch_number' => $batchNumber,
'quantity' => $curScanQty,
'created_at' => $createdDt,
- 'operator_id'=> $operatorName,
+ 'operator_id' => $operatorName,
]);
- }
- else if ($curExistQty == $curScanQty) // 2 = 2
- {
+ } elseif ($curExistQty == $curScanQty) { // 2 = 2
// $record->delete();
$record->serial_number = $serialNumber;
$record->batch_number = $batchNumber;
@@ -3105,16 +2930,14 @@ class CreateInvoiceValidation extends CreateRecord
// 'created_at' => $createdDt,
// 'operator_id'=> $operatorName,
// ]);
- }
- else
- {
+ } else {
Notification::make()
->title('Item Code Limit Exceeds')
->body("Scanned item code '$itemCode' has '$curScanQty' quantity.
But, '$curExistQty' quantity only available for the invoice '$invoiceNumber'.")
->danger()
->seconds(2)
->send();
- $this->dispatch('playWarnSound');
+ $this->dispatch('playWarnSound');
$this->form->fill([
'plant_id' => $plantId,
@@ -3122,15 +2945,13 @@ class CreateInvoiceValidation extends CreateRecord
'serial_number' => null,
'total_quantity' => $totQuan,
'update_invoice' => false,
- 'scanned_quantity'=> $scanMQuan,
+ 'scanned_quantity' => $scanMQuan,
]);
+
return;
}
- }
- else
- {
- if (str_contains($serialNumber, '|'))
- {
+ } else {
+ if (str_contains($serialNumber, '|')) {
$itemCode = null;
$this->currentItemCode = '';
$batchNumber = null;
@@ -3152,8 +2973,9 @@ class CreateInvoiceValidation extends CreateRecord
'serial_number' => null,
'total_quantity' => $totQuan,
'update_invoice' => false,
- 'scanned_quantity'=> $scanMQuan,
+ 'scanned_quantity' => $scanMQuan,
]);
+
return;
}
@@ -3176,8 +2998,7 @@ class CreateInvoiceValidation extends CreateRecord
$scannedMQuantity = InvoiceValidation::where('invoice_number', $invoiceNumber)->whereNotNull('serial_number')->where('serial_number', '!=', '')->where('plant_id', $plantId)->count();
- if ($totQuan == $scannedMQuantity)
- {
+ if ($totQuan == $scannedMQuantity) {
Notification::make()
->title('Completed: Material Invoice')
->body("Material invoice '$invoiceNumber' completed the scanning process.
Scan the next 'Material Invoice' to proceed!")
@@ -3187,13 +3008,13 @@ class CreateInvoiceValidation extends CreateRecord
$this->dispatch('playNotificationSound');
- $filename = $invoiceNumber . '.xlsx';
+ $filename = $invoiceNumber.'.xlsx';
$directory = 'uploads/temp';
$disk = Storage::disk('local');
- $filePath = $directory . '/' . $filename;
- //$fullPath = null;
+ $filePath = $directory.'/'.$filename;
+ // $fullPath = null;
if ($disk->exists($filePath)) {
- //$fullPath = $disk->path($filePath);
+ // $fullPath = $disk->path($filePath);
$disk->delete($filePath);
}
@@ -3203,29 +3024,25 @@ class CreateInvoiceValidation extends CreateRecord
'serial_number' => null,
'total_quantity' => 0,
'update_invoice' => false,
- 'scanned_quantity'=> 0
+ 'scanned_quantity' => 0,
]);
$this->dispatch('refreshCompletedInvoice', invoiceNumber: $invoiceNumber, plantId: $plantId, isSerial: false);
- }
- else
- {
+ } else {
$this->form->fill([
'plant_id' => $plantId,
'invoice_number' => $invoiceNumber,
'serial_number' => null,
'total_quantity' => $totQuan,
'update_invoice' => false,
- 'scanned_quantity'=> $scannedMQuantity,
+ 'scanned_quantity' => $scannedMQuantity,
]);
$this->dispatch('refreshMaterialInvoiceData', invoiceNumber: $invoiceNumber, plantId: $plantId);
}
+
return;
- }
- else
- {
- if ($totQuan == $scanSQuan)
- {
+ } else {
+ if ($totQuan == $scanSQuan) {
Notification::make()
->title('Completed: Serial Invoice')
->body("Serial invoice '$invoiceNumber' completed the scanning process.
Scan the next 'Serial Invoice' to proceed!")
@@ -3235,13 +3052,13 @@ class CreateInvoiceValidation extends CreateRecord
$this->dispatch('playNotificationSound');
- $filename = $invoiceNumber . '.xlsx';
+ $filename = $invoiceNumber.'.xlsx';
$directory = 'uploads/temp';
$disk = Storage::disk('local');
- $filePath = $directory . '/' . $filename;
- //$fullPath = null;
+ $filePath = $directory.'/'.$filename;
+ // $fullPath = null;
if ($disk->exists($filePath)) {
- //$fullPath = $disk->path($filePath);
+ // $fullPath = $disk->path($filePath);
$disk->delete($filePath);
}
@@ -3251,28 +3068,27 @@ class CreateInvoiceValidation extends CreateRecord
'serial_number' => null,
'total_quantity' => 0,
'update_invoice' => false,
- 'scanned_quantity'=> 0
+ 'scanned_quantity' => 0,
]);
$this->dispatch('refreshCompletedInvoice', invoiceNumber: $invoiceNumber, plantId: $plantId, isSerial: true);
+
return;
- }
- else
- {
+ } else {
$this->form->fill([
'plant_id' => $plantId,
'invoice_number' => $invoiceNumber,
'serial_number' => null,
'total_quantity' => $totQuan,
'update_invoice' => false,
- 'scanned_quantity'=> $scanSQuan,
+ 'scanned_quantity' => $scanSQuan,
]);
- //$hasRecords = InvoiceValidation::where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->first()->stickerMasterRelation->material_type ?? null;
+ // $hasRecords = InvoiceValidation::where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->first()->stickerMasterRelation->material_type ?? null;
$this->dispatch('refreshInvoiceData', invoiceNumber: $invoiceNumber, plantId: $plantId, onCapFocus: false);
}
- ///^([a-zA-Z0-9]{6,})\|([1-9][a-zA-Z0-9]{8,})(?:\/[MmPpCc])?\|?$/
- if (!preg_match('/^([a-zA-Z0-9]{6,})\|([1-9][a-zA-Z0-9]{8,})(?:\/[MmPpCc])?\|?$/', $serNo, $matches)) {
+ // /^([a-zA-Z0-9]{6,})\|([1-9][a-zA-Z0-9]{8,})(?:\/[MmPpCc])?\|?$/
+ 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')
@@ -3280,27 +3096,23 @@ class CreateInvoiceValidation extends CreateRecord
->seconds(3)
->send();
- $this->dispatch('playWarnSound');
+ $this->dispatch('playWarnSound');
- //..Mail
+ // ..Mail
- $mInvoiceType = 'Serial';
- $mailData = $this->getMail();
- $mPlantName = $mailData['plant_name'];
- $emails = $mailData['emails'];
-
- if (!empty($emails))
- {
- //Mail::to($emails)->send(new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType));
- Mail::to($emails)->send(
- new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType, 'InvalidFormat')
- );
- }
- else
- {
- \Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
- }
+ $mInvoiceType = 'Serial';
+ $mailData = $this->getMail();
+ $mPlantName = $mailData['plant_name'];
+ $emails = $mailData['emails'];
+ if (! empty($emails)) {
+ // Mail::to($emails)->send(new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType));
+ Mail::to($emails)->send(
+ new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType, 'InvalidFormat')
+ );
+ } else {
+ \Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
+ }
$this->form->fill([
'plant_id' => $plantId,
@@ -3308,14 +3120,14 @@ class CreateInvoiceValidation extends CreateRecord
'serial_number' => null,
'total_quantity' => $totQuan,
'update_invoice' => false,
- 'scanned_quantity'=> $scanSQuan,
+ 'scanned_quantity' => $scanSQuan,
]);
+
return;
}
- //'/^([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))
- {
+ // '/^([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];
@@ -3326,14 +3138,14 @@ class CreateInvoiceValidation extends CreateRecord
$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);
+ $isMarkPs = (! $isMarkM && ! $isMarkP && ! $isMarkC) ? true : false;
+ // dd($serialNumber, $isMarkM, $isMarkP, $isMarkC, $isMarkPs);
$serialNumber = preg_replace('/\/[MmPpCc]$/', '', $serialNumber);
$record = InvoiceValidation::where('serial_number', $serialNumber)->where('plant_id', $plantId)->first();
- if (!$record) {
+ if (! $record) {
Notification::make()
->title('Serial Number Not Found
Serial \''.$serialNumber.'\' not found in database for choosed plant.')
// ->body("Serial '$serialNumber' not found in database for choosed plant.")..........
@@ -3343,25 +3155,22 @@ class CreateInvoiceValidation extends CreateRecord
$this->dispatch('play-warn-sound');
- //..Mail
+ // ..Mail
$mInvoiceType = 'Serial';
$mailData = $this->getMail();
$mPlantName = $mailData['plant_name'];
$emails = $mailData['emails'];
- if (!empty($emails))
- {
+ if (! empty($emails)) {
Mail::to($emails)->send(
new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, 'NotFound')
);
- }
- else
- {
+ } else {
\Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
}
- //..
+ // ..
$this->form->fill([
'plant_id' => $plantId,
@@ -3369,15 +3178,16 @@ class CreateInvoiceValidation extends CreateRecord
'serial_number' => null,
'total_quantity' => $totQuan,
'update_invoice' => false,
- 'scanned_quantity'=> $scanSQuan,
+ 'scanned_quantity' => $scanSQuan,
]);
+
return;
}
$record = InvoiceValidation::where('serial_number', $serialNumber)->where('invoice_number', $invoiceNumber)->where('plant_id', $plantId)->first();
- //$invoiceNumber = $this->form->getState()['invoice_number'];
+ // $invoiceNumber = $this->form->getState()['invoice_number'];
- if (!$record) {
+ if (! $record) {
Notification::make()
->title('Unknown: Serial Number
Serial \''.$serialNumber.'\' not found in invoice.')
// ->body("Serial '$serialNumber' not found in invoice.")
@@ -3387,20 +3197,17 @@ class CreateInvoiceValidation extends CreateRecord
$this->dispatch('playWarnSound');
- //.Mail
+ // .Mail
$mInvoiceType = 'Serial';
$mailData = $this->getMail();
$mPlantName = $mailData['plant_name'];
$emails = $mailData['emails'];
- if (!empty($emails))
- {
+ if (! empty($emails)) {
Mail::to($emails)->send(
new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, 'NotFoundInvoice')
);
- }
- else
- {
+ } else {
\Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
}
@@ -3410,8 +3217,9 @@ class CreateInvoiceValidation extends CreateRecord
'serial_number' => null,
'total_quantity' => $totQuan,
'update_invoice' => false,
- 'scanned_quantity'=> $scanSQuan,
+ 'scanned_quantity' => $scanSQuan,
]);
+
return;
}
@@ -3422,7 +3230,7 @@ class CreateInvoiceValidation extends CreateRecord
})
->first();
- if (!$record) {
+ if (! $record) {
Notification::make()
->title('Unknown: Item Code')
->body("Item code '$itemCode' with serial number '$serialNumber' not found.")
@@ -3437,14 +3245,11 @@ class CreateInvoiceValidation extends CreateRecord
$mPlantName = $mailData['plant_name'];
$emails = $mailData['emails'];
- if (!empty($emails))
- {
+ if (! empty($emails)) {
Mail::to($emails)->send(
- new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode,'NotFoundItemS')
+ new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, 'NotFoundItemS')
);
- }
- else
- {
+ } else {
\Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
}
@@ -3454,8 +3259,9 @@ class CreateInvoiceValidation extends CreateRecord
'serial_number' => null,
'total_quantity' => $totQuan,
'update_invoice' => false,
- 'scanned_quantity'=> $scanSQuan,
+ 'scanned_quantity' => $scanSQuan,
]);
+
return;
}
@@ -3464,11 +3270,12 @@ class CreateInvoiceValidation extends CreateRecord
$hasPumpSetQr = $record->stickerMasterRelation->tube_sticker_pumpset ?? null;
$hasCapacitorQr = $record->stickerMasterRelation->panel_box_code ?? null;
- if (!$hasMotorQr && !$hasPumpQr && !$hasPumpSetQr && !$hasCapacitorQr)
- {
+ if (! $hasMotorQr && ! $hasPumpQr && ! $hasPumpSetQr && ! $hasCapacitorQr) {
$hasMotorQr = $record->stickerMasterRelation->pack_slip_motor ?? null;
$hasPumpQr = $record->stickerMasterRelation->pack_slip_pump ?? null;
$hasPumpSetQr = $record->stickerMasterRelation->pack_slip_pumpset ?? null;
+ } elseif (! $hasPumpSetQr && ! $hasPumpQr) {
+ $hasPumpQr = $record->stickerMasterRelation->pack_slip_pump ?? null;
}
$hadMotorQr = $record->motor_scanned_status ?? null;
@@ -3476,8 +3283,7 @@ class CreateInvoiceValidation extends CreateRecord
$hadPumpSetQr = $record->scanned_status_set ?? null;
$hadCapacitorQr = $record->capacitor_scanned_status ?? null;
- if (!$hasMotorQr && !$hasPumpQr && !$hasPumpSetQr && !$hasCapacitorQr)
- {
+ if (! $hasMotorQr && ! $hasPumpQr && ! $hasPumpSetQr && ! $hasCapacitorQr) {
Notification::make()
->title('Invalid: Item Code')
->body("Scanned 'Item Code' doesn't have valid package type to proceed!")
@@ -3492,14 +3298,11 @@ class CreateInvoiceValidation extends CreateRecord
$mPlantName = $mailData['plant_name'];
$emails = $mailData['emails'];
- if (!empty($emails))
- {
+ if (! empty($emails)) {
Mail::to($emails)->send(
- new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode,'NotValidPackage')
+ new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, 'NotValidPackage')
);
- }
- else
- {
+ } else {
\Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
}
@@ -3509,27 +3312,23 @@ class CreateInvoiceValidation extends CreateRecord
'serial_number' => null,
'total_quantity' => $totQuan,
'update_invoice' => false,
- 'scanned_quantity'=> $scanSQuan,
+ 'scanned_quantity' => $scanSQuan,
]);
+
return;
}
- if ($hasMotorQr && !$hasPumpQr && !$hasPumpSetQr && !$hasCapacitorQr)
- {
+ if ($hasMotorQr && ! $hasPumpQr && ! $hasPumpSetQr && ! $hasCapacitorQr) {
$isMarkM = true;
$isMarkP = false;
$isMarkC = false;
$isMarkPs = false;
- }
- else if (!$hasMotorQr && $hasPumpQr && !$hasPumpSetQr && !$hasCapacitorQr)
- {
+ } elseif (! $hasMotorQr && $hasPumpQr && ! $hasPumpSetQr && ! $hasCapacitorQr) {
$isMarkM = false;
$isMarkP = true;
$isMarkC = false;
$isMarkPs = false;
- }
- else if (!$hasMotorQr && !$hasPumpQr && !$hasPumpSetQr && $hasCapacitorQr)
- {
+ } elseif (! $hasMotorQr && ! $hasPumpQr && ! $hasPumpSetQr && $hasCapacitorQr) {
$isMarkM = false;
$isMarkP = false;
$isMarkC = true;
@@ -3537,28 +3336,24 @@ class CreateInvoiceValidation extends CreateRecord
}
if ($isMarkM) {
- if (!$hasMotorQr)
- {
+ if (! $hasMotorQr) {
Notification::make()
->title('Unknown: Motor QR')
->body("Scanned 'Item Code' doesn't have 'Motor' QR to proceed!")
->danger()
->seconds(3)
->send();
- $this->dispatch('playWarnSound');
+ $this->dispatch('playWarnSound');
$mInvoiceType = 'Serial';
$mailData = $this->getMail();
$mPlantName = $mailData['plant_name'];
$emails = $mailData['emails'];
- if (!empty($emails))
- {
+ if (! empty($emails)) {
Mail::to($emails)->send(
- new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode,'NotMotorQR')
+ new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, 'NotMotorQR')
);
- }
- else
- {
+ } else {
\Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
}
@@ -3568,12 +3363,11 @@ class CreateInvoiceValidation extends CreateRecord
'serial_number' => null,
'total_quantity' => $totQuan,
'update_invoice' => false,
- 'scanned_quantity'=> $scanSQuan,
+ 'scanned_quantity' => $scanSQuan,
]);
+
return;
- }
- else if ($hadMotorQr == $hasMotorQr)
- {
+ } elseif ($hadMotorQr == $hasMotorQr) {
Notification::make()
->title('Duplicate: Motor QR')
->body("Scanned 'Motor' serial number already completed the scanning process.")
@@ -3583,21 +3377,18 @@ class CreateInvoiceValidation extends CreateRecord
$this->dispatch('playWarnSound');
- //..Mail
+ // ..Mail
$mInvoiceType = 'Serial';
$mailData = $this->getMail();
$mPlantName = $mailData['plant_name'];
$emails = $mailData['emails'];
- if (!empty($emails))
- {
+ if (! empty($emails)) {
Mail::to($emails)->send(
new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, 'DuplicateMotorQR')
);
- }
- else
- {
+ } else {
\Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
}
@@ -3607,32 +3398,29 @@ class CreateInvoiceValidation extends CreateRecord
'serial_number' => null,
'total_quantity' => $totQuan,
'update_invoice' => false,
- 'scanned_quantity'=> $scanSQuan,
+ 'scanned_quantity' => $scanSQuan,
]);
+
return;
}
$packCnt = 1;
$scanCnt = 1;
$record->motor_scanned_status = 1;
- //if ($hadPumpQr == $hasPumpQr && $hadPumpSetQr == $hasPumpSetQr)
- if ($hasPumpQr || $hasPumpSetQr || $hasCapacitorQr)
- {
+ // if ($hadPumpQr == $hasPumpQr && $hadPumpSetQr == $hasPumpSetQr)
+ if ($hasPumpQr || $hasPumpSetQr || $hasCapacitorQr) {
$packCnt = $hasPumpQr ? $packCnt + 1 : $packCnt;
$packCnt = $hasPumpSetQr ? $packCnt + 1 : $packCnt;
$packCnt = $hasCapacitorQr ? $packCnt + 1 : $packCnt;
- $scanCnt = $hadPumpQr ? $scanCnt + 1: $scanCnt;
- $scanCnt = $hadPumpSetQr ? $scanCnt + 1: $scanCnt;
- $scanCnt = $hadCapacitorQr ? $scanCnt + 1: $scanCnt;
+ $scanCnt = $hadPumpQr ? $scanCnt + 1 : $scanCnt;
+ $scanCnt = $hadPumpSetQr ? $scanCnt + 1 : $scanCnt;
+ $scanCnt = $hadCapacitorQr ? $scanCnt + 1 : $scanCnt;
- if ($packCnt == $scanCnt)
- {
+ if ($packCnt == $scanCnt) {
$record->scanned_status = 'Scanned';
}
- }
- else
- {
+ } else {
$record->scanned_status = 'Scanned';
}
$record->operator_id = $operatorName;
@@ -3652,17 +3440,16 @@ class CreateInvoiceValidation extends CreateRecord
'serial_number' => null,
'total_quantity' => $totQuan,
'update_invoice' => false,
- 'scanned_quantity'=> $scannedQuantity,
+ 'scanned_quantity' => $scannedQuantity,
]);
- if ($totQuan == $scannedQuantity)
- {
+ if ($totQuan == $scannedQuantity) {
Notification::make()
- ->title('Completed: Serial Invoice')
- ->body("Serial invoice '$invoiceNumber' completed the scanning process.
Scan the next 'Serial Invoice' to proceed!")
- ->success()
- ->seconds(3)
- ->send();
+ ->title('Completed: Serial Invoice')
+ ->body("Serial invoice '$invoiceNumber' completed the scanning process.
Scan the next 'Serial Invoice' to proceed!")
+ ->success()
+ ->seconds(3)
+ ->send();
$this->dispatch('playNotificationSound');
$mInvoiceType = 'Serial';
@@ -3670,24 +3457,21 @@ class CreateInvoiceValidation extends CreateRecord
$mPlantName = $mailData['plant_name'];
$emails = $mailData['emails'];
- if (!empty($emails))
- {
+ if (! empty($emails)) {
Mail::to($emails)->send(
- new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode,'CompletedSerialInvoice')
+ new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, 'CompletedSerialInvoice')
);
- }
- else
- {
+ } else {
\Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
}
- $filename = $invoiceNumber . '.xlsx';
+ $filename = $invoiceNumber.'.xlsx';
$directory = 'uploads/temp';
$disk = Storage::disk('local');
- $filePath = $directory . '/' . $filename;
- //$fullPath = null;
+ $filePath = $directory.'/'.$filename;
+ // $fullPath = null;
if ($disk->exists($filePath)) {
- //$fullPath = $disk->path($filePath);
+ // $fullPath = $disk->path($filePath);
$disk->delete($filePath);
}
@@ -3697,21 +3481,18 @@ class CreateInvoiceValidation extends CreateRecord
'serial_number' => null,
'total_quantity' => 0,
'update_invoice' => false,
- 'scanned_quantity'=> 0
+ 'scanned_quantity' => 0,
]);
$this->dispatch('refreshCompletedInvoice', invoiceNumber: $invoiceNumber, plantId: $plantId, isSerial: true);
- }
- else
- {
+ } else {
$this->dispatch('refreshInvoiceData', invoiceNumber: $invoiceNumber, plantId: $plantId, onCapFocus: false);
// $this->refreshInvoiceTable();
}
+
return;
- }
- else if ($isMarkP) {
- if (!$hasPumpQr)
- {
+ } elseif ($isMarkP) {
+ if (! $hasPumpQr) {
Notification::make()
->title('Unknown: Pump QR')
->body("Scanned 'Item Code' doesn't have 'Pump' QR to proceed!")
@@ -3726,15 +3507,12 @@ class CreateInvoiceValidation extends CreateRecord
$mPlantName = $mailData['plant_name'];
$emails = $mailData['emails'];
- if (!empty($emails))
- {
- //Mail::to($emails)->send(new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType));
+ if (! empty($emails)) {
+ // Mail::to($emails)->send(new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType));
Mail::to($emails)->send(
- new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode,'NotPumpQR')
+ new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, 'NotPumpQR')
);
- }
- else
- {
+ } else {
\Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
}
@@ -3744,12 +3522,11 @@ class CreateInvoiceValidation extends CreateRecord
'serial_number' => null,
'total_quantity' => $totQuan,
'update_invoice' => false,
- 'scanned_quantity'=> $scanSQuan,
+ 'scanned_quantity' => $scanSQuan,
]);
+
return;
- }
- else if ($hadPumpQr == $hasPumpQr)
- {
+ } elseif ($hadPumpQr == $hasPumpQr) {
Notification::make()
->title('Duplicate: Pump QR')
->body("Scanned 'Pump' serial number already completed the scanning process.")
@@ -3763,15 +3540,12 @@ class CreateInvoiceValidation extends CreateRecord
$mPlantName = $mailData['plant_name'];
$emails = $mailData['emails'];
- if (!empty($emails))
- {
- //Mail::to($emails)->send(new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType));
+ if (! empty($emails)) {
+ // Mail::to($emails)->send(new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType));
Mail::to($emails)->send(
- new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode,'DuplicatePumpQR')
+ new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, 'DuplicatePumpQR')
);
- }
- else
- {
+ } else {
\Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
}
@@ -3781,8 +3555,9 @@ class CreateInvoiceValidation extends CreateRecord
'serial_number' => null,
'total_quantity' => $totQuan,
'update_invoice' => false,
- 'scanned_quantity'=> $scanSQuan,
+ 'scanned_quantity' => $scanSQuan,
]);
+
return;
}
@@ -3790,23 +3565,19 @@ class CreateInvoiceValidation extends CreateRecord
$scanCnt = 1;
$record->pump_scanned_status = 1;
// if ($hadMotorQr == $hasMotorQr && $hadPumpSetQr == $hasPumpSetQr && ($hadCapacitorQr == '1' && $hasCapacitorQr))
- if ($hasMotorQr || $hasPumpSetQr || $hasCapacitorQr)
- {
+ if ($hasMotorQr || $hasPumpSetQr || $hasCapacitorQr) {
$packCnt = $hasMotorQr ? $packCnt + 1 : $packCnt;
$packCnt = $hasPumpSetQr ? $packCnt + 1 : $packCnt;
$packCnt = $hasCapacitorQr ? $packCnt + 1 : $packCnt;
- $scanCnt = $hadMotorQr ? $scanCnt + 1: $scanCnt;
- $scanCnt = $hadPumpSetQr ? $scanCnt + 1: $scanCnt;
- $scanCnt = $hadCapacitorQr ? $scanCnt + 1: $scanCnt;
+ $scanCnt = $hadMotorQr ? $scanCnt + 1 : $scanCnt;
+ $scanCnt = $hadPumpSetQr ? $scanCnt + 1 : $scanCnt;
+ $scanCnt = $hadCapacitorQr ? $scanCnt + 1 : $scanCnt;
- if ($packCnt == $scanCnt)
- {
+ if ($packCnt == $scanCnt) {
$record->scanned_status = 'Scanned';
}
- }
- else
- {
+ } else {
$record->scanned_status = 'Scanned';
}
$record->operator_id = $operatorName;
@@ -3826,17 +3597,16 @@ class CreateInvoiceValidation extends CreateRecord
'serial_number' => null,
'total_quantity' => $totQuan,
'update_invoice' => false,
- 'scanned_quantity'=> $scannedQuantity,
+ 'scanned_quantity' => $scannedQuantity,
]);
- if ($totQuan == $scannedQuantity)
- {
+ if ($totQuan == $scannedQuantity) {
Notification::make()
- ->title('Completed: Serial Invoice')
- ->body("Serial invoice '$invoiceNumber' completed the scanning process.
Scan the next 'Serial Invoice' to proceed!")
- ->success()
- ->seconds(3)
- ->send();
+ ->title('Completed: Serial Invoice')
+ ->body("Serial invoice '$invoiceNumber' completed the scanning process.
Scan the next 'Serial Invoice' to proceed!")
+ ->success()
+ ->seconds(3)
+ ->send();
$this->dispatch('playNotificationSound');
@@ -3845,25 +3615,22 @@ class CreateInvoiceValidation extends CreateRecord
$mPlantName = $mailData['plant_name'];
$emails = $mailData['emails'];
- if (!empty($emails))
- {
- //Mail::to($emails)->send(new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType));
+ if (! empty($emails)) {
+ // Mail::to($emails)->send(new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType));
Mail::to($emails)->send(
- new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode,'CSerialInvoice')
+ new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, 'CSerialInvoice')
);
- }
- else
- {
+ } else {
\Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
}
- $filename = $invoiceNumber . '.xlsx';
+ $filename = $invoiceNumber.'.xlsx';
$directory = 'uploads/temp';
$disk = Storage::disk('local');
- $filePath = $directory . '/' . $filename;
- //$fullPath = null;
+ $filePath = $directory.'/'.$filename;
+ // $fullPath = null;
if ($disk->exists($filePath)) {
- //$fullPath = $disk->path($filePath);
+ // $fullPath = $disk->path($filePath);
$disk->delete($filePath);
}
@@ -3873,21 +3640,18 @@ class CreateInvoiceValidation extends CreateRecord
'serial_number' => null,
'total_quantity' => 0,
'update_invoice' => false,
- 'scanned_quantity'=> 0
+ 'scanned_quantity' => 0,
]);
$this->dispatch('refreshCompletedInvoice', invoiceNumber: $invoiceNumber, plantId: $plantId, isSerial: true);
- }
- else
- {
+ } else {
$this->dispatch('refreshInvoiceData', invoiceNumber: $invoiceNumber, plantId: $plantId, onCapFocus: false);
// $this->refreshInvoiceTable();
}
+
return;
- }
- else if ($isMarkC) {
- if (!$hasCapacitorQr)
- {
+ } elseif ($isMarkC) {
+ if (! $hasCapacitorQr) {
Notification::make()
// ->title('Unknown: Capacitor QR')
->title('Missing: Panel Box Code')
@@ -3904,15 +3668,12 @@ class CreateInvoiceValidation extends CreateRecord
$mPlantName = $mailData['plant_name'];
$emails = $mailData['emails'];
- if (!empty($emails))
- {
- //Mail::to($emails)->send(new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType));
+ if (! empty($emails)) {
+ // Mail::to($emails)->send(new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType));
Mail::to($emails)->send(
- new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode,'MissingPanelBox')
+ new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, 'MissingPanelBox')
);
- }
- else
- {
+ } else {
\Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
}
@@ -3922,12 +3683,11 @@ class CreateInvoiceValidation extends CreateRecord
'serial_number' => null,
'total_quantity' => $totQuan,
'update_invoice' => false,
- 'scanned_quantity'=> $scanSQuan,
+ 'scanned_quantity' => $scanSQuan,
]);
+
return;
- }
- else if ($hadCapacitorQr == '1' && $hasCapacitorQr)
- {
+ } elseif ($hadCapacitorQr == '1' && $hasCapacitorQr) {
Notification::make()
->title('Duplicate: Capacitor QR')
->body("Scanned 'Capacitor' serial number already completed the scanning process.")
@@ -3942,15 +3702,12 @@ class CreateInvoiceValidation extends CreateRecord
$mPlantName = $mailData['plant_name'];
$emails = $mailData['emails'];
- if (!empty($emails))
- {
- //Mail::to($emails)->send(new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType));
+ if (! empty($emails)) {
+ // Mail::to($emails)->send(new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType));
Mail::to($emails)->send(
- new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode,'DuplicateCapacitorQR')
+ new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, 'DuplicateCapacitorQR')
);
- }
- else
- {
+ } else {
\Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
}
@@ -3960,13 +3717,14 @@ class CreateInvoiceValidation extends CreateRecord
'serial_number' => null,
'total_quantity' => $totQuan,
'update_invoice' => false,
- 'scanned_quantity'=> $scanSQuan,
+ 'scanned_quantity' => $scanSQuan,
]);
+
return;
}
- //hereToUpdate
- //$this->dispatch('openCapacitorModal');
+ // hereToUpdate
+ // $this->dispatch('openCapacitorModal');
$this->dispatch('openCapacitorModal', itemCode: $itemCode, serialNumber: $serialNumber, plantId: $plantId);
$scannedQuantity = InvoiceValidation::where('invoice_number', $invoiceNumber)->where('scanned_status', 'Scanned')->where('plant_id', $plantId)->count();
@@ -3977,17 +3735,15 @@ class CreateInvoiceValidation extends CreateRecord
'serial_number' => null,
'total_quantity' => $totQuan,
'update_invoice' => false,
- 'scanned_quantity'=> $scannedQuantity,
+ 'scanned_quantity' => $scannedQuantity,
]);
$this->dispatch('refreshInvoiceData', invoiceNumber: $invoiceNumber, plantId: $plantId, onCapFocus: true);
+
// $this->refreshInvoiceTable();
return;
- }
- else if ($isMarkPs)
- {
- if (!$hasPumpSetQr)
- {
+ } elseif ($isMarkPs) {
+ if (! $hasPumpSetQr) {
Notification::make()
->title('Unknown: Pump Set QR')
->body("Scanned 'Item Code' doesn't have 'Pump Set' QR to proceed!")
@@ -4002,15 +3758,12 @@ class CreateInvoiceValidation extends CreateRecord
$mPlantName = $mailData['plant_name'];
$emails = $mailData['emails'];
- if (!empty($emails))
- {
- //Mail::to($emails)->send(new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType));
+ if (! empty($emails)) {
+ // Mail::to($emails)->send(new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType));
Mail::to($emails)->send(
- new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode,'UnknownPumpsetQR')
+ new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, 'UnknownPumpsetQR')
);
- }
- else
- {
+ } else {
\Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
}
@@ -4020,12 +3773,11 @@ class CreateInvoiceValidation extends CreateRecord
'serial_number' => null,
'total_quantity' => $totQuan,
'update_invoice' => false,
- 'scanned_quantity'=> $scanSQuan,
+ 'scanned_quantity' => $scanSQuan,
]);
+
return;
- }
- else if ($hadPumpSetQr == $hasPumpSetQr)
- {
+ } elseif ($hadPumpSetQr == $hasPumpSetQr) {
Notification::make()
->title('Duplicate: Pump Set QR')
->body("Scanned 'Pump Set' serial number already completed the scanning process.")
@@ -4040,15 +3792,12 @@ class CreateInvoiceValidation extends CreateRecord
$mPlantName = $mailData['plant_name'];
$emails = $mailData['emails'];
- if (!empty($emails))
- {
- //Mail::to($emails)->send(new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType));
+ if (! empty($emails)) {
+ // Mail::to($emails)->send(new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType));
Mail::to($emails)->send(
- new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode,'DuplicatePumpsetQR')
+ new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, 'DuplicatePumpsetQR')
);
- }
- else
- {
+ } else {
\Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
}
@@ -4058,8 +3807,9 @@ class CreateInvoiceValidation extends CreateRecord
'serial_number' => null,
'total_quantity' => $totQuan,
'update_invoice' => false,
- 'scanned_quantity'=> $scanSQuan,
+ 'scanned_quantity' => $scanSQuan,
]);
+
return;
}
@@ -4067,23 +3817,19 @@ class CreateInvoiceValidation extends CreateRecord
$scanCnt = 1;
$record->scanned_status_set = 1;
// if ($hadMotorQr == $hasMotorQr && $hadPumpQr == $hasPumpQr && ($hadCapacitorQr == '1' && $hasCapacitorQr))
- if ($hasMotorQr || $hasPumpQr || $hasCapacitorQr)
- {
+ if ($hasMotorQr || $hasPumpQr || $hasCapacitorQr) {
$packCnt = $hasMotorQr ? $packCnt + 1 : $packCnt;
$packCnt = $hasPumpQr ? $packCnt + 1 : $packCnt;
$packCnt = $hasCapacitorQr ? $packCnt + 1 : $packCnt;
- $scanCnt = $hadMotorQr ? $scanCnt + 1: $scanCnt;
- $scanCnt = $hadPumpQr ? $scanCnt + 1: $scanCnt;
- $scanCnt = $hadCapacitorQr ? $scanCnt + 1: $scanCnt;
+ $scanCnt = $hadMotorQr ? $scanCnt + 1 : $scanCnt;
+ $scanCnt = $hadPumpQr ? $scanCnt + 1 : $scanCnt;
+ $scanCnt = $hadCapacitorQr ? $scanCnt + 1 : $scanCnt;
- if ($packCnt == $scanCnt)
- {
+ if ($packCnt == $scanCnt) {
$record->scanned_status = 'Scanned';
}
- }
- else
- {
+ } else {
$record->scanned_status = 'Scanned';
}
$record->operator_id = $operatorName;
@@ -4103,17 +3849,16 @@ class CreateInvoiceValidation extends CreateRecord
'serial_number' => null,
'total_quantity' => $totQuan,
'update_invoice' => false,
- 'scanned_quantity'=> $scannedQuantity,
+ 'scanned_quantity' => $scannedQuantity,
]);
- if ($totQuan == $scannedQuantity)
- {
+ if ($totQuan == $scannedQuantity) {
Notification::make()
- ->title('Completed: Serial Invoice')
- ->body("Serial invoice '$invoiceNumber' completed the scanning process.
Scan the next 'Serial Invoice' to proceed!")
- ->success()
- ->seconds(3)
- ->send();
+ ->title('Completed: Serial Invoice')
+ ->body("Serial invoice '$invoiceNumber' completed the scanning process.
Scan the next 'Serial Invoice' to proceed!")
+ ->success()
+ ->seconds(3)
+ ->send();
$this->dispatch('playNotificationSound');
@@ -4122,25 +3867,22 @@ class CreateInvoiceValidation extends CreateRecord
$mPlantName = $mailData['plant_name'];
$emails = $mailData['emails'];
- if (!empty($emails))
- {
- //Mail::to($emails)->send(new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType));
+ if (! empty($emails)) {
+ // Mail::to($emails)->send(new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType));
Mail::to($emails)->send(
- new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode,'ComSerInv')
+ new InvalidSerialMail($serNo, $invoiceNumber, $mPlantName, $mInvoiceType, $itemCode, 'ComSerInv')
);
- }
- else
- {
+ } else {
\Log::warning("No recipients found for plant {$plantId}, module Serial, rule invalid_serial.");
}
- $filename = $invoiceNumber . '.xlsx';
+ $filename = $invoiceNumber.'.xlsx';
$directory = 'uploads/temp';
$disk = Storage::disk('local');
- $filePath = $directory . '/' . $filename;
- //$fullPath = null;
+ $filePath = $directory.'/'.$filename;
+ // $fullPath = null;
if ($disk->exists($filePath)) {
- //$fullPath = $disk->path($filePath);
+ // $fullPath = $disk->path($filePath);
$disk->delete($filePath);
}
@@ -4150,16 +3892,15 @@ class CreateInvoiceValidation extends CreateRecord
'serial_number' => null,
'total_quantity' => 0,
'update_invoice' => false,
- 'scanned_quantity'=> 0
+ 'scanned_quantity' => 0,
]);
$this->dispatch('refreshCompletedInvoice', invoiceNumber: $invoiceNumber, plantId: $plantId, isSerial: true);
- }
- else
- {
+ } else {
$this->dispatch('refreshInvoiceData', invoiceNumber: $invoiceNumber, plantId: $plantId, onCapFocus: false);
// $this->refreshInvoiceTable();
}
+
return;
}
}