Compare commits
7 Commits
999228e272
...
2a17b020b4
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2a17b020b4 | ||
|
|
e67e3710c5 | ||
|
|
64705ba2f0 | ||
|
|
716d2e48d7 | ||
|
|
b3c034a602 | ||
|
|
81640fda90 | ||
|
|
58a58f3d9b |
@@ -6,6 +6,7 @@ use App\Models\Block;
|
||||
use Filament\Actions\Imports\ImportColumn;
|
||||
use Filament\Actions\Imports\Importer;
|
||||
use Filament\Actions\Imports\Models\Import;
|
||||
use Notification;
|
||||
|
||||
class BlockImporter extends Importer
|
||||
{
|
||||
@@ -32,12 +33,18 @@ class BlockImporter extends Importer
|
||||
|
||||
public function resolveRecord(): ?Block
|
||||
{
|
||||
$plant = \App\Models\Plant::where('name', $this->data['plant'])->first();
|
||||
return Block::updateOrCreate([
|
||||
'name' => $this->data['name'],
|
||||
'plant_id' => $plant->id
|
||||
]
|
||||
);
|
||||
// return Block::firstOrNew([
|
||||
// // Update existing records, matching them by `$this->data['column_name']`
|
||||
// 'email' => $this->data['email'],
|
||||
// ]);
|
||||
|
||||
return new Block();
|
||||
// return new Block();
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Import $import): string
|
||||
|
||||
@@ -25,12 +25,16 @@ class CompanyImporter extends Importer
|
||||
|
||||
public function resolveRecord(): ?Company
|
||||
{
|
||||
return Company::updateOrCreate([
|
||||
'name' => $this->data['name']
|
||||
]
|
||||
);
|
||||
// return Company::firstOrNew([
|
||||
// // Update existing records, matching them by `$this->data['column_name']`
|
||||
// 'email' => $this->data['email'],
|
||||
// ]);
|
||||
|
||||
return new Company();
|
||||
// return new Company();
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Import $import): string
|
||||
|
||||
@@ -45,12 +45,17 @@ class ItemImporter extends Importer
|
||||
|
||||
public function resolveRecord(): ?Item
|
||||
{
|
||||
// return Item::firstOrNew([
|
||||
// // Update existing records, matching them by `$this->data['column_name']`
|
||||
// 'email' => $this->data['email'],
|
||||
// ]);
|
||||
|
||||
return new Item;
|
||||
$plant = \App\Models\Plant::where('name', $this->data['plant'])->first();
|
||||
return Item::updateOrCreate([
|
||||
'code' => $this->data['code'],
|
||||
'plant_id' => $plant->id
|
||||
],
|
||||
[
|
||||
'description' => $this->data['description'],
|
||||
'hourly_quantity' => $this->data['hourly_quantity']
|
||||
]
|
||||
);
|
||||
// return new Item;
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Import $import): string
|
||||
|
||||
@@ -38,12 +38,21 @@ class LineImporter extends Importer
|
||||
|
||||
public function resolveRecord(): ?Line
|
||||
{
|
||||
$plant = \App\Models\Plant::where('name', $this->data['plant'])->first();
|
||||
return Line::updateOrCreate([
|
||||
'name' => $this->data['name'],
|
||||
'plant_id' => $plant->id
|
||||
],
|
||||
[
|
||||
'type' => $this->data['type']
|
||||
]
|
||||
);
|
||||
// return Line::firstOrNew([
|
||||
// // Update existing records, matching them by `$this->data['column_name']`
|
||||
// 'email' => $this->data['email'],
|
||||
// ]);
|
||||
|
||||
return new Line();
|
||||
// return new Line();
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Import $import): string
|
||||
|
||||
@@ -31,12 +31,19 @@ class LineStopImporter extends Importer
|
||||
|
||||
public function resolveRecord(): ?LineStop
|
||||
{
|
||||
return LineStop::updateOrCreate([
|
||||
'code' => $this->data['code']
|
||||
],
|
||||
[
|
||||
'reason' => $this->data['reason']
|
||||
]
|
||||
);
|
||||
// return LineStop::firstOrNew([
|
||||
// // Update existing records, matching them by `$this->data['column_name']`
|
||||
// 'email' => $this->data['email'],
|
||||
// ]);
|
||||
|
||||
return new LineStop();
|
||||
// return new LineStop();
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Import $import): string
|
||||
|
||||
@@ -45,12 +45,22 @@ class PlantImporter extends Importer
|
||||
|
||||
public function resolveRecord(): ?Plant
|
||||
{
|
||||
$company = \App\Models\Company::where('name', $this->data['company'])->first();
|
||||
return Plant::updateOrCreate([
|
||||
'code' => $this->data['code'],
|
||||
'name' => $this->data['name'],
|
||||
],
|
||||
[
|
||||
'address' => $this->data['address'],
|
||||
'company_id' => $company->id
|
||||
]
|
||||
);
|
||||
// return Plant::firstOrNew([
|
||||
// // Update existing records, matching them by `$this->data['column_name']`
|
||||
// 'email' => $this->data['email'],
|
||||
// ]);
|
||||
|
||||
return new Plant();
|
||||
// return new Plant();
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Import $import): string
|
||||
|
||||
@@ -64,12 +64,46 @@ class ShiftImporter extends Importer
|
||||
|
||||
public function resolveRecord(): ?Shift
|
||||
{
|
||||
$plant = \App\Models\Plant::where('name', $this->data['plant'])->first();
|
||||
$block = \App\Models\Block::where('name', $this->data['block'])->where('plant_id', $plant->id)->first();
|
||||
|
||||
if (!$plant || !$block) {
|
||||
// Optionally handle missing plant/block
|
||||
return null;
|
||||
}
|
||||
|
||||
$shift = Shift::where('name', $this->data['name'])
|
||||
->where('plant_id', $plant->id)
|
||||
->where('block_id', $block->id)
|
||||
->first();
|
||||
|
||||
if ($shift) {
|
||||
// Update only if necessary to avoid duplicate key error
|
||||
$shift->update([
|
||||
'start_time' => $this->data['start_time'],
|
||||
'duration' => $this->data['duration'],
|
||||
'end_time' => $this->data['end_time'],
|
||||
'status' => $this->data['status']
|
||||
]);
|
||||
return $shift;
|
||||
} else {
|
||||
// Safe to create new
|
||||
return Shift::create([
|
||||
'name' => $this->data['name'],
|
||||
'plant_id' => $plant->id,
|
||||
'block_id' => $block->id,
|
||||
'start_time' => $this->data['start_time'],
|
||||
'duration' => $this->data['duration'],
|
||||
'end_time' => $this->data['end_time'],
|
||||
'status' => $this->data['status']
|
||||
]);
|
||||
}
|
||||
// return Shift::firstOrNew([
|
||||
// // Update existing records, matching them by `$this->data['column_name']`
|
||||
// 'email' => $this->data['email'],
|
||||
// ]);
|
||||
|
||||
return new Shift();
|
||||
// return new Shift();
|
||||
}
|
||||
|
||||
public static function getCompletedNotificationBody(Import $import): string
|
||||
|
||||
@@ -26,7 +26,7 @@ class StickerMasterImporter extends Importer
|
||||
->requiredMapping()
|
||||
->exampleHeader('Plant Name')
|
||||
->example('Ransar Industries-I')
|
||||
->label('PLANT')
|
||||
->label('PLANT NAME')
|
||||
->relationship(resolveUsing: 'name')
|
||||
->rules(['required']),
|
||||
|
||||
@@ -178,6 +178,41 @@ class StickerMasterImporter extends Importer
|
||||
|
||||
public function resolveRecord(): ?StickerMaster
|
||||
{
|
||||
$item = \App\Models\Item::where('code', $this->data['item'])->first();
|
||||
$plant = \App\Models\Plant::where('name', $this->data['plant'])->first();
|
||||
if (!$plant || !$item) {
|
||||
// Optionally handle missing plant/block
|
||||
return null;
|
||||
}
|
||||
return StickerMaster::updateOrCreate([
|
||||
'item_id' => $item->id,
|
||||
'plant_id' => $plant->id
|
||||
],
|
||||
[
|
||||
'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'],
|
||||
'part_validation1' => $this->data['part_validation1'],
|
||||
'part_validation2' => $this->data['part_validation2'],
|
||||
'part_validation3' => $this->data['part_validation3'],
|
||||
'part_validation4' => $this->data['part_validation4'],
|
||||
'part_validation5' => $this->data['part_validation5'],
|
||||
'panel_box_code' => $this->data['panel_box_code'],
|
||||
'load_rate' => $this->data['load_rate'],
|
||||
'bundle_quantity' => $this->data['bundle_quantity'],
|
||||
'material_type' => $this->data['material_type']
|
||||
]
|
||||
);
|
||||
// return StickerMaster::firstOrNew([
|
||||
// // Update existing records, matching them by `$this->data['column_name']`
|
||||
// 'email' => $this->data['email'],
|
||||
|
||||
@@ -277,6 +277,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
|
||||
$uniqueCodes = array_unique($materialCodes);
|
||||
|
||||
//itemNotFound
|
||||
$matchedItems = StickerMaster::with('item')
|
||||
->whereHas('item', function ($query) use ($uniqueCodes) {
|
||||
$query->whereIn('code', $uniqueCodes);
|
||||
@@ -294,7 +295,36 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
$message = $missingCount > 10 ? "'$missingCount' item codes are not found in database." : 'The following item codes are not found in database:<br>' . implode(', ', $missingCodes);
|
||||
|
||||
Notification::make()
|
||||
->title('Unknown Item Codes')
|
||||
->title('Unknown: Item Codes')
|
||||
->body($message)
|
||||
->danger()
|
||||
->send();
|
||||
|
||||
if ($disk->exists($filePath)) {
|
||||
$disk->delete($filePath);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
//plantNotFound
|
||||
$matchedItems = StickerMaster::with('item')
|
||||
->whereHas('item', function ($query) use ($uniqueCodes, $plantId) {
|
||||
$query->whereIn('code', $uniqueCodes)->where('plant_id', $plantId);
|
||||
})
|
||||
->get();
|
||||
|
||||
$matchedCodes = $matchedItems->pluck('item.code')->toArray();
|
||||
|
||||
$missingCodes = array_diff($uniqueCodes, $matchedCodes);
|
||||
|
||||
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:<br>' . implode(', ', $missingCodes);
|
||||
|
||||
Notification::make()
|
||||
->title('Unknown: Item Codes')
|
||||
->body($message)
|
||||
->danger()
|
||||
->send();
|
||||
@@ -737,6 +767,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
|
||||
$uniqueCodes = array_unique($materialCodes);
|
||||
|
||||
//itemNotFound
|
||||
$matchedItems = StickerMaster::with('item')
|
||||
->whereHas('item', function ($query) use ($uniqueCodes) {
|
||||
$query->whereIn('code', $uniqueCodes);
|
||||
@@ -751,10 +782,10 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
{
|
||||
$missingCount = count($missingCodes);
|
||||
|
||||
$message = $missingCount > 10 ? "'$missingCount' item codes are not found in database." : 'The following item codes are not found in database:<br>' . implode(', ', $missingCodes);
|
||||
$message = $missingCount > 10 ? "'$missingCount' item codes are not found in database." : 'The following item codes are not found in database:<br>' . implode(', ', $missingCodes); //->where('plant_id', $plantId)
|
||||
|
||||
Notification::make()
|
||||
->title('Unknown Item Codes')
|
||||
->title('Unknown: Item Codes')
|
||||
->body($message)
|
||||
->danger()
|
||||
->send();
|
||||
@@ -765,6 +796,36 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
return;
|
||||
}
|
||||
|
||||
//plantNotFound
|
||||
$matchedItems = StickerMaster::with('item')
|
||||
->whereHas('item', function ($query) use ($uniqueCodes, $plantId) {
|
||||
$query->whereIn('code', $uniqueCodes)->where('plant_id', $plantId);
|
||||
})
|
||||
->get();
|
||||
|
||||
$matchedCodes = $matchedItems->pluck('item.code')->toArray();
|
||||
|
||||
$missingCodes = array_diff($uniqueCodes, $matchedCodes);
|
||||
|
||||
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:<br>' . implode(', ', $missingCodes);
|
||||
|
||||
Notification::make()
|
||||
->title('Unknown: Item Codes')
|
||||
->body($message)
|
||||
->danger()
|
||||
->send();
|
||||
|
||||
if ($disk->exists($filePath)) {
|
||||
$disk->delete($filePath);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
$invalidCodes = $matchedItems
|
||||
->filter(fn ($sticker) => !empty($sticker->material_type)) //filter invalid
|
||||
->pluck('item.code')
|
||||
@@ -1217,6 +1278,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
|
||||
$uniqueCodes = array_unique($materialCodes);
|
||||
|
||||
//itemNotFound
|
||||
$matchedItems = StickerMaster::with('item')
|
||||
->whereHas('item', function ($query) use ($uniqueCodes) {
|
||||
$query->whereIn('code', $uniqueCodes);
|
||||
@@ -1234,7 +1296,36 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
$message = $missingCount > 10 ? "'$missingCount' item codes are not found in database." : 'The following item codes are not found in database:<br>' . implode(', ', $missingCodes);
|
||||
|
||||
Notification::make()
|
||||
->title('Unknown Item Codes')
|
||||
->title('Unknown: Item Codes')
|
||||
->body($message)
|
||||
->danger()
|
||||
->send();
|
||||
|
||||
if ($disk->exists($filePath)) {
|
||||
$disk->delete($filePath);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
//plantNotFound
|
||||
$matchedItems = StickerMaster::with('item')
|
||||
->whereHas('item', function ($query) use ($uniqueCodes, $plantId) {
|
||||
$query->whereIn('code', $uniqueCodes)->where('plant_id', $plantId);
|
||||
})
|
||||
->get();
|
||||
|
||||
$matchedCodes = $matchedItems->pluck('item.code')->toArray();
|
||||
|
||||
$missingCodes = array_diff($uniqueCodes, $matchedCodes);
|
||||
|
||||
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:<br>' . implode(', ', $missingCodes);
|
||||
|
||||
Notification::make()
|
||||
->title('Unknown: Item Codes')
|
||||
->body($message)
|
||||
->danger()
|
||||
->send();
|
||||
@@ -1250,7 +1341,6 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
->pluck('item.code')
|
||||
->toArray();
|
||||
|
||||
|
||||
if (!empty($invalidCodes))
|
||||
{
|
||||
$missingCount = count($invalidCodes);
|
||||
@@ -1551,6 +1641,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
|
||||
$uniqueCodes = array_unique($materialCodes);
|
||||
|
||||
//itemNotFound
|
||||
$matchedItems = StickerMaster::with('item')
|
||||
->whereHas('item', function ($query) use ($uniqueCodes) {
|
||||
$query->whereIn('code', $uniqueCodes);
|
||||
@@ -1578,7 +1669,36 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
$message = $missingCount > 10 ? "'$missingCount' item codes are not found in database." : 'The following item codes are not found in database:<br>' . implode(', ', $missingCodes);
|
||||
|
||||
Notification::make()
|
||||
->title('Unknown Item Codes')
|
||||
->title('Unknown: Item Codes')
|
||||
->body($message)
|
||||
->danger()
|
||||
->send();
|
||||
|
||||
if ($disk->exists($filePath)) {
|
||||
$disk->delete($filePath);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
//plantNotFound
|
||||
$matchedItems = StickerMaster::with('item')
|
||||
->whereHas('item', function ($query) use ($uniqueCodes, $plantId) {
|
||||
$query->whereIn('code', $uniqueCodes)->where('plant_id', $plantId);
|
||||
})
|
||||
->get();
|
||||
|
||||
$matchedCodes = $matchedItems->pluck('item.code')->toArray();
|
||||
|
||||
$missingCodes = array_diff($uniqueCodes, $matchedCodes);
|
||||
|
||||
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:<br>' . implode(', ', $missingCodes);
|
||||
|
||||
Notification::make()
|
||||
->title('Unknown: Item Codes')
|
||||
->body($message)
|
||||
->danger()
|
||||
->send();
|
||||
@@ -1594,7 +1714,6 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
->pluck('item.code')
|
||||
->toArray();
|
||||
|
||||
|
||||
if (!empty($invalidCodes))
|
||||
{
|
||||
$missingCount = count($invalidCodes);
|
||||
@@ -1995,7 +2114,7 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
}
|
||||
|
||||
// $record = StickerMaster::where('plant_id', $plantId)->with('item')->where('item.code', $itemCode);
|
||||
$record = StickerMaster::where('plant_id', $plantId)->whereHas('item', function ($query) {
|
||||
$record = StickerMaster::whereHas('item', function ($query) {
|
||||
$query->where('code', $this->currentItemCode);
|
||||
});
|
||||
if ($record->count() <= 0)
|
||||
@@ -2016,6 +2135,27 @@ class CreateInvoiceValidation extends CreateRecord
|
||||
return;
|
||||
}
|
||||
|
||||
$record = StickerMaster::where('plant_id', $plantId)->whereHas('item', function ($query) {
|
||||
$query->where('code', $this->currentItemCode);
|
||||
});
|
||||
if ($record->count() <= 0)
|
||||
{
|
||||
Notification::make()
|
||||
->title('Unknown: Item Code')
|
||||
->body("Item code '$itemCode' not found in database for choosed plant.")
|
||||
->danger()
|
||||
->send();
|
||||
|
||||
$this->form->fill([
|
||||
'plant_id' => $plantId,
|
||||
'invoice_number' => $invoiceNumber,
|
||||
'serial_number' => null,
|
||||
'total_quantity' => $totQuan,
|
||||
'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)
|
||||
|
||||
@@ -158,12 +158,12 @@ class ItemResource extends Resource
|
||||
Tables\Columns\TextColumn::make('code')
|
||||
->sortable()
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('hourly_quantity')
|
||||
->numeric()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('description')
|
||||
->sortable()
|
||||
->searchable(),
|
||||
Tables\Columns\TextColumn::make('hourly_quantity')
|
||||
->numeric()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('plant.name')
|
||||
->sortable()
|
||||
->searchable(),
|
||||
@@ -196,11 +196,11 @@ class ItemResource extends Resource
|
||||
])
|
||||
->headerActions([
|
||||
ImportAction::make()
|
||||
->importer(ItemImporter::class)
|
||||
->maxRows(100000),
|
||||
->importer(ItemImporter::class),
|
||||
// ->maxRows(100000),
|
||||
ExportAction::make()
|
||||
// ->columnMapping(true)
|
||||
//->label('Export')
|
||||
// ->label('Export')
|
||||
// ->fileName("items" . date('Y-m-d') . ".xlsx")
|
||||
->exporter(ItemExporter::class),
|
||||
// ->formats([
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -6,6 +6,8 @@ use App\Filament\Resources\ProductionQuantityResource;
|
||||
use App\Filament\Widgets\ItemOverview;
|
||||
use App\Models\ProductionQuantity;
|
||||
use App\Models\Shift;
|
||||
use App\Models\Item;
|
||||
use Carbon\Carbon;
|
||||
use Filament\Actions;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Notifications\Notification;
|
||||
@@ -111,15 +113,20 @@ class CreateProductionQuantity extends CreateRecord
|
||||
return [];
|
||||
}
|
||||
|
||||
public function processAllValues($formData)
|
||||
public function processAllValues($formQRData)
|
||||
{
|
||||
//$formValues = [];
|
||||
$formValues = request()->all(); // This will get all form data from the request
|
||||
//dd($formValues);
|
||||
$this->validateAndProcessForm($formValues); // Process the form values
|
||||
// This will get all form data from the request
|
||||
$this->qrData = null;
|
||||
$this->iId = null;
|
||||
$this->succId = null;
|
||||
$this->sNoId = null;
|
||||
$this->succStat = null;
|
||||
$formValues = request()->all();
|
||||
$this->validateAndProcessForm($formValues, $formQRData); // Process the form values
|
||||
}
|
||||
|
||||
public function validateAndProcessForm($formValues)
|
||||
public function validateAndProcessForm($formValues, $formQRData)
|
||||
{
|
||||
$user = Filament::auth()->user(); //->name
|
||||
$operatorName = $user->name;
|
||||
@@ -131,7 +138,7 @@ class CreateProductionQuantity extends CreateRecord
|
||||
$formData = $componentData['data']['data'][0]; // Access first item in data array
|
||||
|
||||
// Extract specific values
|
||||
$this->qrData = $formData['item_code'] ?? null;
|
||||
$this->qrData = $formQRData ?? $formData['item_code'];
|
||||
$this->pId = $formData['plant_id'] ?? null;
|
||||
$this->bId = $formData['block_name'] ?? null;
|
||||
$this->sId = $formData['shift_id'] ?? null;
|
||||
@@ -153,6 +160,745 @@ class CreateProductionQuantity extends CreateRecord
|
||||
return;
|
||||
}
|
||||
|
||||
// dd($formData, $formQRData);
|
||||
// dd($this->form->getState()['serial_number']);
|
||||
|
||||
if (empty($formQRData)) {
|
||||
$this->form->fill([
|
||||
'plant_id'=> $this->pId,
|
||||
'block_name'=> $this->bId,
|
||||
'shift_id'=> $this->sId,
|
||||
'line_id'=> $this->lId,
|
||||
'item_id'=> null,
|
||||
'serial_number'=> null,
|
||||
'success_msg'=> null,
|
||||
'production_order'=> $this->prodOrder,
|
||||
'operator_id'=> $operatorName,
|
||||
'recent_qr' => $this->recQr,
|
||||
]);
|
||||
Notification::make()
|
||||
->title('Invalid QR')
|
||||
->body("Scan the valid QR code.<br>(Ex: Item_Code|Serial_Number )")
|
||||
->danger()
|
||||
->send();
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!$this->pId) {
|
||||
$this->form->fill([
|
||||
'plant_id'=> null,
|
||||
'block_name'=> null,
|
||||
'shift_id'=> null,
|
||||
'line_id'=> null,
|
||||
'item_id'=> null,
|
||||
'serial_number'=> null,
|
||||
'success_msg'=> null,
|
||||
'production_order'=> null,
|
||||
'operator_id'=> $operatorName,
|
||||
'recent_qr' => $this->recQr,
|
||||
]);
|
||||
Notification::make()
|
||||
->title('Choose Plant')
|
||||
->body("Please select a plant first.")
|
||||
->danger()
|
||||
->send();
|
||||
return;
|
||||
}
|
||||
else if (!$this->bId) {
|
||||
$this->form->fill([
|
||||
'plant_id'=> $this->pId,
|
||||
'block_name'=> null,
|
||||
'shift_id'=> null,
|
||||
'line_id'=> null,
|
||||
'item_id'=> null,
|
||||
'serial_number'=> null,
|
||||
'success_msg'=> null,
|
||||
'production_order'=> null,
|
||||
'operator_id'=> $operatorName,
|
||||
'recent_qr' => $this->recQr,
|
||||
]);
|
||||
Notification::make()
|
||||
->title('Choose Block')
|
||||
->body("Please select a block first.")
|
||||
->danger()
|
||||
->send();
|
||||
return;
|
||||
}
|
||||
else if (!$this->sId) {
|
||||
$this->form->fill([
|
||||
'plant_id'=> $this->pId,
|
||||
'block_name'=> $this->bId,
|
||||
'shift_id'=> null,
|
||||
'line_id'=> null,
|
||||
'item_id'=> null,
|
||||
'serial_number'=> null,
|
||||
'success_msg'=> null,
|
||||
'production_order'=> null,
|
||||
'operator_id'=> $operatorName,
|
||||
'recent_qr' => $this->recQr,
|
||||
]);
|
||||
Notification::make()
|
||||
->title('Choose Shift')
|
||||
->body("Please select a shift first.")
|
||||
->danger()
|
||||
->send();
|
||||
return;
|
||||
}
|
||||
else if (!$this->lId) {
|
||||
$this->form->fill([
|
||||
'plant_id'=> $this->pId,
|
||||
'block_name'=> $this->bId,
|
||||
'shift_id'=> $this->sId,
|
||||
'line_id'=> null,
|
||||
'item_id'=> null,
|
||||
'serial_number'=> null,
|
||||
'success_msg'=> null,
|
||||
'production_order'=> null,
|
||||
'operator_id'=> $operatorName,
|
||||
'recent_qr' => $this->recQr,
|
||||
]);
|
||||
Notification::make()
|
||||
->title('Choose Line')
|
||||
->body("Please select a line first.")
|
||||
->danger()
|
||||
->send();
|
||||
return;
|
||||
}
|
||||
else if (!$this->prodOrder) {
|
||||
$this->form->fill([
|
||||
'plant_id'=> $this->pId,
|
||||
'block_name'=> $this->bId,
|
||||
'shift_id'=> $this->sId,
|
||||
'line_id'=> $this->lId,
|
||||
'item_id'=> null,
|
||||
'serial_number'=> null,
|
||||
'success_msg'=> null,
|
||||
'production_order'=> null,
|
||||
'operator_id'=> $operatorName,
|
||||
'recent_qr' => $this->recQr,
|
||||
]);
|
||||
Notification::make()
|
||||
->title('Please scan the production order first.')
|
||||
->danger()
|
||||
->send();
|
||||
return;
|
||||
}
|
||||
|
||||
if(!is_numeric($this->prodOrder))
|
||||
{
|
||||
$this->form->fill([
|
||||
'plant_id'=> $this->pId,
|
||||
'block_name'=> $this->bId,
|
||||
'shift_id'=> $this->sId,
|
||||
'line_id'=> $this->lId,
|
||||
'item_id'=> null,
|
||||
'serial_number'=> null,
|
||||
'success_msg'=> null,
|
||||
'production_order'=> null,
|
||||
'operator_id'=> $operatorName,
|
||||
'recent_qr' => $this->recQr,
|
||||
]);
|
||||
|
||||
Notification::make()
|
||||
->title('Invalid Production Order')
|
||||
->body("Must contain numeric values only.")
|
||||
->danger()
|
||||
->send();
|
||||
return;
|
||||
}
|
||||
else if (!preg_match('/^[1-9][0-9]{6,}$/', $this->prodOrder))
|
||||
{
|
||||
$this->form->fill([
|
||||
'plant_id'=> $this->pId,
|
||||
'block_name'=> $this->bId,
|
||||
'shift_id'=> $this->sId,
|
||||
'line_id'=> $this->lId,
|
||||
'item_id'=> null,
|
||||
'serial_number'=> null,
|
||||
'success_msg'=> null,
|
||||
'production_order'=> null,
|
||||
'operator_id'=> $operatorName,
|
||||
'recent_qr' => $this->recQr,
|
||||
]);
|
||||
|
||||
Notification::make()
|
||||
->title('Invalid Production Order')
|
||||
->body("Must contain at least 7 digits.<br>Must start with a non-zero digit.")
|
||||
->danger()
|
||||
->send();
|
||||
return;
|
||||
}
|
||||
|
||||
// ********************************
|
||||
|
||||
$exists = \App\Models\ProductionPlan::where('plant_id', $this->pId)
|
||||
->where('shift_id', $this->sId)
|
||||
->where('line_id', $this->lId)
|
||||
->whereDate('created_at', today())
|
||||
->latest()
|
||||
->exists();
|
||||
|
||||
if ($exists)
|
||||
{
|
||||
$currentDate = date('Y-m-d');
|
||||
|
||||
$shiftId = Shift::where('id', $this->sId)
|
||||
->first();
|
||||
|
||||
[$hRs, $miNs] = explode('.', $shiftId->duration) + [0, 0];
|
||||
$hRs = (int) $hRs;
|
||||
//$miNs = (int) $miNs;-*/
|
||||
|
||||
$totalMinutes = $hRs * 60 + $miNs;
|
||||
|
||||
$from_dt = $currentDate . ' ' . $shiftId->start_time;
|
||||
|
||||
$to_dt = date('Y-m-d H:i:s', strtotime($from_dt . " + $totalMinutes minutes"));
|
||||
|
||||
$currentDateTime = date('Y-m-d H:i:s');
|
||||
|
||||
// Check if current date time is within the range
|
||||
if (!($currentDateTime >= $from_dt && $currentDateTime < $to_dt)) {
|
||||
//echo "Choosed a valid shift...";
|
||||
// $set('ppLineError', 'Valid (From: '.$from_dt.', To: '.$to_dt.')');
|
||||
|
||||
$this->form->fill([
|
||||
'plant_id'=> $this->pId,
|
||||
'block_name'=> $this->bId,
|
||||
'shift_id'=> $this->sId,
|
||||
'line_id'=> $this->lId,
|
||||
'item_id'=> null,
|
||||
'serial_number'=> null,
|
||||
'success_msg'=> null,
|
||||
'production_order'=> $this->prodOrder,
|
||||
'operator_id'=> $operatorName,
|
||||
'recent_qr' => $this->recQr,
|
||||
]);
|
||||
Notification::make()
|
||||
->title('Invalid Shift')
|
||||
->body("Please select a valid shift.")
|
||||
->danger()
|
||||
->send();
|
||||
//$set('validationError', 'Curr.'.$currentDateTime.' (From: '.$from_dt.', To: '.$to_dt.')');
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->form->fill([
|
||||
'plant_id'=> $this->pId,
|
||||
'block_name'=> $this->bId,
|
||||
'shift_id'=> $this->sId,
|
||||
'line_id'=> $this->lId,
|
||||
'item_id'=> null,
|
||||
'serial_number'=> null,
|
||||
'success_msg'=> null,
|
||||
'production_order'=> $this->prodOrder,
|
||||
'operator_id'=> $operatorName,
|
||||
'recent_qr' => $this->recQr,
|
||||
]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$existShifts = \App\Models\ProductionPlan::where('plant_id', $this->pId)
|
||||
->where('shift_id', $this->sId)
|
||||
->where('line_id', $this->lId)
|
||||
->whereDate('created_at', Carbon::yesterday())
|
||||
->latest()
|
||||
->exists();
|
||||
|
||||
if ($existShifts) //if ($existShifts->count() > 0)
|
||||
{ // record exist on yesterday
|
||||
//$currentDate = date('Y-m-d');
|
||||
$yesterday = date('Y-m-d', strtotime('-1 days'));
|
||||
|
||||
$shiftId = Shift::where('id', $this->sId)
|
||||
->first();
|
||||
|
||||
[$hRs, $miNs] = explode('.', $shiftId->duration) + [0, 0];
|
||||
$hRs = (int) $hRs;
|
||||
// $miNs = (int) $miNs;-*/
|
||||
|
||||
$totalMinutes = $hRs * 60 + $miNs;
|
||||
|
||||
$from_dt = $yesterday . ' ' . $shiftId->start_time;
|
||||
|
||||
$to_dt = date('Y-m-d H:i:s', strtotime($from_dt . " + $totalMinutes minutes"));
|
||||
|
||||
$currentDateTime = date('Y-m-d H:i:s');
|
||||
|
||||
// Check if current date time is within the range
|
||||
if ($currentDateTime >= $from_dt && $currentDateTime < $to_dt) {
|
||||
$this->form->fill([
|
||||
'plant_id'=> $this->pId,
|
||||
'block_name'=> $this->bId,
|
||||
'shift_id'=> $this->sId,
|
||||
'line_id'=> $this->lId,
|
||||
'item_id'=> null,
|
||||
'serial_number'=> null,
|
||||
'success_msg'=> null,
|
||||
'production_order'=> $this->prodOrder,
|
||||
'operator_id'=> $operatorName,
|
||||
'recent_qr' => $this->recQr,
|
||||
]);
|
||||
}
|
||||
else
|
||||
{
|
||||
$currentDate = date('Y-m-d');
|
||||
|
||||
$shiftId = Shift::where('id', $this->sId)
|
||||
->first();
|
||||
|
||||
[$hRs, $miNs] = explode('.', $shiftId->duration) + [0, 0];
|
||||
$hRs = (int) $hRs;
|
||||
// $miNs = (int) $miNs;-*/
|
||||
|
||||
$totalMinutes = $hRs * 60 + $miNs;
|
||||
|
||||
$from_dt = $currentDate . ' ' . $shiftId->start_time;
|
||||
|
||||
$to_dt = date('Y-m-d H:i:s', strtotime($from_dt . " + $totalMinutes minutes"));
|
||||
|
||||
$currentDateTime = date('Y-m-d H:i:s');
|
||||
|
||||
// Check if current date time is within the range
|
||||
if ($currentDateTime >= $from_dt && $currentDateTime < $to_dt) {
|
||||
//echo "Choosed a valid shift...";
|
||||
// $set('ppLineError', 'Valid (From: '.$from_dt.', To: '.$to_dt.')');
|
||||
|
||||
$this->form->fill([
|
||||
'plant_id'=> $this->pId,
|
||||
'block_name'=> $this->bId,
|
||||
'shift_id'=> $this->sId,
|
||||
'line_id'=> $this->lId,
|
||||
'item_id'=> null,
|
||||
'serial_number'=> null,
|
||||
'success_msg'=> null,
|
||||
'production_order'=> $this->prodOrder,
|
||||
'operator_id'=> $operatorName,
|
||||
'recent_qr' => $this->recQr,
|
||||
]);
|
||||
Notification::make()
|
||||
->title('Plan Not Found')
|
||||
->body("Please set production plan first.")
|
||||
->danger()
|
||||
->send();
|
||||
//$set('validationError', 'Curr.'.$currentDateTime.' (From: '.$from_dt.', To: '.$to_dt.')');
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
//echo "Choosed a valid shift...";
|
||||
// $set('ppLineError', 'Valid (From: '.$from_dt.', To: '.$to_dt.')');
|
||||
|
||||
$this->form->fill([
|
||||
'plant_id'=> $this->pId,
|
||||
'block_name'=> $this->bId,
|
||||
'shift_id'=> $this->sId,
|
||||
'line_id'=> $this->lId,
|
||||
'item_id'=> null,
|
||||
'serial_number'=> null,
|
||||
'success_msg'=> null,
|
||||
'production_order'=> $this->prodOrder,
|
||||
'operator_id'=> $operatorName,
|
||||
'recent_qr' => $this->recQr,
|
||||
]);
|
||||
Notification::make()
|
||||
->title('Invalid Shift')
|
||||
->body("Please select a valid shift.")
|
||||
->danger()
|
||||
->send();
|
||||
//$set('validationError', 'Curr.'.$currentDateTime.' (From: '.$from_dt.', To: '.$to_dt.')');
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{ // record not exist on yesterday
|
||||
|
||||
//$currentDate = date('Y-m-d');
|
||||
$yesterday = date('Y-m-d', strtotime('-1 days'));
|
||||
|
||||
$shiftId = Shift::where('id', $this->sId)
|
||||
->first();
|
||||
|
||||
[$hRs, $miNs] = explode('.', $shiftId->duration) + [0, 0];
|
||||
$hRs = (int) $hRs;
|
||||
// $miNs = (int) $miNs;-*/
|
||||
|
||||
$totalMinutes = $hRs * 60 + $miNs;
|
||||
|
||||
$from_dt = $yesterday . ' ' . $shiftId->start_time;
|
||||
|
||||
$to_dt = date('Y-m-d H:i:s', strtotime($from_dt . " + $totalMinutes minutes"));
|
||||
|
||||
$currentDateTime = date('Y-m-d H:i:s');
|
||||
|
||||
// Check if current date time is within the range
|
||||
if ($currentDateTime >= $from_dt && $currentDateTime < $to_dt) {
|
||||
//echo "Choosed a valid shift...";
|
||||
// $set('ppLineError', 'Valid (From: '.$from_dt.', To: '.$to_dt.')');
|
||||
|
||||
$this->form->fill([
|
||||
'plant_id'=> $this->pId,
|
||||
'block_name'=> $this->bId,
|
||||
'shift_id'=> $this->sId,
|
||||
'line_id'=> $this->lId,
|
||||
'item_id'=> null,
|
||||
'serial_number'=> null,
|
||||
'success_msg'=> null,
|
||||
'production_order'=> $this->prodOrder,
|
||||
'operator_id'=> $operatorName,
|
||||
'recent_qr' => $this->recQr,
|
||||
]);
|
||||
Notification::make()
|
||||
->title('Plan Not Found')
|
||||
->body("Please set production plan first.")
|
||||
->danger()
|
||||
->send();
|
||||
//$set('validationError', 'Curr.'.$currentDateTime.' (From: '.$from_dt.', To: '.$to_dt.')');
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
$currentDate = date('Y-m-d');
|
||||
|
||||
$shiftId = Shift::where('id', $this->sId)
|
||||
->first();
|
||||
|
||||
[$hRs, $miNs] = explode('.', $shiftId->duration) + [0, 0];
|
||||
$hRs = (int) $hRs;
|
||||
// $miNs = (int) $miNs;-*/
|
||||
|
||||
$totalMinutes = $hRs * 60 + $miNs;
|
||||
|
||||
$from_dt = $currentDate . ' ' . $shiftId->start_time;
|
||||
|
||||
$to_dt = date('Y-m-d H:i:s', strtotime($from_dt . " + $totalMinutes minutes"));
|
||||
|
||||
$currentDateTime = date('Y-m-d H:i:s');
|
||||
|
||||
// Check if current date time is within the range
|
||||
if ($currentDateTime >= $from_dt && $currentDateTime < $to_dt) {
|
||||
//echo "Choosed a valid shift...";
|
||||
// $set('ppLineError', 'Valid (From: '.$from_dt.', To: '.$to_dt.')');
|
||||
|
||||
$this->form->fill([
|
||||
'plant_id'=> $this->pId,
|
||||
'block_name'=> $this->bId,
|
||||
'shift_id'=> $this->sId,
|
||||
'line_id'=> $this->lId,
|
||||
'item_id'=> null,
|
||||
'serial_number'=> null,
|
||||
'success_msg'=> null,
|
||||
'production_order'=> $this->prodOrder,
|
||||
'operator_id'=> $operatorName,
|
||||
'recent_qr' => $this->recQr,
|
||||
]);
|
||||
Notification::make()
|
||||
->title('Plan Not Found')
|
||||
->body("Please set production plan first.")
|
||||
->danger()
|
||||
->send();
|
||||
//$set('validationError', 'Curr.'.$currentDateTime.' (From: '.$from_dt.', To: '.$to_dt.')');
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
//echo "Choosed a valid shift...";
|
||||
// $set('ppLineError', 'Valid (From: '.$from_dt.', To: '.$to_dt.')');
|
||||
|
||||
$this->form->fill([
|
||||
'plant_id'=> $this->pId,
|
||||
'block_name'=> $this->bId,
|
||||
'shift_id'=> $this->sId,
|
||||
'line_id'=> $this->lId,
|
||||
'item_id'=> null,
|
||||
'serial_number'=> null,
|
||||
'success_msg'=> null,
|
||||
'production_order'=> $this->prodOrder,
|
||||
'operator_id'=> $operatorName,
|
||||
'recent_qr' => $this->recQr,
|
||||
]);
|
||||
Notification::make()
|
||||
->title('Invalid Shift')
|
||||
->body("Please select a valid shift.")
|
||||
->danger()
|
||||
->send();
|
||||
//$set('validationError', 'Curr.'.$currentDateTime.' (From: '.$from_dt.', To: '.$to_dt.')');
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ********************************
|
||||
|
||||
$this->form->fill([
|
||||
'plant_id'=> $this->pId,
|
||||
'block_name'=> $this->bId,
|
||||
'shift_id'=> $this->sId,
|
||||
'line_id'=> $this->lId,
|
||||
'item_id'=> null,
|
||||
'serial_number'=> null,
|
||||
'success_msg'=> null,
|
||||
'production_order'=> $this->prodOrder,
|
||||
'operator_id'=> $operatorName,
|
||||
'recent_qr' => $this->recQr,
|
||||
]);
|
||||
}
|
||||
|
||||
if (!preg_match('/^[a-zA-Z0-9]{6,}+\|[1-9][a-zA-Z0-9]{8,}+(\|)?$/', $formQRData)) {
|
||||
if (strpos($formQRData, '|') === false) {
|
||||
$this->form->fill([
|
||||
'plant_id'=> $this->pId,
|
||||
'block_name'=> $this->bId,
|
||||
'shift_id'=> $this->sId,
|
||||
'line_id'=> $this->lId,
|
||||
'item_id'=> null,
|
||||
'serial_number'=> null,
|
||||
'success_msg'=> null,
|
||||
'production_order'=> $this->prodOrder,
|
||||
'operator_id'=> $operatorName,
|
||||
'recent_qr' => $this->recQr,
|
||||
]);
|
||||
|
||||
Notification::make()
|
||||
->title('Invalid QR')
|
||||
->body("Scan the valid QR code.<br>(Ex: Item_Code|Serial_Number )")
|
||||
->danger()
|
||||
->send();
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
$splits = explode('|', $formQRData);
|
||||
$iCode = trim($splits[0]);
|
||||
$sNumber = isset($splits[1]) ? trim($splits[1]) : null;
|
||||
|
||||
if (!ctype_alnum($iCode)) {
|
||||
$this->form->fill([
|
||||
'plant_id'=> $this->pId,
|
||||
'block_name'=> $this->bId,
|
||||
'shift_id'=> $this->sId,
|
||||
'line_id'=> $this->lId,
|
||||
'item_id'=> null,
|
||||
'serial_number'=> null,
|
||||
'success_msg'=> null,
|
||||
'production_order'=> $this->prodOrder,
|
||||
'operator_id'=> $operatorName,
|
||||
'recent_qr' => $this->recQr,
|
||||
]);
|
||||
|
||||
Notification::make()
|
||||
->title('Invalid Item Code')
|
||||
->body("Item code must contain alpha-numeric values only.")
|
||||
->danger()
|
||||
->send();
|
||||
return;
|
||||
}
|
||||
else if (strlen($iCode) < 6) {
|
||||
$this->form->fill([
|
||||
'plant_id'=> $this->pId,
|
||||
'block_name'=> $this->bId,
|
||||
'shift_id'=> $this->sId,
|
||||
'line_id'=> $this->lId,
|
||||
'item_id'=> null,
|
||||
'serial_number'=> null,
|
||||
'success_msg'=> null,
|
||||
'production_order'=> $this->prodOrder,
|
||||
'operator_id'=> $operatorName,
|
||||
'recent_qr' => $this->recQr,
|
||||
]);
|
||||
|
||||
Notification::make()
|
||||
->title('Invalid Item Code')
|
||||
->body("Item code must be at least 6 digits.")
|
||||
->danger()
|
||||
->send();
|
||||
return;
|
||||
}
|
||||
else if (!ctype_alnum($sNumber)) {
|
||||
$this->form->fill([
|
||||
'plant_id'=> $this->pId,
|
||||
'block_name'=> $this->bId,
|
||||
'shift_id'=> $this->sId,
|
||||
'line_id'=> $this->lId,
|
||||
'item_id'=> null,
|
||||
'serial_number'=> null,
|
||||
'success_msg'=> null,
|
||||
'production_order'=> $this->prodOrder,
|
||||
'operator_id'=> $operatorName,
|
||||
'recent_qr' => $this->recQr,
|
||||
]);
|
||||
|
||||
Notification::make()
|
||||
->title('Invalid Serial Number')
|
||||
->body("Serial Number must contain alpha-numeric values only.")
|
||||
->danger()
|
||||
->duration(800)
|
||||
->send();
|
||||
return;
|
||||
}
|
||||
else if (strlen($sNumber) < 9) {
|
||||
$this->form->fill([
|
||||
'plant_id'=> $this->pId,
|
||||
'block_name'=> $this->bId,
|
||||
'shift_id'=> $this->sId,
|
||||
'line_id'=> $this->lId,
|
||||
'item_id'=> null,
|
||||
'serial_number'=> null,
|
||||
'success_msg'=> null,
|
||||
'production_order'=> $this->prodOrder,
|
||||
'operator_id'=> $operatorName,
|
||||
'recent_qr' => $this->recQr,
|
||||
]);
|
||||
|
||||
Notification::make()
|
||||
->title('Invalid Serial Number')
|
||||
->body("Serial Number must be at least 9 digits.")
|
||||
->danger()
|
||||
->duration(800)
|
||||
->send();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
$this->form->fill([
|
||||
'plant_id'=> $this->pId,
|
||||
'block_name'=> $this->bId,
|
||||
'shift_id'=> $this->sId,
|
||||
'line_id'=> $this->lId,
|
||||
'item_id'=> null,
|
||||
'serial_number'=> null,
|
||||
'success_msg'=> null,
|
||||
'production_order'=> $this->prodOrder,
|
||||
'operator_id'=> $operatorName,
|
||||
'recent_qr' => $this->recQr,
|
||||
]);
|
||||
|
||||
Notification::make()
|
||||
->title('Invalid QR')
|
||||
->body("Scan the valid QR code.<br>(Ex: Item_Code|Serial_Number )")
|
||||
->danger()
|
||||
->send();
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->form->fill([
|
||||
'plant_id'=> $this->pId,
|
||||
'block_name'=> $this->bId,
|
||||
'shift_id'=> $this->sId,
|
||||
'line_id'=> $this->lId,
|
||||
'item_id'=> null,
|
||||
'serial_number'=> null,
|
||||
'success_msg'=> null,
|
||||
'production_order'=> $this->prodOrder,
|
||||
'operator_id'=> $operatorName,
|
||||
'recent_qr' => $this->recQr,
|
||||
]);
|
||||
}
|
||||
|
||||
// Only search when all parent IDs are selected
|
||||
$parts = explode('|', $formQRData);
|
||||
$itemCode = trim($parts[0]);
|
||||
$serialNumber = isset($parts[1]) ? trim($parts[1]) : null;
|
||||
|
||||
// Fetch item using item code and plant_id
|
||||
$masItem = Item::where('code', $itemCode)->first();
|
||||
if (!$masItem)
|
||||
{
|
||||
$this->form->fill([
|
||||
'plant_id'=> $this->pId,
|
||||
'block_name'=> $this->bId,
|
||||
'shift_id'=> $this->sId,
|
||||
'line_id'=> $this->lId,
|
||||
'item_id'=> null,
|
||||
'serial_number'=> null,
|
||||
'success_msg'=> null,
|
||||
'production_order'=> $this->prodOrder,
|
||||
'operator_id'=> $operatorName,
|
||||
'recent_qr' => $this->recQr,
|
||||
]);
|
||||
Notification::make()
|
||||
->title('Unknown Item Code')
|
||||
->body("Item code does not exist in master data.")
|
||||
->danger()
|
||||
->send();
|
||||
return;
|
||||
}
|
||||
|
||||
$item = Item::where('code', $itemCode)
|
||||
->where('plant_id', $this->pId)
|
||||
->first();
|
||||
|
||||
if ($item)
|
||||
{
|
||||
$sNo = ProductionQuantity::where('serial_number', $serialNumber)->where('plant_id', $this->pId)->exists();
|
||||
if (!$sNo)
|
||||
{
|
||||
$this->form->fill([
|
||||
'plant_id'=> $this->pId,
|
||||
'block_name'=> $this->bId,
|
||||
'shift_id'=> $this->sId,
|
||||
'line_id'=> $this->lId,
|
||||
'item_id'=> $item->id,
|
||||
'serial_number'=> null,
|
||||
'success_msg'=> 'Y',
|
||||
'production_order'=> $this->prodOrder,
|
||||
'operator_id'=> $operatorName,
|
||||
'recent_qr' => $this->recQr,
|
||||
]);
|
||||
$this->succId = 'Y';
|
||||
$this->iId = $item->id;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->form->fill([
|
||||
'plant_id'=> $this->pId,
|
||||
'block_name'=> $this->bId,
|
||||
'shift_id'=> $this->sId,
|
||||
'line_id'=> $this->lId,
|
||||
'item_id'=> null,
|
||||
'serial_number'=> null,
|
||||
'success_msg'=> null,
|
||||
'production_order'=> $this->prodOrder,
|
||||
'operator_id'=> $operatorName,
|
||||
'recent_qr' => $this->recQr,
|
||||
]);
|
||||
Notification::make()
|
||||
->title('Duplicate Serial Number')
|
||||
->body("Serial number already exist in database for choosed plant.")
|
||||
->danger()
|
||||
->send();
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->form->fill([
|
||||
'plant_id'=> $this->pId,
|
||||
'block_name'=> $this->bId,
|
||||
'shift_id'=> $this->sId,
|
||||
'line_id'=> $this->lId,
|
||||
'item_id'=> null,
|
||||
'serial_number'=> null,
|
||||
'success_msg'=> null,
|
||||
'production_order'=> $this->prodOrder,
|
||||
'operator_id'=> $operatorName,
|
||||
'recent_qr' => $this->recQr,
|
||||
]);
|
||||
|
||||
Notification::make()
|
||||
->title('Unknown Item Code')
|
||||
->body("Item code does not exist in master data for choosed plant.")
|
||||
->danger()
|
||||
->send();
|
||||
return;
|
||||
}
|
||||
|
||||
if ($this->succId === null) {
|
||||
$this->form->fill([
|
||||
'plant_id'=> $this->pId,
|
||||
@@ -162,7 +908,7 @@ class CreateProductionQuantity extends CreateRecord
|
||||
'item_id'=> null,
|
||||
'serial_number'=> null,
|
||||
'success_msg'=> null,
|
||||
'production_order'=> null,
|
||||
'production_order'=> $this->prodOrder,
|
||||
'operator_id'=> $operatorName,
|
||||
'recent_qr' => $this->recQr,
|
||||
]);
|
||||
|
||||
@@ -41,4 +41,12 @@ class ProductionLineStop extends Model
|
||||
{
|
||||
return $this->belongsTo(LineStop::class);
|
||||
}
|
||||
|
||||
// //..this is my code below
|
||||
// public function lineStopRelation()
|
||||
// {
|
||||
// return $this->belongsTo(LineStop::class, 'linestop_id');
|
||||
// }
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user