Added view rights against plant on import and export and Validation logic updated
All checks were successful
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 10s
All checks were successful
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 10s
This commit is contained in:
@@ -24,10 +24,10 @@ class QualityValidationExporter extends Exporter
|
|||||||
// Increment and return the row number
|
// Increment and return the row number
|
||||||
return ++$rowNumber;
|
return ++$rowNumber;
|
||||||
}),
|
}),
|
||||||
ExportColumn::make('plant.name')
|
ExportColumn::make('plant.code')
|
||||||
->label('PLANT'),
|
->label('PLANT CODE'),
|
||||||
ExportColumn::make('line.name')
|
ExportColumn::make('line.name')
|
||||||
->label('LINE'),
|
->label('LINE NAME'),
|
||||||
ExportColumn::make('production_order')
|
ExportColumn::make('production_order')
|
||||||
->label('PRODUCTION ORDER'),
|
->label('PRODUCTION ORDER'),
|
||||||
ExportColumn::make('serial_number')
|
ExportColumn::make('serial_number')
|
||||||
@@ -54,14 +54,14 @@ class QualityValidationExporter extends Exporter
|
|||||||
->label('NAME PLATE PUMP'),
|
->label('NAME PLATE PUMP'),
|
||||||
ExportColumn::make('name_plate_pumpset')
|
ExportColumn::make('name_plate_pumpset')
|
||||||
->label('NAME PLATE PUMPSET'),
|
->label('NAME PLATE PUMPSET'),
|
||||||
|
ExportColumn::make('warranty_card')
|
||||||
|
->label('WARRANTY CARD'),
|
||||||
ExportColumn::make('tube_sticker_motor')
|
ExportColumn::make('tube_sticker_motor')
|
||||||
->label('TUBE STICKER MOTOR'),
|
->label('TUBE STICKER MOTOR'),
|
||||||
ExportColumn::make('tube_sticker_pump')
|
ExportColumn::make('tube_sticker_pump')
|
||||||
->label('TUBE STICKER PUMP'),
|
->label('TUBE STICKER PUMP'),
|
||||||
ExportColumn::make('tube_sticker_pumpset')
|
ExportColumn::make('tube_sticker_pumpset')
|
||||||
->label('TUBE STICKER PUMPSET'),
|
->label('TUBE STICKER PUMPSET'),
|
||||||
ExportColumn::make('warranty_card')
|
|
||||||
->label('WARRANTY CARD'),
|
|
||||||
ExportColumn::make('part_validation1')
|
ExportColumn::make('part_validation1')
|
||||||
->label('PART VALIDATION 1'),
|
->label('PART VALIDATION 1'),
|
||||||
ExportColumn::make('part_validation2')
|
ExportColumn::make('part_validation2')
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ use Filament\Actions\Imports\ImportColumn;
|
|||||||
use Filament\Actions\Imports\Importer;
|
use Filament\Actions\Imports\Importer;
|
||||||
use Filament\Actions\Imports\Models\Import;
|
use Filament\Actions\Imports\Models\Import;
|
||||||
use Filament\Facades\Filament;
|
use Filament\Facades\Filament;
|
||||||
use Illuminate\Validation\Rule;
|
|
||||||
use Str;
|
use Str;
|
||||||
|
|
||||||
class QualityValidationImporter extends Importer
|
class QualityValidationImporter extends Importer
|
||||||
@@ -101,6 +100,11 @@ class QualityValidationImporter extends Importer
|
|||||||
->exampleHeader('Name Plate PumpSet')
|
->exampleHeader('Name Plate PumpSet')
|
||||||
->example('1')
|
->example('1')
|
||||||
->label('Name Plate PumpSet'),
|
->label('Name Plate PumpSet'),
|
||||||
|
ImportColumn::make('warranty_card')
|
||||||
|
->requiredMapping()
|
||||||
|
->exampleHeader('Warranty Card')
|
||||||
|
->example('1')
|
||||||
|
->label('Warranty Card'),
|
||||||
ImportColumn::make('tube_sticker_motor')
|
ImportColumn::make('tube_sticker_motor')
|
||||||
->requiredMapping()
|
->requiredMapping()
|
||||||
->exampleHeader('Tube Sticker Motor')
|
->exampleHeader('Tube Sticker Motor')
|
||||||
@@ -116,11 +120,6 @@ class QualityValidationImporter extends Importer
|
|||||||
->exampleHeader('Tube Sticker PumpSet')
|
->exampleHeader('Tube Sticker PumpSet')
|
||||||
->example('1')
|
->example('1')
|
||||||
->label('Tube Sticker PumpSet'),
|
->label('Tube Sticker PumpSet'),
|
||||||
ImportColumn::make('warranty_card')
|
|
||||||
->requiredMapping()
|
|
||||||
->exampleHeader('Warranty Card')
|
|
||||||
->example('1')
|
|
||||||
->label('Warranty Card'),
|
|
||||||
ImportColumn::make('part_validation1')
|
ImportColumn::make('part_validation1')
|
||||||
->requiredMapping()
|
->requiredMapping()
|
||||||
->exampleHeader('Part Validation 1')
|
->exampleHeader('Part Validation 1')
|
||||||
@@ -160,10 +159,10 @@ class QualityValidationImporter extends Importer
|
|||||||
->rules(['required']),
|
->rules(['required']),
|
||||||
ImportColumn::make('plant')
|
ImportColumn::make('plant')
|
||||||
->requiredMapping()
|
->requiredMapping()
|
||||||
->exampleHeader('Plant Name')
|
->exampleHeader('Plant Code')
|
||||||
->example('Ransar Industries-I')
|
->example('1000')
|
||||||
->label('Plant Name')
|
->label('Plant Code')
|
||||||
->relationship(resolveUsing:'name')
|
->relationship(resolveUsing: 'code')
|
||||||
->rules(['required']),
|
->rules(['required']),
|
||||||
ImportColumn::make('updated_at')
|
ImportColumn::make('updated_at')
|
||||||
->requiredMapping()
|
->requiredMapping()
|
||||||
@@ -183,13 +182,19 @@ class QualityValidationImporter extends Importer
|
|||||||
public function resolveRecord(): ?QualityValidation
|
public function resolveRecord(): ?QualityValidation
|
||||||
{
|
{
|
||||||
$warnMsg = [];
|
$warnMsg = [];
|
||||||
$plant = Plant::where('name', $this->data['plant'])->first();
|
$plantCod = $this->data['plant'];
|
||||||
|
$plant = null;
|
||||||
$line = null;
|
$line = null;
|
||||||
$stickMaster = null;
|
$stickMaster = null;
|
||||||
if (!$plant) {
|
if (Str::length($plantCod) < 4 || ! is_numeric($plantCod) || ! preg_match('/^[1-9]\d{3,}$/', $plantCod)) {
|
||||||
$warnMsg[] = "Plant not found";
|
$warnMsg[] = 'Invalid plant code found';
|
||||||
|
} else {
|
||||||
|
$plant = Plant::where('code', $plantCod)->first();
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
|
if (! $plant) {
|
||||||
|
$warnMsg[] = 'Plant not found';
|
||||||
|
} else {
|
||||||
$line = Line::where('name', $this->data['line'])->where('plant_id', $plant->id)->first();
|
$line = Line::where('name', $this->data['line'])->where('plant_id', $plant->id)->first();
|
||||||
$uniqueCode = trim($this->data['sticker_master_id_code']); // stickerMaster.item
|
$uniqueCode = trim($this->data['sticker_master_id_code']); // stickerMaster.item
|
||||||
$stickMaster = StickerMaster::select('id')->with('item')
|
$stickMaster = StickerMaster::select('id')->with('item')
|
||||||
@@ -199,19 +204,19 @@ class QualityValidationImporter extends Importer
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (! $line) {
|
if (! $line) {
|
||||||
$warnMsg[] = "Line not found";
|
$warnMsg[] = 'Line not found';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! $stickMaster) {
|
if (! $stickMaster) {
|
||||||
$warnMsg[] = "Sticker item code not found";
|
$warnMsg[] = 'Sticker item code not found';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! is_numeric($this->data['production_order']) || Str::length($this->data['production_order']) < 7 || Str::length($this->data['production_order']) > 14) {
|
if (! is_numeric($this->data['production_order']) || Str::length($this->data['production_order']) < 7 || Str::length($this->data['production_order']) > 14) {
|
||||||
$warnMsg[] = "Invalid production order found";
|
$warnMsg[] = 'Invalid production order found';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! ctype_alnum($this->data['serial_number']) || Str::length($this->data['serial_number']) < 9) {
|
if (! ctype_alnum($this->data['serial_number']) || Str::length($this->data['serial_number']) < 9) {
|
||||||
$warnMsg[] = "Invalid serial number found";
|
$warnMsg[] = 'Invalid serial number found';
|
||||||
}
|
}
|
||||||
// dd($stickMaster);
|
// dd($stickMaster);
|
||||||
|
|
||||||
@@ -221,7 +226,7 @@ class QualityValidationImporter extends Importer
|
|||||||
|
|
||||||
$user = User::where('name', $this->data['operator_id'])->first();
|
$user = User::where('name', $this->data['operator_id'])->first();
|
||||||
if (! $user) {
|
if (! $user) {
|
||||||
$warnMsg[] = "Operator ID not found";
|
$warnMsg[] = 'Operator ID not found';
|
||||||
}
|
}
|
||||||
$fromDate = $this->data['created_at'];
|
$fromDate = $this->data['created_at'];
|
||||||
$toDate = $this->data['updated_at'];
|
$toDate = $this->data['updated_at'];
|
||||||
@@ -282,7 +287,7 @@ class QualityValidationImporter extends Importer
|
|||||||
QualityValidation::updateOrCreate([
|
QualityValidation::updateOrCreate([
|
||||||
'plant_id' => $plant->id,
|
'plant_id' => $plant->id,
|
||||||
'sticker_master_id' => $stickMaster, // ->id
|
'sticker_master_id' => $stickMaster, // ->id
|
||||||
'serial_number' => $this->data['serial_number']
|
'serial_number' => $this->data['serial_number'],
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'line_id' => $line->id,
|
'line_id' => $line->id,
|
||||||
|
|||||||
Reference in New Issue
Block a user