Adde panel box qr code logic fro production order screen
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Gemini PR Review / Gemini PR Review (pull_request) Has been cancelled
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Has been cancelled
Laravel Larastan / larastan (pull_request) Has been cancelled
Laravel Pint / pint (pull_request) Has been cancelled
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Gemini PR Review / Gemini PR Review (pull_request) Has been cancelled
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Has been cancelled
Laravel Larastan / larastan (pull_request) Has been cancelled
Laravel Pint / pint (pull_request) Has been cancelled
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\ProductionOrder;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Http\Request;
|
||||
// use SimpleSoftwareIO\QrCode\Facades\QrCode;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
@@ -42,8 +43,6 @@ class ProductionOrderController extends Controller
|
||||
|
||||
$qrData = $itemCode . '|' . $serial;
|
||||
|
||||
Log::info($qrData);
|
||||
|
||||
// $qrBase64 = base64_encode(
|
||||
// QrCode::format('png')->size(100)->generate($qrData)
|
||||
// );
|
||||
@@ -68,47 +67,53 @@ class ProductionOrderController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
// public function printpanel($production_order){
|
||||
// $order = ProductionOrder::where('production_order', $production_order)->first();
|
||||
public function printpanel($production_order, $plantCode){
|
||||
$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 ?? '';
|
||||
// $year =
|
||||
// $month =
|
||||
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');
|
||||
|
||||
// $stickers = [];
|
||||
$stickers = [];
|
||||
|
||||
// for ($i = $fromSerial; $i <= $toSerial; $i++)
|
||||
// {
|
||||
for ($i = $fromSerial; $i <= $toSerial; $i++)
|
||||
{
|
||||
|
||||
// $serial = str_pad($i, 6, '0', STR_PAD_LEFT);
|
||||
$serial = str_pad($i, 6, '0', STR_PAD_LEFT);
|
||||
$serialCount = substr(str_pad($i, 6, '0', STR_PAD_LEFT), -5);
|
||||
|
||||
// $qrData = $serial . '/' . $itemCode . '/' . $serial . '/' . $itemCode;
|
||||
$qrData = $plantCode . '/' . $itemCode . '/' . $year.$month . '/' . $serialCount;
|
||||
|
||||
// $qrBase64 = base64_encode(
|
||||
// QrCode::format('png')->size(100)->generate($qrData)
|
||||
// );
|
||||
$panel = $plantCode . '/' . $itemCode . '/' . $year.$month . '/' . $serialCount;
|
||||
|
||||
// $stickers[] = [
|
||||
// 'serial' => $serial,
|
||||
// 'qr' => 'data:image/png;base64,' . $qrBase64,
|
||||
// 'production_order' => $production_order,
|
||||
// 'description' => $itemDes ?? ''
|
||||
// ];
|
||||
// }
|
||||
|
||||
// $pdf = Pdf::loadView('production-orders.printpallet', compact('stickers'))
|
||||
// ->setPaper([0, 0, 170, 40]);
|
||||
$qrCode = new QrCode($qrData);
|
||||
$output = new Output\Png;
|
||||
$qrBinary = $output->output($qrCode, 100);
|
||||
$qrBase64 = base64_encode($qrBinary);
|
||||
|
||||
// return $pdf->stream('stickers.pdf');
|
||||
// }
|
||||
// }
|
||||
$stickers[] = [
|
||||
'serial' => $panel,
|
||||
'qr' => 'data:image/png;base64,' . $qrBase64,
|
||||
'production_order' => $production_order,
|
||||
'description' => $itemDes ?? ''
|
||||
];
|
||||
}
|
||||
|
||||
$pdf = Pdf::loadView('production-orders.printpanel', compact('stickers'))
|
||||
->setPaper([0, 0, 113.39, 113.39]);
|
||||
|
||||
return $pdf->stream('stickers.pdf');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
|
||||
Reference in New Issue
Block a user