Merge pull request 'Changed qr code quality to 100 in controller page' (#626) from ranjith-dev into master
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Reviewed-on: #626
This commit was merged in pull request #626.
This commit is contained in:
@@ -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]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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[] = [
|
||||
|
||||
Reference in New Issue
Block a user