Updated validation logic to allow greater than or equal to 1 on sticker types #662
@@ -179,6 +179,35 @@ class StickerMasterImporter extends Importer
|
||||
$part5 = trim($this->data['part_validation5']);
|
||||
$laserPart1 = trim($this->data['laser_part_validation1']);
|
||||
$laserPart2 = trim($this->data['laser_part_validation2']);
|
||||
$SerialNumberMotor = trim($this->data['serial_number_motor']) ?? null;
|
||||
$SerialNumberMotor = ($SerialNumberMotor == '0') ? null : $SerialNumberMotor;
|
||||
$SerialNumberPump = trim($this->data['serial_number_pump']) ?? null;
|
||||
$SerialNumberPump = ($SerialNumberPump == '0') ? null : $SerialNumberPump;
|
||||
$SerialNumberPumpSet = trim($this->data['serial_number_pumpset']) ?? null;
|
||||
$SerialNumberPumpSet = ($SerialNumberPumpSet == '0') ? null : $SerialNumberPumpSet;
|
||||
$PackSlipMotor = trim($this->data['pack_slip_motor']) ?? null;
|
||||
$PackSlipMotor = ($PackSlipMotor == '0') ? null : $PackSlipMotor;
|
||||
$PackSlipPump = trim($this->data['pack_slip_pump']) ?? null;
|
||||
$PackSlipPump = ($PackSlipPump == '0') ? null : $PackSlipPump;
|
||||
$PackSlipPumpSet = trim($this->data['pack_slip_pumpset']) ?? null;
|
||||
$PackSlipPumpSet = ($PackSlipPumpSet == '0') ? null : $PackSlipPumpSet;
|
||||
$NamePlateMotor = trim($this->data['name_plate_motor']) ?? null;
|
||||
$NamePlateMotor = ($NamePlateMotor == '0') ? null : $NamePlateMotor;
|
||||
$NamePlatePump = trim($this->data['name_plate_pump']) ?? null;
|
||||
$NamePlatePump = ($NamePlatePump == '0') ? null : $NamePlatePump;
|
||||
$NamePlatePumpSet = trim($this->data['name_plate_pumpset']) ?? null;
|
||||
$NamePlatePumpSet = ($NamePlatePumpSet == '0') ? null : $NamePlatePumpSet;
|
||||
$TubeStickMotor = trim($this->data['tube_sticker_motor']) ?? null;
|
||||
$TubeStickMotor = ($TubeStickMotor == '0') ? null : $TubeStickMotor;
|
||||
$TubeStickPump = trim($this->data['tube_sticker_pump']) ?? null;
|
||||
$TubeStickPump = ($TubeStickPump == '0') ? null : $TubeStickPump;
|
||||
$TubeStickPumpSet = trim($this->data['tube_sticker_pumpset']) ?? null;
|
||||
$TubeStickPumpSet = ($TubeStickPumpSet == '0') ? null : $TubeStickPumpSet;
|
||||
$WarrantyCard = trim($this->data['warranty_card']) ?? null;
|
||||
$WarrantyCard = ($WarrantyCard == '0') ? null : $WarrantyCard;
|
||||
$LoadRate = $this->data['load_rate'] ?? 0;
|
||||
$BundleQuantity = $this->data['bundle_quantity'] ?? null;
|
||||
$MaterialType = $this->data['material_type'] ?? null;
|
||||
|
||||
$createdBy = Filament::auth()->user()->name;
|
||||
$updatedBy = Filament::auth()->user()->name;
|
||||
@@ -195,19 +224,19 @@ class StickerMasterImporter extends Importer
|
||||
}
|
||||
|
||||
if (! $plant) {
|
||||
$warnMsg[] = 'Plant not found';
|
||||
$warnMsg[] = 'Plant not found!';
|
||||
} else {
|
||||
$plantId = $plant->id;
|
||||
if (Str::length($itemCod) < 6 || ! ctype_alnum($itemCod)) {
|
||||
$warnMsg[] = 'Invalid item code found';
|
||||
$warnMsg[] = 'Invalid item code found!';
|
||||
} else {
|
||||
$item = Item::where('code', $itemCod)->first();
|
||||
if (! $item) {
|
||||
$warnMsg[] = 'Item code not found';
|
||||
$warnMsg[] = 'Item code not found!';
|
||||
} else {
|
||||
$item = Item::where('code', $itemCod)->where('plant_id', $plantId)->first();
|
||||
if (! $item) {
|
||||
$warnMsg[] = 'Item code not found for the plant';
|
||||
$warnMsg[] = 'Item code not found for the plant!';
|
||||
} else {
|
||||
$itemId = $item->id;
|
||||
|
||||
@@ -217,7 +246,7 @@ class StickerMasterImporter extends Importer
|
||||
}
|
||||
|
||||
if (Str::length($panelCod) > 0 && (Str::length($panelCod) < 6 || ! ctype_alnum($panelCod))) {
|
||||
$warnMsg[] = 'Invalid panel box code found';
|
||||
$warnMsg[] = 'Invalid panel box code found!';
|
||||
} elseif ($panelCod) {
|
||||
$parts = [$part1, $part2, $part3, $part4];
|
||||
$validParts = array_values(array_filter($parts, fn ($p) => ! empty($p)));
|
||||
@@ -228,53 +257,53 @@ class StickerMasterImporter extends Importer
|
||||
[$part1, $part2, $part3, $part4, $part5] = array_pad($validParts, 5, '');
|
||||
}
|
||||
|
||||
if (Str::length($this->data['serial_number_motor']) > 0 && $this->data['serial_number_motor'] != '1') {
|
||||
$warnMsg[] = 'Serial number motor must be 1 or empty';
|
||||
if (Str::length($SerialNumberMotor) > 0 && (! is_numeric($SerialNumberMotor) || $SerialNumberMotor < 1)) {
|
||||
$warnMsg[] = "Serial number motor must be greater than or equal to '1' or empty!";
|
||||
}
|
||||
if (Str::length($this->data['serial_number_pump']) > 0 && $this->data['serial_number_pump'] != '1') {
|
||||
$warnMsg[] = 'Serial number pump must be 1 or empty';
|
||||
if (Str::length($SerialNumberPump) > 0 && (! is_numeric($SerialNumberPump) || $SerialNumberPump < 1)) {
|
||||
$warnMsg[] = "Serial number pump must be greater than or equal to '1' or empty!";
|
||||
}
|
||||
if (Str::length($this->data['serial_number_pumpset']) > 0 && $this->data['serial_number_pumpset'] != '1') {
|
||||
$warnMsg[] = 'Serial number pumpset must be 1 or empty';
|
||||
if (Str::length($SerialNumberPumpSet) > 0 && (! is_numeric($SerialNumberPumpSet) || $SerialNumberPumpSet < 1)) {
|
||||
$warnMsg[] = "Serial number pumpset must be greater than or equal to '1' or empty!";
|
||||
}
|
||||
if (Str::length($this->data['pack_slip_motor']) > 0 && $this->data['pack_slip_motor'] != '1') {
|
||||
$warnMsg[] = 'Pack slip motor must be 1 or empty';
|
||||
if (Str::length($PackSlipMotor) > 0 && (! is_numeric($PackSlipMotor) || $PackSlipMotor < 1)) {
|
||||
$warnMsg[] = "Pack slip motor must be greater than or equal to '1' or empty!";
|
||||
}
|
||||
if (Str::length($this->data['pack_slip_pump']) > 0 && $this->data['pack_slip_pump'] != '1') {
|
||||
$warnMsg[] = 'Pack slip pump must be 1 or empty';
|
||||
if (Str::length($PackSlipPump) > 0 && (! is_numeric($PackSlipPump) || $PackSlipPump < 1)) {
|
||||
$warnMsg[] = "Pack slip pump must be greater than or equal to '1' or empty!";
|
||||
}
|
||||
if (Str::length($this->data['pack_slip_pumpset']) > 0 && $this->data['pack_slip_pumpset'] != '1') {
|
||||
$warnMsg[] = 'Pack slip pumpset must be 1 or empty';
|
||||
if (Str::length($PackSlipPumpSet) > 0 && (! is_numeric($PackSlipPumpSet) || $PackSlipPumpSet < 1)) {
|
||||
$warnMsg[] = "Pack slip pumpset must be greater than or equal to '1' or empty!";
|
||||
}
|
||||
if (Str::length($this->data['name_plate_motor']) > 0 && $this->data['name_plate_motor'] != '1') {
|
||||
$warnMsg[] = 'Name plate motor must be 1 or empty';
|
||||
if (Str::length($NamePlateMotor) > 0 && (! is_numeric($NamePlateMotor) || $NamePlateMotor < 1)) {
|
||||
$warnMsg[] = "Name plate motor must be greater than or equal to '1' or empty!";
|
||||
}
|
||||
if (Str::length($this->data['name_plate_pump']) > 0 && $this->data['name_plate_pump'] != '1') {
|
||||
$warnMsg[] = 'Name plate pump must be 1 or empty';
|
||||
if (Str::length($NamePlatePump) > 0 && (! is_numeric($NamePlatePump) || $NamePlatePump < 1)) {
|
||||
$warnMsg[] = "Name plate pump must be greater than or equal to '1' or empty!";
|
||||
}
|
||||
if (Str::length($this->data['name_plate_pumpset']) > 0 && $this->data['name_plate_pumpset'] != '1') {
|
||||
$warnMsg[] = 'Name plate pumpset must be 1 or empty';
|
||||
if (Str::length($NamePlatePumpSet) > 0 && (! is_numeric($NamePlatePumpSet) || $NamePlatePumpSet < 1)) {
|
||||
$warnMsg[] = "Name plate pumpset must be greater than or equal to '1' or empty!";
|
||||
}
|
||||
if (Str::length($this->data['tube_sticker_motor']) > 0 && $this->data['tube_sticker_motor'] != '1') {
|
||||
$warnMsg[] = 'Tube sticker motor must be 1 or empty';
|
||||
if (Str::length($TubeStickMotor) > 0 && (! is_numeric($TubeStickMotor) || $TubeStickMotor < 1)) {
|
||||
$warnMsg[] = "Tube sticker motor must be greater than or equal to '1' or empty!";
|
||||
}
|
||||
if (Str::length($this->data['tube_sticker_pump']) > 0 && $this->data['tube_sticker_pump'] != '1') {
|
||||
$warnMsg[] = 'Tube sticker pump must be 1 or empty';
|
||||
if (Str::length($TubeStickPump) > 0 && (! is_numeric($TubeStickPump) || $TubeStickPump < 1)) {
|
||||
$warnMsg[] = "Tube sticker pump must be greater than or equal to '1' or empty!";
|
||||
}
|
||||
if (Str::length($this->data['tube_sticker_pumpset']) > 0 && $this->data['tube_sticker_pumpset'] != '1') {
|
||||
$warnMsg[] = 'Tube sticker pumpset must be 1 or empty';
|
||||
if (Str::length($TubeStickPumpSet) > 0 && (! is_numeric($TubeStickPumpSet) || $TubeStickPumpSet < 1)) {
|
||||
$warnMsg[] = "Tube sticker pumpset must be greater than or equal to '1' or empty!";
|
||||
}
|
||||
if (Str::length($this->data['warranty_card']) > 0 && $this->data['warranty_card'] != '1') {
|
||||
$warnMsg[] = 'Warranty card must be 1 or empty';
|
||||
if (Str::length($WarrantyCard) > 0 && (! is_numeric($WarrantyCard) || $WarrantyCard < 1)) {
|
||||
$warnMsg[] = "Warranty card must be greater than or equal to '1' or empty!";
|
||||
}
|
||||
if (Str::length($this->data['load_rate']) < 0 || ! is_numeric($this->data['load_rate']) || $this->data['load_rate'] < 0) {
|
||||
$warnMsg[] = 'Load rate must be greater than or equal to 0';
|
||||
if (Str::length($LoadRate) < 0 || ! is_numeric($LoadRate) || $LoadRate < 0) {
|
||||
$warnMsg[] = "Load rate must be greater than or equal to '0'!";
|
||||
}
|
||||
if (Str::length($this->data['bundle_quantity']) > 0 && (! is_numeric($this->data['bundle_quantity']) || $this->data['bundle_quantity'] <= 1)) {
|
||||
$warnMsg[] = "Bundle quantity must be greater than or equal to '2' or empty";
|
||||
if (Str::length($BundleQuantity) > 0 && (! is_numeric($BundleQuantity) || $BundleQuantity <= 1)) {
|
||||
$warnMsg[] = "Bundle quantity must be greater than or equal to '2' or empty!";
|
||||
}
|
||||
if (Str::length($this->data['material_type']) > 0 && $this->data['material_type'] != '1' && $this->data['material_type'] != '2' && $this->data['material_type'] != '3' && $this->data['material_type'] != '4') { // ($this->data['material_type'] != null) &&
|
||||
$warnMsg[] = 'Material type must be 1 or 2 or 3 or 4 or empty';
|
||||
if (Str::length($MaterialType) > 0 && $MaterialType != '1' && $MaterialType != '2' && $MaterialType != '3' && $MaterialType != '4') { // ($this->data['material_type'] != null) &&
|
||||
$warnMsg[] = "Material type must be '1' or '2' or '3' or '4' or empty!";
|
||||
}
|
||||
|
||||
if (empty($warnMsg)) {
|
||||
@@ -298,19 +327,19 @@ class StickerMasterImporter extends Importer
|
||||
'plant_id' => $plantId,
|
||||
],
|
||||
[
|
||||
'serial_number_motor' => $this->data['serial_number_motor'],
|
||||
'serial_number_pump' => $this->data['serial_number_pump'],
|
||||
'serial_number_pumpset' => $this->data['serial_number_pumpset'],
|
||||
'pack_slip_motor' => $this->data['pack_slip_motor'],
|
||||
'pack_slip_pump' => $this->data['pack_slip_pump'],
|
||||
'pack_slip_pumpset' => $this->data['pack_slip_pumpset'],
|
||||
'name_plate_motor' => $this->data['name_plate_motor'],
|
||||
'name_plate_pump' => $this->data['name_plate_pump'],
|
||||
'name_plate_pumpset' => $this->data['name_plate_pumpset'],
|
||||
'tube_sticker_motor' => $this->data['tube_sticker_motor'],
|
||||
'tube_sticker_pump' => $this->data['tube_sticker_pump'],
|
||||
'tube_sticker_pumpset' => $this->data['tube_sticker_pumpset'],
|
||||
'warranty_card' => $this->data['warranty_card'],
|
||||
'serial_number_motor' => $SerialNumberMotor,
|
||||
'serial_number_pump' => $SerialNumberPump,
|
||||
'serial_number_pumpset' => $SerialNumberPumpSet,
|
||||
'pack_slip_motor' => $PackSlipMotor,
|
||||
'pack_slip_pump' => $PackSlipPump,
|
||||
'pack_slip_pumpset' => $PackSlipPumpSet,
|
||||
'name_plate_motor' => $NamePlateMotor,
|
||||
'name_plate_pump' => $NamePlatePump,
|
||||
'name_plate_pumpset' => $NamePlatePumpSet,
|
||||
'tube_sticker_motor' => $TubeStickMotor,
|
||||
'tube_sticker_pump' => $TubeStickPump,
|
||||
'tube_sticker_pumpset' => $TubeStickPumpSet,
|
||||
'warranty_card' => $WarrantyCard,
|
||||
'part_validation1' => $part1,
|
||||
'part_validation2' => $part2,
|
||||
'part_validation3' => $part3,
|
||||
@@ -319,9 +348,9 @@ class StickerMasterImporter extends Importer
|
||||
'laser_part_validation1' => $laserPart1,
|
||||
'laser_part_validation2' => $laserPart2,
|
||||
'panel_box_code' => $panelCod,
|
||||
'load_rate' => $this->data['load_rate'],
|
||||
'bundle_quantity' => $this->data['bundle_quantity'],
|
||||
'material_type' => $this->data['material_type'],
|
||||
'load_rate' => $LoadRate,
|
||||
'material_type' => $MaterialType,
|
||||
'bundle_quantity' => $BundleQuantity,
|
||||
'created_by' => $createdBy,
|
||||
'updated_by' => $updatedBy,
|
||||
]);
|
||||
|
||||
Reference in New Issue
Block a user