Updated LeakTestValidation livewire with validations
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 16s
Gemini PR Review / Gemini PR Review (pull_request) Failing after 18s
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Successful in 18s
Laravel Pint / pint (pull_request) Successful in 6m27s
Laravel Larastan / larastan (pull_request) Failing after 7m22s
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 16s
Gemini PR Review / Gemini PR Review (pull_request) Failing after 18s
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Successful in 18s
Laravel Pint / pint (pull_request) Successful in 6m27s
Laravel Larastan / larastan (pull_request) Failing after 7m22s
This commit is contained in:
@@ -83,16 +83,55 @@ class LeakTestValidation extends Page
|
||||
public function processQr($value)
|
||||
{
|
||||
$plantId = $this->plantId;
|
||||
$this->leakTestQr = $value;
|
||||
$this->leakTestQr = trim($value);
|
||||
$parts = explode('|', trim($value));
|
||||
$validQr = false;
|
||||
|
||||
if (! preg_match('/^[^|]+\|[^|]+\|?$/', trim($value))) {
|
||||
if (! $plantId) {
|
||||
Notification::make()
|
||||
->title('Please select a plant first!')
|
||||
->danger()
|
||||
->duration(5000)
|
||||
->send();
|
||||
} elseif (! $value) {
|
||||
Notification::make()
|
||||
->title('Please scan the serial number!')
|
||||
->danger()
|
||||
->duration(5000)
|
||||
->send();
|
||||
} elseif (! preg_match('/^[^|]+\|[^|]+\|?$/', trim($value)) && count($parts) > 1) {
|
||||
Notification::make()
|
||||
->title('Invalid QR Format')
|
||||
->body("Expected format: ItemCode|SerialNumber<br>Received Format '$value'")
|
||||
->danger()
|
||||
->duration(5000)
|
||||
->send();
|
||||
} elseif (count($parts) == 1) {
|
||||
$sNumber = trim($value);
|
||||
if (strlen($sNumber) < 9) {
|
||||
Notification::make()
|
||||
->title('Invalid Serial Number')
|
||||
->body("Serial number '$sNumber' should contain minimum 9 digits!")
|
||||
->danger()
|
||||
->duration(5000)
|
||||
->send();
|
||||
} elseif (! ctype_alnum($sNumber)) {
|
||||
Notification::make()
|
||||
->title('Invalid Serial Number')
|
||||
->body("Serial number '$sNumber' should contain only alpha numeric values!")
|
||||
->danger()
|
||||
->duration(5000)
|
||||
->send();
|
||||
} elseif (! preg_match('/^[1-9][a-zA-Z0-9]{8,}$/', $sNumber)) {
|
||||
Notification::make()
|
||||
->title('Invalid Serial Number')
|
||||
->body("Serial number '{$sNumber}' should not begin with '0' or letter!")
|
||||
->danger()
|
||||
->duration(5000)
|
||||
->send();
|
||||
} else {
|
||||
$validQr = true;
|
||||
}
|
||||
} else {
|
||||
$iCode = trim($parts[0]);
|
||||
$sNumber = isset($parts[1]) ? trim($parts[1]) : null;
|
||||
@@ -103,10 +142,17 @@ class LeakTestValidation extends Page
|
||||
->danger()
|
||||
->duration(5000)
|
||||
->send();
|
||||
} elseif (! preg_match('/^[a-zA-Z0-9]+$/', $iCode)) {
|
||||
} elseif (! ctype_alnum($iCode)) {
|
||||
Notification::make()
|
||||
->title('Invalid Item Code')
|
||||
->body("Item code '$iCode' should contain alpha numeric values!")
|
||||
->body("Item code '$iCode' should contain only alpha numeric values!")
|
||||
->danger()
|
||||
->duration(5000)
|
||||
->send();
|
||||
} elseif (! preg_match('/^[a-zA-Z1-9][a-zA-Z0-9]{5,}$/', $iCode)) {
|
||||
Notification::make()
|
||||
->title('Invalid Item Code')
|
||||
->body("Item code '{$iCode}' should not begin with '0'!")
|
||||
->danger()
|
||||
->duration(5000)
|
||||
->send();
|
||||
@@ -117,22 +163,42 @@ class LeakTestValidation extends Page
|
||||
->danger()
|
||||
->duration(5000)
|
||||
->send();
|
||||
} elseif (! ctype_alnum($sNumber)) {
|
||||
Notification::make()
|
||||
->title('Invalid Serial Number')
|
||||
->body("Serial number '$sNumber' should contain only alpha numeric values!")
|
||||
->danger()
|
||||
->duration(5000)
|
||||
->send();
|
||||
} elseif (! preg_match('/^[1-9][a-zA-Z0-9]{8,}$/', $sNumber)) {
|
||||
Notification::make()
|
||||
->title('Invalid Serial Number')
|
||||
->body("Serial number '{$sNumber}' should not begin with '0' or letter!")
|
||||
->danger()
|
||||
->duration(5000)
|
||||
->send();
|
||||
} else {
|
||||
$leakTestQrExists = LeakTestReading::where('plant_id', $plantId)->where('item_code', $iCode)->where('serial_number', $sNumber)->first();
|
||||
$validQr = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (! $leakTestQrExists) {
|
||||
Notification::make()
|
||||
->title('Leak Test QR Not Found')
|
||||
->danger()
|
||||
->duration(5000)
|
||||
->send();
|
||||
} else {
|
||||
Notification::make()
|
||||
->title('Leak Test QR Found')
|
||||
->success()
|
||||
->duration(5000)
|
||||
->send();
|
||||
}
|
||||
if ($validQr) {
|
||||
$leakTestQrExists = LeakTestReading::where('plant_id', $plantId)->where('serial_number', $sNumber)->latest()->first();
|
||||
|
||||
if (! $leakTestQrExists) {
|
||||
Notification::make()
|
||||
->title('No leak test readings found!')
|
||||
->danger()
|
||||
->duration(5000)
|
||||
->send();
|
||||
} else {
|
||||
$leakStat = ($leakTestQrExists->test_status == 'P') ? 'Pass' : 'Fail';
|
||||
Notification::make()
|
||||
->title('Leak Test Readings Found')
|
||||
->body("Item Code : {$leakTestQrExists->item_code} <br> Serial Number : {$leakTestQrExists->serial_number} <br> Test Status : {$leakStat} <br> Created At : {$leakTestQrExists->created_at->format('d-m-Y H:i:s')}")
|
||||
->success()
|
||||
->duration(5000)
|
||||
->send();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user