fix conflict issue in sticker pdf service
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 12s
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Successful in 13s
Gemini PR Review / Gemini PR Review (pull_request) Successful in 20s
Laravel Pint / pint (pull_request) Failing after 2m32s
Laravel Larastan / larastan (pull_request) Failing after 5m36s

This commit is contained in:
dhanabalan
2026-09-20 10:50:49 +05:30
parent 6b3c693b5e
commit dc95259fc5
42 changed files with 3844 additions and 1966 deletions

View File

@@ -24,32 +24,41 @@ class ProcessOrderExporter extends Exporter
}),
ExportColumn::make('plant.code')
->label('PLANT CODE'),
ExportColumn::make('line.name')
->label('LINE NAME'),
ExportColumn::make('item.code')
->label('ITEM CODE'),
ExportColumn::make('item.description')
->label('ITEM DESCRIPTION'),
ExportColumn::make('process_order')
->label('PROCESS ORDER'),
ExportColumn::make('coil_number')
->label('COIL NUMBER'),
ExportColumn::make('order_quantity')
->label('ORDER QUANTITY'),
ExportColumn::make('updated_order_quantity')
->label('UPDATED ORDER QUANTITY'),
ExportColumn::make('received_quantity')
->label('RECEIVED QUANTITY'),
ExportColumn::make('sfg_number')
->label('SFG NUMBER'),
ExportColumn::make('machine_name')
->label('MACHINE ID'),
->label('MACHINE NAME'),
ExportColumn::make('scrap_quantity')
->label('SCRAP QUANTITY'),
ExportColumn::make('rework_status')
->label('REWORK STATUS'),
ExportColumn::make('created_at')
->label('CREATED AT'),
ExportColumn::make('updated_at')
->label('UPDATED AT'),
ExportColumn::make('created_by')
->label('CREATED BY'),
ExportColumn::make('updated_at')
->label('UPDATED AT'),
ExportColumn::make('updated_by')
->label('UPDATED BY'),
ExportColumn::make('deleted_at')
->enabledByDefault(false)
->label('DELETED AT'),
];
}

View File

@@ -3,13 +3,16 @@
namespace App\Filament\Imports;
use App\Models\Item;
use App\Models\Line;
use App\Models\Plant;
use App\Models\ProcessOrder;
use App\Models\ProductCharacteristicsMaster;
use App\Models\User;
use Filament\Actions\Imports\Exceptions\RowImportFailedException;
use Filament\Actions\Imports\ImportColumn;
use Filament\Actions\Imports\Importer;
use Filament\Actions\Imports\Models\Import;
use Filament\Facades\Filament;
use Str;
class ProcessOrderImporter extends Importer
@@ -22,10 +25,15 @@ class ProcessOrderImporter extends Importer
ImportColumn::make('plant')
->requiredMapping()
->exampleHeader('PLANT CODE')
->example('1000')
->example('1200')
->label('PLANT CODE')
->relationship(resolveUsing: 'code')
->rules(['required']),
ImportColumn::make('line')
->exampleHeader('LINE NAME')
->example('Poly Wrapped Wire SFG')
->label('LINE NAME')
->relationship(resolveUsing: 'name'),
ImportColumn::make('item')
->requiredMapping()
->exampleHeader('ITEM CODE')
@@ -34,68 +42,393 @@ class ProcessOrderImporter extends Importer
->relationship(resolveUsing: 'code')
->rules(['required']),
ImportColumn::make('process_order')
->requiredMapping()
->exampleHeader('PROCESS ORDER')
->example('202500123456')
->example('202601123456')
->label('PROCESS ORDER')
->rules(['required']),
ImportColumn::make('order_quantity')
->requiredMapping()
->exampleHeader('ORDER QUANTITY')
->example('1000')
->label('ORDER QUANTITY')
->rules(['required']),
ImportColumn::make('updated_order_quantity')
->exampleHeader('UPDATED ORDER QUANTITY')
->label('UPDATED ORDER QUANTITY'),
ImportColumn::make('coil_number')
->exampleHeader('COIL NUMBER')
// ->example('01')
->label('COIL NUMBER'),
ImportColumn::make('received_quantity')
->exampleHeader('RECEIVED QUANTITY')
// ->example('01')
->label('RECEIVED QUANTITY'),
ImportColumn::make('sfg_number')
->exampleHeader('SFG NUMBER')
// ->example('200000220613-72')
->label('SFG NUMBER'),
ImportColumn::make('machine_name')
->exampleHeader('MACHINE NAME')
// ->example('WMIWRM13 - 2-L2')
->label('MACHINE NAME'),
ImportColumn::make('scrap_quantity')
->exampleHeader('SCRAP QUANTITY')
// ->example('0')
->label('SCRAP QUANTITY'),
ImportColumn::make('rework_status')
->exampleHeader('REWORK STATUS')
// ->example('0')
->label('REWORK STATUS'),
ImportColumn::make('created_at')
->exampleHeader('CREATED AT')
// ->example('2026-02-20 13:00:00')
->label('CREATED AT'),
ImportColumn::make('updated_at')
->exampleHeader('UPDATED AT')
// ->example('2026-02-20 13:00:00')
->label('UPDATED AT'),
ImportColumn::make('created_by')
->exampleHeader('CREATED BY')
->example('RAW01234')
->label('CREATED BY')
->rules(['required']),
// ->example('RAW01234')
->label('CREATED BY'),
ImportColumn::make('updated_by')
->exampleHeader('UPDATED BY')
// ->example('RAW01234')
->label('UPDATED BY'),
];
}
public function resolveRecord(): ?ProcessOrder
{
$warnMsg = [];
$plant = Plant::where('code', $this->data['plant'])->first();
$itemCode = Item::where('code', $this->data['item'])->first();
$iCode = trim($this->data['item']);
if (! $plant) {
$warnMsg[] = 'Plant not found';
} elseif (Str::length($iCode) < 6 || ! ctype_alnum($iCode)) {
$warnMsg[] = 'Invalid item code found';
} elseif (! $itemCode) {
$warnMsg[] = 'Item Code not found';
}
$plant = null;
$plantCod = trim($this->data['plant']) ?? '';
$plantId = null;
$iCode = trim($this->data['item']) ?? '';
$itemId = null;
$lineNam = trim($this->data['line']) ?? '';
$lineId = null;
$processOrder = trim($this->data['process_order'] ?? '');
$coilNo = trim($this->data['coil_number'] ?? '');
$sfgNo = trim($this->data['sfg_number'] ?? '');
$machineName = trim($this->data['machine_name'] ?? '');
$orderQuan = trim($this->data['order_quantity'] ?? '');
$updatedOrderQuan = trim($this->data['updated_order_quantity'] ?? '');
$scrapQuan = trim($this->data['scrap_quantity'] ?? '');
$reworkStatus = trim($this->data['rework_status'] ?? '');
$recQuan = trim($this->data['received_quantity'] ?? '');
$createdAt = trim($this->data['created_at'] ?? '');
$createdBy = trim($this->data['created_by'] ?? '');
$updatedAt = trim($this->data['updated_at'] ?? '');
$updatedBy = trim($this->data['updated_by'] ?? '');
// $user = Filament::auth()->user();
// $operatorName = $user->name;
if ($processOrder == '') {
$warnMsg[] = 'Process Order cannot be empty';
if ($plantCod == null || $plantCod == '') {
$warnMsg[] = "Plant code can't be empty!";
} elseif (Str::length($plantCod) < 4 || ! is_numeric($plantCod) || ! preg_match('/^[1-9]\d{3,6}$/', $plantCod)) {
$warnMsg[] = 'Invalid plant code found';
}
if ($iCode == null || $iCode == '') {
$warnMsg[] = "Item code can't be empty!";
} elseif (Str::length($iCode) < 6 || ! ctype_alnum($iCode)) {
$warnMsg[] = 'Invalid item code found!';
}
if ($machineName != null && $machineName != '' && Str::length($machineName) > 18) {
$warnMsg[] = 'Invalid machine name found!';
}
if ($processOrder == null || $processOrder == '') {
$warnMsg[] = "Process order can't be empty!";
} elseif ($processOrder && (Str::contains($processOrder, '.') || Str::contains($processOrder, 'E', ignoreCase: true))) {
$warnMsg[] = 'Invalid process order found!';
}
if ($lineNam == null || $lineNam == '') {
$warnMsg[] = "Line name can't be empty!";
}
if ($orderQuan == null || $orderQuan == '') {
$warnMsg[] = "Order quantity can't be empty!";
} elseif ($orderQuan == 0 || $orderQuan == '0') {
$warnMsg[] = "Order quantity can't be zero!";
} elseif (Str::length($orderQuan) >= 1 && ! is_numeric($orderQuan)) {
$warnMsg[] = 'Invalid order quantity found!';
}
if ($updatedOrderQuan == null || $updatedOrderQuan == '' || $updatedOrderQuan == 0 || $updatedOrderQuan == '0') {
$updatedOrderQuan = $orderQuan;
} elseif (Str::length($updatedOrderQuan) >= 1 && ! is_numeric($updatedOrderQuan)) {
$warnMsg[] = 'Invalid Updated order quantity found!';
}
$user = User::where('name', $this->data['created_by'])->first();
if (! $user) {
$warnMsg[] = 'User not found';
if ($coilNo == null || $coilNo == '') {
$coilNo = '0';
}
if ($plant && $processOrder != '') {
$existingOrder = ProcessOrder::where('plant_id', $plant->id)
->where('process_order', $processOrder)
->first();
if ($existingOrder && $existingOrder->item_id !== ($itemCode->id ?? null)) {
$warnMsg[] = 'Same Process Order already exists for this Plant with a different Item Code';
}
if ($scrapQuan == null || $scrapQuan == '') {
$scrapQuan = 0;
}
if ($recQuan == null || $recQuan == '') {
$recQuan = 0;
}
if ($reworkStatus == null || $reworkStatus = '' || $reworkStatus == 0 || $reworkStatus = '0') {
$reworkStatus = 0;
} elseif ($reworkStatus == 1 || $reworkStatus = '1') {
$reworkStatus = 1;
} else {
$warnMsg[] = 'Invalid rework status found!';
}
if (! empty($warnMsg)) {
throw new RowImportFailedException(implode(', ', $warnMsg));
}
return ProcessOrder::create([
'plant_id' => $plant->id,
'item_id' => $itemCode->id,
'process_order' => trim($this->data['process_order']),
'coil_number' => '0',
'order_quantity' => 0,
'received_quantity' => 0,
'created_by' => $user->name,
]);
$plant = Plant::where('code', $plantCod)->first();
if (! $plant) {
$warnMsg[] = 'Plant not found!';
} else {
$plantId = $plant->id;
}
// TESTING PURPOSE ONLY - TO CHECK DUPLICATE PROCESS ORDER WITH SAME COIL NUMBER FOR THE SAME PLANT
// $existing = ProcessOrder::where('plant_id', $plantId)->where('process_order', $processOrder)->first();
// if ($existing) {
// $existing = ProcessOrder::where('plant_id', $plantId)->where('process_order', $processOrder)->where('coil_number', $coilNo)->first();
// if ($existing) {
// $warnMsg[] = 'Process Order with coil number already exists!';
// } else {
// $warnMsg[] = 'Process order already exists!';
// }
// } else {
// $warnMsg[] = 'New process order found!';
// }
// if (! empty($warnMsg)) {
// throw new RowImportFailedException(implode(', ', $warnMsg));
// }
$itemCode = Item::where('code', $iCode)->first();
if (! $itemCode) {
$warnMsg[] = 'Item code not found!';
} else {
if ($plantId) {
$itemCode = Item::where('code', $iCode)->where('plant_id', $plantId)->first();
if (! $itemCode) {
$warnMsg[] = 'Item code not found for the given plant!';
} else {
$itemId = $itemCode->id;
}
}
}
$lineExists = Line::where('name', $lineNam)->first();
if (! $lineExists) {
$warnMsg[] = 'Line name not found!';
} else {
if ($plantId) {
$lineAgainstPlant = Line::where('name', $lineNam)->where('plant_id', $plantId)->first();
if (! $lineAgainstPlant) {
$warnMsg[] = 'Line name not found for the given plant!';
} else {
$lineId = $lineAgainstPlant->id;
}
}
}
if ($plantId && $itemId && $lineId && $processOrder != '') {
$existingOrder = ProcessOrder::where('plant_id', $plantId)
->where('process_order', $processOrder)
->first();
if ($existingOrder && $existingOrder->item_id !== ($itemId ?? null)) {
$warnMsg[] = 'Same Process Order already exists for this Plant with a different Item Code!';
}
// $masterExist = ProductCharacteristicsMaster::where('plant_id', $plantId)->where('item_id', $itemId)->first();
// if (! $masterExist) {
// $warnMsg[] = 'Characteristics master not found for the given plant!';
// } else {
// $masterExist = ProductCharacteristicsMaster::where('plant_id', $plantId)->where('line_id', $lineId)->where('item_id', $itemId)->first();
// if (! $masterExist) {
// $warnMsg[] = 'Characteristics master not found for the given line!';
// }
// }
}
// $user = User::where('name', $this->data['created_by'])->first();
// if (! $user) {
// $warnMsg[] = 'User not found!';
// }
if (! $createdBy) {
$createdBy = Filament::auth()->user()->name;
$updatedBy = Filament::auth()->user()->name;
} elseif (! $updatedBy) {
$updatedBy = Filament::auth()->user()->name;
}
if (! empty($warnMsg)) {
throw new RowImportFailedException(implode(', ', $warnMsg));
}
$existing = ProcessOrder::where('plant_id', $plantId)
->where('process_order', $processOrder)
// ->where('coil_number', $coilNo)
->first();
$receivedQty = ProcessOrder::where('plant_id', $plantId)
->where('process_order', $processOrder)
->sum('received_quantity');
if ($existing) {
$liveOrdQuan = (float) $existing->order_quantity;
$liveUpdatedOrdQuan = (float) $existing->updated_order_quantity;
$allowedIncrease = $liveOrdQuan * 0.10;
$maxAllowedQty = $liveOrdQuan + $allowedIncrease;
$minAllowedQty = $liveOrdQuan - $allowedIncrease;
if ($liveUpdatedOrdQuan > $maxAllowedQty) {
throw new RowImportFailedException(
"Updated order quantity cannot exceed 10% of existing order quantity. Max allowed: {$maxAllowedQty}!"
);
} elseif ($liveUpdatedOrdQuan < $minAllowedQty) {
throw new RowImportFailedException(
"Updated order quantity cannot decrease -10% of existing order quantity. Min allowed: {$minAllowedQty}!"
);
} elseif ($liveUpdatedOrdQuan < $receivedQty) {
throw new RowImportFailedException(
"Updated order quantity cannot decrease below its received quantity {$receivedQty}!"
);
}
}
if ($coilNo != null && $coilNo != '' && $scrapQuan && $reworkStatus && $recQuan && $createdAt && $createdBy && $updatedAt && $updatedBy && Filament::auth()->user()->hasRole('Super Admin')) {
$existingCoil = ProcessOrder::where('plant_id', $plantId)
->where('process_order', $processOrder)
->where('line_id', $lineId)
->where('coil_number', $coilNo)
->first();
// $existingProcess = ProcessOrder::where('plant_id', $plantId)
// ->where('process_order', $processOrder)
// ->where('line_id', $lineId)
// ->first();
if ($existing) {
$existUpdateOrdQuan = $existing->updated_order_quantity;
} else {
$existUpdateOrdQuan = $updatedOrderQuan;
}
if (! $existingCoil) {
ProcessOrder::Create(
[
'plant_id' => $plantId,
'line_id' => $lineId,
'process_order' => $processOrder,
'item_id' => $itemId,
'coil_number' => $coilNo,
'order_quantity' => $orderQuan,
'updated_order_quantity' => $existUpdateOrdQuan,
'received_quantity' => $recQuan,
'scrap_quantity' => $scrapQuan,
'sfg_number' => $sfgNo,
'machine_name' => $machineName,
'rework_status' => $reworkStatus,
'created_at' => $createdAt,
'updated_at' => $updatedAt,
'created_by' => $createdBy,
'updated_by' => $updatedBy,
]
);
} else {
ProcessOrder::where('plant_id', $plantId)
->where('process_order', $processOrder)
->where('line_id', $lineId)
->where('coil_number', $coilNo)
->update([
// 'order_quantity' => $orderQty,
'received_quantity' => $recQuan,
'scrap_quantity' => $scrapQuan,
// 'sfg_number' => $sfgNo,
// 'machine_name' => $machineId,
'rework_status' => $reworkStatus,
'updated_by' => $updatedBy,
'updated_at' => $updatedAt,
]);
}
} else {
$coilNo = '0';
// $existing = ProcessOrder::where('plant_id', $plantId)
// ->where('process_order', $processOrder)
// // ->where('coil_number', $coilNo)
// ->first();
if ($existing) {
$existUpdateOrdQuan = $existing->updated_order_quantity;
} else {
$existUpdateOrdQuan = $updatedOrderQuan;
}
if (! $existing && ($coilNo == '0' || $coilNo == 0)) {
ProcessOrder::create([
'plant_id' => $plantId,
'line_id' => $lineId,
'item_id' => $itemId,
'process_order' => $processOrder,
'coil_number' => '0',
'order_quantity' => $orderQuan,
'updated_order_quantity' => $existUpdateOrdQuan,
'received_quantity' => 0,
'scrap_quantity' => 0,
'created_by' => $createdBy,
'updated_by' => $updatedBy,
]);
} elseif (! $existing) {
ProcessOrder::Create(
[
'plant_id' => $plantId,
'line_id' => $lineId,
'item_id' => $itemId,
'process_order' => $processOrder,
'coil_number' => $coilNo,
'order_quantity' => $orderQuan,
'updated_order_quantity' => $existUpdateOrdQuan,
'received_quantity' => $recQuan,
'scrap_quantity' => $scrapQuan ?? 0,
'sfg_number' => $sfgNo,
'machine_name' => $machineName,
'rework_status' => $reworkStatus,
// 'created_at' => $createdAt,
// 'updated_at' => $updatedAt,
'created_by' => $createdBy,
'updated_by' => $updatedBy,
]
);
} else {// $coilNo = '0'
if ($existing->process_order == $processOrder) {
throw new RowImportFailedException('Process order already exist for the given plant!');
} elseif ($existing->rework_status == 1 && $reworkStatus == 0) {
throw new RowImportFailedException('Rework coil number already exist for the given Plant and Process Order!');
} else {
ProcessOrder::where('plant_id', $plantId)
->where('process_order', $processOrder)
->where('coil_number', $coilNo)
->update([
// 'order_quantity' => $orderQty,
'received_quantity' => $recQuan,
'scrap_quantity' => $scrapQuan,
// 'sfg_number' => $sfgNo,
// 'machine_name' => $machineId,
'rework_status' => $reworkStatus,
'updated_by' => $updatedBy,
// 'updated_at' => $updatedAt,
]);
}
}
}
return null;
// return new ProcessOrder();
}

File diff suppressed because it is too large Load Diff

View File

@@ -19,6 +19,7 @@ use Filament\Forms\Components\ViewField;
use Filament\Notifications\Notification;
use Filament\Forms\Components\Actions\Action;
use Filament\Forms\Components\Hidden;
use Illuminate\Support\Facades\Auth;
class ProductionCalender extends Page
{
@@ -160,4 +161,9 @@ class ProductionCalender extends Page
}
}
public static function canAccess(): bool
{
return Auth::check() && Auth::user()->can('view production calender page');
}
}

View File

@@ -403,6 +403,9 @@ class ProductionQuantityPage extends Page implements HasForms
public function processMachine($value)
{
$plantId = $this->pId;
$plantCode = Plant::find($plantId);
$PlaCo = $plantCode->code;
$this->mNam = $value;
$now = Carbon::now()->format('H:i:s');
@@ -412,6 +415,72 @@ class ProductionQuantityPage extends Page implements HasForms
$machine = Machine::where('plant_id', $plantId)->where('work_center', $this->mNam)->with('line.block')->first();
$machinenotAgaPlant = Machine::where('work_center', $this->mNam)->first();
$machineAgaPlant = Machine::where('plant_id', $plantId)->where('work_center', $this->mNam)->first();
if (!$machinenotAgaPlant) {
Notification::make()
->title('Unknown WorkCenter')
->body("Work Center not found")
->danger()
->send();
$this->form->fill([
'plant_id' => $this->pId,
'machine_id' => $this->mNam,
'block_name' => $this->bNam,
'shift_id' => $this->sNam,
'line_id' => $this->lNam,
'item_id' => null,
'serial_number' => null,
'success_msg' => null,
'production_order' => $this->prodOrder,
'sap_msg_status' => null,
'sap_msg_description' => null,
// 'operator_id'=> $operatorName,
'recent_qr' => $this->recQr,
]);
return;
}
else if (!$machineAgaPlant) {
Notification::make()
->title('Unknown WorkCenter')
->body("Work Center not found against plant code $PlaCo")
->danger()
->send();
$this->form->fill([
'plant_id' => $this->pId,
'machine_id' => $this->mNam,
'block_name' => $this->bNam,
'shift_id' => $this->sNam,
'line_id' => $this->lNam,
'item_id' => null,
'serial_number' => null,
'success_msg' => null,
'production_order' => $this->prodOrder,
'sap_msg_status' => null,
'sap_msg_description' => null,
// 'operator_id'=> $operatorName,
'recent_qr' => $this->recQr,
]);
return;
}
$rec = ProductionQuantity::where('plant_id', $plantId)->where('machine_id', $machineAgaPlant->id)->latest()->first();
if($rec)
{
$item = Item::where('id', $rec->item_id)->where('plant_id', $plantId)->first();
$itemCode = $item?->code ?? '';
$serialNo = $rec->serial_number ?? '';
$this->recQr = $itemCode . ' | ' . $serialNo;
}
if ($machine) {
$this->lNam = Line::where('id', $machine->line_id)->value('name');
$this->bNam = $machine->line->block->name ?? null;
@@ -436,15 +505,6 @@ class ProductionQuantityPage extends Page implements HasForms
'recent_qr' => $this->recQr,
]);
$this->triggerChartUpdate();
} else {
Notification::make()
->title('Unknown WorkCenter')
->body('Work Center not found')
->danger()
->send();
return;
}
}
@@ -1065,46 +1125,6 @@ class ProductionQuantityPage extends Page implements HasForms
$iCode = trim($splits[0]);
$sNumber = isset($splits[1]) ? trim($splits[1]) : null;
// $machine = Machine::where('work_center', $this->mNam)->where('plant_id', $this->pId)->first();
// $this->mId = $machine->id;
// $lineId = $machine->line_id;
// $this->lId = $lineId;
// $line = Line::find($lineId);
// if (! $line) {
// Notification::make()
// ->title('Invalid Line')
// ->body('Line associated with the machine not found.')
// ->danger()
// ->send();
// return;
// }
// $blockId = $line->block_id;
// $this->bId = $blockId;
// $shift = Shift::where('block_id', $blockId)->first();
// if (! $shift) {
// Notification::make()
// ->title('No Shift Found')
// ->body('No shift associated with this block.')
// ->danger()
// ->send();
// return;
// }
// $shiftId = $shift->id;
// $this->sId = $shiftId;
// $line = Line::with('block')->find($lineId);
// $lineName = $line?->name;
// $blockName = $line?->block?->name;
// $shiftName = $shift?->name;
if (! ctype_alnum($iCode)) {
@@ -1121,7 +1141,7 @@ class ProductionQuantityPage extends Page implements HasForms
'sap_msg_status' => null,
'sap_msg_description' => null,
'operator_id' => $operatorName,
'recent_qr' => $this->recent_qr,
'recent_qr' => $this->recQr,
]);
Notification::make()
@@ -1145,7 +1165,7 @@ class ProductionQuantityPage extends Page implements HasForms
'sap_msg_status' => null,
'sap_msg_description' => null,
'operator_id' => $operatorName,
'recent_qr' => $this->recent_qr,
'recent_qr' => $this->recQr,
]);
Notification::make()
@@ -1169,7 +1189,7 @@ class ProductionQuantityPage extends Page implements HasForms
'sap_msg_status' => null,
'sap_msg_description' => null,
'operator_id' => $operatorName,
'recent_qr' => $this->recent_qr,
'recent_qr' => $this->recQr,
]);
Notification::make()
@@ -1194,7 +1214,7 @@ class ProductionQuantityPage extends Page implements HasForms
'sap_msg_status' => null,
'sap_msg_description' => null,
'operator_id' => $operatorName,
'recent_qr' => $this->recent_qr,
'recent_qr' => $this->recQr,
]);
Notification::make()
@@ -1221,7 +1241,7 @@ class ProductionQuantityPage extends Page implements HasForms
'sap_msg_status' => null,
'sap_msg_description' => null,
'operator_id' => $operatorName,
'recent_qr' => $this->recent_qr,
'recent_qr' => $this->recQr,
]);
Notification::make()
@@ -1376,13 +1396,10 @@ class ProductionQuantityPage extends Page implements HasForms
->title('Invalid QR Found') // {$operatorName}
->body('Please, scan the valid QR code.')
->danger()
// ->persistent()
->send();
return;
} else {
// // Perform any additional processing or database operations
// $this->saveFormData($formValues);
$parts = explode('|', $this->qrData);
$itemCode = trim($parts[0]);
@@ -1467,7 +1484,7 @@ class ProductionQuantityPage extends Page implements HasForms
'sap_msg_status' => null,
'sap_msg_description' => null,
'operator_id' => $operatorName,
'recent_qr' => $this->recent_qr,
'recent_qr' => $this->recQr,
]);
return;
@@ -1489,7 +1506,6 @@ class ProductionQuantityPage extends Page implements HasForms
// $this->recent_qr = $itemCode.' | '.$this->sNoId;
// after success insertion
$this->form->fill([
'plant_id' => $this->pId,
'machine_id' => $this->mNam,
'block_name' => $this->bNam,
@@ -1502,7 +1518,7 @@ class ProductionQuantityPage extends Page implements HasForms
'sap_msg_status' => null,
'sap_msg_description' => null,
'operator_id' => $operatorName,
'recent_qr' => $this->recent_qr,
'recent_qr' => $itemCode.' | '.$this->sNoId,
]);
Notification::make()

File diff suppressed because it is too large Load Diff

View File

@@ -11,6 +11,7 @@ use Filament\Forms\Components\Section;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\TextInput;
use Filament\Notifications\Notification;
use Illuminate\Support\Facades\Auth;
class ProductionTarget extends Page
{
@@ -30,13 +31,16 @@ class ProductionTarget extends Page
->schema([
Select::make('plant_id')
->label('Plant')
->relationship('plant', 'name')
->reactive()
// ->searchable()
->options(function (callable $get) {
$userHas = Filament::auth()->user()->plant_id;
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
})
->required()
->afterStateUpdated(function ($state, callable $get, $set) {
// dd($state);
$set('line_id', null);
$set('year', null);
$set('month', null);
@@ -45,6 +49,8 @@ class ProductionTarget extends Page
Select::make('line_id')
->label('Line')
->required()
->relationship('line', 'name')
// ->searchable()
->columnSpan(1)
->options(function (callable $get) {
if (!$get('plant_id')) {
@@ -58,6 +64,8 @@ class ProductionTarget extends Page
->reactive()
->afterStateUpdated(function ($state, callable $get, $set) {
$plantId = $get('plant_id');
$set('year', null);
$set('month', null);
$this->dispatch('loadData',$plantId, $state, '', '');
@@ -65,7 +73,9 @@ class ProductionTarget extends Page
Select::make('year')
->label('Year')
->reactive()
// ->searchable()
->options([
'2025' => '2025',
'2026' => '2026',
'2027' => '2027',
'2028' => '2028',
@@ -93,6 +103,7 @@ class ProductionTarget extends Page
Select::make('month')
->label('Month')
->reactive()
// ->searchable()
->options([
'01' => 'January',
'02' => 'February',
@@ -170,4 +181,9 @@ class ProductionTarget extends Page
$this->dispatch('loadData1' ,$plantId, $lineId, $year, $month);
}
public static function canAccess(): bool
{
return Auth::check() && Auth::user()->can('view production target page');
}
}

View File

@@ -61,14 +61,55 @@ class RfqDashboard extends Page
// session()->forget('rfq_number');
// }),
// Select::make('rfq_number')
// ->label('Select RFQ Number')
// ->reactive()
// ->options(function (callable $get) {
// return RequestQuotation::orderBy('rfq_number')
// ->pluck('rfq_number', 'id')
// ->toArray();
// })
// ->afterStateUpdated(function ($state, callable $set) {
// session(['rfq_id' => $state]);
// $set('transport_name', null);
// session()->forget('transport_name');
// }),
Select::make('rfq_number')
->label('Select RFQ Number')
->reactive()
->options(function (callable $get) {
->options(function () {
return RequestQuotation::orderBy('rfq_number')
->pluck('rfq_number', 'id')
->toArray();
$user = Filament::auth()->user();
if ($user?->hasAnyRole(['Super Admin', 'RFQ Supervisor'])) {
return RequestQuotation::orderBy('rfq_number')
->pluck('rfq_number', 'id')
->toArray();
}
$userName = $user?->name;
$masterIds = \App\Models\SpotRateTransportMaster::whereRaw(
"user_name::jsonb @> ?",
[json_encode([$userName])]
)
->pluck('id')
->unique()
->toArray();
if (empty($masterIds)) {
return [];
}
return RequestQuotation::whereIn(
'spot_rate_transport_master_id',
$masterIds
)
->orderBy('rfq_number')
->pluck('rfq_number', 'id')
->toArray();
})
->afterStateUpdated(function ($state, callable $set) {
session(['rfq_id' => $state]);

View File

@@ -10,6 +10,8 @@ class Welcome extends Page
protected static string $view = 'filament.pages.welcome';
protected static ?string $navigationGroup = 'IIOT';
public function getHeading(): string
{
return '';

View File

@@ -139,7 +139,7 @@ class CreateInvoiceValidation extends CreateRecord
$user1 = Filament::auth()->user();
$user1->notify(new PushAlertNotification());
// $user1->notify(new PushAlertNotification());
$this->form->fill([
'plant_id' => $plantId,

View File

@@ -2,6 +2,8 @@
namespace App\Filament\Resources;
use App\Filament\Exports\ItemCharacteristicExporter;
use App\Filament\Imports\ItemCharacteristicImporter;
use App\Filament\Resources\ItemCharacteristicResource\Pages;
use App\Filament\Resources\ItemCharacteristicResource\RelationManagers;
use App\Models\Item;
@@ -15,6 +17,8 @@ use Filament\Tables;
use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\SoftDeletingScope;
use Filament\Tables\Actions\ExportAction;
use Filament\Tables\Actions\ImportAction;
class ItemCharacteristicResource extends Resource
{
@@ -924,6 +928,22 @@ class ItemCharacteristicResource extends Resource
Tables\Actions\ForceDeleteBulkAction::make(),
Tables\Actions\RestoreBulkAction::make(),
]),
])
->headerActions([
ImportAction::make()
->label('Import Item Characteristics')
->color('warning')
->importer(ItemCharacteristicImporter::class)
->visible(function() {
return Filament::auth()->user()->can('view import item characteristics');
}),
ExportAction::make()
->label('Export Item Characteristics')
->color('warning')
->exporter(ItemCharacteristicExporter::class)
->visible(function() {
return Filament::auth()->user()->can('view export item characteristics');
}),
]);
}

View File

@@ -82,9 +82,6 @@ class ItemResource extends Resource
Forms\Components\TextInput::make('category')
->label('Category')
->placeholder('Scan the Category'),
Forms\Components\TextInput::make('category')
->label('Category')
->placeholder('Scan the Category'),
Forms\Components\TextInput::make('code')
->required()
->placeholder('Scan the valid code')

View File

@@ -216,7 +216,10 @@ class LineResource extends Resource
])
->hint(fn ($get) => $get('lTypeError') ? $get('lTypeError') : null)
->hintColor('danger'),
Forms\Components\TextInput::make('line_capacity')
->label('Line Capacity')
->required()
->reactive(),
Forms\Components\TextInput::make('no_of_operation')
->label('No of Operation')
->required()
@@ -1061,6 +1064,11 @@ class LineResource extends Resource
->alignCenter()
->sortable()
->searchable(),
Tables\Columns\TextColumn::make('line_capacity')
->label('Line Capacity')
->alignCenter()
->sortable()
->searchable(),
Tables\Columns\TextColumn::make('no_of_operation')
->label('No of Operation')
->alignCenter()

View File

@@ -3,10 +3,28 @@
namespace App\Filament\Resources\ProcessOrderResource\Pages;
use App\Filament\Resources\ProcessOrderResource;
use App\Models\ProcessOrder;
use Filament\Actions;
use Filament\Facades\Filament;
use Filament\Notifications\Notification;
use Filament\Resources\Pages\CreateRecord;
class CreateProcessOrder extends CreateRecord
{
protected static string $resource = ProcessOrderResource::class;
protected function afterCreate(): void
{
$plantId = $this->data['plant_id'];
$processOrder = $this->data['process_order'];
$updatedQty = (float) $this->data['updated_order_quantity'];
ProcessOrder::where('plant_id', $plantId)
->where('process_order', $processOrder)
->update([
'updated_order_quantity' => $updatedQty,
'updated_by' => Filament::auth()->user()->name,
]);
}
}

View File

@@ -3,13 +3,78 @@
namespace App\Filament\Resources\ProcessOrderResource\Pages;
use App\Filament\Resources\ProcessOrderResource;
use App\Models\ProcessOrder;
use Filament\Actions;
use Filament\Facades\Filament;
use Filament\Notifications\Notification;
use Filament\Resources\Pages\EditRecord;
class EditProcessOrder extends EditRecord
{
protected static string $resource = ProcessOrderResource::class;
protected function beforeSave(): void
{
$plantId = $this->data['plant_id'] ?? null;
$processOrder = $this->data['process_order'] ?? null;
$extraQty = (float) ($this->data['updated_order_quantity'] ?? 0);
$extraQtyRaw = $this->data['updated_order_quantity'] ?? '';
if (!preg_match('/^\d+(\.\d{1,3})?$/', $extraQtyRaw)) {
Notification::make()
->title('Invalid Quantity')
->body('Only positive numbers with up to 3 decimal places are allowed.')
->danger()
->send();
$this->halt(); // stop save
}
if ($extraQty < 0)
{
Notification::make()
->title('Invalid Quantity')
->body('Negative values are not allowed.')
->danger()
->send();
$this->halt();
}
if ($extraQty > 0) {
$order = ProcessOrder::where('plant_id', $plantId)
->where('process_order', $processOrder)
->first();
if ($order) {
$baseQty = (float) $order->order_quantity;
$maxAllowed = $baseQty * 0.10;
$maxFinalQty = $baseQty + $maxAllowed;
if ($extraQty > $maxFinalQty) {
Notification::make()
->title('Limit Exceeded')
->body("You can only increase the order by 10% (Max allowed: {$maxFinalQty}).")
->danger()
->send();
$this->halt(); // stops save
}
ProcessOrder::where('plant_id', $plantId)
->where('process_order', $processOrder)
->update([
'updated_order_quantity' => $extraQty,
'updated_by' => Filament::auth()->user()?->name,
]);
}
}
}
protected function getHeaderActions(): array
{
return [

View File

@@ -437,7 +437,7 @@ class ProductionPlanResource extends Resource
->sortable()
->searchable(),
Tables\Columns\TextColumn::make('line.name')
->label('Plant')
->label('Line')
->alignCenter()
->sortable()
->searchable(),
@@ -476,7 +476,6 @@ class ProductionPlanResource extends Resource
// ->label('Shift')
// ->alignCenter()
// ->sortable(), // ->searchable(),
Tables\Columns\TextColumn::make('created_at')
->label('Created At')
->dateTime()

View File

@@ -158,9 +158,6 @@ class EditRfqTransporterBid extends EditRecord
$body
));
}
}
protected function getHeaderActions(): array

View File

@@ -15,6 +15,9 @@ use Storage;
use Maatwebsite\Excel\Facades\Excel;
use Livewire\Livewire;
use Str;
use Firebase\JWT\JWT;
use Firebase\JWT\Key;
class CreateSerialValidation extends CreateRecord
{
@@ -67,6 +70,8 @@ class CreateSerialValidation extends CreateRecord
$invoiceNumber = trim($invoiceNumber);
$parts = explode('.', $invoiceNumber);
$this->showCapacitorInput = false;
$user = Filament::auth()->user();
@@ -90,9 +95,60 @@ class CreateSerialValidation extends CreateRecord
//..GET SERIAL INVOICE API
// $decodedJwt = JWT::decode($invoiceNumber, new Key('dummy_key', 'HS256')); // replace 'dummy_key' with actual key if needed
// if (!$decodedJwt || !isset($decodedJwt->data)) {
// Notification::make()
// ->title("Invalid e-Invoice QR data or format received...")
// ->info()
// ->seconds(1)
// ->send();
// return;
// }
// $documentData = $decodedJwt->data; // This should be JSON string containing DocNo
// // Extract DocNo using regex
// preg_match('/"DocNo"\s*:\s*"([^"]+)"/', $documentData, $matches);
// if (isset($matches[1])) {
// $this->invoiceNumber = $matches[1];
// } else {
// Notification::make()
// ->title("DocNo not found in QR data...")
// ->info()
// ->seconds(1)
// ->send();
// return;
// }
//..
// Decode JWT payload
$payloadJson = base64_decode(strtr($parts[1], '-_', '+/'));
$payload = json_decode($payloadJson, true);
if (!isset($payload['data'])) {
throw new \Exception('Invalid payload');
}
$documentData = $payload['data'];
// Extract DocNo
preg_match('/"DocNo"\s*:\s*"([^"]+)"/', $documentData, $matches);
if (!isset($matches[1])) {
// throw new \Exception('DocNo not found');
}
if (isset($matches[1])) {
$invoiceNumber = $matches[1];
//dd($invoiceNumber);
}
$updateStatus = $this->form->getState()['update_invoice'] ?? null;
$this->invoiceNumber = trim($this->form->getState()['invoice_number']) ?? $invoiceNumber;

View File

@@ -124,36 +124,57 @@ class StickerStructureDetailResource extends Resource
{
return $table
->columns([
Tables\Columns\TextColumn::make('id')
->label('ID')
->numeric()
->sortable(),
Tables\Columns\TextColumn::make('No.')
->label('No.')
->getStateUsing(function ($record, $livewire, $column, $rowLoop) {
$paginator = $livewire->getTableRecords();
$perPage = method_exists($paginator, 'perPage') ? $paginator->perPage() : 10;
$currentPage = method_exists($paginator, 'currentPage') ? $paginator->currentPage() : 1;
return ($currentPage - 1) * $perPage + $rowLoop->iteration;
}),
Tables\Columns\TextColumn::make('plant.code')
->label('Plant Code')
->alignCenter(),
Tables\Columns\TextColumn::make('itemCharacteristic.item.code')
->label('Item')
->alignCenter(),
Tables\Columns\TextColumn::make('sticker_id')
->label('Sticker ID'),
->label('Sticker ID')
->alignCenter(),
Tables\Columns\TextColumn::make('sticker_width')
->label('Sticker Width'),
->label('Sticker Width')
->alignCenter(),
Tables\Columns\TextColumn::make('sticker_height')
->label('Sticker Height'),
->label('Sticker Height')
->alignCenter(),
Tables\Columns\TextColumn::make('sticker_lmargin')
->label('Sticker Left Margin'),
->label('Sticker Left Margin')
->alignCenter(),
Tables\Columns\TextColumn::make('sticker_rmargin')
->label('Sticker Right Margin'),
->label('Sticker Right Margin')
->alignCenter(),
Tables\Columns\TextColumn::make('sticker_tmargin')
->label('Sticker Top Margin'),
->label('Sticker Top Margin')
->alignCenter(),
Tables\Columns\TextColumn::make('sticker_bmargin')
->label('Sticker Bottom Margin'),
->label('Sticker Bottom Margin')
->alignCenter(),
Tables\Columns\TextColumn::make('created_at')
->label('Created At')
->alignCenter()
->dateTime()
->sortable()
->toggleable(isToggledHiddenByDefault: true),
Tables\Columns\TextColumn::make('updated_at')
->label('Updated At')
->alignCenter()
->dateTime()
->sortable()
->toggleable(isToggledHiddenByDefault: true),
Tables\Columns\TextColumn::make('deleted_at')
->label('Deleted At')
->alignCenter()
->dateTime()
->sortable()
->toggleable(isToggledHiddenByDefault: true),

View File

@@ -387,20 +387,179 @@ class CreateStickerValidation extends CreateRecord
// ]);
}
// foreach ($stickers as $sticker) {
// // $printerName = $this->getCupsPrinterNameByIp($sticker['print_ip']);
// \Log::info("Looking up printer for IP: " . $sticker['print_ip']);
// $printerName = $this->getCupsPrinterNameByIp($sticker['print_ip']);
// \Log::info("Found printer: " . ($printerName ?? 'NULL'));
// if (! $printerName) {
// Notification::make()
// ->danger()
// ->title('Printer Not Found')
// ->body("No CUPS printer configured for IP: {$sticker['print_ip']}")
// ->send();
// return;
// }
// $structure = StickerStructureDetail::findOrFail($sticker['sticker_id']);
// $itemCharacteristic = ItemCharacteristic::where('plant_id', $this->plantId)
// ->where('id', $sticker['item_characteristic'])
// ->firstOrFail();
// $dynamicElements = StickerDetail::where(
// 'sticker_structure_detail_id',
// $structure->id
// )->where('element_type', 'Dynamic')->get();
// /** STEP 3: Stream PDF to CUPS (STDIN) */
// $process = proc_open(
// 'lp -d ' . escapeshellarg($printerName) . ' -o fit-to-page -',
// [
// ['pipe', 'r'], // STDIN
// ['pipe', 'w'], // STDOUT
// ['pipe', 'w'], // STDERR
// ],
// $pipes
// );
// if (! is_resource($process)) {
// Notification::make()
// ->danger()
// ->title('Print Failed')
// ->body('Unable to start CUPS print process.')
// ->send();
// return;
// // continue;
// }
// $pdfContent = (new StickerPdfService())->generatePdf1(
// $structure->sticker_id,
// $dynamicElements,
// $itemCharacteristic,
// $serialNumber,
// $serNo
// );
// fwrite($pipes[0], $pdfContent);
// fclose($pipes[0]);
// $stderr = stream_get_contents($pipes[2]);
// fclose($pipes[1]);
// fclose($pipes[2]);
// $status = proc_close($process);
// if ($status != 0) {
// Notification::make()
// ->danger()
// ->title('Print Failed')
// ->body("CUPS error: {$stderr}")
// ->send();
// return;
// }
// }
foreach ($stickers as $sticker)
{
\Log::info("Looking up printer for IP: " . $sticker['print_ip']);
$printerName = $this->getCupsPrinterNameByIp($sticker['print_ip']);
\Log::info("Found printer: " . ($printerName ?? 'NULL'));
if (! $printerName) {
Notification::make()
->danger()
->title('Printer Not Found')
->body("No CUPS printer configured for IP: {$sticker['print_ip']}")
->send();
return;
}
$structure = StickerStructureDetail::findOrFail($sticker['sticker_id']);
$itemCharacteristic = ItemCharacteristic::where('plant_id', $this->plantId)
->where('id', $sticker['item_characteristic'])
->firstOrFail();
$dynamicElements = StickerDetail::where(
'sticker_structure_detail_id',
$structure->id
)->where('element_type', 'Dynamic')->get();
$pdfContent = (new StickerPdfService())->generatePdf1(
$structure->sticker_id,
$dynamicElements,
$itemCharacteristic,
$serialNumber,
$serNo
);
$tempPdfPath = storage_path('app/temp_sticker_' . uniqid() . '.pdf');
file_put_contents($tempPdfPath, $pdfContent);
exec(
"lp -d " . escapeshellarg($printerName) . " " . escapeshellarg($tempPdfPath),
$output,
$status
);
\Log::info("LP Output:", $output);
\Log::info("LP Status: " . $status);
if ($status != 0) {
Notification::make()
->danger()
->title('Print Failed')
->body("CUPS error while printing.")
->send();
if (file_exists($tempPdfPath)) {
unlink($tempPdfPath);
}
return;
}
if (file_exists($tempPdfPath)) {
unlink($tempPdfPath);
}
}
Notification::make()
->success()
->title('Sticker Printed')
->body("Sticker for Serial Number: $serialNumber printed successfully!")
->seconds(3)
->send();
// [$itemCode, $serialNumber] = explode('|', $serNo);
// $this->dispatch('open-sticker-pdf', [
// 'url' => url("/sticker/pdf/{$itemCode}/{$serialNumber}/$this->plantId/$this->ref_number")
// ]);
}
protected function getCupsPrinterNameByIp(string $ip): ?string
{
// exec('lpstat -v 2>&1', $output, $status);
exec('lpstat -h cups:631 -v 2>&1', $output, $status);
if ($status != 0 || empty($output)) {
return null;
}
foreach ($output as $line){
foreach ($output as $line) {
$parts = explode(':', $line, 2);
if (count($parts) < 2) continue;
@@ -411,6 +570,7 @@ class CreateStickerValidation extends CreateRecord
return $printerName;
}
}
return null;
}
}