Added pallet validation resource pages
This commit is contained in:
305
app/Filament/Resources/PalletValidationResource.php
Normal file
305
app/Filament/Resources/PalletValidationResource.php
Normal file
@@ -0,0 +1,305 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Resources;
|
||||||
|
|
||||||
|
use App\Filament\Exports\PalletValidationExporter;
|
||||||
|
use App\Filament\Imports\PalletValidationImporter;
|
||||||
|
use App\Filament\Resources\PalletValidationResource\Pages;
|
||||||
|
use App\Filament\Resources\PalletValidationResource\RelationManagers;
|
||||||
|
use App\Models\PalletValidation;
|
||||||
|
use Filament\Facades\Filament;
|
||||||
|
use Filament\Forms;
|
||||||
|
use Filament\Forms\Components\Section;
|
||||||
|
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\Actions;
|
||||||
|
use Filament\Notifications\Notification;
|
||||||
|
use Filament\Tables\Actions\ExportAction;
|
||||||
|
use Filament\Tables\Actions\ImportAction;
|
||||||
|
use Log;
|
||||||
|
use Filament\Tables\Actions\Action;
|
||||||
|
|
||||||
|
|
||||||
|
class PalletValidationResource extends Resource
|
||||||
|
{
|
||||||
|
protected static ?string $model = PalletValidation::class;
|
||||||
|
|
||||||
|
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
|
||||||
|
protected static ?string $navigationGroup = 'Export Dispatch';
|
||||||
|
|
||||||
|
|
||||||
|
public static function form(Form $form): Form
|
||||||
|
{
|
||||||
|
|
||||||
|
return $form
|
||||||
|
->schema([
|
||||||
|
Section::make('')
|
||||||
|
->schema([
|
||||||
|
Forms\Components\Select::make('plant_id')
|
||||||
|
->label('Plant')
|
||||||
|
->relationship('plant', 'name')
|
||||||
|
->required()
|
||||||
|
->reactive()
|
||||||
|
->afterStateUpdated(function ($state, callable $set) {
|
||||||
|
$set('pallet_number', null);
|
||||||
|
$set('serial_number', null);
|
||||||
|
$set('removeSno_number', null);
|
||||||
|
$set('Sno_quantity', 0);
|
||||||
|
$set('pending_pallet_list', null);
|
||||||
|
}),
|
||||||
|
Forms\Components\TextInput::make('pallet_number')
|
||||||
|
->label('Scan Pallet No')
|
||||||
|
->reactive()
|
||||||
|
->required()
|
||||||
|
->readonly() //fn ($get) => (bool)$get('pallet_number_locked') || $get('serial_number') || $get('removeSno_number')
|
||||||
|
->extraAttributes([
|
||||||
|
'x-data' => '{ value: "" }',
|
||||||
|
'x-model' => 'value',
|
||||||
|
'x-on:keydown.enter.prevent' => '$wire.processPalletNo()',
|
||||||
|
])
|
||||||
|
->suffixAction(fn ($get,$set) =>
|
||||||
|
Forms\Components\Actions\Action::make('addPallet')
|
||||||
|
->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');
|
||||||
|
|
||||||
|
$user = Filament::auth()->user();
|
||||||
|
|
||||||
|
$operatorName = $user->name;
|
||||||
|
|
||||||
|
$clickedTime = now();
|
||||||
|
|
||||||
|
$created = $operatorName;
|
||||||
|
|
||||||
|
session(['pallet_clicked_time' => $clickedTime->toDateTimeString()]);
|
||||||
|
|
||||||
|
session(['pallet_created_by' => $created]);
|
||||||
|
|
||||||
|
$year = now()->format('y');
|
||||||
|
$month = now()->format('m');
|
||||||
|
$prefix = "EP-{$year}{$month}";
|
||||||
|
$lastPallet = PalletValidation::where('pallet_number', 'like', "{$prefix}%")
|
||||||
|
->where('plant_id', $plantId)
|
||||||
|
->orderByDesc('pallet_number')
|
||||||
|
->first();
|
||||||
|
$newNumber = $lastPallet
|
||||||
|
? str_pad(intval(substr($lastPallet->pallet_number, -3)) + 1, 3, '0', STR_PAD_LEFT)
|
||||||
|
: '001';
|
||||||
|
$newPalletNumber = "{$prefix}{$newNumber}";
|
||||||
|
|
||||||
|
$set('pallet_number', $newPalletNumber);
|
||||||
|
$set('pallet_number_locked', true);
|
||||||
|
$set('plant_id', $plantId);
|
||||||
|
|
||||||
|
$livewire->redirectToQrPdf($newPalletNumber);
|
||||||
|
})
|
||||||
|
),
|
||||||
|
|
||||||
|
Forms\Components\TextInput::make('serial_number')
|
||||||
|
->label('Scan Serial No')
|
||||||
|
->reactive()
|
||||||
|
->readOnly(fn (callable $get) => !$get('pallet_number') || $get('removeSno_number'))
|
||||||
|
->extraAttributes([
|
||||||
|
'x-on:keydown.enter.prevent' => '$wire.processPalletSNo()',
|
||||||
|
]),
|
||||||
|
Forms\Components\TextInput::make('removeSno_number')
|
||||||
|
->label('Remove Serial No')
|
||||||
|
->reactive()
|
||||||
|
->readOnly(fn (callable $get) => !$get('pallet_number') || $get('serial_number'))
|
||||||
|
->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\Hidden::make('created_by')
|
||||||
|
->default(Filament::auth()->user()?->name),
|
||||||
|
Forms\Components\Hidden::make('scanned_by')
|
||||||
|
->default(Filament::auth()->user()?->name),
|
||||||
|
Forms\Components\Hidden::make('pallet_number_locked')
|
||||||
|
->default(false),
|
||||||
|
Forms\Components\Select::make('pending_pallet_list')
|
||||||
|
->label('Pending Pallet List')
|
||||||
|
->reactive()
|
||||||
|
->afterStateUpdated(function ($state, callable $set) {
|
||||||
|
$set('pallet_number', $state);
|
||||||
|
$set('pallet_number_locked', false);
|
||||||
|
})
|
||||||
|
->options(function ($get) {
|
||||||
|
|
||||||
|
$plantId = $get('plant_id');
|
||||||
|
|
||||||
|
if (!$plantId) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
return PalletValidation::query()
|
||||||
|
->where('plant_id', $plantId)
|
||||||
|
->where(function($query) {
|
||||||
|
$query->whereNull('pallet_status')
|
||||||
|
->orWhere('pallet_status', '');
|
||||||
|
})
|
||||||
|
->whereNotNull('pallet_number')
|
||||||
|
->orderBy('pallet_number', 'asc')
|
||||||
|
->pluck('pallet_number')
|
||||||
|
->unique()
|
||||||
|
->mapWithKeys(fn($number) => [$number => $number])
|
||||||
|
->toArray();
|
||||||
|
}),
|
||||||
|
|
||||||
|
Forms\Components\View::make('forms.components.save-pallet-button')
|
||||||
|
])
|
||||||
|
->columns(5),
|
||||||
|
Forms\Components\TextInput::make('id')
|
||||||
|
->hidden()
|
||||||
|
->readOnly(),
|
||||||
|
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function table(Table $table): Table
|
||||||
|
{
|
||||||
|
return $table
|
||||||
|
|
||||||
|
->columns([
|
||||||
|
// Tables\Columns\TextColumn::make('id')
|
||||||
|
// ->label('ID')
|
||||||
|
// ->numeric()
|
||||||
|
// ->sortable(),
|
||||||
|
|
||||||
|
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')
|
||||||
|
->searchable()
|
||||||
|
->alignCenter()
|
||||||
|
->sortable(),
|
||||||
|
Tables\Columns\TextColumn::make('pallet_number')
|
||||||
|
->label('Pallet Number')
|
||||||
|
->searchable()
|
||||||
|
->alignCenter()
|
||||||
|
->sortable(),
|
||||||
|
Tables\Columns\TextColumn::make('serial_number')
|
||||||
|
->label('Serial Number')
|
||||||
|
->searchable()
|
||||||
|
->alignCenter()
|
||||||
|
->sortable(),
|
||||||
|
Tables\Columns\TextColumn::make('pallet_status')
|
||||||
|
->label('Pallet Status')
|
||||||
|
->searchable()
|
||||||
|
->alignCenter()
|
||||||
|
->sortable(),
|
||||||
|
Tables\Columns\TextColumn::make('locator_number')
|
||||||
|
->label('Locator Number')
|
||||||
|
->searchable()
|
||||||
|
->alignCenter()
|
||||||
|
->sortable(),
|
||||||
|
Tables\Columns\TextColumn::make('locator_quantity')
|
||||||
|
->label('Locator Quantity')
|
||||||
|
->alignCenter()
|
||||||
|
->sortable(),
|
||||||
|
Tables\Columns\TextColumn::make('created_by')
|
||||||
|
->label('Created By')
|
||||||
|
->alignCenter()
|
||||||
|
->sortable(),
|
||||||
|
Tables\Columns\TextColumn::make('scanned_by')
|
||||||
|
->label('Scanned By')
|
||||||
|
->alignCenter()
|
||||||
|
->sortable(),
|
||||||
|
Tables\Columns\TextColumn::make('updated_by')
|
||||||
|
->label('Updated By')
|
||||||
|
->alignCenter()
|
||||||
|
->sortable(),
|
||||||
|
Tables\Columns\TextColumn::make('created_at')
|
||||||
|
->dateTime()
|
||||||
|
->alignCenter()
|
||||||
|
->sortable(),
|
||||||
|
Tables\Columns\TextColumn::make('updated_at')
|
||||||
|
->dateTime()
|
||||||
|
->alignCenter()
|
||||||
|
->sortable()
|
||||||
|
->toggleable(isToggledHiddenByDefault: true),
|
||||||
|
Tables\Columns\TextColumn::make('scanned_at')
|
||||||
|
->dateTime()
|
||||||
|
->alignCenter()
|
||||||
|
->sortable()
|
||||||
|
->toggleable(isToggledHiddenByDefault: true),
|
||||||
|
Tables\Columns\TextColumn::make('deleted_at')
|
||||||
|
->dateTime()
|
||||||
|
->alignCenter()
|
||||||
|
->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()
|
||||||
|
->importer(PalletValidationImporter::class)
|
||||||
|
->visible(function() {
|
||||||
|
return Filament::auth()->user()->can('view import pallet validation');
|
||||||
|
}),
|
||||||
|
ExportAction::make()
|
||||||
|
->exporter(PalletValidationExporter::class)
|
||||||
|
->visible(function() {
|
||||||
|
return Filament::auth()->user()->can('view export pallet validation');
|
||||||
|
}),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getRelations(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
//
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getPages(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'index' => Pages\ListPalletValidations::route('/'),
|
||||||
|
'create' => Pages\CreatePalletValidation::route('/create'),
|
||||||
|
'view' => Pages\ViewPalletValidation::route('/{record}'),
|
||||||
|
'edit' => Pages\EditPalletValidation::route('/{record}/edit'),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getEloquentQuery(): Builder
|
||||||
|
{
|
||||||
|
return parent::getEloquentQuery()
|
||||||
|
->withoutGlobalScopes([
|
||||||
|
SoftDeletingScope::class,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,835 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Resources\PalletValidationResource\Pages;
|
||||||
|
|
||||||
|
use App\Filament\Resources\PalletValidationResource;
|
||||||
|
use App\Models\LocatorInvoiceValidation;
|
||||||
|
use App\Models\PalletValidation;
|
||||||
|
use Filament\Actions;
|
||||||
|
use Filament\Facades\Filament;
|
||||||
|
use Filament\Notifications\Notification;
|
||||||
|
use Filament\Resources\Pages\CreateRecord;
|
||||||
|
use Illuminate\View\View;
|
||||||
|
|
||||||
|
class CreatePalletValidation extends CreateRecord
|
||||||
|
{
|
||||||
|
public $plantId;
|
||||||
|
public $pallet_number;
|
||||||
|
public $palletNo;
|
||||||
|
public $pendingPallet;
|
||||||
|
public $snoCount = 0;
|
||||||
|
|
||||||
|
public $pallet_number_locked = false;
|
||||||
|
|
||||||
|
public $serial_number;
|
||||||
|
protected static string $view = 'filament.resources.pallet-validation-resource.pages.create-pallet-validation';
|
||||||
|
protected static string $resource = PalletValidationResource::class;
|
||||||
|
|
||||||
|
|
||||||
|
protected $listeners = [
|
||||||
|
'updateSnoQuantity' => 'handleUpdateSnoQuantity',
|
||||||
|
];
|
||||||
|
|
||||||
|
public ?array $data = null;
|
||||||
|
|
||||||
|
|
||||||
|
public function processPalletSNo()
|
||||||
|
{
|
||||||
|
$plantId = $this->form->getState()['plant_id'];
|
||||||
|
|
||||||
|
$plantId = trim($plantId) ?? null;
|
||||||
|
|
||||||
|
$pendingPallet = $this->form->getState()['pending_pallet_list'];
|
||||||
|
|
||||||
|
$palletNumber = trim($this->form->getState()['pallet_number'])?? null;
|
||||||
|
|
||||||
|
$palletNumber = trim($palletNumber) ?? null;
|
||||||
|
|
||||||
|
$serialNumber = trim($this->form->getState()['serial_number'])?? null;
|
||||||
|
|
||||||
|
$serialNumber = trim($serialNumber) ?? null;
|
||||||
|
|
||||||
|
$user = Filament::auth()->user();
|
||||||
|
|
||||||
|
$operatorName = $user->name;
|
||||||
|
|
||||||
|
$clickedAt = session('pallet_clicked_time');
|
||||||
|
|
||||||
|
$clickedBy = session('pallet_created_by');
|
||||||
|
|
||||||
|
|
||||||
|
if(!$palletNumber)
|
||||||
|
{
|
||||||
|
Notification::make()
|
||||||
|
->title('Pallet number cannot be empty')
|
||||||
|
->danger()
|
||||||
|
->send();
|
||||||
|
$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 = PalletValidation::where('plant_id', $plantId)
|
||||||
|
->where('pallet_number', $palletNumber)
|
||||||
|
->count('pallet_number');
|
||||||
|
|
||||||
|
|
||||||
|
if(!$serialNumber)
|
||||||
|
{
|
||||||
|
Notification::make()
|
||||||
|
->title('Serial number cannot be empty')
|
||||||
|
->danger()
|
||||||
|
->send();
|
||||||
|
$this->dispatch('loadData', $palletNumber, $plantId);
|
||||||
|
$this->form->fill([
|
||||||
|
'serial_number' => null,
|
||||||
|
'plant_id' => $plantId,
|
||||||
|
'pallet_number' => $palletNumber,
|
||||||
|
'pending_pallet_list' => $pendingPallet,
|
||||||
|
'Sno_quantity' => $count,
|
||||||
|
'created_by' => $operatorName,
|
||||||
|
'scanned_by' => $operatorName,
|
||||||
|
]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(strlen($serialNumber) < 13)
|
||||||
|
{
|
||||||
|
Notification::make()
|
||||||
|
->title('Serial number should contain minimum 13 digits.')
|
||||||
|
->danger()
|
||||||
|
->send();
|
||||||
|
$this->dispatch('loadData', $palletNumber, $plantId);
|
||||||
|
$this->form->fill([
|
||||||
|
'serial_number' => null,
|
||||||
|
'plant_id' => $plantId,
|
||||||
|
'pallet_number' => $palletNumber,
|
||||||
|
'pending_pallet_list' => $pendingPallet,
|
||||||
|
'Sno_quantity' => $count,
|
||||||
|
'created_by' => $operatorName,
|
||||||
|
'scanned_by' => $operatorName,
|
||||||
|
]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!ctype_alnum($serialNumber))
|
||||||
|
{
|
||||||
|
Notification::make()
|
||||||
|
->title('Serial number must contain alpha-numeric values only.')
|
||||||
|
->danger()
|
||||||
|
->send();
|
||||||
|
$this->dispatch('loadData', $palletNumber, $plantId);
|
||||||
|
$this->form->fill([
|
||||||
|
'serial_number' => null,
|
||||||
|
'plant_id' => $plantId,
|
||||||
|
'pallet_number' => $palletNumber,
|
||||||
|
'pending_pallet_list' => $pendingPallet,
|
||||||
|
'Sno_quantity' => $count,
|
||||||
|
'created_by' => $operatorName,
|
||||||
|
'scanned_by' => $operatorName,
|
||||||
|
]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$existInvoiceSno = LocatorInvoiceValidation::where('serial_number', $serialNumber)
|
||||||
|
->where('plant_id', $plantId)
|
||||||
|
->where('scanned_status', '=', 'Scanned')
|
||||||
|
->first();
|
||||||
|
|
||||||
|
$invoiceNumber = $existInvoiceSno?->invoice_number;
|
||||||
|
if($existInvoiceSno)
|
||||||
|
{
|
||||||
|
Notification::make()
|
||||||
|
->title("Scanned serial number '{$serialNumber}' already completed the scanning process and exist in invoice number : {$invoiceNumber}.<br>Scan the new serial number to add!")
|
||||||
|
->danger()
|
||||||
|
->send();
|
||||||
|
$this->dispatch('loadData', $palletNumber, $plantId);
|
||||||
|
$this->form->fill([
|
||||||
|
'serial_number' => null,
|
||||||
|
'plant_id' => $plantId,
|
||||||
|
'pallet_number' => $palletNumber,
|
||||||
|
'pending_pallet_list' => $pendingPallet,
|
||||||
|
'Sno_quantity' => $count,
|
||||||
|
'created_by' => $operatorName,
|
||||||
|
'scanned_by' => $operatorName,
|
||||||
|
]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$existingRecord = PalletValidation::where('serial_number', $serialNumber)
|
||||||
|
->where('plant_id', $plantId)
|
||||||
|
->first();
|
||||||
|
|
||||||
|
if ($existingRecord)
|
||||||
|
{
|
||||||
|
|
||||||
|
// if ($existingRecord && ($existingRecord->pallet_number == null || $existingRecord->pallet_number == '')) {
|
||||||
|
// Notification::make()
|
||||||
|
// ->title("Scanned serial number '{$serialNumber}' exists in pallet table .<br>scan the valid serial number to proceed...")
|
||||||
|
// ->danger()
|
||||||
|
// ->send();
|
||||||
|
// $this->form->fill([
|
||||||
|
// 'serial_number' => null,
|
||||||
|
// 'plant_id' => $this->plantId,
|
||||||
|
// 'pallet_number' => $this->pallet_number,
|
||||||
|
// 'pending_pallet_list' => $this->pendingPallet,
|
||||||
|
// 'created_by' => $operatorName,
|
||||||
|
// 'scanned_by' => $operatorName,
|
||||||
|
// ]);
|
||||||
|
// return;
|
||||||
|
|
||||||
|
// }
|
||||||
|
|
||||||
|
if ($existingRecord && $existingRecord->pallet_number == $palletNumber)
|
||||||
|
{
|
||||||
|
Notification::make()
|
||||||
|
->title("Scanned serial number '{$serialNumber}' is already exists in pallet number '{$palletNumber}'.<br>Scan the new serial number to proceed...")
|
||||||
|
->danger()
|
||||||
|
->send();
|
||||||
|
}
|
||||||
|
else if ($existingRecord && $existingRecord->pallet_number && $existingRecord->pallet_number != $palletNumber)
|
||||||
|
{
|
||||||
|
Notification::make()
|
||||||
|
->title("Scanned serial number '{$serialNumber}' already exists in pallet number '{$existingRecord->pallet_number}'.<br>Scan the new serial number to proceed...")
|
||||||
|
->danger()
|
||||||
|
->send();
|
||||||
|
}
|
||||||
|
else if ($existingRecord && $existingRecord->locator_number)
|
||||||
|
{
|
||||||
|
Notification::make()
|
||||||
|
->title("Scanned serial number '{$serialNumber}' is already exists in locator number '{$existingRecord->locator_number}'.<br>Scan the new serial number to proceed...")
|
||||||
|
->danger()
|
||||||
|
->send();
|
||||||
|
}
|
||||||
|
$this->dispatch('loadData', $palletNumber, $plantId);
|
||||||
|
$this->form->fill([
|
||||||
|
'serial_number' => null,
|
||||||
|
'plant_id' => $plantId,
|
||||||
|
'pallet_number' => $palletNumber,
|
||||||
|
'pending_pallet_list' => $pendingPallet,
|
||||||
|
'Sno_quantity' => $count,
|
||||||
|
'created_by' => $operatorName,
|
||||||
|
'scanned_by' => $operatorName,
|
||||||
|
]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
|
||||||
|
$existingPallet = PalletValidation::where('plant_id', $plantId)
|
||||||
|
->where('pallet_number', $palletNumber)
|
||||||
|
->first();
|
||||||
|
|
||||||
|
$createdAt = $existingPallet ? $existingPallet->created_at : $clickedAt ?? now();
|
||||||
|
|
||||||
|
$createdBy = $existingPallet ? $existingPallet->created_by : $clickedBy ?? $operatorName;
|
||||||
|
|
||||||
|
$record = PalletValidation::create([
|
||||||
|
'plant_id' => $plantId,
|
||||||
|
'pallet_number' => $palletNumber,
|
||||||
|
'serial_number' => $serialNumber,
|
||||||
|
'created_by' => $createdBy,
|
||||||
|
'scanned_by' => $operatorName,
|
||||||
|
'created_at' => $createdAt,
|
||||||
|
'scanned_at' => now(),
|
||||||
|
'updated_by' => $operatorName,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$count = PalletValidation::where('plant_id', $plantId)
|
||||||
|
->where('pallet_number', $palletNumber)
|
||||||
|
->count('pallet_number');
|
||||||
|
|
||||||
|
if ($record)
|
||||||
|
{
|
||||||
|
Notification::make()
|
||||||
|
->title("Scanned serial number : '{$serialNumber}' successfully inserted into pallet table!<br>Scan the next new serial number to proceed...")
|
||||||
|
->success()
|
||||||
|
->send();
|
||||||
|
|
||||||
|
$this->snoCount = PalletValidation::where('plant_id', $plantId)
|
||||||
|
->where('pallet_number', $palletNumber)
|
||||||
|
->count();
|
||||||
|
|
||||||
|
$this->form->fill([
|
||||||
|
'plant_id' => $plantId,
|
||||||
|
'pallet_number' => $palletNumber,
|
||||||
|
'serial_number' => null,
|
||||||
|
'pending_pallet_list' => $pendingPallet,
|
||||||
|
'Sno_quantity' => $count,
|
||||||
|
'created_by' => $operatorName,
|
||||||
|
'scanned_by' => $operatorName,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$this->dispatch('loadData', $palletNumber, $plantId);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Notification::make()
|
||||||
|
->title('Pallet validation not inserted.')
|
||||||
|
->danger()
|
||||||
|
->send();
|
||||||
|
$this->dispatch('loadData', $palletNumber, $plantId);
|
||||||
|
$this->form->fill([
|
||||||
|
'plant_id' => $plantId,
|
||||||
|
'pallet_number' => $palletNumber,
|
||||||
|
'serial_number' => null,
|
||||||
|
'pending_pallet_list' => $pendingPallet,
|
||||||
|
'Sno_quantity' => $count,
|
||||||
|
'scanned_by' => $operatorName,
|
||||||
|
]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (\Exception $e)
|
||||||
|
{
|
||||||
|
Notification::make()
|
||||||
|
->title('Error: Pallet validation not inserted.')
|
||||||
|
->body("Something went wrong while inserting serial number : '{$serialNumber}' into pallet table!\nScan the new serial number to proceed...")
|
||||||
|
->danger()
|
||||||
|
->send();
|
||||||
|
$this->dispatch('loadData', $palletNumber, $plantId);
|
||||||
|
$this->form->fill([
|
||||||
|
'plant_id' => $plantId,
|
||||||
|
'pallet_number' => $palletNumber,
|
||||||
|
'serial_number' => null,
|
||||||
|
'pending_pallet_list' => $pendingPallet,
|
||||||
|
'Sno_quantity' => $count,
|
||||||
|
'created_by' => $operatorName,
|
||||||
|
'scanned_by' => $operatorName,
|
||||||
|
]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function handleUpdateSnoQuantity($newValue)
|
||||||
|
{
|
||||||
|
// Update the form field
|
||||||
|
$this->form->fill([
|
||||||
|
'Sno_quantity' => $newValue,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function redirectToQrPdf($palletNo)
|
||||||
|
{
|
||||||
|
$this->palletNo = $this->form->getState()['pallet_number'];
|
||||||
|
|
||||||
|
//return redirect()->route('download-qr-pdf', ['palletNo' => $this->palletNo]);
|
||||||
|
$url = route('download-qr-pdf', ['palletNo' => $this->palletNo]);
|
||||||
|
$this->js(<<<JS
|
||||||
|
window.dispatchEvent(new CustomEvent('open-pdf', {
|
||||||
|
detail: {
|
||||||
|
url: "{$url}"
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
JS);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
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()['pallet_number'])?? null;
|
||||||
|
|
||||||
|
$palletNumber = trim($palletNumber) ?? null;
|
||||||
|
|
||||||
|
$serialNumber = trim($this->form->getState()['serial_number'])?? null;
|
||||||
|
|
||||||
|
$serialNumber = trim($serialNumber) ?? null;
|
||||||
|
|
||||||
|
$user = Filament::auth()->user();
|
||||||
|
|
||||||
|
$operatorName = $user->name;
|
||||||
|
|
||||||
|
$isCompleted = $this->data['is_completed'] ?? false;
|
||||||
|
|
||||||
|
$this->pendingPallet = $this->form->getState()['pending_pallet_list'];
|
||||||
|
|
||||||
|
|
||||||
|
$palletExist = PalletValidation::where('pallet_number', $palletNumber)
|
||||||
|
->where('plant_id', $plantId)
|
||||||
|
->first();
|
||||||
|
|
||||||
|
if(!$palletExist)
|
||||||
|
{
|
||||||
|
Notification::make()
|
||||||
|
->title("Pallet number '$palletNumber' does not have serial numbers to save!<br>Add the valid serial number into pallet number to proceed...")
|
||||||
|
->danger()
|
||||||
|
->send();
|
||||||
|
$this->dispatch('loadData', $palletNumber, $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;
|
||||||
|
}
|
||||||
|
|
||||||
|
$allCompleted = PalletValidation::where('plant_id', $plantId)
|
||||||
|
->where('pallet_number', $palletNumber)
|
||||||
|
->where('pallet_status', '=','Completed')
|
||||||
|
->first();
|
||||||
|
|
||||||
|
if ($allCompleted)
|
||||||
|
{
|
||||||
|
Notification::make()
|
||||||
|
->title("Pallet number '$palletNumber' already completed the master packing!<br>Generate the new pallet number or choose from pending pallet list!")
|
||||||
|
->danger()
|
||||||
|
->send();
|
||||||
|
$this->dispatch('loadData', '', $plantId);
|
||||||
|
$this->form->fill([
|
||||||
|
'serial_number' => null,
|
||||||
|
'plant_id' => $plantId,
|
||||||
|
'pallet_number' => null,
|
||||||
|
'pending_pallet_list' => null,//$pendingPallet
|
||||||
|
'Sno_quantity' => 0,
|
||||||
|
'created_by' => $operatorName,
|
||||||
|
'scanned_by' => $operatorName,
|
||||||
|
]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$count = PalletValidation::where('plant_id', $plantId)
|
||||||
|
->where('pallet_number', $palletNumber)
|
||||||
|
->count('pallet_number');
|
||||||
|
|
||||||
|
if (!$isCompleted)
|
||||||
|
{
|
||||||
|
$updated = PalletValidation::where('pallet_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()->send();
|
||||||
|
$this->dispatch('loadData', '', $plantId);
|
||||||
|
$this->form->fill([
|
||||||
|
'serial_number' => null,
|
||||||
|
'plant_id' => $plantId,
|
||||||
|
'pallet_number' => null,//$palletNumber
|
||||||
|
'pending_pallet_list' => null,//$pendingPallet
|
||||||
|
'Sno_quantity' => 0,//$count,
|
||||||
|
'created_by' => $operatorName,
|
||||||
|
'scanned_by' => $operatorName,
|
||||||
|
]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$updated = PalletValidation::where('pallet_number', $palletNumber)
|
||||||
|
->where('plant_id', $plantId)
|
||||||
|
->update([
|
||||||
|
'pallet_status' => 'Completed',
|
||||||
|
'updated_at' => now(),
|
||||||
|
'updated_by' => $operatorName,
|
||||||
|
]);
|
||||||
|
|
||||||
|
if ($updated > 0)
|
||||||
|
{
|
||||||
|
Notification::make()->title("Pallet number '$palletNumber' completed the master packing successfully!")->success()->send();
|
||||||
|
$this->dispatch('loadData', '', $plantId);
|
||||||
|
$this->form->fill([
|
||||||
|
'serial_number' => null,
|
||||||
|
'plant_id' => $plantId,
|
||||||
|
'pallet_number' => null,//$palletNumber
|
||||||
|
'pending_pallet_list' => null,//$pendingPallet
|
||||||
|
'Sno_quantity' => 0,//$count
|
||||||
|
'created_by' => $operatorName,
|
||||||
|
'scanned_by' => $operatorName,
|
||||||
|
]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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()['pallet_number']) ?? null;
|
||||||
|
|
||||||
|
$palletNumber = trim($palletNumber) ?? null;
|
||||||
|
|
||||||
|
$serialNumber = trim($this->form->getState()['removeSno_number']) ?? null;
|
||||||
|
|
||||||
|
$serialNumber = trim($serialNumber) ?? null;
|
||||||
|
|
||||||
|
$user = Filament::auth()->user();
|
||||||
|
|
||||||
|
$operatorName = $user->name;
|
||||||
|
|
||||||
|
if (!$palletNumber)
|
||||||
|
{
|
||||||
|
Notification::make()
|
||||||
|
->title('Pallet number is required to remove.')
|
||||||
|
->danger()
|
||||||
|
->send();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$count = PalletValidation::where('plant_id', $plantId)
|
||||||
|
->where('pallet_number', $palletNumber)
|
||||||
|
->count('pallet_number');
|
||||||
|
|
||||||
|
if (!$serialNumber)
|
||||||
|
{
|
||||||
|
Notification::make()
|
||||||
|
->title('Serial number is required to remove.')
|
||||||
|
->danger()
|
||||||
|
->send();
|
||||||
|
$this->dispatch('loadData', $palletNumber, $plantId);
|
||||||
|
$this->form->fill([
|
||||||
|
'serial_number' => null,
|
||||||
|
'plant_id' => $plantId,
|
||||||
|
'pallet_number' => $palletNumber,
|
||||||
|
'pending_pallet_list' => $pendingPallet,
|
||||||
|
'Sno_quantity' => $count,
|
||||||
|
'created_by' => $operatorName,
|
||||||
|
'scanned_by' => $operatorName,
|
||||||
|
]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(strlen($serialNumber) < 13)
|
||||||
|
{
|
||||||
|
Notification::make()
|
||||||
|
->title('Serial number should contain minimum 13 digits.')
|
||||||
|
->danger()
|
||||||
|
->send();
|
||||||
|
$this->dispatch('loadData', $palletNumber, $plantId);
|
||||||
|
$this->form->fill([
|
||||||
|
'serial_number' => null,
|
||||||
|
'plant_id' => $plantId,
|
||||||
|
'pallet_number' => $palletNumber,
|
||||||
|
'pending_pallet_list' => $pendingPallet,
|
||||||
|
'Sno_quantity' => $count,
|
||||||
|
'created_by' => $operatorName,
|
||||||
|
'scanned_by' => $operatorName,
|
||||||
|
]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else if (!ctype_alnum($serialNumber))
|
||||||
|
{
|
||||||
|
Notification::make()
|
||||||
|
->title('Serial number must contain alpha-numeric values only.')
|
||||||
|
->danger()
|
||||||
|
->send();
|
||||||
|
$this->dispatch('loadData', $palletNumber, $plantId);
|
||||||
|
$this->form->fill([
|
||||||
|
'serial_number' => null,
|
||||||
|
'plant_id' => $plantId,
|
||||||
|
'pallet_number' => $palletNumber,
|
||||||
|
'pending_pallet_list' => $pendingPallet,
|
||||||
|
'Sno_quantity' => $count,
|
||||||
|
'created_by' => $operatorName,
|
||||||
|
'scanned_by' => $operatorName,
|
||||||
|
]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$invoiceExist = LocatorInvoiceValidation::where('plant_id', $plantId)
|
||||||
|
->where('serial_number', $serialNumber)
|
||||||
|
->where('scanned_status', '=', 'Scanned')
|
||||||
|
->first();
|
||||||
|
|
||||||
|
if($invoiceExist)
|
||||||
|
{
|
||||||
|
Notification::make()
|
||||||
|
->title("Scanned serial number '{$serialNumber}' already completed the scanning process and exist in invoice number : '{$invoiceExist->invoice_number}'.<br>Scan the valid exist serial number to remove!")
|
||||||
|
->danger()
|
||||||
|
->send();
|
||||||
|
$this->dispatch('loadData', $palletNumber, $plantId);
|
||||||
|
$this->form->fill([
|
||||||
|
'serial_number' => null,
|
||||||
|
'plant_id' => $plantId,
|
||||||
|
'pallet_number' => $palletNumber,
|
||||||
|
'pending_pallet_list' => $pendingPallet,
|
||||||
|
'Sno_quantity' => $count,
|
||||||
|
'created_by' => $operatorName,
|
||||||
|
'scanned_by' => $operatorName,
|
||||||
|
]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$serialexist = PalletValidation::where('plant_id', $plantId)
|
||||||
|
->where('serial_number', $serialNumber)
|
||||||
|
->first();
|
||||||
|
if(!$serialexist)
|
||||||
|
{
|
||||||
|
Notification::make()
|
||||||
|
->title('Serial number not exists in pallet table.')
|
||||||
|
->danger()
|
||||||
|
->send();
|
||||||
|
$this->dispatch('loadData', $palletNumber, $plantId);
|
||||||
|
$this->form->fill([
|
||||||
|
'serial_number' => null,
|
||||||
|
'plant_id' => $plantId,
|
||||||
|
'pallet_number' => $palletNumber,
|
||||||
|
'pending_pallet_list' => $pendingPallet,
|
||||||
|
'Sno_quantity' => $count,
|
||||||
|
'created_by' => $operatorName,
|
||||||
|
'scanned_by' => $operatorName,
|
||||||
|
]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$palletExist = PalletValidation::where('plant_id', $plantId)
|
||||||
|
->where('serial_number', $serialNumber)
|
||||||
|
->where('pallet_number', '!=', '')
|
||||||
|
->where('pallet_number', '!=', null)
|
||||||
|
->first();
|
||||||
|
|
||||||
|
if($palletExist && $palletExist->pallet_number != $palletNumber)
|
||||||
|
{
|
||||||
|
Notification::make()
|
||||||
|
->title("Scanned serial number exist in pallet number '$palletExist->pallet_number'.<br>Scan the valid exist serial number to remove!")
|
||||||
|
->danger()
|
||||||
|
->send();
|
||||||
|
$this->dispatch('loadData', $palletNumber, $plantId);
|
||||||
|
$this->form->fill([
|
||||||
|
'serial_number' => null,
|
||||||
|
'plant_id' => $plantId,
|
||||||
|
'pallet_number' => $palletNumber,
|
||||||
|
'pending_pallet_list' => $pendingPallet,
|
||||||
|
'Sno_quantity' => $count,
|
||||||
|
'created_by' => $operatorName,
|
||||||
|
'scanned_by' => $operatorName,
|
||||||
|
]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$locatorExist = PalletValidation::where('plant_id', $plantId)
|
||||||
|
->where('serial_number', $serialNumber)
|
||||||
|
->where('locator_number', '!=', '')
|
||||||
|
->where('locator_number', '!=', null)
|
||||||
|
->first();
|
||||||
|
|
||||||
|
if($locatorExist && $locatorExist->locator_number)
|
||||||
|
{
|
||||||
|
Notification::make()
|
||||||
|
->title("Scanned serial number exist in locator number '$locatorExist->locator_number'.<br>Scan the valid exist serial number to remove!")
|
||||||
|
->danger()
|
||||||
|
->send();
|
||||||
|
$this->dispatch('loadData', $palletNumber, $plantId);
|
||||||
|
$this->form->fill([
|
||||||
|
'serial_number' => null,
|
||||||
|
'plant_id' => $plantId,
|
||||||
|
'pallet_number' => $palletNumber,
|
||||||
|
'pending_pallet_list' => $pendingPallet,
|
||||||
|
'Sno_quantity' => $count,
|
||||||
|
'created_by' => $operatorName,
|
||||||
|
'scanned_by' => $operatorName,
|
||||||
|
]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$deleted = PalletValidation::where('plant_id', $plantId)
|
||||||
|
->where('pallet_number', $palletNumber)
|
||||||
|
->where('serial_number', $serialNumber)
|
||||||
|
->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()
|
||||||
|
->send();
|
||||||
|
|
||||||
|
$this->snoCount = PalletValidation::where('plant_id', $plantId)
|
||||||
|
->where('pallet_number', $palletNumber)
|
||||||
|
->count();
|
||||||
|
|
||||||
|
$this->form->fill([
|
||||||
|
'plant_id' => $plantId,
|
||||||
|
'pallet_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 delete serial number.')
|
||||||
|
->danger()
|
||||||
|
->send();
|
||||||
|
$this->dispatch('loadData', $palletNumber, $plantId);
|
||||||
|
$this->form->fill([
|
||||||
|
'serial_number' => null,
|
||||||
|
'plant_id' => $plantId,
|
||||||
|
'pallet_number' => $palletNumber,
|
||||||
|
'pending_pallet_list' => $pendingPallet,
|
||||||
|
'Sno_quantity' => $count,
|
||||||
|
'created_by' => $operatorName,
|
||||||
|
'scanned_by' => $operatorName,
|
||||||
|
]);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//$this->dispatch('removeSno', $serialNumber, $palletNumber, $plantId);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
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()['pallet_number']) ?? null;
|
||||||
|
|
||||||
|
$palletNumber = trim($palletNumber) ?? null;
|
||||||
|
|
||||||
|
$serialNumber = trim($this->form->getState()['serial_number']) ?? null;
|
||||||
|
|
||||||
|
$serialNumber = trim($serialNumber) ?? null;
|
||||||
|
|
||||||
|
$user = Filament::auth()->user();
|
||||||
|
|
||||||
|
$operatorName = $user->name;
|
||||||
|
|
||||||
|
//$this->dispatch('loadData', $palletNumber, $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,
|
||||||
|
]);
|
||||||
|
|
||||||
|
if (!$palletNumber)
|
||||||
|
{
|
||||||
|
Notification::make()
|
||||||
|
->title('Pallet number is required.')
|
||||||
|
->danger()
|
||||||
|
->send();
|
||||||
|
$this->dispatch('loadData', '', $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;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (strlen($palletNumber) < 10)
|
||||||
|
{
|
||||||
|
Notification::make()
|
||||||
|
->title("Pallet number '$palletNumber' must be at least 10 digits.")
|
||||||
|
->danger()
|
||||||
|
->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 = PalletValidation::where('plant_id', $plantId)
|
||||||
|
->where('pallet_number', $palletNumber)
|
||||||
|
->count('pallet_number');
|
||||||
|
|
||||||
|
|
||||||
|
$palletNotCompleted = PalletValidation::where('plant_id', $plantId)
|
||||||
|
->where('pallet_number', $palletNumber)
|
||||||
|
->where('pallet_status', '=','')
|
||||||
|
->orWhere('pallet_status', '=',null)
|
||||||
|
->first();
|
||||||
|
|
||||||
|
if (!$palletNotCompleted)
|
||||||
|
{
|
||||||
|
Notification::make()
|
||||||
|
->title("Already completed for pallet number $palletNumber")
|
||||||
|
->danger()
|
||||||
|
->send();
|
||||||
|
|
||||||
|
$this->dispatch('loadData', $palletNumber, $plantId);
|
||||||
|
$this->form->fill([
|
||||||
|
'serial_number' => null,
|
||||||
|
'plant_id' => $plantId,
|
||||||
|
'pallet_number' => $palletNumber,
|
||||||
|
'pending_pallet_list' => $pendingPallet,
|
||||||
|
'Sno_quantity' => $count,
|
||||||
|
'created_by' => $operatorName,
|
||||||
|
'scanned_by' => $operatorName,
|
||||||
|
]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->form->fill([
|
||||||
|
'serial_number' => null,
|
||||||
|
'plant_id' => $plantId,
|
||||||
|
'pallet_number' => $palletNumber,
|
||||||
|
'pending_pallet_list' => $pendingPallet,
|
||||||
|
'Sno_quantity' => $count,
|
||||||
|
'created_by' => $operatorName,
|
||||||
|
'scanned_by' => $operatorName,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$this->dispatch('loadData', $palletNumber, $plantId);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getFormActions(): array
|
||||||
|
{
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getHeader(): ?View
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getHeading(): string
|
||||||
|
{
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getSubheading(): ?string
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Resources\PalletValidationResource\Pages;
|
||||||
|
|
||||||
|
use App\Filament\Resources\PalletValidationResource;
|
||||||
|
use Filament\Actions;
|
||||||
|
use Filament\Resources\Pages\EditRecord;
|
||||||
|
|
||||||
|
class EditPalletValidation extends EditRecord
|
||||||
|
{
|
||||||
|
protected static string $resource = PalletValidationResource::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\PalletValidationResource\Pages;
|
||||||
|
|
||||||
|
use App\Filament\Resources\PalletValidationResource;
|
||||||
|
use Filament\Actions;
|
||||||
|
use Filament\Resources\Pages\ListRecords;
|
||||||
|
|
||||||
|
class ListPalletValidations extends ListRecords
|
||||||
|
{
|
||||||
|
protected static string $resource = PalletValidationResource::class;
|
||||||
|
|
||||||
|
protected function getHeaderActions(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
Actions\CreateAction::make(),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Filament\Resources\PalletValidationResource\Pages;
|
||||||
|
|
||||||
|
use App\Filament\Resources\PalletValidationResource;
|
||||||
|
use Filament\Actions;
|
||||||
|
use Filament\Resources\Pages\ViewRecord;
|
||||||
|
|
||||||
|
class ViewPalletValidation extends ViewRecord
|
||||||
|
{
|
||||||
|
protected static string $resource = PalletValidationResource::class;
|
||||||
|
|
||||||
|
protected function getHeaderActions(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
Actions\EditAction::make(),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user