38 Commits

Author SHA1 Message Date
dhanabalan
cd17021097 Added trigger create event logic in leak test reading
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 13s
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Successful in 15s
Gemini PR Review / Gemini PR Review (pull_request) Failing after 20s
Laravel Pint / pint (pull_request) Successful in 3m41s
Laravel Larastan / larastan (pull_request) Failing after 5m22s
2026-10-24 12:58:08 +05:30
dhanabalan
cf1d6a1c05 Changed logic in leak test readings scanning qr code
All checks were successful
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 13s
2026-10-24 12:57:34 +05:30
dhanabalan
534b6e9c1a removed uniqueness in plants table
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 14s
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Successful in 16s
Gemini PR Review / Gemini PR Review (pull_request) Failing after 21s
Laravel Pint / pint (pull_request) Successful in 3m38s
Laravel Larastan / larastan (pull_request) Failing after 5m41s
2026-10-24 10:42:54 +05:30
dhanabalan
323c396a40 Changed duplicate logic in invoice validation
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 14s
Gemini PR Review / Gemini PR Review (pull_request) Failing after 20s
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Successful in 13s
Laravel Pint / pint (pull_request) Successful in 2m46s
Laravel Larastan / larastan (pull_request) Failing after 5m16s
2026-10-24 08:29:56 +05:30
dhanabalan
baf41cfea1 changed regex pattern in panel box inspection page
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 13s
Gemini PR Review / Gemini PR Review (pull_request) Failing after 15s
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Successful in 13s
Laravel Pint / pint (pull_request) Successful in 4m23s
Laravel Larastan / larastan (pull_request) Failing after 6m0s
2026-10-23 17:24:16 +05:30
dhanabalan
92324e9f3b removed searchable in invoice validation
All checks were successful
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 12s
2026-10-23 17:23:20 +05:30
dhanabalan
683309c5cf Added logic in panel box validation changed regex pattern
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 13s
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Successful in 13s
Gemini PR Review / Gemini PR Review (pull_request) Failing after 18s
Laravel Pint / pint (pull_request) Successful in 3m37s
Laravel Larastan / larastan (pull_request) Failing after 5m20s
2026-10-23 17:13:49 +05:30
dhanabalan
3716741b3a removed logic in panel box inspection stock
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 12s
Gemini PR Review / Gemini PR Review (pull_request) Failing after 18s
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Successful in 12s
Laravel Larastan / larastan (pull_request) Failing after 4m41s
Laravel Pint / pint (pull_request) Successful in 3m48s
2026-10-23 16:52:17 +05:30
dhanabalan
8d213f563f changed regex logic in panel box valiation resource page
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 13s
Gemini PR Review / Gemini PR Review (pull_request) Failing after 16s
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Successful in 15s
Laravel Larastan / larastan (pull_request) Failing after 4m7s
Laravel Pint / pint (pull_request) Successful in 6m9s
2026-10-23 16:47:46 +05:30
dhanabalan
842eedbca2 Added seperate method for random serial generation
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 13s
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Successful in 15s
Gemini PR Review / Gemini PR Review (pull_request) Failing after 18s
Laravel Pint / pint (pull_request) Successful in 4m49s
Laravel Larastan / larastan (pull_request) Failing after 6m39s
2026-10-23 14:06:13 +05:30
dhanabalan
d7c386d053 Added random seral list in bulk sticker printing page
All checks were successful
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 13s
2026-10-23 14:02:45 +05:30
dhanabalan
4260c7b18a Added random serial number list livewire pages
All checks were successful
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 13s
2026-10-23 14:00:31 +05:30
dhanabalan
77456a5d8a removed required forinspection lot number in panel box validation
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 13s
Gemini PR Review / Gemini PR Review (pull_request) Failing after 16s
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Successful in 14s
Laravel Pint / pint (pull_request) Successful in 2m55s
Laravel Larastan / larastan (pull_request) Failing after 4m8s
2026-10-23 12:03:30 +05:30
dhanabalan
700c01eebc intialize variable in edit panel gr master
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 14s
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Successful in 26s
Gemini PR Review / Gemini PR Review (pull_request) Failing after 36s
Laravel Pint / pint (pull_request) Failing after 3s
Laravel Larastan / larastan (pull_request) Failing after 5m2s
2026-10-23 11:43:41 +05:30
dhanabalan
40222cb59e Added panel box serial number in invoice validation filter
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 14s
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Successful in 16s
Gemini PR Review / Gemini PR Review (pull_request) Failing after 20s
Laravel Pint / pint (pull_request) Successful in 3m44s
Laravel Larastan / larastan (pull_request) Failing after 4m39s
2026-10-23 11:24:56 +05:30
dhanabalan
3f964e7b88 Changed label name for production characteristic exporter
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 14s
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Successful in 14s
Gemini PR Review / Gemini PR Review (pull_request) Failing after 19s
Laravel Larastan / larastan (pull_request) Failing after 47s
Laravel Pint / pint (pull_request) Successful in 3m48s
2026-10-23 10:52:56 +05:30
dhanabalan
9cbb6a7877 Added filter panel box serial number in invoice validations
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 13s
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Successful in 15s
Gemini PR Review / Gemini PR Review (pull_request) Failing after 20s
Laravel Pint / pint (pull_request) Successful in 3m27s
Laravel Larastan / larastan (pull_request) Failing after 6m31s
2026-10-23 10:40:30 +05:30
dhanabalan
6e7da3cd7a Added tollfree and feed rule in sticker pdf service and multiple sticker method
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 13s
Gemini PR Review / Gemini PR Review (pull_request) Failing after 19s
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Successful in 13s
Laravel Larastan / larastan (pull_request) Failing after 7m42s
Laravel Pint / pint (pull_request) Successful in 6m37s
2026-10-22 16:51:06 +05:30
dhanabalan
8eb5a47226 Added tollfree and feedback in sticker detail page
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 15s
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Successful in 16s
Gemini PR Review / Gemini PR Review (pull_request) Failing after 21s
Laravel Pint / pint (pull_request) Successful in 2m32s
Laravel Larastan / larastan (pull_request) Failing after 7m34s
2026-10-22 16:48:40 +05:30
dhanabalan
35ed640660 Added tollfree in plant resource page
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 13s
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Successful in 17s
Gemini PR Review / Gemini PR Review (pull_request) Failing after 22s
Laravel Pint / pint (pull_request) Successful in 4m51s
Laravel Larastan / larastan (pull_request) Failing after 5m0s
2026-10-21 11:11:47 +05:30
dhanabalan
342e71bb87 Added tollfree in plants model file
All checks were successful
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 13s
2026-10-21 11:08:22 +05:30
dhanabalan
91771a1add Added tollfree column in plants
All checks were successful
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 14s
2026-10-21 11:07:27 +05:30
dhanabalan
7323a35e73 Changed logic in bulk sticker printing page against serial number its fetch job order
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 13s
Gemini PR Review / Gemini PR Review (pull_request) Failing after 18s
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Successful in 14s
Laravel Pint / pint (pull_request) Successful in 4m37s
Laravel Larastan / larastan (pull_request) Failing after 5m9s
2026-10-20 14:23:13 +05:30
dhanabalan
46f20c423c changed logic in sticker pdf service
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 14s
Gemini PR Review / Gemini PR Review (pull_request) Failing after 18s
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Successful in 14s
Laravel Larastan / larastan (pull_request) Failing after 6m21s
Laravel Pint / pint (pull_request) Successful in 7m39s
2026-10-20 11:59:41 +05:30
dhanabalan
31e7306a39 Added one more rule in sticker pdf service
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 20s
Gemini PR Review / Gemini PR Review (pull_request) Failing after 28s
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Successful in 19s
Laravel Pint / pint (pull_request) Successful in 2m56s
Laravel Larastan / larastan (pull_request) Failing after 6m24s
2026-10-20 11:47:04 +05:30
dhanabalan
4ea1d5470e Added company name rule in sticker detail
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 14s
Gemini PR Review / Gemini PR Review (pull_request) Failing after 17s
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Successful in 13s
Laravel Pint / pint (pull_request) Successful in 4m14s
Laravel Larastan / larastan (pull_request) Failing after 5m58s
2026-10-20 11:45:21 +05:30
dhanabalan
f41bfa0ee7 Changed logic in sticker order reprint
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 15s
Gemini PR Review / Gemini PR Review (pull_request) Failing after 19s
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Successful in 13s
Laravel Pint / pint (pull_request) Successful in 3m37s
Laravel Larastan / larastan (pull_request) Failing after 6m19s
2026-10-20 11:24:37 +05:30
dhanabalan
93092f45fe Added notification in sticker order reprint
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 12s
Gemini PR Review / Gemini PR Review (pull_request) Failing after 14s
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Successful in 12s
Laravel Larastan / larastan (pull_request) Failing after 4m43s
Laravel Pint / pint (pull_request) Successful in 3m16s
2026-10-20 11:21:17 +05:30
dhanabalan
ab6a3b7c5c changed logic in bulk sticker for machine bug
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 14s
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Successful in 15s
Gemini PR Review / Gemini PR Review (pull_request) Failing after 18s
Laravel Pint / pint (pull_request) Successful in 3m14s
Laravel Larastan / larastan (pull_request) Failing after 6m11s
2026-10-20 11:15:24 +05:30
dhanabalan
57b1ec5b82 Added notification in bulk sticker
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 13s
Gemini PR Review / Gemini PR Review (pull_request) Failing after 15s
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Successful in 12s
Laravel Larastan / larastan (pull_request) Failing after 5m59s
Laravel Pint / pint (pull_request) Successful in 4m10s
2026-10-20 11:09:36 +05:30
dhanabalan
6f9347011f changed logic in bulk sticker printing of machine issue
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 15s
Gemini PR Review / Gemini PR Review (pull_request) Failing after 25s
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Successful in 20s
Laravel Pint / pint (pull_request) Successful in 3m40s
Laravel Larastan / larastan (pull_request) Failing after 7m22s
2026-10-20 11:05:01 +05:30
dhanabalan
ab2c6c6e3f Added validation in sticker mapping master page
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 13s
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Successful in 14s
Gemini PR Review / Gemini PR Review (pull_request) Failing after 18s
Laravel Pint / pint (pull_request) Successful in 3m31s
Laravel Larastan / larastan (pull_request) Failing after 7m19s
2026-10-20 10:59:09 +05:30
dhanabalan
ad688fb3b1 Added notification in bulk sticker printing page
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 13s
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Successful in 15s
Gemini PR Review / Gemini PR Review (pull_request) Failing after 17s
Laravel Pint / pint (pull_request) Successful in 4m2s
Laravel Larastan / larastan (pull_request) Failing after 4m34s
2026-10-20 10:52:14 +05:30
dhanabalan
4f97cd607e Added logic in sticker pdf service
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 13s
Gemini PR Review / Gemini PR Review (pull_request) Failing after 25s
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Successful in 21s
Laravel Pint / pint (pull_request) Successful in 3m46s
Laravel Larastan / larastan (pull_request) Failing after 6m22s
2026-10-20 10:10:07 +05:30
dhanabalan
bb74a6c480 Added two more options in sticker detail resource page
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 21s
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Successful in 16s
Gemini PR Review / Gemini PR Review (pull_request) Failing after 19s
Laravel Pint / pint (pull_request) Successful in 2m25s
Laravel Larastan / larastan (pull_request) Failing after 6m34s
2026-10-20 10:02:41 +05:30
dhanabalan
9015095ecc Added feed back column in plant resource
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 14s
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Successful in 1m7s
Gemini PR Review / Gemini PR Review (pull_request) Failing after 1m15s
Laravel Pint / pint (pull_request) Successful in 3m3s
Laravel Larastan / larastan (pull_request) Failing after 5m56s
2026-10-20 09:56:16 +05:30
dhanabalan
43c474bb59 Added feed address in plant model file
All checks were successful
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 17s
2026-10-20 09:54:05 +05:30
dhanabalan
1db5e62e21 Added feed address column in plants table
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
2026-10-20 09:52:43 +05:30
20 changed files with 1939 additions and 179 deletions

View File

@@ -30,7 +30,7 @@ class ProductionCharacteristicExporter extends Exporter
ExportColumn::make('machine.work_center')
->label('WORK CENTER'),
ExportColumn::make('production_order')
->label('PRODUCTION ORDER'),
->label('PRODUCTION ORDER / DOC NO'),
ExportColumn::make('serial_number')
->label('SERIAL NUMBER'),
ExportColumn::make('characteristic_name')

View File

@@ -25,6 +25,8 @@ use Filament\Forms\Components\Section;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\TextInput;
use Illuminate\Support\Facades\Log;
use Livewire\Attributes\On;
use Filament\Forms\Set;
class BulkStickerPrinting extends Page implements HasForms
{
@@ -36,12 +38,19 @@ class BulkStickerPrinting extends Page implements HasForms
public array $filters = [];
public array $serialNumbers = [''];
public $serNo;
public $ref_number;
//public $workCenter;
public function mount(): void
{
$this->form->fill();
}
public function form(Form $form): Form
{
return $form
@@ -85,21 +94,211 @@ class BulkStickerPrinting extends Page implements HasForms
TextInput::make('production_order')
->label('Production Order')
->reactive()
->required()
->afterStateUpdated(function ($state, callable $set, $get) {
->readOnly(),
// ->afterStateUpdated(function ($state, callable $set, $get) {
for ($i = 1; $i <= 8; $i++) {
$set("sticker_structure{$i}_id", null);
}
// for ($i = 1; $i <= 8; $i++) {
// $set("sticker_structure{$i}_id", null);
// }
// if (blank($state)) {
// return;
// }
// $plantid = $get('plant_id');
// $machineId = $get('machine_id');
// $plantName = Plant::where('id', $plantid)->value('name');
// $workCenter = Machine::where('id', $machineId)->value('work_center');
// if (empty($machineId)) {
// Notification::make()
// ->title('Work Center not selected')
// ->body('Please select a Work Center first.')
// ->warning()
// ->send();
// return;
// }
// $productionOrder = ClassCharacteristic::where('plant_id', $plantid)->where('machine_id', $machineId)->where('aufnr', $state)->first();
// if (! $productionOrder) {
// Notification::make()
// ->title('Production Order not found')
// ->body("Production Order '{$state}' was not found against machine '$workCenter' and plant '$plantName'.")
// ->danger()
// ->send();
// return;
// }
// $plantId = $productionOrder->plant_id;
// $itemId = $productionOrder->item_id;
// $item = Item::find($itemId);
// if (! $item) {
// Notification::make()
// ->title('Item not found')
// ->body("Item code '{$itemId}' was not found in item master.")
// ->danger()
// ->send();
// return;
// }
// $itemCode = $item->code;
// $item = Item::where('code', $itemCode)->where('plant_id', $plantId)->first();
// if (! $item) {
// Notification::make()
// ->title('Item not found')
// ->body("Item '{$itemCode}' was not found for the selected plant.")
// ->danger()
// ->send();
// return;
// }
// $itemCharacteristic = ClassCharacteristic::where('plant_id', $plantId)->where('item_id', $item->id)->first();
// if (! $itemCharacteristic) {
// Notification::make()
// ->title('Class characteristic not found')
// ->body("No class characteristic found for item '{$itemCode}'.")
// ->danger()
// ->send();
// return;
// }
// $itemCharacteristicId = $itemCharacteristic->id;
// $stickerMappings = StickerMappingMaster::where('plant_id', $plantId)
// ->where('item_id', $item->id)
// ->get();
// if ($stickerMappings->isEmpty()) {
// Notification::make()
// ->title('Sticker mapping not found')
// ->body("No sticker mapping found for item '$itemCode' and plant '$plantName'.")
// ->danger()
// ->send();
// return;
// }
// $stickerOptions = [];
// // foreach ($stickerMappings as $stickerMapping) {
// // for ($i = 1; $i <= 8; $i++) {
// // $stickerStructureId = $stickerMapping->{"sticker_structure{$i}_id"};
// // if ($stickerStructureId) {
// // $detail = StickerStructureDetail::where('id', $stickerStructureId)
// // ->first();
// // if ($detail && $detail->sticker_id) {
// // $stickerOptions[$detail->sticker_id] = $detail->sticker_id;
// // }
// // }
// // }
// // }
// foreach ($stickerMappings as $stickerMapping) {
// for ($i = 1; $i <= 8; $i++) {
// $machineColumn = "sticker{$i}_machine_id";
// $stickerMachineId = $stickerMapping->$machineColumn;
// if ((string) $stickerMachineId != (string) $machineId) {
// continue;
// }
// $structureColumn = "sticker_structure{$i}_id";
// $stickerStructureId = $stickerMapping->$structureColumn;
// if (empty($stickerStructureId)) {
// continue;
// }
// $detail = StickerStructureDetail::find($stickerStructureId);
// if ($detail && $detail->sticker_id) {
// $stickerOptions[$detail->sticker_id] =
// $detail->sticker_id;
// }
// $set("sticker_structure{$i}_id", $stickerStructureId);
// }
// }
// $set('sticker_options', $stickerOptions);
// }),
Select::make('sticker_id')
->label('Sticker ID')
->options(fn (callable $get) => $get('sticker_options') ?? [])
->reactive()
->afterStateUpdated(function ($state, callable $set) {
if (blank($state)) {
return;
}
$plantid = $get('plant_id');
$sticker = StickerStructureDetail::where('sticker_id', $state)->first();
if (! $sticker) {
Notification::make()
->title('Sticker not found')
->body("Sticker ID '{$state}' was not found.")
->danger()
->send();
return;
}
$set('sticker_code', $state);
}),
Hidden::make('sticker_options')
->default([]),
TextInput::make('from_serial_number')
->label('From Serial Number')
->reactive()
->afterStateUpdated(function ($state, callable $set, callable $get) {
if (blank($state)) {
return;
}
$plantId = $get('plant_id');
$machineId = $get('machine_id');
$plantName = Plant::where('id', $plantid)->value('name');
$record = ClassCharacteristic::where('plant_id', $plantId)->where('machine_id', $machineId)->where('gernr', $state)->first();
if (! $record) {
$plantName = Plant::find($plantId)?->name;
$machineName = Machine::find($machineId)?->work_center;
Notification::make()
->title('Serial Number Not Found')
->body("Serial number '{$state}' was not found against work center '$machineName' and plant '$plantName'.")
->danger()
->send();
return;
}
$plantName = Plant::where('id', $plantId)->value('name');
$workCenter = Machine::where('id', $machineId)->value('work_center');
@@ -113,12 +312,12 @@ class BulkStickerPrinting extends Page implements HasForms
return;
}
$productionOrder = ClassCharacteristic::where('plant_id', $plantid)->where('machine_id', $machineId)->where('aufnr', $state)->first();
$productionOrder = ClassCharacteristic::where('plant_id', $plantId)->where('machine_id', $machineId)->where('gernr', $state)->first();
if (! $productionOrder) {
Notification::make()
->title('Production Order not found')
->body("Production Order '{$state}' was not found against machine '$workCenter' and plant '$plantName'.")
->body("Production Order '{$state}' was not found against machine '$workCenter', Serial Number '$state' and plant '$plantName'.")
->danger()
->send();
@@ -165,7 +364,7 @@ class BulkStickerPrinting extends Page implements HasForms
return;
}
$itemCharacteristicId = $itemCharacteristic->id;
// $itemCharacteristicId = $itemCharacteristic->id;
$stickerMappings = StickerMappingMaster::where('plant_id', $plantId)
->where('item_id', $item->id)
@@ -183,24 +382,6 @@ class BulkStickerPrinting extends Page implements HasForms
$stickerOptions = [];
// foreach ($stickerMappings as $stickerMapping) {
// for ($i = 1; $i <= 8; $i++) {
// $stickerStructureId = $stickerMapping->{"sticker_structure{$i}_id"};
// if ($stickerStructureId) {
// $detail = StickerStructureDetail::where('id', $stickerStructureId)
// ->first();
// if ($detail && $detail->sticker_id) {
// $stickerOptions[$detail->sticker_id] = $detail->sticker_id;
// }
// }
// }
// }
foreach ($stickerMappings as $stickerMapping) {
for ($i = 1; $i <= 8; $i++) {
@@ -235,40 +416,48 @@ class BulkStickerPrinting extends Page implements HasForms
}
$set('sticker_options', $stickerOptions);
$set('production_order', $record->aufnr);
}),
Select::make('sticker_id')
->label('Sticker ID')
->options(fn (callable $get) => $get('sticker_options') ?? [])
TextInput::make('to_serial_number')
->label('To Serial Number')
->reactive()
->afterStateUpdated(function ($state, callable $set) {
->afterStateUpdated(function ($state, callable $set, callable $get) {
if (blank($state)) {
return;
}
$sticker = StickerStructureDetail::where('sticker_id', $state)->first();
$productionOrder = $get('production_order');
$plantId = $get('plant_id');
$machineId = $get('machine_id');
if (! $sticker) {
$toSerialRecord = ClassCharacteristic::where('plant_id', $plantId)->where('machine_id', $machineId)->where('gernr', $state)->first();
if (! $toSerialRecord) {
Notification::make()
->title('Sticker not found')
->body("Sticker ID '{$state}' was not found.")
->title('Serial Number Not Found')
->body("To Serial Number '{$state}' was not found.")
->danger()
->send();
$set('to_serial_number', null);
return;
}
$set('sticker_code', $state);
if ((string) $toSerialRecord->aufnr != (string) $productionOrder) {
Notification::make()
->title('Production Order Mismatch')
->body("To Serial Number '{$state}' does not belong to Production Order '{$productionOrder}'.")
->danger()
->send();
$set('to_serial_number', null);
return;
}
}),
Hidden::make('sticker_options')
->default([]),
TextInput::make('from_serial_number')
->label('From Serial Number')
->reactive(),
TextInput::make('to_serial_number')
->label('To Serial Number')
->reactive(),
])
->columns(6),
]);
@@ -798,6 +987,7 @@ class BulkStickerPrinting extends Page implements HasForms
}
}
public function generateStickerId()
{
$state = $this->form->getState();
@@ -975,7 +1165,7 @@ class BulkStickerPrinting extends Page implements HasForms
//.New Logic
$stickerMappingMasterItems = StickerMappingMaster::where('plant_id', $plantId)->get();
$stickerMappingMasterItems = StickerMappingMaster::where('plant_id', $plantId)->where('item_id', $pOrderExist->item_id)->get();
if ($stickerMappingMasterItems->isEmpty()) {
Notification::make()
@@ -1077,54 +1267,69 @@ class BulkStickerPrinting extends Page implements HasForms
$matchedMachineId = null;
// for ($i = 1; $i <= 8; $i++) {
// $structureColumn = "sticker_structure{$i}_id";
// if (
// (string) $stickerMappingMasterItem->{$structureColumn}
// == (string) $structure->id
// ) {
// $machineColumn = "sticker{$i}_machine_id";
// $matchedMachineId = $stickerMappingMasterItem->{$machineColumn};
// break;
// }
// }
// if ($matchedMachineId == null || (string) $matchedMachineId != (string) $machineId)
// {
// Notification::make()
// ->danger()
// ->title('Machine Mapping Mismatch')
// ->body("Selected machine '{$machineId}' does not match the machine mapped to the selected sticker.")
// ->send();
// return;
// }
//..New
for ($i = 1; $i <= 8; $i++) {
$structureColumn = "sticker_structure{$i}_id";
$machineColumn = "sticker{$i}_machine_id";
$mappedStructureId = $stickerMappingMasterItem->{$structureColumn} ?? null;
if (
(string) $stickerMappingMasterItem->{$structureColumn}
== (string) $structure->id
$mappedStructureId !== null &&
(string) $mappedStructureId === (string) $structure->id
) {
$machineColumn = "sticker{$i}_machine_id";
$matchedMachineId = $stickerMappingMasterItem->{$machineColumn};
$matchedMachineId = $stickerMappingMasterItem->{$machineColumn} ?? null;
break;
}
}
if (
$matchedMachineId == null ||
(string) $matchedMachineId != (string) $machineId
) {
$selectedMachineId = trim((string) $machineId);
$mappedMachineId = trim((string) $matchedMachineId);
if ($mappedMachineId === '' || $mappedMachineId !== $selectedMachineId) {
Notification::make()
->danger()
->title('Machine Mapping Mismatch')
->body("Selected machine '{$machineId}' does not match the machine mapped to the selected sticker.")
->body("Selected machine '{$selectedMachineId}' does not match the mapped machine '{$mappedMachineId}'.")
->send();
return;
}
if ((string) $matchedMachineId != (string) $machineId) {
Notification::make()
->danger()
->title('Machine Not Found')
->body("Machine '{$machineId}' is not mapped for Item Code '{$itemCode}' against sticker '$stickerId' in sticker mapping master.")
->send();
return;
}
// $matchedMachineId = StickerMappingMaster::where('plant_id', $plantId)->where('item_id', $pOrderExist->item_id)->where('sticker_structure1_id', $structure->id)->where('sticker1_machine_id', $machineId)->first();
// if (!$matchedMachineId) {
// if ((string) $matchedMachineId != (string) $machineId) {
// Notification::make()
// ->danger()
// ->title('Machine Not Found')
// ->body("Machine '{$machineId}' is not mapped for Item Code '{$itemCode}' in sticker mapping master.")
// ->body("Machine '{$machineId}' is not mapped for Item Code '{$itemCode}' against sticker '$stickerId' in sticker mapping master.")
// ->send();
// return;
@@ -1236,6 +1441,378 @@ class BulkStickerPrinting extends Page implements HasForms
}
#[On('generate-sticker-id')]
public function generateStickerId2(string $serialNumbers)
{
$state = $this->form->getState();
$plantId = trim($state['plant_id'] ?? '');
$machineId = trim($state['machine_id'] ?? '');
$stickerId = $state['sticker_id'] ?? null;
$pOrder = $state['production_order'] ?? null;
$fromSno = trim($state['from_serial_number'] ?? '');
$toSno = trim($state['to_serial_number'] ?? '');
$serialNumbersArray = array_filter(array_map('trim', explode(',', $serialNumbers)));
if (count($serialNumbersArray) > 50) {
Notification::make()
->title('Too Many Serial Numbers')
->body('You can enter a maximum of 50 serial numbers.')
->danger()
->send();
return;
}
$plantName = Plant::where('id', $plantId)->value('name');
if (!$stickerId) {
Notification::make()
->danger()
->title('Sticker ID Not Selected')
->body('Please Choose a Sticker ID.')
->send();
return;
}
$pOrderExist = ClassCharacteristic::where('plant_id',$plantId)->where('aufnr', $pOrder)->first();
if(!$pOrderExist){
Notification::make()
->danger()
->title('Unknown Production Order')
->body("Production Order '$pOrder' not found.")
->send();
return;
}
if($pOrderExist){
$existingSerialNumbers = ClassCharacteristic::where('plant_id', $plantId)
->where('aufnr', $pOrder)
->whereIn('gernr', $serialNumbersArray)
->pluck('gernr')
->map(fn ($value) => trim((string) $value))
->unique()
->toArray();
$invalidSerialNumbers = array_values(
array_diff($serialNumbersArray, $existingSerialNumbers)
);
if (!empty($invalidSerialNumbers)) {
Notification::make()
->danger()
->title('Unknown Serial Numbers')
->body(
"The following serial numbers do not belong to Production Order '$pOrder' "
. "for plant '$plantName': "
. implode(', ', $invalidSerialNumbers)
)
->send();
return;
}
}
$existingStickers = StickerOrder::where('plant_id', $plantId)
->where('production_order', $pOrder)
->where('sticker_id', $stickerId)
->where('print_status', 'Printed')
->whereIn('serial_number', $serialNumbersArray)
->pluck('serial_number')
->unique()
->values()
->toArray();
if (!empty($existingStickers)) {
Notification::make()
->danger()
->title('Duplicate Sticker')
->body("The following serial numbers already exist in generated stickers for ". "Sticker '$stickerId', Production Order '$pOrder', and plant '$plantName': ". implode(', ', $existingStickers))
->send();
return;
}
$structure = StickerStructureDetail::where('sticker_id',$stickerId)->first();
if (!$structure) {
Notification::make()
->danger()
->title('Sticker Structure Not Found')
->body("No sticker structure found for sticker ID '{$stickerId}'.")
->send();
return;
}
//.New Logic
$stickerMappingMasterItems = StickerMappingMaster::where('plant_id', $plantId)->where('item_id', $pOrderExist->item_id)->get();
if ($stickerMappingMasterItems->isEmpty()) {
Notification::make()
->danger()
->title('Sticker Mapping Not Found')
->body("No sticker mapping found for plant ID '{$plantId}'.")
->send();
return;
}
$structureIds = $stickerMappingMasterItems
->flatMap(function ($mapping) {
$ids = [];
for ($i = 1; $i <= 8; $i++) {
$column = "sticker_structure{$i}_id";
if (!empty($mapping->{$column})) {
$ids[] = $mapping->{$column};
}
}
return $ids;
})
->unique()
->values();
$detailsById = StickerStructureDetail::whereIn('id', $structureIds)
->get()
->keyBy('id');
$structure = null;
$stickerMappingMasterItem = null;
foreach ($stickerMappingMasterItems as $mapping) {
for ($i = 1; $i <= 8; $i++) {
$column = "sticker_structure{$i}_id";
$structureId = $mapping->{$column};
if (empty($structureId)) {
continue;
}
$detail = $detailsById->get($structureId);
if (!$detail) {
continue;
}
if ((string) $detail->sticker_id === (string) $stickerId) {
$structure = $detail;
$stickerMappingMasterItem = $mapping;
break 2;
}
}
}
if (!$structure) {
Notification::make()
->danger()
->title('Sticker Mapping Not Found')
->body("No mapping found for sticker ID '{$stickerId}' and plant ID '{$plantId}'.")
->send();
return;
}
// $checkItem = StickerMappingMaster::where('plant_id', $plantId)->where('item_id', $pOrderExist->item_id)->where('sticker_structure1_id', $structure->id)->first();
$itemCode = Item::where('id', $pOrderExist->item_id)->value('code');
$plantCode = Plant::where('id', $plantId)->value('code');
// if (!$checkItem) {
// Notification::make()
// ->danger()
// ->title('Item Not Found')
// ->body("Item code '$itemCode' not found in sticker mapping master for selected sticker ID '{$stickerId}'.")
// ->send();
// return;
// }
$itemCharacteristic1 = ClassCharacteristic::where('plant_id', $plantId)->where('aufnr', $pOrder)->where('item_id', $pOrderExist->item_id)->first();
if (!$itemCharacteristic1) {
Notification::make()
->danger()
->title('Item Not Found')
->body("Item code '{$itemCode}' was not found against job number '$pOrder' in class characteristic.")
->send();
return;
}
$matchedMachineId = null;
for ($i = 1; $i <= 8; $i++) {
$structureColumn = "sticker_structure{$i}_id";
$machineColumn = "sticker{$i}_machine_id";
$mappedStructureId = $stickerMappingMasterItem->{$structureColumn} ?? null;
if (
$mappedStructureId !== null &&
(string) $mappedStructureId === (string) $structure->id
) {
$matchedMachineId = $stickerMappingMasterItem->{$machineColumn} ?? null;
break;
}
}
$selectedMachineId = trim((string) $machineId);
$mappedMachineId = trim((string) $matchedMachineId);
if ($mappedMachineId === '' || $mappedMachineId !== $selectedMachineId) {
Notification::make()
->danger()
->title('Machine Mapping Mismatch')
->body("Selected machine '{$selectedMachineId}' does not match the mapped machine '{$mappedMachineId}'.")
->send();
return;
}
$itemCharacteristic = ClassCharacteristic::where('plant_id', $plantId)
->where('item_id', $pOrderExist->item_id)
->where('machine_id', $machineId)
->where('aufnr', $pOrder)
->first();
if(!$itemCharacteristic){
Notification::make()
->danger()
->title('Record Not Found')
->body("Record not found in class characteristic against job '$pOrder', item '$itemCode' and plant '$plantCode'.")
->send();
return;
}
$elements = StickerDetail::where('sticker_structure_detail_id',$structure->id)->get();
if ($elements->isEmpty()) {
Notification::make()
->danger()
->title('Sticker Details Not Found')
->body('No sticker details configured for the selected sticker.')
->send();
return;
}
$stickerService = new StickerPdfService();
$template = $stickerService->generateTemplate(
$structure->sticker_id,
$elements,
$itemCharacteristic,
$itemCode,
$plantId,
$machineId
);
$pdfContent = $stickerService->generateMultipleBulkFromTemplate(
$template,
$serialNumbersArray,
$itemCode,
);
$fileName = 'bulk_sticker_'. '_'. uniqid(). '.pdf';
$tempPdfPath = storage_path('app/' . $fileName);
file_put_contents(
$tempPdfPath,
$pdfContent
);
$pdfUrl = route(
'sticker.preview',
[
'path' => $fileName,
]
);
$this->dispatch('open-sticker-pdf',urls: [$pdfUrl]);
$totalStickers = count($serialNumbersArray);
$item = Item::where('id', $pOrderExist->item_id)->where('plant_id', $plantId)->first();
foreach ($serialNumbersArray as $serialNumber) {
$serialNumber = trim($serialNumber);
$exists = StickerOrder::where('plant_id', $plantId)
->where('production_order', $pOrder)
->where('sticker_id', $stickerId)
->where('serial_number', $serialNumber)
->first();
if (!$exists) {
StickerOrder::create([
'plant_id' => $plantId,
'item_id' => $item->id,
'production_order' => $pOrder,
'serial_number' => $serialNumber,
'sticker_id' => $stickerId,
'print_status' => 'Printed',
]);
}
}
Notification::make()
->success()
->title('Sticker Generated')
->body("{$totalStickers} sticker(s) generated successfully.")
->seconds(3)
->send();
return;
}
#[On('production-order-updated')]
public function updateProductionOrder(string $productionOrder): void
{
$this->filters['production_order'] = $productionOrder;
}
#[On('sticker-options')]
public function stickerStructure(array $stickerOptions): void
{
$this->filters['sticker_options'] = $stickerOptions;
}
#[On('production-order-clear')]
public function updateProductionOrderClear(): void
{
$this->filters['production_order'] = null;
}
#[On('sticker-options-clear')]
public function stickerStructureClear(): void
{
$this->filters['sticker_options'] = null;
}
public static function canAccess(): bool
{
return Auth::check() && Auth::user()->can('view sticker bulk print page');

View File

@@ -288,11 +288,11 @@ class PanelBoxInspectionStock extends Page
{
$parts = explode('/', $itemId);
if (count($parts) < 3) {
if (!preg_match('/^\d+\/\d+\/\d{4}\/\d+$/', $itemId) || preg_match('/[a-zA-Z]/', $itemId)) {
Notification::make()
->title('Invalid QR Format')
->body('Expected format: plantcode/itemcode/yearmm/serialnumber (Or) plantcode/panelboxcode/serialnumber')
->body("Expected format: plantcode/itemcode/yearmm/serialnumber : Format Received : $itemId")
->danger()
->send();
$this->form->fill([
@@ -310,10 +310,10 @@ class PanelBoxInspectionStock extends Page
$itemCode = $panelBoxCode;
$serialNumber = $panelBoxSerialNo;
if (strlen($serialNumber) > 30) {
if (strlen($serialNumber) > 15) {
Notification::make()
->title('Invalid Serial Number')
->body("Serial number cannot be greater than 30 characters. Current length: " . strlen($panelBoxSerialNo))
->body("Serial number cannot be greater than 15 characters. Current length: " . strlen($panelBoxSerialNo))
->danger()
->send();
@@ -358,10 +358,11 @@ class PanelBoxInspectionStock extends Page
return;
}
}
else {
else
{
Notification::make()
->title('Invalid QR Format')
->body('Expected format: plantcode/itemcode/yearmm/serialnumber (Or) plantcode/panelboxcode/serialnumber')
->body('Expected format: plantcode/itemcode/yearmm/serialnumber')
->danger()
->send();
$this->form->fill([

View File

@@ -277,15 +277,14 @@ class StickerOrderReprint extends Page implements HasForms
$plantId = $get('plant_id');
$machineId = $get('machine_id');
$record = ClassCharacteristic::where('plant_id', $plantId)
->where('machine_id', $machineId)
->where('gernr', $state)
->first();
$record = ClassCharacteristic::where('plant_id', $plantId)->where('machine_id', $machineId)->where('gernr', $state)->first();
if (! $record) {
$plantName = Plant::find($plantId)?->name;
$machineName = Machine::find($machineId)?->work_center;
Notification::make()
->title('Serial Number Not Found')
->body("Serial number '{$state}' was not found.")
->body("Serial number '{$state}' was not found against work center '$machineName' and plant '$plantName'.")
->danger()
->send();
@@ -1091,7 +1090,7 @@ class StickerOrderReprint extends Page implements HasForms
return;
}
$stickerMappingMasterItems = StickerMappingMaster::where('plant_id', $plantId)->get();
$stickerMappingMasterItems = StickerMappingMaster::where('plant_id', $plantId)->where('item_id', $pOrderExist->item_id)->get();
if ($stickerMappingMasterItems->isEmpty()) {
Notification::make()
@@ -1209,35 +1208,27 @@ class StickerOrderReprint extends Page implements HasForms
for ($i = 1; $i <= 8; $i++) {
$structureColumn = "sticker_structure{$i}_id";
$machineColumn = "sticker{$i}_machine_id";
$mappedStructureId = $stickerMappingMasterItem->{$structureColumn} ?? null;
if (
(string) $stickerMappingMasterItem->{$structureColumn}
== (string) $structure->id
$mappedStructureId !== null &&
(string) $mappedStructureId === (string) $structure->id
) {
$machineColumn = "sticker{$i}_machine_id";
$matchedMachineId = $stickerMappingMasterItem->{$machineColumn};
$matchedMachineId = $stickerMappingMasterItem->{$machineColumn} ?? null;
break;
}
}
if ($matchedMachineId == null || (string) $matchedMachineId != (string) $machineId)
{
$selectedMachineId = trim((string) $machineId);
$mappedMachineId = trim((string) $matchedMachineId);
if ($mappedMachineId === '' || $mappedMachineId !== $selectedMachineId) {
Notification::make()
->danger()
->title('Machine Mapping Mismatch')
->body("Selected machine '{$machineId}' does not match the machine mapped to the selected sticker.")
->send();
return;
}
if ((string) $matchedMachineId != (string) $machineId) {
Notification::make()
->danger()
->title('Machine Not Found')
->body("Machine '{$machineId}' is not mapped for Item Code '{$itemCode}' against sticker '$stickerId' in sticker mapping master.")
->body("Selected machine '{$selectedMachineId}' does not match the mapped machine '{$mappedMachineId}'.")
->send();
return;

View File

@@ -1270,6 +1270,9 @@ class InvoiceValidationResource extends Resource
TextInput::make('serial_number')
->label('Serial Number')
->placeholder(placeholder: 'Enter Serial Number'),
TextInput::make('panel_box_serial_number')
->label('Panel Box Serial Number')
->placeholder(placeholder: 'Enter Panel Box Serial Number'),
Select::make('sticker_master_id')
->label('Search by Item Code')
->nullable()
@@ -1278,15 +1281,16 @@ class InvoiceValidationResource extends Resource
->options(function (callable $get) {
$pId = $get('Plant');
// if (empty($pId)) {
// return [];
// }
return Item::whereHas('stickerMasters', function ($query) use ($pId) {
if ($pId) {
$query->where('plant_id', $pId);
}
$query->whereHas('invoiceValidations');
})->pluck('code', 'id');
if (! $pId) {
return [];
} else {
return Item::whereHas('stickerMasters', function ($query) use ($pId) {
if ($pId) {
$query->where('plant_id', $pId);
}
$query->whereHas('invoiceValidations');
})->pluck('code', 'id');
}
}),
Select::make('scanned_status')
->label('Scanned Status')
@@ -1323,7 +1327,7 @@ class InvoiceValidationResource extends Resource
])
->query(function ($query, array $data) {
// Hide all records initially if no filters are applied
if (empty($data['invoice_type']) || (empty($data['Plant']) && empty($data['invoice_number']) && empty($data['serial_number']) && empty($data['created_from']) && empty($data['created_to']) && empty($data['operator_id']) && empty($data['scanned_status']) && empty($data['sticker_master_id']))) {
if (empty($data['invoice_type']) || (empty($data['Plant']) && empty($data['invoice_number']) && empty($data['serial_number']) && empty($data['panel_box_serial_number']) && empty($data['created_from']) && empty($data['created_to']) && empty($data['operator_id']) && empty($data['scanned_status']) && empty($data['sticker_master_id']))) {
if (empty($data['invoice_type'])) {
Notification::make()
->title('Please, choose invoice type to filter.')
@@ -1381,6 +1385,10 @@ class InvoiceValidationResource extends Resource
$query->where('serial_number', 'like', '%'.$data['serial_number'].'%');
}
if (! empty($data['panel_box_serial_number'])) {
$query->where('panel_box_serial_number', 'like', '%'.$data['panel_box_serial_number'].'%');
}
if (! empty($data['created_from'])) {
$query->where('created_at', '>=', $data['created_from']);
}
@@ -1393,8 +1401,9 @@ class InvoiceValidationResource extends Resource
$query->where('operator_id', $data['operator_id']);
}
if (! empty($data['sticker_master_id'])) {
if (! empty($data['sticker_master_id']) && ! empty($data['Plant'])) {
$stickerMasterIds = StickerMaster::where('item_id', $data['sticker_master_id'])
->where('plant_id', $data['Plant'])
->pluck('id')
->toArray();
@@ -1424,7 +1433,11 @@ class InvoiceValidationResource extends Resource
$indicators[] = 'Serial Number: '.$data['serial_number'];
}
if (! empty($data['sticker_master_id'])) {
if (! empty($data['panel_box_serial_number'])) {
$indicators[] = 'Panel Box Serial Number: '.$data['panel_box_serial_number'];
}
if (! empty($data['sticker_master_id']) && ! empty($data['Plant'])) {
$itemCode = Item::find($data['sticker_master_id'])->code ?? 'Unknown';
$indicators[] = 'Item Code: '.$itemCode;
}

View File

@@ -21,6 +21,8 @@ use Filament\Tables\Filters\Filter;
use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\SoftDeletingScope;
use Filament\Forms\Set;
use Filament\Notifications\Notification;
class LeakTestReadingResource extends Resource
{
@@ -76,39 +78,84 @@ class LeakTestReadingResource extends Resource
->hintColor('danger'),
Forms\Components\TextInput::make('item_code')
->required()
->label('Item Code')
->placeholder('Scan the valid item code')
->label('Scan QR Code')
->placeholder('Scan the valid QR Code')
->autofocus(true)
->alphaNum()
->minLength(6)
// ->alphaNum()
// ->minLength(6)
->reactive()
->disabled(fn (Get $get) => ! empty($get('id')) && ! Filament::auth()->user()->hasRole('Super Admin'))
->afterStateUpdated(function ($state, callable $set, callable $get) {
$code = $get('item_code');
$set('lsrCodeError', null);
if (! $code) {
$set('lsrCodeError', 'Scan the valid item code.');
// ->afterStateUpdated(function ($state, callable $set, callable $get) {
// $code = $get('item_code');
// $set('lsrCodeError', null);
// if (! $code) {
// $set('lsrCodeError', 'Scan the valid item code.');
return;
} else {
if (strlen($code) < 6) {
$set('lsrCodeError', 'Item code must be at least 6 digits.');
// return;
// } else {
// if (strlen($code) < 6) {
// $set('lsrCodeError', 'Item code must be at least 6 digits.');
return;
} elseif (! ctype_alnum($code)) {
// return;
// } elseif (! ctype_alnum($code)) {
// $set('item_code', null);
// $set('lsrCodeError', 'Item code must contain only alpha-numeric characters!');
// return;
// } elseif (! preg_match('/^[a-zA-Z1-9][a-zA-Z0-9]{5,}$/', $code)) {
// $set('item_code', null);
// $set('lsrCodeError', "Item code should not begin with '0' or letter!");
// return;
// }
// $set('lsrCodeError', null);
// }
// })
->afterStateUpdated(function ($state, Set $set, Get $get, $livewire) {
if (blank($state)) {
$set('item_code', null);
$set('lsrCodeError', 'Item code must contain only alpha-numeric characters!');
return;
} elseif (! preg_match('/^[a-zA-Z1-9][a-zA-Z0-9]{5,}$/', $code)) {
$set('item_code', null);
$set('lsrCodeError', "Item code should not begin with '0' or letter!");
$set('serial_number', null);
return;
}
$set('lsrCodeError', null);
}
})
$parts = explode('|', trim($state));
if (! preg_match('/^[^|]+\|[^|]+\|?$/', trim($state))) {
Notification::make()
->title('Invalid QR Format')
->body("Expected format: ItemCode|SerialNumber<br>Received Format '$state'")
->danger()
->send();
$set('item_code', null);
return;
}
else{
$iCode = $parts[0];
if (strlen($parts[0]) > 6) {
Notification::make()
->title('Invalid Item Code')
->body("Item code '$iCode' should contain minimum 6 digits!")
->danger()
->send();
$set('item_code', null);
return;
}
elseif(!preg_match('/^[a-zA-Z0-9]+$/', $iCode)){
Notification::make()
->title('Invalid Item Code')
->body("Item code '$iCode' should contain alpha numeric values!")
->danger()
->send();
$set('item_code', null);
return;
}
$set('item_code', trim($parts[0]));
$set('serial_number', isset($parts[1]) ? trim($parts[1]) : null);
// $set('test_status', 'P');
$livewire->dispatch('submit-leak-test-form');
}
})
->extraAttributes(fn ($get) => [
'class' => $get('lsrCodeError') ? 'border-red-500' : '',
])
@@ -158,13 +205,14 @@ class LeakTestReadingResource extends Resource
->label('Test Status')
->searchable()
->reactive()
->default('P')
// ->disabled(fn (Get $get) => ! empty($get('id')))
->options(function (callable $set, callable $get) {
$plantId = $get('plant_id');
$itemCode = $get('item_code');
$serialNumber = $get('serial_number');
// $itemCode = $get('item_code');
// $serialNumber = $get('serial_number');
if (! $plantId || ! $itemCode || ! $serialNumber) {
if (! $plantId) { //|| ! $itemCode || ! $serialNumber
$set('test_status', null);
return [];

View File

@@ -4,9 +4,55 @@ namespace App\Filament\Resources\LeakTestReadingResource\Pages;
use App\Filament\Resources\LeakTestReadingResource;
use Filament\Actions;
use Filament\Notifications\Notification;
use Filament\Resources\Pages\CreateRecord;
use Livewire\Attributes\On;
class CreateLeakTestReading extends CreateRecord
{
protected static string $resource = LeakTestReadingResource::class;
public function processQR($value){
$qrCode = $value;
$parts = explode('|', $qrCode);
$plantId = $this->form->getState()['plant_id'];
if (! preg_match('/^[^|]+(?:\|[^|]+)?$/', $value)) {
Notification::make()
->title('Invalid QR Format')
->body('Expected format: ItemCode|SerialNumber')
->danger()
->send();
return;
}
$itemCode = $parts[0] ?? null;
$serialNumber = $parts[1] ?? null;
$this->form->fill([
'plant_id' => $plantId,
'item_code' => $itemCode,
'serial_number' => $serialNumber,
'test_status' => 'PASS'
]);
}
#[On('submit-leak-test-form')]
public function submitLeakTestForm(): void
{
$this->create();
}
protected function getRedirectUrl(): string
{
//return $this->getResource()::getUrl('create'); // Stay on Create Page after savin
return $this->getResource()::getUrl('create', [
'plant_id' => $this->data['plant_id'] ?? null,
]);
}
}

View File

@@ -210,8 +210,7 @@ class PanelBoxValidationResource extends Resource
'class' => $get('inspecOrdError') ? 'border-red-500' : '',
])
->hint(fn ($get) => $get('inspecOrdError') ? $get('inspecOrdError') : null)
->hintColor('danger')
->required(),
->hintColor('danger'),
Forms\Components\Hidden::make('inspection')
->default(fn () => session('last_selected_inspection'))
->afterStateHydrated(function ($state, $set) {
@@ -562,11 +561,11 @@ class PanelBoxValidationResource extends Resource
{
$parts = explode('/', $state);
if (count($parts) < 3) {
if (!preg_match('/^\d+\/\d+\/\d{4}\/\d+$/', $state) || preg_match('/[a-zA-Z]/', $state)) {
Notification::make()
->title('Invalid QR Format')
->body('Expected format: plantcode/itemcode/yearmm/serialnumber (Or) plantcode/panelboxcode/serialnumber')
->body("Expected format: plantcode/itemcode/yearmm/serialnumber Format Received : $state")
->danger()
->send();
$set('item_id', null);
@@ -581,10 +580,10 @@ class PanelBoxValidationResource extends Resource
$itemCode = $panelBoxCode;
$serialNumber = $panelBoxSerialNo;
if (strlen($serialNumber) > 30) {
if (strlen($serialNumber) > 15) {
Notification::make()
->title('Invalid Serial Number')
->body("Serial number cannot be greater than 30 characters. Current length: " . strlen($panelBoxSerialNo))
->body("Serial number cannot be greater than 15 characters. Current length: " . strlen($panelBoxSerialNo))
->danger()
->send();

View File

@@ -18,6 +18,8 @@ class EditPanelGrMaster extends EditRecord
{
$record = $this->record;
$scannedQuantity = 0;
$sticker = StickerMaster::where('plant_id', $record->plant_id)->where('item_id', $record->item_id)->first();
if($sticker)

View File

@@ -185,15 +185,13 @@ class PlantResource extends Resource
->hint(fn ($get) => $get('pAddressError') ? $get('pAddressError') : null)
->hintColor('danger'),
Forms\Components\Textarea::make('reg_address')
->required()
->label('Reg Address')
->label('Regd Address')
->placeholder('Scan the valid Regd address')
->unique(ignoreRecord: true)
->columnSpanFull()
->reactive()
->minLength(5)
->afterStateUpdated(function ($state, callable $set, callable $get) {
$nameId = $get('address');
$nameId = $get('reg_address');
// Ensure `linestop_id` is not cleared
if (! $nameId) {
$set('pRegAddressError', 'Scan the valid reg address.');
@@ -208,6 +206,50 @@ class PlantResource extends Resource
])
->hint(fn ($get) => $get('pRegAddressError') ? $get('pRegAddressError') : null)
->hintColor('danger'),
Forms\Components\Textarea::make('feed_address')
->label('Feed Address')
->placeholder('Scan the valid Feed address')
->columnSpanFull()
->reactive()
->minLength(5)
->afterStateUpdated(function ($state, callable $set, callable $get) {
$nameId = $get('feed_address');
// Ensure `linestop_id` is not cleared
if (! $nameId) {
$set('pFeedAddressError', 'Scan the valid feed back address.');
return;
} else {
$set('pFeedAddressError', null);
}
})
->extraAttributes(fn ($get) => [
'class' => $get('pFeedAddressError') ? 'border-red-500' : '',
])
->hint(fn ($get) => $get('pFeedAddressError') ? $get('pRegAddressError') : null)
->hintColor('danger'),
Forms\Components\Textarea::make('tollfree')
->label('Tollfree')
->placeholder('Scan the valid Tollfree')
->columnSpanFull()
->reactive()
->minLength(5)
->afterStateUpdated(function ($state, callable $set, callable $get) {
$nameId = $get('tollfree');
// Ensure `linestop_id` is not cleared
if (! $nameId) {
$set('pTollfreeError', 'Scan the valid tollfree.');
return;
} else {
$set('pTollfreeError', null);
}
})
->extraAttributes(fn ($get) => [
'class' => $get('pTollfreeError') ? 'border-red-500' : '',
])
->hint(fn ($get) => $get('pTollfreeError') ? $get('pTollfreeError') : null)
->hintColor('danger'),
Forms\Components\TextInput::make('id')
->hidden()
->readOnly(),
@@ -262,6 +304,16 @@ class PlantResource extends Resource
->alignCenter()
->sortable()
->searchable(),
Tables\Columns\TextColumn::make('feed_address')
->label('FeedBack')
->alignCenter()
->sortable()
->searchable(),
Tables\Columns\TextColumn::make('tollfree')
->label('Tollfree')
->alignCenter()
->sortable()
->searchable(),
Tables\Columns\TextColumn::make('company.name')
->label('Company')
->alignCenter()

View File

@@ -116,6 +116,11 @@ class StickerDetailResource extends Resource
->prepend('Serial Number', 'serial_number')
->prepend('Plant Name', 'plant_name')
->prepend('Plant Address', 'plant_address')
->prepend('Regd Address', 'regd_address')
->prepend('Regd Unit', 'regd_unit')
->prepend('Feed Address', 'feed_address')
->prepend('Tollfree', 'tollfree')
->prepend('Company Name', 'company_name')
->prepend('Current Date', 'current_date')
->prepend('Tested By', 'tested_by')
->prepend('Verified By', 'verified_by')

View File

@@ -89,7 +89,26 @@ class StickerMappingMasterResource extends Resource
})
->searchable()
->required(),
->required()
->rules([
function (callable $get, $record) {
return function (string $attribute, $value, $fail) use ($get, $record) {
$plantId = $get('plant_id');
$query = StickerMappingMaster::where('plant_id', $plantId)
->where('item_id', $value);
// Ignore the current record when editing
if ($record) {
$query->where('id', '!=', $record->id);
}
if ($query->exists()) {
$fail('Item Code already exist to the selected plant.');
}
};
},
]),
])
->columns(2),

View File

@@ -866,7 +866,7 @@ class InvoiceDataTable extends Component
$panelExistsInvoice = InvoiceValidation::where('plant_id', $this->plantId)
->where('panel_box_serial_number', $serialNumber)
->where('panel_box_code', $itemCode)
// ->where('panel_box_code', $itemCode)
->where('panel_box_supplier', $supplier)
->first();

View File

@@ -0,0 +1,238 @@
<?php
namespace App\Livewire;
use App\Models\ClassCharacteristic;
use App\Models\StickerStructureDetail;
use App\Models\Item;
use App\Models\StickerMappingMaster;
use Filament\Notifications\Notification;
use Livewire\Component;
use Livewire\Attributes\Reactive;
class RandomSerialNumberList extends Component
{
public bool $showMultipleSerials = false;
public array $serialNumbers = [''];
#[Reactive]
public $plantId = null;
#[Reactive]
public $machineId = null;
public function updatedShowMultipleSerials($value): void
{
$this->serialNumbers = collect($this->serialNumbers)
->filter(fn ($serial) => trim($serial) !== '')
->values()
->toArray();
// Clear all values whenever the checkbox changes
$this->serialNumbers = [''];
}
public function splitSerialNumbers(string $text): void
{
$serials = preg_split('/[\r\n\t ,;]+/', trim($text));
$this->serialNumbers = collect($serials)
->filter(fn ($serial) => $serial !== '')
->values()
->toArray();
if (empty($this->serialNumbers)) {
$this->serialNumbers = [''];
}
$plantId = $this->plantId;
$machineId = $this->machineId;
if (!$plantId) {
Notification::make()
->danger()
->title('Plant Not Selected')
->body('Please select a plant before pasting serial numbers.')
->send();
$this->dispatch('sticker-options-clear', stickerOptions: '');
$this->dispatch('production-order-clear', productionOrder: '');
return;
}
$serialNumbersArray = array_values(
array_filter(
array_map('trim', $this->serialNumbers),
fn ($serial) => $serial !== ''
)
);
if (count($serialNumbersArray) > 50) {
Notification::make()
->title('Too Many Serial Numbers')
->body('You can enter a maximum of 50 serial numbers.')
->danger()
->send();
$this->dispatch('sticker-options-clear', stickerOptions: '');
$this->dispatch('production-order-clear', productionOrder: '');
$this->serialNumbers = [''];
return;
}
$records = ClassCharacteristic::where('plant_id', $plantId)->whereIn('gernr', $serialNumbersArray)->get();
$foundSerialNumbers = $records->pluck('gernr')
->map(fn ($serial) => trim((string) $serial))
->unique()
->toArray();
$missingSerialNumbers = array_values(
array_diff($serialNumbersArray, $foundSerialNumbers)
);
if (!empty($missingSerialNumbers)) {
Notification::make()
->danger()
->title('Serial Numbers Not Found')
->body('The following serial numbers do not exist for the selected plant: '. implode(', ', $missingSerialNumbers))
->send();
return;
}
$productionOrder = $records->first()->aufnr;
$invalidSerialNumbers = $productionOrder
? $records->filter(
fn ($record) => $record->aufnr != $productionOrder
)->pluck('gernr')->unique()->values()->toArray()
: [];
if (!empty($invalidSerialNumbers)) {
Notification::make()
->danger()
->title('Invalid Serial Numbers')
->body('The following serial numbers belong to a different production order: '. implode(', ', $invalidSerialNumbers))
->send();
return;
}
$record = $records->first();
$itemId = $record->item_id;
$item = Item::find($itemId);
if (! $item) {
Notification::make()
->title('Item not found')
->body("Item code '{$itemId}' was not found in item master.")
->danger()
->send();
$this->dispatch('sticker-options-clear', stickerOptions: '');
$this->dispatch('production-order-clear', productionOrder: '');
return;
}
$itemCode = $item->code;
$item = Item::where('code', $itemCode)->where('plant_id', $plantId)->first();
if (! $item) {
Notification::make()
->title('Item not found')
->body("Item '{$itemCode}' was not found for the selected plant.")
->danger()
->send();
$this->dispatch('sticker-options-clear', stickerOptions: '');
$this->dispatch('production-order-clear', productionOrder: '');
return;
}
$itemCharacteristic = ClassCharacteristic::where('plant_id', $plantId)->where('item_id', $item->id)->first();
if (! $itemCharacteristic) {
Notification::make()
->title('Class characteristic not found')
->body("No class characteristic found for item '{$itemCode}'.")
->danger()
->send();
return;
}
// $itemCharacteristicId = $itemCharacteristic->id;
$stickerMappings = StickerMappingMaster::where('plant_id', $plantId)
->where('item_id', $item->id)
->get();
if (! $stickerMappings) {
Notification::make()
->title('Sticker mapping not found')
->body("No sticker mapping found for this plant and item '$itemCode'.")
->danger()
->send();
return;
}
$stickerOptions = [];
foreach ($stickerMappings as $stickerMapping) {
for ($i = 1; $i <= 8; $i++) {
$machineColumn = "sticker{$i}_machine_id";
$stickerMachineId = $stickerMapping->$machineColumn;
if ((string) $stickerMachineId != (string) $machineId) {
continue;
}
$structureColumn = "sticker_structure{$i}_id";
$stickerStructureId = $stickerMapping->$structureColumn;
if (empty($stickerStructureId)) {
continue;
}
$detail = StickerStructureDetail::find($stickerStructureId);
if ($detail && $detail->sticker_id) {
$stickerOptions[$detail->sticker_id] =
$detail->sticker_id;
}
$this->dispatch('sticker-structure-updated', stickerStructureId: $stickerStructureId);
}
}
$this->dispatch('sticker-options', stickerOptions: $stickerOptions);
$this->dispatch('production-order-updated', productionOrder: $productionOrder);
}
public function generate(): void
{
$serialNumbersString = implode(',', array_filter(
$this->serialNumbers,
fn ($serial) => trim($serial) !== ''
));
$this->dispatch('generate-sticker-id', serialNumbers: $serialNumbersString);
}
public function clear(){
$this->serialNumbers = [''];
$this->dispatch('sticker-options-clear', stickerOptions: '');
$this->dispatch('production-order-clear', productionOrder: '');
}
public function render()
{
return view('livewire.random-serial-number-list');
}
}

View File

@@ -18,6 +18,8 @@ class Plant extends Model
'address',
'warehouse_number',
'reg_address',
'feed_address',
'tollfree',
];
public function company(): BelongsTo

View File

@@ -9,6 +9,8 @@ use App\Models\StickerDetail;
use App\Models\StickerMappingMaster;
use App\Models\StickerStructureDetail;
use App\Models\StickerValidation;
use App\Models\Company;
use App\Models\Plant;
use App\Models\TestApprovalMapping;
use App\Models\ClassCharacteristic;
use Illuminate\Http\Response;
@@ -1057,6 +1059,7 @@ class StickerPdfService
$plantName = $itemCharacteristic?->plant?->name ?? '';
$plantAddress = $itemCharacteristic?->plant?->address ?? '';
$plantRegdAddress = $itemCharacteristic?->plant?->reg_address ?? '';
$dateOfTest = $itemCharacteristic?->created_at?->format('d.m.Y') ?? '';
// $currentDate = $itemCharacteristic?->created_at?->format('M-y') ?? '';
@@ -1154,6 +1157,158 @@ class StickerPdfService
? number_format((float) $itemCharacteristic->{$column} * 2, 2, '.', '')
: '';
}
if ($row->characteristics_type == 'regd_address') {
$column = 'zmm_brand';
$textValue = $itemCharacteristic?->{$column} != null
? $itemCharacteristic->{$column}
: '';
if($textValue == 'TORMAC'){
$cName = Company::where('name', 'TORMAC')->first();
$plantRegdAddress = Plant::where('company_id', $cName->id)->first();
$textValue = $plantRegdAddress->reg_address;
}
else if($textValue == 'CRI'){
$cName = Company::where('name', 'CRI')->first();
$plantRegdAddress = Plant::where('company_id', $cName->id)->where('id', $plantId)->first();
$textValue = $plantRegdAddress->address;
}
else if($textValue == 'GENVIK'){
$cName = Company::where('name', 'GENVIK')->first();
$plantRegdAddress = Plant::where('company_id', $cName->id)->first();
$textValue = $plantRegdAddress->reg_address;
}
else if($textValue == 'ZIRANTEC'){
$cName = Company::where('name', 'ZIRANTEC')->first();
$plantRegdAddress = Plant::where('company_id', $cName->id)->first();
$textValue = $plantRegdAddress->reg_address;
}
}
if ($row->characteristics_type == 'feed_address') {
$column = 'zmm_brand';
$textValue = $itemCharacteristic?->{$column} != null
? $itemCharacteristic->{$column}
: '';
if($textValue == 'TORMAC'){
$cName = Company::where('name', 'TORMAC')->first();
$plantRegdAddress = Plant::where('company_id', $cName->id)->first();
$textValue = $plantRegdAddress->feed_address;
}
else if($textValue == 'CRI'){
$cName = Company::where('name', 'CRI')->first();
$plantRegdAddress = Plant::where('company_id', $cName->id)->where('id', $plantId)->first();
$textValue = $plantRegdAddress->feed_address;
}
else if($textValue == 'GENVIK'){
$cName = Company::where('name', 'GENVIK')->first();
$plantRegdAddress = Plant::where('company_id', $cName->id)->first();
$textValue = $plantRegdAddress->feed_address;
}
else if($textValue == 'ZIRANTEC'){
$cName = Company::where('name', 'ZIRANTEC')->first();
$plantRegdAddress = Plant::where('company_id', $cName->id)->first();
$textValue = $plantRegdAddress->feed_address;
}
}
if ($row->characteristics_type == 'regd_unit') {
$column = 'zmm_brand';
$textValue = $itemCharacteristic?->{$column} != null
? $itemCharacteristic->{$column}
: '';
if($textValue == 'TORMAC'){
$cName = Company::where('name', 'TORMAC')->first();
$plantRegdUnit = Plant::where('company_id', $cName->id)->first();
$textValue = $plantRegdUnit->name;
}
else if($textValue == 'CRI'){
$cName = Company::where('name', 'CRI')->first();
$plantRegdUnit = Plant::where('company_id', $cName->id)->where('id', $plantId)->first();
$textValue = $plantRegdUnit->name;
}
else if($textValue == 'GENVIK'){
$cName = Company::where('name', 'GENVIK')->first();
$plantRegdUnit = Plant::where('company_id', $cName->id)->first();
$textValue = $plantRegdUnit->name;
}
else if($textValue == 'ZIRANTEC'){
$cName = Company::where('name', 'ZIRANTEC')->first();
$plantRegdUnit = Plant::where('company_id', $cName->id)->first();
$textValue = $plantRegdUnit->name;
}
}
if ($row->characteristics_type == 'company_name') {
$column = 'zmm_brand';
$textValue = $itemCharacteristic?->{$column} != null
? $itemCharacteristic->{$column}
: '';
if($textValue == 'TORMAC'){
$cName = Company::where('name', 'TORMAC')->first();
$textValue = $cName->name;
}
else if($textValue == 'CRI'){
$cName = Company::where('name', 'CRI')->first();
$textValue = $cName->name;
}
else if($textValue == 'GENVIK'){
$cName = Company::where('name', 'GENVIK')->first();
$textValue = $cName->name;
}
else if($textValue == 'ZIRANTEC'){
$cName = Company::where('name', 'ZIRANTEC')->first();
$textValue = $cName->name;
}
}
if ($row->characteristics_type == 'tollfree') {
$column = 'zmm_brand';
$textValue = $itemCharacteristic?->{$column} != null
? $itemCharacteristic->{$column}
: '';
if($textValue == 'TORMAC'){
$cName = Company::where('name', 'TORMAC')->first();
$plantRegdUnit = Plant::where('company_id', $cName->id)->first();
$textValue = $plantRegdUnit->tollfree;
}
else if($textValue == 'CRI'){
$cName = Company::where('name', 'CRI')->first();
$plantRegdUnit = Plant::where('company_id', $cName->id)->where('id', $plantId)->first();
$textValue = $plantRegdUnit->tollfree;
}
else if($textValue == 'GENVIK'){
$cName = Company::where('name', 'GENVIK')->first();
$plantRegdUnit = Plant::where('company_id', $cName->id)->first();
$textValue = $plantRegdUnit->tollfree;
}
else if($textValue == 'ZIRANTEC'){
$cName = Company::where('name', 'ZIRANTEC')->first();
$plantRegdUnit = Plant::where('company_id', $cName->id)->first();
$textValue = $plantRegdUnit->tollfree;
}
}
if (str_contains($row->string_value ?? '', '₹')) {
@@ -1170,30 +1325,15 @@ class StickerPdfService
if (!empty($row->string_font)) {
$fontFile = storage_path('app/private/fonts/' . $row->string_font . '.ttf');
Log::info($fontFile, [
'font' => $row->string_font,
]);
if (file_exists($fontFile)) {
\Log::info('TCPDF FONT DEBUG', [
'K_PATH_FONTS' => defined('K_PATH_FONTS') ? K_PATH_FONTS : 'NOT DEFINED',
'fontFile' => $fontFile,
'php_sapi' => PHP_SAPI,
]);
$font = TCPDF_FONTS::addTTFfont(
$fontFile,
'TrueTypeUnicode',
'',
32
);
Log::info('FONT CONVERSION RESULT', [
'result' => $font,
]);
} else {
Log::warning('FONT FILE NOT FOUND', [
'font_file' => $fontFile,
]);
$font = 'helvetica';
}
} else {
@@ -1211,6 +1351,7 @@ class StickerPdfService
'font' => $font,
'size' => (int) ($row->string_size ?? 10),
'color' => $row->element_colour ?? '#000000',
'string_align' => strtolower($row->string_align ?? ''),
];
}
elseif ($row->design_element_type == 'QR') {
@@ -1467,7 +1608,7 @@ class StickerPdfService
// }
public function generateBulkFromTemplate(array $template,$fromSerial,$toSerial,string $itemCode)
public function generateBulkFromTemplate(array $template,$fromSerial,$toSerial,string $itemCode, ?string $randomSerials = null)
{
$stickerWidth = (float) $template['width'];
$stickerHeight = (float) $template['height'];
@@ -1564,11 +1705,42 @@ class StickerPdfService
$rgb[2]
);
$pdf->Text(
$element['x'],
$element['y'] + $currentY,
(string) $textValue
);
// $pdf->Text(
// $element['x'],
// $element['y'] + $currentY,
// (string) $textValue
// );
$alignment = strtolower($element['string_align'] ?? '');
$pdf->SetFont($element['font'], '', $element['size']);
$x = (float) $element['x'];
$y = $element['y'] + $currentY;
// $textWidth = $pdf->GetStringWidth((string) $textValue);
if ($alignment == 'center') {
if($stickerId == 'Sewage PumpSet Test Certificate' || $stickerId == 'Submersible Mixer Test Certificate' || $stickerId == 'Pump Test Certificate' || $stickerId == 'Submersible Aerator Pump Test Certificate'){
$leftMargin = 10; // mm from left edge
$rightMargin = 24; // mm from right edge
$usableWidth = $stickerWidth - $leftMargin - $rightMargin;
$textWidth = $pdf->GetStringWidth((string) $textValue);
// start x = left margin + half of the leftover space
$x = $leftMargin + (($usableWidth - $textWidth) / 2);
// if text is wider than the usable area, don't go past the left margin
if ($textWidth > $usableWidth) {
$x = $leftMargin;
}
}
}
$pdf->Text($x, $y, (string) $textValue);
}
elseif ($element['type'] == 'qr') {
@@ -1871,6 +2043,445 @@ class StickerPdfService
}
}
//..Multiple Serial Numbers
public function generateMultipleBulkFromTemplate(array $template, array $serialNumbersArray,string $itemCode, ?string $randomSerials = null)
{
$stickerWidth = (float) $template['width'];
$stickerHeight = (float) $template['height'];
$stickerId = $template['sticker_id'] ?? null;
// $gap = 5.0;
// $count = ($toSerial - $fromSerial) + 1;
// $totalHeight =
// ($stickerHeight * $count)
// +
// ($gap * ($count - 1));
$orientation = $stickerWidth > $stickerHeight ? 'L' : 'P';
// $pdf = new TCPDF(
// 'P',
// 'mm',
// [
// $stickerWidth,
// $stickerHeight
// ],
// true,
// 'UTF-8',
// false
// );
$pdf = new TCPDF($orientation, 'mm', [$stickerWidth, $stickerHeight], true, 'UTF-8', false);
$pdf->setPrintHeader(false);
$pdf->setPrintFooter(false);
$pdf->SetMargins(
0,
0,
0,
0
);
$pdf->SetAutoPageBreak(false, 0);
// $pdf->AddPage();
$currentY = 0;
// Generate every serial
if ($stickerId != 'SelfPriming Monoblock Pump Dual') {
foreach ($serialNumbersArray as $serial) {
$serial = (string) $serial;
$pdf->AddPage();
$qrContent = $itemCode . '|' . $serial;
$serialString = (string) $serial;
$serialDate = '';
if (strlen($serialString) >= 4) {
$year = substr($serialString, 0, 2);
$month = substr($serialString, 2, 2);
if ((int) $month >= 1 && (int) $month <= 12) {
$serialDate = \Carbon\Carbon::createFromFormat(
'y-m',
$year . '-' . $month
)->format('M-y');
}
}
foreach ($template['elements'] as $element) {
if ($element['type'] == 'text') {
$textValue = $element['value'];
if ($textValue == '__SERIAL_NUMBER__') {
$textValue = (string) $serial;
}
if ($textValue == '__CURRENT_DATE__') {
$textValue = $serialDate;
}
$pdf->SetFont($element['font'],'',$element['size']);
$rgb = $this->hexToRgb($element['color']);
$pdf->SetTextColor(
$rgb[0],
$rgb[1],
$rgb[2]
);
// $pdf->Text(
// $element['x'],
// $element['y'] + $currentY,
// (string) $textValue
// );
$alignment = strtolower($element['string_align'] ?? '');
$pdf->SetFont($element['font'], '', $element['size']);
$x = (float) $element['x'];
$y = $element['y'] + $currentY;
// $textWidth = $pdf->GetStringWidth((string) $textValue);
if ($alignment == 'center') {
if($stickerId == 'Sewage PumpSet Test Certificate' || $stickerId == 'Submersible Mixer Test Certificate' || $stickerId == 'Pump Test Certificate' || $stickerId == 'Submersible Aerator Pump Test Certificate'){
$leftMargin = 10; // mm from left edge
$rightMargin = 24; // mm from right edge
$usableWidth = $stickerWidth - $leftMargin - $rightMargin;
$textWidth = $pdf->GetStringWidth((string) $textValue);
// start x = left margin + half of the leftover space
$x = $leftMargin + (($usableWidth - $textWidth) / 2);
// if text is wider than the usable area, don't go past the left margin
if ($textWidth > $usableWidth) {
$x = $leftMargin;
}
}
}
$pdf->Text($x, $y, (string) $textValue);
}
elseif ($element['type'] == 'qr') {
$qrValue = $element['value'];
if ($qrValue == '__DYNAMIC_QR__') {
$qrValue = $qrContent;
}
$pdf->write2DBarcode(
$qrValue,
'QRCODE,H',
$element['x'],
$element['y'] + $currentY,
$element['size'],
$element['size']
);
}
elseif ($element['type'] == 'image') {
if (!empty($element['path']) && file_exists($element['path']))
{
$pdf->Image(
$element['path'],
$element['x'],
$element['y'] + $currentY,
$element['width'],
$element['height']
);
}
}
elseif ($element['type'] == 'shape') {
$rgb = $this->hexToRgb(
$element['color']
);
$pdf->SetDrawColor(
$rgb[0],
$rgb[1],
$rgb[2]
);
$pdf->SetLineWidth(
$element['pen_size']
);
if ($element['name'] == 'Line') {
$pdf->Line(
$element['x1'],
$element['y1'] + $currentY,
$element['x2'],
$element['y2'] + $currentY
);
}
elseif ($element['name'] == 'Rectangle') {
$x = min($element['x1'],$element['x2']);
$y = min($element['y1'],$element['y2']);
$width = abs($element['x2'] - $element['x1']);
$height = abs($element['y2'] - $element['y1']);
$pdf->Rect(
$x,
$y + $currentY,
$width,
$height,
'D'
);
}
elseif ($element['name'] == 'CurvedRectangle')
{
$x = min($element['x1'],$element['x2']);
$y = min($element['y1'],$element['y2']);
$width = abs($element['x2'] - $element['x1']);
$height = abs($element['y2'] - $element['y1']);
$pdf->RoundedRect(
$x,
$y + $currentY,
$width,
$height,
$element['radius'],
'1111',
'D'
);
}
}
}
// $currentY += $stickerHeight + $gap;
}
return $pdf->Output('', 'S');
}
// if($stickerId == 'SelfPriming Monoblock Pump Dual'){
// foreach ($serialNumbersArray as $serial) {
// $serial = (string) $serial;
// $pdf->AddPage();
// $serialString = (string) $serial;
// $serialDate = '';
// $firstSerial = $serial;
// $secondSerial = $serial + 1;
// $serialString = (string) $firstSerial;
// $serialDate = '';
// if (strlen($serialString) >= 4) {
// $year = substr($serialString, 0, 2);
// $month = substr($serialString, 2, 2);
// if ((int) $month >= 1 && (int) $month <= 12) {
// $serialDate = \Carbon\Carbon::createFromFormat(
// 'y-m',
// $year . '-' . $month
// )->format('M-y');
// }
// }
// foreach ($template['elements'] as $element) {
// if ($element['type'] == 'text') {
// $textValue = $element['value'];
// if ($textValue == '__SERIAL_NUMBER__') {
// $textValue = (string) $firstSerial;
// }
// if ($textValue == 'TO__SERIAL_NUMBER__') {
// if ($secondSerial <= $toSerial) {
// $textValue = (string) $secondSerial;
// } else {
// $textValue = '';
// }
// }
// if ($textValue == '__CURRENT_DATE__') {
// $textValue = $serialDate;
// }
// $pdf->SetFont(
// $element['font'],
// '',
// $element['size']
// );
// $rgb = $this->hexToRgb($element['color']);
// $pdf->SetTextColor(
// $rgb[0],
// $rgb[1],
// $rgb[2]
// );
// $pdf->Text(
// $element['x'],
// $element['y'] + $currentY,
// (string) $textValue
// );
// }
// elseif ($element['type'] == 'qr') {
// $qrValue = $element['value'];
// if ($qrValue == '__DYNAMIC_QR__') {
// $qrValue = $itemCode . '|' . $firstSerial;
// }
// elseif ($qrValue == '__DYNAMIC_QR2__') {
// if ($secondSerial <= $toSerial) {
// $qrValue = $itemCode . '|' . $secondSerial;
// } else {
// $qrValue = '';
// }
// }
// if ($qrValue != '') {
// $pdf->write2DBarcode(
// $qrValue,
// 'QRCODE,H',
// $element['x'],
// $element['y'] + $currentY,
// $element['size'],
// $element['size']
// );
// }
// }
// elseif ($element['type'] == 'image') {
// if (
// !empty($element['path']) &&
// file_exists($element['path'])
// ) {
// $pdf->Image(
// $element['path'],
// $element['x'],
// $element['y'] + $currentY,
// $element['width'],
// $element['height']
// );
// }
// }
// elseif ($element['type'] == 'shape') {
// $rgb = $this->hexToRgb($element['color']);
// $pdf->SetDrawColor(
// $rgb[0],
// $rgb[1],
// $rgb[2]
// );
// $pdf->SetLineWidth(
// $element['pen_size']
// );
// if ($element['name'] == 'Line') {
// $pdf->Line(
// $element['x1'],
// $element['y1'] + $currentY,
// $element['x2'],
// $element['y2'] + $currentY
// );
// }
// elseif ($element['name'] == 'Rectangle') {
// $x = min(
// $element['x1'],
// $element['x2']
// );
// $y = min(
// $element['y1'],
// $element['y2']
// );
// $width = abs(
// $element['x2'] - $element['x1']
// );
// $height = abs(
// $element['y2'] - $element['y1']
// );
// $pdf->Rect(
// $x,
// $y + $currentY,
// $width,
// $height,
// 'D'
// );
// }
// elseif ($element['name'] == 'CurvedRectangle') {
// $x = min(
// $element['x1'],
// $element['x2']
// );
// $y = min(
// $element['y1'],
// $element['y2']
// );
// $width = abs(
// $element['x2'] - $element['x1']
// );
// $height = abs(
// $element['y2'] - $element['y1']
// );
// $pdf->RoundedRect(
// $x,
// $y + $currentY,
// $width,
// $height,
// $element['radius'],
// '1111',
// 'D'
// );
// }
// }
// }
// }
// return $pdf->Output('', 'S');
// }
}
public function generatePdfBySerial($item, $serNo, $plantId, $refNumber)
{
$recFound = ProductionQuantity::where('plant_id', $plantId)

View File

@@ -0,0 +1,31 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
$sql1 = <<<'SQL'
ALTER TABLE plants
ADD COLUMN feed_address TEXT DEFAULT NULL
SQL;
DB::statement($sql1);
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('plants', function (Blueprint $table) {
//
});
}
};

View File

@@ -0,0 +1,31 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
$sql1 = <<<'SQL'
ALTER TABLE plants
ADD COLUMN tollfree TEXT DEFAULT NULL
SQL;
DB::statement($sql1);
}
/**
* Reverse the migrations.
*/
public function down(): void
{
// Schema::table('plants', function (Blueprint $table) {
// //
// });
}
};

View File

@@ -18,7 +18,25 @@
>
Generate Sticker
</button>
</div>
</div>
{{-- <label class="flex items-center gap-2 mt-4">
<input
type="checkbox"
wire:model="showMultipleSerials"
class="rounded border-gray-300 text-primary-600 focus:ring-primary-500"
>
<span class="text-sm font-medium">Show Multiple Serial Numbers</span>
</label> --}}
{{-- <div class="bg-white shadow rounded-xl p-4 mt-6">
<livewire:random-serial-number-list />
</div> --}}
<div class="bg-white shadow rounded-xl p-4 mt-6">
<livewire:random-serial-number-list
:plant-id="$filters['plant_id'] ?? null"
:machine-id="$filters['machine_id'] ?? null"
/>
</div>
{{-- <script>
document.addEventListener('livewire:init', () => {

View File

@@ -0,0 +1,76 @@
<div class="w-fit rounded-xl bg-white p-4 shadow-sm ring-1 ring-gray-950/5">
<label class="flex items-center gap-2 mt-4">
<input
type="checkbox"
wire:model.live="showMultipleSerials"
class="rounded border-gray-300 text-primary-600"
>
<span class="text-sm font-medium">
Show Multiple Serial Numbers
</span>
</label>
<button
type="button"
wire:click="generate"
class="mt-2 rounded bg-primary-600 px-4 py-1 text-white"
>
Generate
</button>
<button
type="button"
wire:click="clear"
class="mt-2 rounded bg-primary-600 px-4 py-1 text-white"
>
Clear
</button>
@if ($showMultipleSerials)
<div class="mt-4 overflow-x-auto">
<div class="flex justify-end mb-2">
<span class="text-sm font-medium">
Total Count:
<span class="text-primary-600 font-bold">
{{ count(array_filter($serialNumbers, fn ($serial) => trim($serial) !== '')) }}
</span>
</span>
</div>
<table class="w-1/2 border-collapse border border-gray-300 text-sm">
<thead>
<tr class="bg-gray-100">
<th class="border px-3 py-2">S.No</th>
<th class="border px-3 py-2">Serial Number</th>
</tr>
</thead>
<tbody>
@foreach ($serialNumbers as $index => $serial)
<tr wire:key="serial-row-{{ $index }}">
<td class="border px-3 py-2 text-center">
{{ $index + 1 }}
</td>
<td class="border px-3 py-2">
<input
type="text"
{{-- wire:model="serialNumbers.{{ $index }}" --}}
wire:model.live="serialNumbers.{{ $index }}"
@if ($index === 0)
x-data
@paste.prevent="
const text = $event.clipboardData.getData('text');
$wire.splitSerialNumbers(text);
"
@endif
class="w-full rounded border-gray-300"
placeholder="Paste serial numbers here"
>
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
@endif
</div>