changed print panel box 2 button logic in produciton order
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 16s
Gemini PR Review / Gemini PR Review (pull_request) Failing after 20s
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Successful in 18s
Laravel Pint / pint (pull_request) Successful in 2m1s
Laravel Larastan / larastan (pull_request) Failing after 6m42s
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 16s
Gemini PR Review / Gemini PR Review (pull_request) Failing after 20s
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Successful in 18s
Laravel Pint / pint (pull_request) Successful in 2m1s
Laravel Larastan / larastan (pull_request) Failing after 6m42s
This commit is contained in:
@@ -146,64 +146,139 @@ class ProductionOrderController extends Controller
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function printpanel2($production_order, $plantCode){
|
// public function printpanel2($production_order, $plantCode){
|
||||||
|
|
||||||
|
// $order = ProductionOrder::where('production_order', $production_order)->first();
|
||||||
|
|
||||||
|
// $wareHouseNo = Plant::where('code', $plantCode)->first();
|
||||||
|
|
||||||
|
// $wareNo = $wareHouseNo->warehouse_number ?? null;
|
||||||
|
|
||||||
|
// 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 ?? '';
|
||||||
|
// $now = Carbon::now();
|
||||||
|
// $year = $now->format('y');
|
||||||
|
// // $month = $now->format('m');
|
||||||
|
// // $month = $now->format('m');
|
||||||
|
|
||||||
|
// // $stickers = [];
|
||||||
|
|
||||||
|
// // for ($i = $fromSerial; $i <= $toSerial; $i++)
|
||||||
|
// // {
|
||||||
|
|
||||||
|
// // $currentSerial = (string) $i;
|
||||||
|
|
||||||
|
// // $year = substr($currentSerial, -10, 2);
|
||||||
|
|
||||||
|
// // $month = substr($currentSerial, -8, 2);
|
||||||
|
|
||||||
|
// // $serial = str_pad($i, 6, '0', STR_PAD_LEFT);
|
||||||
|
// // $serialCount = substr(str_pad($i, 6, '0', STR_PAD_LEFT), -6);
|
||||||
|
|
||||||
|
// // $qrData = $plantCode . $wareNo . '/' . $itemCode . '/' . $year.$month . '/' . $serialCount;
|
||||||
|
|
||||||
|
// // $panel = $plantCode . $wareNo . '/' . $itemCode . '/' . $year.$month . '/' . $serialCount;
|
||||||
|
|
||||||
|
// // $qrCode = new QrCode($qrData);
|
||||||
|
// // $output = new Output\Png;
|
||||||
|
// // $qrBinary = $output->output($qrCode, 100);
|
||||||
|
// // $qrBase64 = base64_encode($qrBinary);
|
||||||
|
|
||||||
|
// // $stickers[] = [
|
||||||
|
// // 'serial' => $panel,
|
||||||
|
// // 'qr' => 'data:image/png;base64,' . $qrBase64,
|
||||||
|
// // 'production_order' => $production_order,
|
||||||
|
// // 'description' => $itemDes ?? ''
|
||||||
|
// // ];
|
||||||
|
// // }
|
||||||
|
|
||||||
|
// $pdf = Pdf::loadView('production-orders.printpanel2', compact('stickers'))
|
||||||
|
// ->setPaper([0, 0, 113.39, 113.39]);
|
||||||
|
|
||||||
|
// return $pdf->stream('stickers.pdf');
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
public function printpanel2($production_order, $plantCode)
|
||||||
|
{
|
||||||
$order = ProductionOrder::where('production_order', $production_order)->first();
|
$order = ProductionOrder::where('production_order', $production_order)->first();
|
||||||
|
|
||||||
$wareHouseNo = Plant::where('code', $plantCode)->first();
|
|
||||||
|
|
||||||
$wareNo = $wareHouseNo->warehouse_number ?? null;
|
|
||||||
|
|
||||||
if (!$order) {
|
if (!$order) {
|
||||||
abort(404, 'Production Order not found');
|
abort(404, 'Production Order not found');
|
||||||
}
|
}
|
||||||
else{
|
|
||||||
$fromSerial = (int) $order->from_serial_number;
|
$fromSerial = (int) $order->from_serial_number;
|
||||||
$toSerial = (int) $order->to_serial_number;
|
$toSerial = (int) $order->to_serial_number;
|
||||||
|
|
||||||
$itemCode = $order->item->code ?? '';
|
$itemCode = $order->item->code ?? '';
|
||||||
$itemDes = $order->item->description ?? '';
|
$itemDes = $order->item->description ?? '';
|
||||||
$now = Carbon::now();
|
|
||||||
$year = $now->format('y');
|
|
||||||
// $month = $now->format('m');
|
|
||||||
// $month = $now->format('m');
|
|
||||||
|
|
||||||
$stickers = [];
|
$stickers = [];
|
||||||
|
|
||||||
for ($i = $fromSerial; $i <= $toSerial; $i++)
|
for ($i = $fromSerial; $i <= $toSerial; $i += 2) {
|
||||||
{
|
|
||||||
|
|
||||||
$currentSerial = (string) $i;
|
$row = [];
|
||||||
|
|
||||||
|
for ($j = 0; $j < 2; $j++) {
|
||||||
|
|
||||||
|
$current = $i + $j;
|
||||||
|
|
||||||
|
if ($current > $toSerial) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Original encoded serial number
|
||||||
|
$currentSerial = (string) $current;
|
||||||
|
|
||||||
|
// Extract year and month
|
||||||
$year = substr($currentSerial, -10, 2);
|
$year = substr($currentSerial, -10, 2);
|
||||||
|
|
||||||
$month = substr($currentSerial, -8, 2);
|
$month = substr($currentSerial, -8, 2);
|
||||||
|
|
||||||
$serial = str_pad($i, 6, '0', STR_PAD_LEFT);
|
// Extract only the last 6 digits
|
||||||
$serialCount = substr(str_pad($i, 6, '0', STR_PAD_LEFT), -6);
|
$serialCount = substr($currentSerial, -6);
|
||||||
|
|
||||||
$qrData = $plantCode . $wareNo . '/' . $itemCode . '/' . $year.$month . '/' . $serialCount;
|
// QR format: PlantCode/ItemCode/YearMonth/Serial
|
||||||
|
$qrData = $plantCode . '/' .
|
||||||
$panel = $plantCode . $wareNo . '/' . $itemCode . '/' . $year.$month . '/' . $serialCount;
|
$itemCode . '/' .
|
||||||
|
$year . $month . '/' .
|
||||||
|
$serialCount;
|
||||||
|
|
||||||
|
// Generate QR code
|
||||||
$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);
|
||||||
|
|
||||||
$qrBase64 = base64_encode($qrBinary);
|
$qrBase64 = base64_encode($qrBinary);
|
||||||
|
|
||||||
$stickers[] = [
|
$row[] = [
|
||||||
'serial' => $panel,
|
'serial' => $qrData,
|
||||||
'qr' => 'data:image/png;base64,' . $qrBase64,
|
'qr' => 'data:image/png;base64,' . $qrBase64,
|
||||||
'production_order' => $production_order,
|
'production_order' => $production_order,
|
||||||
'description' => $itemDes ?? ''
|
'description' => $itemDes,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
$pdf = Pdf::loadView('production-orders.printpanel2', compact('stickers'))
|
$stickers[] = $row;
|
||||||
->setPaper([0, 0, 113.39, 113.39]);
|
}
|
||||||
|
|
||||||
|
$pdf = Pdf::loadView(
|
||||||
|
'production-orders.printpanel2',
|
||||||
|
compact('stickers')
|
||||||
|
)->setPaper([0, 0, 113.39, 113.39]);
|
||||||
|
|
||||||
return $pdf->stream('stickers.pdf');
|
return $pdf->stream('stickers.pdf');
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public function printitemserial($production_order, $plantCode)
|
public function printitemserial($production_order, $plantCode)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -97,22 +97,29 @@
|
|||||||
|
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
@foreach($stickers as $sticker)
|
@foreach($stickers as $row)
|
||||||
@php
|
|
||||||
$descSize = 4;
|
|
||||||
@endphp
|
|
||||||
|
|
||||||
<div class="sticker-row {{ $loop->first ? '' : 'new-page' }}">
|
<div class="sticker-row {{ $loop->first ? '' : 'new-page' }}">
|
||||||
|
|
||||||
@foreach(['left', 'right'] as $side)
|
@foreach(['left', 'right'] as $index => $side)
|
||||||
|
|
||||||
|
@if(isset($row[$index]))
|
||||||
<div class="sticker {{ $side }}">
|
<div class="sticker {{ $side }}">
|
||||||
<img class="qr" src="{{ $sticker['qr'] }}">
|
|
||||||
<div class="serial">{{ $sticker['serial'] }}</div>
|
<img class="qr" src="{{ $row[$index]['qr'] }}">
|
||||||
{{-- <div class="desc" style="font-size: {{ $descSize }}mm;">{{ $sticker['description'] }}</div> --}}
|
|
||||||
|
<div class="serial">
|
||||||
|
{{ $row[$index]['serial'] }}
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="desc">
|
<div class="desc">
|
||||||
<span>{{ trim($sticker['description'], " \"'") }}</span>
|
<span>
|
||||||
|
{{ trim($row[$index]['description'], " \"'") }}
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
@endif
|
||||||
|
|
||||||
@endforeach
|
@endforeach
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user