ranjith-dev #382

Merged
jothi merged 4 commits from ranjith-dev into master 2026-02-24 07:48:02 +00:00
5 changed files with 1100 additions and 0 deletions
Showing only changes of commit 9872777875 - Show all commits

View File

@@ -0,0 +1,308 @@
<?php
namespace App\Filament\Resources;
use App\Filament\Resources\WireMasterPackingResource\Pages;
use App\Models\CustomerPoMaster;
use App\Models\Plant;
use App\Models\WireMasterPacking;
use Filament\Facades\Filament;
use Filament\Forms;
use Filament\Forms\Components\Section;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Form;
use Filament\Notifications\Notification;
use Filament\Resources\Resource;
use Filament\Tables;
use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\SoftDeletingScope;
class WireMasterPackingResource extends Resource
{
protected static ?string $model = WireMasterPacking::class;
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
public $importedPoList = [];
public static function form(Form $form): Form
{
return $form
->schema([
Section::make('')
->schema([
Forms\Components\Select::make('plant_id')
->label('Plant')
->reactive()
->relationship('plant', 'name')
->options(function (callable $get) {
$userHas = Filament::auth()->user()->plant_id;
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
})
->required(),
Forms\Components\Select::make('customer_po_master_id')
->label('Customer PO')
->reactive()
->searchable()
->options(function (callable $get) {
$plantId = $get('plant_id');
if (empty($plantId)) {
return [];
}
return CustomerPoMaster::where('plant_id', $plantId)->pluck('customer_po', 'id');
})
->required(),
Forms\Components\TextInput::make('wire_packing_number')
->label('Scan Wire Packing No')
->reactive()
->required()
->readonly()
->extraAttributes([
'x-data' => '{ value: "" }',
'x-model' => 'value',
'x-on:keydown.enter.prevent' => '$wire.processPalletNo()',
])
->suffixAction(fn ($get, $set) => Forms\Components\Actions\Action::make('addWirePackNo')
->label('')
->button()
->icon('heroicon-o-plus')
->color('primary')
->extraAttributes([
'class' => 'p-1 w-7 h-7',
])
->action(function ($get, $set, $livewire) {
$plantId = $get('plant_id');
session(['pallet_clicked_time' => now()->toDateTimeString()]);
session(['pallet_created_by' => Filament::auth()->user()->name]);
$year = now()->format('y');
$month = now()->format('m');
$prefix = "MP-{$year}{$month}";
$lastPallet = WireMasterPacking::where('wire_packing_number', 'like', "{$prefix}%")
->orderByDesc('wire_packing_number')
->first();
// if ($lastPallet) {
// // Extract numeric part after prefix
// $lastNumber = substr($lastPallet->wire_packing_number, strlen($prefix));
// $newNumber = str_pad(((int) $lastNumber) + 1, 3, '0', STR_PAD_LEFT);
// } else {
// // First pallet of the month
// $newNumber = '001';
// }
if ($lastPallet) {
$lastNumber = (int) substr(
$lastPallet->wire_packing_number,
strlen($prefix)
);
$newNumber = $lastNumber + 1;
$newNumber = $newNumber < 1000
? str_pad($newNumber, 3, '0', STR_PAD_LEFT)
: (string) $newNumber;
} else {
$newNumber = '001';
}
$newPalletNumber = "{$prefix}{$newNumber}";
$set('wire_packing_number', $newPalletNumber);
$set('plant_id', $plantId);
// $livewire->redirectToQrPdf($newPalletNumber);
})
),
Forms\Components\TextInput::make('process_order')
->label('Process Order')
->reactive()
->readOnly(fn (callable $get) => ! $get('wire_packing_number'))
->extraAttributes([
'x-on:keydown.enter.prevent' => '$wire.processOrderSNo()',
]),
Forms\Components\TextInput::make('removeSno_number')
->label('Remove Process Order')
->reactive()
->minLength(9)
->readOnly(fn (callable $get) => ! $get('wire_packing_number') || $get('process_order'))
->extraAttributes([
'x-data' => '{ value: "" }',
'x-model' => 'value',
'x-on:keydown.enter.prevent' => '$wire.processRemoveSNo()',
]),
Forms\Components\TextInput::make('Sno_quantity')
->label('SNo. Quantity')
->readOnly()
->default('0'),
Forms\Components\Select::make('pending_pallet_list')
->label('Pending Pallet List')
->reactive()
->afterStateUpdated(function ($state, callable $set) {
$set('wire_packing_number', $state);
$set('pallet_number_locked', false);
})
->options(function ($get) {
$plantId = $get('plant_id');
if (! $plantId) {
return [];
}
return WireMasterPacking::query()
->where('plant_id', $plantId)
->where(function ($query) {
$query->whereNull('wire_packing_status')
->orWhere('wire_packing_status', '');
})
->whereNotNull('wire_packing_number')
->orderBy('wire_packing_number', 'asc')
->pluck('wire_packing_number')
->unique()
->mapWithKeys(fn ($number) => [$number => $number])
->toArray();
}),
// Forms\Components\Checkbox::make('is_po')
// ->label('PO!')
// ->reactive(),
Forms\Components\View::make('forms.components.save-processorder-button'),
Forms\Components\Hidden::make('created_by')
->label('Created By'),
Forms\Components\Hidden::make('updated_by')
->label('Updated By'),
])
->columns(6),
]);
}
public static function table(Table $table): Table
{
return $table
->columns([
Tables\Columns\TextColumn::make('No.')
->label('No.')
->alignCenter()
->getStateUsing(function ($record, $livewire, $column, $rowLoop) {
$paginator = $livewire->getTableRecords();
$perPage = method_exists($paginator, 'perPage') ? $paginator->perPage() : 10;
$currentPage = method_exists($paginator, 'currentPage') ? $paginator->currentPage() : 1;
return ($currentPage - 1) * $perPage + $rowLoop->iteration;
}),
Tables\Columns\TextColumn::make('plant.name')
->label('Plant')
->alignCenter()
->searchable()
->sortable(),
Tables\Columns\TextColumn::make('item.code')
->label('Item')
->alignCenter()
->searchable()
->sortable(),
Tables\Columns\TextColumn::make('item.description')
->label('Description')
->alignCenter()
->searchable()
->sortable(),
Tables\Columns\TextColumn::make('customerPo.customer_po')
->label('Customer PO')
->alignCenter()
->searchable()
->sortable(),
Tables\Columns\TextColumn::make('customerPo.customer_name')
->label('Customer Name')
->alignCenter()
->searchable()
->sortable(),
Tables\Columns\TextColumn::make('wire_packing_number')
->label('Wire Packing Number')
->alignCenter()
->searchable()
->sortable(),
Tables\Columns\TextColumn::make('process_order')
->label('Process Order')
->alignCenter()
->searchable()
->sortable(),
Tables\Columns\TextColumn::make('weight')
->label('Weight')
->alignCenter()
->searchable()
->sortable(),
Tables\Columns\TextColumn::make('wire_packing_status')
->label('Wire Packing Status')
->alignCenter()
->searchable()
->sortable(),
Tables\Columns\TextColumn::make('created_by')
->label('Created By')
->alignCenter()
->searchable()
->sortable(),
Tables\Columns\TextColumn::make('created_at')
->label('Created At')
->alignCenter()
->dateTime()
->sortable()
->toggleable(isToggledHiddenByDefault: true),
Tables\Columns\TextColumn::make('updated_at')
->label('Updated At')
->alignCenter()
->dateTime()
->sortable()
->toggleable(isToggledHiddenByDefault: true),
Tables\Columns\TextColumn::make('deleted_at')
->dateTime()
->sortable()
->toggleable(isToggledHiddenByDefault: true),
])
->filters([
Tables\Filters\TrashedFilter::make(),
])
->actions([
Tables\Actions\ViewAction::make(),
Tables\Actions\EditAction::make(),
])
->bulkActions([
Tables\Actions\BulkActionGroup::make([
Tables\Actions\DeleteBulkAction::make(),
Tables\Actions\ForceDeleteBulkAction::make(),
Tables\Actions\RestoreBulkAction::make(),
]),
]);
}
public static function getRelations(): array
{
return [
//
];
}
public static function getPages(): array
{
return [
'index' => Pages\ListWireMasterPackings::route('/'),
'create' => Pages\CreateWireMasterPacking::route('/create'),
'view' => Pages\ViewWireMasterPacking::route('/{record}'),
'edit' => Pages\EditWireMasterPacking::route('/{record}/edit'),
];
}
public static function getEloquentQuery(): Builder
{
return parent::getEloquentQuery()
->withoutGlobalScopes([
SoftDeletingScope::class,
]);
}
}

View File

@@ -0,0 +1,732 @@
<?php
namespace App\Filament\Resources\WireMasterPackingResource\Pages;
use App\Filament\Resources\WireMasterPackingResource;
use App\Models\Item;
use App\Models\Plant;
use App\Models\WireMasterPacking;
use Filament\Actions;
use Filament\Facades\Filament;
use Filament\Notifications\Notification;
use Filament\Resources\Pages\CreateRecord;
use Illuminate\View\View;
class CreateWireMasterPacking extends CreateRecord
{
protected static string $resource = WireMasterPackingResource::class;
public $processOrder;
public $customerPo;
public $plantId;
public $count = 0;
public $snoCount = 0;
public $pendingPallet;
public array $importedPoList = [];
protected static string $view = 'filament.resources.wire-sticker-resource.create-wire-master-packing';
protected $listeners = [
'updateSnoQuantity' => 'handleUpdateSnoQuantity',
];
public function handleUpdateSnoQuantity($newValue)
{
$this->form->fill([
'Sno_quantity' => $newValue,
]);
}
public function processOrderSNo(){
$plantId = $this->form->getState()['plant_id'];
$plantId = trim($plantId) ?? null;
$processOrder = trim($this->form->getState()['process_order'])?? null;
$customerPo = trim($this->form->getState()['customer_po_master_id'])?? null;
$wirePackNo = trim($this->form->getState()['wire_packing_number'])?? null;
$wirePackNo = trim($wirePackNo) ?? null;
$user = Filament::auth()->user();
$operatorName = $user->name;
if (empty($processOrder) || $processOrder == '')
{
Notification::make()
->title("Process Order can't be empty")
->danger()
->duration(5000)
->send();
$this->form->fill([
'process_order' => null,
'plant_id' => $plantId,
'customer_po_master_id' => $customerPo,
'wire_packing_number' => $wirePackNo,
'Sno_quantity' => 0,
'created_by' => $operatorName,
'scanned_by' => $operatorName,
]);
return;
}
$pattern = '/^([^|]+)\|([^|]+)\|(\d+(\.\d+)?)$/';
if (!preg_match($pattern, $processOrder, $matches))
{
Notification::make()
->title("Scan Valid Qr code ")
->body("Expected Format : (MaterialCode|Process Order-Id|Weight)")
->danger()
->duration(5000)
->send();
$this->form->fill([
'process_order' => null,
'plant_id' => $plantId,
'customer_po_master_id' => $customerPo,
'wire_packing_number' => $wirePackNo,
'Sno_quantity' => 0,
'created_by' => $operatorName,
'scanned_by' => $operatorName,
]);
return;
}
$materialCode = $matches[1];
$processOrderId = $matches[2];
$weight = $matches[3];
$icode = Item::where('code', $materialCode)->first();
if(!$icode)
{
Notification::make()
->title("Unknown Item Code")
->body("Item Code not found '$materialCode'")
->danger()
->duration(5000)
->send();
$this->form->fill([
'process_order' => null,
'plant_id' => $plantId,
'customer_po_master_id' => $customerPo,
'wire_packing_number' => $wirePackNo,
'Sno_quantity' => 0,
'created_by' => $operatorName,
'scanned_by' => $operatorName,
]);
return;
}
$icodeAgaPlant = Item::where('code', $materialCode)->where('plant_id', $plantId)->first();
$plantCode = Plant::where('id', $plantId)->first();
$plantcode = $plantCode->code;
$itemId = $icodeAgaPlant->id;
if(!$icodeAgaPlant)
{
Notification::make()
->title("Unknown Item Code")
->body("Item Code not found '$materialCode' against Plant Code '$plantcode'")
->danger()
->duration(5000)
->send();
$this->form->fill([
'process_order' => null,
'plant_id' => $plantId,
'customer_po_master_id' => $customerPo,
'wire_packing_number' => $wirePackNo,
'Sno_quantity' => 0,
'created_by' => $operatorName,
'scanned_by' => $operatorName,
]);
return;
}
$processOrderAgaPlant = WireMasterPacking::where('process_order', $processOrderId)->where('plant_id', $plantId)->first();
if($processOrderAgaPlant)
{
Notification::make()
->title("Duplicate Process Order")
->body("Duplicate process order found '$processOrderId' against Plant Code '$plantcode'")
->danger()
->duration(5000)
->send();
$this->form->fill([
'process_order' => null,
'plant_id' => $plantId,
'customer_po_master_id' => $customerPo,
'wire_packing_number' => $wirePackNo,
'Sno_quantity' => 0,
'created_by' => $operatorName,
'scanned_by' => $operatorName,
]);
return;
}
try
{
$existingPallet = WireMasterPacking::where('plant_id', $plantId)
->where('wire_packing_number', $wirePackNo)
->first();
$count = WireMasterPacking::where('plant_id', $plantId)
->where('wire_packing_number', $wirePackNo)
->count('wire_packing_number');
$createdAt = $existingPallet ? $existingPallet->created_at : $clickedAt ?? now();
$createdBy = $existingPallet ? $existingPallet->created_by : $clickedBy ?? $operatorName;
$record = WireMasterPacking::create([
'plant_id' => $plantId,
'item_id' => $itemId,
'wire_packing_number' => $wirePackNo,
'process_order' => $processOrderId,
'customer_po_master_id' => $customerPo,
'weight' => $weight,
'created_by' => $createdBy,
'scanned_by' => $operatorName,
'created_at' => $createdAt,
'scanned_at' => now(),
'updated_by' => $operatorName,
]);
if ($record)
{
$this->snoCount = WireMasterPacking::where('plant_id', $plantId)
->where('wire_packing_number', $wirePackNo)
->count();
$this->dispatch('loadData', $wirePackNo, $plantId);
$this->form->fill([
'plant_id' => $plantId,
'customer_po_master_id' => $customerPo,
'wire_packing_number' => $wirePackNo,
'process_order' => null,
// 'pending_pallet_list' => $pendingPallet,
'Sno_quantity' => $this->snoCount,
'created_by' => $operatorName,
'scanned_by' => $operatorName,
]);
}
else
{
Notification::make()
->title("Failed to insert scanned serial number '$processOrderId' into wire master table!")
->danger()
->duration(5000)
->send();
$this->dispatch('loadData', $wirePackNo, $plantId);
$this->form->fill([
'plant_id' => $plantId,
'customer_po_master_id' => $customerPo,
'wire_packing_number' => $wirePackNo,
'process_order' => null,
// 'pending_pallet_list' => $pendingPallet,
'Sno_quantity' => $count,
'scanned_by' => $operatorName,
]);
return;
}
}
catch (\Exception $e)
{
Notification::make()
->title('Error: Serial not inserted.')
->body("Something went wrong while inserting process order '{$processOrderId}' into pallet table!\nScan the new process order to proceed...")
->danger()
->duration(5000)
->send();
$this->dispatch('loadData', $wirePackNo, $plantId);
$this->form->fill([
'plant_id' => $plantId,
'customer_po_master_id' => $customerPo,
'wire_packing_number' => $wirePackNo,
'process_order' => null,
// 'pending_pallet_list' => $pendingPallet,
'Sno_quantity' => $count,
'created_by' => $operatorName,
'scanned_by' => $operatorName,
]);
return;
}
$this->dispatch('loadData', $wirePackNo, $plantId);
}
public function markAsComplete()
{
$plantId = $this->form->getState()['plant_id'];
$plantId = trim($plantId) ?? null;
$pendingPallet = $this->form->getState()['pending_pallet_list'];
$palletNumber = trim($this->form->getState()['wire_packing_number'])?? null;
$palletNumber = trim($palletNumber) ?? null;
$processOrder = trim($this->form->getState()['process_order'])?? null;
$processOrder = trim($processOrder) ?? null;
$user = Filament::auth()->user();
$operatorName = $user->name;
$isCompleted = $this->data['is_completed'] ?? false;
// $this->pendingPallet = $this->form->getState()['pending_pallet_list'];
if (! ($this->data['is_completed'] ?? false)) {
Notification::make()
->title('Completion required')
->body('Please check the "Is Completed" checkbox to finish master packing.')
->warning()
->duration(3000)
->send();
return;
}
$palletExist = WireMasterPacking::where('wire_packing_number', $palletNumber)
->where('plant_id', $plantId)
->first();
if (!$palletExist)
{
Notification::make()
->title("Pallet number '$palletNumber' does not have process orders to save!<br>Add the valid process order into pallet number to proceed...")
->danger()
->duration(5000)
->send();
$this->dispatch('loadData', $palletNumber, $plantId);
$this->form->fill([
'process_order' => null,
'plant_id' => $plantId,
'wire_packing_number' => $palletNumber,
'pending_pallet_list' => $pendingPallet,
'Sno_quantity' => 0,
'created_by' => $operatorName,
'scanned_by' => $operatorName,
]);
return;
}
$allCompleted = WireMasterPacking::where('plant_id', $plantId)
->where('wire_packing_number', $palletNumber)
->where('wire_packing_status', '=','Completed')
->first();
if ($allCompleted)
{
Notification::make()
->title("Master Packing pallet number '$palletNumber' already completed the master packing!<br>Generate the new Master Packing Pallet number or choose from pending pallet list!")
->danger()
->duration(5000)
->send();
$this->dispatch('loadData', '', $plantId);
$this->form->fill([
'process_order' => null,
'plant_id' => $plantId,
'wire_packing_number' => null,
'pending_pallet_list' => null,//$pendingPallet
'Sno_quantity' => 0,
'created_by' => $operatorName,
'scanned_by' => $operatorName,
]);
return;
}
// $count = PalletValidation::where('plant_id', $plantId)
// ->where('pallet_number', $palletNumber)
// ->count('pallet_number');
if (!$isCompleted)
{
$updated = WireMasterPacking::where('wire_packing_number', $palletNumber)
->where('plant_id', $plantId)
->update([
'updated_at' => now(),
'updated_by' => $operatorName,
]);
if ($updated > 0)
{
Notification::make()
->title("Pallet number '$palletNumber' records saved successfully!")
->success()
->duration(800)
->send();
$this->dispatch('loadData', '', $plantId);
$this->form->fill([
'process_order' => null,
'plant_id' => $plantId,
'wire_packing_number' => null,//$palletNumber
'pending_pallet_list' => null,//$pendingPallet
'Sno_quantity' => 0,//$count,
'created_by' => $operatorName,
'scanned_by' => $operatorName,
]);
return;
}
}
else
{
$updated = WireMasterPacking::where('wire_packing_number', $palletNumber)
->where('plant_id', $plantId)
->update([
'wire_packing_status' => 'Completed',
'updated_at' => now(),
'updated_by' => $operatorName,
]);
if ($updated > 0)
{
Notification::make()
->title("Pallet number '$palletNumber' completed the master packing successfully!")
->success()
->duration(800)
->send();
$this->dispatch('loadData', '', $plantId);
$this->form->fill([
'process_order' => null,
'plant_id' => $plantId,
'wire_packing_number' => null,//$palletNumber
'pending_pallet_list' => null,//$pendingPallet
'Sno_quantity' => 0,//$count
'created_by' => $operatorName,
'scanned_by' => $operatorName,
]);
return;
}
}
}
public function processPalletNo()
{
$plantId = $this->form->getState()['plant_id'];
$plantId = trim($plantId) ?? null;
$pendingPallet = $this->form->getState()['pending_pallet_list'];
$palletNumber = trim($this->form->getState()['wire_packing_number']) ?? null;
$customerPo = trim($this->form->getState()['customer_po_master_id'])?? null;
$palletNumber = trim($palletNumber) ?? null;
$processOrder = trim($this->form->getState()['process_order']) ?? null;
$processOrder = trim($processOrder) ?? null;
$user = Filament::auth()->user();
$operatorName = $user->name;
//$this->dispatch('loadData', $palletNumber, $plantId);
$this->form->fill([
'serial_number' => null,
'plant_id' => $plantId,
'customer_po_master_id' => $customerPo,
'pallet_number' => $palletNumber,
'pending_pallet_list' => $pendingPallet,
'Sno_quantity' => 0,
'created_by' => $operatorName,
'scanned_by' => $operatorName,
]);
if (!$palletNumber)
{
Notification::make()
->title('Pallet number is required.')
->danger()
->duration(5000)
->send();
$this->dispatch('loadData', '', $plantId);
$this->form->fill([
'process_order' => null,
'plant_id' => $plantId,
'customer_po_master_id' => $customerPo,
'wire_packing_number' => $palletNumber,
'pending_pallet_list' => $pendingPallet,
'Sno_quantity' => 0,
'created_by' => $operatorName,
'scanned_by' => $operatorName,
]);
return;
}
if (strlen($palletNumber) < 10)
{
Notification::make()
->title("Pallet number '$palletNumber' must be at least 10 digits.")
->danger()
->duration(5000)
->send();
$this->dispatch('loadLocator' ,'',$plantId);
$this->form->fill([
'serial_number' => null,
'plant_id' => $plantId,
'customer_po_master_id' => $customerPo,
'pallet_number' => $palletNumber,
'pending_pallet_list' => $pendingPallet,
'Sno_quantity' => 0,
'created_by' => $operatorName,
'scanned_by' => $operatorName,
]);
return;
}
$count = WireMasterPacking::where('plant_id', $plantId)
->where('wire_packing_number', $palletNumber)
->count('wire_packing_number');
$palletNotCompleted = WireMasterPacking::where('plant_id', $plantId)
->where('wire_packing_number', $palletNumber)
->where('wire_packing_status', '=','')
->orWhere('wire_packing_status', '=',null)
->first();
if (!$palletNotCompleted)
{
Notification::make()
->title("Already completed for pallet number $palletNumber!")
->danger()
->duration(5000)
->send();
$this->dispatch('loadData', $palletNumber, $plantId);
$this->form->fill([
'process_order' => null,
'plant_id' => $plantId,
'customer_po_master_id' => $customerPo,
'wire_packing_number' => $palletNumber,
'pending_pallet_list' => $pendingPallet,
'Sno_quantity' => $count,
'created_by' => $operatorName,
'scanned_by' => $operatorName,
]);
return;
}
$this->form->fill([
'process_order' => null,
'plant_id' => $plantId,
'customer_po_master_id' => $customerPo,
'wire_packing_number' => $palletNumber,
'pending_pallet_list' => $pendingPallet,
'Sno_quantity' => $count,
'created_by' => $operatorName,
'scanned_by' => $operatorName,
]);
$this->dispatch('loadData', $palletNumber, $plantId);
}
public function processRemoveSNo()
{
$plantId = $this->form->getState()['plant_id'];
$plantId = trim($plantId) ?? null;
$pendingPallet = $this->form->getState()['pending_pallet_list'];
$palletNumber = trim($this->form->getState()['wire_packing_number']) ?? null;
$customerPo = trim($this->form->getState()['customer_po_master_id'])?? null;
$palletNumber = trim($palletNumber) ?? null;
$processOrder = trim($this->form->getState()['removeSno_number']) ?? null;
$processOrder = trim($processOrder) ?? null;
$user = Filament::auth()->user();
$operatorName = $user->name;
if (!$palletNumber)
{
Notification::make()
->title('Master Pallet number is required to remove.')
->danger()
->duration(5000)
->send();
return;
}
$count = WireMasterPacking::where('plant_id', $plantId)
->where('wire_packing_number', $palletNumber)
->count('wire_packing_number');
if (!$processOrder)
{
Notification::make()
->title('Process order is required to remove.')
->danger()
->duration(5000)
->send();
$this->dispatch('loadData', $palletNumber, $plantId);
$this->form->fill([
'process_order' => null,
'plant_id' => $plantId,
'customer_po_master_id' => $customerPo,
'wire_packing_number' => $palletNumber,
'pending_pallet_list' => $pendingPallet,
'Sno_quantity' => $count,
'created_by' => $operatorName,
'scanned_by' => $operatorName,
]);
return;
}
$processOrderexist = WireMasterPacking::where('plant_id', $plantId)
->where('process_order', $processOrder)
->first();
if (!$processOrderexist)
{
Notification::make()
->title('Process Order not exists in pallet table.')
->danger()
->duration(5000)
->send();
$this->dispatch('loadData', $palletNumber, $plantId);
$this->form->fill([
'process_order' => null,
'plant_id' => $plantId,
'customer_po_master_id' => $customerPo,
'wire_packing_number' => $palletNumber,
'pending_pallet_list' => $pendingPallet,
'Sno_quantity' => $count,
'created_by' => $operatorName,
'scanned_by' => $operatorName,
]);
return;
}
$palletExist = WireMasterPacking::where('plant_id', $plantId)
->where('process_order', $processOrder)
->where('wire_packing_number', '!=', '')
->where('wire_packing_number', '!=', null)
->first();
if ($palletExist && $palletExist->wire_packing_number != $palletNumber)
{
Notification::make()
->title("Scanned process order number exist in pallet number '$palletExist->wire_packing_number'.<br>Scan the valid exist process order to remove!")
->danger()
->duration(5000)
->send();
$this->dispatch('loadData', $palletNumber, $plantId);
$this->form->fill([
'process_order' => null,
'plant_id' => $plantId,
'customer_po_master_id' => $customerPo,
'wire_packing_number' => $palletNumber,
'pending_pallet_list' => $pendingPallet,
'Sno_quantity' => $count,
'created_by' => $operatorName,
'scanned_by' => $operatorName,
]);
return;
}
$deleted = WireMasterPacking::where('plant_id', $plantId)
->where('wire_packing_number', $palletNumber)
->where('process_order', $processOrder)
->forceDelete();
if ($deleted)
{
// Notification::make()
// ->title("Scanned serial number '$serialNumber' successfully removed from pallet table!<br>Scan the next exist serial number to remove...")
// ->success()
// ->duration(600)
// ->send();
$this->snoCount = WireMasterPacking::where('plant_id', $plantId)
->where('wire_packing_number', $palletNumber)
->count();
$this->form->fill([
'plant_id' => $plantId,
'customer_po_master_id' => $customerPo,
'wire_packing_number' => $palletNumber,
'removeSno_number' => null,
'pending_pallet_list' => $this->pendingPallet,
'Sno_quantity' => $this->snoCount,
'created_by' => $operatorName,
'scanned_by' => $operatorName,
]);
$this->dispatch('loadData', $palletNumber, $plantId);
}
else
{
Notification::make()
->title("Failed to remove scanned process order '$processOrder' from master pallet!")
->danger()
->duration(5000)
->send();
$this->dispatch('loadData', $palletNumber, $plantId);
$this->form->fill([
'process_order' => null,
'plant_id' => $plantId,
'customer_po_master_id' => $customerPo,
'wire_packing_number' => $palletNumber,
'pending_pallet_list' => $pendingPallet,
'Sno_quantity' => $count,
'created_by' => $operatorName,
'scanned_by' => $operatorName,
]);
}
//$this->dispatch('removeSno', $serialNumber, $palletNumber, $plantId);
}
public function getFormActions(): array
{
return [];
}
}

View File

@@ -0,0 +1,22 @@
<?php
namespace App\Filament\Resources\WireMasterPackingResource\Pages;
use App\Filament\Resources\WireMasterPackingResource;
use Filament\Actions;
use Filament\Resources\Pages\EditRecord;
class EditWireMasterPacking extends EditRecord
{
protected static string $resource = WireMasterPackingResource::class;
protected function getHeaderActions(): array
{
return [
Actions\ViewAction::make(),
Actions\DeleteAction::make(),
Actions\ForceDeleteAction::make(),
Actions\RestoreAction::make(),
];
}
}

View File

@@ -0,0 +1,19 @@
<?php
namespace App\Filament\Resources\WireMasterPackingResource\Pages;
use App\Filament\Resources\WireMasterPackingResource;
use Filament\Actions;
use Filament\Resources\Pages\ListRecords;
class ListWireMasterPackings extends ListRecords
{
protected static string $resource = WireMasterPackingResource::class;
protected function getHeaderActions(): array
{
return [
Actions\CreateAction::make(),
];
}
}

View File

@@ -0,0 +1,19 @@
<?php
namespace App\Filament\Resources\WireMasterPackingResource\Pages;
use App\Filament\Resources\WireMasterPackingResource;
use Filament\Actions;
use Filament\Resources\Pages\ViewRecord;
class ViewWireMasterPacking extends ViewRecord
{
protected static string $resource = WireMasterPackingResource::class;
protected function getHeaderActions(): array
{
return [
Actions\EditAction::make(),
];
}
}