Merge pull request 'ranjith-dev' (#975) from ranjith-dev into master
All checks were successful
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 13s
All checks were successful
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 13s
Reviewed-on: #975
This commit was merged in pull request #975.
This commit is contained in:
301
app/Filament/Pages/SpareMasterPrint.php
Normal file
301
app/Filament/Pages/SpareMasterPrint.php
Normal file
@@ -0,0 +1,301 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Pages;
|
||||
|
||||
use Filament\Pages\Page;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Filament\Forms\Concerns\InteractsWithForms;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Forms\Components\Section;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Notifications\Notification;
|
||||
use App\Models\SaleOrderMaster;
|
||||
use App\Models\Plant;
|
||||
use App\Models\SparePacking;
|
||||
use Filament\Facades\Filament;
|
||||
|
||||
class SpareMasterPrint extends Page
|
||||
{
|
||||
protected static ?string $navigationIcon = 'heroicon-o-document-text';
|
||||
|
||||
protected static string $view = 'filament.pages.spare-master-print';
|
||||
|
||||
protected static ?string $navigationGroup = 'Spare Packing';
|
||||
|
||||
use InteractsWithForms;
|
||||
|
||||
public $pId, $palletNo, $serialNo;
|
||||
public $snoCount = 0;
|
||||
|
||||
public bool $disableSerialNo = false;
|
||||
public bool $disablePalletNo = false;
|
||||
|
||||
public $locatorNumber;
|
||||
public $state = [];
|
||||
|
||||
public $plantId;
|
||||
|
||||
public $scanLocator;
|
||||
|
||||
public $locators;
|
||||
|
||||
public array $filters = [];
|
||||
|
||||
public function mount()
|
||||
{
|
||||
$this->form->fill([
|
||||
'plant_id'=>$this->plantId,
|
||||
'pallet_quantity' => 0,
|
||||
]);
|
||||
}
|
||||
|
||||
public function form(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
->statePath('filters')
|
||||
->schema([
|
||||
Section::make('')
|
||||
->schema([
|
||||
Select::make('plant_id')
|
||||
->label('Plant')
|
||||
->reactive()
|
||||
// ->options(Plant::pluck('name', 'id'))
|
||||
->options(function (callable $get) {
|
||||
$userHas = Filament::auth()->user()->plant_id;
|
||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
|
||||
})
|
||||
->required(),
|
||||
Select::make('sale_order_master_id')
|
||||
->label('Sale Order Number')
|
||||
->reactive()
|
||||
->searchable()
|
||||
->options(function (callable $get) {
|
||||
$plantId = $get('plant_id');
|
||||
if (empty($plantId)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return SaleOrderMaster::where('plant_id', $plantId)->distinct()->pluck('sale_order_number', 'sale_order_number'); //->pluck('customer_po', 'id'); ->distinct()
|
||||
})
|
||||
->required()
|
||||
->afterStateUpdated(function ($state, callable $set) {
|
||||
$set('scan_pallet_no', null);
|
||||
}),
|
||||
Select::make('scan_pallet_no')
|
||||
->label('Scan Pallet No')
|
||||
->reactive()
|
||||
->searchable()
|
||||
->options(function ($get) {
|
||||
|
||||
$plantId = $get('plant_id');
|
||||
$saleOrder = $get('sale_order_master_id');
|
||||
|
||||
if (! $plantId || ! $saleOrder)
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
$poIds = SaleOrderMaster::where('plant_id', $plantId)->where('sale_order_number', $saleOrder)->pluck('id');
|
||||
$palletNumbers = SparePacking::query()
|
||||
->where('plant_id', $plantId)
|
||||
->whereIn('sale_order_master_id', $poIds)
|
||||
->whereNotNull('spare_packing_number')
|
||||
->groupBy('spare_packing_number')
|
||||
->havingRaw('COUNT(*) = COUNT(spare_packing_status)')
|
||||
->havingRaw("SUM(CASE WHEN TRIM(spare_packing_status) = '' THEN 1 ELSE 0 END) = 0")
|
||||
->orderBy('spare_packing_number')
|
||||
->pluck('spare_packing_number')
|
||||
->toArray();
|
||||
return collect($palletNumbers) ->mapWithKeys(fn ($number) => [$number => $number]) ->toArray();
|
||||
})
|
||||
->afterStateUpdated(function ($state, callable $set, $get) {
|
||||
$palletNo = $state;
|
||||
$plantId = $get('plant_id');
|
||||
|
||||
$this->dispatch('loadData', $palletNo, $plantId);
|
||||
})
|
||||
->extraAttributes([
|
||||
'wire:keydown.enter' => 'processPalletNo($event.target.value)',
|
||||
]),
|
||||
// TextInput::make('customer_name')
|
||||
// ->label('Customer Name')
|
||||
// ->required()
|
||||
// ->reactive(),
|
||||
])
|
||||
->columns(3)
|
||||
]);
|
||||
}
|
||||
|
||||
public function processPalletNo($palletNo)
|
||||
{
|
||||
$plantId = $this->form->getState()['plant_id'];
|
||||
|
||||
$plantId = trim($plantId) ?? null;
|
||||
|
||||
$palletNo= $this->form->getState()['scan_pallet_no'];
|
||||
|
||||
$palletNo = trim($palletNo) ?? null;
|
||||
|
||||
$operatorName = Filament::auth()->user()->name;
|
||||
|
||||
if ($palletNo == null || $palletNo == '')
|
||||
{
|
||||
Notification::make()
|
||||
->title("Pallet number can't be empty!")
|
||||
->danger()
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadLocator' ,'',$plantId);
|
||||
$this->form->fill
|
||||
([
|
||||
'plant_id' => $plantId,
|
||||
'scan_serial_no' => null,
|
||||
'scan_pallet_no' => null,
|
||||
'scan_locator_no' => null,
|
||||
'pallet_quantity' => 0,
|
||||
'created_by' => $operatorName,
|
||||
'scanned_by' => $operatorName,
|
||||
]);
|
||||
return;
|
||||
}
|
||||
// else if (strlen($palletNo) < 10)
|
||||
// {
|
||||
// Notification::make()
|
||||
// ->title("Pallet number '$palletNo' must be at least 10 digits.")
|
||||
// ->danger()
|
||||
// ->duration(5000)
|
||||
// ->send();
|
||||
|
||||
// $this->dispatch('loadLocator' ,'',$plantId);
|
||||
// $this->form->fill
|
||||
// ([
|
||||
// 'plant_id' => $plantId,
|
||||
// 'scan_serial_no' => null,
|
||||
// 'scan_pallet_no' => null,
|
||||
// 'scan_locator_no' => null,
|
||||
// 'pallet_quantity' => 0,
|
||||
// 'created_by' => $operatorName,
|
||||
// 'scanned_by' => $operatorName,
|
||||
// ]);
|
||||
// return;
|
||||
// }
|
||||
|
||||
$Palletexists = WireMasterPacking::where('wire_packing_number', $palletNo)
|
||||
->where('plant_id', $plantId)->first();
|
||||
if(!$Palletexists)
|
||||
{
|
||||
Notification::make()
|
||||
->title("Pallet number '$palletNo' does not found in wire master packing table.")
|
||||
->danger()
|
||||
->duration(5000)
|
||||
->send();
|
||||
|
||||
$this->dispatch('loadData' ,'',$plantId);
|
||||
$this->form->fill
|
||||
([
|
||||
'plant_id' => $plantId,
|
||||
'scan_pallet_no' => null,
|
||||
'pallet_quantity' => 0,
|
||||
'created_by' => $operatorName,
|
||||
'scanned_by' => $operatorName,
|
||||
]);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->snoCount = WireMasterPacking::where('plant_id', $plantId)
|
||||
->where('wire_packing_number', $palletNo)
|
||||
->count();
|
||||
|
||||
$this->dispatch('loadData', $palletNo, $plantId);
|
||||
$this->form->fill
|
||||
([
|
||||
'plant_id' => $plantId,
|
||||
'scan_pallet_no' => $palletNo,
|
||||
'pallet_quantity' => $this->snoCount,
|
||||
'created_by' => $operatorName,
|
||||
'scanned_by' => $operatorName,
|
||||
]);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public function saveCustomerPO(){
|
||||
$plantId = $this->form->getState()['plant_id'];
|
||||
|
||||
$plantId = trim($plantId) ?? null;
|
||||
|
||||
$palletNo= $this->form->getState()['scan_pallet_no'];
|
||||
|
||||
$palletNo = trim($palletNo) ?? null;
|
||||
|
||||
$customerPO = $this->form->getState()['customer_po'];
|
||||
|
||||
$customerPO = trim($customerPO) ?? null;
|
||||
|
||||
$customerName = $this->form->getState()['customer_name'];
|
||||
|
||||
$customerName = trim($customerName) ?? null;
|
||||
|
||||
if (!$plantId || !$palletNo) {
|
||||
return; // optional validation
|
||||
}
|
||||
|
||||
$record = WireMasterPacking::where('plant_id', $plantId)
|
||||
->where('wire_packing_number', $palletNo)
|
||||
->update([
|
||||
'customer_po' => $customerPO,
|
||||
'customer_name' => $customerName,
|
||||
'updated_at' => now(),
|
||||
]);
|
||||
|
||||
if($record){
|
||||
Notification::make()
|
||||
->title("Customer PO updated successfully for the pallet number '$palletNo'")
|
||||
->success()
|
||||
->send();
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
Notification::make()
|
||||
->title("Customer PO updation failed for the pallet number '$palletNo'")
|
||||
->success()
|
||||
->send();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public function printPallet()
|
||||
{
|
||||
$palletNumber = $this->form->getState()['scan_pallet_no'] ?? null;
|
||||
$plantId = $this->form->getState()['plant_id'] ?? null;
|
||||
$customerId = $this->form->getState()['customer_po_master_id'] ?? null;
|
||||
|
||||
$state = $this->form->getState();
|
||||
|
||||
// $customerCode = $state['customer_po'] ?? null;
|
||||
// $customerName = $state['customer_name'] ?? null;
|
||||
|
||||
if (!$palletNumber) {
|
||||
Notification::make()
|
||||
->title("Pallet number cant't be empty!")
|
||||
->danger()
|
||||
->duration(5000)
|
||||
->send();
|
||||
return;
|
||||
}
|
||||
|
||||
$this->dispatch('open-pdf', url: route('print.sparepallet', [
|
||||
'pallet' => $state['scan_pallet_no'],
|
||||
'plant' => $state['plant_id'],
|
||||
'customer' => $state['sale_order_master_id'],
|
||||
]));
|
||||
}
|
||||
|
||||
public static function canAccess(): bool
|
||||
{
|
||||
return Auth::check() && Auth::user()->can('view spare master print page');
|
||||
}
|
||||
}
|
||||
@@ -95,6 +95,7 @@ class RequestCharacteristicResource extends Resource
|
||||
$set('machine_id', null);
|
||||
$set('item_id', null);
|
||||
$set('aufnr', null);
|
||||
$set('gernr', null);
|
||||
$set('machine_name', null);
|
||||
$set('characteristic_approver_master_id', null);
|
||||
$set('approver_type', null);
|
||||
@@ -126,6 +127,7 @@ class RequestCharacteristicResource extends Resource
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
$set('item_id', null);
|
||||
$set('aufnr', null);
|
||||
$set('gernr', null);
|
||||
$set('machine_name', null);
|
||||
$set('characteristic_approver_master_id', null);
|
||||
$set('approver_type', null);
|
||||
@@ -213,6 +215,7 @@ class RequestCharacteristicResource extends Resource
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
if (! $state) {
|
||||
$set('aufnr', null);
|
||||
$set('gernr', null);
|
||||
}
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
@@ -237,6 +240,9 @@ class RequestCharacteristicResource extends Resource
|
||||
return false;
|
||||
})
|
||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||
if (! $state) {
|
||||
$set('gernr', null);
|
||||
}
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->default(function () {
|
||||
@@ -246,6 +252,32 @@ class RequestCharacteristicResource extends Resource
|
||||
})
|
||||
->readOnly(fn ($get) => ($get('item_id') == null))
|
||||
->disabled(fn ($get) => self::isFieldDisabled($get)),
|
||||
Forms\Components\TextInput::make('gernr')
|
||||
->label('Serial Number')
|
||||
->reactive()
|
||||
->minLength(13)
|
||||
->readOnly(fn (callable $get) => (! $get('aufnr')))
|
||||
->afterStateUpdated(function (callable $set) {
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
// ->rules([
|
||||
// function (callable $get) {
|
||||
// return Rule::unique('class_characteristics', 'gernr')
|
||||
// ->where('plant_id', $get('plant_id'))
|
||||
// ->ignore($get('id'));
|
||||
// },
|
||||
// ])
|
||||
// ->validationMessages([
|
||||
// 'unique' => "The 'GERNR' has already been taken.", // The GERNR has already been taken for this plant.
|
||||
// ])
|
||||
->required(function (callable $get) {
|
||||
$appTyp = $get('approver_type');
|
||||
if ($appTyp == 'Stop') {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}),
|
||||
Forms\Components\Select::make('machine_name')
|
||||
->label('Machine Name')
|
||||
->reactive()
|
||||
@@ -333,6 +365,9 @@ class RequestCharacteristicResource extends Resource
|
||||
$set('current_value', null);
|
||||
$set('update_value', null);
|
||||
}
|
||||
if ($appTyp != 'Stop') {
|
||||
$set('gernr', null);
|
||||
}
|
||||
$set('updated_by', Filament::auth()->user()?->name);
|
||||
})
|
||||
->default(function () {
|
||||
@@ -443,8 +478,9 @@ class RequestCharacteristicResource extends Resource
|
||||
|
||||
$plantId = $get('plant_id');
|
||||
$jobNo = $get('aufnr');
|
||||
$sNo = $get('gernr');
|
||||
$updId = $get('id');
|
||||
$pendingExists = RequestCharacteristic::where('plant_id', $plantId)->where('aufnr', $jobNo)->where('characteristic_name', $value)->latest()->first();
|
||||
$pendingExists = RequestCharacteristic::where('plant_id', $plantId)->where('aufnr', $jobNo)->where('gernr', $sNo)->where('characteristic_name', $value)->latest()->first();
|
||||
|
||||
if ($pendingExists) {
|
||||
if ($updId && $pendingExists->id == $updId) {
|
||||
@@ -966,6 +1002,11 @@ class RequestCharacteristicResource extends Resource
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('gernr')
|
||||
->label('Serial Number')
|
||||
->alignCenter()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('characteristicApproverMaster.machine_name')
|
||||
->label('Machine Name')
|
||||
->alignCenter()
|
||||
@@ -1236,8 +1277,11 @@ class RequestCharacteristicResource extends Resource
|
||||
->label('Job Number')
|
||||
->placeholder('Enter Job Number')
|
||||
->numeric()
|
||||
->minlength(7)
|
||||
->maxlength(10),
|
||||
TextInput::make('gernr')
|
||||
->label('Serial Number')
|
||||
->placeholder('Enter Serial Number')
|
||||
->numeric(),
|
||||
TextInput::make('work_flow_id')
|
||||
->label('Work Flow ID')
|
||||
->placeholder('Enter Work Flow ID'),
|
||||
@@ -1313,7 +1357,7 @@ class RequestCharacteristicResource extends Resource
|
||||
])
|
||||
->query(function ($query, array $data) {
|
||||
// Hide all records initially if no filters are applied
|
||||
if (empty($data['Plant']) && empty($data['machine']) && empty($data['item_id']) && empty($data['aufnr']) && empty($data['model_type']) && empty($data['work_flow_id']) && empty($data['machine_name']) && empty($data['request_type']) && empty($data['master_characteristic_field']) && empty($data['approver_status1']) && empty($data['approver_status2']) && empty($data['approver_status3']) && empty($data['approver_status']) && empty($data['created_from']) && empty($data['created_to'])) {
|
||||
if (empty($data['Plant']) && empty($data['machine']) && empty($data['item_id']) && empty($data['aufnr']) && empty($data['gernr']) && empty($data['model_type']) && empty($data['work_flow_id']) && empty($data['machine_name']) && empty($data['request_type']) && empty($data['master_characteristic_field']) && empty($data['approver_status1']) && empty($data['approver_status2']) && empty($data['approver_status3']) && empty($data['approver_status']) && empty($data['created_from']) && empty($data['created_to'])) {
|
||||
return $query->whereRaw('1 = 0');
|
||||
}
|
||||
|
||||
@@ -1339,6 +1383,10 @@ class RequestCharacteristicResource extends Resource
|
||||
$query->where('aufnr', 'like', '%'.$data['aufnr'].'%');
|
||||
}
|
||||
|
||||
if (! empty($data['gernr'])) {
|
||||
$query->where('gernr', 'like', '%'.$data['gernr'].'%');
|
||||
}
|
||||
|
||||
if (! empty($data['model_type'])) {
|
||||
$query->where('model_type', 'like', '%'.$data['model_type'].'%');
|
||||
}
|
||||
@@ -1436,6 +1484,10 @@ class RequestCharacteristicResource extends Resource
|
||||
$indicators[] = 'Job No: '.$data['aufnr'];
|
||||
}
|
||||
|
||||
if (! empty($data['gernr'])) {
|
||||
$indicators[] = 'Serial No: '.$data['gernr'];
|
||||
}
|
||||
|
||||
if (! empty($data['model_type'])) {
|
||||
$indicators[] = 'Model Type: '.$data['model_type'];
|
||||
}
|
||||
|
||||
@@ -4,6 +4,8 @@ namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\CustomerPoMaster;
|
||||
use App\Models\Plant;
|
||||
use App\Models\SaleOrderMaster;
|
||||
use App\Models\SparePacking;
|
||||
use App\Models\WireMasterPacking;
|
||||
use Barryvdh\DomPDF\Facade\Pdf;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -279,9 +281,6 @@ class PalletPrintController extends Controller
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
//
|
||||
@@ -310,4 +309,101 @@ class PalletPrintController extends Controller
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
public function printSpare(Request $request, $pallet, $plant)
|
||||
{
|
||||
|
||||
$customerPoMasterId = SparePacking::where('plant_id', $plant)
|
||||
->where('spare_packing_number', $pallet)
|
||||
->value('sale_order_master_id');
|
||||
|
||||
$masterIds = SparePacking::where('plant_id', $plant)
|
||||
->where('spare_packing_number', $pallet)
|
||||
->pluck('sale_order_master_id');
|
||||
|
||||
$customerPo = SaleOrderMaster::whereIn('id', $masterIds)
|
||||
->value('sale_order_number');
|
||||
|
||||
$customerPoMasterIds = SaleOrderMaster::where('sale_order_number', $customerPo)
|
||||
->pluck('id');
|
||||
|
||||
$items = SparePacking::with('item')
|
||||
->where('plant_id', $plant)
|
||||
->where('spare_packing_number', $pallet)
|
||||
->get()
|
||||
->map(function ($row) {
|
||||
return (object) [
|
||||
'code' => $row->item->code,
|
||||
'description' => $row->item->description,
|
||||
'box_count' => 1, // each row = one box
|
||||
'weight' => $row->quantity,
|
||||
];
|
||||
});
|
||||
|
||||
$customer = SaleOrderMaster::find($customerPoMasterId);
|
||||
|
||||
$customerCode = $customer->sale_order_number ?? '';
|
||||
$customerName = $customer->supplier_name ?? '';
|
||||
|
||||
$totalBoxes = SparePacking::where('plant_id', $plant)
|
||||
->whereIn('sale_order_master_id', $customerPoMasterIds)
|
||||
->select('spare_packing_number')
|
||||
->groupBy('spare_packing_number')
|
||||
->havingRaw(
|
||||
'COUNT(*) = COUNT(CASE WHEN spare_packing_status = ? THEN 1 END)',
|
||||
['Completed']
|
||||
)
|
||||
->count();
|
||||
|
||||
$completedPallets = SparePacking::where('plant_id', $plant)
|
||||
->whereIn('sale_order_master_id', $customerPoMasterIds)
|
||||
->select('spare_packing_number')
|
||||
->groupBy('spare_packing_number')
|
||||
->havingRaw(
|
||||
'COUNT(*) = COUNT(CASE WHEN spare_packing_status = ? THEN 1 END)',
|
||||
['Completed']
|
||||
)
|
||||
->orderBy('spare_packing_number')
|
||||
->pluck('spare_packing_number')
|
||||
->values();
|
||||
|
||||
$index = $completedPallets->search($pallet);
|
||||
|
||||
$currentPalletNo = ($index !== false) ? $index + 1 : 0;
|
||||
|
||||
$boxLabel = $currentPalletNo.'/'.$totalBoxes;
|
||||
|
||||
$grossWeight = $items->sum('weight');
|
||||
$widthPt = 85 * 2.83465; // 85mm → points
|
||||
$heightPt = 100 * 2.83465; // 100mm → points
|
||||
|
||||
$plantName = Plant::where('id', $plant)->value('name');
|
||||
|
||||
$plantAddress = Plant::where('id', $plant)->value('address');
|
||||
|
||||
$scannedAt = SparePacking::where('plant_id', $plant)
|
||||
->where('spare_packing_number', $pallet)
|
||||
->value('scanned_at');
|
||||
|
||||
$pdf = Pdf::loadView('pdf.spare-pallet', [
|
||||
'product' => 'Spare Packing List',
|
||||
'plantName' => $plantName,
|
||||
'plantAddress' => $plantAddress,
|
||||
// 'monthYear' => now()->format('M-y'),
|
||||
'monthYear' => $scannedAt
|
||||
? \Carbon\Carbon::parse($scannedAt)->format('M-y')
|
||||
: '',
|
||||
'branch' => '',
|
||||
'customerCode' => $customerCode,
|
||||
'customerName' => $customerName,
|
||||
'masterBox' => $boxLabel,
|
||||
'items' => $items,
|
||||
'grossWeight' => $grossWeight + 3.050,
|
||||
'netWeight' => $grossWeight,
|
||||
'pallet' => $pallet,
|
||||
])->setPaper([0, 0, $widthPt, $heightPt], 'portrait');
|
||||
|
||||
return $pdf->stream("Pallet-{$pallet}.pdf");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ class RequestCharacteristic extends Model
|
||||
'item_id',
|
||||
'characteristic_approver_master_id',
|
||||
'aufnr',
|
||||
'gernr',
|
||||
'characteristic_name',
|
||||
'current_value',
|
||||
'update_value',
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
namespace App\Policies;
|
||||
|
||||
use Illuminate\Auth\Access\Response;
|
||||
use App\Models\SparePacking;
|
||||
use App\Models\User;
|
||||
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
// use Illuminate\Database\Schema\Blueprint;
|
||||
// use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
$sql1 = <<<'SQL'
|
||||
ALTER TABLE request_characteristics
|
||||
ADD COLUMN gernr TEXT DEFAULT NULL
|
||||
SQL;
|
||||
|
||||
DB::statement($sql1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
// Schema::table('request_characteristics', function (Blueprint $table) {
|
||||
// //
|
||||
// });
|
||||
}
|
||||
};
|
||||
36
resources/views/filament/pages/spare-master-print.blade.php
Normal file
36
resources/views/filament/pages/spare-master-print.blade.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<x-filament-panels::page>
|
||||
|
||||
<div class="space-y-4">
|
||||
{{-- Render the Select form fields --}}
|
||||
<div class="space-y-4">
|
||||
{{ $this->form }}
|
||||
</div>
|
||||
|
||||
{{-- Add Pallet and Remove Pallet buttons --}}
|
||||
<div class="flex flex-row gap-2 mt-4">
|
||||
<button
|
||||
type="button"
|
||||
wire:click="printPallet"
|
||||
class="px-3 py-1 border border-primary-500 text-primary-600 rounded hover:bg-primary-50 hover:border-primary-700 transition text-sm"
|
||||
>
|
||||
Print Pallet
|
||||
</button>
|
||||
{{-- <button
|
||||
type="button"
|
||||
wire:click="saveCustomerPO"
|
||||
class="px-3 py-1 border border-primary-500 text-primary-600 rounded hover:bg-primary-50 hover:border-primary-700 transition text-sm"
|
||||
>
|
||||
Save PO
|
||||
</button> --}}
|
||||
</div>
|
||||
<div class="bg-white shadow rounded-xl p-4 mt-6">
|
||||
<livewire:spare-pack-data />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
window.addEventListener('open-pdf', event => {
|
||||
window.open(event.detail.url, '_blank');
|
||||
});
|
||||
</script>
|
||||
</x-filament-panels::page>
|
||||
458
resources/views/pdf/spare-pallet.blade.php
Normal file
458
resources/views/pdf/spare-pallet.blade.php
Normal file
@@ -0,0 +1,458 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>SpareLabel</title>
|
||||
|
||||
@php
|
||||
|
||||
$pageHeightMm = 292;
|
||||
$pageWidthMm = 100;
|
||||
$paddingMm = 1.3;
|
||||
|
||||
$headerRows = [
|
||||
'MFG. MONTH & YEAR' => $monthYear,
|
||||
'SALE ORDER NO' => $customerCode,
|
||||
'SUPPLIER NAME' => $customerName,
|
||||
'MASTER BOX NO.' => $masterBox,
|
||||
];
|
||||
|
||||
|
||||
$titleHeight = 10;
|
||||
$headerRowHeight = 5;
|
||||
$itemHeaderHeight = 14;
|
||||
|
||||
// FOOTER SECTION
|
||||
$grossWeightHeight = 5;
|
||||
$netWeightHeight = 5;
|
||||
$licenseHeight = 5;
|
||||
$companyInfoHeight = 6.9;
|
||||
|
||||
$logoHeight = $titleHeight * 0.8;
|
||||
$logoMaxWidth = 20;
|
||||
|
||||
$isilogoHeight = $titleHeight * 0.9;
|
||||
$isilogoMaxWidth = 11;
|
||||
|
||||
$availableHeight = $pageHeightMm - (2 * $paddingMm);
|
||||
|
||||
$itemPages = collect($items)->chunk(40);
|
||||
|
||||
if ($itemPages->isEmpty()) {
|
||||
$itemPages = collect([
|
||||
collect()
|
||||
]);
|
||||
}
|
||||
|
||||
$qrBase64 = 'data:image/png;base64,' . base64_encode(
|
||||
QrCode::format('png')
|
||||
->size(120)
|
||||
->margin(0)
|
||||
->generate($pallet)
|
||||
);
|
||||
|
||||
@endphp
|
||||
|
||||
<style>
|
||||
|
||||
@page {
|
||||
size: 100mm 292mm;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
* {
|
||||
box-sizing: border-box;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
body {
|
||||
margin: 0;
|
||||
padding: <?php echo $paddingMm; ?>mm;
|
||||
font-family: DejaVu Sans, sans-serif;
|
||||
font-size: 7px;
|
||||
color: #000;
|
||||
width: <?php echo $pageWidthMm - (2 * $paddingMm); ?>mm;
|
||||
height: <?php echo $availableHeight; ?>mm;
|
||||
line-height: 1;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.page {
|
||||
width: <?php echo $pageWidthMm - (2 * $paddingMm); ?>mm;
|
||||
height: <?php echo $availableHeight; ?>mm;
|
||||
page-break-after: always;
|
||||
break-after: page;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.page:last-child {
|
||||
page-break-after: auto;
|
||||
break-after: auto;
|
||||
}
|
||||
|
||||
table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
}
|
||||
|
||||
td,
|
||||
th {
|
||||
border: 0.3px solid #000 !important;
|
||||
vertical-align: middle;
|
||||
line-height: 1 !important;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.title-row td {
|
||||
height: <?php echo $titleHeight - 0.6; ?>mm !important;
|
||||
text-align: center;
|
||||
font-weight: bold;
|
||||
position: relative;
|
||||
padding: 0 !important;
|
||||
font-size: 8.5px;
|
||||
}
|
||||
|
||||
.logo {
|
||||
position: absolute;
|
||||
left: 2mm;
|
||||
top: 50%;
|
||||
transform: translateY(-50%);
|
||||
height: <?php echo min(8, ($titleHeight - 0.6) * 0.6); ?>mm;
|
||||
width: auto;
|
||||
}
|
||||
|
||||
.vertical-line {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
border-left: 0.3px solid #000;
|
||||
}
|
||||
|
||||
.vertical-line.left {
|
||||
left: 12mm;
|
||||
}
|
||||
|
||||
.vertical-line.right {
|
||||
right: 12mm;
|
||||
}
|
||||
|
||||
.header-row td {
|
||||
height: <?php echo $headerRowHeight - 0.6; ?>mm !important;
|
||||
padding: 0.2mm 0.5mm !important;
|
||||
}
|
||||
|
||||
.header-row .label {
|
||||
width: 40%;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.items-header-row td {
|
||||
height: <?php echo $itemHeaderHeight - 0.6; ?>mm !important;
|
||||
font-weight: bold;
|
||||
text-align: center;
|
||||
font-size: 6.5px;
|
||||
padding: 0.2mm 0.5mm !important;
|
||||
}
|
||||
|
||||
.item-row td {
|
||||
height: <?php echo 4; ?>mm !important;
|
||||
font-size: 6.5px !important;
|
||||
padding: 0.1mm 0.4mm !important;
|
||||
line-height: 1 !important;
|
||||
}
|
||||
|
||||
.gross-weight-row td {
|
||||
height: <?php echo $grossWeightHeight - 0.6; ?>mm !important;
|
||||
text-align: center;
|
||||
font-size: 6.5px;
|
||||
padding: 0.2mm 0.5mm !important;
|
||||
}
|
||||
|
||||
.net-weight-row td {
|
||||
height: <?php echo $netWeightHeight - 0.6; ?>mm !important;
|
||||
text-align: center;
|
||||
font-size: 6.5px;
|
||||
padding: 0.2mm 0.5mm !important;
|
||||
}
|
||||
|
||||
.license-row td {
|
||||
height: <?php echo $licenseHeight - 0.6; ?>mm !important;
|
||||
text-align: center;
|
||||
font-size: 6.5px;
|
||||
padding: 0.2mm 0.5mm !important;
|
||||
}
|
||||
|
||||
.company-info-row td {
|
||||
height: <?php echo $companyInfoHeight - 0.6; ?>mm !important;
|
||||
font-size: 5.5px;
|
||||
line-height: 0.9 !important;
|
||||
padding: 0.1mm 0.5mm !important;
|
||||
}
|
||||
|
||||
.label {
|
||||
font-weight: bold;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.center {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.right {
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.col-1 {
|
||||
width: 18%;
|
||||
}
|
||||
|
||||
.col-2 {
|
||||
width: 55%;
|
||||
}
|
||||
|
||||
.col-3 {
|
||||
width: 14%;
|
||||
}
|
||||
|
||||
.col-4 {
|
||||
width: 13%;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
</head>
|
||||
|
||||
|
||||
<body>
|
||||
|
||||
@foreach ($itemPages as $pageItems)
|
||||
|
||||
@php
|
||||
|
||||
$numItems = count($pageItems) ?: 1;
|
||||
|
||||
$fixedSpace = $titleHeight + (4 * $headerRowHeight) + $itemHeaderHeight + $netWeightHeight + $licenseHeight + $companyInfoHeight;
|
||||
|
||||
$fixedRowCount = 1 /* title */
|
||||
+ 4 /* header rows */
|
||||
+ 1 /* items header */
|
||||
+ 1 /* net weight */
|
||||
+ 1 /* license */
|
||||
+ 1; /* company info */
|
||||
|
||||
$desiredBottomGap = 5;
|
||||
|
||||
$spaceForItemsOnly = $availableHeight - $fixedSpace + ($fixedRowCount * 0.6) - $desiredBottomGap;
|
||||
|
||||
$itemRowHeight = ($spaceForItemsOnly / $numItems) + 0.6;
|
||||
|
||||
$maxItemRowHeight = 5;
|
||||
|
||||
if ($itemRowHeight > $maxItemRowHeight) {
|
||||
$itemRowHeight = $maxItemRowHeight;
|
||||
}
|
||||
|
||||
$itemRowHeight = floor($itemRowHeight * 10) / 10;
|
||||
|
||||
if ($itemRowHeight < 3) {
|
||||
|
||||
$itemFontSize = '5.5px';
|
||||
|
||||
$itemPadding = '0.1mm 0.3mm';
|
||||
|
||||
} elseif ($itemRowHeight < 3.5) {
|
||||
|
||||
$itemFontSize = '6px';
|
||||
|
||||
$itemPadding = '0.1mm 0.4mm';
|
||||
|
||||
} elseif ($itemRowHeight < 4) {
|
||||
|
||||
$itemFontSize = '6.5px';
|
||||
|
||||
$itemPadding = '0.1mm 0.5mm';
|
||||
|
||||
} else {
|
||||
|
||||
$itemFontSize = '7px';
|
||||
|
||||
$itemPadding = '0.2mm 0.5mm';
|
||||
}
|
||||
|
||||
$compensatedItemHeight = $itemRowHeight - 0.6;
|
||||
|
||||
$pageTotalQuantity = $pageItems->sum('weight');
|
||||
|
||||
@endphp
|
||||
|
||||
<div class="page">
|
||||
|
||||
<style>
|
||||
|
||||
.page .item-row{
|
||||
height: <?php echo $compensatedItemHeight; ?>mm !important;
|
||||
font-size: <?php echo $itemFontSize; ?> !important;
|
||||
padding: <?php echo $itemPadding; ?> !important;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
<table>
|
||||
|
||||
<tr class="title-row">
|
||||
|
||||
<td colspan="4">
|
||||
|
||||
<div class="vertical-line left"></div>
|
||||
|
||||
<img
|
||||
src="<?php echo public_path('images/crilogo1.png'); ?>"
|
||||
class="logo"
|
||||
alt="CRI Logo"
|
||||
|
||||
style="
|
||||
height: <?php echo $logoHeight; ?>mm;
|
||||
max-width: <?php echo $logoMaxWidth; ?>mm;
|
||||
width: auto;
|
||||
"
|
||||
>
|
||||
Master Packing Slip
|
||||
<div class="vertical-line right"></div>
|
||||
<img
|
||||
src="{{ $qrBase64 }}"
|
||||
style="
|
||||
position: absolute;
|
||||
bottom: 0.8mm;
|
||||
right: 2mm;
|
||||
width: 8mm;
|
||||
height: 7.8mm;
|
||||
"
|
||||
>
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
|
||||
<?php foreach ($headerRows as $label => $value): ?>
|
||||
|
||||
<tr class="header-row">
|
||||
|
||||
<td class="label">
|
||||
<?php echo $label; ?>
|
||||
</td>
|
||||
|
||||
<td colspan="3">
|
||||
<?php echo $value; ?>
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
|
||||
<?php endforeach; ?>
|
||||
|
||||
<tr class="items-header-row">
|
||||
<td class="col-1 center">MATERIAL CODE</td>
|
||||
<td class="col-2 center">DESCRIPTION</td>
|
||||
<td class="col-3 center">QTY in kg</td>
|
||||
<td class="col-4 center">NO. OF BOXES</td>
|
||||
</tr>
|
||||
|
||||
@if ($pageItems->count() > 0)
|
||||
|
||||
@foreach ($pageItems as $item)
|
||||
|
||||
<tr class="item-row">
|
||||
|
||||
<td class="col-1 center">
|
||||
<?php echo $item->code; ?>
|
||||
</td>
|
||||
|
||||
<td class="col-2" style="white-space: nowrap;">
|
||||
<?php echo $item->description; ?>
|
||||
</td>
|
||||
|
||||
<td class="col-3 right">
|
||||
<?php echo number_format($item->weight, 3); ?>
|
||||
</td>
|
||||
|
||||
<td class="col-4 center">
|
||||
<?php echo $item->box_count; ?>
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
|
||||
@endforeach
|
||||
|
||||
@else
|
||||
|
||||
<tr class="item-row">
|
||||
|
||||
<td colspan="4" class="center">
|
||||
No items available
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
|
||||
@endif
|
||||
|
||||
<tr class="net-weight-row">
|
||||
|
||||
<td colspan="2" class="label center">
|
||||
TOTAL QUANTITY
|
||||
</td>
|
||||
|
||||
<td colspan="2" class="center">
|
||||
<?php echo number_format($pageTotalQuantity, 3); ?>
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
|
||||
<tr class="license-row">
|
||||
|
||||
<td colspan="4" class="center">
|
||||
|
||||
MANUFACTURERS
|
||||
|
||||
|
||||
MADE IN INDIA
|
||||
|
||||
|
||||
*Under License
|
||||
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
|
||||
<tr class="company-info-row">
|
||||
|
||||
<td colspan="4" class="center">
|
||||
C.R.I. PUMPS PRIVATE LIMITED
|
||||
<br>
|
||||
|
||||
(Unit of {{ $plantName }})
|
||||
<br>
|
||||
|
||||
{{ $plantAddress }}
|
||||
<br>
|
||||
|
||||
India Regd.Office :
|
||||
7/46-1, Keeranatham Road,
|
||||
Saravanampatti,
|
||||
Coimbatore- 641 035
|
||||
<br>
|
||||
|
||||
For Feedback/Complaint:
|
||||
C.R.I. Customer care cell
|
||||
Toll-Free: 1800 121 1243
|
||||
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
|
||||
</div>
|
||||
|
||||
@endforeach
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -192,6 +192,10 @@ Route::get('get-pdf', [PdfController::class, 'getPdf']); // processorder/get-pdf
|
||||
|
||||
Route::get('laser/item/get-quality-master-data', [StickerMasterController::class, 'get_quality_master']);
|
||||
|
||||
// ..Model Master - Laser
|
||||
|
||||
// Route::get('laser/model-master/get', [StickerMasterController::class, 'get_master']);
|
||||
|
||||
// ..Part Validation
|
||||
|
||||
Route::get('laser/item/get-master-data', [StickerMasterController::class, 'get_master']);
|
||||
@@ -264,8 +268,12 @@ Route::post('file/store', [SapFileController::class, 'store'])->name('file.store
|
||||
|
||||
Route::get('/print-pallet/{pallet}/{plant}', [PalletPrintController::class, 'print'])->name('print.pallet');
|
||||
|
||||
Route::get('/print-spare-pallet/{pallet}/{plant}', [PalletPrintController::class, 'printSpare'])->name('print.sparepallet');
|
||||
|
||||
Route::post('vehicle/entry', [VehicleController::class, 'storeVehicleEntry']);
|
||||
|
||||
// Item Code
|
||||
|
||||
Route::get('item-code', [PlantController::class, 'getItemCode']);
|
||||
|
||||
// Route::post('laser-stop-report', [SapFileController::class, 'laserStopReport']);
|
||||
|
||||
Reference in New Issue
Block a user