Added print item in print order controller and create page
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled

This commit is contained in:
dhanabalan
2026-05-19 15:17:33 +05:30
parent 6bac832d1f
commit b52fd57c23
2 changed files with 82 additions and 1 deletions

View File

@@ -210,6 +210,39 @@ class CreateProductionOrder extends CreateRecord
}
}
public function printItemSerial()
{
$pOrder = trim($this->form->getState()['production_order'] ?? '') ?? null;
$plantId = trim($this->form->getState()['plant_id'] ?? '') ?? null;
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]);
}
}
public function printPanel()
{
$pOrder = trim($this->form->getState()['production_order'] ?? '') ?? null;

View File

@@ -50,7 +50,8 @@ class ProductionOrderController extends Controller
$qrCode = new QrCode($qrData);
$output = new Output\Png;
$qrBinary = $output->output($qrCode, 100);
// $qrBinary = $output->output($qrCode, 100);
$qrBinary = $output->output($qrCode, 600);
$qrBase64 = base64_encode($qrBinary);
$stickers[] = [
@@ -134,6 +135,53 @@ class ProductionOrderController extends Controller
}
}
public function printitemserial($production_order)
{
$order = ProductionOrder::where('production_order', $production_order)->first();
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 ?? '';
$stickers = [];
for ($i = $fromSerial; $i <= $toSerial; $i++)
{
$serial = str_pad($i, 6, '0', STR_PAD_LEFT);
$qrData = $itemCode . '|' . $serial;
// $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');
}
}
/**
* Store a newly created resource in storage.
*/