Compare commits
60 Commits
renovate/a
...
67ee3ce0f2
| Author | SHA1 | Date | |
|---|---|---|---|
| 67ee3ce0f2 | |||
|
|
567b0544a3 | ||
| 57c56fffeb | |||
|
|
076d4a8f68 | ||
| 88b6fb4256 | |||
|
|
d04c800701 | ||
| 9a514a758e | |||
|
|
cb3427ad13 | ||
| 6d01112c4d | |||
|
|
b880fa2ed2 | ||
| b74095713b | |||
|
|
742e70cec2 | ||
| d027156614 | |||
|
|
c8f288c8af | ||
| 27ea356e8f | |||
|
|
77fb0b21e7 | ||
| 435f46fae4 | |||
|
|
4d507a7ca3 | ||
| b5be827bc3 | |||
|
|
801dcb5ff8 | ||
| 8ba03cf2b9 | |||
|
|
484c3f7cfe | ||
| 0dcf34d713 | |||
|
|
b16724f8f0 | ||
| 4025fcf783 | |||
|
|
64a6030513 | ||
| 3363498fb6 | |||
|
|
c1b3e51cc1 | ||
|
|
9872777875 | ||
|
|
fab3e56f31 | ||
|
|
fd8b5570fd | ||
| a6b8a5c0cc | |||
|
|
8dabfb1fa5 | ||
| c6714b195e | |||
|
|
3bdcc15c18 | ||
|
|
2696e9633c | ||
|
|
d46819a79d | ||
|
|
6321d3c8db | ||
| d392fe9c78 | |||
|
|
79e6d498d9 | ||
| eccc6342c0 | |||
|
|
543ce2fc81 | ||
| dbc9a02669 | |||
|
|
dc0bf9a9a7 | ||
| 837b936b51 | |||
|
|
5afc8afa1a | ||
| 528914e2d0 | |||
|
|
84f5ee7f7e | ||
| bb94206a1e | |||
|
|
25ed37f50d | ||
| d7f758b584 | |||
|
|
a1f3bc555e | ||
| 85bfb99273 | |||
|
|
6010cf5998 | ||
| 2f2faa3019 | |||
|
|
f818a8c44b | ||
| d72f4c89fd | |||
|
|
b698493e1a | ||
| 4c07abe394 | |||
|
|
9fd451bbda |
58
app/Filament/Exports/CustomerPoMasterExporter.php
Normal file
58
app/Filament/Exports/CustomerPoMasterExporter.php
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Exports;
|
||||||
|
|
||||||
|
use App\Models\CustomerPoMaster;
|
||||||
|
use Filament\Actions\Exports\ExportColumn;
|
||||||
|
use Filament\Actions\Exports\Exporter;
|
||||||
|
use Filament\Actions\Exports\Models\Export;
|
||||||
|
|
||||||
|
class CustomerPoMasterExporter extends Exporter
|
||||||
|
{
|
||||||
|
protected static ?string $model = CustomerPoMaster::class;
|
||||||
|
|
||||||
|
public static function getColumns(): array
|
||||||
|
{
|
||||||
|
static $rowNumber = 0;
|
||||||
|
return [
|
||||||
|
ExportColumn::make('no')
|
||||||
|
->label('NO')
|
||||||
|
->state(function ($record) use (&$rowNumber) {
|
||||||
|
// Increment and return the row number
|
||||||
|
return ++$rowNumber;
|
||||||
|
}),
|
||||||
|
ExportColumn::make('plant.code')
|
||||||
|
->label('PLANT CODE'),
|
||||||
|
ExportColumn::make('item.code')
|
||||||
|
->label('ITEM CODE'),
|
||||||
|
ExportColumn::make('customer_po')
|
||||||
|
->label('CUSTOMER PO'),
|
||||||
|
ExportColumn::make('customer_name')
|
||||||
|
->label('CUSTOMER NAME'),
|
||||||
|
ExportColumn::make('quantity')
|
||||||
|
->label('QUANTITY'),
|
||||||
|
ExportColumn::make('created_at')
|
||||||
|
->label('CREATED AT'),
|
||||||
|
ExportColumn::make('updated_at')
|
||||||
|
->label('UPDATED AT'),
|
||||||
|
ExportColumn::make('created_by')
|
||||||
|
->label('CREATED BY'),
|
||||||
|
ExportColumn::make('updated_by')
|
||||||
|
->label('UPDATED BY'),
|
||||||
|
ExportColumn::make('deleted_at')
|
||||||
|
->label('DELETED AT')
|
||||||
|
->enabledByDefault(false),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getCompletedNotificationBody(Export $export): string
|
||||||
|
{
|
||||||
|
$body = 'Your customer po master export has completed and ' . number_format($export->successful_rows) . ' ' . str('row')->plural($export->successful_rows) . ' exported.';
|
||||||
|
|
||||||
|
if ($failedRowsCount = $export->getFailedRowsCount()) {
|
||||||
|
$body .= ' ' . number_format($failedRowsCount) . ' ' . str('row')->plural($failedRowsCount) . ' failed to export.';
|
||||||
|
}
|
||||||
|
|
||||||
|
return $body;
|
||||||
|
}
|
||||||
|
}
|
||||||
140
app/Filament/Imports/CustomerPoMasterImporter.php
Normal file
140
app/Filament/Imports/CustomerPoMasterImporter.php
Normal file
@@ -0,0 +1,140 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Imports;
|
||||||
|
|
||||||
|
use App\Models\CustomerPoMaster;
|
||||||
|
use App\Models\Item;
|
||||||
|
use App\Models\Plant;
|
||||||
|
use App\Models\User;
|
||||||
|
use Filament\Actions\Imports\ImportColumn;
|
||||||
|
use Filament\Actions\Imports\Importer;
|
||||||
|
use Filament\Actions\Imports\Models\Import;
|
||||||
|
use Filament\Actions\Imports\Exceptions\RowImportFailedException;
|
||||||
|
use Filament\Facades\Filament;
|
||||||
|
use Str;
|
||||||
|
|
||||||
|
class CustomerPoMasterImporter extends Importer
|
||||||
|
{
|
||||||
|
protected static ?string $model = CustomerPoMaster::class;
|
||||||
|
|
||||||
|
public static function getColumns(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
ImportColumn::make('plant')
|
||||||
|
->requiredMapping()
|
||||||
|
->exampleHeader('Plant Code')
|
||||||
|
->example('1000')
|
||||||
|
->label('Plant Code')
|
||||||
|
->relationship(resolveUsing: 'code')
|
||||||
|
->rules(['required']),
|
||||||
|
ImportColumn::make('item')
|
||||||
|
->requiredMapping()
|
||||||
|
->exampleHeader('Item Code')
|
||||||
|
->example('630214')
|
||||||
|
->label('Item Code')
|
||||||
|
->relationship(resolveUsing: 'code')
|
||||||
|
->rules(['required']),
|
||||||
|
ImportColumn::make('customer_po')
|
||||||
|
->requiredMapping()
|
||||||
|
->exampleHeader('Customer PO')
|
||||||
|
->example('1JA0029512')
|
||||||
|
->label('Customer PO')
|
||||||
|
->rules(['required']),
|
||||||
|
ImportColumn::make('customer_name')
|
||||||
|
->requiredMapping()
|
||||||
|
->exampleHeader('Customer Name')
|
||||||
|
->example('KANKARIA MACHINERY STORE')
|
||||||
|
->label('Customer Name')
|
||||||
|
->rules(['required']),
|
||||||
|
ImportColumn::make('quantity')
|
||||||
|
->requiredMapping()
|
||||||
|
->exampleHeader('Quantity')
|
||||||
|
->example('5')
|
||||||
|
->label('Quantity')
|
||||||
|
->rules(['required']),
|
||||||
|
// ImportColumn::make('created_by')
|
||||||
|
// ->requiredMapping()
|
||||||
|
// ->exampleHeader('Created By')
|
||||||
|
// ->example('Admin')
|
||||||
|
// ->label('Created By')
|
||||||
|
// ->rules(['required']),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function resolveRecord(): ?CustomerPoMaster
|
||||||
|
{
|
||||||
|
$warnMsg = [];
|
||||||
|
$plantCod = $this->data['plant'];
|
||||||
|
$plant = null;
|
||||||
|
$item = null;
|
||||||
|
|
||||||
|
if (Str::length($plantCod) < 4 || ! is_numeric($plantCod) || ! preg_match('/^[1-9]\d{3,}$/', $plantCod)) {
|
||||||
|
$warnMsg[] = 'Invalid plant code found';
|
||||||
|
} else {
|
||||||
|
$plant = Plant::where('code', $plantCod)->first();
|
||||||
|
if (! $plant) {
|
||||||
|
$warnMsg[] = 'Plant not found';
|
||||||
|
} else {
|
||||||
|
$item = Item::where('code', $this->data['item'])->where('plant_id', $plant->id)->first();
|
||||||
|
}
|
||||||
|
if (! $item) {
|
||||||
|
$warnMsg[] = 'Item not found';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Str::length($this->data['customer_po']) < 9) {
|
||||||
|
$warnMsg[] = 'Invalid Customer PO number found';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (empty($this->data['customer_po'])) {
|
||||||
|
$warnMsg[] = 'Customer PO cannot be empty.';
|
||||||
|
}
|
||||||
|
|
||||||
|
// $user = User::where('name', $this->data['created_by'])->first();
|
||||||
|
// if (! $user) {
|
||||||
|
// $warnMsg[] = 'User not found';
|
||||||
|
// }
|
||||||
|
|
||||||
|
$user = Filament::auth()->user();
|
||||||
|
|
||||||
|
$operatorName = $user->name;
|
||||||
|
|
||||||
|
if (! empty($warnMsg)) {
|
||||||
|
throw new RowImportFailedException(implode(', ', $warnMsg));
|
||||||
|
}
|
||||||
|
//else { // if (empty($warnMsg))
|
||||||
|
// $grMaster = GrMaster::where('plant_id', $plant->id)
|
||||||
|
// ->where('serial_number', $this->data['serial_number'])
|
||||||
|
// ->latest()
|
||||||
|
// ->first();
|
||||||
|
|
||||||
|
// if ($grMaster) {
|
||||||
|
// throw new RowImportFailedException('Serial number already exist!');
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
CustomerPoMaster::updateOrCreate([
|
||||||
|
'plant_id' => $plant->id,
|
||||||
|
'item_id' => $item->id,
|
||||||
|
'customer_po' => $this->data['customer_po'],
|
||||||
|
'customer_name' => $this->data['customer_name'],
|
||||||
|
'quantity' => $this->data['quantity'] ?? null,
|
||||||
|
'created_by' => $operatorName,
|
||||||
|
]);
|
||||||
|
|
||||||
|
return null;
|
||||||
|
|
||||||
|
// return new CustomerPoMaster();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getCompletedNotificationBody(Import $import): string
|
||||||
|
{
|
||||||
|
$body = 'Your customer po master import has completed and ' . number_format($import->successful_rows) . ' ' . str('row')->plural($import->successful_rows) . ' imported.';
|
||||||
|
|
||||||
|
if ($failedRowsCount = $import->getFailedRowsCount()) {
|
||||||
|
$body .= ' ' . number_format($failedRowsCount) . ' ' . str('row')->plural($failedRowsCount) . ' failed to import.';
|
||||||
|
}
|
||||||
|
|
||||||
|
return $body;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -142,13 +142,12 @@ class ProcessOrderImporter extends Importer
|
|||||||
if ($recQuan == null || $recQuan == '') {
|
if ($recQuan == null || $recQuan == '') {
|
||||||
$recQuan = 0;
|
$recQuan = 0;
|
||||||
}
|
}
|
||||||
if ($reworkStatus == null || $reworkStatus = '') {
|
if ($reworkStatus == null || $reworkStatus = '' || $reworkStatus == 0 || $reworkStatus = '0') {
|
||||||
$reworkStatus = 0;
|
$reworkStatus = 0;
|
||||||
}
|
} elseif ($reworkStatus == 1 || $reworkStatus = '1') {
|
||||||
|
$reworkStatus = 1;
|
||||||
if ($createdBy == null || $createdBy == '') {
|
} else {
|
||||||
$createdBy = Filament::auth()->user()?->name;
|
$warnMsg[] = 'Invalid rework status found';
|
||||||
$updatedBy = $createdBy;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Str::length($plantCod) < 4 || ! is_numeric($plantCod) || ! preg_match('/^[1-9]\d{3,}$/', $plantCod)) {
|
if (Str::length($plantCod) < 4 || ! is_numeric($plantCod) || ! preg_match('/^[1-9]\d{3,}$/', $plantCod)) {
|
||||||
@@ -209,21 +208,16 @@ class ProcessOrderImporter extends Importer
|
|||||||
$lineId = null;
|
$lineId = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($createdBy != null && $createdBy != '') {
|
// $user = User::where('name', $this->data['created_by'])->first();
|
||||||
if ($plantId) {
|
// if (! $user) {
|
||||||
$user = User::where('name', $createdBy)->first();
|
// $warnMsg[] = 'User not found';
|
||||||
|
// }
|
||||||
|
|
||||||
$userPlant = User::where('name', $createdBy)->where('plant_id', $plantId)->first();
|
if (! $createdBy) {
|
||||||
|
$createdBy = Filament::auth()->user()->name;
|
||||||
if (! $user) {
|
$updatedBy = Filament::auth()->user()->name;
|
||||||
$warnMsg[] = 'Created By user name not found!';
|
} elseif (! $updatedBy) {
|
||||||
} elseif (! $userPlant && ! $user->hasRole('Super Admin')) {
|
$updatedBy = Filament::auth()->user()->name;
|
||||||
$warnMsg[] = "Created By user '{$createdBy}' not found for Plant '{$plantCod}'!";
|
|
||||||
} elseif (! $user->hasRole(['Super Admin', 'Process Quality Manager', 'Process Manager', 'Process Supervisor', 'Process Employee'])) {
|
|
||||||
$warnMsg[] = 'Created By user does not have rights!';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$updatedBy = Filament::auth()->user()?->name;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! empty($warnMsg)) {
|
if (! empty($warnMsg)) {
|
||||||
@@ -280,9 +274,10 @@ class ProcessOrderImporter extends Importer
|
|||||||
->where('coil_number', $coilNo)
|
->where('coil_number', $coilNo)
|
||||||
->first();
|
->first();
|
||||||
|
|
||||||
if (! $existing && $coilNo == '0' || $coilNo == 0) {
|
if (! $existing && ($coilNo == '0' || $coilNo == 0)) {
|
||||||
ProcessOrder::create([
|
ProcessOrder::create([
|
||||||
'plant_id' => $plantId,
|
'plant_id' => $plantId,
|
||||||
|
'line_id' => $lineId,
|
||||||
'item_id' => $itemId,
|
'item_id' => $itemId,
|
||||||
'process_order' => $processOrder,
|
'process_order' => $processOrder,
|
||||||
'coil_number' => '0',
|
'coil_number' => '0',
|
||||||
@@ -297,8 +292,8 @@ class ProcessOrderImporter extends Importer
|
|||||||
[
|
[
|
||||||
'plant_id' => $plantId,
|
'plant_id' => $plantId,
|
||||||
'line_id' => $lineId,
|
'line_id' => $lineId,
|
||||||
'process_order' => $processOrder,
|
|
||||||
'item_id' => $itemId,
|
'item_id' => $itemId,
|
||||||
|
'process_order' => $processOrder,
|
||||||
'coil_number' => $coilNo,
|
'coil_number' => $coilNo,
|
||||||
'order_quantity' => $orderQuan,
|
'order_quantity' => $orderQuan,
|
||||||
'received_quantity' => $recQuan,
|
'received_quantity' => $recQuan,
|
||||||
@@ -306,13 +301,17 @@ class ProcessOrderImporter extends Importer
|
|||||||
'sfg_number' => $sfgNo,
|
'sfg_number' => $sfgNo,
|
||||||
'machine_name' => $machineName,
|
'machine_name' => $machineName,
|
||||||
'rework_status' => $reworkStatus,
|
'rework_status' => $reworkStatus,
|
||||||
'created_at' => $createdAt,
|
// 'created_at' => $createdAt,
|
||||||
'updated_at' => $updatedAt,
|
// 'updated_at' => $updatedAt,
|
||||||
'created_by' => $createdBy,
|
'created_by' => $createdBy,
|
||||||
'updated_by' => $updatedBy,
|
'updated_by' => $updatedBy,
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
} else {// $coilNo = '0'
|
} else {// $coilNo = '0'
|
||||||
|
if ($existing->rework_status == 1 && $reworkStatus == 0) {
|
||||||
|
throw new RowImportFailedException('Rework coil number already exist for the given Plant and Process Order!');
|
||||||
|
}
|
||||||
|
|
||||||
ProcessOrder::where('plant_id', $plantId)
|
ProcessOrder::where('plant_id', $plantId)
|
||||||
->where('process_order', $processOrder)
|
->where('process_order', $processOrder)
|
||||||
->where('coil_number', $coilNo)
|
->where('coil_number', $coilNo)
|
||||||
@@ -324,7 +323,7 @@ class ProcessOrderImporter extends Importer
|
|||||||
// 'machine_name' => $machineId,
|
// 'machine_name' => $machineId,
|
||||||
'rework_status' => $reworkStatus,
|
'rework_status' => $reworkStatus,
|
||||||
'updated_by' => $updatedBy,
|
'updated_by' => $updatedBy,
|
||||||
'updated_at' => $updatedAt,
|
// 'updated_at' => $updatedAt,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,47 +31,6 @@ class ProductionTarget extends Page
|
|||||||
->schema([
|
->schema([
|
||||||
Section::make('')
|
Section::make('')
|
||||||
->schema([
|
->schema([
|
||||||
Select::make('plant_id')
|
|
||||||
->label('Plant')
|
|
||||||
->relationship('plant', 'name')
|
|
||||||
->reactive()
|
|
||||||
// ->searchable()
|
|
||||||
->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()
|
|
||||||
->afterStateUpdated(function ($state, callable $get, $set) {
|
|
||||||
// dd($state);
|
|
||||||
$set('line_id', null);
|
|
||||||
$set('year', null);
|
|
||||||
$set('month', null);
|
|
||||||
$this->dispatch('loadData',$state, '', '', '');
|
|
||||||
}),
|
|
||||||
Select::make('line_id')
|
|
||||||
->label('Line')
|
|
||||||
->required()
|
|
||||||
->relationship('line', 'name')
|
|
||||||
// ->searchable()
|
|
||||||
->columnSpan(1)
|
|
||||||
->options(function (callable $get) {
|
|
||||||
if (!$get('plant_id')) {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
|
|
||||||
return \App\Models\Line::where('plant_id', $get('plant_id'))
|
|
||||||
->pluck('name', 'id')
|
|
||||||
->toArray();
|
|
||||||
})
|
|
||||||
->reactive()
|
|
||||||
->afterStateUpdated(function ($state, callable $get, $set) {
|
|
||||||
$plantId = $get('plant_id');
|
|
||||||
|
|
||||||
|
|
||||||
$set('year', null);
|
|
||||||
$set('month', null);
|
|
||||||
$this->dispatch('loadData',$plantId, $state, '', '');
|
|
||||||
}),
|
|
||||||
Select::make('year')
|
Select::make('year')
|
||||||
->label('Year')
|
->label('Year')
|
||||||
->reactive()
|
->reactive()
|
||||||
@@ -97,9 +56,13 @@ class ProductionTarget extends Page
|
|||||||
->required()
|
->required()
|
||||||
->afterStateUpdated(function ($state, callable $get, $set) {
|
->afterStateUpdated(function ($state, callable $get, $set) {
|
||||||
$set('month', null);
|
$set('month', null);
|
||||||
|
$set('plant_id', null);
|
||||||
|
$set('line_id', null);
|
||||||
|
$set('category', null);
|
||||||
$plantId = $get('plant_id');
|
$plantId = $get('plant_id');
|
||||||
$lineId = $get('line_id');
|
$lineId = $get('line_id');
|
||||||
$this->dispatch('loadData',$plantId, $lineId, $state, '');
|
// $this->dispatch('loadData',$plantId, $lineId, $state, '');
|
||||||
|
$this->dispatch('loadData',$state, '', '', '', '');
|
||||||
}),
|
}),
|
||||||
|
|
||||||
Select::make('month')
|
Select::make('month')
|
||||||
@@ -121,23 +84,86 @@ class ProductionTarget extends Page
|
|||||||
'12' => 'December',
|
'12' => 'December',
|
||||||
])
|
])
|
||||||
->required()
|
->required()
|
||||||
->afterStateUpdated(function ($state, callable $get) {
|
->afterStateUpdated(function ($state, callable $get, $set) {
|
||||||
|
|
||||||
|
$set('plant_id', null);
|
||||||
|
$set('line_id', null);
|
||||||
|
$set('category', null);
|
||||||
|
|
||||||
|
$year = $get('year');
|
||||||
|
|
||||||
|
$this->dispatch('loadData',$year, $state, '', '', '');
|
||||||
|
|
||||||
|
// $plantId = $get('plant_id');
|
||||||
|
// $lineId = $get('line_id');
|
||||||
|
// // $month = $get('month');
|
||||||
|
// $year = $get('year');
|
||||||
|
|
||||||
|
// $month = (int) $get('month');
|
||||||
|
|
||||||
|
// if (!$month) {
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
// $this->dispatch('loadData', $plantId, $lineId, $month, $year);
|
||||||
|
}),
|
||||||
|
Select::make('plant_id')
|
||||||
|
->label('Plant')
|
||||||
|
->relationship('plant', 'name')
|
||||||
|
->reactive()
|
||||||
|
// ->searchable()
|
||||||
|
->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()
|
||||||
|
->afterStateUpdated(function ($state, callable $get, $set) {
|
||||||
|
// dd($state);
|
||||||
|
$set('line_id', null);
|
||||||
|
$set('category', null);
|
||||||
|
$this->dispatch('loadData',$state, '', '', '', '');
|
||||||
|
}),
|
||||||
|
Select::make('line_id')
|
||||||
|
->label('Line')
|
||||||
|
->required()
|
||||||
|
->relationship('line', 'name')
|
||||||
|
// ->searchable()
|
||||||
|
->columnSpan(1)
|
||||||
|
->options(function (callable $get) {
|
||||||
|
if (!$get('plant_id')) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
return \App\Models\Line::where('plant_id', $get('plant_id'))
|
||||||
|
->pluck('name', 'id')
|
||||||
|
->toArray();
|
||||||
|
})
|
||||||
|
->reactive()
|
||||||
|
->afterStateUpdated(function ($state, callable $get, $set) {
|
||||||
$plantId = $get('plant_id');
|
$plantId = $get('plant_id');
|
||||||
$lineId = $get('line_id');
|
$lineId = $get('line_id');
|
||||||
// $month = $get('month');
|
// $month = $get('month');
|
||||||
$year = $get('year');
|
$year = $get('year');
|
||||||
|
|
||||||
$month = (int) $get('month');
|
$month = (int) $get('month');
|
||||||
|
$this->dispatch('loadData',$year, $month, $plantId, $lineId, '');
|
||||||
|
}),
|
||||||
|
|
||||||
if (!$month) {
|
TextInput::make('category')
|
||||||
return;
|
->label('Category')
|
||||||
}
|
->reactive()
|
||||||
$this->dispatch('loadData', $plantId, $lineId, $month, $year);
|
->afterStateUpdated(function ($state, callable $get, $set) {
|
||||||
|
$plantId = $get('plant_id');
|
||||||
|
$lineId = $get('line_id');
|
||||||
|
// $month = $get('month');
|
||||||
|
$year = $get('year');
|
||||||
|
|
||||||
|
$month = (int) $get('month');
|
||||||
|
$category = $get('category');
|
||||||
|
$this->dispatch('loadData',$year, $month, $plantId, $lineId, $category);
|
||||||
}),
|
}),
|
||||||
|
|
||||||
])
|
])
|
||||||
->columns(4)
|
->columns(5)
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
304
app/Filament/Pages/WireMasterPrint.php
Normal file
304
app/Filament/Pages/WireMasterPrint.php
Normal file
@@ -0,0 +1,304 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Pages;
|
||||||
|
|
||||||
|
use App\Models\CustomerPoMaster;
|
||||||
|
use App\Models\Plant;
|
||||||
|
use App\Models\WireMasterPacking;
|
||||||
|
use Filament\Facades\Filament;
|
||||||
|
use Filament\Pages\Page;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
use Filament\Forms\Contracts\HasForms;
|
||||||
|
use Filament\Forms\Concerns\InteractsWithForms;
|
||||||
|
use Filament\Forms\Form;
|
||||||
|
use Filament\Forms\Components\Section;
|
||||||
|
use Filament\Forms\Components\Select;
|
||||||
|
use Filament\Forms\Components\TextInput;
|
||||||
|
use Filament\Notifications\Notification;
|
||||||
|
|
||||||
|
class WireMasterPrint extends Page
|
||||||
|
{
|
||||||
|
protected static ?string $navigationIcon = 'heroicon-o-document-text';
|
||||||
|
|
||||||
|
protected static string $view = 'filament.pages.wire-master-print';
|
||||||
|
|
||||||
|
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('customer_po_master_id')
|
||||||
|
->label('Customer PO')
|
||||||
|
->reactive()
|
||||||
|
->searchable()
|
||||||
|
->options(function (callable $get) {
|
||||||
|
$plantId = $get('plant_id');
|
||||||
|
if (empty($plantId)) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
return CustomerPoMaster::where('plant_id', $plantId)->pluck('customer_po', 'id');
|
||||||
|
})
|
||||||
|
->required(),
|
||||||
|
select::make('scan_pallet_no')
|
||||||
|
->label('Scan Pallet No')
|
||||||
|
->reactive()
|
||||||
|
->options(function ($get) {
|
||||||
|
|
||||||
|
$plantId = $get('plant_id');
|
||||||
|
$customerPoId = $get('customer_po_master_id');
|
||||||
|
|
||||||
|
if (! $plantId || ! $customerPoId) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
$palletNumbers = WireMasterPacking::query()
|
||||||
|
->select('wire_packing_number')
|
||||||
|
->where('plant_id', $plantId)
|
||||||
|
->where('customer_po_master_id', $customerPoId)
|
||||||
|
->whereNotNull('wire_packing_number')
|
||||||
|
->groupBy('wire_packing_number')
|
||||||
|
->havingRaw('COUNT(*) = COUNT(wire_packing_status)')
|
||||||
|
->havingRaw("SUM(CASE WHEN TRIM(wire_packing_status) = '' THEN 1 ELSE 0 END) = 0")
|
||||||
|
->orderBy('wire_packing_number', 'asc')
|
||||||
|
->pluck('wire_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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// return redirect()->route('print.pallet', [
|
||||||
|
// 'pallet' => $palletNumber,
|
||||||
|
// 'plant' => $plantId,
|
||||||
|
// ]);
|
||||||
|
$this->dispatch('open-pdf', url: route('print.pallet', [
|
||||||
|
'pallet' => $state['scan_pallet_no'],
|
||||||
|
'plant' => $state['plant_id'],
|
||||||
|
'customer' => $state['customer_po_master_id'],
|
||||||
|
]));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function canAccess(): bool
|
||||||
|
{
|
||||||
|
return Auth::check() && Auth::user()->can('view wire master print page');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -339,6 +339,11 @@ class CharacteristicValueResource extends Resource
|
|||||||
->searchable()
|
->searchable()
|
||||||
->alignCenter()
|
->alignCenter()
|
||||||
->sortable(),
|
->sortable(),
|
||||||
|
Tables\Columns\TextColumn::make('item.description')
|
||||||
|
->label('Description')
|
||||||
|
->searchable()
|
||||||
|
->alignCenter()
|
||||||
|
->sortable(),
|
||||||
Tables\Columns\TextColumn::make('machine.work_center')
|
Tables\Columns\TextColumn::make('machine.work_center')
|
||||||
->label('Machine')
|
->label('Machine')
|
||||||
->searchable()
|
->searchable()
|
||||||
|
|||||||
176
app/Filament/Resources/CustomerPoMasterResource.php
Normal file
176
app/Filament/Resources/CustomerPoMasterResource.php
Normal file
@@ -0,0 +1,176 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Resources;
|
||||||
|
|
||||||
|
use App\Filament\Exports\CustomerPoMasterExporter;
|
||||||
|
use App\Filament\Imports\CustomerPoMasterImporter;
|
||||||
|
use App\Filament\Resources\CustomerPoMasterResource\Pages;
|
||||||
|
use App\Filament\Resources\CustomerPoMasterResource\RelationManagers;
|
||||||
|
use App\Models\CustomerPoMaster;
|
||||||
|
use App\Models\Item;
|
||||||
|
use App\Models\Plant;
|
||||||
|
use Filament\Facades\Filament;
|
||||||
|
use Filament\Forms;
|
||||||
|
use Filament\Forms\Form;
|
||||||
|
use Filament\Resources\Resource;
|
||||||
|
use Filament\Tables;
|
||||||
|
use Filament\Tables\Table;
|
||||||
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||||
|
use Filament\Tables\Actions\ExportAction;
|
||||||
|
use Filament\Tables\Actions\ImportAction;
|
||||||
|
|
||||||
|
class CustomerPoMasterResource extends Resource
|
||||||
|
{
|
||||||
|
protected static ?string $model = CustomerPoMaster::class;
|
||||||
|
|
||||||
|
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
|
||||||
|
|
||||||
|
public static function form(Form $form): Form
|
||||||
|
{
|
||||||
|
return $form
|
||||||
|
->schema([
|
||||||
|
Forms\Components\Select::make('plant_id')
|
||||||
|
->label('Plant')
|
||||||
|
->reactive()
|
||||||
|
->relationship('plant', 'name')
|
||||||
|
->options(function (callable $get) {
|
||||||
|
$userHas = Filament::auth()->user()->plant_id;
|
||||||
|
|
||||||
|
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
||||||
|
})
|
||||||
|
->required(),
|
||||||
|
Forms\Components\Select::make('item_id')
|
||||||
|
->label('Item Code')
|
||||||
|
->reactive()
|
||||||
|
->searchable()
|
||||||
|
->options(function (callable $get) {
|
||||||
|
$plantId = $get('plant_id');
|
||||||
|
if (empty($plantId)) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
return Item::where('plant_id', $plantId)->pluck('code', 'id');
|
||||||
|
})
|
||||||
|
->required(),
|
||||||
|
Forms\Components\TextInput::make('customer_po')
|
||||||
|
->label('Customer PO'),
|
||||||
|
Forms\Components\TextInput::make('customer_name')
|
||||||
|
->label('Customer Name'),
|
||||||
|
Forms\Components\TextInput::make('quantity')
|
||||||
|
->label('Quantity'),
|
||||||
|
Forms\Components\Hidden::make('created_by')
|
||||||
|
->label('Created By')
|
||||||
|
->default(Filament::auth()->user()?->name),
|
||||||
|
Forms\Components\Hidden::make('updated_by')
|
||||||
|
->default(Filament::auth()->user()?->name),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function table(Table $table): Table
|
||||||
|
{
|
||||||
|
return $table
|
||||||
|
->columns([
|
||||||
|
Tables\Columns\TextColumn::make('No.')
|
||||||
|
->label('No.')
|
||||||
|
->getStateUsing(function ($record, $livewire, $column, $rowLoop) {
|
||||||
|
$paginator = $livewire->getTableRecords();
|
||||||
|
$perPage = method_exists($paginator, 'perPage') ? $paginator->perPage() : 10;
|
||||||
|
$currentPage = method_exists($paginator, 'currentPage') ? $paginator->currentPage() : 1;
|
||||||
|
|
||||||
|
return ($currentPage - 1) * $perPage + $rowLoop->iteration;
|
||||||
|
}),
|
||||||
|
Tables\Columns\TextColumn::make('plant.name')
|
||||||
|
->label('Plant')
|
||||||
|
->alignCenter()
|
||||||
|
->sortable(),
|
||||||
|
Tables\Columns\TextColumn::make('item.code')
|
||||||
|
->label('Item Code')
|
||||||
|
->searchable()
|
||||||
|
->alignCenter()
|
||||||
|
->sortable(),
|
||||||
|
Tables\Columns\TextColumn::make('customer_po')
|
||||||
|
->label('Customer PO')
|
||||||
|
->searchable()
|
||||||
|
->alignCenter()
|
||||||
|
->sortable(),
|
||||||
|
Tables\Columns\TextColumn::make('customer_name')
|
||||||
|
->label('Customer Name')
|
||||||
|
->searchable()
|
||||||
|
->alignCenter()
|
||||||
|
->sortable(),
|
||||||
|
Tables\Columns\TextColumn::make('quantity')
|
||||||
|
->label('Quantity')
|
||||||
|
->searchable()
|
||||||
|
->alignCenter()
|
||||||
|
->sortable(),
|
||||||
|
Tables\Columns\TextColumn::make('created_at')
|
||||||
|
->dateTime()
|
||||||
|
->sortable()
|
||||||
|
->toggleable(isToggledHiddenByDefault: true),
|
||||||
|
Tables\Columns\TextColumn::make('updated_at')
|
||||||
|
->dateTime()
|
||||||
|
->sortable()
|
||||||
|
->toggleable(isToggledHiddenByDefault: true),
|
||||||
|
Tables\Columns\TextColumn::make('deleted_at')
|
||||||
|
->dateTime()
|
||||||
|
->sortable()
|
||||||
|
->toggleable(isToggledHiddenByDefault: true),
|
||||||
|
])
|
||||||
|
->filters([
|
||||||
|
Tables\Filters\TrashedFilter::make(),
|
||||||
|
])
|
||||||
|
->actions([
|
||||||
|
Tables\Actions\ViewAction::make(),
|
||||||
|
Tables\Actions\EditAction::make(),
|
||||||
|
])
|
||||||
|
->bulkActions([
|
||||||
|
Tables\Actions\BulkActionGroup::make([
|
||||||
|
Tables\Actions\DeleteBulkAction::make(),
|
||||||
|
Tables\Actions\ForceDeleteBulkAction::make(),
|
||||||
|
Tables\Actions\RestoreBulkAction::make(),
|
||||||
|
]),
|
||||||
|
])
|
||||||
|
->headerActions([
|
||||||
|
ImportAction::make()
|
||||||
|
->label('Import Customer PO')
|
||||||
|
->color('warning')
|
||||||
|
->importer(CustomerPoMasterImporter::class)
|
||||||
|
->visible(function () {
|
||||||
|
return Filament::auth()->user()->can('view import customer po master');
|
||||||
|
}),
|
||||||
|
ExportAction::make()
|
||||||
|
->label('Export Customer PO')
|
||||||
|
->color('warning')
|
||||||
|
->exporter(CustomerPoMasterExporter::class)
|
||||||
|
->visible(function () {
|
||||||
|
return Filament::auth()->user()->can('view export customer po master');
|
||||||
|
}),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getRelations(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
//
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getPages(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'index' => Pages\ListCustomerPoMasters::route('/'),
|
||||||
|
'create' => Pages\CreateCustomerPoMaster::route('/create'),
|
||||||
|
'view' => Pages\ViewCustomerPoMaster::route('/{record}'),
|
||||||
|
'edit' => Pages\EditCustomerPoMaster::route('/{record}/edit'),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getEloquentQuery(): Builder
|
||||||
|
{
|
||||||
|
return parent::getEloquentQuery()
|
||||||
|
->withoutGlobalScopes([
|
||||||
|
SoftDeletingScope::class,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Resources\CustomerPoMasterResource\Pages;
|
||||||
|
|
||||||
|
use App\Filament\Resources\CustomerPoMasterResource;
|
||||||
|
use Filament\Actions;
|
||||||
|
use Filament\Resources\Pages\CreateRecord;
|
||||||
|
|
||||||
|
class CreateCustomerPoMaster extends CreateRecord
|
||||||
|
{
|
||||||
|
protected static string $resource = CustomerPoMasterResource::class;
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Resources\CustomerPoMasterResource\Pages;
|
||||||
|
|
||||||
|
use App\Filament\Resources\CustomerPoMasterResource;
|
||||||
|
use Filament\Actions;
|
||||||
|
use Filament\Resources\Pages\EditRecord;
|
||||||
|
|
||||||
|
class EditCustomerPoMaster extends EditRecord
|
||||||
|
{
|
||||||
|
protected static string $resource = CustomerPoMasterResource::class;
|
||||||
|
|
||||||
|
protected function getHeaderActions(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
Actions\ViewAction::make(),
|
||||||
|
Actions\DeleteAction::make(),
|
||||||
|
Actions\ForceDeleteAction::make(),
|
||||||
|
Actions\RestoreAction::make(),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Resources\CustomerPoMasterResource\Pages;
|
||||||
|
|
||||||
|
use App\Filament\Resources\CustomerPoMasterResource;
|
||||||
|
use Filament\Actions;
|
||||||
|
use Filament\Resources\Pages\ListRecords;
|
||||||
|
|
||||||
|
class ListCustomerPoMasters extends ListRecords
|
||||||
|
{
|
||||||
|
protected static string $resource = CustomerPoMasterResource::class;
|
||||||
|
|
||||||
|
protected function getHeaderActions(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
Actions\CreateAction::make(),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Resources\CustomerPoMasterResource\Pages;
|
||||||
|
|
||||||
|
use App\Filament\Resources\CustomerPoMasterResource;
|
||||||
|
use Filament\Actions;
|
||||||
|
use Filament\Resources\Pages\ViewRecord;
|
||||||
|
|
||||||
|
class ViewCustomerPoMaster extends ViewRecord
|
||||||
|
{
|
||||||
|
protected static string $resource = CustomerPoMasterResource::class;
|
||||||
|
|
||||||
|
protected function getHeaderActions(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
Actions\EditAction::make(),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -446,7 +446,7 @@ class GrMasterResource extends Resource
|
|||||||
->alignCenter()
|
->alignCenter()
|
||||||
->sortable(),
|
->sortable(),
|
||||||
Tables\Columns\TextColumn::make('item.code')
|
Tables\Columns\TextColumn::make('item.code')
|
||||||
->label('Item Code')
|
->label('Item')
|
||||||
->searchable()
|
->searchable()
|
||||||
->alignCenter()
|
->alignCenter()
|
||||||
->sortable(),
|
->sortable(),
|
||||||
|
|||||||
@@ -351,12 +351,12 @@ class InvoiceInTransitResource extends Resource
|
|||||||
if (empty($transportName)) {
|
if (empty($transportName)) {
|
||||||
$invalidTransportName[] = "Row {$index}";
|
$invalidTransportName[] = "Row {$index}";
|
||||||
}
|
}
|
||||||
if (empty($LRBAWNo)) {
|
// if (empty($LRBAWNo)) {
|
||||||
$invalidLRBLAWNo[] = "Row {$index}";
|
// $invalidLRBLAWNo[] = "Row {$index}";
|
||||||
}
|
// }
|
||||||
if (empty($LRBAWDt)) {
|
// if (empty($LRBAWDt)) {
|
||||||
$invalidLRBLAWDt[] = "Row {$index}";
|
// $invalidLRBLAWDt[] = "Row {$index}";
|
||||||
}
|
// }
|
||||||
if (empty($pendingDays)) {
|
if (empty($pendingDays)) {
|
||||||
$invalidPenDay[] = "Row {$index}";
|
$invalidPenDay[] = "Row {$index}";
|
||||||
}
|
}
|
||||||
@@ -367,50 +367,56 @@ class InvoiceInTransitResource extends Resource
|
|||||||
$invalidPlaCoFound[] = $plantCode;
|
$invalidPlaCoFound[] = $plantCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if($LRBAWNo){
|
||||||
|
if(strlen($LRBAWNo) < 2){
|
||||||
|
$invalidLRBLAWNo[] = $LRBAWNo;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$plant = Plant::where('code', $plantCode)->first();
|
$plant = Plant::where('code', $plantCode)->first();
|
||||||
|
|
||||||
// $plantId = $plant->id;
|
// $plantId = $plant->id;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! empty($invalidPlantCode) || ! empty($invalidRecPlant) || ! empty($invalidRecPlantName) || ! empty($invalidInvNo) || ! empty($invalidInvDt) || ! empty($invalidICode) || ! empty($invalidDesc) || ! empty($invalidQty) || ($invalidTransportName) || ! empty($invalidLRBLAWNo) || ! empty($invalidLRBLAWDt) || ! empty($invalidPenDay)) {
|
if (! empty($invalidPlantCode) || ! empty($invalidRecPlant) || ! empty($invalidRecPlantName) || ! empty($invalidInvNo) || ! empty($invalidInvDt) || ! empty($invalidICode) || ! empty($invalidDesc) || ! empty($invalidQty) || ($invalidTransportName) || ! empty($invalidPenDay)) {
|
||||||
$errorMsg = '';
|
$errorMsg = '';
|
||||||
|
|
||||||
if (! empty($invalidPlantCode)) {
|
if (! empty($invalidPlantCode)) {
|
||||||
$errorMsg .= 'Missing Receiving Plant in rows: '.implode(', ', $invalidPlantCode).'<br>';
|
$errorMsg .= 'Missing Receiving Plant Code in rows: '.implode(', ', $invalidPlantCode).'<br>';
|
||||||
}
|
}
|
||||||
if (! empty($invalidRecPlant)) {
|
if (! empty($invalidRecPlant)) {
|
||||||
$errorMsg .= 'Missing Receiving Plant Name in rows: '.implode(', ', $invalidRecPlant).'<br>';
|
$errorMsg .= 'Missing Receiving Plant in rows: '.implode(', ', $invalidRecPlant).'<br>';
|
||||||
}
|
}
|
||||||
if (! empty($invalidRecPlantName)) {
|
if (! empty($invalidRecPlantName)) {
|
||||||
$errorMsg .= 'Missing Transit Days in rows: '.implode(', ', $invalidRecPlantName).'<br>';
|
$errorMsg .= 'Missing Receiving Plant Name in rows: '.implode(', ', $invalidRecPlantName).'<br>';
|
||||||
}
|
}
|
||||||
if (! empty($invalidInvNo)) {
|
if (! empty($invalidInvNo)) {
|
||||||
$errorMsg .= 'Missing Transport Name in rows: '.implode(', ', $invalidInvNo).'<br>';
|
$errorMsg .= 'Missing Invoice Number in rows: '.implode(', ', $invalidInvNo).'<br>';
|
||||||
}
|
}
|
||||||
if (! empty($invalidInvDt)) {
|
if (! empty($invalidInvDt)) {
|
||||||
$errorMsg .= 'Missing Receiving Plant in rows: '.implode(', ', $invalidInvDt).'<br>';
|
$errorMsg .= 'Missing Invoice Dates in rows: '.implode(', ', $invalidInvDt).'<br>';
|
||||||
}
|
}
|
||||||
if (! empty($invalidICode)) {
|
if (! empty($invalidICode)) {
|
||||||
$errorMsg .= 'Missing Receiving Plant Name in rows: '.implode(', ', $invalidICode).'<br>';
|
$errorMsg .= 'Missing Item Code in rows: '.implode(', ', $invalidICode).'<br>';
|
||||||
}
|
}
|
||||||
if (! empty($invalidDesc)) {
|
if (! empty($invalidDesc)) {
|
||||||
$errorMsg .= 'Missing Transit Days in rows: '.implode(', ', $invalidDesc).'<br>';
|
$errorMsg .= 'Missing Item Description in rows: '.implode(', ', $invalidDesc).'<br>';
|
||||||
}
|
}
|
||||||
if (! empty($invalidQty)) {
|
if (! empty($invalidQty)) {
|
||||||
$errorMsg .= 'Missing Transport Name in rows: '.implode(', ', $invalidQty).'<br>';
|
$errorMsg .= 'Missing Quantity in rows: '.implode(', ', $invalidQty).'<br>';
|
||||||
}
|
}
|
||||||
if (! empty($invalidTransportName)) {
|
if (! empty($invalidTransportName)) {
|
||||||
$errorMsg .= 'Missing Receiving Plant in rows: '.implode(', ', $invalidTransportName).'<br>';
|
$errorMsg .= 'Missing Transport Name in rows: '.implode(', ', $invalidTransportName).'<br>';
|
||||||
}
|
|
||||||
if (! empty($invalidLRBLAWNo)) {
|
|
||||||
$errorMsg .= 'Missing Receiving Plant Name in rows: '.implode(', ', $invalidLRBLAWNo).'<br>';
|
|
||||||
}
|
|
||||||
if (! empty($invalidLRBLAWDt)) {
|
|
||||||
$errorMsg .= 'Missing Transit Days in rows: '.implode(', ', $invalidLRBLAWDt).'<br>';
|
|
||||||
}
|
}
|
||||||
|
// if (! empty($invalidLRBLAWNo)) {
|
||||||
|
// $errorMsg .= 'Missing Receiving Plant Name in rows: '.implode(', ', $invalidLRBLAWNo).'<br>';
|
||||||
|
// }
|
||||||
|
// if (! empty($invalidLRBLAWDt)) {
|
||||||
|
// $errorMsg .= 'Missing Transit Days in rows: '.implode(', ', $invalidLRBLAWDt).'<br>';
|
||||||
|
// }
|
||||||
if (! empty($invalidPenDay)) {
|
if (! empty($invalidPenDay)) {
|
||||||
$errorMsg .= 'Missing Transport Name in rows: '.implode(', ', $invalidPenDay).'<br>';
|
$errorMsg .= 'Missing Pending Days in rows: '.implode(', ', $invalidPenDay).'<br>';
|
||||||
}
|
}
|
||||||
|
|
||||||
Notification::make()
|
Notification::make()
|
||||||
@@ -454,19 +460,30 @@ class InvoiceInTransitResource extends Resource
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (! empty($invalidLRBLAWNo)) {
|
||||||
|
$invalidLRBLAWNo = array_unique($invalidLRBLAWNo);
|
||||||
|
Notification::make()
|
||||||
|
->title('Invalid LR/BL/AW Number')
|
||||||
|
->body('LR/BL/AW Number should contain length minimum 2 digits:<br>'.implode(', ', $invalidLRBLAWNo))
|
||||||
|
->danger()
|
||||||
|
->send();
|
||||||
|
if ($disk->exists($path)) {
|
||||||
|
$disk->delete($path);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$mandatoryColumns = 23;
|
$mandatoryColumns = 23;
|
||||||
|
|
||||||
$firstRow = $rows[0] ?? [];
|
$firstRow = $rows[0] ?? [];
|
||||||
|
|
||||||
if (count($firstRow) < $mandatoryColumns) {
|
if (count($firstRow) < $mandatoryColumns) {
|
||||||
|
|
||||||
Notification::make()
|
Notification::make()
|
||||||
->title('Invalid Excel Format')
|
->title('Invalid Excel Format')
|
||||||
->body('Few columns not found. Columns A to W are mandatory.')
|
->body('Few columns not found. Columns A to W are mandatory.')
|
||||||
->danger()
|
->danger()
|
||||||
->persistent()
|
->persistent()
|
||||||
->send();
|
->send();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -530,7 +547,7 @@ class InvoiceInTransitResource extends Resource
|
|||||||
if (! empty($OBDDate)) {
|
if (! empty($OBDDate)) {
|
||||||
if (preg_match('/^\d{2}[-\/]\d{2}[-\/]\d{4}$/', $OBDDate)) {
|
if (preg_match('/^\d{2}[-\/]\d{2}[-\/]\d{4}$/', $OBDDate)) {
|
||||||
[$day, $month, $year] = preg_split('/[-\/]/', $OBDDate);
|
[$day, $month, $year] = preg_split('/[-\/]/', $OBDDate);
|
||||||
$formattedDate = "{$year}-{$month}-{$day}";
|
$formatted = "{$year}-{$month}-{$day}";
|
||||||
} elseif (is_numeric($OBDDate)) {
|
} elseif (is_numeric($OBDDate)) {
|
||||||
$formatted = \PhpOffice\PhpSpreadsheet\Shared\Date::excelToDateTimeObject($OBDDate)->format('Y-m-d');
|
$formatted = \PhpOffice\PhpSpreadsheet\Shared\Date::excelToDateTimeObject($OBDDate)->format('Y-m-d');
|
||||||
} else {
|
} else {
|
||||||
@@ -540,6 +557,16 @@ class InvoiceInTransitResource extends Resource
|
|||||||
$formatted = null;
|
$formatted = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$rowNumber = $index + 1;
|
||||||
|
if ($LRBAWNo == '' || $LRBAWDt == '') {
|
||||||
|
// $missedInvoices[] = $invoiceNo;
|
||||||
|
// $missedInvoices[$invoiceNo][] = $index + 1;
|
||||||
|
// continue;
|
||||||
|
$key = $invoiceNo ?: 'Row '.$rowNumber;
|
||||||
|
$missedInvoices[$key][$rowNumber] = true;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
$inserted = InvoiceInTransit::create([
|
$inserted = InvoiceInTransit::create([
|
||||||
'plant_id' => $plant->id,
|
'plant_id' => $plant->id,
|
||||||
'receiving_plant' => $receivingPlant,
|
'receiving_plant' => $receivingPlant,
|
||||||
@@ -567,10 +594,28 @@ class InvoiceInTransitResource extends Resource
|
|||||||
'created_by' => $operatorName,
|
'created_by' => $operatorName,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$formattedMissed = [];
|
||||||
|
|
||||||
|
if (!empty($missedInvoices)) {
|
||||||
|
$formattedMissed = array_map(
|
||||||
|
fn($rows, $invoice) =>
|
||||||
|
$invoice . ' (Row: ' . implode(', ', array_keys($rows)) . ')',
|
||||||
|
$missedInvoices,
|
||||||
|
array_keys($missedInvoices)
|
||||||
|
);
|
||||||
|
}
|
||||||
if ($inserted) {
|
if ($inserted) {
|
||||||
|
$message = "Invoice in transit uploaded successfully!";
|
||||||
|
|
||||||
|
if (!empty($formattedMissed)) {
|
||||||
|
$message .= "\n\nSkipped Invoices (Missing LR/Date):\n"
|
||||||
|
. implode("\n", $formattedMissed);
|
||||||
|
}
|
||||||
|
|
||||||
Notification::make()
|
Notification::make()
|
||||||
->title('Upload Success')
|
->title('Upload Completed')
|
||||||
->body('Invoice in transit uploaded successfully!')
|
->body($message)
|
||||||
->success()
|
->success()
|
||||||
->send();
|
->send();
|
||||||
|
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ class ProductCharacteristicsMasterResource extends Resource
|
|||||||
|
|
||||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
||||||
})
|
})
|
||||||
|
->disabled(fn (Get $get) => ! empty($get('id')))
|
||||||
->default(function () {
|
->default(function () {
|
||||||
$userHas = Filament::auth()->user()->plant_id;
|
$userHas = Filament::auth()->user()->plant_id;
|
||||||
|
|
||||||
@@ -72,6 +73,7 @@ class ProductCharacteristicsMasterResource extends Resource
|
|||||||
|
|
||||||
return \App\Models\Item::where('plant_id', $plantId)->pluck('code', 'id');
|
return \App\Models\Item::where('plant_id', $plantId)->pluck('code', 'id');
|
||||||
})
|
})
|
||||||
|
->disabled(fn (Get $get) => ! empty($get('id')))
|
||||||
->afterStateUpdated(function ($state, callable $set) {
|
->afterStateUpdated(function ($state, callable $set) {
|
||||||
$set('updated_by', Filament::auth()->user()?->name);
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
})
|
})
|
||||||
@@ -88,6 +90,7 @@ class ProductCharacteristicsMasterResource extends Resource
|
|||||||
|
|
||||||
return Line::where('plant_id', $plantId)->pluck('name', 'id');
|
return Line::where('plant_id', $plantId)->pluck('name', 'id');
|
||||||
})
|
})
|
||||||
|
->disabled(fn (Get $get) => ! empty($get('id')))
|
||||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||||
$set('machine_id', null);
|
$set('machine_id', null);
|
||||||
if (! $get('work_group_master_id')) {
|
if (! $get('work_group_master_id')) {
|
||||||
@@ -164,6 +167,7 @@ class ProductCharacteristicsMasterResource extends Resource
|
|||||||
->where('work_group_master_id', $workGroupId)
|
->where('work_group_master_id', $workGroupId)
|
||||||
->pluck('work_center', 'id');
|
->pluck('work_center', 'id');
|
||||||
})
|
})
|
||||||
|
->disabled(fn (Get $get) => ! empty($get('id')))
|
||||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||||
if (! $get('plant_id') || ! $get('line_id') || ! $get('work_group_master_id')) {
|
if (! $get('plant_id') || ! $get('line_id') || ! $get('work_group_master_id')) {
|
||||||
$set('machine_id', null);
|
$set('machine_id', null);
|
||||||
@@ -180,6 +184,7 @@ class ProductCharacteristicsMasterResource extends Resource
|
|||||||
->reactive()
|
->reactive()
|
||||||
->searchable()
|
->searchable()
|
||||||
// ->preload()
|
// ->preload()
|
||||||
|
->disabled(fn (Get $get) => ! empty($get('id') && ! Filament::auth()->user()->hasRole('Super Admin')))
|
||||||
->afterStateUpdated(function ($state, callable $set) {
|
->afterStateUpdated(function ($state, callable $set) {
|
||||||
$set('updated_by', Filament::auth()->user()?->name);
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
})
|
})
|
||||||
@@ -199,6 +204,7 @@ class ProductCharacteristicsMasterResource extends Resource
|
|||||||
])
|
])
|
||||||
->reactive()
|
->reactive()
|
||||||
// ->preload()
|
// ->preload()
|
||||||
|
->disabled(fn (Get $get) => ! empty($get('id') && ! Filament::auth()->user()->hasRole('Super Admin')))
|
||||||
->afterStateUpdated(function ($state, callable $set) {
|
->afterStateUpdated(function ($state, callable $set) {
|
||||||
$set('updated_by', Filament::auth()->user()?->name);
|
$set('updated_by', Filament::auth()->user()?->name);
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ class ProductionPlanResource extends Resource
|
|||||||
Section::make('')
|
Section::make('')
|
||||||
->schema([
|
->schema([
|
||||||
Forms\Components\Select::make('plant_id')
|
Forms\Components\Select::make('plant_id')
|
||||||
|
->label('Plant')
|
||||||
->relationship('plant', 'name')
|
->relationship('plant', 'name')
|
||||||
->required()
|
->required()
|
||||||
// ->nullable()
|
// ->nullable()
|
||||||
@@ -79,6 +80,7 @@ class ProductionPlanResource extends Resource
|
|||||||
->hint(fn ($get) => $get('ppPlantError') ? $get('ppPlantError') : null)
|
->hint(fn ($get) => $get('ppPlantError') ? $get('ppPlantError') : null)
|
||||||
->hintColor('danger'),
|
->hintColor('danger'),
|
||||||
Forms\Components\Select::make('line_id')
|
Forms\Components\Select::make('line_id')
|
||||||
|
->label('Line')
|
||||||
->relationship('line', 'name')
|
->relationship('line', 'name')
|
||||||
->required()
|
->required()
|
||||||
// ->nullable()
|
// ->nullable()
|
||||||
@@ -437,7 +439,7 @@ class ProductionPlanResource extends Resource
|
|||||||
->sortable()
|
->sortable()
|
||||||
->searchable(),
|
->searchable(),
|
||||||
Tables\Columns\TextColumn::make('line.name')
|
Tables\Columns\TextColumn::make('line.name')
|
||||||
->label('Plant')
|
->label('Line')
|
||||||
->alignCenter()
|
->alignCenter()
|
||||||
->sortable()
|
->sortable()
|
||||||
->searchable(),
|
->searchable(),
|
||||||
|
|||||||
308
app/Filament/Resources/WireMasterPackingResource.php
Normal file
308
app/Filament/Resources/WireMasterPackingResource.php
Normal file
@@ -0,0 +1,308 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Resources;
|
||||||
|
|
||||||
|
use App\Filament\Resources\WireMasterPackingResource\Pages;
|
||||||
|
use App\Models\CustomerPoMaster;
|
||||||
|
use App\Models\Plant;
|
||||||
|
use App\Models\WireMasterPacking;
|
||||||
|
use Filament\Facades\Filament;
|
||||||
|
use Filament\Forms;
|
||||||
|
use Filament\Forms\Components\Section;
|
||||||
|
use Filament\Forms\Components\TextInput;
|
||||||
|
use Filament\Forms\Form;
|
||||||
|
use Filament\Notifications\Notification;
|
||||||
|
use Filament\Resources\Resource;
|
||||||
|
use Filament\Tables;
|
||||||
|
use Filament\Tables\Table;
|
||||||
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
|
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||||
|
|
||||||
|
class WireMasterPackingResource extends Resource
|
||||||
|
{
|
||||||
|
protected static ?string $model = WireMasterPacking::class;
|
||||||
|
|
||||||
|
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
|
||||||
|
|
||||||
|
public $importedPoList = [];
|
||||||
|
|
||||||
|
|
||||||
|
public static function form(Form $form): Form
|
||||||
|
{
|
||||||
|
return $form
|
||||||
|
->schema([
|
||||||
|
Section::make('')
|
||||||
|
->schema([
|
||||||
|
Forms\Components\Select::make('plant_id')
|
||||||
|
->label('Plant')
|
||||||
|
->reactive()
|
||||||
|
->relationship('plant', 'name')
|
||||||
|
->options(function (callable $get) {
|
||||||
|
$userHas = Filament::auth()->user()->plant_id;
|
||||||
|
|
||||||
|
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
||||||
|
})
|
||||||
|
->required(),
|
||||||
|
Forms\Components\Select::make('customer_po_master_id')
|
||||||
|
->label('Customer PO')
|
||||||
|
->reactive()
|
||||||
|
->searchable()
|
||||||
|
->options(function (callable $get) {
|
||||||
|
$plantId = $get('plant_id');
|
||||||
|
if (empty($plantId)) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
return CustomerPoMaster::where('plant_id', $plantId)->pluck('customer_po', 'id');
|
||||||
|
})
|
||||||
|
->required(),
|
||||||
|
Forms\Components\TextInput::make('wire_packing_number')
|
||||||
|
->label('Scan Wire Packing No')
|
||||||
|
->reactive()
|
||||||
|
->required()
|
||||||
|
->readonly()
|
||||||
|
->extraAttributes([
|
||||||
|
'x-data' => '{ value: "" }',
|
||||||
|
'x-model' => 'value',
|
||||||
|
'x-on:keydown.enter.prevent' => '$wire.processPalletNo()',
|
||||||
|
])
|
||||||
|
->suffixAction(fn ($get, $set) => Forms\Components\Actions\Action::make('addWirePackNo')
|
||||||
|
->label('')
|
||||||
|
->button()
|
||||||
|
->icon('heroicon-o-plus')
|
||||||
|
->color('primary')
|
||||||
|
->extraAttributes([
|
||||||
|
'class' => 'p-1 w-7 h-7',
|
||||||
|
])
|
||||||
|
->action(function ($get, $set, $livewire) {
|
||||||
|
|
||||||
|
$plantId = $get('plant_id');
|
||||||
|
|
||||||
|
session(['pallet_clicked_time' => now()->toDateTimeString()]);
|
||||||
|
session(['pallet_created_by' => Filament::auth()->user()->name]);
|
||||||
|
|
||||||
|
$year = now()->format('y');
|
||||||
|
$month = now()->format('m');
|
||||||
|
$prefix = "MP-{$year}{$month}";
|
||||||
|
|
||||||
|
$lastPallet = WireMasterPacking::where('wire_packing_number', 'like', "{$prefix}%")
|
||||||
|
->orderByDesc('wire_packing_number')
|
||||||
|
->first();
|
||||||
|
|
||||||
|
// if ($lastPallet) {
|
||||||
|
// // Extract numeric part after prefix
|
||||||
|
// $lastNumber = substr($lastPallet->wire_packing_number, strlen($prefix));
|
||||||
|
// $newNumber = str_pad(((int) $lastNumber) + 1, 3, '0', STR_PAD_LEFT);
|
||||||
|
// } else {
|
||||||
|
// // First pallet of the month
|
||||||
|
// $newNumber = '001';
|
||||||
|
// }
|
||||||
|
|
||||||
|
if ($lastPallet) {
|
||||||
|
$lastNumber = (int) substr(
|
||||||
|
$lastPallet->wire_packing_number,
|
||||||
|
strlen($prefix)
|
||||||
|
);
|
||||||
|
|
||||||
|
$newNumber = $lastNumber + 1;
|
||||||
|
|
||||||
|
$newNumber = $newNumber < 1000
|
||||||
|
? str_pad($newNumber, 3, '0', STR_PAD_LEFT)
|
||||||
|
: (string) $newNumber;
|
||||||
|
} else {
|
||||||
|
$newNumber = '001';
|
||||||
|
}
|
||||||
|
|
||||||
|
$newPalletNumber = "{$prefix}{$newNumber}";
|
||||||
|
|
||||||
|
$set('wire_packing_number', $newPalletNumber);
|
||||||
|
$set('plant_id', $plantId);
|
||||||
|
|
||||||
|
// $livewire->redirectToQrPdf($newPalletNumber);
|
||||||
|
})
|
||||||
|
),
|
||||||
|
Forms\Components\TextInput::make('process_order')
|
||||||
|
->label('Process Order')
|
||||||
|
->reactive()
|
||||||
|
->readOnly(fn (callable $get) => ! $get('wire_packing_number'))
|
||||||
|
->extraAttributes([
|
||||||
|
'x-on:keydown.enter.prevent' => '$wire.processOrderSNo()',
|
||||||
|
]),
|
||||||
|
Forms\Components\TextInput::make('removeSno_number')
|
||||||
|
->label('Remove Process Order')
|
||||||
|
->reactive()
|
||||||
|
->minLength(9)
|
||||||
|
->readOnly(fn (callable $get) => ! $get('wire_packing_number') || $get('process_order'))
|
||||||
|
->extraAttributes([
|
||||||
|
'x-data' => '{ value: "" }',
|
||||||
|
'x-model' => 'value',
|
||||||
|
'x-on:keydown.enter.prevent' => '$wire.processRemoveSNo()',
|
||||||
|
]),
|
||||||
|
Forms\Components\TextInput::make('Sno_quantity')
|
||||||
|
->label('SNo. Quantity')
|
||||||
|
->readOnly()
|
||||||
|
->default('0'),
|
||||||
|
Forms\Components\Select::make('pending_pallet_list')
|
||||||
|
->label('Pending Pallet List')
|
||||||
|
->reactive()
|
||||||
|
->afterStateUpdated(function ($state, callable $set) {
|
||||||
|
$set('wire_packing_number', $state);
|
||||||
|
$set('pallet_number_locked', false);
|
||||||
|
})
|
||||||
|
->options(function ($get) {
|
||||||
|
|
||||||
|
$plantId = $get('plant_id');
|
||||||
|
|
||||||
|
if (! $plantId) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
return WireMasterPacking::query()
|
||||||
|
->where('plant_id', $plantId)
|
||||||
|
->where(function ($query) {
|
||||||
|
$query->whereNull('wire_packing_status')
|
||||||
|
->orWhere('wire_packing_status', '');
|
||||||
|
})
|
||||||
|
->whereNotNull('wire_packing_number')
|
||||||
|
->orderBy('wire_packing_number', 'asc')
|
||||||
|
->pluck('wire_packing_number')
|
||||||
|
->unique()
|
||||||
|
->mapWithKeys(fn ($number) => [$number => $number])
|
||||||
|
->toArray();
|
||||||
|
}),
|
||||||
|
// Forms\Components\Checkbox::make('is_po')
|
||||||
|
// ->label('PO!')
|
||||||
|
// ->reactive(),
|
||||||
|
Forms\Components\View::make('forms.components.save-processorder-button'),
|
||||||
|
|
||||||
|
Forms\Components\Hidden::make('created_by')
|
||||||
|
->label('Created By'),
|
||||||
|
Forms\Components\Hidden::make('updated_by')
|
||||||
|
->label('Updated By'),
|
||||||
|
])
|
||||||
|
->columns(6),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function table(Table $table): Table
|
||||||
|
{
|
||||||
|
return $table
|
||||||
|
->columns([
|
||||||
|
Tables\Columns\TextColumn::make('No.')
|
||||||
|
->label('No.')
|
||||||
|
->alignCenter()
|
||||||
|
->getStateUsing(function ($record, $livewire, $column, $rowLoop) {
|
||||||
|
$paginator = $livewire->getTableRecords();
|
||||||
|
$perPage = method_exists($paginator, 'perPage') ? $paginator->perPage() : 10;
|
||||||
|
$currentPage = method_exists($paginator, 'currentPage') ? $paginator->currentPage() : 1;
|
||||||
|
|
||||||
|
return ($currentPage - 1) * $perPage + $rowLoop->iteration;
|
||||||
|
}),
|
||||||
|
Tables\Columns\TextColumn::make('plant.name')
|
||||||
|
->label('Plant')
|
||||||
|
->alignCenter()
|
||||||
|
->searchable()
|
||||||
|
->sortable(),
|
||||||
|
Tables\Columns\TextColumn::make('item.code')
|
||||||
|
->label('Item')
|
||||||
|
->alignCenter()
|
||||||
|
->searchable()
|
||||||
|
->sortable(),
|
||||||
|
Tables\Columns\TextColumn::make('item.description')
|
||||||
|
->label('Description')
|
||||||
|
->alignCenter()
|
||||||
|
->searchable()
|
||||||
|
->sortable(),
|
||||||
|
Tables\Columns\TextColumn::make('customerPo.customer_po')
|
||||||
|
->label('Customer PO')
|
||||||
|
->alignCenter()
|
||||||
|
->searchable()
|
||||||
|
->sortable(),
|
||||||
|
Tables\Columns\TextColumn::make('customerPo.customer_name')
|
||||||
|
->label('Customer Name')
|
||||||
|
->alignCenter()
|
||||||
|
->searchable()
|
||||||
|
->sortable(),
|
||||||
|
Tables\Columns\TextColumn::make('wire_packing_number')
|
||||||
|
->label('Wire Packing Number')
|
||||||
|
->alignCenter()
|
||||||
|
->searchable()
|
||||||
|
->sortable(),
|
||||||
|
Tables\Columns\TextColumn::make('process_order')
|
||||||
|
->label('Process Order')
|
||||||
|
->alignCenter()
|
||||||
|
->searchable()
|
||||||
|
->sortable(),
|
||||||
|
Tables\Columns\TextColumn::make('weight')
|
||||||
|
->label('Weight')
|
||||||
|
->alignCenter()
|
||||||
|
->searchable()
|
||||||
|
->sortable(),
|
||||||
|
Tables\Columns\TextColumn::make('wire_packing_status')
|
||||||
|
->label('Wire Packing Status')
|
||||||
|
->alignCenter()
|
||||||
|
->searchable()
|
||||||
|
->sortable(),
|
||||||
|
Tables\Columns\TextColumn::make('created_by')
|
||||||
|
->label('Created By')
|
||||||
|
->alignCenter()
|
||||||
|
->searchable()
|
||||||
|
->sortable(),
|
||||||
|
Tables\Columns\TextColumn::make('created_at')
|
||||||
|
->label('Created At')
|
||||||
|
->alignCenter()
|
||||||
|
->dateTime()
|
||||||
|
->sortable()
|
||||||
|
->toggleable(isToggledHiddenByDefault: true),
|
||||||
|
Tables\Columns\TextColumn::make('updated_at')
|
||||||
|
->label('Updated At')
|
||||||
|
->alignCenter()
|
||||||
|
->dateTime()
|
||||||
|
->sortable()
|
||||||
|
->toggleable(isToggledHiddenByDefault: true),
|
||||||
|
Tables\Columns\TextColumn::make('deleted_at')
|
||||||
|
->dateTime()
|
||||||
|
->sortable()
|
||||||
|
->toggleable(isToggledHiddenByDefault: true),
|
||||||
|
])
|
||||||
|
->filters([
|
||||||
|
Tables\Filters\TrashedFilter::make(),
|
||||||
|
])
|
||||||
|
->actions([
|
||||||
|
Tables\Actions\ViewAction::make(),
|
||||||
|
Tables\Actions\EditAction::make(),
|
||||||
|
])
|
||||||
|
->bulkActions([
|
||||||
|
Tables\Actions\BulkActionGroup::make([
|
||||||
|
Tables\Actions\DeleteBulkAction::make(),
|
||||||
|
Tables\Actions\ForceDeleteBulkAction::make(),
|
||||||
|
Tables\Actions\RestoreBulkAction::make(),
|
||||||
|
]),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getRelations(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
//
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getPages(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'index' => Pages\ListWireMasterPackings::route('/'),
|
||||||
|
'create' => Pages\CreateWireMasterPacking::route('/create'),
|
||||||
|
'view' => Pages\ViewWireMasterPacking::route('/{record}'),
|
||||||
|
'edit' => Pages\EditWireMasterPacking::route('/{record}/edit'),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getEloquentQuery(): Builder
|
||||||
|
{
|
||||||
|
return parent::getEloquentQuery()
|
||||||
|
->withoutGlobalScopes([
|
||||||
|
SoftDeletingScope::class,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,732 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Resources\WireMasterPackingResource\Pages;
|
||||||
|
|
||||||
|
use App\Filament\Resources\WireMasterPackingResource;
|
||||||
|
use App\Models\Item;
|
||||||
|
use App\Models\Plant;
|
||||||
|
use App\Models\WireMasterPacking;
|
||||||
|
use Filament\Actions;
|
||||||
|
use Filament\Facades\Filament;
|
||||||
|
use Filament\Notifications\Notification;
|
||||||
|
use Filament\Resources\Pages\CreateRecord;
|
||||||
|
use Illuminate\View\View;
|
||||||
|
|
||||||
|
class CreateWireMasterPacking extends CreateRecord
|
||||||
|
{
|
||||||
|
protected static string $resource = WireMasterPackingResource::class;
|
||||||
|
|
||||||
|
public $processOrder;
|
||||||
|
|
||||||
|
public $customerPo;
|
||||||
|
|
||||||
|
public $plantId;
|
||||||
|
|
||||||
|
public $count = 0;
|
||||||
|
|
||||||
|
public $snoCount = 0;
|
||||||
|
|
||||||
|
public $pendingPallet;
|
||||||
|
|
||||||
|
public array $importedPoList = [];
|
||||||
|
|
||||||
|
protected static string $view = 'filament.resources.wire-sticker-resource.create-wire-master-packing';
|
||||||
|
|
||||||
|
protected $listeners = [
|
||||||
|
'updateSnoQuantity' => 'handleUpdateSnoQuantity',
|
||||||
|
];
|
||||||
|
|
||||||
|
public function handleUpdateSnoQuantity($newValue)
|
||||||
|
{
|
||||||
|
$this->form->fill([
|
||||||
|
'Sno_quantity' => $newValue,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function processOrderSNo(){
|
||||||
|
|
||||||
|
$plantId = $this->form->getState()['plant_id'];
|
||||||
|
|
||||||
|
$plantId = trim($plantId) ?? null;
|
||||||
|
|
||||||
|
$processOrder = trim($this->form->getState()['process_order'])?? null;
|
||||||
|
|
||||||
|
$customerPo = trim($this->form->getState()['customer_po_master_id'])?? null;
|
||||||
|
|
||||||
|
$wirePackNo = trim($this->form->getState()['wire_packing_number'])?? null;
|
||||||
|
|
||||||
|
$wirePackNo = trim($wirePackNo) ?? null;
|
||||||
|
|
||||||
|
$user = Filament::auth()->user();
|
||||||
|
|
||||||
|
$operatorName = $user->name;
|
||||||
|
|
||||||
|
if (empty($processOrder) || $processOrder == '')
|
||||||
|
{
|
||||||
|
Notification::make()
|
||||||
|
->title("Process Order can't be empty")
|
||||||
|
->danger()
|
||||||
|
->duration(5000)
|
||||||
|
->send();
|
||||||
|
|
||||||
|
$this->form->fill([
|
||||||
|
'process_order' => null,
|
||||||
|
'plant_id' => $plantId,
|
||||||
|
'customer_po_master_id' => $customerPo,
|
||||||
|
'wire_packing_number' => $wirePackNo,
|
||||||
|
'Sno_quantity' => 0,
|
||||||
|
'created_by' => $operatorName,
|
||||||
|
'scanned_by' => $operatorName,
|
||||||
|
]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$pattern = '/^([^|]+)\|([^|]+)\|(\d+(\.\d+)?)$/';
|
||||||
|
|
||||||
|
if (!preg_match($pattern, $processOrder, $matches))
|
||||||
|
{
|
||||||
|
Notification::make()
|
||||||
|
->title("Scan Valid Qr code ")
|
||||||
|
->body("Expected Format : (MaterialCode|Process Order-Id|Weight)")
|
||||||
|
->danger()
|
||||||
|
->duration(5000)
|
||||||
|
->send();
|
||||||
|
|
||||||
|
$this->form->fill([
|
||||||
|
'process_order' => null,
|
||||||
|
'plant_id' => $plantId,
|
||||||
|
'customer_po_master_id' => $customerPo,
|
||||||
|
'wire_packing_number' => $wirePackNo,
|
||||||
|
'Sno_quantity' => 0,
|
||||||
|
'created_by' => $operatorName,
|
||||||
|
'scanned_by' => $operatorName,
|
||||||
|
]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$materialCode = $matches[1];
|
||||||
|
$processOrderId = $matches[2];
|
||||||
|
$weight = $matches[3];
|
||||||
|
|
||||||
|
$icode = Item::where('code', $materialCode)->first();
|
||||||
|
|
||||||
|
if(!$icode)
|
||||||
|
{
|
||||||
|
Notification::make()
|
||||||
|
->title("Unknown Item Code")
|
||||||
|
->body("Item Code not found '$materialCode'")
|
||||||
|
->danger()
|
||||||
|
->duration(5000)
|
||||||
|
->send();
|
||||||
|
|
||||||
|
$this->form->fill([
|
||||||
|
'process_order' => null,
|
||||||
|
'plant_id' => $plantId,
|
||||||
|
'customer_po_master_id' => $customerPo,
|
||||||
|
'wire_packing_number' => $wirePackNo,
|
||||||
|
'Sno_quantity' => 0,
|
||||||
|
'created_by' => $operatorName,
|
||||||
|
'scanned_by' => $operatorName,
|
||||||
|
]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$icodeAgaPlant = Item::where('code', $materialCode)->where('plant_id', $plantId)->first();
|
||||||
|
|
||||||
|
$plantCode = Plant::where('id', $plantId)->first();
|
||||||
|
|
||||||
|
$plantcode = $plantCode->code;
|
||||||
|
|
||||||
|
$itemId = $icodeAgaPlant->id;
|
||||||
|
|
||||||
|
if(!$icodeAgaPlant)
|
||||||
|
{
|
||||||
|
Notification::make()
|
||||||
|
->title("Unknown Item Code")
|
||||||
|
->body("Item Code not found '$materialCode' against Plant Code '$plantcode'")
|
||||||
|
->danger()
|
||||||
|
->duration(5000)
|
||||||
|
->send();
|
||||||
|
|
||||||
|
$this->form->fill([
|
||||||
|
'process_order' => null,
|
||||||
|
'plant_id' => $plantId,
|
||||||
|
'customer_po_master_id' => $customerPo,
|
||||||
|
'wire_packing_number' => $wirePackNo,
|
||||||
|
'Sno_quantity' => 0,
|
||||||
|
'created_by' => $operatorName,
|
||||||
|
'scanned_by' => $operatorName,
|
||||||
|
]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$processOrderAgaPlant = WireMasterPacking::where('process_order', $processOrderId)->where('plant_id', $plantId)->first();
|
||||||
|
|
||||||
|
if($processOrderAgaPlant)
|
||||||
|
{
|
||||||
|
Notification::make()
|
||||||
|
->title("Duplicate Process Order")
|
||||||
|
->body("Duplicate process order found '$processOrderId' against Plant Code '$plantcode'")
|
||||||
|
->danger()
|
||||||
|
->duration(5000)
|
||||||
|
->send();
|
||||||
|
|
||||||
|
$this->form->fill([
|
||||||
|
'process_order' => null,
|
||||||
|
'plant_id' => $plantId,
|
||||||
|
'customer_po_master_id' => $customerPo,
|
||||||
|
'wire_packing_number' => $wirePackNo,
|
||||||
|
'Sno_quantity' => 0,
|
||||||
|
'created_by' => $operatorName,
|
||||||
|
'scanned_by' => $operatorName,
|
||||||
|
]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try
|
||||||
|
{
|
||||||
|
$existingPallet = WireMasterPacking::where('plant_id', $plantId)
|
||||||
|
->where('wire_packing_number', $wirePackNo)
|
||||||
|
->first();
|
||||||
|
|
||||||
|
$count = WireMasterPacking::where('plant_id', $plantId)
|
||||||
|
->where('wire_packing_number', $wirePackNo)
|
||||||
|
->count('wire_packing_number');
|
||||||
|
|
||||||
|
$createdAt = $existingPallet ? $existingPallet->created_at : $clickedAt ?? now();
|
||||||
|
|
||||||
|
$createdBy = $existingPallet ? $existingPallet->created_by : $clickedBy ?? $operatorName;
|
||||||
|
|
||||||
|
$record = WireMasterPacking::create([
|
||||||
|
'plant_id' => $plantId,
|
||||||
|
'item_id' => $itemId,
|
||||||
|
'wire_packing_number' => $wirePackNo,
|
||||||
|
'process_order' => $processOrderId,
|
||||||
|
'customer_po_master_id' => $customerPo,
|
||||||
|
'weight' => $weight,
|
||||||
|
'created_by' => $createdBy,
|
||||||
|
'scanned_by' => $operatorName,
|
||||||
|
'created_at' => $createdAt,
|
||||||
|
'scanned_at' => now(),
|
||||||
|
'updated_by' => $operatorName,
|
||||||
|
]);
|
||||||
|
|
||||||
|
if ($record)
|
||||||
|
{
|
||||||
|
|
||||||
|
$this->snoCount = WireMasterPacking::where('plant_id', $plantId)
|
||||||
|
->where('wire_packing_number', $wirePackNo)
|
||||||
|
->count();
|
||||||
|
|
||||||
|
$this->dispatch('loadData', $wirePackNo, $plantId);
|
||||||
|
$this->form->fill([
|
||||||
|
'plant_id' => $plantId,
|
||||||
|
'customer_po_master_id' => $customerPo,
|
||||||
|
'wire_packing_number' => $wirePackNo,
|
||||||
|
'process_order' => null,
|
||||||
|
// 'pending_pallet_list' => $pendingPallet,
|
||||||
|
'Sno_quantity' => $this->snoCount,
|
||||||
|
'created_by' => $operatorName,
|
||||||
|
'scanned_by' => $operatorName,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Notification::make()
|
||||||
|
->title("Failed to insert scanned serial number '$processOrderId' into wire master table!")
|
||||||
|
->danger()
|
||||||
|
->duration(5000)
|
||||||
|
->send();
|
||||||
|
|
||||||
|
$this->dispatch('loadData', $wirePackNo, $plantId);
|
||||||
|
$this->form->fill([
|
||||||
|
'plant_id' => $plantId,
|
||||||
|
'customer_po_master_id' => $customerPo,
|
||||||
|
'wire_packing_number' => $wirePackNo,
|
||||||
|
'process_order' => null,
|
||||||
|
// 'pending_pallet_list' => $pendingPallet,
|
||||||
|
'Sno_quantity' => $count,
|
||||||
|
'scanned_by' => $operatorName,
|
||||||
|
]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (\Exception $e)
|
||||||
|
{
|
||||||
|
Notification::make()
|
||||||
|
->title('Error: Serial not inserted.')
|
||||||
|
->body("Something went wrong while inserting process order '{$processOrderId}' into pallet table!\nScan the new process order to proceed...")
|
||||||
|
->danger()
|
||||||
|
->duration(5000)
|
||||||
|
->send();
|
||||||
|
|
||||||
|
$this->dispatch('loadData', $wirePackNo, $plantId);
|
||||||
|
$this->form->fill([
|
||||||
|
'plant_id' => $plantId,
|
||||||
|
'customer_po_master_id' => $customerPo,
|
||||||
|
'wire_packing_number' => $wirePackNo,
|
||||||
|
'process_order' => null,
|
||||||
|
// 'pending_pallet_list' => $pendingPallet,
|
||||||
|
'Sno_quantity' => $count,
|
||||||
|
'created_by' => $operatorName,
|
||||||
|
'scanned_by' => $operatorName,
|
||||||
|
]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->dispatch('loadData', $wirePackNo, $plantId);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function markAsComplete()
|
||||||
|
{
|
||||||
|
|
||||||
|
$plantId = $this->form->getState()['plant_id'];
|
||||||
|
|
||||||
|
$plantId = trim($plantId) ?? null;
|
||||||
|
|
||||||
|
$pendingPallet = $this->form->getState()['pending_pallet_list'];
|
||||||
|
|
||||||
|
$palletNumber = trim($this->form->getState()['wire_packing_number'])?? null;
|
||||||
|
|
||||||
|
$palletNumber = trim($palletNumber) ?? null;
|
||||||
|
|
||||||
|
$processOrder = trim($this->form->getState()['process_order'])?? null;
|
||||||
|
|
||||||
|
$processOrder = trim($processOrder) ?? null;
|
||||||
|
|
||||||
|
$user = Filament::auth()->user();
|
||||||
|
|
||||||
|
$operatorName = $user->name;
|
||||||
|
|
||||||
|
$isCompleted = $this->data['is_completed'] ?? false;
|
||||||
|
|
||||||
|
// $this->pendingPallet = $this->form->getState()['pending_pallet_list'];
|
||||||
|
|
||||||
|
if (! ($this->data['is_completed'] ?? false)) {
|
||||||
|
Notification::make()
|
||||||
|
->title('Completion required')
|
||||||
|
->body('Please check the "Is Completed" checkbox to finish master packing.')
|
||||||
|
->warning()
|
||||||
|
->duration(3000)
|
||||||
|
->send();
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$palletExist = WireMasterPacking::where('wire_packing_number', $palletNumber)
|
||||||
|
->where('plant_id', $plantId)
|
||||||
|
->first();
|
||||||
|
|
||||||
|
if (!$palletExist)
|
||||||
|
{
|
||||||
|
Notification::make()
|
||||||
|
->title("Pallet number '$palletNumber' does not have process orders to save!<br>Add the valid process order into pallet number to proceed...")
|
||||||
|
->danger()
|
||||||
|
->duration(5000)
|
||||||
|
->send();
|
||||||
|
|
||||||
|
$this->dispatch('loadData', $palletNumber, $plantId);
|
||||||
|
$this->form->fill([
|
||||||
|
'process_order' => null,
|
||||||
|
'plant_id' => $plantId,
|
||||||
|
'wire_packing_number' => $palletNumber,
|
||||||
|
'pending_pallet_list' => $pendingPallet,
|
||||||
|
'Sno_quantity' => 0,
|
||||||
|
'created_by' => $operatorName,
|
||||||
|
'scanned_by' => $operatorName,
|
||||||
|
]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$allCompleted = WireMasterPacking::where('plant_id', $plantId)
|
||||||
|
->where('wire_packing_number', $palletNumber)
|
||||||
|
->where('wire_packing_status', '=','Completed')
|
||||||
|
->first();
|
||||||
|
|
||||||
|
if ($allCompleted)
|
||||||
|
{
|
||||||
|
Notification::make()
|
||||||
|
->title("Master Packing pallet number '$palletNumber' already completed the master packing!<br>Generate the new Master Packing Pallet number or choose from pending pallet list!")
|
||||||
|
->danger()
|
||||||
|
->duration(5000)
|
||||||
|
->send();
|
||||||
|
|
||||||
|
$this->dispatch('loadData', '', $plantId);
|
||||||
|
$this->form->fill([
|
||||||
|
'process_order' => null,
|
||||||
|
'plant_id' => $plantId,
|
||||||
|
'wire_packing_number' => null,
|
||||||
|
'pending_pallet_list' => null,//$pendingPallet
|
||||||
|
'Sno_quantity' => 0,
|
||||||
|
'created_by' => $operatorName,
|
||||||
|
'scanned_by' => $operatorName,
|
||||||
|
]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// $count = PalletValidation::where('plant_id', $plantId)
|
||||||
|
// ->where('pallet_number', $palletNumber)
|
||||||
|
// ->count('pallet_number');
|
||||||
|
|
||||||
|
if (!$isCompleted)
|
||||||
|
{
|
||||||
|
$updated = WireMasterPacking::where('wire_packing_number', $palletNumber)
|
||||||
|
->where('plant_id', $plantId)
|
||||||
|
->update([
|
||||||
|
'updated_at' => now(),
|
||||||
|
'updated_by' => $operatorName,
|
||||||
|
]);
|
||||||
|
|
||||||
|
if ($updated > 0)
|
||||||
|
{
|
||||||
|
Notification::make()
|
||||||
|
->title("Pallet number '$palletNumber' records saved successfully!")
|
||||||
|
->success()
|
||||||
|
->duration(800)
|
||||||
|
->send();
|
||||||
|
|
||||||
|
$this->dispatch('loadData', '', $plantId);
|
||||||
|
$this->form->fill([
|
||||||
|
'process_order' => null,
|
||||||
|
'plant_id' => $plantId,
|
||||||
|
'wire_packing_number' => null,//$palletNumber
|
||||||
|
'pending_pallet_list' => null,//$pendingPallet
|
||||||
|
'Sno_quantity' => 0,//$count,
|
||||||
|
'created_by' => $operatorName,
|
||||||
|
'scanned_by' => $operatorName,
|
||||||
|
]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$updated = WireMasterPacking::where('wire_packing_number', $palletNumber)
|
||||||
|
->where('plant_id', $plantId)
|
||||||
|
->update([
|
||||||
|
'wire_packing_status' => 'Completed',
|
||||||
|
'updated_at' => now(),
|
||||||
|
'updated_by' => $operatorName,
|
||||||
|
]);
|
||||||
|
|
||||||
|
if ($updated > 0)
|
||||||
|
{
|
||||||
|
Notification::make()
|
||||||
|
->title("Pallet number '$palletNumber' completed the master packing successfully!")
|
||||||
|
->success()
|
||||||
|
->duration(800)
|
||||||
|
->send();
|
||||||
|
|
||||||
|
$this->dispatch('loadData', '', $plantId);
|
||||||
|
$this->form->fill([
|
||||||
|
'process_order' => null,
|
||||||
|
'plant_id' => $plantId,
|
||||||
|
'wire_packing_number' => null,//$palletNumber
|
||||||
|
'pending_pallet_list' => null,//$pendingPallet
|
||||||
|
'Sno_quantity' => 0,//$count
|
||||||
|
'created_by' => $operatorName,
|
||||||
|
'scanned_by' => $operatorName,
|
||||||
|
]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function processPalletNo()
|
||||||
|
{
|
||||||
|
$plantId = $this->form->getState()['plant_id'];
|
||||||
|
|
||||||
|
$plantId = trim($plantId) ?? null;
|
||||||
|
|
||||||
|
$pendingPallet = $this->form->getState()['pending_pallet_list'];
|
||||||
|
|
||||||
|
$palletNumber = trim($this->form->getState()['wire_packing_number']) ?? null;
|
||||||
|
|
||||||
|
$customerPo = trim($this->form->getState()['customer_po_master_id'])?? null;
|
||||||
|
|
||||||
|
$palletNumber = trim($palletNumber) ?? null;
|
||||||
|
|
||||||
|
$processOrder = trim($this->form->getState()['process_order']) ?? null;
|
||||||
|
|
||||||
|
$processOrder = trim($processOrder) ?? null;
|
||||||
|
|
||||||
|
$user = Filament::auth()->user();
|
||||||
|
|
||||||
|
$operatorName = $user->name;
|
||||||
|
|
||||||
|
//$this->dispatch('loadData', $palletNumber, $plantId);
|
||||||
|
$this->form->fill([
|
||||||
|
'serial_number' => null,
|
||||||
|
'plant_id' => $plantId,
|
||||||
|
'customer_po_master_id' => $customerPo,
|
||||||
|
'pallet_number' => $palletNumber,
|
||||||
|
'pending_pallet_list' => $pendingPallet,
|
||||||
|
'Sno_quantity' => 0,
|
||||||
|
'created_by' => $operatorName,
|
||||||
|
'scanned_by' => $operatorName,
|
||||||
|
]);
|
||||||
|
|
||||||
|
if (!$palletNumber)
|
||||||
|
{
|
||||||
|
Notification::make()
|
||||||
|
->title('Pallet number is required.')
|
||||||
|
->danger()
|
||||||
|
->duration(5000)
|
||||||
|
->send();
|
||||||
|
|
||||||
|
$this->dispatch('loadData', '', $plantId);
|
||||||
|
$this->form->fill([
|
||||||
|
'process_order' => null,
|
||||||
|
'plant_id' => $plantId,
|
||||||
|
'customer_po_master_id' => $customerPo,
|
||||||
|
'wire_packing_number' => $palletNumber,
|
||||||
|
'pending_pallet_list' => $pendingPallet,
|
||||||
|
'Sno_quantity' => 0,
|
||||||
|
'created_by' => $operatorName,
|
||||||
|
'scanned_by' => $operatorName,
|
||||||
|
]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (strlen($palletNumber) < 10)
|
||||||
|
{
|
||||||
|
Notification::make()
|
||||||
|
->title("Pallet number '$palletNumber' must be at least 10 digits.")
|
||||||
|
->danger()
|
||||||
|
->duration(5000)
|
||||||
|
->send();
|
||||||
|
|
||||||
|
$this->dispatch('loadLocator' ,'',$plantId);
|
||||||
|
$this->form->fill([
|
||||||
|
'serial_number' => null,
|
||||||
|
'plant_id' => $plantId,
|
||||||
|
'customer_po_master_id' => $customerPo,
|
||||||
|
'pallet_number' => $palletNumber,
|
||||||
|
'pending_pallet_list' => $pendingPallet,
|
||||||
|
'Sno_quantity' => 0,
|
||||||
|
'created_by' => $operatorName,
|
||||||
|
'scanned_by' => $operatorName,
|
||||||
|
]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$count = WireMasterPacking::where('plant_id', $plantId)
|
||||||
|
->where('wire_packing_number', $palletNumber)
|
||||||
|
->count('wire_packing_number');
|
||||||
|
|
||||||
|
|
||||||
|
$palletNotCompleted = WireMasterPacking::where('plant_id', $plantId)
|
||||||
|
->where('wire_packing_number', $palletNumber)
|
||||||
|
->where('wire_packing_status', '=','')
|
||||||
|
->orWhere('wire_packing_status', '=',null)
|
||||||
|
->first();
|
||||||
|
|
||||||
|
if (!$palletNotCompleted)
|
||||||
|
{
|
||||||
|
Notification::make()
|
||||||
|
->title("Already completed for pallet number $palletNumber!")
|
||||||
|
->danger()
|
||||||
|
->duration(5000)
|
||||||
|
->send();
|
||||||
|
|
||||||
|
$this->dispatch('loadData', $palletNumber, $plantId);
|
||||||
|
$this->form->fill([
|
||||||
|
'process_order' => null,
|
||||||
|
'plant_id' => $plantId,
|
||||||
|
'customer_po_master_id' => $customerPo,
|
||||||
|
'wire_packing_number' => $palletNumber,
|
||||||
|
'pending_pallet_list' => $pendingPallet,
|
||||||
|
'Sno_quantity' => $count,
|
||||||
|
'created_by' => $operatorName,
|
||||||
|
'scanned_by' => $operatorName,
|
||||||
|
]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->form->fill([
|
||||||
|
'process_order' => null,
|
||||||
|
'plant_id' => $plantId,
|
||||||
|
'customer_po_master_id' => $customerPo,
|
||||||
|
'wire_packing_number' => $palletNumber,
|
||||||
|
'pending_pallet_list' => $pendingPallet,
|
||||||
|
'Sno_quantity' => $count,
|
||||||
|
'created_by' => $operatorName,
|
||||||
|
'scanned_by' => $operatorName,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$this->dispatch('loadData', $palletNumber, $plantId);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function processRemoveSNo()
|
||||||
|
{
|
||||||
|
$plantId = $this->form->getState()['plant_id'];
|
||||||
|
|
||||||
|
$plantId = trim($plantId) ?? null;
|
||||||
|
|
||||||
|
$pendingPallet = $this->form->getState()['pending_pallet_list'];
|
||||||
|
|
||||||
|
$palletNumber = trim($this->form->getState()['wire_packing_number']) ?? null;
|
||||||
|
|
||||||
|
$customerPo = trim($this->form->getState()['customer_po_master_id'])?? null;
|
||||||
|
|
||||||
|
$palletNumber = trim($palletNumber) ?? null;
|
||||||
|
|
||||||
|
$processOrder = trim($this->form->getState()['removeSno_number']) ?? null;
|
||||||
|
|
||||||
|
$processOrder = trim($processOrder) ?? null;
|
||||||
|
|
||||||
|
$user = Filament::auth()->user();
|
||||||
|
|
||||||
|
$operatorName = $user->name;
|
||||||
|
|
||||||
|
if (!$palletNumber)
|
||||||
|
{
|
||||||
|
Notification::make()
|
||||||
|
->title('Master Pallet number is required to remove.')
|
||||||
|
->danger()
|
||||||
|
->duration(5000)
|
||||||
|
->send();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$count = WireMasterPacking::where('plant_id', $plantId)
|
||||||
|
->where('wire_packing_number', $palletNumber)
|
||||||
|
->count('wire_packing_number');
|
||||||
|
|
||||||
|
if (!$processOrder)
|
||||||
|
{
|
||||||
|
Notification::make()
|
||||||
|
->title('Process order is required to remove.')
|
||||||
|
->danger()
|
||||||
|
->duration(5000)
|
||||||
|
->send();
|
||||||
|
|
||||||
|
$this->dispatch('loadData', $palletNumber, $plantId);
|
||||||
|
$this->form->fill([
|
||||||
|
'process_order' => null,
|
||||||
|
'plant_id' => $plantId,
|
||||||
|
'customer_po_master_id' => $customerPo,
|
||||||
|
'wire_packing_number' => $palletNumber,
|
||||||
|
'pending_pallet_list' => $pendingPallet,
|
||||||
|
'Sno_quantity' => $count,
|
||||||
|
'created_by' => $operatorName,
|
||||||
|
'scanned_by' => $operatorName,
|
||||||
|
]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$processOrderexist = WireMasterPacking::where('plant_id', $plantId)
|
||||||
|
->where('process_order', $processOrder)
|
||||||
|
->first();
|
||||||
|
if (!$processOrderexist)
|
||||||
|
{
|
||||||
|
Notification::make()
|
||||||
|
->title('Process Order not exists in pallet table.')
|
||||||
|
->danger()
|
||||||
|
->duration(5000)
|
||||||
|
->send();
|
||||||
|
|
||||||
|
$this->dispatch('loadData', $palletNumber, $plantId);
|
||||||
|
$this->form->fill([
|
||||||
|
'process_order' => null,
|
||||||
|
'plant_id' => $plantId,
|
||||||
|
'customer_po_master_id' => $customerPo,
|
||||||
|
'wire_packing_number' => $palletNumber,
|
||||||
|
'pending_pallet_list' => $pendingPallet,
|
||||||
|
'Sno_quantity' => $count,
|
||||||
|
'created_by' => $operatorName,
|
||||||
|
'scanned_by' => $operatorName,
|
||||||
|
]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$palletExist = WireMasterPacking::where('plant_id', $plantId)
|
||||||
|
->where('process_order', $processOrder)
|
||||||
|
->where('wire_packing_number', '!=', '')
|
||||||
|
->where('wire_packing_number', '!=', null)
|
||||||
|
->first();
|
||||||
|
|
||||||
|
if ($palletExist && $palletExist->wire_packing_number != $palletNumber)
|
||||||
|
{
|
||||||
|
Notification::make()
|
||||||
|
->title("Scanned process order number exist in pallet number '$palletExist->wire_packing_number'.<br>Scan the valid exist process order to remove!")
|
||||||
|
->danger()
|
||||||
|
->duration(5000)
|
||||||
|
->send();
|
||||||
|
|
||||||
|
$this->dispatch('loadData', $palletNumber, $plantId);
|
||||||
|
$this->form->fill([
|
||||||
|
'process_order' => null,
|
||||||
|
'plant_id' => $plantId,
|
||||||
|
'customer_po_master_id' => $customerPo,
|
||||||
|
'wire_packing_number' => $palletNumber,
|
||||||
|
'pending_pallet_list' => $pendingPallet,
|
||||||
|
'Sno_quantity' => $count,
|
||||||
|
'created_by' => $operatorName,
|
||||||
|
'scanned_by' => $operatorName,
|
||||||
|
]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$deleted = WireMasterPacking::where('plant_id', $plantId)
|
||||||
|
->where('wire_packing_number', $palletNumber)
|
||||||
|
->where('process_order', $processOrder)
|
||||||
|
->forceDelete();
|
||||||
|
|
||||||
|
if ($deleted)
|
||||||
|
{
|
||||||
|
// Notification::make()
|
||||||
|
// ->title("Scanned serial number '$serialNumber' successfully removed from pallet table!<br>Scan the next exist serial number to remove...")
|
||||||
|
// ->success()
|
||||||
|
// ->duration(600)
|
||||||
|
// ->send();
|
||||||
|
|
||||||
|
$this->snoCount = WireMasterPacking::where('plant_id', $plantId)
|
||||||
|
->where('wire_packing_number', $palletNumber)
|
||||||
|
->count();
|
||||||
|
|
||||||
|
$this->form->fill([
|
||||||
|
'plant_id' => $plantId,
|
||||||
|
'customer_po_master_id' => $customerPo,
|
||||||
|
'wire_packing_number' => $palletNumber,
|
||||||
|
'removeSno_number' => null,
|
||||||
|
'pending_pallet_list' => $this->pendingPallet,
|
||||||
|
'Sno_quantity' => $this->snoCount,
|
||||||
|
'created_by' => $operatorName,
|
||||||
|
'scanned_by' => $operatorName,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$this->dispatch('loadData', $palletNumber, $plantId);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Notification::make()
|
||||||
|
->title("Failed to remove scanned process order '$processOrder' from master pallet!")
|
||||||
|
->danger()
|
||||||
|
->duration(5000)
|
||||||
|
->send();
|
||||||
|
|
||||||
|
$this->dispatch('loadData', $palletNumber, $plantId);
|
||||||
|
$this->form->fill([
|
||||||
|
'process_order' => null,
|
||||||
|
'plant_id' => $plantId,
|
||||||
|
'customer_po_master_id' => $customerPo,
|
||||||
|
'wire_packing_number' => $palletNumber,
|
||||||
|
'pending_pallet_list' => $pendingPallet,
|
||||||
|
'Sno_quantity' => $count,
|
||||||
|
'created_by' => $operatorName,
|
||||||
|
'scanned_by' => $operatorName,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
//$this->dispatch('removeSno', $serialNumber, $palletNumber, $plantId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getFormActions(): array
|
||||||
|
{
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Resources\WireMasterPackingResource\Pages;
|
||||||
|
|
||||||
|
use App\Filament\Resources\WireMasterPackingResource;
|
||||||
|
use Filament\Actions;
|
||||||
|
use Filament\Resources\Pages\EditRecord;
|
||||||
|
|
||||||
|
class EditWireMasterPacking extends EditRecord
|
||||||
|
{
|
||||||
|
protected static string $resource = WireMasterPackingResource::class;
|
||||||
|
|
||||||
|
protected function getHeaderActions(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
Actions\ViewAction::make(),
|
||||||
|
Actions\DeleteAction::make(),
|
||||||
|
Actions\ForceDeleteAction::make(),
|
||||||
|
Actions\RestoreAction::make(),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Resources\WireMasterPackingResource\Pages;
|
||||||
|
|
||||||
|
use App\Filament\Resources\WireMasterPackingResource;
|
||||||
|
use Filament\Actions;
|
||||||
|
use Filament\Resources\Pages\ListRecords;
|
||||||
|
|
||||||
|
class ListWireMasterPackings extends ListRecords
|
||||||
|
{
|
||||||
|
protected static string $resource = WireMasterPackingResource::class;
|
||||||
|
|
||||||
|
protected function getHeaderActions(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
Actions\CreateAction::make(),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Resources\WireMasterPackingResource\Pages;
|
||||||
|
|
||||||
|
use App\Filament\Resources\WireMasterPackingResource;
|
||||||
|
use Filament\Actions;
|
||||||
|
use Filament\Resources\Pages\ViewRecord;
|
||||||
|
|
||||||
|
class ViewWireMasterPacking extends ViewRecord
|
||||||
|
{
|
||||||
|
protected static string $resource = WireMasterPackingResource::class;
|
||||||
|
|
||||||
|
protected function getHeaderActions(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
Actions\EditAction::make(),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
301
app/Http/Controllers/PalletPrintController.php
Normal file
301
app/Http/Controllers/PalletPrintController.php
Normal file
@@ -0,0 +1,301 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Models\CustomerPoMaster;
|
||||||
|
use App\Models\Plant;
|
||||||
|
use App\Models\WireMasterPacking;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Barryvdh\DomPDF\Facade\Pdf;
|
||||||
|
use SimpleSoftwareIO\QrCode\Facades\QrCode;
|
||||||
|
|
||||||
|
|
||||||
|
class PalletPrintController extends Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Display a listing of the resource.
|
||||||
|
*/
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
// public function print(Request $request, $pallet, $plant)
|
||||||
|
// {
|
||||||
|
|
||||||
|
// $customerId = $request->query('customer');
|
||||||
|
|
||||||
|
// // $customerName = $request->query('customer_name');
|
||||||
|
|
||||||
|
// // $items = WireMasterPacking::with('item')
|
||||||
|
// // ->where('plant_id', $plant)
|
||||||
|
// // ->where('wire_packing_number', $pallet)
|
||||||
|
// // ->get()
|
||||||
|
// // ->groupBy('item_id')
|
||||||
|
// // ->map(function ($rows) {
|
||||||
|
// // $first = $rows->first();
|
||||||
|
|
||||||
|
// // return (object) [
|
||||||
|
// // 'code' => $first->item->code,
|
||||||
|
// // 'description' => $first->item->description,
|
||||||
|
// // 'box_count' => $rows->count(),
|
||||||
|
// // 'weight' => $rows->sum('weight'),
|
||||||
|
// // ];
|
||||||
|
// // })
|
||||||
|
// // ->values();
|
||||||
|
|
||||||
|
// $items = WireMasterPacking::with('item')
|
||||||
|
// ->where('plant_id', $plant)
|
||||||
|
// ->where('wire_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->weight,
|
||||||
|
// ];
|
||||||
|
// });
|
||||||
|
|
||||||
|
// $masterBox = WireMasterPacking::where('plant_id', $plant)
|
||||||
|
// ->where('wire_packing_number', $pallet)
|
||||||
|
// ->value('customer_po_master_id');
|
||||||
|
|
||||||
|
// $customer = CustomerPoMaster::find($masterBox);
|
||||||
|
|
||||||
|
// $customerCode = $customer->customer_po ?? '';
|
||||||
|
// $customerName = $customer->customer_name ?? '';
|
||||||
|
|
||||||
|
// // $masterBox = WireMasterPacking::where('plant_id', $plant)
|
||||||
|
// // ->where('wire_packing_number', $pallet)
|
||||||
|
// // ->distinct('customer_po')
|
||||||
|
// // ->count('customer_po');
|
||||||
|
|
||||||
|
// // $pallets = WireMasterPacking::where('plant_id', $plant)
|
||||||
|
// // ->select('wire_packing_number', 'updated_at')
|
||||||
|
// // ->distinct('wire_packing_number')
|
||||||
|
// // ->orderBy('wire_packing_number')
|
||||||
|
// // ->orderBy('updated_at', 'asc')
|
||||||
|
// // ->get()
|
||||||
|
// // ->pluck('wire_packing_number')
|
||||||
|
// // ->values();
|
||||||
|
|
||||||
|
// // $currentPalletNo = $pallets->search($pallet) + 1;
|
||||||
|
|
||||||
|
// // $totalBoxes = WireMasterPacking::where('plant_id', $plant)
|
||||||
|
// // // ->where('wire_packing_number', $pallet)
|
||||||
|
// // ->distinct()
|
||||||
|
// // ->count('customer_po');
|
||||||
|
|
||||||
|
// // $boxLabel = $currentPalletNo . '/' . $totalBoxes;
|
||||||
|
|
||||||
|
// $totalBoxes = WireMasterPacking::where('plant_id', $plant)
|
||||||
|
// ->where('customer_po_master_id', $customerId)
|
||||||
|
// ->distinct('wire_packing_number')
|
||||||
|
// ->count('wire_packing_number');
|
||||||
|
|
||||||
|
// $completedPallets = WireMasterPacking::where('plant_id', $plant)
|
||||||
|
// ->where('customer_po_master_id', $customerId)
|
||||||
|
// ->select('wire_packing_number')
|
||||||
|
// ->groupBy('wire_packing_number')
|
||||||
|
// ->havingRaw(
|
||||||
|
// 'COUNT(*) = COUNT(CASE WHEN wire_packing_status = ? THEN 1 END)',
|
||||||
|
// ['Completed']
|
||||||
|
// )
|
||||||
|
// ->orderBy('wire_packing_number')
|
||||||
|
// ->pluck('wire_packing_number')
|
||||||
|
// ->values();
|
||||||
|
|
||||||
|
|
||||||
|
// $index = $completedPallets->search($pallet);
|
||||||
|
|
||||||
|
// $currentPalletNo = ($index !== false) ? $index + 1 : 0;
|
||||||
|
|
||||||
|
// $boxLabel = $currentPalletNo . '/' . $totalBoxes;
|
||||||
|
|
||||||
|
// // $completedPallets = WireMasterPacking::where('plant_id', $plant)
|
||||||
|
// // ->select('wire_packing_number')
|
||||||
|
// // ->groupBy('wire_packing_number')
|
||||||
|
// // ->havingRaw('COUNT(*) = COUNT(CASE WHEN wire_packing_status = ? THEN 1 END)', ['Completed'])
|
||||||
|
// // ->orderBy('wire_packing_number')
|
||||||
|
// // ->pluck('wire_packing_number')
|
||||||
|
// // ->values();
|
||||||
|
|
||||||
|
// // $currentPalletNo = $completedPallets->search($pallet) != false
|
||||||
|
// // ? $completedPallets->search($pallet) + 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');
|
||||||
|
|
||||||
|
// $pdf = Pdf::loadView('pdf.wire-pallet', [
|
||||||
|
// 'product' => 'Submersible Winding Wire',
|
||||||
|
// 'plantName' => $plantName,
|
||||||
|
// 'plantAddress' => $plantAddress,
|
||||||
|
// 'monthYear' => now()->format('M-y'),
|
||||||
|
// 'branch' => '',
|
||||||
|
// 'customerCode' => $customerCode,
|
||||||
|
// 'customerName' => $customerName,
|
||||||
|
// 'masterBox' => $boxLabel,
|
||||||
|
// 'items' => $items,
|
||||||
|
// 'grossWeight' => $grossWeight,
|
||||||
|
// 'netWeight' => $grossWeight - 3.05,
|
||||||
|
// 'pallet' => $pallet,
|
||||||
|
// 'qrHtml' => '<barcode code="' . $pallet . '" type="QRCODE,H" class="barcode" />'
|
||||||
|
// ])->setPaper([0, 0, $widthPt, $heightPt], 'portrait');
|
||||||
|
|
||||||
|
// return $pdf->stream("Pallet-{$pallet}.pdf");
|
||||||
|
// // $pdfPath = storage_path("app/public/Pallet-{$pallet}.pdf");
|
||||||
|
// // $pdf->save($pdfPath);
|
||||||
|
|
||||||
|
// // $printerName = 'Tsc';
|
||||||
|
// // $output = [];
|
||||||
|
// // $returnVar = 0;
|
||||||
|
|
||||||
|
// // exec("lp -d {$printerName} " . escapeshellarg($pdfPath), $output, $returnVar);
|
||||||
|
|
||||||
|
// // if ($returnVar == 0) {
|
||||||
|
// // return response()->json([
|
||||||
|
// // 'status' => 'success',
|
||||||
|
// // 'message' => "PDF sent to printer $printerName successfully."
|
||||||
|
// // ]);
|
||||||
|
// // } else {
|
||||||
|
// // return response()->json([
|
||||||
|
// // 'status' => 'error',
|
||||||
|
// // 'message' => "Failed to send PDF to printer $printerName.",
|
||||||
|
// // 'output' => $output,
|
||||||
|
// // 'code' => $returnVar
|
||||||
|
// // ], 500);
|
||||||
|
// // }
|
||||||
|
// }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Store a newly created resource in storage.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
public function print(Request $request, $pallet, $plant)
|
||||||
|
{
|
||||||
|
$customerId = $request->query('customer');
|
||||||
|
|
||||||
|
// Fetch items
|
||||||
|
$items = WireMasterPacking::with('item')
|
||||||
|
->where('plant_id', $plant)
|
||||||
|
->where('wire_packing_number', $pallet)
|
||||||
|
->get()
|
||||||
|
->map(function ($row) {
|
||||||
|
return (object) [
|
||||||
|
'code' => $row->item->code,
|
||||||
|
'description' => $row->item->description,
|
||||||
|
'box_count' => 1,
|
||||||
|
'weight' => $row->weight,
|
||||||
|
];
|
||||||
|
});
|
||||||
|
|
||||||
|
// Fetch master box & customer info
|
||||||
|
$masterBox = WireMasterPacking::where('plant_id', $plant)
|
||||||
|
->where('wire_packing_number', $pallet)
|
||||||
|
->value('customer_po_master_id');
|
||||||
|
|
||||||
|
$customer = CustomerPoMaster::find($masterBox);
|
||||||
|
$customerCode = $customer->customer_po ?? '';
|
||||||
|
$customerName = $customer->customer_name ?? '';
|
||||||
|
|
||||||
|
// Calculate total boxes & current pallet number
|
||||||
|
$totalBoxes = WireMasterPacking::where('plant_id', $plant)
|
||||||
|
->where('customer_po_master_id', $customerId)
|
||||||
|
->distinct('wire_packing_number')
|
||||||
|
->count('wire_packing_number');
|
||||||
|
|
||||||
|
$completedPallets = WireMasterPacking::where('plant_id', $plant)
|
||||||
|
->where('customer_po_master_id', $customerId)
|
||||||
|
->select('wire_packing_number')
|
||||||
|
->groupBy('wire_packing_number')
|
||||||
|
->havingRaw(
|
||||||
|
'COUNT(*) = COUNT(CASE WHEN wire_packing_status = ? THEN 1 END)',
|
||||||
|
['Completed']
|
||||||
|
)
|
||||||
|
->orderBy('wire_packing_number')
|
||||||
|
->pluck('wire_packing_number')
|
||||||
|
->values();
|
||||||
|
|
||||||
|
$index = $completedPallets->search($pallet);
|
||||||
|
$currentPalletNo = ($index !== false) ? $index + 1 : 0;
|
||||||
|
$boxLabel = $currentPalletNo . '/' . $totalBoxes;
|
||||||
|
|
||||||
|
// Calculate gross weight
|
||||||
|
$grossWeight = $items->sum('weight');
|
||||||
|
|
||||||
|
// Page dimensions in points for DomPDF
|
||||||
|
$widthPt = 85 * 2.83465; // 85mm
|
||||||
|
$heightPt = 100 * 2.83465; // 100mm
|
||||||
|
|
||||||
|
// Plant info
|
||||||
|
$plantName = Plant::where('id', $plant)->value('name');
|
||||||
|
$plantAddress = Plant::where('id', $plant)->value('address');
|
||||||
|
|
||||||
|
// Generate QR code using GD (no Imagick required)
|
||||||
|
$qrBase64 = 'data:image/png;base64,' . base64_encode(
|
||||||
|
QrCode::format('png')
|
||||||
|
->size(120) // ~12mm
|
||||||
|
->margin(0)
|
||||||
|
->errorCorrection('H')
|
||||||
|
->generate($pallet)
|
||||||
|
);
|
||||||
|
|
||||||
|
// Load Blade view with data
|
||||||
|
$pdf = Pdf::loadView('pdf.wire-pallet', [
|
||||||
|
'product' => 'Submersible Winding Wire',
|
||||||
|
'plantName' => $plantName,
|
||||||
|
'plantAddress' => $plantAddress,
|
||||||
|
'monthYear' => now()->format('M-y'),
|
||||||
|
'branch' => '',
|
||||||
|
'customerCode' => $customerCode,
|
||||||
|
'customerName' => $customerName,
|
||||||
|
'masterBox' => $boxLabel,
|
||||||
|
'items' => $items,
|
||||||
|
'grossWeight' => $grossWeight,
|
||||||
|
'netWeight' => $grossWeight - 3.05,
|
||||||
|
'pallet' => $pallet,
|
||||||
|
'qrBase64' => $qrBase64
|
||||||
|
])->setPaper([0, 0, $widthPt, $heightPt], 'portrait');
|
||||||
|
|
||||||
|
return $pdf->stream("Pallet-{$pallet}.pdf");
|
||||||
|
}
|
||||||
|
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -26,6 +26,7 @@ class ProductionTargetPlan extends Component
|
|||||||
|
|
||||||
protected $listeners = [
|
protected $listeners = [
|
||||||
'loadData' => 'loadProductionData',
|
'loadData' => 'loadProductionData',
|
||||||
|
'loadCategoryData' => 'loadProductionDataCategory',
|
||||||
'loadData1' => 'exportProductionData',
|
'loadData1' => 'exportProductionData',
|
||||||
];
|
];
|
||||||
|
|
||||||
@@ -175,7 +176,7 @@ class ProductionTargetPlan extends Component
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
public function loadProductionData($plantId, $lineId, $month, $year)
|
public function loadProductionData($year, $month, $plantId, $lineId, $category)
|
||||||
{
|
{
|
||||||
if (!$plantId || !$lineId || !$month || !$year) {
|
if (!$plantId || !$lineId || !$month || !$year) {
|
||||||
$this->records = [];
|
$this->records = [];
|
||||||
@@ -195,6 +196,9 @@ class ProductionTargetPlan extends Component
|
|||||||
->where('production_plans.line_id', $lineId)
|
->where('production_plans.line_id', $lineId)
|
||||||
->whereMonth('production_plans.created_at', $month)
|
->whereMonth('production_plans.created_at', $month)
|
||||||
->whereYear('production_plans.created_at', $year)
|
->whereYear('production_plans.created_at', $year)
|
||||||
|
->when($category, function ($query) use ($category) {
|
||||||
|
$query->where('items.category', $category);
|
||||||
|
})
|
||||||
->select(
|
->select(
|
||||||
'production_plans.item_id',
|
'production_plans.item_id',
|
||||||
'production_plans.plant_id',
|
'production_plans.plant_id',
|
||||||
@@ -203,6 +207,7 @@ class ProductionTargetPlan extends Component
|
|||||||
'production_plans.working_days',
|
'production_plans.working_days',
|
||||||
'production_plans.leave_dates',
|
'production_plans.leave_dates',
|
||||||
'items.code as item_code',
|
'items.code as item_code',
|
||||||
|
'items.category as category',
|
||||||
'items.description as item_description',
|
'items.description as item_description',
|
||||||
'lines.name as line_name',
|
'lines.name as line_name',
|
||||||
'lines.line_capacity as line_capacity',
|
'lines.line_capacity as line_capacity',
|
||||||
@@ -229,6 +234,11 @@ class ProductionTargetPlan extends Component
|
|||||||
->where('line_id', $lineId)
|
->where('line_id', $lineId)
|
||||||
->whereMonth('created_at', $month)
|
->whereMonth('created_at', $month)
|
||||||
->whereYear('created_at', $year)
|
->whereYear('created_at', $year)
|
||||||
|
->when($category, function ($query) use ($category) {
|
||||||
|
$query->whereHas('item', function ($q) use ($category) {
|
||||||
|
$q->where('category', $category);
|
||||||
|
});
|
||||||
|
})
|
||||||
->groupBy('plant_id', 'line_id', 'item_id', DB::raw('DATE(created_at)'))
|
->groupBy('plant_id', 'line_id', 'item_id', DB::raw('DATE(created_at)'))
|
||||||
->get()
|
->get()
|
||||||
->groupBy(fn($row) =>
|
->groupBy(fn($row) =>
|
||||||
@@ -249,7 +259,7 @@ class ProductionTargetPlan extends Component
|
|||||||
$lineCapacity = (float) ($row['line_capacity'] ?? 0);
|
$lineCapacity = (float) ($row['line_capacity'] ?? 0);
|
||||||
$dailyLineCapacity = (float) ($row['line_capacity'] ?? 0);
|
$dailyLineCapacity = (float) ($row['line_capacity'] ?? 0);
|
||||||
|
|
||||||
|
$row['category'] = $row['category'] ?? '-';
|
||||||
$row['daily_line_capacity'] = [];
|
$row['daily_line_capacity'] = [];
|
||||||
$row['daily_target_dynamic'] = [];
|
$row['daily_target_dynamic'] = [];
|
||||||
$row['produced_quantity'] = [];
|
$row['produced_quantity'] = [];
|
||||||
@@ -291,6 +301,122 @@ class ProductionTargetPlan extends Component
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// public function loadProductionDataCategory($year, $month, $plantId, $lineId, $category)
|
||||||
|
// {
|
||||||
|
// if (!$plantId || !$lineId || !$month || !$year || !$category) {
|
||||||
|
// $this->records = [];
|
||||||
|
// $this->dates = [];
|
||||||
|
// $this->leaveDates = [];
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// $dates = $this->getMonthDates($month, $year);
|
||||||
|
// $this->dates = $dates;
|
||||||
|
|
||||||
|
// $plans = ProductionPlan::query()
|
||||||
|
// ->join('items', 'items.id', '=', 'production_plans.item_id')
|
||||||
|
// ->join('lines', 'lines.id', '=', 'production_plans.line_id')
|
||||||
|
// ->join('plants', 'plants.id', '=', 'production_plans.plant_id')
|
||||||
|
// ->where('production_plans.plant_id', $plantId)
|
||||||
|
// ->where('production_plans.line_id', $lineId)
|
||||||
|
// ->whereMonth('production_plans.created_at', $month)
|
||||||
|
// ->whereYear('production_plans.created_at', $year)
|
||||||
|
// ->select(
|
||||||
|
// 'production_plans.item_id',
|
||||||
|
// 'production_plans.plant_id',
|
||||||
|
// 'production_plans.line_id',
|
||||||
|
// 'production_plans.plan_quantity',
|
||||||
|
// 'production_plans.working_days',
|
||||||
|
// 'production_plans.leave_dates',
|
||||||
|
// 'items.code as item_code',
|
||||||
|
// 'items.description as item_description',
|
||||||
|
// 'lines.name as line_name',
|
||||||
|
// 'lines.line_capacity as line_capacity',
|
||||||
|
// 'plants.name as plant_name'
|
||||||
|
// )
|
||||||
|
// ->get();
|
||||||
|
|
||||||
|
// $leaveDates = [];
|
||||||
|
|
||||||
|
// if ($plans->isNotEmpty() && $plans[0]->leave_dates) {
|
||||||
|
// $leaveDates = array_map('trim', explode(',', $plans[0]->leave_dates));
|
||||||
|
// }
|
||||||
|
|
||||||
|
// $this->leaveDates = $leaveDates;
|
||||||
|
|
||||||
|
// $producedData = ProductionQuantity::selectRaw("
|
||||||
|
// plant_id,
|
||||||
|
// line_id,
|
||||||
|
// item_id,
|
||||||
|
// DATE(created_at) as prod_date,
|
||||||
|
// COUNT(*) as total_qty
|
||||||
|
// ")
|
||||||
|
// ->where('plant_id', $plantId)
|
||||||
|
// ->where('line_id', $lineId)
|
||||||
|
// ->whereMonth('created_at', $month)
|
||||||
|
// ->whereYear('created_at', $year)
|
||||||
|
// ->groupBy('plant_id', 'line_id', 'item_id', DB::raw('DATE(created_at)'))
|
||||||
|
// ->get()
|
||||||
|
// ->groupBy(fn($row) =>
|
||||||
|
// $row->plant_id . '_' . $row->line_id . '_' . $row->item_id
|
||||||
|
// )
|
||||||
|
// ->map(fn($group) => $group->keyBy('prod_date'));
|
||||||
|
|
||||||
|
|
||||||
|
// $records = [];
|
||||||
|
|
||||||
|
// foreach ($plans as $plan) {
|
||||||
|
|
||||||
|
// $row = $plan->toArray();
|
||||||
|
|
||||||
|
// $remainingQty = (float) $row['plan_quantity'];
|
||||||
|
// $remainingDays = (int) ($row['working_days'] ?? 0);
|
||||||
|
|
||||||
|
// $lineCapacity = (float) ($row['line_capacity'] ?? 0);
|
||||||
|
// $dailyLineCapacity = (float) ($row['line_capacity'] ?? 0);
|
||||||
|
|
||||||
|
|
||||||
|
// $row['daily_line_capacity'] = [];
|
||||||
|
// $row['daily_target_dynamic'] = [];
|
||||||
|
// $row['produced_quantity'] = [];
|
||||||
|
|
||||||
|
// $key = $row['plant_id'].'_'.$row['line_id'].'_'.$row['item_id'];
|
||||||
|
|
||||||
|
// foreach ($dates as $date) {
|
||||||
|
|
||||||
|
// // Skip leave dates fast
|
||||||
|
// if (isset($leaveDates) && in_array($date, $leaveDates)) {
|
||||||
|
// $row['daily_line_capacity'][$date] = '-';
|
||||||
|
// $row['daily_target_dynamic'][$date] = '-';
|
||||||
|
// $row['produced_quantity'][$date] = '-';
|
||||||
|
// continue;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// $todayTarget = $remainingDays > 0
|
||||||
|
// ? round($remainingQty / $remainingDays, 2)
|
||||||
|
// : 0;
|
||||||
|
|
||||||
|
// $producedQty = $producedData[$key][$date]->total_qty ?? 0;
|
||||||
|
|
||||||
|
// $row['daily_target_dynamic'][$date] = $todayTarget;
|
||||||
|
// $row['produced_quantity'][$date] = $producedQty;
|
||||||
|
// $row['daily_line_capacity'][$date] = $dailyLineCapacity;
|
||||||
|
|
||||||
|
// // Carry forward remaining qty
|
||||||
|
// $remainingQty = max(0, $remainingQty - $producedQty);
|
||||||
|
|
||||||
|
// if ($remainingDays > 0) {
|
||||||
|
// $remainingDays--;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// $records[] = $row;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// $this->records = $records;
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
public function exportProductionData()
|
public function exportProductionData()
|
||||||
{
|
{
|
||||||
return Excel::download(
|
return Excel::download(
|
||||||
|
|||||||
55
app/Livewire/WireMasterDataTable.php
Normal file
55
app/Livewire/WireMasterDataTable.php
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Livewire;
|
||||||
|
|
||||||
|
use App\Models\WireMasterPacking;
|
||||||
|
use Livewire\Component;
|
||||||
|
|
||||||
|
class WireMasterDataTable extends Component
|
||||||
|
{
|
||||||
|
|
||||||
|
public $plantId;
|
||||||
|
|
||||||
|
public $wirePackNo;
|
||||||
|
|
||||||
|
public $snoCount = 0;
|
||||||
|
|
||||||
|
public $records = [];
|
||||||
|
|
||||||
|
protected $listeners = [
|
||||||
|
'loadData' => 'loadWireMasterData',
|
||||||
|
];
|
||||||
|
|
||||||
|
public function loadWireMasterData($wirePackNo, $plantId)
|
||||||
|
{
|
||||||
|
$this->plantId = $plantId;
|
||||||
|
$this->wirePackNo = $wirePackNo;
|
||||||
|
$this->records = [];
|
||||||
|
|
||||||
|
$this->records = WireMasterPacking::query()
|
||||||
|
->where('plant_id', $this->plantId)
|
||||||
|
->where('wire_packing_number', $this->wirePackNo)
|
||||||
|
->orderBy('scanned_at')
|
||||||
|
->get()
|
||||||
|
->map(function ($record) {
|
||||||
|
return [
|
||||||
|
'created_at' => $record->created_at,
|
||||||
|
'created_by' => $record->created_by ?? '',
|
||||||
|
'wire_packing_number' => $record->wire_packing_number,
|
||||||
|
'item_code' => $record->item?->code ?? '',
|
||||||
|
'item_description' => $record->item?->description ?? '',
|
||||||
|
'process_order' => $record->process_order,
|
||||||
|
'weight' => $record->weight,
|
||||||
|
'scanned_at' => $record->scanned_at,
|
||||||
|
'scanned_by' => $record->scanned_by ?? '',
|
||||||
|
];
|
||||||
|
})
|
||||||
|
->toArray();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function render()
|
||||||
|
{
|
||||||
|
return view('livewire.wire-master-data-table');
|
||||||
|
}
|
||||||
|
}
|
||||||
33
app/Models/CustomerPoMaster.php
Normal file
33
app/Models/CustomerPoMaster.php
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||||
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||||
|
|
||||||
|
class CustomerPoMaster extends Model
|
||||||
|
{
|
||||||
|
use SoftDeletes;
|
||||||
|
|
||||||
|
protected $fillable = [
|
||||||
|
'plant_id',
|
||||||
|
'item_id',
|
||||||
|
'customer_po',
|
||||||
|
'customer_name',
|
||||||
|
'quantity',
|
||||||
|
'created_at',
|
||||||
|
'updated_at',
|
||||||
|
'created_by',
|
||||||
|
];
|
||||||
|
|
||||||
|
public function plant(): BelongsTo
|
||||||
|
{
|
||||||
|
return $this->belongsTo(Plant::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function item(): BelongsTo
|
||||||
|
{
|
||||||
|
return $this->belongsTo(Item::class);
|
||||||
|
}
|
||||||
|
}
|
||||||
44
app/Models/WireMasterPacking.php
Normal file
44
app/Models/WireMasterPacking.php
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||||
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||||
|
|
||||||
|
class WireMasterPacking extends Model
|
||||||
|
{
|
||||||
|
use SoftDeletes;
|
||||||
|
|
||||||
|
protected $fillable = [
|
||||||
|
'plant_id',
|
||||||
|
'item_id',
|
||||||
|
'customer_po_master_id',
|
||||||
|
'wire_packing_number',
|
||||||
|
'process_order',
|
||||||
|
'batch_number',
|
||||||
|
'weight',
|
||||||
|
'wire_packing_status',
|
||||||
|
'created_at',
|
||||||
|
'created_by',
|
||||||
|
'updated_at',
|
||||||
|
'updated_by',
|
||||||
|
'scanned_at',
|
||||||
|
'scanned_by',
|
||||||
|
|
||||||
|
];
|
||||||
|
|
||||||
|
public function plant(): BelongsTo
|
||||||
|
{
|
||||||
|
return $this->belongsTo(Plant::class);
|
||||||
|
}
|
||||||
|
public function item(): BelongsTo
|
||||||
|
{
|
||||||
|
return $this->belongsTo(Item::class, 'item_id');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function customerPo(): BelongsTo
|
||||||
|
{
|
||||||
|
return $this->belongsTo(CustomerPoMaster::class, 'customer_po_master_id');
|
||||||
|
}
|
||||||
|
}
|
||||||
106
app/Policies/CustomerPoMasterPolicy.php
Normal file
106
app/Policies/CustomerPoMasterPolicy.php
Normal file
@@ -0,0 +1,106 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Policies;
|
||||||
|
|
||||||
|
use Illuminate\Auth\Access\Response;
|
||||||
|
use App\Models\CustomerPoMaster;
|
||||||
|
use App\Models\User;
|
||||||
|
|
||||||
|
class CustomerPoMasterPolicy
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Determine whether the user can view any models.
|
||||||
|
*/
|
||||||
|
public function viewAny(User $user): bool
|
||||||
|
{
|
||||||
|
return $user->checkPermissionTo('view-any CustomerPoMaster');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine whether the user can view the model.
|
||||||
|
*/
|
||||||
|
public function view(User $user, CustomerPoMaster $customerpomaster): bool
|
||||||
|
{
|
||||||
|
return $user->checkPermissionTo('view CustomerPoMaster');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine whether the user can create models.
|
||||||
|
*/
|
||||||
|
public function create(User $user): bool
|
||||||
|
{
|
||||||
|
return $user->checkPermissionTo('create CustomerPoMaster');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine whether the user can update the model.
|
||||||
|
*/
|
||||||
|
public function update(User $user, CustomerPoMaster $customerpomaster): bool
|
||||||
|
{
|
||||||
|
return $user->checkPermissionTo('update CustomerPoMaster');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine whether the user can delete the model.
|
||||||
|
*/
|
||||||
|
public function delete(User $user, CustomerPoMaster $customerpomaster): bool
|
||||||
|
{
|
||||||
|
return $user->checkPermissionTo('delete CustomerPoMaster');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine whether the user can delete any models.
|
||||||
|
*/
|
||||||
|
public function deleteAny(User $user): bool
|
||||||
|
{
|
||||||
|
return $user->checkPermissionTo('delete-any CustomerPoMaster');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine whether the user can restore the model.
|
||||||
|
*/
|
||||||
|
public function restore(User $user, CustomerPoMaster $customerpomaster): bool
|
||||||
|
{
|
||||||
|
return $user->checkPermissionTo('restore CustomerPoMaster');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine whether the user can restore any models.
|
||||||
|
*/
|
||||||
|
public function restoreAny(User $user): bool
|
||||||
|
{
|
||||||
|
return $user->checkPermissionTo('restore-any CustomerPoMaster');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine whether the user can replicate the model.
|
||||||
|
*/
|
||||||
|
public function replicate(User $user, CustomerPoMaster $customerpomaster): bool
|
||||||
|
{
|
||||||
|
return $user->checkPermissionTo('replicate CustomerPoMaster');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine whether the user can reorder the models.
|
||||||
|
*/
|
||||||
|
public function reorder(User $user): bool
|
||||||
|
{
|
||||||
|
return $user->checkPermissionTo('reorder CustomerPoMaster');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine whether the user can permanently delete the model.
|
||||||
|
*/
|
||||||
|
public function forceDelete(User $user, CustomerPoMaster $customerpomaster): bool
|
||||||
|
{
|
||||||
|
return $user->checkPermissionTo('force-delete CustomerPoMaster');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine whether the user can permanently delete any models.
|
||||||
|
*/
|
||||||
|
public function forceDeleteAny(User $user): bool
|
||||||
|
{
|
||||||
|
return $user->checkPermissionTo('force-delete-any CustomerPoMaster');
|
||||||
|
}
|
||||||
|
}
|
||||||
106
app/Policies/WireMasterPackingPolicy.php
Normal file
106
app/Policies/WireMasterPackingPolicy.php
Normal file
@@ -0,0 +1,106 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Policies;
|
||||||
|
|
||||||
|
use Illuminate\Auth\Access\Response;
|
||||||
|
use App\Models\WireMasterPacking;
|
||||||
|
use App\Models\User;
|
||||||
|
|
||||||
|
class WireMasterPackingPolicy
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Determine whether the user can view any models.
|
||||||
|
*/
|
||||||
|
public function viewAny(User $user): bool
|
||||||
|
{
|
||||||
|
return $user->checkPermissionTo('view-any WireMasterPacking');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine whether the user can view the model.
|
||||||
|
*/
|
||||||
|
public function view(User $user, WireMasterPacking $wiremasterpacking): bool
|
||||||
|
{
|
||||||
|
return $user->checkPermissionTo('view WireMasterPacking');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine whether the user can create models.
|
||||||
|
*/
|
||||||
|
public function create(User $user): bool
|
||||||
|
{
|
||||||
|
return $user->checkPermissionTo('create WireMasterPacking');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine whether the user can update the model.
|
||||||
|
*/
|
||||||
|
public function update(User $user, WireMasterPacking $wiremasterpacking): bool
|
||||||
|
{
|
||||||
|
return $user->checkPermissionTo('update WireMasterPacking');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine whether the user can delete the model.
|
||||||
|
*/
|
||||||
|
public function delete(User $user, WireMasterPacking $wiremasterpacking): bool
|
||||||
|
{
|
||||||
|
return $user->checkPermissionTo('delete WireMasterPacking');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine whether the user can delete any models.
|
||||||
|
*/
|
||||||
|
public function deleteAny(User $user): bool
|
||||||
|
{
|
||||||
|
return $user->checkPermissionTo('delete-any WireMasterPacking');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine whether the user can restore the model.
|
||||||
|
*/
|
||||||
|
public function restore(User $user, WireMasterPacking $wiremasterpacking): bool
|
||||||
|
{
|
||||||
|
return $user->checkPermissionTo('restore WireMasterPacking');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine whether the user can restore any models.
|
||||||
|
*/
|
||||||
|
public function restoreAny(User $user): bool
|
||||||
|
{
|
||||||
|
return $user->checkPermissionTo('restore-any WireMasterPacking');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine whether the user can replicate the model.
|
||||||
|
*/
|
||||||
|
public function replicate(User $user, WireMasterPacking $wiremasterpacking): bool
|
||||||
|
{
|
||||||
|
return $user->checkPermissionTo('replicate WireMasterPacking');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine whether the user can reorder the models.
|
||||||
|
*/
|
||||||
|
public function reorder(User $user): bool
|
||||||
|
{
|
||||||
|
return $user->checkPermissionTo('reorder WireMasterPacking');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine whether the user can permanently delete the model.
|
||||||
|
*/
|
||||||
|
public function forceDelete(User $user, WireMasterPacking $wiremasterpacking): bool
|
||||||
|
{
|
||||||
|
return $user->checkPermissionTo('force-delete WireMasterPacking');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine whether the user can permanently delete any models.
|
||||||
|
*/
|
||||||
|
public function forceDeleteAny(User $user): bool
|
||||||
|
{
|
||||||
|
return $user->checkPermissionTo('force-delete-any WireMasterPacking');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
<?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
|
||||||
|
{
|
||||||
|
$sql = <<<'SQL'
|
||||||
|
CREATE TABLE wire_master_packings (
|
||||||
|
id BIGINT GENERATED always AS IDENTITY PRIMARY KEY,
|
||||||
|
|
||||||
|
plant_id BIGINT NOT NULL,
|
||||||
|
item_id BIGINT NOT NULL,
|
||||||
|
customer_po_master_id BIGINT NOT NULL,
|
||||||
|
wire_packing_number TEXT DEFAULT NULL,
|
||||||
|
process_order TEXT DEFAULT NULL,
|
||||||
|
batch_number TEXT DEFAULT NULL,
|
||||||
|
|
||||||
|
weight TEXT DEFAULT NULL,
|
||||||
|
wire_packing_status TEXT DEFAULT NULL,
|
||||||
|
|
||||||
|
created_at TIMESTAMP NOT NULL DEFAULT NOW(),
|
||||||
|
updated_at TIMESTAMP NOT NULL DEFAULT NOW(),
|
||||||
|
scanned_at TIMESTAMP NOT NULL DEFAULT NOW(),
|
||||||
|
created_by TEXT DEFAULT NULL,
|
||||||
|
updated_by TEXT DEFAULT NULL,
|
||||||
|
scanned_by TEXT DEFAULT NULL,
|
||||||
|
deleted_at TIMESTAMP,
|
||||||
|
|
||||||
|
FOREIGN KEY (plant_id) REFERENCES plants(id),
|
||||||
|
FOREIGN KEY (customer_po_master_id) REFERENCES customer_po_masters(id),
|
||||||
|
FOREIGN KEY (item_id) REFERENCES items(id)
|
||||||
|
);
|
||||||
|
SQL;
|
||||||
|
DB::statement($sql);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('wire_master_packings');
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
<?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
|
||||||
|
{
|
||||||
|
$sql = <<<'SQL'
|
||||||
|
CREATE TABLE customer_po_masters (
|
||||||
|
id BIGINT GENERATED always AS IDENTITY PRIMARY KEY,
|
||||||
|
|
||||||
|
plant_id BIGINT NOT NULL,
|
||||||
|
item_id BIGINT NOT NULL,
|
||||||
|
customer_po TEXT DEFAULT NULL,
|
||||||
|
customer_name TEXT DEFAULT NULL,
|
||||||
|
|
||||||
|
quantity TEXT DEFAULT NULL,
|
||||||
|
|
||||||
|
created_at TIMESTAMP NOT NULL DEFAULT NOW(),
|
||||||
|
updated_at TIMESTAMP NOT NULL DEFAULT NOW(),
|
||||||
|
created_by TEXT DEFAULT NULL,
|
||||||
|
updated_by TEXT DEFAULT NULL,
|
||||||
|
deleted_at TIMESTAMP,
|
||||||
|
|
||||||
|
FOREIGN KEY (plant_id) REFERENCES plants(id),
|
||||||
|
FOREIGN KEY (item_id) REFERENCES items(id)
|
||||||
|
);
|
||||||
|
SQL;
|
||||||
|
DB::statement($sql);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('customer_po_masters');
|
||||||
|
}
|
||||||
|
};
|
||||||
36
resources/views/filament/pages/wire-master-print.blade.php
Normal file
36
resources/views/filament/pages/wire-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:wire-master-data-table />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
window.addEventListener('open-pdf', event => {
|
||||||
|
window.open(event.detail.url, '_blank');
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
</x-filament-panels::page>
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
|
||||||
|
|
||||||
|
<x-filament::page>
|
||||||
|
|
||||||
|
<div class="filament-form space-y-6">
|
||||||
|
{{ $this->form }}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="bg-white shadow rounded-xl p-4">
|
||||||
|
<livewire:wire-master-data-table />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="filament-actions mt-6">
|
||||||
|
<x-filament::actions>
|
||||||
|
@foreach ($this->getFormActions() as $action)
|
||||||
|
{{ $action }}
|
||||||
|
@endforeach
|
||||||
|
</x-filament::actions>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@push('scripts')
|
||||||
|
<script>
|
||||||
|
window.addEventListener('open-pdf', event => {
|
||||||
|
const url = event.detail.url;
|
||||||
|
const win = window.open(url, '_blank');
|
||||||
|
if (!win || win.closed || typeof win.closed == 'undefined') {
|
||||||
|
alert('Popup blocked. Please allow popups for this site.');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
@endpush
|
||||||
|
</x-filament::page>
|
||||||
@@ -64,57 +64,57 @@ document.addEventListener('DOMContentLoaded', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
// function updateWorkingDays(date) {
|
function updateWorkingDays(date) {
|
||||||
// let totalDays = new Date(
|
|
||||||
// date.getFullYear(),
|
|
||||||
// date.getMonth()+1,
|
|
||||||
// 0
|
|
||||||
// ).getDate();
|
|
||||||
|
|
||||||
// let workingDays = totalDays - selectedDates.length;
|
|
||||||
// // document.querySelector('input[name="working_days"]').value = workingDays;
|
|
||||||
|
|
||||||
// const input = document.querySelector('#working_days');
|
|
||||||
|
|
||||||
// input.value = workingDays;
|
|
||||||
|
|
||||||
// input.dispatchEvent(new Event('input'));
|
|
||||||
|
|
||||||
// const monthInput = document.querySelector('#month');
|
|
||||||
// monthInput.value = date.getMonth() + 1; // 1–12 month number
|
|
||||||
// monthInput.dispatchEvent(new Event('input'));
|
|
||||||
|
|
||||||
// const yearInput = document.querySelector('#year');
|
|
||||||
// yearInput.value = date.getFullYear();
|
|
||||||
// yearInput.dispatchEvent(new Event('input'));
|
|
||||||
|
|
||||||
// const selectedDatesInput = document.querySelector('#selected_dates');
|
|
||||||
// selectedDatesInput.value = selectedDates.join(',');
|
|
||||||
// selectedDatesInput.dispatchEvent(new Event('input'));
|
|
||||||
|
|
||||||
// }
|
|
||||||
|
|
||||||
function updateWorkingDays(date) {
|
|
||||||
let totalDays = new Date(
|
let totalDays = new Date(
|
||||||
date.getFullYear(),
|
date.getFullYear(),
|
||||||
date.getMonth() + 1,
|
date.getMonth()+1,
|
||||||
0
|
0
|
||||||
).getDate();
|
).getDate();
|
||||||
|
|
||||||
let workingDays = totalDays - selectedDates.length;
|
let workingDays = totalDays - selectedDates.length;
|
||||||
|
// document.querySelector('input[name="working_days"]').value = workingDays;
|
||||||
|
|
||||||
// Set values only
|
const input = document.querySelector('#working_days');
|
||||||
document.querySelector('#working_days').value = workingDays;
|
|
||||||
document.querySelector('#month').value = date.getMonth() + 1;
|
input.value = workingDays;
|
||||||
document.querySelector('#year').value = date.getFullYear();
|
|
||||||
document.querySelector('#selected_dates').value = selectedDates.join(',');
|
input.dispatchEvent(new Event('input'));
|
||||||
|
|
||||||
|
const monthInput = document.querySelector('#month');
|
||||||
|
monthInput.value = date.getMonth() + 1; // 1–12 month number
|
||||||
|
monthInput.dispatchEvent(new Event('input'));
|
||||||
|
|
||||||
|
const yearInput = document.querySelector('#year');
|
||||||
|
yearInput.value = date.getFullYear();
|
||||||
|
yearInput.dispatchEvent(new Event('input'));
|
||||||
|
|
||||||
|
const selectedDatesInput = document.querySelector('#selected_dates');
|
||||||
|
selectedDatesInput.value = selectedDates.join(',');
|
||||||
|
selectedDatesInput.dispatchEvent(new Event('input'));
|
||||||
|
|
||||||
// Trigger only ONE update (important)
|
|
||||||
document
|
|
||||||
.querySelector('#selected_dates')
|
|
||||||
.dispatchEvent(new Event('input'));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// function updateWorkingDays(date) {
|
||||||
|
// let totalDays = new Date(
|
||||||
|
// date.getFullYear(),
|
||||||
|
// date.getMonth() + 1,
|
||||||
|
// 0
|
||||||
|
// ).getDate();
|
||||||
|
|
||||||
|
// let workingDays = totalDays - selectedDates.length;
|
||||||
|
|
||||||
|
// // Set values only
|
||||||
|
// document.querySelector('#working_days').value = workingDays;
|
||||||
|
// document.querySelector('#month').value = date.getMonth() + 1;
|
||||||
|
// document.querySelector('#year').value = date.getFullYear();
|
||||||
|
// document.querySelector('#selected_dates').value = selectedDates.join(',');
|
||||||
|
|
||||||
|
// // Trigger only ONE update (important)
|
||||||
|
// document
|
||||||
|
// .querySelector('#selected_dates')
|
||||||
|
// .dispatchEvent(new Event('input'));
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
calendar.render();
|
calendar.render();
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
<div class="flex flex-col items-start space-y-1">
|
||||||
|
<div class="flex items-center">
|
||||||
|
<input
|
||||||
|
type="checkbox"
|
||||||
|
id="is_completed"
|
||||||
|
wire:model.defer="data.is_completed"
|
||||||
|
class="focus:outline-none focus:ring-0 focus:border-transparent border-gray-300"
|
||||||
|
>
|
||||||
|
<label for="is_completed" style="margin-left:2mm;" class="whitespace-nowrap mb-0">
|
||||||
|
Is Completed!
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
wire:click="markAsComplete"
|
||||||
|
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 Pallet
|
||||||
|
</button>
|
||||||
|
|
||||||
|
|
||||||
@@ -6,10 +6,11 @@
|
|||||||
<table class="w-full divide-y divide-gray-200 text-sm text-center">
|
<table class="w-full divide-y divide-gray-200 text-sm text-center">
|
||||||
<thead class="bg-gray-100 text-s font-semibold uppercase text-gray-700">
|
<thead class="bg-gray-100 text-s font-semibold uppercase text-gray-700">
|
||||||
<tr>
|
<tr>
|
||||||
<th class="border px-4 py-2" rowspan="3">No</th>
|
<th class="border px-4 py-2" rowspan="4">No</th>
|
||||||
<th class="border px-4 py-2 whitespace-nowrap" rowspan="3">Plant</th>
|
<th class="border px-4 py-2 whitespace-nowrap" rowspan="3">Plant</th>
|
||||||
<th class="border px-4 py-2 whitespace-nowrap" rowspan="3">Line</th>
|
<th class="border px-4 py-2 whitespace-nowrap" rowspan="3">Line</th>
|
||||||
<th class="border px-4 py-2 whitespace-nowrap" rowspan="3">Item Code</th>
|
<th class="border px-4 py-2 whitespace-nowrap" rowspan="3">Item Code</th>
|
||||||
|
<th class="border px-4 py-2 whitespace-nowrap" rowspan="3">Category</th>
|
||||||
|
|
||||||
<th class="border px-4 py-2 whitespace-nowrap" colspan="{{ count($dates) * 3 }}" class="text-center">
|
<th class="border px-4 py-2 whitespace-nowrap" colspan="{{ count($dates) * 3 }}" class="text-center">
|
||||||
Production Plan Dates
|
Production Plan Dates
|
||||||
@@ -45,6 +46,7 @@
|
|||||||
<td class="border px-4 py-2 whitespace-nowrap">{{ $record['plant_name'] }}</td>
|
<td class="border px-4 py-2 whitespace-nowrap">{{ $record['plant_name'] }}</td>
|
||||||
<td class="border px-4 py-2 whitespace-nowrap">{{ $record['line_name'] }}</td>
|
<td class="border px-4 py-2 whitespace-nowrap">{{ $record['line_name'] }}</td>
|
||||||
<td class="border px-4 py-2 whitespace-nowrap">{{ $record['item_code'] }}</td>
|
<td class="border px-4 py-2 whitespace-nowrap">{{ $record['item_code'] }}</td>
|
||||||
|
<td class="border px-4 py-2 whitespace-nowrap">{{ $record['category'] }}</td>
|
||||||
|
|
||||||
{{-- @foreach($dates as $date)
|
{{-- @foreach($dates as $date)
|
||||||
<td class="border px-4 py-2 whitespace-nowrap">{{ $record['target_plan'][$date] ?? '-' }}</td>
|
<td class="border px-4 py-2 whitespace-nowrap">{{ $record['target_plan'][$date] ?? '-' }}</td>
|
||||||
|
|||||||
47
resources/views/livewire/wire-master-data-table.blade.php
Normal file
47
resources/views/livewire/wire-master-data-table.blade.php
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
<div class="p-4">
|
||||||
|
<h2 class="text-lg font-bold mb-4 text-gray-700 uppercase tracking-wider">
|
||||||
|
WMP DATA TABLE:
|
||||||
|
</h2>
|
||||||
|
<div class="overflow-x-auto rounded-lg shadow">
|
||||||
|
<table class="w-full divide-y divide-gray-200 text-sm text-center">
|
||||||
|
<thead class="bg-gray-100 text-s font-semibold uppercase text-gray-700">
|
||||||
|
<tr>
|
||||||
|
<th class="border px-4 py-2">No</th>
|
||||||
|
<th class="border px-4 py-2">Created Datetime</th>
|
||||||
|
<th class="border px-4 py-2 whitespace-nowrap">Created By</th>
|
||||||
|
<th class="border px-4 py-2 whitespace-nowrap">MPacking No</th>
|
||||||
|
<th class="border px-4 py-2 whitespace-nowrap">Item Code</th>
|
||||||
|
<th class="border px-4 py-2">Description</th>
|
||||||
|
<th class="border px-4 py-2">Process Order</th>
|
||||||
|
<th class="border px-4 py-2">Weight</th>
|
||||||
|
<th class="border px-4 py-2">Scanned Datetime</th>
|
||||||
|
<th class="border px-4 py-2 whitespace-nowrap">Scanned By</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody class="divide-y divide-gray-100">
|
||||||
|
@forelse ($records as $index => $record)
|
||||||
|
<tr class="hover:bg-gray-50">
|
||||||
|
<td class="border px-4 py-2">{{ $index + 1 }}</td>
|
||||||
|
<td class="border px-4 py-2 whitespace-nowrap">{{ $record['created_at'] ?? '-' }}</td>
|
||||||
|
<td class="border px-4 py-2 whitespace-nowrap">{{ $record['created_by'] ?? '-' }}</td>
|
||||||
|
<td class="border px-4 py-2 whitespace-nowrap">{{ $record['wire_packing_number'] ?? '-' }}</td>
|
||||||
|
<td class="border px-4 py-2">{{ $record['item_code'] ?? '-' }}</td>
|
||||||
|
<td class="border px-4 py-2 whitespace-nowrap">{{ $record['item_description'] ?? '-' }}</td>
|
||||||
|
<td class="border px-4 py-2 whitespace-nowrap">{{ $record['process_order'] ?? '-' }}</td>
|
||||||
|
<td class="border px-4 py-2">{{ $record['weight'] ?? '-' }}</td>
|
||||||
|
<td class="border px-4 py-2 whitespace-nowrap">{{ $record['scanned_at'] ?? '-' }}</td>
|
||||||
|
<td class="border px-4 py-2">{{ $record['scanned_by'] ?? '-' }}</td>
|
||||||
|
</tr>
|
||||||
|
@empty
|
||||||
|
<tr>
|
||||||
|
<td colspan="10" class="px-4 py-4 text-center text-gray-500">
|
||||||
|
No wire master packing records found.
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
@endforelse
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
378
resources/views/pdf/wire-pallet.blade.php
Normal file
378
resources/views/pdf/wire-pallet.blade.php
Normal file
@@ -0,0 +1,378 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<title>WireLabel</title>
|
||||||
|
@php
|
||||||
|
|
||||||
|
$pageHeightMm = 100;
|
||||||
|
$pageWidthMm = 85;
|
||||||
|
$paddingMm = 1.3;
|
||||||
|
|
||||||
|
|
||||||
|
$headerRows = [
|
||||||
|
'PRODUCT' => $product,
|
||||||
|
'MONTH/YEAR' => $monthYear,
|
||||||
|
'CUSTOMER PO' => $customerCode,
|
||||||
|
'CUSTOMER NAME' => $customerName,
|
||||||
|
'NO OF MASTER BOX' => $masterBox,
|
||||||
|
];
|
||||||
|
|
||||||
|
$titleHeight = 10;
|
||||||
|
$headerRowHeight = 5;
|
||||||
|
$itemHeaderHeight = 5;
|
||||||
|
|
||||||
|
// 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); // 97.4mm
|
||||||
|
|
||||||
|
$numItems = count($items) ?: 1;
|
||||||
|
|
||||||
|
// Total fixed space
|
||||||
|
$fixedSpace = $titleHeight +
|
||||||
|
(5 * $headerRowHeight) + // 6 header rows
|
||||||
|
$itemHeaderHeight +
|
||||||
|
$grossWeightHeight +
|
||||||
|
$netWeightHeight +
|
||||||
|
$licenseHeight +
|
||||||
|
$companyInfoHeight;
|
||||||
|
|
||||||
|
$spaceForItemsOnly = $availableHeight - $fixedSpace; //97.4 - 68 = 29.4mm
|
||||||
|
|
||||||
|
// $itemRowHeight = $spaceForItemsOnly / $numItems; // 29.4 / 2 = 14.7
|
||||||
|
|
||||||
|
$itemRowHeight = floor(($spaceForItemsOnly / $numItems) * 10) / 10;
|
||||||
|
|
||||||
|
// $itemRowHeight -= 0.5;
|
||||||
|
if ($numItems == 1) {
|
||||||
|
$itemRowHeight -= 0.5;
|
||||||
|
}
|
||||||
|
|
||||||
|
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';
|
||||||
|
}
|
||||||
|
|
||||||
|
// Compensate for borders (0.3mm top + 0.3mm bottom = 0.6mm)
|
||||||
|
$compensatedTitleHeight = $titleHeight - 0.6;
|
||||||
|
$compensatedHeaderHeight = $headerRowHeight - 0.6;
|
||||||
|
$compensatedItemHeaderHeight = $itemHeaderHeight - 0.6;
|
||||||
|
$compensatedItemHeight = $itemRowHeight - 0.6;
|
||||||
|
$compensatedGrossHeight = $grossWeightHeight - 0.6;
|
||||||
|
$compensatedNetHeight = $netWeightHeight - 0.6;
|
||||||
|
$compensatedLicenseHeight = $licenseHeight - 0.6;
|
||||||
|
$compensatedCompanyHeight = $companyInfoHeight - 0.6;
|
||||||
|
// $qrBase64 = 'data:image/png;base64,' . base64_encode(
|
||||||
|
// QrCode::format('png')
|
||||||
|
// ->size(120) // 12mm ~ 120px
|
||||||
|
// ->margin(0)
|
||||||
|
// ->generate($pallet)
|
||||||
|
// $qrBase64 = 'data:image/png;base64,' . base64_encode(
|
||||||
|
// QrCode::format('png')
|
||||||
|
// ->size(120)
|
||||||
|
// ->margin(0)
|
||||||
|
// ->errorCorrection('H')
|
||||||
|
// ->generate($pallet)
|
||||||
|
// );
|
||||||
|
@endphp
|
||||||
|
|
||||||
|
<style>
|
||||||
|
@page {
|
||||||
|
size: 85mm 100mm;
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
table {
|
||||||
|
width: 100%;
|
||||||
|
border-collapse: collapse;
|
||||||
|
/* table-layout: fixed; */
|
||||||
|
/* height: <?php echo $availableHeight; ?>mm !important; */
|
||||||
|
}
|
||||||
|
|
||||||
|
td, th {
|
||||||
|
border: 0.3px solid #000 !important;
|
||||||
|
vertical-align: middle;
|
||||||
|
line-height: 1 !important;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Title row - FIXED 12mm */
|
||||||
|
.title-row td {
|
||||||
|
height: <?php echo $compensatedTitleHeight; ?>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, $compensatedTitleHeight * 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 rows - FIXED 5mm each */
|
||||||
|
.header-row td {
|
||||||
|
height: <?php echo $compensatedHeaderHeight; ?>mm !important;
|
||||||
|
padding: 0.2mm 0.5mm !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Items header - FIXED 5mm */
|
||||||
|
.items-header-row td {
|
||||||
|
height: <?php echo $compensatedItemHeaderHeight; ?>mm !important;
|
||||||
|
font-weight: bold;
|
||||||
|
text-align: center;
|
||||||
|
font-size: 6.5px;
|
||||||
|
padding: 0.2mm 0.5mm !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ITEM ROWS - ONLY THESE ADJUST DYNAMICALLY */
|
||||||
|
.item-row td {
|
||||||
|
height: <?php echo $compensatedItemHeight; ?>mm !important;
|
||||||
|
font-size: <?php echo $itemFontSize; ?> !important;
|
||||||
|
padding: <?php echo $itemPadding; ?> !important;
|
||||||
|
line-height: 1 !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Gross Weight row - FIXED 5mm */
|
||||||
|
.gross-weight-row td {
|
||||||
|
height: <?php echo $compensatedGrossHeight; ?>mm !important;
|
||||||
|
text-align: center;
|
||||||
|
font-size: 6.5px;
|
||||||
|
padding: 0.2mm 0.5mm !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Net Weight row - FIXED 5mm */
|
||||||
|
.net-weight-row td {
|
||||||
|
height: <?php echo $compensatedNetHeight; ?>mm !important;
|
||||||
|
text-align: center;
|
||||||
|
font-size: 6.5px;
|
||||||
|
padding: 0.2mm 0.5mm !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* License row - FIXED 5mm */
|
||||||
|
.license-row td {
|
||||||
|
height: <?php echo $compensatedLicenseHeight; ?>mm !important;
|
||||||
|
text-align: center;
|
||||||
|
font-size: 6.5px;
|
||||||
|
padding: 0.2mm 0.5mm !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Company info row - FIXED 8mm */
|
||||||
|
.company-info-row td {
|
||||||
|
height: <?php echo $compensatedCompanyHeight; ?>mm !important;
|
||||||
|
font-size: 5.5px;
|
||||||
|
line-height: 0.9 !important;
|
||||||
|
padding: 0.1mm 0.5mm !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.label {
|
||||||
|
font-weight: bold;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.header-row .label {
|
||||||
|
width: 40%; /* All header label cells get same width */
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
.center {
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.right {
|
||||||
|
text-align: right;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Column widths */
|
||||||
|
.col-1 { width: 22%; }
|
||||||
|
.col-2 { width: 45%; }
|
||||||
|
.col-3 { width: 15%; }
|
||||||
|
.col-4 { width: 25%; }
|
||||||
|
|
||||||
|
/* Force exact heights for rows - ALL FIXED EXCEPT ITEM ROWS */
|
||||||
|
.title-row {
|
||||||
|
height: <?php echo $titleHeight; ?>mm !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.header-row {
|
||||||
|
height: <?php echo $headerRowHeight; ?>mm !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.items-header-row {
|
||||||
|
height: <?php echo $itemHeaderHeight; ?>mm !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ONLY ITEM ROWS HAVE DYNAMIC HEIGHT */
|
||||||
|
.item-row {
|
||||||
|
height: <?php echo $itemRowHeight; ?>mm !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.gross-weight-row {
|
||||||
|
height: <?php echo $grossWeightHeight; ?>mm !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.net-weight-row {
|
||||||
|
height: <?php echo $netWeightHeight; ?>mm !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.license-row {
|
||||||
|
height: <?php echo $licenseHeight; ?>mm !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.company-info-row {
|
||||||
|
height: <?php echo $companyInfoHeight; ?>mm !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
</style>
|
||||||
|
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<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"> --}}
|
||||||
|
<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;">
|
||||||
|
C.R.I POLY WRAPPED WINDING WIRE
|
||||||
|
<div class="vertical-line right"></div>
|
||||||
|
{{-- <img src="<?php echo public_path('images/isi_8783.png'); ?>"
|
||||||
|
class="logo"
|
||||||
|
alt="CRI Logo"
|
||||||
|
style="height: <?php echo $isilogoHeight; ?>mm;
|
||||||
|
max-width: <?php echo $isilogoMaxWidth; ?>mm;
|
||||||
|
left: 71mm;"> --}}
|
||||||
|
<img src="{{ $qrBase64 }}"
|
||||||
|
style="position: absolute; bottom: 1.2mm; right: 2mm; width: 8mm; height: 7.2mm;">
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<!-- Header Information Rows - FIXED 5mm each -->
|
||||||
|
<?php foreach ($headerRows as $label => $value): ?>
|
||||||
|
{{-- <tr class="header-row">
|
||||||
|
<td class="label" colspan="2"><?php echo $label; ?> :</td>
|
||||||
|
<td colspan="2"><?php echo $value; ?></td>
|
||||||
|
</tr> --}}
|
||||||
|
<tr class="header-row">
|
||||||
|
<td class="label"><?php echo $label; ?></td>
|
||||||
|
<td colspan="3"><?php echo $value; ?></td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<?php endforeach; ?>
|
||||||
|
|
||||||
|
<!-- Items Header - FIXED 5mm -->
|
||||||
|
<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</td>
|
||||||
|
<td class="col-4 center">NO OF BOX</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<!-- Item Rows - ONLY THESE ADJUST DYNAMICALLY -->
|
||||||
|
<?php if(count($items) > 0): ?>
|
||||||
|
<?php foreach ($items 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>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
<?php else: ?>
|
||||||
|
<tr class="item-row">
|
||||||
|
<td colspan="4" class="center">No items available</td>
|
||||||
|
</tr>
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
|
<!-- Gross Weight - FIXED 5mm -->
|
||||||
|
<tr class="gross-weight-row">
|
||||||
|
<td colspan="2" class="label center">GROSS WEIGHT</td>
|
||||||
|
<td colspan="2" class="center"><?php echo number_format($grossWeight, 3); ?></td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<!-- Net Weight - FIXED 5mm -->
|
||||||
|
<tr class="net-weight-row">
|
||||||
|
<td colspan="2" class="label center">NET WEIGHT</td>
|
||||||
|
<td colspan="2" class="center"><?php echo number_format($netWeight, 3); ?></td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<!-- License - FIXED 5mm -->
|
||||||
|
<tr class="license-row">
|
||||||
|
<td colspan="4" class="center">
|
||||||
|
{{-- MANUFACTURERS MADE IN INDIA *UNDER LICENSE --}}
|
||||||
|
MANUFACTURERS
|
||||||
|
MADE IN INDIA
|
||||||
|
*Under License
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<!-- Company Info - FIXED 8mm -->
|
||||||
|
<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 036<br>
|
||||||
|
For Feedback/Complaint: C.R.I Customer care cell Toll-Free: 1800 121 1243
|
||||||
|
{{-- <img src="{{ $qrBase64 }}"
|
||||||
|
style="position: absolute; bottom: 2.8mm; right: 2mm; width: 8mm; height: 6.8mm;"> --}}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -24,7 +24,7 @@ use App\Http\Controllers\ModuleProductionLineStopController;
|
|||||||
use App\Http\Controllers\ModuleProductionOrderDataController;
|
use App\Http\Controllers\ModuleProductionOrderDataController;
|
||||||
use App\Http\Controllers\ObdController;
|
use App\Http\Controllers\ObdController;
|
||||||
use App\Http\Controllers\PalletController;
|
use App\Http\Controllers\PalletController;
|
||||||
// use App\Http\Controllers\PalletPrintController;
|
use App\Http\Controllers\PalletPrintController;
|
||||||
use App\Http\Controllers\PdfController;
|
use App\Http\Controllers\PdfController;
|
||||||
use App\Http\Controllers\PlantController;
|
use App\Http\Controllers\PlantController;
|
||||||
use App\Http\Controllers\ProductionStickerReprintController;
|
use App\Http\Controllers\ProductionStickerReprintController;
|
||||||
@@ -151,14 +151,6 @@ Route::post('testing/reading/store-data', [TestingPanelController::class, 'store
|
|||||||
|
|
||||||
Route::get('get-pdf', [PdfController::class, 'getPdf']);
|
Route::get('get-pdf', [PdfController::class, 'getPdf']);
|
||||||
|
|
||||||
Route::get('process-order/details', [PdfController::class, 'getProcessOrderData']);
|
|
||||||
|
|
||||||
Route::post('process-order', [PdfController::class, 'storeProcessOrderData']);
|
|
||||||
|
|
||||||
Route::get('sap/files', [SapFileController::class, 'readFiles']);
|
|
||||||
|
|
||||||
Route::get('get-characteristics/master-data', [CharacteristicsController::class, 'getCharacteristicsMaster']);
|
|
||||||
|
|
||||||
// ..Part Validation - Characteristics
|
// ..Part Validation - Characteristics
|
||||||
|
|
||||||
Route::get('laser/item/get-master-data', [StickerMasterController::class, 'get_master']);
|
Route::get('laser/item/get-master-data', [StickerMasterController::class, 'get_master']);
|
||||||
@@ -189,9 +181,19 @@ Route::get('laser/characteristics/request', [CharacteristicsController::class, '
|
|||||||
|
|
||||||
Route::post('laser-doc-pdf', [PdfController::class, 'storeLaserPdf']);
|
Route::post('laser-doc-pdf', [PdfController::class, 'storeLaserPdf']);
|
||||||
|
|
||||||
|
// ..Process Order
|
||||||
|
|
||||||
|
Route::get('process-order/details', [PdfController::class, 'getProcessOrderData']);
|
||||||
|
|
||||||
|
Route::post('process-order', [PdfController::class, 'storeProcessOrderData']);
|
||||||
|
|
||||||
|
Route::get('sap/files', [SapFileController::class, 'readFiles']);
|
||||||
|
|
||||||
// ..Product Characteristics
|
// ..Product Characteristics
|
||||||
|
|
||||||
Route::get('characteristics/get/master', [CharacteristicsController::class, 'getCharMaster']);
|
Route::get('get-characteristics/master-data', [CharacteristicsController::class, 'getCharacteristicsMaster']);
|
||||||
|
|
||||||
|
Route::get('characteristics/get/master', [CharacteristicsController::class, 'getCharMaster']); // LIVEEEE
|
||||||
|
|
||||||
Route::post('characteristics/values', [CharacteristicsController::class, 'storeCharValues']);
|
Route::post('characteristics/values', [CharacteristicsController::class, 'storeCharValues']);
|
||||||
|
|
||||||
@@ -213,7 +215,6 @@ Route::post('file/store', [SapFileController::class, 'store'])->name('file.store
|
|||||||
|
|
||||||
// Route::post('invoice-exit', [InvoiceValidationController::class, 'handle']);
|
// Route::post('invoice-exit', [InvoiceValidationController::class, 'handle']);
|
||||||
|
|
||||||
// Route::get('/print-pallet/{pallet}/{plant}', [PalletPrintController::class, 'print'])
|
Route::get('/print-pallet/{pallet}/{plant}', [PalletPrintController::class, 'print'])->name('print.pallet');
|
||||||
// ->name('print.pallet');
|
|
||||||
|
|
||||||
Route::post('vehicle/entry', [VehicleController::class, 'storeVehicleEntry']);
|
Route::post('vehicle/entry', [VehicleController::class, 'storeVehicleEntry']);
|
||||||
|
|||||||
Reference in New Issue
Block a user