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
93 lines
2.1 KiB
PHP
93 lines
2.1 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use App\Models\ProductionOrder;
|
|
use Illuminate\Http\Request;
|
|
use SimpleSoftwareIO\QrCode\Facades\QrCode;
|
|
use Barryvdh\DomPDF\Facade\Pdf;
|
|
|
|
class ProductionOrderController extends Controller
|
|
{
|
|
/**
|
|
* Display a listing of the resource.
|
|
*/
|
|
public function index()
|
|
{
|
|
//
|
|
}
|
|
|
|
public function print($production_order)
|
|
{
|
|
$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 ?? '';
|
|
|
|
$stickers = [];
|
|
|
|
for ($i = $fromSerial; $i <= $toSerial; $i++)
|
|
{
|
|
|
|
$serial = str_pad($i, 6, '0', STR_PAD_LEFT);
|
|
|
|
$qrData = $itemCode . '|' . $serial;
|
|
|
|
$qrBase64 = base64_encode(
|
|
QrCode::format('png')->size(100)->generate($qrData)
|
|
);
|
|
|
|
$stickers[] = [
|
|
'serial' => $serial,
|
|
'qr' => 'data:image/png;base64,' . $qrBase64,
|
|
'production_order' => $production_order,
|
|
'description' => $itemDes ?? ''
|
|
];
|
|
}
|
|
|
|
$pdf = Pdf::loadView('production-orders.print', compact('stickers'))
|
|
->setPaper([0, 0, 170, 40]);
|
|
|
|
return $pdf->stream('stickers.pdf');
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Store a newly created resource in storage.
|
|
*/
|
|
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)
|
|
{
|
|
//
|
|
}
|
|
}
|