Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 12s
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Successful in 11s
Gemini PR Review / review (pull_request) Failing after 32s
Laravel Pint / pint (pull_request) Successful in 2m34s
Laravel Larastan / larastan (pull_request) Failing after 3m26s
105 lines
2.4 KiB
PHP
105 lines
2.4 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use App\Models\Item;
|
|
use App\Models\ProductionQuantity;
|
|
use App\Models\StickerMaster;
|
|
use Illuminate\Http\Request;
|
|
use Mpdf\Mpdf;
|
|
use Mpdf\QrCode\Output;
|
|
use Mpdf\QrCode\QrCode;
|
|
|
|
class ProductionStickerReprintController extends Controller
|
|
{
|
|
/**
|
|
* Display a listing of the resource.
|
|
*/
|
|
public function index()
|
|
{
|
|
//
|
|
}
|
|
|
|
public function downloadQrPdf($palletNo)
|
|
{
|
|
$parts = explode('|', $palletNo);
|
|
$itemCode = trim($parts[0]);
|
|
$serialNumberRaw = isset($parts[1]) ? trim($parts[1]) : null;
|
|
|
|
if ($serialNumberRaw != null) {
|
|
$serial = preg_replace('/\/.*/', '', $serialNumberRaw);
|
|
$serial = trim($serial);
|
|
} else {
|
|
$serial = null;
|
|
}
|
|
|
|
$item = Item::where('code', $itemCode)->first();
|
|
$itemId= $item->id;
|
|
|
|
if (!$item) {
|
|
abort(404, "Item with code {$itemCode} not found.");
|
|
}
|
|
|
|
$production = ProductionQuantity::where('item_id', $item->id)
|
|
->where('serial_number', $serial)
|
|
->first();
|
|
|
|
if (!$production) {
|
|
abort(404, "Production data for item code '{$itemCode}' with serial '{$serial}' not found.");
|
|
}
|
|
|
|
$productionOrder = $production->production_order ?? '';
|
|
|
|
if ($item->category == 'Submersible Motor')
|
|
{
|
|
$copies = 1;
|
|
}
|
|
elseif ($item->category == 'Submersible Pump')
|
|
{
|
|
$copies = 2;
|
|
}
|
|
// 5. Generate QR Code (base64)
|
|
$qrCode = new QrCode($palletNo);
|
|
$output = new Output\Png();
|
|
$qrBinary = $output->output($qrCode, 100); // 100 = size
|
|
$qrBase64 = base64_encode($qrBinary);
|
|
|
|
// 6. Return view
|
|
return view('print-qr', [
|
|
'qrBase64' => $qrBase64,
|
|
'serial' => $serial,
|
|
'productionOrder' => $productionOrder,
|
|
'item' => $item,
|
|
'copies'=> $copies,
|
|
]);
|
|
}
|
|
public function store(Request $request)
|
|
{
|
|
//
|
|
}
|
|
|
|
/**
|
|
* Display the specified resource.
|
|
*/
|
|
public function show(string $id)
|
|
{
|
|
//
|
|
}
|
|
|
|
/**
|
|
* Update the specified resource in storage.
|
|
*/
|
|
public function update(Request $request, string $id)
|
|
{
|
|
//
|
|
}
|
|
|
|
/**
|
|
* Remove the specified resource from storage.
|
|
*/
|
|
public function destroy(string $id)
|
|
{
|
|
//
|
|
}
|
|
}
|