Added logic for invalid quantity updation in panel gr master #968
@@ -3,13 +3,49 @@
|
|||||||
namespace App\Filament\Resources\PanelGrMasterResource\Pages;
|
namespace App\Filament\Resources\PanelGrMasterResource\Pages;
|
||||||
|
|
||||||
use App\Filament\Resources\PanelGrMasterResource;
|
use App\Filament\Resources\PanelGrMasterResource;
|
||||||
|
use App\Models\PanelBoxValidation;
|
||||||
|
use App\Models\StickerMaster;
|
||||||
use Filament\Actions;
|
use Filament\Actions;
|
||||||
|
use Filament\Facades\Filament;
|
||||||
|
use Filament\Notifications\Notification;
|
||||||
use Filament\Resources\Pages\EditRecord;
|
use Filament\Resources\Pages\EditRecord;
|
||||||
|
|
||||||
class EditPanelGrMaster extends EditRecord
|
class EditPanelGrMaster extends EditRecord
|
||||||
{
|
{
|
||||||
protected static string $resource = PanelGrMasterResource::class;
|
protected static string $resource = PanelGrMasterResource::class;
|
||||||
|
|
||||||
|
protected function mutateFormDataBeforeSave(array $data): array
|
||||||
|
{
|
||||||
|
$record = $this->record;
|
||||||
|
|
||||||
|
$sticker = StickerMaster::where('plant_id', $record->plant_id)->where('item_id', $record->item_id)->first();
|
||||||
|
|
||||||
|
if($sticker)
|
||||||
|
{
|
||||||
|
$scannedQuantity = PanelBoxValidation::where('plant_id', $record->plant_id)
|
||||||
|
->where('production_order', $record->document_number)
|
||||||
|
->where('inspection_lot_number', $record->inspection_lot_number)
|
||||||
|
->where('sticker_master_id', $sticker->id)
|
||||||
|
->count();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if ((int) $data['quantity'] < $scannedQuantity) {
|
||||||
|
Notification::make()
|
||||||
|
->title('Invalid Quantity')
|
||||||
|
->body("Already scanned quantity is {$scannedQuantity}.<br>Panel GR Master quantity cannot be less than {$scannedQuantity}.")
|
||||||
|
->danger()
|
||||||
|
->send();
|
||||||
|
$this->halt();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
$data['updated_by'] = Filament::auth()->user()?->name;
|
||||||
|
$data['updated_at'] = now();
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
protected function getHeaderActions(): array
|
protected function getHeaderActions(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
|
|||||||
Reference in New Issue
Block a user