Changed qr code quality to 100 in controller page #626

Merged
jothi merged 1 commits from ranjith-dev into master 2026-05-20 10:57:55 +00:00
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) { $plantId = trim($this->form->getState()['plant_id'] ?? '') ?? null;
abort(404, 'Production Order not found');
$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; if (! $pOrderExists) {
Notification::make()
$now = Carbon::now(); ->title("Production Order '{$pOrder}' does not exist to get print!")
$year = $now->format('y'); ->danger()
$month = $now->format('m'); ->send();
return;
$stickers = []; } else {
return redirect()->route('production-orders.printItemSerial', ['production_order' => $pOrder, 'plant_code' => $plantCode]);
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

@@ -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) { $plantId = trim($this->form->getState()['plant_id'] ?? '') ?? null;
abort(404, 'Production Order not found');
$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; if (! $pOrderExists) {
Notification::make()
$now = Carbon::now(); ->title("Production Order '{$pOrder}' does not exist to get print!")
$year = $now->format('y'); ->danger()
$month = $now->format('m'); ->send();
return;
$stickers = []; } else {
return redirect()->route('production-orders.printItemSerial', ['production_order' => $pOrder, 'plant_code' => $plantCode]);
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

@@ -189,7 +189,7 @@ class ProductionOrderController extends Controller
$qrCode = new QrCode($qrData); $qrCode = new QrCode($qrData);
$output = new Output\Png; $output = new Output\Png;
// $qrBinary = $output->output($qrCode, 100); // $qrBinary = $output->output($qrCode, 100);
$qrBinary = $output->output($qrCode, 600); $qrBinary = $output->output($qrCode, 100);
$qrBase64 = base64_encode($qrBinary); $qrBase64 = base64_encode($qrBinary);
$stickers[] = [ $stickers[] = [