Merge pull request 'ranjith-dev' (#618) from ranjith-dev into master
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled

Reviewed-on: #618
This commit was merged in pull request #618.
This commit is contained in:
2026-05-19 09:50:01 +00:00
4 changed files with 126 additions and 1 deletions

View File

@@ -210,6 +210,39 @@ class CreateProductionOrder extends CreateRecord
}
}
public function printItemSerial()
{
$pOrder = trim($this->form->getState()['production_order'] ?? '') ?? null;
$plantId = trim($this->form->getState()['plant_id'] ?? '') ?? null;
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;
}
$pOrderExists = ProductionOrder::where('plant_id', $plantId)->where('production_order', $pOrder)->first();
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]);
}
}
public function printPanel()
{
$pOrder = trim($this->form->getState()['production_order'] ?? '') ?? null;

View File

@@ -50,7 +50,8 @@ class ProductionOrderController extends Controller
$qrCode = new QrCode($qrData);
$output = new Output\Png;
$qrBinary = $output->output($qrCode, 100);
// $qrBinary = $output->output($qrCode, 100);
$qrBinary = $output->output($qrCode, 600);
$qrBase64 = base64_encode($qrBinary);
$stickers[] = [
@@ -134,6 +135,53 @@ class ProductionOrderController extends Controller
}
}
public function printitemserial($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)
// );
$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');
}
}
/**
* Store a newly created resource in storage.
*/

View File

@@ -0,0 +1,40 @@
<div class="flex flex-row gap-2 items-center flex-wrap">
@can('view save production order button')
<button
type="button"
wire:click="saveProductionOrder"
class="px-2 py-1 border border-primary-500 text-primary-600 rounded hover:bg-primary-50 hover:border-primary-700 transition text-sm"
>
Save
</button>
@endcan
@can('view print production order button')
<button
type="button"
wire:click="printProductionOrder"
class="px-2 py-1 border border-primary-500 text-primary-600 rounded hover:bg-primary-50 hover:border-primary-700 transition text-sm"
>
Print
</button>
@endcan
@can('view print panel production order button')
<button
type="button"
wire:click="printPanel"
class="px-2 py-1 border border-primary-500 text-primary-600 rounded hover:bg-primary-50 hover:border-primary-700 transition text-sm"
>
Print Panel
</button>
@endcan
@can('view print item serial production order button')
<button
type="button"
wire:click="printItemSerial"
class="px-2 py-1 border border-primary-500 text-primary-600 rounded hover:bg-primary-50 hover:border-primary-700 transition text-sm"
>
Print Item
</button>
@endcan
</div>

View File

@@ -61,6 +61,10 @@ Route::get('production-orders/{production_order}/{plant_code}/printpanel',
[ProductionOrderController::class, 'printpanel']
)->name('production-orders.printpanel');
Route::get('production-orders/{production_order}/printItemSerial',
[ProductionOrderController::class, 'printItemSerial']
)->name('production-orders.printItemSerial');
// Route::get('/characteristic/approve', [CharacteristicApprovalController::class, 'approve'])
// ->name('characteristic.approve')
// ->middleware('signed');