ranjith-dev #1526

Merged
jothi merged 4 commits from ranjith-dev into master 2026-11-26 03:05:17 +00:00
6 changed files with 269 additions and 0 deletions

View File

@@ -211,6 +211,42 @@ class CreateProductionOrder extends CreateRecord
}
}
public function printProductionOrderSecond()
{
$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.print2', ['production_order' => $pOrder]);
}
}
public function printItemSerial()
{
$pOrder = trim($this->form->getState()['production_order'] ?? '') ?? null;
@@ -378,6 +414,7 @@ class CreateProductionOrder extends CreateRecord
}
}
protected function getFormActions(): array
{
return [];

View File

@@ -49,6 +49,42 @@ class EditProductionOrder extends EditRecord
}
}
public function printProductionOrderSecond()
{
$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.print2', ['production_order' => $pOrder]);
}
}
public function printPanel()
{
$plantId = $this->form->getState()['plant_id'] ?? null;

View File

@@ -50,6 +50,42 @@ class ViewProductionOrder extends ViewRecord
}
}
public function printProductionOrderSecond()
{
$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.print2', ['production_order' => $pOrder]);
}
}
public function printPanel()
{
$plantId = $this->form->getState()['plant_id'] ?? null;

View File

@@ -72,6 +72,57 @@ class ProductionOrderController extends Controller
}
}
public function print2($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, 100);
$qrBase64 = base64_encode($qrBinary);
$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, 28.35]);
$pdf = Pdf::loadView('production-orders.print2', compact('stickers'))
->setPaper([0, 0, 170.0787, 28.3465]);
return $pdf->stream('stickers.pdf');
}
}
public function printpanel($production_order, $plantCode){
\Log::info('Print Panel Started', [

View File

@@ -18,6 +18,15 @@ class="px-2 py-1 border border-primary-500 text-primary-600 rounded hover:bg-pri
Print
</button>
@endcan
@can('view print production order 2 button')
<button
type="button"
wire:click="printProductionOrderSecond"
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 2
</button>
@endcan
@can('view print panel production order button')
<button
type="button"

View File

@@ -0,0 +1,100 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<style>
@page { margin: 0; }
html, body {
margin: 0;
padding: 0;
font-size: 6pt;
line-height: 1;
}
.sticker {
width: 170pt;
height: 24pt; /* clearly less than 28.35pt page */
overflow: hidden;
}
table { width: 100%; border-collapse: collapse; }
td { padding: 0; margin: 0; vertical-align: top; line-height: 1; }
.qr {
display: block;
width: 24pt;
height: 24pt;
margin-top: 2pt;
margin-left: 4pt;
}
.text {
position: relative;
padding-left: 5pt;
}
.serial {
font-size: 8pt;
font-weight: bold;
position: relative;
top: 3pt;
right:5pt;
}
.po {
font-size: 8pt;
font-weight: bold;
position: absolute;
right: 5pt;
top: 3pt;
}
.po-long {
font-size: 8pt;
font-weight: bold;
text-align: right;
position: absolute;
right: 5pt;
top: 2pt;
width: 69pt;
}
.desc {
font-family: "Arial Narrow";
font-size: 7pt;
font-weight: bold;
letter-spacing: -0.3px;
white-space: nowrap;
position: relative;
top: 9pt;
margin-left: -5pt;
width: 125pt;
overflow: hidden;
}
</style>
</head>
<body>
@foreach($stickers as $sticker)
<div class="sticker">
<table>
<tr>
<td style="width:28pt;">
<img class="qr" src="{{ $sticker['qr'] }}">
</td>
<td class="text">
<div class="serial">{{ $sticker['serial'] }}</div>
<div class="{{ strlen($sticker['serial']) > 14 ? 'po-long' : 'po' }}">
{{ $sticker['production_order'] }}
</div>
<div class="desc">{{ $sticker['description'] }}</div>
</td>
</tr>
</table>
</div>
@endforeach
</body>
</html>