Added coil packing resource pages
All checks were successful
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 13s
All checks were successful
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 13s
This commit is contained in:
468
app/Filament/Resources/CoilPackingResource.php
Normal file
468
app/Filament/Resources/CoilPackingResource.php
Normal file
@@ -0,0 +1,468 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Resources;
|
||||||
|
|
||||||
|
use App\Filament\Resources\CoilPackingResource\Pages;
|
||||||
|
use App\Filament\Resources\CoilPackingResource\RelationManagers;
|
||||||
|
use App\Models\CoilPacking;
|
||||||
|
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\Forms\Components\Section;
|
||||||
|
use Filament\Tables\Actions\ExportAction;
|
||||||
|
use Filament\Tables\Actions\ImportAction;
|
||||||
|
use App\Filament\Exports\CoilPackingExporter;
|
||||||
|
use App\Filament\Imports\CoilPackingImporter;
|
||||||
|
use Filament\Tables\Filters\Filter;
|
||||||
|
use Filament\Forms\Components\Select;
|
||||||
|
use Filament\Forms\Components\DateTimePicker;
|
||||||
|
use Filament\Forms\Components\TextInput;
|
||||||
|
|
||||||
|
class CoilPackingResource extends Resource
|
||||||
|
{
|
||||||
|
protected static ?string $model = CoilPacking::class;
|
||||||
|
|
||||||
|
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
|
||||||
|
|
||||||
|
protected static ?string $navigationGroup = 'Coil Packing';
|
||||||
|
|
||||||
|
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()
|
||||||
|
->afterStateUpdated(function (callable $set) {
|
||||||
|
$set('coil_packing_number', null);
|
||||||
|
$set('process_order', null);
|
||||||
|
}),
|
||||||
|
Forms\Components\TextInput::make('coil_packing_number')
|
||||||
|
->label('Scan Coil 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');
|
||||||
|
|
||||||
|
$year = now()->format('y');
|
||||||
|
$month = now()->format('m');
|
||||||
|
$prefix = "CP-{$year}{$month}";
|
||||||
|
|
||||||
|
$lastPallet = CoilPacking::where('coil_packing_number', 'like', "{$prefix}%")
|
||||||
|
->orderByDesc('coil_packing_number')
|
||||||
|
->first();
|
||||||
|
|
||||||
|
if ($lastPallet) {
|
||||||
|
$lastNumber = (int) substr(
|
||||||
|
$lastPallet->coil_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('coil_packing_number', $newPalletNumber);
|
||||||
|
$set('plant_id', $plantId);
|
||||||
|
|
||||||
|
$livewire->redirectToCoilQrPdf($newPalletNumber);
|
||||||
|
})
|
||||||
|
),
|
||||||
|
Forms\Components\TextInput::make('process_order')
|
||||||
|
->label('Coil No')
|
||||||
|
->reactive()
|
||||||
|
->readOnly(fn (callable $get) => ! $get('coil_packing_number') || $get('removeSno_number'))
|
||||||
|
->extraAttributes([
|
||||||
|
'x-on:keydown.enter.prevent' => '$wire.processOrderSNo()',
|
||||||
|
]),
|
||||||
|
Forms\Components\TextInput::make('removeSno_number')
|
||||||
|
->label('Remove Coil No')
|
||||||
|
->reactive()
|
||||||
|
->minLength(9)
|
||||||
|
->readOnly(fn (callable $get) => ! $get('coil_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('coil_packing_number', $state);
|
||||||
|
$set('pallet_number_locked', false);
|
||||||
|
})
|
||||||
|
->options(function ($get) {
|
||||||
|
|
||||||
|
$plantId = $get('plant_id');
|
||||||
|
|
||||||
|
if (!$plantId) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
return CoilPacking::query()
|
||||||
|
->where('plant_id', $plantId)
|
||||||
|
->where(function ($query) {
|
||||||
|
$query->whereNull('coil_packing_status')
|
||||||
|
->orWhere('coil_packing_status', '');
|
||||||
|
})
|
||||||
|
->whereNotNull('coil_packing_number')
|
||||||
|
->orderBy('coil_packing_number', 'asc')
|
||||||
|
->pluck('coil_packing_number')
|
||||||
|
->unique()
|
||||||
|
->mapWithKeys(fn ($number) => [$number => $number])
|
||||||
|
->toArray();
|
||||||
|
}),
|
||||||
|
Forms\Components\View::make('forms.components.save-coil-processorder-button'),
|
||||||
|
Forms\Components\Hidden::make('created_by')
|
||||||
|
->label('Created By'),
|
||||||
|
Forms\Components\Hidden::make('updated_by')
|
||||||
|
->label('Updated By'),
|
||||||
|
])
|
||||||
|
->columns(5),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
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('coil_packing_number')
|
||||||
|
->label('Coil Packing Number')
|
||||||
|
->alignCenter()
|
||||||
|
->searchable()
|
||||||
|
->sortable(),
|
||||||
|
Tables\Columns\TextColumn::make('process_order')
|
||||||
|
->label('Coil Number')
|
||||||
|
->alignCenter()
|
||||||
|
->searchable()
|
||||||
|
->sortable(),
|
||||||
|
Tables\Columns\TextColumn::make('coil_packing_status')
|
||||||
|
->label('Coil Packing Status')
|
||||||
|
->alignCenter()
|
||||||
|
->searchable()
|
||||||
|
->sortable(),
|
||||||
|
Tables\Columns\TextColumn::make('created_at')
|
||||||
|
->label('Created At')
|
||||||
|
->alignCenter()
|
||||||
|
->dateTime()
|
||||||
|
->sortable(),
|
||||||
|
Tables\Columns\TextColumn::make('created_by')
|
||||||
|
->label('Created By')
|
||||||
|
->alignCenter()
|
||||||
|
->sortable(),
|
||||||
|
Tables\Columns\TextColumn::make('updated_at')
|
||||||
|
->label('Updated At')
|
||||||
|
->alignCenter()
|
||||||
|
->dateTime()
|
||||||
|
->sortable()
|
||||||
|
->toggleable(isToggledHiddenByDefault: true),
|
||||||
|
Tables\Columns\TextColumn::make('updated_by')
|
||||||
|
->label('Updated By')
|
||||||
|
->alignCenter()
|
||||||
|
->sortable()
|
||||||
|
->toggleable(isToggledHiddenByDefault: true),
|
||||||
|
Tables\Columns\TextColumn::make('scanned_at')
|
||||||
|
->label('Scanned At')
|
||||||
|
->dateTime()
|
||||||
|
->sortable()
|
||||||
|
->toggleable(isToggledHiddenByDefault: true),
|
||||||
|
Tables\Columns\TextColumn::make('scanned_by')
|
||||||
|
->label('Scanned By')
|
||||||
|
->alignCenter()
|
||||||
|
->sortable()
|
||||||
|
->toggleable(isToggledHiddenByDefault: true),
|
||||||
|
Tables\Columns\TextColumn::make('deleted_at')
|
||||||
|
->dateTime()
|
||||||
|
->sortable()
|
||||||
|
->toggleable(isToggledHiddenByDefault: true),
|
||||||
|
])
|
||||||
|
->filters([
|
||||||
|
Tables\Filters\TrashedFilter::make(),
|
||||||
|
Filter::make('advanced_filters')
|
||||||
|
->label('Advanced Filters')
|
||||||
|
->form([
|
||||||
|
Select::make('Plant')
|
||||||
|
->label('Search by Plant Name')
|
||||||
|
->nullable()
|
||||||
|
->searchable()
|
||||||
|
->reactive()
|
||||||
|
->options(function (callable $get) {
|
||||||
|
$userHas = Filament::auth()->user()->plant_id;
|
||||||
|
|
||||||
|
if ($userHas && strlen($userHas) > 0) {
|
||||||
|
return Plant::where('id', $userHas)->pluck('name', 'id')->toArray();
|
||||||
|
} else {
|
||||||
|
return Plant::whereHas('coilPacking', function ($query) {
|
||||||
|
$query->whereNotNull('id');
|
||||||
|
})->orderBy('code')->pluck('name', 'id');
|
||||||
|
}
|
||||||
|
|
||||||
|
// return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
||||||
|
})
|
||||||
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||||
|
$set('Item', null);
|
||||||
|
}),
|
||||||
|
Select::make('Item')
|
||||||
|
->label('Search by Item Code')
|
||||||
|
->nullable()
|
||||||
|
->searchable()
|
||||||
|
->reactive()
|
||||||
|
->options(function (callable $get) {
|
||||||
|
$plantId = $get('Plant');
|
||||||
|
|
||||||
|
if (empty($plantId)) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
return Item::whereHas('coilPacking', function ($query) use ($plantId) {
|
||||||
|
if ($plantId) {
|
||||||
|
$query->where('plant_id', $plantId);
|
||||||
|
}
|
||||||
|
})->pluck('code', 'id');
|
||||||
|
})
|
||||||
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||||
|
$set('process_order', null);
|
||||||
|
}),
|
||||||
|
TextInput::make('coil_packing_number')
|
||||||
|
->label('Coil Packing Number')
|
||||||
|
->reactive()
|
||||||
|
->placeholder('Enter Coil Packing Number')
|
||||||
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||||
|
$set('process_order', null);
|
||||||
|
}),
|
||||||
|
TextInput::make('process_order')
|
||||||
|
->label('Coil No')
|
||||||
|
->reactive()
|
||||||
|
->placeholder('Enter Coil No')
|
||||||
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||||
|
$set('Rework', null);
|
||||||
|
}),
|
||||||
|
Select::make('coil_packing_status')
|
||||||
|
->label('Coil Packing Status')
|
||||||
|
->reactive()
|
||||||
|
->options([
|
||||||
|
'Completed' => 'Completed',
|
||||||
|
'Pending' => 'Pending',
|
||||||
|
]),
|
||||||
|
DateTimePicker::make(name: 'created_from')
|
||||||
|
->label('Created From')
|
||||||
|
->placeholder('Select From DateTime')
|
||||||
|
->reactive()
|
||||||
|
->native(false),
|
||||||
|
DateTimePicker::make('created_to')
|
||||||
|
->label('Created To')
|
||||||
|
->placeholder('Select To DateTime')
|
||||||
|
->reactive()
|
||||||
|
->native(false),
|
||||||
|
])
|
||||||
|
->query(function ($query, array $data) {
|
||||||
|
// Hide all records initially if no filters are applied
|
||||||
|
if (empty($data['Plant']) && empty($data['Item']) && empty($data['process_order']) && empty($data['coil_packing_number']) && empty($data['coil_packing_status']) && empty($data['created_from']) && empty($data['created_to'])) {
|
||||||
|
return $query->whereRaw('1 = 0');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! empty($data['Plant'])) {
|
||||||
|
$query->where('plant_id', $data['Plant']);
|
||||||
|
} else {
|
||||||
|
$userHas = Filament::auth()->user()->plant_id;
|
||||||
|
|
||||||
|
if ($userHas && strlen($userHas) > 0) {
|
||||||
|
return $query->whereRaw('1 = 0');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! empty($data['Item'])) {
|
||||||
|
$query->where('item_id', $data['Item']);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! empty($data['process_order'])) {
|
||||||
|
$query->where('process_order', 'like', '%'.$data['process_order'].'%');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! empty($data['coil_packing_number'])) {
|
||||||
|
$query->where('coil_packing_number', 'like', '%'.$data['coil_packing_number'].'%');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! empty($data['coil_packing_status'])) {
|
||||||
|
if ($data['coil_packing_status'] == 'Pending') {
|
||||||
|
$query->where(function ($q) {
|
||||||
|
$q->whereNull('coil_packing_status')
|
||||||
|
->orWhere('coil_packing_status', '');
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
$query->where('coil_packing_status', $data['coil_packing_status']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! empty($data['created_from'])) {
|
||||||
|
$query->where('created_at', '>=', $data['created_from']);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! empty($data['created_to'])) {
|
||||||
|
$query->where('created_at', '<=', $data['created_to']);
|
||||||
|
}
|
||||||
|
// $query->orderBy('created_at', 'asc');
|
||||||
|
})
|
||||||
|
->indicateUsing(function (array $data) {
|
||||||
|
$indicators = [];
|
||||||
|
|
||||||
|
if (! empty($data['Plant'])) {
|
||||||
|
$indicators[] = 'Plant Name: '.Plant::where('id', $data['Plant'])->value('name');
|
||||||
|
} else {
|
||||||
|
$userHas = Filament::auth()->user()->plant_id;
|
||||||
|
|
||||||
|
if ($userHas && strlen($userHas) > 0) {
|
||||||
|
return 'Plant Name: Choose plant to filter records.';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! empty($data['Item'])) {
|
||||||
|
$indicators[] = 'Item Code: '.Item::where('id', $data['Item'])->value('code');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! empty($data['process_order'])) {
|
||||||
|
$indicators[] = 'Coil No: '.$data['process_order'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! empty($data['coil_packing_number'])) {
|
||||||
|
$indicators[] = 'Coil Packing Number: '.$data['coil_packing_number'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! empty($data['coil_packing_status'])) {
|
||||||
|
$indicators[] = 'Coil Packing Status: '.$data['coil_packing_status'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! empty($data['created_from'])) {
|
||||||
|
$indicators[] = 'From: '.$data['created_from'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! empty($data['created_to'])) {
|
||||||
|
$indicators[] = 'To: '.$data['created_to'];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $indicators;
|
||||||
|
}),
|
||||||
|
])
|
||||||
|
->filtersFormMaxHeight('280px')
|
||||||
|
->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 Coil Packing')
|
||||||
|
->color('warning')
|
||||||
|
->importer(CoilPackingImporter::class)
|
||||||
|
->visible(function () {
|
||||||
|
return Filament::auth()->user()->can('view import coil packing');
|
||||||
|
}),
|
||||||
|
ExportAction::make()
|
||||||
|
->label('Export Coil Packing')
|
||||||
|
->color('warning')
|
||||||
|
->exporter(CoilPackingExporter::class)
|
||||||
|
->visible(function () {
|
||||||
|
return Filament::auth()->user()->can('view export coil packing');
|
||||||
|
}),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getRelations(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
//
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getPages(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'index' => Pages\ListCoilPackings::route('/'),
|
||||||
|
'create' => Pages\CreateCoilPacking::route('/create'),
|
||||||
|
'view' => Pages\ViewCoilPacking::route('/{record}'),
|
||||||
|
'edit' => Pages\EditCoilPacking::route('/{record}/edit'),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getEloquentQuery(): Builder
|
||||||
|
{
|
||||||
|
return parent::getEloquentQuery()
|
||||||
|
->withoutGlobalScopes([
|
||||||
|
SoftDeletingScope::class,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,800 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Resources\CoilPackingResource\Pages;
|
||||||
|
|
||||||
|
use App\Filament\Resources\CoilPackingResource;
|
||||||
|
use App\Models\CoilPacking;
|
||||||
|
use App\Models\Item;
|
||||||
|
use App\Models\Plant;
|
||||||
|
use Filament\Actions;
|
||||||
|
use Filament\Facades\Filament;
|
||||||
|
use Filament\Notifications\Notification;
|
||||||
|
use Filament\Resources\Pages\CreateRecord;
|
||||||
|
|
||||||
|
class CreateCoilPacking extends CreateRecord
|
||||||
|
{
|
||||||
|
protected static string $resource = CoilPackingResource::class;
|
||||||
|
|
||||||
|
protected static string $view = 'filament.resources.coil-packing-resource.create-coil-packing';
|
||||||
|
|
||||||
|
public $processOrder;
|
||||||
|
|
||||||
|
public $plantId;
|
||||||
|
|
||||||
|
public $count = 0;
|
||||||
|
|
||||||
|
public $snoCount = 0;
|
||||||
|
|
||||||
|
public $pendingPallet;
|
||||||
|
|
||||||
|
public $palletNo;
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
$coilPackNo = trim($this->form->getState()['coil_packing_number'])?? null;
|
||||||
|
|
||||||
|
$coilPackNo = trim($coilPackNo) ?? null;
|
||||||
|
|
||||||
|
$user = Filament::auth()->user();
|
||||||
|
|
||||||
|
$operatorName = $user->name;
|
||||||
|
|
||||||
|
if (empty($processOrder) || $processOrder == '')
|
||||||
|
{
|
||||||
|
Notification::make()
|
||||||
|
->title("Coil No can't be empty")
|
||||||
|
->danger()
|
||||||
|
->duration(5000)
|
||||||
|
->send();
|
||||||
|
|
||||||
|
$this->form->fill([
|
||||||
|
'process_order' => null,
|
||||||
|
'plant_id' => $plantId,
|
||||||
|
'coil_packing_number' => $coilPackNo,
|
||||||
|
'Sno_quantity' => 0,
|
||||||
|
'created_by' => $operatorName,
|
||||||
|
'scanned_by' => $operatorName,
|
||||||
|
]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$pattern = '/^([^|]+)\|([^|]+)$/';
|
||||||
|
|
||||||
|
if (!preg_match($pattern, $processOrder, $matches))
|
||||||
|
{
|
||||||
|
Notification::make()
|
||||||
|
->title("Scan Valid Qr code ")
|
||||||
|
->body("Expected Format: ItemCode|CoilNo")
|
||||||
|
->danger()
|
||||||
|
->duration(5000)
|
||||||
|
->send();
|
||||||
|
|
||||||
|
$this->form->fill([
|
||||||
|
'process_order' => null,
|
||||||
|
'plant_id' => $plantId,
|
||||||
|
'coil_packing_number' => $coilPackNo,
|
||||||
|
'Sno_quantity' => 0,
|
||||||
|
'created_by' => $operatorName,
|
||||||
|
'scanned_by' => $operatorName,
|
||||||
|
]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$materialCode = $matches[1];
|
||||||
|
$coilNo = $matches[2];
|
||||||
|
|
||||||
|
$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([
|
||||||
|
'plant_id' => $plantId,
|
||||||
|
'coil_packing_number' => $coilPackNo,
|
||||||
|
'process_order' => null,
|
||||||
|
'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([
|
||||||
|
'plant_id' => $plantId,
|
||||||
|
'coil_packing_number' => $coilPackNo,
|
||||||
|
'process_order' => null,
|
||||||
|
'Sno_quantity' => 0,
|
||||||
|
'created_by' => $operatorName,
|
||||||
|
'scanned_by' => $operatorName,
|
||||||
|
]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$processOrderAgaPlant = CoilPacking::where('process_order', $coilNo)->where('plant_id', $plantId)->first();
|
||||||
|
|
||||||
|
if($processOrderAgaPlant)
|
||||||
|
{
|
||||||
|
Notification::make()
|
||||||
|
->title("Duplicate Coil No")
|
||||||
|
->body("Duplicate coil number found '$coilNo' against Plant Code '$plantcode'")
|
||||||
|
->danger()
|
||||||
|
->duration(5000)
|
||||||
|
->send();
|
||||||
|
|
||||||
|
$this->form->fill([
|
||||||
|
'plant_id' => $plantId,
|
||||||
|
'coil_packing_number' => $coilPackNo,
|
||||||
|
'process_order' => null,
|
||||||
|
'Sno_quantity' => 0,
|
||||||
|
'created_by' => $operatorName,
|
||||||
|
'scanned_by' => $operatorName,
|
||||||
|
]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
$existingPallet = CoilPacking::where('plant_id', $plantId)
|
||||||
|
->where('coil_packing_number', $coilPackNo)
|
||||||
|
->first();
|
||||||
|
|
||||||
|
$count = CoilPacking::where('plant_id', $plantId)
|
||||||
|
->where('coil_packing_number', $coilPackNo)
|
||||||
|
->count('coil_packing_number');
|
||||||
|
|
||||||
|
$createdAt = $existingPallet ? $existingPallet->created_at : $clickedAt ?? now();
|
||||||
|
|
||||||
|
$createdBy = $existingPallet ? $existingPallet->created_by : $clickedBy ?? $operatorName;
|
||||||
|
|
||||||
|
$record = CoilPacking::create([
|
||||||
|
'plant_id' => $plantId,
|
||||||
|
'item_id' => $itemId,
|
||||||
|
'coil_packing_number' => $coilPackNo,
|
||||||
|
'process_order' => $coilNo,
|
||||||
|
'created_by' => $createdBy,
|
||||||
|
'scanned_by' => $operatorName,
|
||||||
|
'created_at' => $createdAt,
|
||||||
|
'scanned_at' => now(),
|
||||||
|
'updated_by' => $operatorName,
|
||||||
|
]);
|
||||||
|
|
||||||
|
if ($record)
|
||||||
|
{
|
||||||
|
|
||||||
|
$this->snoCount = CoilPacking::where('plant_id', $plantId)
|
||||||
|
->where('coil_packing_number', $coilPackNo)
|
||||||
|
->count();
|
||||||
|
|
||||||
|
$this->dispatch('loadData', $coilPackNo, $plantId);
|
||||||
|
$this->form->fill([
|
||||||
|
'plant_id' => $plantId,
|
||||||
|
'item_id' => $itemId,
|
||||||
|
'coil_packing_number' => $coilPackNo,
|
||||||
|
'process_order' => null,
|
||||||
|
'Sno_quantity' => $this->snoCount,
|
||||||
|
'created_by' => $operatorName,
|
||||||
|
'scanned_by' => $operatorName,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Notification::make()
|
||||||
|
->title("Failed to insert scanned serial number '$coilNo' into coil packing table!")
|
||||||
|
->danger()
|
||||||
|
->duration(5000)
|
||||||
|
->send();
|
||||||
|
|
||||||
|
$this->dispatch('loadData', $coilPackNo, $plantId);
|
||||||
|
$this->form->fill([
|
||||||
|
'plant_id' => $plantId,
|
||||||
|
'item_id' => $itemId,
|
||||||
|
'coil_packing_number' => $coilPackNo,
|
||||||
|
'process_order' => null,
|
||||||
|
'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 '{$coilNo}' into pallet table!\nScan the new process order to proceed...")
|
||||||
|
->danger()
|
||||||
|
->duration(5000)
|
||||||
|
->send();
|
||||||
|
|
||||||
|
$this->dispatch('loadData', $coilPackNo, $plantId);
|
||||||
|
$this->form->fill([
|
||||||
|
'plant_id' => $plantId,
|
||||||
|
'coil_packing_number' => $coilPackNo,
|
||||||
|
'process_order' => null,
|
||||||
|
'Sno_quantity' => $count,
|
||||||
|
'created_by' => $operatorName,
|
||||||
|
'scanned_by' => $operatorName,
|
||||||
|
]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->dispatch('loadData', $coilPackNo, $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()['coil_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 = CoilPacking::where('coil_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,
|
||||||
|
'coil_packing_number' => $palletNumber,
|
||||||
|
'pending_pallet_list' => $pendingPallet,
|
||||||
|
'Sno_quantity' => 0,
|
||||||
|
'created_by' => $operatorName,
|
||||||
|
'scanned_by' => $operatorName,
|
||||||
|
]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$allCompleted = CoilPacking::where('plant_id', $plantId)
|
||||||
|
->where('coil_packing_number', $palletNumber)
|
||||||
|
->where('coil_packing_status', '=','Completed')
|
||||||
|
->first();
|
||||||
|
|
||||||
|
if ($allCompleted)
|
||||||
|
{
|
||||||
|
Notification::make()
|
||||||
|
->title("Coil Packing pallet number '$palletNumber' already completed the master packing!<br>Generate the new Coil 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,
|
||||||
|
'coil_packing_number' => null,
|
||||||
|
'pending_pallet_list' => null,//$pendingPallet
|
||||||
|
'Sno_quantity' => 0,
|
||||||
|
'created_by' => $operatorName,
|
||||||
|
'scanned_by' => $operatorName,
|
||||||
|
]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$isCompleted)
|
||||||
|
{
|
||||||
|
$updated = CoilPacking::where('coil_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,
|
||||||
|
'coil_packing_number' => null,//$palletNumber
|
||||||
|
'pending_pallet_list' => null,//$pendingPallet
|
||||||
|
'Sno_quantity' => 0,//$count,
|
||||||
|
'created_by' => $operatorName,
|
||||||
|
'scanned_by' => $operatorName,
|
||||||
|
]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$updated = CoilPacking::where('coil_packing_number', $palletNumber)
|
||||||
|
->where('plant_id', $plantId)
|
||||||
|
->update([
|
||||||
|
'coil_packing_status' => 'Completed',
|
||||||
|
'updated_at' => now(),
|
||||||
|
'updated_by' => $operatorName,
|
||||||
|
]);
|
||||||
|
|
||||||
|
if ($updated > 0)
|
||||||
|
{
|
||||||
|
Notification::make()
|
||||||
|
->title("Pallet number '$palletNumber' completed the coil packing successfully!")
|
||||||
|
->success()
|
||||||
|
->duration(800)
|
||||||
|
->send();
|
||||||
|
|
||||||
|
$this->dispatch('loadData', '', $plantId);
|
||||||
|
$this->form->fill([
|
||||||
|
'process_order' => null,
|
||||||
|
'plant_id' => $plantId,
|
||||||
|
'coil_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()['coil_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;
|
||||||
|
|
||||||
|
//$this->dispatch('loadData', $palletNumber, $plantId);
|
||||||
|
$this->form->fill([
|
||||||
|
'process_order' => null,
|
||||||
|
'plant_id' => $plantId,
|
||||||
|
'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,
|
||||||
|
'coil_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,
|
||||||
|
'pallet_number' => $palletNumber,
|
||||||
|
'pending_pallet_list' => $pendingPallet,
|
||||||
|
'Sno_quantity' => 0,
|
||||||
|
'created_by' => $operatorName,
|
||||||
|
'scanned_by' => $operatorName,
|
||||||
|
]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$count = CoilPacking::where('plant_id', $plantId)
|
||||||
|
->where('coil_packing_number', $palletNumber)
|
||||||
|
->count('coil_packing_number');
|
||||||
|
|
||||||
|
|
||||||
|
$palletNotCompleted = CoilPacking::where('plant_id', $plantId)
|
||||||
|
->where('coil_packing_number', $palletNumber)
|
||||||
|
->where('coil_packing_status', '=','')
|
||||||
|
->orWhere('coil_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,
|
||||||
|
'coil_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,
|
||||||
|
'coil_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()['coil_packing_number']) ?? 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('Coil Pallet number is required to remove.')
|
||||||
|
->danger()
|
||||||
|
->duration(5000)
|
||||||
|
->send();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$pattern = '/^([^|]+)\|([^|]+)$/';
|
||||||
|
|
||||||
|
if (!preg_match($pattern, $processOrder, $matches))
|
||||||
|
{
|
||||||
|
Notification::make()
|
||||||
|
->title("Scan Valid Qr code ")
|
||||||
|
->body("Expected Format : (MaterialCode|Coil Number)")
|
||||||
|
->danger()
|
||||||
|
->duration(5000)
|
||||||
|
->send();
|
||||||
|
|
||||||
|
$this->form->fill([
|
||||||
|
'plant_id' => $plantId,
|
||||||
|
'removeSno_number' => null,
|
||||||
|
'Sno_quantity' => 0,
|
||||||
|
'created_by' => $operatorName,
|
||||||
|
'scanned_by' => $operatorName,
|
||||||
|
]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$materialCode = $matches[1];
|
||||||
|
$coilNo = $matches[2];
|
||||||
|
|
||||||
|
$count = CoilPacking::where('plant_id', $plantId)
|
||||||
|
->where('coil_packing_number', $palletNumber)
|
||||||
|
->count('coil_packing_number');
|
||||||
|
|
||||||
|
|
||||||
|
if (!$coilNo)
|
||||||
|
{
|
||||||
|
Notification::make()
|
||||||
|
->title('Coil number is required to remove.')
|
||||||
|
->danger()
|
||||||
|
->duration(5000)
|
||||||
|
->send();
|
||||||
|
|
||||||
|
$this->dispatch('loadData', $palletNumber, $plantId);
|
||||||
|
$this->form->fill([
|
||||||
|
'plant_id' => $plantId,
|
||||||
|
'removeSno_number' => null,
|
||||||
|
'coil_packing_number' => $palletNumber,
|
||||||
|
'pending_pallet_list' => $pendingPallet,
|
||||||
|
'Sno_quantity' => $count,
|
||||||
|
'created_by' => $operatorName,
|
||||||
|
'scanned_by' => $operatorName,
|
||||||
|
]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$item = Item::where('plant_id', $plantId)->where('code', $materialCode)->first();
|
||||||
|
|
||||||
|
if(!$item){
|
||||||
|
Notification::make()
|
||||||
|
->title('Unknown Item Code')
|
||||||
|
->body("Item code {$materialCode} was not found in the Item Master.")
|
||||||
|
->danger()
|
||||||
|
->send();
|
||||||
|
|
||||||
|
$this->form->fill([
|
||||||
|
'plant_id' => $plantId,
|
||||||
|
'coil_packing_number' => $palletNumber,
|
||||||
|
'removeSno_number' => null,
|
||||||
|
'Sno_quantity' => $count,
|
||||||
|
'created_by' => $operatorName,
|
||||||
|
'scanned_by' => $operatorName,
|
||||||
|
]);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$itemCodeInPallet = CoilPacking::where('plant_id', $plantId)->where('item_id', $item->id)->where('coil_packing_number', $palletNumber)->first();
|
||||||
|
|
||||||
|
if(!$itemCodeInPallet){
|
||||||
|
Notification::make()
|
||||||
|
->title('Unknown Item Code')
|
||||||
|
->body("Item code {$materialCode} was not found in the pallet number '$palletNumber'.")
|
||||||
|
->danger()
|
||||||
|
->send();
|
||||||
|
|
||||||
|
$this->form->fill([
|
||||||
|
'plant_id' => $plantId,
|
||||||
|
'coil_packing_number' => $palletNumber,
|
||||||
|
'removeSno_number' => null,
|
||||||
|
'Sno_quantity' => $count,
|
||||||
|
'created_by' => $operatorName,
|
||||||
|
'scanned_by' => $operatorName,
|
||||||
|
]);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$itemCodeInPalletSerial = CoilPacking::where('plant_id', $plantId)->where('item_id', $item->id)->where('coil_packing_number', $palletNumber)->where('process_order', $coilNo)->first();
|
||||||
|
|
||||||
|
if(!$itemCodeInPalletSerial){
|
||||||
|
Notification::make()
|
||||||
|
->title('Mismatch Item Code')
|
||||||
|
->body("Item code {$materialCode} mismatch with serial number was not found in the pallet number '$palletNumber'.")
|
||||||
|
->danger()
|
||||||
|
->send();
|
||||||
|
|
||||||
|
$this->form->fill([
|
||||||
|
'plant_id' => $plantId,
|
||||||
|
'coil_packing_number' => $palletNumber,
|
||||||
|
'removeSno_number' => null,
|
||||||
|
'Sno_quantity' => $count,
|
||||||
|
'created_by' => $operatorName,
|
||||||
|
'scanned_by' => $operatorName,
|
||||||
|
]);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$processOrderexist = CoilPacking::where('plant_id', $plantId)
|
||||||
|
->where('process_order', $coilNo)
|
||||||
|
->first();
|
||||||
|
if (!$processOrderexist)
|
||||||
|
{
|
||||||
|
Notification::make()
|
||||||
|
->title('Coil Number not exists in pallet table.')
|
||||||
|
->danger()
|
||||||
|
->duration(5000)
|
||||||
|
->send();
|
||||||
|
|
||||||
|
$this->dispatch('loadData', $palletNumber, $plantId);
|
||||||
|
$this->form->fill([
|
||||||
|
'plant_id' => $plantId,
|
||||||
|
'removeSno_number' => null,
|
||||||
|
'coil_packing_number' => $palletNumber,
|
||||||
|
'pending_pallet_list' => $pendingPallet,
|
||||||
|
'Sno_quantity' => $count,
|
||||||
|
'created_by' => $operatorName,
|
||||||
|
'scanned_by' => $operatorName,
|
||||||
|
]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$palletExist = CoilPacking::where('plant_id', $plantId)
|
||||||
|
->where('process_order', $coilNo)
|
||||||
|
->where('coil_packing_number', '!=', '')
|
||||||
|
->where('coil_packing_number', '!=', null)
|
||||||
|
->first();
|
||||||
|
|
||||||
|
if ($palletExist && $palletExist->coil_packing_number != $palletNumber)
|
||||||
|
{
|
||||||
|
Notification::make()
|
||||||
|
->title("Scanned coil number exist in pallet number '$palletExist->coil_packing_number'.<br>Scan the valid exist coil number to remove!")
|
||||||
|
->danger()
|
||||||
|
->duration(5000)
|
||||||
|
->send();
|
||||||
|
|
||||||
|
$this->dispatch('loadData', $palletNumber, $plantId);
|
||||||
|
$this->form->fill([
|
||||||
|
'plant_id' => $plantId,
|
||||||
|
'removeSno_number' => null,
|
||||||
|
'coil_packing_number' => $palletNumber,
|
||||||
|
'pending_pallet_list' => $pendingPallet,
|
||||||
|
'Sno_quantity' => $count,
|
||||||
|
'created_by' => $operatorName,
|
||||||
|
'scanned_by' => $operatorName,
|
||||||
|
]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$deleted = CoilPacking::where('plant_id', $plantId)
|
||||||
|
->where('coil_packing_number', $palletNumber)
|
||||||
|
->where('process_order', $coilNo)
|
||||||
|
->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 = CoilPacking::where('plant_id', $plantId)
|
||||||
|
->where('coil_packing_number', $palletNumber)
|
||||||
|
->count();
|
||||||
|
|
||||||
|
$this->form->fill([
|
||||||
|
'plant_id' => $plantId,
|
||||||
|
'coil_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([
|
||||||
|
'plant_id' => $plantId,
|
||||||
|
'removeSno_number' => null,
|
||||||
|
'coil_packing_number' => $palletNumber,
|
||||||
|
'pending_pallet_list' => $pendingPallet,
|
||||||
|
'Sno_quantity' => $count,
|
||||||
|
'created_by' => $operatorName,
|
||||||
|
'scanned_by' => $operatorName,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function redirectToCoilQrPdf($palletNo)
|
||||||
|
{
|
||||||
|
$this->palletNo = $this->form->getState()['coil_packing_number'];
|
||||||
|
|
||||||
|
//return redirect()->route('download-qr-pdf', ['palletNo' => $this->palletNo]);
|
||||||
|
$url = route('download-coil-qr-pdf', ['palletNo' => $this->palletNo]);
|
||||||
|
$this->js(<<<JS
|
||||||
|
window.dispatchEvent(new CustomEvent('open-pdf', {
|
||||||
|
detail: {
|
||||||
|
url: "{$url}"
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
JS);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getFormActions(): array
|
||||||
|
{
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Resources\CoilPackingResource\Pages;
|
||||||
|
|
||||||
|
use App\Filament\Resources\CoilPackingResource;
|
||||||
|
use Filament\Actions;
|
||||||
|
use Filament\Resources\Pages\EditRecord;
|
||||||
|
|
||||||
|
class EditCoilPacking extends EditRecord
|
||||||
|
{
|
||||||
|
protected static string $resource = CoilPackingResource::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\CoilPackingResource\Pages;
|
||||||
|
|
||||||
|
use App\Filament\Resources\CoilPackingResource;
|
||||||
|
use Filament\Actions;
|
||||||
|
use Filament\Resources\Pages\ListRecords;
|
||||||
|
|
||||||
|
class ListCoilPackings extends ListRecords
|
||||||
|
{
|
||||||
|
protected static string $resource = CoilPackingResource::class;
|
||||||
|
|
||||||
|
protected function getHeaderActions(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
Actions\CreateAction::make(),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Resources\CoilPackingResource\Pages;
|
||||||
|
|
||||||
|
use App\Filament\Resources\CoilPackingResource;
|
||||||
|
use Filament\Actions;
|
||||||
|
use Filament\Resources\Pages\ViewRecord;
|
||||||
|
|
||||||
|
class ViewCoilPacking extends ViewRecord
|
||||||
|
{
|
||||||
|
protected static string $resource = CoilPackingResource::class;
|
||||||
|
|
||||||
|
protected function getHeaderActions(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
Actions\EditAction::make(),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user