ranjith-dev #415
@@ -28,6 +28,8 @@ class ProcessOrderExporter extends Exporter
|
|||||||
->label('LINE NAME'),
|
->label('LINE NAME'),
|
||||||
ExportColumn::make('item.code')
|
ExportColumn::make('item.code')
|
||||||
->label('ITEM CODE'),
|
->label('ITEM CODE'),
|
||||||
|
ExportColumn::make('item.description')
|
||||||
|
->label('ITEM DESCRIPTION'),
|
||||||
ExportColumn::make('process_order')
|
ExportColumn::make('process_order')
|
||||||
->label('PROCESS ORDER'),
|
->label('PROCESS ORDER'),
|
||||||
ExportColumn::make('coil_number')
|
ExportColumn::make('coil_number')
|
||||||
|
|||||||
@@ -110,7 +110,7 @@ class ProductCharacteristicsMasterImporter extends Importer
|
|||||||
$groupWorkCenter = trim($this->data['work_group_master_id']) ?? null;
|
$groupWorkCenter = trim($this->data['work_group_master_id']) ?? null;
|
||||||
$workCenter = trim($this->data['machine']) ?? null;
|
$workCenter = trim($this->data['machine']) ?? null;
|
||||||
$charTyp = trim($this->data['characteristics_type']) ?? null;
|
$charTyp = trim($this->data['characteristics_type']) ?? null;
|
||||||
$charName = trim($this->data['name']) ?? null;
|
$charNam = trim($this->data['name']) ?? null;
|
||||||
$inspectTyp = trim($this->data['inspection_type']) ?? null;
|
$inspectTyp = trim($this->data['inspection_type']) ?? null;
|
||||||
$lower = trim($this->data['lower']) ?? null;
|
$lower = trim($this->data['lower']) ?? null;
|
||||||
$middle = trim($this->data['middle']) ?? null;
|
$middle = trim($this->data['middle']) ?? null;
|
||||||
@@ -123,6 +123,7 @@ class ProductCharacteristicsMasterImporter extends Importer
|
|||||||
$lineId = null;
|
$lineId = null;
|
||||||
$workGroupMasterId = null;
|
$workGroupMasterId = null;
|
||||||
$machineId = null;
|
$machineId = null;
|
||||||
|
|
||||||
if ($plantCod == null || $plantCod == '') {
|
if ($plantCod == null || $plantCod == '') {
|
||||||
$warnMsg[] = "Plant code can't be empty!";
|
$warnMsg[] = "Plant code can't be empty!";
|
||||||
} elseif (Str::length($plantCod) < 4 || ! is_numeric($plantCod) || ! preg_match('/^[1-9]\d{3,}$/', $plantCod)) {
|
} elseif (Str::length($plantCod) < 4 || ! is_numeric($plantCod) || ! preg_match('/^[1-9]\d{3,}$/', $plantCod)) {
|
||||||
@@ -142,23 +143,19 @@ class ProductCharacteristicsMasterImporter extends Importer
|
|||||||
if ($workCenter == null || $workCenter == '') {
|
if ($workCenter == null || $workCenter == '') {
|
||||||
$warnMsg[] = "Work center can't be empty!";
|
$warnMsg[] = "Work center can't be empty!";
|
||||||
}
|
}
|
||||||
if ($charTyp == null || $charTyp == '') {
|
if ($charTyp != 'Product' && $charTyp != 'Process') {
|
||||||
$warnMsg[] = "Characteristics type can't be empty!";
|
$warnMsg[] = "Characteristics type must be either 'Product' or 'Process'!";
|
||||||
}
|
}
|
||||||
if ($charName == null || $charName == '') {
|
if ($charNam == null || $charNam == '') {
|
||||||
$warnMsg[] = "Characteristics name can't be empty!";
|
$warnMsg[] = "Characteristics name can't be empty!";
|
||||||
}
|
}
|
||||||
if ($inspectTyp == null || $inspectTyp == '') {
|
if ($inspectTyp != 'Visual' && $inspectTyp != 'Value') {
|
||||||
$warnMsg[] = "Inspection type can't be empty!";
|
$warnMsg[] = "Inspection type must be either 'Visual' or 'Value'!";
|
||||||
}
|
}
|
||||||
if ($lower == null || $lower == '') {
|
if ($lower == null || $lower == '' || $middle == null || $middle == '' || $upper == null || $upper == '' || $upper == 0 || $upper == '0') {
|
||||||
$warnMsg[] = "Lower value can't be empty!";
|
$lower = 0;
|
||||||
}
|
$middle = 0;
|
||||||
if ($middle == null || $middle == '') {
|
$upper = 0;
|
||||||
$warnMsg[] = "Middle value can't be empty!";
|
|
||||||
}
|
|
||||||
if ($upper == null || $upper == '') {
|
|
||||||
$warnMsg[] = "Upper value can't be empty!";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! empty($warnMsg)) {
|
if (! empty($warnMsg)) {
|
||||||
@@ -229,12 +226,12 @@ class ProductCharacteristicsMasterImporter extends Importer
|
|||||||
$machine = Machine::where('work_center', $workCenter)->where('plant_id', $plantId)->where('line_id', $lineId)->first();
|
$machine = Machine::where('work_center', $workCenter)->where('plant_id', $plantId)->where('line_id', $lineId)->first();
|
||||||
|
|
||||||
if (! $machine) {
|
if (! $machine) {
|
||||||
$warnMsg[] = 'Work center not found for the given line!';
|
$warnMsg[] = "Work center '{$workCenter}' is not mapped for the given line!";
|
||||||
} else {
|
} else {
|
||||||
$machine = Machine::where('work_center', $workCenter)->where('plant_id', $plantId)->where('line_id', $lineId)->where('work_group_master_id', $workGroupMasterId)->first();
|
$machine = Machine::where('work_center', $workCenter)->where('plant_id', $plantId)->where('line_id', $lineId)->where('work_group_master_id', $workGroupMasterId)->first();
|
||||||
|
|
||||||
if (! $machine) {
|
if (! $machine) {
|
||||||
$warnMsg[] = 'Work center not found for the given group work center!';
|
$warnMsg[] = "Work center '{$workCenter}' is not mapped for the given group work center!";
|
||||||
} else {
|
} else {
|
||||||
$machineId = $machine->id;
|
$machineId = $machine->id;
|
||||||
}
|
}
|
||||||
@@ -259,17 +256,22 @@ class ProductCharacteristicsMasterImporter extends Importer
|
|||||||
$warnMsg[] = 'Upper, Lower, and Middle values are required.';
|
$warnMsg[] = 'Upper, Lower, and Middle values are required.';
|
||||||
} elseif (! is_numeric($upper) || ! is_numeric($lower) || ! is_numeric($middle)) {
|
} elseif (! is_numeric($upper) || ! is_numeric($lower) || ! is_numeric($middle)) {
|
||||||
$warnMsg[] = 'Upper, Lower, and Middle values must be numeric.';
|
$warnMsg[] = 'Upper, Lower, and Middle values must be numeric.';
|
||||||
} elseif ($lower == $upper) {
|
} else {
|
||||||
if ($lower != $middle) {
|
$lower = (float) $lower;
|
||||||
$warnMsg[] = "For 'Value' inspection type, values must satisfy: Lower = Middle = Upper.";
|
$middle = (float) $middle;
|
||||||
|
$upper = (float) $upper;
|
||||||
|
if ($lower == $upper) {
|
||||||
|
if ($lower != $middle) {
|
||||||
|
$warnMsg[] = "For 'Value' inspection type, values must satisfy: Lower = Middle = Upper.";
|
||||||
|
}
|
||||||
|
} elseif (! ($lower < $middle && $middle < $upper)) {
|
||||||
|
$warnMsg[] = "For 'Value' inspection type, values must satisfy: Lower < Middle < Upper.";
|
||||||
}
|
}
|
||||||
} elseif (! ($lower < $middle && $middle < $upper)) {
|
|
||||||
$warnMsg[] = "For 'Value' inspection type, values must satisfy: Lower < Middle < Upper.";
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$lower = null;
|
$lower = 0;
|
||||||
$middle = null;
|
$middle = 0;
|
||||||
$upper = null;
|
$upper = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -278,10 +280,9 @@ class ProductCharacteristicsMasterImporter extends Importer
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($machineId) {
|
if ($machineId) {
|
||||||
$record = ProductCharacteristicsMaster::where('plant_id', $plantId)->where('line_id', $lineId)->where('work_group_master_id', $workGroupMasterId)->where('machine_id', $machineId)->where('item_id', $itemId)->first();
|
$record = ProductCharacteristicsMaster::where('plant_id', $plantId)->where('line_id', $lineId)->where('work_group_master_id', $workGroupMasterId)->where('machine_id', $machineId)->where('item_id', $itemId)->where('characteristics_type', $charTyp)->where('name', $charNam)->first();
|
||||||
// ->where('characteristics_type', $get('characteristics_type'))
|
|
||||||
if ($record) {
|
if ($record) {
|
||||||
$createdBy = $record->created_by;
|
$createdBy = $record->created_by ?? $createdBy;
|
||||||
}
|
}
|
||||||
|
|
||||||
ProductCharacteristicsMaster::updateOrCreate(
|
ProductCharacteristicsMaster::updateOrCreate(
|
||||||
@@ -291,11 +292,10 @@ class ProductCharacteristicsMasterImporter extends Importer
|
|||||||
'line_id' => $lineId,
|
'line_id' => $lineId,
|
||||||
'work_group_master_id' => $workGroupMasterId,
|
'work_group_master_id' => $workGroupMasterId,
|
||||||
'machine_id' => $machineId,
|
'machine_id' => $machineId,
|
||||||
// 'characteristics_type' => $charTyp,
|
'characteristics_type' => $charTyp,
|
||||||
|
'name' => $charNam,
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'name' => $charName,
|
|
||||||
'characteristics_type' => $charTyp,
|
|
||||||
'inspection_type' => $inspectTyp,
|
'inspection_type' => $inspectTyp,
|
||||||
'lower' => $lower,
|
'lower' => $lower,
|
||||||
'middle' => $middle,
|
'middle' => $middle,
|
||||||
|
|||||||
@@ -50,14 +50,15 @@ class ProcessOrderResource extends Resource
|
|||||||
return $form
|
return $form
|
||||||
->schema([
|
->schema([
|
||||||
Forms\Components\Select::make('plant_id')
|
Forms\Components\Select::make('plant_id')
|
||||||
->label('Plant')
|
->label('Plant Name')
|
||||||
->searchable()
|
|
||||||
->relationship('plant', 'name')
|
->relationship('plant', 'name')
|
||||||
|
->searchable()
|
||||||
->options(function (callable $get) {
|
->options(function (callable $get) {
|
||||||
$userHas = Filament::auth()->user()->plant_id;
|
$userHas = Filament::auth()->user()->plant_id;
|
||||||
|
|
||||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
||||||
})
|
})
|
||||||
|
->disabled(fn (Get $get) => ! empty($get('id')))
|
||||||
->default(function () {
|
->default(function () {
|
||||||
$userHas = Filament::auth()->user()->plant_id;
|
$userHas = Filament::auth()->user()->plant_id;
|
||||||
|
|
||||||
@@ -93,7 +94,8 @@ class ProcessOrderResource extends Resource
|
|||||||
->hintColor('danger')
|
->hintColor('danger')
|
||||||
->required(),
|
->required(),
|
||||||
Forms\Components\Select::make('line_id')
|
Forms\Components\Select::make('line_id')
|
||||||
->label('Line')
|
->label('Line Name')
|
||||||
|
->reactive()
|
||||||
->searchable()
|
->searchable()
|
||||||
->options(function (callable $get) {
|
->options(function (callable $get) {
|
||||||
$plantId = $get('plant_id');
|
$plantId = $get('plant_id');
|
||||||
@@ -103,7 +105,7 @@ class ProcessOrderResource extends Resource
|
|||||||
|
|
||||||
return Line::where('plant_id', $plantId)->pluck('name', 'id');
|
return Line::where('plant_id', $plantId)->pluck('name', 'id');
|
||||||
})
|
})
|
||||||
->reactive()
|
->disabled(fn (Get $get) => ! empty($get('id')))
|
||||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||||
$set('item_id', null);
|
$set('item_id', null);
|
||||||
$set('item_description', null);
|
$set('item_description', null);
|
||||||
@@ -123,6 +125,7 @@ class ProcessOrderResource extends Resource
|
|||||||
// ->relationship('item', 'id')
|
// ->relationship('item', 'id')
|
||||||
// ->required(),
|
// ->required(),
|
||||||
->searchable()
|
->searchable()
|
||||||
|
->reactive()
|
||||||
->options(function (callable $get) {
|
->options(function (callable $get) {
|
||||||
$plantId = $get('plant_id');
|
$plantId = $get('plant_id');
|
||||||
if (empty($plantId)) {
|
if (empty($plantId)) {
|
||||||
@@ -131,7 +134,7 @@ class ProcessOrderResource extends Resource
|
|||||||
|
|
||||||
return Item::where('plant_id', $plantId)->pluck('code', 'id');
|
return Item::where('plant_id', $plantId)->pluck('code', 'id');
|
||||||
})
|
})
|
||||||
->reactive()
|
->disabled(fn (Get $get) => ! empty($get('id')))
|
||||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||||
$plantId = $get('plant_id');
|
$plantId = $get('plant_id');
|
||||||
$itemId = $get('item_id');
|
$itemId = $get('item_id');
|
||||||
@@ -166,9 +169,8 @@ class ProcessOrderResource extends Resource
|
|||||||
$set('updated_by', Filament::auth()->user()?->name);
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
})
|
})
|
||||||
->required(),
|
->required(),
|
||||||
|
|
||||||
Forms\Components\TextInput::make('item_description')
|
Forms\Components\TextInput::make('item_description')
|
||||||
->label('Description')
|
->label('Item Description')
|
||||||
->readOnly()
|
->readOnly()
|
||||||
->required()
|
->required()
|
||||||
->reactive()
|
->reactive()
|
||||||
@@ -187,7 +189,7 @@ class ProcessOrderResource extends Resource
|
|||||||
$set('updated_by', Filament::auth()->user()?->name);
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
}),
|
}),
|
||||||
Forms\Components\TextInput::make('item_uom')
|
Forms\Components\TextInput::make('item_uom')
|
||||||
->label('UOM')
|
->label('Item UOM')
|
||||||
->readOnly()
|
->readOnly()
|
||||||
->required()
|
->required()
|
||||||
->reactive()
|
->reactive()
|
||||||
@@ -262,12 +264,11 @@ class ProcessOrderResource extends Resource
|
|||||||
->first();
|
->first();
|
||||||
|
|
||||||
if ($existing) {
|
if ($existing) {
|
||||||
|
// Notification::make()
|
||||||
Notification::make()
|
// ->title('Duplicate Process Order!')
|
||||||
->title('Duplicate Process Order!')
|
// ->body("Process Order '{$value}' is already exist with item code '{$existing->item->code}'.")
|
||||||
->body("Process Order '{$value}' is already exist with item code '{$existing->item->code}'.")
|
// ->danger()
|
||||||
->danger()
|
// ->send();
|
||||||
->send();
|
|
||||||
$fail("process order already exists for this plant and item code '{$existing->item->code}'.");
|
$fail("process order already exists for this plant and item code '{$existing->item->code}'.");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -445,7 +446,7 @@ class ProcessOrderResource extends Resource
|
|||||||
->hint(fn ($get) => $get('sfgNumberError') ? $get('sfgNumberError') : null)
|
->hint(fn ($get) => $get('sfgNumberError') ? $get('sfgNumberError') : null)
|
||||||
->hintColor('danger'),
|
->hintColor('danger'),
|
||||||
Forms\Components\TextInput::make('machine_name')
|
Forms\Components\TextInput::make('machine_name')
|
||||||
->label('Machine ID')
|
->label('Machine Name')
|
||||||
->reactive()
|
->reactive()
|
||||||
->readOnly(fn ($get) => ($get('process_order') == null))
|
->readOnly(fn ($get) => ($get('process_order') == null))
|
||||||
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
->afterStateUpdated(function (callable $set, callable $get, ?string $state) {
|
||||||
@@ -680,27 +681,27 @@ class ProcessOrderResource extends Resource
|
|||||||
return ($currentPage - 1) * $perPage + $rowLoop->iteration;
|
return ($currentPage - 1) * $perPage + $rowLoop->iteration;
|
||||||
}),
|
}),
|
||||||
Tables\Columns\TextColumn::make('plant.name')
|
Tables\Columns\TextColumn::make('plant.name')
|
||||||
->label('Plant')
|
->label('Plant Name')
|
||||||
->alignCenter()
|
->alignCenter()
|
||||||
->searchable()
|
->searchable()
|
||||||
->sortable(),
|
->sortable(),
|
||||||
Tables\Columns\TextColumn::make('line.name')
|
Tables\Columns\TextColumn::make('line.name')
|
||||||
->label('Line')
|
->label('Line Name')
|
||||||
->searchable()
|
->searchable()
|
||||||
->alignCenter()
|
->alignCenter()
|
||||||
->sortable(),
|
->sortable(),
|
||||||
Tables\Columns\TextColumn::make('item.code')
|
Tables\Columns\TextColumn::make('item.code')
|
||||||
->label('Item')
|
->label('Item Code')
|
||||||
->searchable()
|
->searchable()
|
||||||
->alignCenter()
|
->alignCenter()
|
||||||
->sortable(),
|
->sortable(),
|
||||||
Tables\Columns\TextColumn::make('item.description')
|
Tables\Columns\TextColumn::make('item.description')
|
||||||
->label('Description')
|
->label('Item Description')
|
||||||
->alignCenter()
|
->alignCenter()
|
||||||
->searchable()
|
->searchable()
|
||||||
->sortable(),
|
->sortable(),
|
||||||
Tables\Columns\TextColumn::make('item.uom')
|
Tables\Columns\TextColumn::make('item.uom')
|
||||||
->label('Uom')
|
->label('Item UOM')
|
||||||
->alignCenter()
|
->alignCenter()
|
||||||
->searchable()
|
->searchable()
|
||||||
->sortable(),
|
->sortable(),
|
||||||
@@ -735,7 +736,7 @@ class ProcessOrderResource extends Resource
|
|||||||
->searchable()
|
->searchable()
|
||||||
->sortable(),
|
->sortable(),
|
||||||
Tables\Columns\TextColumn::make('machine_name')
|
Tables\Columns\TextColumn::make('machine_name')
|
||||||
->label('Machine ID')
|
->label('Machine Name')
|
||||||
->alignCenter()
|
->alignCenter()
|
||||||
->searchable()
|
->searchable()
|
||||||
->sortable(),
|
->sortable(),
|
||||||
@@ -778,16 +779,35 @@ class ProcessOrderResource extends Resource
|
|||||||
->label('Advanced Filters')
|
->label('Advanced Filters')
|
||||||
->form([
|
->form([
|
||||||
Select::make('Plant')
|
Select::make('Plant')
|
||||||
->label('Select Plant Name')
|
->label('Search by Plant Name')
|
||||||
->nullable()
|
->nullable()
|
||||||
|
->searchable()
|
||||||
|
->reactive()
|
||||||
->options(function (callable $get) {
|
->options(function (callable $get) {
|
||||||
$userHas = Filament::auth()->user()->plant_id;
|
$userHas = Filament::auth()->user()->plant_id;
|
||||||
|
|
||||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
||||||
})
|
})
|
||||||
->reactive()
|
|
||||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||||
$set('Item', null);
|
$set('Item', null);
|
||||||
|
$set('Line', null);
|
||||||
|
}),
|
||||||
|
Select::make('Line')
|
||||||
|
->label('Search by Line Name')
|
||||||
|
->nullable()
|
||||||
|
->searchable()
|
||||||
|
->reactive()
|
||||||
|
->options(function (callable $get) {
|
||||||
|
$plantId = $get('Plant');
|
||||||
|
|
||||||
|
return Line::whereHas('processOrders', function ($query) use ($plantId) {
|
||||||
|
if ($plantId) {
|
||||||
|
$query->where('plant_id', $plantId);
|
||||||
|
}
|
||||||
|
})->pluck('name', 'id');
|
||||||
|
})
|
||||||
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||||
|
$set('process_order', null);
|
||||||
}),
|
}),
|
||||||
Select::make('Item')
|
Select::make('Item')
|
||||||
->label('Search by Item Code')
|
->label('Search by Item Code')
|
||||||
@@ -847,7 +867,7 @@ class ProcessOrderResource extends Resource
|
|||||||
])
|
])
|
||||||
->query(function ($query, array $data) {
|
->query(function ($query, array $data) {
|
||||||
// Hide all records initially if no filters are applied
|
// Hide all records initially if no filters are applied
|
||||||
if (empty($data['Plant']) && empty($data['Item']) && empty($data['process_order']) && Str::length($data['coil_number']) <= 0 && empty($data['sfg_number']) && empty($data['machine_name']) && ($data['rework_status'] == null || $data['rework_status'] == '') && empty($data['created_from']) && empty($data['created_to'])) {
|
if (empty($data['Plant']) && empty($data['Line']) && empty($data['Item']) && empty($data['process_order']) && Str::length($data['coil_number']) <= 0 && empty($data['sfg_number']) && empty($data['machine_name']) && ($data['rework_status'] == null || $data['rework_status'] == '') && empty($data['created_from']) && empty($data['created_to'])) {
|
||||||
return $query->whereRaw('1 = 0');
|
return $query->whereRaw('1 = 0');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -861,6 +881,10 @@ class ProcessOrderResource extends Resource
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (! empty($data['Line'])) {
|
||||||
|
$query->where('line_id', $data['Line']);
|
||||||
|
}
|
||||||
|
|
||||||
if (! empty($data['Item'])) {
|
if (! empty($data['Item'])) {
|
||||||
$query->where('item_id', $data['Item']);
|
$query->where('item_id', $data['Item']);
|
||||||
}
|
}
|
||||||
@@ -905,12 +929,16 @@ class ProcessOrderResource extends Resource
|
|||||||
$userHas = Filament::auth()->user()->plant_id;
|
$userHas = Filament::auth()->user()->plant_id;
|
||||||
|
|
||||||
if ($userHas && strlen($userHas) > 0) {
|
if ($userHas && strlen($userHas) > 0) {
|
||||||
return 'Plant: Choose plant to filter records.';
|
return 'Plant Name: Choose plant to filter records.';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (! empty($data['Line'])) {
|
||||||
|
$indicators[] = 'Line Name: '.Line::where('id', $data['Line'])->value('name');
|
||||||
|
}
|
||||||
|
|
||||||
if (! empty($data['Item'])) {
|
if (! empty($data['Item'])) {
|
||||||
$indicators[] = 'Item: '.Item::where('id', $data['Item'])->value('code');
|
$indicators[] = 'Item Code: '.Item::where('id', $data['Item'])->value('code');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! empty($data['process_order'])) {
|
if (! empty($data['process_order'])) {
|
||||||
|
|||||||
@@ -86,7 +86,8 @@ class ProductCharacteristicsMasterResource extends Resource
|
|||||||
->where('line_id', $get('line_id'))
|
->where('line_id', $get('line_id'))
|
||||||
->where('work_group_master_id', $get('work_group_master_id'))
|
->where('work_group_master_id', $get('work_group_master_id'))
|
||||||
->where('machine_id', $get('machine_id'))
|
->where('machine_id', $get('machine_id'))
|
||||||
// ->where('characteristics_type', $get('characteristics_type'))
|
->where('characteristics_type', $get('characteristics_type'))
|
||||||
|
->where('name', $get('name'))
|
||||||
->ignore($get('id'));
|
->ignore($get('id'));
|
||||||
},
|
},
|
||||||
// function (callable $get): Closure {
|
// function (callable $get): Closure {
|
||||||
@@ -227,6 +228,11 @@ class ProductCharacteristicsMasterResource extends Resource
|
|||||||
// ->preload()
|
// ->preload()
|
||||||
->disabled(fn (Get $get) => ! empty($get('id') && ! Filament::auth()->user()->hasRole('Super Admin')))
|
->disabled(fn (Get $get) => ! empty($get('id') && ! Filament::auth()->user()->hasRole('Super Admin')))
|
||||||
->afterStateUpdated(function ($state, callable $set) {
|
->afterStateUpdated(function ($state, callable $set) {
|
||||||
|
if ($state == 'Visual') {
|
||||||
|
$set('lower', 0);
|
||||||
|
$set('middle', 0);
|
||||||
|
$set('upper', 0);
|
||||||
|
}
|
||||||
$set('updated_by', Filament::auth()->user()?->name);
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
})
|
})
|
||||||
->required(),
|
->required(),
|
||||||
@@ -259,7 +265,8 @@ class ProductCharacteristicsMasterResource extends Resource
|
|||||||
$set('middle', ($state + $get('upper')) / 2);
|
$set('middle', ($state + $get('upper')) / 2);
|
||||||
$set('updated_by', Filament::auth()->user()?->name);
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
})
|
})
|
||||||
->visible(fn (callable $get) => $get('inspection_type') == 'Value'),
|
// ->visible(fn (callable $get) => $get('inspection_type') == 'Value')
|
||||||
|
->readOnly(fn (callable $get) => $get('inspection_type') != 'Value'),
|
||||||
Forms\Components\TextInput::make('upper')
|
Forms\Components\TextInput::make('upper')
|
||||||
->label('Upper')
|
->label('Upper')
|
||||||
->numeric()
|
->numeric()
|
||||||
@@ -272,7 +279,8 @@ class ProductCharacteristicsMasterResource extends Resource
|
|||||||
$set('middle', ($get('lower') + $state) / 2);
|
$set('middle', ($get('lower') + $state) / 2);
|
||||||
$set('updated_by', Filament::auth()->user()?->name);
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
})
|
})
|
||||||
->visible(fn (callable $get) => $get('inspection_type') == 'Value'),
|
// ->visible(fn (callable $get) => $get('inspection_type') == 'Value')
|
||||||
|
->readOnly(fn (callable $get) => $get('inspection_type') != 'Value'),
|
||||||
Forms\Components\TextInput::make('middle')
|
Forms\Components\TextInput::make('middle')
|
||||||
->label('Middle')
|
->label('Middle')
|
||||||
->readOnly()
|
->readOnly()
|
||||||
@@ -295,8 +303,8 @@ class ProductCharacteristicsMasterResource extends Resource
|
|||||||
->dehydrateStateUsing(fn ($state, Get $get) => ($get('lower') + $get('upper')) / 2)
|
->dehydrateStateUsing(fn ($state, Get $get) => ($get('lower') + $get('upper')) / 2)
|
||||||
->afterStateUpdated(function ($state, callable $set) {
|
->afterStateUpdated(function ($state, callable $set) {
|
||||||
$set('updated_by', Filament::auth()->user()?->name);
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
})
|
}),
|
||||||
->visible(fn (callable $get) => $get('inspection_type') == 'Value'),
|
// ->visible(fn (callable $get) => $get('inspection_type') == 'Value'),
|
||||||
Forms\Components\Hidden::make('created_by')
|
Forms\Components\Hidden::make('created_by')
|
||||||
->label('Created By')
|
->label('Created By')
|
||||||
->default(Filament::auth()->user()?->name),
|
->default(Filament::auth()->user()?->name),
|
||||||
|
|||||||
@@ -167,6 +167,7 @@ class CharacteristicsController extends Controller
|
|||||||
// ];
|
// ];
|
||||||
|
|
||||||
// return response()->json($response);
|
// return response()->json($response);
|
||||||
|
|
||||||
foreach ($characteristics as $char) {
|
foreach ($characteristics as $char) {
|
||||||
|
|
||||||
$line = Line::find($char->line_id);
|
$line = Line::find($char->line_id);
|
||||||
@@ -203,7 +204,6 @@ class CharacteristicsController extends Controller
|
|||||||
return response()->json([
|
return response()->json([
|
||||||
'items' => $items,
|
'items' => $items,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -2231,62 +2231,89 @@ class CharacteristicsController extends Controller
|
|||||||
], 404);
|
], 404);
|
||||||
}
|
}
|
||||||
|
|
||||||
$lineAgaPlant = Line::where('plant_id', $plantId)->where('name', $lineName)->first();
|
$line = Line::where('plant_id', $plantId)->where('name', $lineName)->first();
|
||||||
|
|
||||||
if (! $lineAgaPlant) {
|
if (! $line) {
|
||||||
return response()->json([
|
return response()->json([
|
||||||
'status_code' => 'ERROR',
|
'status_code' => 'ERROR',
|
||||||
'status_description' => "Line Name not found in lines table for the plant : '$plant->name'!",
|
'status_description' => "Line Name not found in lines table for the plant : '$plant->name'!",
|
||||||
], 404);
|
], 404);
|
||||||
}
|
}
|
||||||
|
|
||||||
$work = Machine::where('work_center', $workCenter)->first();
|
$lineId = $line->id;
|
||||||
|
|
||||||
if (! $work) {
|
$machine = Machine::where('work_center', $workCenter)->first();
|
||||||
|
|
||||||
|
if (! $machine) {
|
||||||
return response()->json([
|
return response()->json([
|
||||||
'status_code' => 'ERROR',
|
'status_code' => 'ERROR',
|
||||||
'status_description' => 'Work Center not found in machines table!',
|
'status_description' => 'Work Center not found in machines table!',
|
||||||
], 404);
|
], 404);
|
||||||
}
|
}
|
||||||
|
|
||||||
$workAgaPlant = Machine::where('plant_id', $plantId)->where('work_center', $workCenter)->first();
|
$machine = Machine::where('plant_id', $plantId)->where('work_center', $workCenter)->first();
|
||||||
|
|
||||||
if (! $workAgaPlant) {
|
if (! $machine) {
|
||||||
return response()->json([
|
return response()->json([
|
||||||
'status_code' => 'ERROR',
|
'status_code' => 'ERROR',
|
||||||
'status_description' => "Work center not found in machines table for the plant : '$plant->name'!",
|
'status_description' => "Work center not found in machines table for the plant : '$plant->name'!",
|
||||||
], 404);
|
], 404);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$machine = Machine::where('plant_id', $plantId)->where('line_id', $lineId)->where('work_center', $workCenter)->first();
|
||||||
|
|
||||||
|
if (! $machine) {
|
||||||
|
return response()->json([
|
||||||
|
'status_code' => 'ERROR',
|
||||||
|
'status_description' => 'Work center is not mapped for the given line!',
|
||||||
|
], 404);
|
||||||
|
}
|
||||||
|
|
||||||
|
$machineId = $machine->id;
|
||||||
|
|
||||||
// $description = $item ? $item->description : '';
|
// $description = $item ? $item->description : '';
|
||||||
|
|
||||||
// $uom = $item ? $item->uom : '';
|
// $uom = $item ? $item->uom : '';
|
||||||
|
|
||||||
// $category = $item ? $item->category : '';
|
// $category = $item ? $item->category : '';
|
||||||
|
|
||||||
$charMaster = ProductCharacteristicsMaster::where('plant_id', $plantId)->where('item_id', $ItemId)
|
$charMasters = ProductCharacteristicsMaster::with('workGroupMaster')->where('plant_id', $plantId)->where('item_id', $ItemId)->where('line_id', $lineId)->where('machine_id', $machineId)->get(); // ->select(['name', 'characteristics_type', 'inspection_type', 'lower', 'middle', 'upper', 'work_group_master_id'])
|
||||||
->where('line_id', $lineAgaPlant->id)->where('machine_id', $workAgaPlant->id)
|
|
||||||
->first();
|
|
||||||
|
|
||||||
if (! $charMaster) {
|
if (! $charMasters) {
|
||||||
return response()->json([
|
return response()->json([
|
||||||
'status_code' => 'ERROR',
|
'status_code' => 'ERROR',
|
||||||
'status_description' => "Characteristics not found in product master table for the plant : '$plant->name'!",
|
'status_description' => "Characteristics not found in product master table for the plant : '$plant->name'!",
|
||||||
], 404);
|
], 404);
|
||||||
|
} else {
|
||||||
|
$output = $charMasters->map(function ($charMast) {
|
||||||
|
$charMaster = [
|
||||||
|
'work_group_master' => optional($charMast->workGroupMaster)->name ?? '',
|
||||||
|
'name' => $charMast?->name ?? '',
|
||||||
|
'characteristics_type' => $charMast?->characteristics_type ?? '',
|
||||||
|
'inspection_type' => $charMast?->inspection_type ?? '',
|
||||||
|
'lower' => (string) $charMast?->lower ?? '',
|
||||||
|
'middle' => (string) $charMast?->middle ?? '',
|
||||||
|
'upper' => (string) $charMast?->upper ?? '',
|
||||||
|
];
|
||||||
|
|
||||||
|
return $charMaster;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
$workGroup = WorkGroupMaster::find($charMaster->work_group_master_id);
|
// $charMasters = ProductCharacteristicsMaster::with('workGroupMaster')->where('plant_id', $plantId)->where('item_id', $ItemId)->where('line_id', $lineId)->where('machine_id', $machineId)->first();
|
||||||
$workGroupName = $workGroup?->name ?? '';
|
|
||||||
|
|
||||||
$output = [
|
// // $workGroup = WorkGroupMaster::find($charMasters->work_group_master_id);
|
||||||
'work_group_master' => $workGroupName ?? '',
|
// // $workGroupName = $workGroup?->name ?? '';
|
||||||
'name' => $charMaster?->name ?? '',
|
|
||||||
'characteristics_type' => $charMaster?->characteristics_type ?? '',
|
// $output = [
|
||||||
'inspection_type' => $charMaster?->inspection_type ?? '',
|
// 'work_group_master' => $charMasters?->workGroupMaster->name ?? '', // $workGroupName ?? '',
|
||||||
'lower' => (string) $charMaster?->lower ?? '',
|
// 'name' => $charMasters?->name ?? '',
|
||||||
'middle' => (string) $charMaster?->middle ?? '',
|
// 'characteristics_type' => $charMasters?->characteristics_type ?? '',
|
||||||
'upper' => (string) $charMaster?->upper ?? '',
|
// 'inspection_type' => $charMasters?->inspection_type ?? '',
|
||||||
];
|
// 'lower' => (string) $charMasters?->lower ?? '',
|
||||||
|
// 'middle' => (string) $charMasters?->middle ?? '',
|
||||||
|
// 'upper' => (string) $charMasters?->upper ?? '',
|
||||||
|
// ];
|
||||||
|
|
||||||
return response()->json($output, 200);
|
return response()->json($output, 200);
|
||||||
}
|
}
|
||||||
@@ -2347,15 +2374,15 @@ class CharacteristicsController extends Controller
|
|||||||
], 404);
|
], 404);
|
||||||
}
|
}
|
||||||
|
|
||||||
$lineAgaPlant = Line::where('plant_id', $plantId)->where('name', $lineName)->first();
|
$line = Line::where('plant_id', $plantId)->where('name', $lineName)->first();
|
||||||
if (! $lineAgaPlant) {
|
if (! $line) {
|
||||||
return response()->json([
|
return response()->json([
|
||||||
'status_code' => 'ERROR',
|
'status_code' => 'ERROR',
|
||||||
'status_description' => "Line '{$lineName}' not found against plant code '$plantCode'!",
|
'status_description' => "Line '{$lineName}' not found against plant code '$plantCode'!",
|
||||||
], 404);
|
], 404);
|
||||||
}
|
}
|
||||||
|
|
||||||
$lineId = $lineAgaPlant->id;
|
$lineId = $line->id;
|
||||||
|
|
||||||
if ($itemCode == null || $itemCode == '') {
|
if ($itemCode == null || $itemCode == '') {
|
||||||
return response()->json([
|
return response()->json([
|
||||||
@@ -2372,15 +2399,15 @@ class CharacteristicsController extends Controller
|
|||||||
], 404);
|
], 404);
|
||||||
}
|
}
|
||||||
|
|
||||||
$itemAgaPlant = Item::where('plant_id', $plantId)->where('code', $itemCode)->first();
|
$item = Item::where('plant_id', $plantId)->where('code', $itemCode)->first();
|
||||||
if (! $itemAgaPlant) {
|
if (! $item) {
|
||||||
return response()->json([
|
return response()->json([
|
||||||
'status_code' => 'ERROR',
|
'status_code' => 'ERROR',
|
||||||
'status_description' => "Item code '{$itemCode}' not found against plant code '$plantCode'!",
|
'status_description' => "Item code '{$itemCode}' not found against plant code '$plantCode'!",
|
||||||
], 404);
|
], 404);
|
||||||
}
|
}
|
||||||
|
|
||||||
$itemId = $itemAgaPlant->id;
|
$itemId = $item->id;
|
||||||
|
|
||||||
if ($workCenter == null || $workCenter == '') {
|
if ($workCenter == null || $workCenter == '') {
|
||||||
return response()->json([
|
return response()->json([
|
||||||
@@ -2397,23 +2424,23 @@ class CharacteristicsController extends Controller
|
|||||||
], 404);
|
], 404);
|
||||||
}
|
}
|
||||||
|
|
||||||
$machineAgaPlant = Machine::where('plant_id', $plantId)->where('work_center', $workCenter)->first();
|
$machine = Machine::where('plant_id', $plantId)->where('work_center', $workCenter)->first();
|
||||||
if (! $machineAgaPlant) {
|
if (! $machine) {
|
||||||
return response()->json([
|
return response()->json([
|
||||||
'status_code' => 'ERROR',
|
'status_code' => 'ERROR',
|
||||||
'status_description' => "Work center '{$workCenter}' not found against plant code '$plantCode'!",
|
'status_description' => "Work center '{$workCenter}' not found against plant code '$plantCode'!",
|
||||||
], 404);
|
], 404);
|
||||||
}
|
}
|
||||||
|
|
||||||
$machineAgaPlantLine = Machine::where('plant_id', $plantId)->where('line_id', $lineId)->where('work_center', $workCenter)->first();
|
$machine = Machine::where('plant_id', $plantId)->where('line_id', $lineId)->where('work_center', $workCenter)->first();
|
||||||
if (! $machineAgaPlantLine) {
|
if (! $machine) {
|
||||||
return response()->json([
|
return response()->json([
|
||||||
'status_code' => 'ERROR',
|
'status_code' => 'ERROR',
|
||||||
'status_description' => "Work center '{$workCenter}' not found against plant code '$plantCode' and line name '$lineName'!",
|
'status_description' => "Work center '{$workCenter}' not found against plant code '$plantCode' and line name '$lineName'!",
|
||||||
], 404);
|
], 404);
|
||||||
}
|
}
|
||||||
|
|
||||||
$machineId = $machineAgaPlantLine->id;
|
$machineId = $machine->id;
|
||||||
|
|
||||||
$data = $request->all();
|
$data = $request->all();
|
||||||
|
|
||||||
|
|||||||
@@ -51,6 +51,11 @@ class Line extends Model
|
|||||||
return $this->belongsTo(WorkGroupMaster::class);
|
return $this->belongsTo(WorkGroupMaster::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function processOrders()
|
||||||
|
{
|
||||||
|
return $this->hasMany(ProcessOrder::class);
|
||||||
|
}
|
||||||
|
|
||||||
public function workGroup1()
|
public function workGroup1()
|
||||||
{
|
{
|
||||||
return $this->belongsTo(WorkGroupMaster::class, 'work_group1_id', 'id');
|
return $this->belongsTo(WorkGroupMaster::class, 'work_group1_id', 'id');
|
||||||
|
|||||||
Reference in New Issue
Block a user