ranjith-dev #625
@@ -24,7 +24,7 @@ class ProductionOrderImporter extends Importer
|
|||||||
->requiredMapping()
|
->requiredMapping()
|
||||||
->label('PLANT CODE')
|
->label('PLANT CODE')
|
||||||
->exampleHeader('PLANT CODE')
|
->exampleHeader('PLANT CODE')
|
||||||
->example('1000')
|
->example('TEST007')
|
||||||
->relationship(resolveUsing: 'code')
|
->relationship(resolveUsing: 'code')
|
||||||
->rules(['required']),
|
->rules(['required']),
|
||||||
ImportColumn::make('item')
|
ImportColumn::make('item')
|
||||||
|
|||||||
@@ -247,6 +247,18 @@ class ProductionOrderResource extends Resource
|
|||||||
->searchable()
|
->searchable()
|
||||||
->alignCenter()
|
->alignCenter()
|
||||||
->sortable(),
|
->sortable(),
|
||||||
|
Tables\Columns\TextColumn::make('item.description')
|
||||||
|
->label('Item Description')
|
||||||
|
->searchable()
|
||||||
|
->alignCenter()
|
||||||
|
->sortable()
|
||||||
|
->toggleable(isToggledHiddenByDefault: true),
|
||||||
|
Tables\Columns\TextColumn::make('item.uom')
|
||||||
|
->label('Unit of Measure')
|
||||||
|
->searchable()
|
||||||
|
->alignCenter()
|
||||||
|
->sortable()
|
||||||
|
->toggleable(isToggledHiddenByDefault: true),
|
||||||
Tables\Columns\TextColumn::make('quantity')
|
Tables\Columns\TextColumn::make('quantity')
|
||||||
->label('Quantity')
|
->label('Quantity')
|
||||||
->searchable()
|
->searchable()
|
||||||
|
|||||||
@@ -216,6 +216,8 @@ class CreateProductionOrder extends CreateRecord
|
|||||||
|
|
||||||
$plantId = trim($this->form->getState()['plant_id'] ?? '') ?? null;
|
$plantId = trim($this->form->getState()['plant_id'] ?? '') ?? null;
|
||||||
|
|
||||||
|
$plantCode = Plant::where('id', $plantId)->value('code');
|
||||||
|
|
||||||
if (empty($plantId)) {
|
if (empty($plantId)) {
|
||||||
Notification::make()
|
Notification::make()
|
||||||
->title('Plant name cannot be empty!')
|
->title('Plant name cannot be empty!')
|
||||||
@@ -239,7 +241,7 @@ class CreateProductionOrder extends CreateRecord
|
|||||||
->send();
|
->send();
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
return redirect()->route('production-orders.printItemSerial', ['production_order' => $pOrder]);
|
return redirect()->route('production-orders.printItemSerial', ['production_order' => $pOrder, 'plant_code' => $plantCode]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -89,36 +89,107 @@ class EditProductionOrder extends EditRecord
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function printItemSerial()
|
// public function printItemSerial()
|
||||||
|
// {
|
||||||
|
// $pOrder = trim($this->form->getState()['production_order'] ?? '') ?? null;
|
||||||
|
|
||||||
|
// $plantId = trim($this->form->getState()['plant_id'] ?? '') ?? null;
|
||||||
|
// $plantCode = Plant::where('id', $plantId)->value('code');
|
||||||
|
// 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, 'plant_code' => $plantCode]);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
public function printitemserial($production_order, $plantCode)
|
||||||
{
|
{
|
||||||
$pOrder = trim($this->form->getState()['production_order'] ?? '') ?? null;
|
$order = ProductionOrder::where('production_order', $production_order)->first();
|
||||||
|
|
||||||
$plantId = trim($this->form->getState()['plant_id'] ?? '') ?? null;
|
if (!$order) {
|
||||||
$plantCode = Plant::where('id', $plantId)->value('code');
|
abort(404, 'Production Order not found');
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
else{
|
||||||
|
$fromSerial = (int) $order->from_serial_number;
|
||||||
|
$toSerial = (int) $order->to_serial_number;
|
||||||
|
$itemCode = $order->item->code ?? '';
|
||||||
|
$itemDes = $order->item->description ?? '';
|
||||||
|
|
||||||
$pOrderExists = ProductionOrder::where('plant_id', $plantId)->where('production_order', $pOrder)->first();
|
$wareHouseNo = Plant::where('code', $plantCode)->first();
|
||||||
|
|
||||||
if (! $pOrderExists) {
|
$wareNo = $wareHouseNo->warehouse_number ?? null;
|
||||||
Notification::make()
|
|
||||||
->title("Production Order '{$pOrder}' does not exist to get print!")
|
$now = Carbon::now();
|
||||||
->danger()
|
$year = $now->format('y');
|
||||||
->send();
|
$month = $now->format('m');
|
||||||
return;
|
|
||||||
} else {
|
$stickers = [];
|
||||||
return redirect()->route('production-orders.printItemSerial', ['production_order' => $pOrder, 'plant_code' => $plantCode]);
|
|
||||||
|
for ($i = $fromSerial; $i <= $toSerial; $i++)
|
||||||
|
{
|
||||||
|
|
||||||
|
$serial = str_pad($i, 6, '0', STR_PAD_LEFT);
|
||||||
|
|
||||||
|
if(!empty($wareNo)){
|
||||||
|
$serial = substr($serial, 0, 4) . $wareNo . substr($serial, 4);
|
||||||
|
$qrData = $itemCode . '|' . $serial;
|
||||||
|
} else {
|
||||||
|
$qrData = $itemCode . '|' . $serial;
|
||||||
|
$serial = str_pad($i, 6, '0', STR_PAD_LEFT);
|
||||||
|
}
|
||||||
|
|
||||||
|
// $qrData = $itemCode . '|' . $serial;
|
||||||
|
|
||||||
|
// $serialCount = substr(str_pad($i, 6, '0', STR_PAD_LEFT), -6);
|
||||||
|
|
||||||
|
// $serialWithWarehouse = substr($serial, 0, 4) . $wareNo . substr($serial, 4);
|
||||||
|
|
||||||
|
// $qrData = $itemCode . '|' . $serialWithWarehouse;
|
||||||
|
|
||||||
|
// $panel = $plantCode . $wareNo . '/' . $itemCode . '/' . $year.$month . '/' . $serialCount;
|
||||||
|
|
||||||
|
// $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');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -89,38 +89,109 @@ class ViewProductionOrder extends ViewRecord
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function printItemSerial()
|
// public function printItemSerial()
|
||||||
|
// {
|
||||||
|
// $pOrder = trim($this->form->getState()['production_order'] ?? '') ?? null;
|
||||||
|
|
||||||
|
// $plantId = trim($this->form->getState()['plant_id'] ?? '') ?? null;
|
||||||
|
|
||||||
|
// $plantCode = Plant::where('id', $plantId)->value('code');
|
||||||
|
|
||||||
|
// 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, 'plant_code' => $plantCode]);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
public function printitemserial($production_order, $plantCode)
|
||||||
{
|
{
|
||||||
$pOrder = trim($this->form->getState()['production_order'] ?? '') ?? null;
|
$order = ProductionOrder::where('production_order', $production_order)->first();
|
||||||
|
|
||||||
$plantId = trim($this->form->getState()['plant_id'] ?? '') ?? null;
|
if (!$order) {
|
||||||
|
abort(404, 'Production Order not found');
|
||||||
$plantCode = Plant::where('id', $plantId)->value('code');
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
else{
|
||||||
|
$fromSerial = (int) $order->from_serial_number;
|
||||||
|
$toSerial = (int) $order->to_serial_number;
|
||||||
|
$itemCode = $order->item->code ?? '';
|
||||||
|
$itemDes = $order->item->description ?? '';
|
||||||
|
|
||||||
$pOrderExists = ProductionOrder::where('plant_id', $plantId)->where('production_order', $pOrder)->first();
|
$wareHouseNo = Plant::where('code', $plantCode)->first();
|
||||||
|
|
||||||
if (! $pOrderExists) {
|
$wareNo = $wareHouseNo->warehouse_number ?? null;
|
||||||
Notification::make()
|
|
||||||
->title("Production Order '{$pOrder}' does not exist to get print!")
|
$now = Carbon::now();
|
||||||
->danger()
|
$year = $now->format('y');
|
||||||
->send();
|
$month = $now->format('m');
|
||||||
return;
|
|
||||||
} else {
|
$stickers = [];
|
||||||
return redirect()->route('production-orders.printItemSerial', ['production_order' => $pOrder, 'plant_code' => $plantCode]);
|
|
||||||
|
for ($i = $fromSerial; $i <= $toSerial; $i++)
|
||||||
|
{
|
||||||
|
|
||||||
|
$serial = str_pad($i, 6, '0', STR_PAD_LEFT);
|
||||||
|
|
||||||
|
if(!empty($wareNo)){
|
||||||
|
$serial = substr($serial, 0, 4) . $wareNo . substr($serial, 4);
|
||||||
|
$qrData = $itemCode . '|' . $serial;
|
||||||
|
} else {
|
||||||
|
$qrData = $itemCode . '|' . $serial;
|
||||||
|
$serial = str_pad($i, 6, '0', STR_PAD_LEFT);
|
||||||
|
}
|
||||||
|
|
||||||
|
// $qrData = $itemCode . '|' . $serial;
|
||||||
|
|
||||||
|
// $serialCount = substr(str_pad($i, 6, '0', STR_PAD_LEFT), -6);
|
||||||
|
|
||||||
|
// $serialWithWarehouse = substr($serial, 0, 4) . $wareNo . substr($serial, 4);
|
||||||
|
|
||||||
|
// $qrData = $itemCode . '|' . $serialWithWarehouse;
|
||||||
|
|
||||||
|
// $panel = $plantCode . $wareNo . '/' . $itemCode . '/' . $year.$month . '/' . $serialCount;
|
||||||
|
|
||||||
|
// $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');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ class ProductionOrderController extends Controller
|
|||||||
$qrCode = new QrCode($qrData);
|
$qrCode = new QrCode($qrData);
|
||||||
$output = new Output\Png;
|
$output = new Output\Png;
|
||||||
// $qrBinary = $output->output($qrCode, 100);
|
// $qrBinary = $output->output($qrCode, 100);
|
||||||
$qrBinary = $output->output($qrCode, 600);
|
$qrBinary = $output->output($qrCode, 100);
|
||||||
$qrBase64 = base64_encode($qrBinary);
|
$qrBase64 = base64_encode($qrBinary);
|
||||||
|
|
||||||
$stickers[] = [
|
$stickers[] = [
|
||||||
@@ -164,14 +164,21 @@ class ProductionOrderController extends Controller
|
|||||||
|
|
||||||
$serial = str_pad($i, 6, '0', STR_PAD_LEFT);
|
$serial = str_pad($i, 6, '0', STR_PAD_LEFT);
|
||||||
|
|
||||||
|
if(!empty($wareNo)){
|
||||||
|
$serial = substr($serial, 0, 4) . $wareNo . substr($serial, 4);
|
||||||
|
$qrData = $itemCode . '|' . $serial;
|
||||||
|
} else {
|
||||||
|
$qrData = $itemCode . '|' . $serial;
|
||||||
|
$serial = str_pad($i, 6, '0', STR_PAD_LEFT);
|
||||||
|
}
|
||||||
|
|
||||||
// $qrData = $itemCode . '|' . $serial;
|
// $qrData = $itemCode . '|' . $serial;
|
||||||
|
|
||||||
$serial = str_pad($i, 6, '0', STR_PAD_LEFT);
|
// $serialCount = substr(str_pad($i, 6, '0', STR_PAD_LEFT), -6);
|
||||||
$serialCount = substr(str_pad($i, 6, '0', STR_PAD_LEFT), -6);
|
|
||||||
|
|
||||||
$serialWithWarehouse = substr($serial, 0, 4) . $wareNo . substr($serial, 4);
|
// $serialWithWarehouse = substr($serial, 0, 4) . $wareNo . substr($serial, 4);
|
||||||
|
|
||||||
$qrData = $itemCode . '|' . $serialWithWarehouse;
|
// $qrData = $itemCode . '|' . $serialWithWarehouse;
|
||||||
|
|
||||||
// $panel = $plantCode . $wareNo . '/' . $itemCode . '/' . $year.$month . '/' . $serialCount;
|
// $panel = $plantCode . $wareNo . '/' . $itemCode . '/' . $year.$month . '/' . $serialCount;
|
||||||
|
|
||||||
@@ -186,7 +193,7 @@ class ProductionOrderController extends Controller
|
|||||||
$qrBase64 = base64_encode($qrBinary);
|
$qrBase64 = base64_encode($qrBinary);
|
||||||
|
|
||||||
$stickers[] = [
|
$stickers[] = [
|
||||||
'serial' => $serialWithWarehouse,
|
'serial' => $serial,
|
||||||
'qr' => 'data:image/png;base64,' . $qrBase64,
|
'qr' => 'data:image/png;base64,' . $qrBase64,
|
||||||
'production_order' => $itemCode,
|
'production_order' => $itemCode,
|
||||||
'description' => $itemDes ?? ''
|
'description' => $itemDes ?? ''
|
||||||
|
|||||||
Reference in New Issue
Block a user