Compare commits
1 Commits
c6714b195e
...
renovate/a
| Author | SHA1 | Date | |
|---|---|---|---|
| e501e91673 |
@@ -142,12 +142,13 @@ class ProcessOrderImporter extends Importer
|
|||||||
if ($recQuan == null || $recQuan == '') {
|
if ($recQuan == null || $recQuan == '') {
|
||||||
$recQuan = 0;
|
$recQuan = 0;
|
||||||
}
|
}
|
||||||
if ($reworkStatus == null || $reworkStatus = '' || $reworkStatus == 0 || $reworkStatus = '0') {
|
if ($reworkStatus == null || $reworkStatus = '') {
|
||||||
$reworkStatus = 0;
|
$reworkStatus = 0;
|
||||||
} elseif ($reworkStatus == 1 || $reworkStatus = '1') {
|
}
|
||||||
$reworkStatus = 1;
|
|
||||||
} else {
|
if ($createdBy == null || $createdBy == '') {
|
||||||
$warnMsg[] = 'Invalid rework status found';
|
$createdBy = Filament::auth()->user()?->name;
|
||||||
|
$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)) {
|
||||||
@@ -208,16 +209,21 @@ class ProcessOrderImporter extends Importer
|
|||||||
$lineId = null;
|
$lineId = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// $user = User::where('name', $this->data['created_by'])->first();
|
if ($createdBy != null && $createdBy != '') {
|
||||||
// if (! $user) {
|
if ($plantId) {
|
||||||
// $warnMsg[] = 'User not found';
|
$user = User::where('name', $createdBy)->first();
|
||||||
// }
|
|
||||||
|
|
||||||
if (! $createdBy) {
|
$userPlant = User::where('name', $createdBy)->where('plant_id', $plantId)->first();
|
||||||
$createdBy = Filament::auth()->user()->name;
|
|
||||||
$updatedBy = Filament::auth()->user()->name;
|
if (! $user) {
|
||||||
} elseif (! $updatedBy) {
|
$warnMsg[] = 'Created By user name not found!';
|
||||||
$updatedBy = Filament::auth()->user()->name;
|
} elseif (! $userPlant && ! $user->hasRole('Super Admin')) {
|
||||||
|
$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)) {
|
||||||
@@ -274,10 +280,9 @@ 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',
|
||||||
@@ -292,8 +297,8 @@ class ProcessOrderImporter extends Importer
|
|||||||
[
|
[
|
||||||
'plant_id' => $plantId,
|
'plant_id' => $plantId,
|
||||||
'line_id' => $lineId,
|
'line_id' => $lineId,
|
||||||
'item_id' => $itemId,
|
|
||||||
'process_order' => $processOrder,
|
'process_order' => $processOrder,
|
||||||
|
'item_id' => $itemId,
|
||||||
'coil_number' => $coilNo,
|
'coil_number' => $coilNo,
|
||||||
'order_quantity' => $orderQuan,
|
'order_quantity' => $orderQuan,
|
||||||
'received_quantity' => $recQuan,
|
'received_quantity' => $recQuan,
|
||||||
@@ -301,17 +306,13 @@ 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)
|
||||||
@@ -323,7 +324,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,6 +31,47 @@ 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()
|
||||||
@@ -56,13 +97,9 @@ 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')
|
||||||
@@ -84,86 +121,23 @@ class ProductionTarget extends Page
|
|||||||
'12' => 'December',
|
'12' => 'December',
|
||||||
])
|
])
|
||||||
->required()
|
->required()
|
||||||
->afterStateUpdated(function ($state, callable $get, $set) {
|
->afterStateUpdated(function ($state, callable $get) {
|
||||||
|
|
||||||
$set('plant_id', null);
|
|
||||||
$set('line_id', null);
|
|
||||||
$set('category', null);
|
|
||||||
|
|
||||||
|
$plantId = $get('plant_id');
|
||||||
|
$lineId = $get('line_id');
|
||||||
|
// $month = $get('month');
|
||||||
$year = $get('year');
|
$year = $get('year');
|
||||||
|
|
||||||
$this->dispatch('loadData',$year, $state, '', '', '');
|
$month = (int) $get('month');
|
||||||
|
|
||||||
// $plantId = $get('plant_id');
|
if (!$month) {
|
||||||
// $lineId = $get('line_id');
|
return;
|
||||||
// // $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 [];
|
|
||||||
}
|
}
|
||||||
|
$this->dispatch('loadData', $plantId, $lineId, $month, $year);
|
||||||
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');
|
|
||||||
$lineId = $get('line_id');
|
|
||||||
// $month = $get('month');
|
|
||||||
$year = $get('year');
|
|
||||||
|
|
||||||
$month = (int) $get('month');
|
|
||||||
$this->dispatch('loadData',$year, $month, $plantId, $lineId, '');
|
|
||||||
}),
|
|
||||||
|
|
||||||
TextInput::make('category')
|
|
||||||
->label('Category')
|
|
||||||
->reactive()
|
|
||||||
->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(5)
|
->columns(4)
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,176 +0,0 @@
|
|||||||
<?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,
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
<?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;
|
|
||||||
}
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
<?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(),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
<?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(),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
<?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')
|
->label('Item Code')
|
||||||
->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,56 +367,50 @@ 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($invalidPenDay)) {
|
if (! empty($invalidPlantCode) || ! empty($invalidRecPlant) || ! empty($invalidRecPlantName) || ! empty($invalidInvNo) || ! empty($invalidInvDt) || ! empty($invalidICode) || ! empty($invalidDesc) || ! empty($invalidQty) || ($invalidTransportName) || ! empty($invalidLRBLAWNo) || ! empty($invalidLRBLAWDt) || ! empty($invalidPenDay)) {
|
||||||
$errorMsg = '';
|
$errorMsg = '';
|
||||||
|
|
||||||
if (! empty($invalidPlantCode)) {
|
if (! empty($invalidPlantCode)) {
|
||||||
$errorMsg .= 'Missing Receiving Plant Code in rows: '.implode(', ', $invalidPlantCode).'<br>';
|
$errorMsg .= 'Missing Receiving Plant in rows: '.implode(', ', $invalidPlantCode).'<br>';
|
||||||
}
|
}
|
||||||
if (! empty($invalidRecPlant)) {
|
if (! empty($invalidRecPlant)) {
|
||||||
$errorMsg .= 'Missing Receiving Plant in rows: '.implode(', ', $invalidRecPlant).'<br>';
|
$errorMsg .= 'Missing Receiving Plant Name in rows: '.implode(', ', $invalidRecPlant).'<br>';
|
||||||
}
|
}
|
||||||
if (! empty($invalidRecPlantName)) {
|
if (! empty($invalidRecPlantName)) {
|
||||||
$errorMsg .= 'Missing Receiving Plant Name in rows: '.implode(', ', $invalidRecPlantName).'<br>';
|
$errorMsg .= 'Missing Transit Days in rows: '.implode(', ', $invalidRecPlantName).'<br>';
|
||||||
}
|
}
|
||||||
if (! empty($invalidInvNo)) {
|
if (! empty($invalidInvNo)) {
|
||||||
$errorMsg .= 'Missing Invoice Number in rows: '.implode(', ', $invalidInvNo).'<br>';
|
$errorMsg .= 'Missing Transport Name in rows: '.implode(', ', $invalidInvNo).'<br>';
|
||||||
}
|
}
|
||||||
if (! empty($invalidInvDt)) {
|
if (! empty($invalidInvDt)) {
|
||||||
$errorMsg .= 'Missing Invoice Dates in rows: '.implode(', ', $invalidInvDt).'<br>';
|
$errorMsg .= 'Missing Receiving Plant in rows: '.implode(', ', $invalidInvDt).'<br>';
|
||||||
}
|
}
|
||||||
if (! empty($invalidICode)) {
|
if (! empty($invalidICode)) {
|
||||||
$errorMsg .= 'Missing Item Code in rows: '.implode(', ', $invalidICode).'<br>';
|
$errorMsg .= 'Missing Receiving Plant Name in rows: '.implode(', ', $invalidICode).'<br>';
|
||||||
}
|
}
|
||||||
if (! empty($invalidDesc)) {
|
if (! empty($invalidDesc)) {
|
||||||
$errorMsg .= 'Missing Item Description in rows: '.implode(', ', $invalidDesc).'<br>';
|
$errorMsg .= 'Missing Transit Days in rows: '.implode(', ', $invalidDesc).'<br>';
|
||||||
}
|
}
|
||||||
if (! empty($invalidQty)) {
|
if (! empty($invalidQty)) {
|
||||||
$errorMsg .= 'Missing Quantity in rows: '.implode(', ', $invalidQty).'<br>';
|
$errorMsg .= 'Missing Transport Name in rows: '.implode(', ', $invalidQty).'<br>';
|
||||||
}
|
}
|
||||||
if (! empty($invalidTransportName)) {
|
if (! empty($invalidTransportName)) {
|
||||||
$errorMsg .= 'Missing Transport Name in rows: '.implode(', ', $invalidTransportName).'<br>';
|
$errorMsg .= 'Missing Receiving Plant 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 Pending Days in rows: '.implode(', ', $invalidPenDay).'<br>';
|
$errorMsg .= 'Missing Transport Name in rows: '.implode(', ', $invalidPenDay).'<br>';
|
||||||
}
|
}
|
||||||
|
|
||||||
Notification::make()
|
Notification::make()
|
||||||
@@ -460,30 +454,19 @@ 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -547,7 +530,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);
|
||||||
$formatted = "{$year}-{$month}-{$day}";
|
$formattedDate = "{$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 {
|
||||||
@@ -557,16 +540,6 @@ 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,
|
||||||
@@ -594,28 +567,10 @@ 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 Completed')
|
->title('Upload Success')
|
||||||
->body($message)
|
->body('Invoice in transit uploaded successfully!')
|
||||||
->success()
|
->success()
|
||||||
->send();
|
->send();
|
||||||
|
|
||||||
|
|||||||
@@ -48,7 +48,6 @@ 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()
|
||||||
@@ -80,7 +79,6 @@ 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()
|
||||||
@@ -439,7 +437,7 @@ class ProductionPlanResource extends Resource
|
|||||||
->sortable()
|
->sortable()
|
||||||
->searchable(),
|
->searchable(),
|
||||||
Tables\Columns\TextColumn::make('line.name')
|
Tables\Columns\TextColumn::make('line.name')
|
||||||
->label('Line')
|
->label('Plant')
|
||||||
->alignCenter()
|
->alignCenter()
|
||||||
->sortable()
|
->sortable()
|
||||||
->searchable(),
|
->searchable(),
|
||||||
|
|||||||
@@ -26,7 +26,6 @@ class ProductionTargetPlan extends Component
|
|||||||
|
|
||||||
protected $listeners = [
|
protected $listeners = [
|
||||||
'loadData' => 'loadProductionData',
|
'loadData' => 'loadProductionData',
|
||||||
'loadCategoryData' => 'loadProductionDataCategory',
|
|
||||||
'loadData1' => 'exportProductionData',
|
'loadData1' => 'exportProductionData',
|
||||||
];
|
];
|
||||||
|
|
||||||
@@ -176,7 +175,7 @@ class ProductionTargetPlan extends Component
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
public function loadProductionData($year, $month, $plantId, $lineId, $category)
|
public function loadProductionData($plantId, $lineId, $month, $year)
|
||||||
{
|
{
|
||||||
if (!$plantId || !$lineId || !$month || !$year) {
|
if (!$plantId || !$lineId || !$month || !$year) {
|
||||||
$this->records = [];
|
$this->records = [];
|
||||||
@@ -196,9 +195,6 @@ 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',
|
||||||
@@ -207,7 +203,6 @@ 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',
|
||||||
@@ -234,11 +229,6 @@ 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) =>
|
||||||
@@ -259,7 +249,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'] = [];
|
||||||
@@ -301,122 +291,6 @@ 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(
|
||||||
|
|||||||
@@ -1,33 +0,0 @@
|
|||||||
<?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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,106 +0,0 @@
|
|||||||
<?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');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -8,7 +8,7 @@
|
|||||||
"require": {
|
"require": {
|
||||||
"php": "^8.2",
|
"php": "^8.2",
|
||||||
"alperenersoy/filament-export": "^3.0",
|
"alperenersoy/filament-export": "^3.0",
|
||||||
"althinect/filament-spatie-roles-permissions": "^2.3",
|
"althinect/filament-spatie-roles-permissions": "^3.0",
|
||||||
"erag/laravel-pwa": "^1.9",
|
"erag/laravel-pwa": "^1.9",
|
||||||
"filament/filament": "^3.3",
|
"filament/filament": "^3.3",
|
||||||
"intervention/image": "^3.11",
|
"intervention/image": "^3.11",
|
||||||
|
|||||||
@@ -1,45 +0,0 @@
|
|||||||
<?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');
|
|
||||||
}
|
|
||||||
};
|
|
||||||
@@ -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();
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -6,11 +6,10 @@
|
|||||||
<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="4">No</th>
|
<th class="border px-4 py-2" rowspan="3">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
|
||||||
@@ -46,7 +45,6 @@
|
|||||||
<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>
|
||||||
|
|||||||
Reference in New Issue
Block a user