Merge pull request 'ranjith-dev' (#625) from ranjith-dev into master
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled

Reviewed-on: #625
This commit was merged in pull request #625.
This commit is contained in:
2026-05-20 09:44:37 +00:00
6 changed files with 223 additions and 60 deletions

View File

@@ -24,7 +24,7 @@ class ProductionOrderImporter extends Importer
->requiredMapping()
->label('PLANT CODE')
->exampleHeader('PLANT CODE')
->example('1000')
->example('TEST007')
->relationship(resolveUsing: 'code')
->rules(['required']),
ImportColumn::make('item')

View File

@@ -247,6 +247,18 @@ class ProductionOrderResource extends Resource
->searchable()
->alignCenter()
->sortable(),
Tables\Columns\TextColumn::make('item.description')
->label('Item Description')
->searchable()
->alignCenter()
->sortable()
->toggleable(isToggledHiddenByDefault: true),
Tables\Columns\TextColumn::make('item.uom')
->label('Unit of Measure')
->searchable()
->alignCenter()
->sortable()
->toggleable(isToggledHiddenByDefault: true),
Tables\Columns\TextColumn::make('quantity')
->label('Quantity')
->searchable()

View File

@@ -216,6 +216,8 @@ class CreateProductionOrder extends CreateRecord
$plantId = trim($this->form->getState()['plant_id'] ?? '') ?? null;
$plantCode = Plant::where('id', $plantId)->value('code');
if (empty($plantId)) {
Notification::make()
->title('Plant name cannot be empty!')
@@ -239,7 +241,7 @@ class CreateProductionOrder extends CreateRecord
->send();
return;
} else {
return redirect()->route('production-orders.printItemSerial', ['production_order' => $pOrder]);
return redirect()->route('production-orders.printItemSerial', ['production_order' => $pOrder, 'plant_code' => $plantCode]);
}
}

View File

@@ -89,36 +89,107 @@ class EditProductionOrder extends EditRecord
}
public function printItemSerial()
// public function printItemSerial()
// {
// $pOrder = trim($this->form->getState()['production_order'] ?? '') ?? null;
// $plantId = trim($this->form->getState()['plant_id'] ?? '') ?? null;
// $plantCode = Plant::where('id', $plantId)->value('code');
// if (empty($plantId)) {
// Notification::make()
// ->title('Plant name cannot be empty!')
// ->danger()
// ->send();
// return;
// } elseif (empty($pOrder)) {
// Notification::make()
// ->title('Production order cannot be empty!')
// ->danger()
// ->send();
// return;
// }
// $pOrderExists = ProductionOrder::where('plant_id', $plantId)->where('production_order', $pOrder)->first();
// if (! $pOrderExists) {
// Notification::make()
// ->title("Production Order '{$pOrder}' does not exist to get print!")
// ->danger()
// ->send();
// return;
// } else {
// return redirect()->route('production-orders.printItemSerial', ['production_order' => $pOrder, 'plant_code' => $plantCode]);
// }
// }
public function printitemserial($production_order, $plantCode)
{
$pOrder = trim($this->form->getState()['production_order'] ?? '') ?? null;
$order = ProductionOrder::where('production_order', $production_order)->first();
$plantId = trim($this->form->getState()['plant_id'] ?? '') ?? null;
$plantCode = Plant::where('id', $plantId)->value('code');
if (empty($plantId)) {
Notification::make()
->title('Plant name cannot be empty!')
->danger()
->send();
return;
} elseif (empty($pOrder)) {
Notification::make()
->title('Production order cannot be empty!')
->danger()
->send();
return;
if (!$order) {
abort(404, 'Production Order not found');
}
else{
$fromSerial = (int) $order->from_serial_number;
$toSerial = (int) $order->to_serial_number;
$itemCode = $order->item->code ?? '';
$itemDes = $order->item->description ?? '';
$pOrderExists = ProductionOrder::where('plant_id', $plantId)->where('production_order', $pOrder)->first();
$wareHouseNo = Plant::where('code', $plantCode)->first();
if (! $pOrderExists) {
Notification::make()
->title("Production Order '{$pOrder}' does not exist to get print!")
->danger()
->send();
return;
} else {
return redirect()->route('production-orders.printItemSerial', ['production_order' => $pOrder, 'plant_code' => $plantCode]);
$wareNo = $wareHouseNo->warehouse_number ?? null;
$now = Carbon::now();
$year = $now->format('y');
$month = $now->format('m');
$stickers = [];
for ($i = $fromSerial; $i <= $toSerial; $i++)
{
$serial = str_pad($i, 6, '0', STR_PAD_LEFT);
if(!empty($wareNo)){
$serial = substr($serial, 0, 4) . $wareNo . substr($serial, 4);
$qrData = $itemCode . '|' . $serial;
} else {
$qrData = $itemCode . '|' . $serial;
$serial = str_pad($i, 6, '0', STR_PAD_LEFT);
}
// $qrData = $itemCode . '|' . $serial;
// $serialCount = substr(str_pad($i, 6, '0', STR_PAD_LEFT), -6);
// $serialWithWarehouse = substr($serial, 0, 4) . $wareNo . substr($serial, 4);
// $qrData = $itemCode . '|' . $serialWithWarehouse;
// $panel = $plantCode . $wareNo . '/' . $itemCode . '/' . $year.$month . '/' . $serialCount;
// $qrBase64 = base64_encode(
// QrCode::format('png')->size(100)->generate($qrData)
// );
$qrCode = new QrCode($qrData);
$output = new Output\Png;
// $qrBinary = $output->output($qrCode, 100);
$qrBinary = $output->output($qrCode, 600);
$qrBase64 = base64_encode($qrBinary);
$stickers[] = [
'serial' => $serial,
'qr' => 'data:image/png;base64,' . $qrBase64,
'production_order' => $itemCode,
'description' => $itemDes ?? ''
];
}
$pdf = Pdf::loadView('production-orders.printItemSerial', compact('stickers'))
->setPaper([0, 0, 170, 40]);
return $pdf->stream('stickers.pdf');
}
}

View File

@@ -89,38 +89,109 @@ class ViewProductionOrder extends ViewRecord
}
public function printItemSerial()
// public function printItemSerial()
// {
// $pOrder = trim($this->form->getState()['production_order'] ?? '') ?? null;
// $plantId = trim($this->form->getState()['plant_id'] ?? '') ?? null;
// $plantCode = Plant::where('id', $plantId)->value('code');
// if (empty($plantId)) {
// Notification::make()
// ->title('Plant name cannot be empty!')
// ->danger()
// ->send();
// return;
// } elseif (empty($pOrder)) {
// Notification::make()
// ->title('Production order cannot be empty!')
// ->danger()
// ->send();
// return;
// }
// $pOrderExists = ProductionOrder::where('plant_id', $plantId)->where('production_order', $pOrder)->first();
// if (! $pOrderExists) {
// Notification::make()
// ->title("Production Order '{$pOrder}' does not exist to get print!")
// ->danger()
// ->send();
// return;
// } else {
// return redirect()->route('production-orders.printItemSerial', ['production_order' => $pOrder, 'plant_code' => $plantCode]);
// }
// }
public function printitemserial($production_order, $plantCode)
{
$pOrder = trim($this->form->getState()['production_order'] ?? '') ?? null;
$order = ProductionOrder::where('production_order', $production_order)->first();
$plantId = trim($this->form->getState()['plant_id'] ?? '') ?? null;
$plantCode = Plant::where('id', $plantId)->value('code');
if (empty($plantId)) {
Notification::make()
->title('Plant name cannot be empty!')
->danger()
->send();
return;
} elseif (empty($pOrder)) {
Notification::make()
->title('Production order cannot be empty!')
->danger()
->send();
return;
if (!$order) {
abort(404, 'Production Order not found');
}
else{
$fromSerial = (int) $order->from_serial_number;
$toSerial = (int) $order->to_serial_number;
$itemCode = $order->item->code ?? '';
$itemDes = $order->item->description ?? '';
$pOrderExists = ProductionOrder::where('plant_id', $plantId)->where('production_order', $pOrder)->first();
$wareHouseNo = Plant::where('code', $plantCode)->first();
if (! $pOrderExists) {
Notification::make()
->title("Production Order '{$pOrder}' does not exist to get print!")
->danger()
->send();
return;
} else {
return redirect()->route('production-orders.printItemSerial', ['production_order' => $pOrder, 'plant_code' => $plantCode]);
$wareNo = $wareHouseNo->warehouse_number ?? null;
$now = Carbon::now();
$year = $now->format('y');
$month = $now->format('m');
$stickers = [];
for ($i = $fromSerial; $i <= $toSerial; $i++)
{
$serial = str_pad($i, 6, '0', STR_PAD_LEFT);
if(!empty($wareNo)){
$serial = substr($serial, 0, 4) . $wareNo . substr($serial, 4);
$qrData = $itemCode . '|' . $serial;
} else {
$qrData = $itemCode . '|' . $serial;
$serial = str_pad($i, 6, '0', STR_PAD_LEFT);
}
// $qrData = $itemCode . '|' . $serial;
// $serialCount = substr(str_pad($i, 6, '0', STR_PAD_LEFT), -6);
// $serialWithWarehouse = substr($serial, 0, 4) . $wareNo . substr($serial, 4);
// $qrData = $itemCode . '|' . $serialWithWarehouse;
// $panel = $plantCode . $wareNo . '/' . $itemCode . '/' . $year.$month . '/' . $serialCount;
// $qrBase64 = base64_encode(
// QrCode::format('png')->size(100)->generate($qrData)
// );
$qrCode = new QrCode($qrData);
$output = new Output\Png;
// $qrBinary = $output->output($qrCode, 100);
$qrBinary = $output->output($qrCode, 600);
$qrBase64 = base64_encode($qrBinary);
$stickers[] = [
'serial' => $serial,
'qr' => 'data:image/png;base64,' . $qrBase64,
'production_order' => $itemCode,
'description' => $itemDes ?? ''
];
}
$pdf = Pdf::loadView('production-orders.printItemSerial', compact('stickers'))
->setPaper([0, 0, 170, 40]);
return $pdf->stream('stickers.pdf');
}
}

View File

@@ -51,7 +51,7 @@ class ProductionOrderController extends Controller
$qrCode = new QrCode($qrData);
$output = new Output\Png;
// $qrBinary = $output->output($qrCode, 100);
$qrBinary = $output->output($qrCode, 600);
$qrBinary = $output->output($qrCode, 100);
$qrBase64 = base64_encode($qrBinary);
$stickers[] = [
@@ -164,14 +164,21 @@ class ProductionOrderController extends Controller
$serial = str_pad($i, 6, '0', STR_PAD_LEFT);
if(!empty($wareNo)){
$serial = substr($serial, 0, 4) . $wareNo . substr($serial, 4);
$qrData = $itemCode . '|' . $serial;
} else {
$qrData = $itemCode . '|' . $serial;
$serial = str_pad($i, 6, '0', STR_PAD_LEFT);
}
// $qrData = $itemCode . '|' . $serial;
$serial = str_pad($i, 6, '0', STR_PAD_LEFT);
$serialCount = substr(str_pad($i, 6, '0', STR_PAD_LEFT), -6);
// $serialCount = substr(str_pad($i, 6, '0', STR_PAD_LEFT), -6);
$serialWithWarehouse = substr($serial, 0, 4) . $wareNo . substr($serial, 4);
// $serialWithWarehouse = substr($serial, 0, 4) . $wareNo . substr($serial, 4);
$qrData = $itemCode . '|' . $serialWithWarehouse;
// $qrData = $itemCode . '|' . $serialWithWarehouse;
// $panel = $plantCode . $wareNo . '/' . $itemCode . '/' . $year.$month . '/' . $serialCount;
@@ -186,7 +193,7 @@ class ProductionOrderController extends Controller
$qrBase64 = base64_encode($qrBinary);
$stickers[] = [
'serial' => $serialWithWarehouse,
'serial' => $serial,
'qr' => 'data:image/png;base64,' . $qrBase64,
'production_order' => $itemCode,
'description' => $itemDes ?? ''