Changed qr code quality to 100 in controller page
Some checks failed
Gemini PR Review / Gemini PR Review (pull_request) Waiting to run
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Waiting to run
Laravel Larastan / larastan (pull_request) Waiting to run
Laravel Pint / pint (pull_request) Waiting to run
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled

This commit is contained in:
dhanabalan
2026-05-20 16:26:29 +05:30
parent 8eb0985128
commit 561e0b448f
3 changed files with 55 additions and 127 deletions

View File

@@ -122,74 +122,38 @@ class EditProductionOrder extends EditRecord
// }
// }
public function printitemserial($production_order, $plantCode)
public function printItemSerial()
{
$order = ProductionOrder::where('production_order', $production_order)->first();
$pOrder = trim($this->form->getState()['production_order'] ?? '') ?? null;
if (!$order) {
abort(404, 'Production Order not found');
$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;
}
else{
$fromSerial = (int) $order->from_serial_number;
$toSerial = (int) $order->to_serial_number;
$itemCode = $order->item->code ?? '';
$itemDes = $order->item->description ?? '';
$wareHouseNo = Plant::where('code', $plantCode)->first();
$pOrderExists = ProductionOrder::where('plant_id', $plantId)->where('production_order', $pOrder)->first();
$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');
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]);
}
}

View File

@@ -124,74 +124,38 @@ class ViewProductionOrder extends ViewRecord
// }
// }
public function printitemserial($production_order, $plantCode)
public function printItemSerial()
{
$order = ProductionOrder::where('production_order', $production_order)->first();
$pOrder = trim($this->form->getState()['production_order'] ?? '') ?? null;
if (!$order) {
abort(404, 'Production Order not found');
$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;
}
else{
$fromSerial = (int) $order->from_serial_number;
$toSerial = (int) $order->to_serial_number;
$itemCode = $order->item->code ?? '';
$itemDes = $order->item->description ?? '';
$wareHouseNo = Plant::where('code', $plantCode)->first();
$pOrderExists = ProductionOrder::where('plant_id', $plantId)->where('production_order', $pOrder)->first();
$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');
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]);
}
}

View File

@@ -189,7 +189,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[] = [