Compare commits
3 Commits
94819ccc4f
...
a52fc9580a
| Author | SHA1 | Date | |
|---|---|---|---|
| a52fc9580a | |||
|
|
6cde9fc570 | ||
|
|
ab1daa57e2 |
@@ -24,14 +24,16 @@ class InvoiceValidationExporter extends Exporter
|
|||||||
// Increment and return the row number
|
// Increment and return the row number
|
||||||
return ++$rowNumber;
|
return ++$rowNumber;
|
||||||
}),
|
}),
|
||||||
ExportColumn::make('plant.name')
|
ExportColumn::make('plant.code')
|
||||||
->label('PLANT'),
|
->label('PLANT CODE'),
|
||||||
ExportColumn::make('invoice_number')
|
ExportColumn::make('invoice_number')
|
||||||
->label('INVOICE NUMBER'),
|
->label('INVOICE NUMBER'),
|
||||||
ExportColumn::make('serial_number')
|
ExportColumn::make('serial_number')
|
||||||
->label('SERIAL NUMBER'),
|
->label('SERIAL NUMBER'),
|
||||||
ExportColumn::make('stickerMaster.item.code')
|
ExportColumn::make('stickerMaster.item.code')
|
||||||
->label('ITEM CODE'),
|
->label('ITEM CODE'),
|
||||||
|
ExportColumn::make('stickerMaster.item.description')
|
||||||
|
->label('ITEM DESCRIPTION'),
|
||||||
ExportColumn::make('motor_scanned_status')
|
ExportColumn::make('motor_scanned_status')
|
||||||
->label('MOTOR SCANNED STATUS'),
|
->label('MOTOR SCANNED STATUS'),
|
||||||
ExportColumn::make('pump_scanned_status')
|
ExportColumn::make('pump_scanned_status')
|
||||||
|
|||||||
@@ -10,12 +10,8 @@ use App\Models\InvoiceValidation;
|
|||||||
use App\Models\Item;
|
use App\Models\Item;
|
||||||
use App\Models\Plant;
|
use App\Models\Plant;
|
||||||
use App\Models\StickerMaster;
|
use App\Models\StickerMaster;
|
||||||
use Auth;
|
|
||||||
use Filament\Actions\Action as FilamentActionsAction;
|
|
||||||
use Filament\Actions\CreateAction;
|
|
||||||
use Filament\Facades\Filament;
|
use Filament\Facades\Filament;
|
||||||
use Filament\Forms;
|
use Filament\Forms;
|
||||||
use Filament\Forms\Components\Actions\Action as ActionsAction;
|
|
||||||
use Filament\Forms\Components\DateTimePicker;
|
use Filament\Forms\Components\DateTimePicker;
|
||||||
use Filament\Forms\Components\FileUpload;
|
use Filament\Forms\Components\FileUpload;
|
||||||
use Filament\Forms\Components\Radio;
|
use Filament\Forms\Components\Radio;
|
||||||
@@ -23,25 +19,23 @@ use Filament\Forms\Components\Section;
|
|||||||
use Filament\Forms\Components\Select;
|
use Filament\Forms\Components\Select;
|
||||||
use Filament\Forms\Components\TextInput;
|
use Filament\Forms\Components\TextInput;
|
||||||
use Filament\Forms\Components\ToggleButtons;
|
use Filament\Forms\Components\ToggleButtons;
|
||||||
|
use Filament\Forms\Components\View;
|
||||||
use Filament\Forms\Form;
|
use Filament\Forms\Form;
|
||||||
use Filament\Forms\Get;
|
use Filament\Forms\Get;
|
||||||
|
use Filament\Notifications\Notification;
|
||||||
use Filament\Resources\Resource;
|
use Filament\Resources\Resource;
|
||||||
use Filament\Tables;
|
use Filament\Tables;
|
||||||
use Filament\Tables\Table;
|
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
|
||||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
|
||||||
use Filament\Notifications\Notification;
|
|
||||||
use Filament\Tables\Actions\Action;
|
use Filament\Tables\Actions\Action;
|
||||||
use Filament\Tables\Actions\ExportAction;
|
use Filament\Tables\Actions\ExportAction;
|
||||||
use Filament\Tables\Filters\Filter;
|
use Filament\Tables\Filters\Filter;
|
||||||
use Illuminate\Support\Facades\Storage;
|
use Filament\Tables\Table;
|
||||||
use Maatwebsite\Excel\Facades\Excel;
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
use Livewire\Livewire;
|
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||||
use Str;
|
|
||||||
use Illuminate\Support\Facades\Session;
|
use Illuminate\Support\Facades\Session;
|
||||||
use Illuminate\Support\Facades\Mail;
|
use Illuminate\Support\Facades\Storage;
|
||||||
use Filament\Forms\Components\View;
|
use Livewire\Livewire;
|
||||||
|
use Maatwebsite\Excel\Facades\Excel;
|
||||||
|
use Str;
|
||||||
|
|
||||||
class InvoiceValidationResource extends Resource
|
class InvoiceValidationResource extends Resource
|
||||||
{
|
{
|
||||||
@@ -53,8 +47,6 @@ class InvoiceValidationResource extends Resource
|
|||||||
|
|
||||||
public $invoiceNumber;
|
public $invoiceNumber;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static function form(Form $form): Form
|
public static function form(Form $form): Form
|
||||||
{
|
{
|
||||||
return $form
|
return $form
|
||||||
@@ -74,6 +66,7 @@ class InvoiceValidationResource extends Resource
|
|||||||
->columnSpan(1)
|
->columnSpan(1)
|
||||||
->options(function (callable $get) {
|
->options(function (callable $get) {
|
||||||
$userHas = Filament::auth()->user()->plant_id;
|
$userHas = Filament::auth()->user()->plant_id;
|
||||||
|
|
||||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
|
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
|
||||||
})
|
})
|
||||||
->default(function () {
|
->default(function () {
|
||||||
@@ -91,10 +84,9 @@ class InvoiceValidationResource extends Resource
|
|||||||
$set('total_quantity', null);
|
$set('total_quantity', null);
|
||||||
$set('scanned_quantity', null);
|
$set('scanned_quantity', null);
|
||||||
$set('ivPlantError', 'Please select a plant first.');
|
$set('ivPlantError', 'Please select a plant first.');
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
$set('ivPlantError', null);
|
$set('ivPlantError', null);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -178,18 +170,17 @@ class InvoiceValidationResource extends Resource
|
|||||||
->reactive()
|
->reactive()
|
||||||
->hidden(fn (callable $get) => ($get('invoice_number') == null || $get('update_invoice') == '0') || ! empty($get('serial_number')))
|
->hidden(fn (callable $get) => ($get('invoice_number') == null || $get('update_invoice') == '0') || ! empty($get('serial_number')))
|
||||||
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
->afterStateUpdated(function ($state, callable $set, callable $get) {
|
||||||
if (!$get('plant_id'))
|
if (! $get('plant_id')) {
|
||||||
{
|
|
||||||
$set('update_invoice', null);
|
$set('update_invoice', null);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($get('update_invoice') == "1")
|
if ($get('update_invoice') == '1') {
|
||||||
{
|
|
||||||
$totQuan = InvoiceValidation::where('invoice_number', $get('invoice_number'))->where('plant_id', $get('plant_id'))->count();
|
$totQuan = InvoiceValidation::where('invoice_number', $get('invoice_number'))->where('plant_id', $get('plant_id'))->count();
|
||||||
if ($totQuan <= 0)
|
if ($totQuan <= 0) {
|
||||||
{
|
|
||||||
$set('update_invoice', null);
|
$set('update_invoice', null);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -197,19 +188,16 @@ class InvoiceValidationResource extends Resource
|
|||||||
$scanMQuan = InvoiceValidation::where('invoice_number', $get('invoice_number'))->whereNotNull('serial_number')->where('serial_number', '!=', '')->where('plant_id', $get('plant_id'))->count();
|
$scanMQuan = InvoiceValidation::where('invoice_number', $get('invoice_number'))->whereNotNull('serial_number')->where('serial_number', '!=', '')->where('plant_id', $get('plant_id'))->count();
|
||||||
$scanSQuan = InvoiceValidation::where('invoice_number', $get('invoice_number'))->where('scanned_status', 'Scanned')->where('plant_id', $get('plant_id'))->count();
|
$scanSQuan = InvoiceValidation::where('invoice_number', $get('invoice_number'))->where('scanned_status', 'Scanned')->where('plant_id', $get('plant_id'))->count();
|
||||||
|
|
||||||
if ($totMQuan > 0)
|
if ($totMQuan > 0) {
|
||||||
{
|
if ($totQuan == $scanMQuan) {
|
||||||
if ($totQuan == $scanMQuan)
|
|
||||||
{
|
|
||||||
$set('update_invoice', null);
|
$set('update_invoice', null);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else
|
if ($totQuan == $scanSQuan) {
|
||||||
{
|
|
||||||
if ($totQuan == $scanSQuan)
|
|
||||||
{
|
|
||||||
$set('update_invoice', null);
|
$set('update_invoice', null);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -224,7 +212,6 @@ class InvoiceValidationResource extends Resource
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static function table(Table $table): Table
|
public static function table(Table $table): Table
|
||||||
{
|
{
|
||||||
return $table
|
return $table
|
||||||
@@ -240,6 +227,7 @@ class InvoiceValidationResource extends Resource
|
|||||||
$paginator = $livewire->getTableRecords();
|
$paginator = $livewire->getTableRecords();
|
||||||
$perPage = method_exists($paginator, 'perPage') ? $paginator->perPage() : 10;
|
$perPage = method_exists($paginator, 'perPage') ? $paginator->perPage() : 10;
|
||||||
$currentPage = method_exists($paginator, 'currentPage') ? $paginator->currentPage() : 1;
|
$currentPage = method_exists($paginator, 'currentPage') ? $paginator->currentPage() : 1;
|
||||||
|
|
||||||
return ($currentPage - 1) * $perPage + $rowLoop->iteration;
|
return ($currentPage - 1) * $perPage + $rowLoop->iteration;
|
||||||
}),
|
}),
|
||||||
Tables\Columns\TextColumn::make('invoice_number')
|
Tables\Columns\TextColumn::make('invoice_number')
|
||||||
@@ -250,6 +238,11 @@ class InvoiceValidationResource extends Resource
|
|||||||
->label('Item Code')
|
->label('Item Code')
|
||||||
->alignCenter()
|
->alignCenter()
|
||||||
->sortable(), // ->searchable()
|
->sortable(), // ->searchable()
|
||||||
|
Tables\Columns\TextColumn::make('stickerMaster.item.description')
|
||||||
|
->label('Item Description')
|
||||||
|
->alignCenter()
|
||||||
|
->sortable() // ->searchable()
|
||||||
|
->toggleable(isToggledHiddenByDefault: true),
|
||||||
Tables\Columns\TextColumn::make('serial_number')
|
Tables\Columns\TextColumn::make('serial_number')
|
||||||
->label('Serial Number')
|
->label('Serial Number')
|
||||||
->alignCenter()
|
->alignCenter()
|
||||||
@@ -269,6 +262,9 @@ class InvoiceValidationResource extends Resource
|
|||||||
Tables\Columns\TextColumn::make('scanned_status')
|
Tables\Columns\TextColumn::make('scanned_status')
|
||||||
->label('Scanned Status')
|
->label('Scanned Status')
|
||||||
->alignCenter(),
|
->alignCenter(),
|
||||||
|
// Tables\Columns\TextColumn::make('stickerMaster.panel_box_code')
|
||||||
|
// ->label('Panel Box Code')
|
||||||
|
// ->alignCenter(),
|
||||||
Tables\Columns\TextColumn::make('panel_box_supplier')
|
Tables\Columns\TextColumn::make('panel_box_supplier')
|
||||||
->label('Panel Box Supplier')
|
->label('Panel Box Supplier')
|
||||||
->alignCenter(),
|
->alignCenter(),
|
||||||
@@ -335,6 +331,7 @@ class InvoiceValidationResource extends Resource
|
|||||||
// ->options(Plant::pluck('name', 'id')->toArray()) // Fetch plant names and IDs
|
// ->options(Plant::pluck('name', 'id')->toArray()) // Fetch plant names and IDs
|
||||||
->options(function (callable $get) {
|
->options(function (callable $get) {
|
||||||
$userHas = Filament::auth()->user()->plant_id;
|
$userHas = Filament::auth()->user()->plant_id;
|
||||||
|
|
||||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
|
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
|
||||||
})
|
})
|
||||||
->label('Select Plant')
|
->label('Select Plant')
|
||||||
@@ -378,42 +375,37 @@ class InvoiceValidationResource extends Resource
|
|||||||
// /home/iot-dev/projects/pds/storage/app/private/uploads/temp/3RA0018735.xlsx
|
// /home/iot-dev/projects/pds/storage/app/private/uploads/temp/3RA0018735.xlsx
|
||||||
|
|
||||||
$totQuan = InvoiceValidation::where('invoice_number', $originalNameOnly)->count();
|
$totQuan = InvoiceValidation::where('invoice_number', $originalNameOnly)->count();
|
||||||
if ($totQuan > 0)
|
if ($totQuan > 0) {
|
||||||
{
|
|
||||||
$scanSQuan = InvoiceValidation::where('invoice_number', $originalNameOnly)->where('scanned_status', 'Scanned')->count();
|
$scanSQuan = InvoiceValidation::where('invoice_number', $originalNameOnly)->where('scanned_status', 'Scanned')->count();
|
||||||
if ($totQuan == $scanSQuan)
|
if ($totQuan == $scanSQuan) {
|
||||||
{
|
|
||||||
$invoiceFirst = InvoiceValidation::with('plant')->where('invoice_number', $originalNameOnly)->first();
|
$invoiceFirst = InvoiceValidation::with('plant')->where('invoice_number', $originalNameOnly)->first();
|
||||||
$plantName = $invoiceFirst ? (String)$invoiceFirst->plant->name : null;
|
$plantName = $invoiceFirst ? (string) $invoiceFirst->plant->name : null;
|
||||||
|
|
||||||
Notification::make()
|
Notification::make()
|
||||||
->title("Serial invoice number : '$originalNameOnly' already completed the scanning process for plant : '$plantName'.")
|
->title("Serial invoice number : '$originalNameOnly' already completed the scanning process for plant : '$plantName'.")
|
||||||
->danger()
|
->danger()
|
||||||
->send();
|
->send();
|
||||||
|
|
||||||
if ($disk->exists($path))
|
if ($disk->exists($path)) {
|
||||||
{
|
|
||||||
$disk->delete($path);
|
$disk->delete($path);
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
$invoiceFirst = InvoiceValidation::with('plant')->where('invoice_number', $originalNameOnly)->first();
|
$invoiceFirst = InvoiceValidation::with('plant')->where('invoice_number', $originalNameOnly)->first();
|
||||||
// $plantCode = $invoiceFirst ? (String)$invoiceFirst->plant->code : null;
|
// $plantCode = $invoiceFirst ? (String)$invoiceFirst->plant->code : null;
|
||||||
$plantName = $invoiceFirst ? (String)$invoiceFirst->plant->name : null;
|
$plantName = $invoiceFirst ? (string) $invoiceFirst->plant->name : null;
|
||||||
$invoicePlantId = $invoiceFirst->plant_id;
|
$invoicePlantId = $invoiceFirst->plant_id;
|
||||||
if ($plantId != $invoicePlantId)
|
if ($plantId != $invoicePlantId) {
|
||||||
{
|
|
||||||
Notification::make()
|
Notification::make()
|
||||||
->title("Serial invoice number : '$originalNameOnly' already exists for plant : '$plantName'.<br>Choose the valid 'Plant' to proceed!")
|
->title("Serial invoice number : '$originalNameOnly' already exists for plant : '$plantName'.<br>Choose the valid 'Plant' to proceed!")
|
||||||
->danger()
|
->danger()
|
||||||
->send();
|
->send();
|
||||||
|
|
||||||
if ($disk->exists($path))
|
if ($disk->exists($path)) {
|
||||||
{
|
|
||||||
$disk->delete($path);
|
$disk->delete($path);
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -422,26 +414,23 @@ class InvoiceValidationResource extends Resource
|
|||||||
$totQuan = InvoiceValidation::where('invoice_number', $originalNameOnly)->where('plant_id', $plantId)->count();
|
$totQuan = InvoiceValidation::where('invoice_number', $originalNameOnly)->where('plant_id', $plantId)->count();
|
||||||
$scanSQuan = InvoiceValidation::where('invoice_number', $originalNameOnly)->where('scanned_status', 'Scanned')->where('plant_id', $plantId)->count();
|
$scanSQuan = InvoiceValidation::where('invoice_number', $originalNameOnly)->where('scanned_status', 'Scanned')->where('plant_id', $plantId)->count();
|
||||||
|
|
||||||
if ($totQuan > 0 && $totQuan == $scanSQuan)
|
if ($totQuan > 0 && $totQuan == $scanSQuan) {
|
||||||
{
|
|
||||||
Notification::make()
|
Notification::make()
|
||||||
->title('Serial invoice already completed the scanning process for selected plant.')
|
->title('Serial invoice already completed the scanning process for selected plant.')
|
||||||
->danger()
|
->danger()
|
||||||
->send();
|
->send();
|
||||||
|
|
||||||
if ($disk->exists($path))
|
if ($disk->exists($path)) {
|
||||||
{
|
|
||||||
$disk->delete($path);
|
$disk->delete($path);
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($fullPath && file_exists($fullPath))
|
if ($fullPath && file_exists($fullPath)) {
|
||||||
{
|
|
||||||
$rows = Excel::toArray(null, $fullPath)[0];
|
$rows = Excel::toArray(null, $fullPath)[0];
|
||||||
|
|
||||||
if ((count($rows) - 1) <= 0)
|
if ((count($rows) - 1) <= 0) {
|
||||||
{
|
|
||||||
Notification::make()
|
Notification::make()
|
||||||
->title('Records Not Found')
|
->title('Records Not Found')
|
||||||
->body("Import the valid 'Serial Invoice' file to proceed..!")
|
->body("Import the valid 'Serial Invoice' file to proceed..!")
|
||||||
@@ -451,6 +440,7 @@ class InvoiceValidationResource extends Resource
|
|||||||
if ($disk->exists($path)) {
|
if ($disk->exists($path)) {
|
||||||
$disk->delete($path);
|
$disk->delete($path);
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -462,9 +452,10 @@ class InvoiceValidationResource extends Resource
|
|||||||
$seenSerialNumbers = [];
|
$seenSerialNumbers = [];
|
||||||
$validRowsFound = false;
|
$validRowsFound = false;
|
||||||
|
|
||||||
foreach ($rows as $index => $row)
|
foreach ($rows as $index => $row) {
|
||||||
{
|
if ($index == 0) {
|
||||||
if ($index == 0) continue; // Skip header
|
continue;
|
||||||
|
} // Skip header
|
||||||
|
|
||||||
$materialCode = trim($row[0]);
|
$materialCode = trim($row[0]);
|
||||||
$serialNumber = trim($row[1]);
|
$serialNumber = trim($row[1]);
|
||||||
@@ -473,24 +464,16 @@ class InvoiceValidationResource extends Resource
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($materialCode))
|
if (! empty($materialCode)) {
|
||||||
{
|
if (Str::length($materialCode) < 6 || ! ctype_alnum($materialCode)) {
|
||||||
if (Str::length($materialCode) < 6 || !ctype_alnum($materialCode))
|
|
||||||
{
|
|
||||||
$invalidMatCodes[] = $materialCode;
|
$invalidMatCodes[] = $materialCode;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
if (empty($serialNumber)) {
|
if (empty($serialNumber)) {
|
||||||
$missingSerials[] = $materialCode;
|
$missingSerials[] = $materialCode;
|
||||||
|
|
||||||
}
|
} elseif (Str::length($serialNumber) < 9 || ! ctype_alnum($serialNumber)) {
|
||||||
else if (Str::length($serialNumber) < 9 || !ctype_alnum($serialNumber))
|
|
||||||
{
|
|
||||||
$invalidSerialCodes[] = $serialNumber;
|
$invalidSerialCodes[] = $serialNumber;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
if (in_array($serialNumber, $seenSerialNumbers)) {
|
if (in_array($serialNumber, $seenSerialNumbers)) {
|
||||||
$duplicateSerials[] = $serialNumber;
|
$duplicateSerials[] = $serialNumber;
|
||||||
} else {
|
} else {
|
||||||
@@ -500,9 +483,7 @@ class InvoiceValidationResource extends Resource
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -524,9 +505,9 @@ class InvoiceValidationResource extends Resource
|
|||||||
if ($disk->exists($path)) {
|
if ($disk->exists($path)) {
|
||||||
$disk->delete($path);
|
$disk->delete($path);
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
} elseif (! empty($uniqueMissingSerials)) {
|
||||||
else if (!empty($uniqueMissingSerials)) {
|
|
||||||
Notification::make()
|
Notification::make()
|
||||||
->title('Missing Serial Numbers')
|
->title('Missing Serial Numbers')
|
||||||
->body("The following item codes doesn't have valid serial number:<br>".implode(', ', $uniqueMissingSerials))
|
->body("The following item codes doesn't have valid serial number:<br>".implode(', ', $uniqueMissingSerials))
|
||||||
@@ -535,9 +516,9 @@ class InvoiceValidationResource extends Resource
|
|||||||
if ($disk->exists($path)) {
|
if ($disk->exists($path)) {
|
||||||
$disk->delete($path);
|
$disk->delete($path);
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
} elseif (! empty($uniqueSerialCodes)) {
|
||||||
else if (!empty($uniqueSerialCodes)) {
|
|
||||||
Notification::make()
|
Notification::make()
|
||||||
->title('Invalid Serial Number')
|
->title('Invalid Serial Number')
|
||||||
->body('The following serial numbers should contain minimum 9 digit alpha numeric values:<br>'.implode(', ', $uniqueSerialCodes))
|
->body('The following serial numbers should contain minimum 9 digit alpha numeric values:<br>'.implode(', ', $uniqueSerialCodes))
|
||||||
@@ -546,9 +527,9 @@ class InvoiceValidationResource extends Resource
|
|||||||
if ($disk->exists($path)) {
|
if ($disk->exists($path)) {
|
||||||
$disk->delete($path);
|
$disk->delete($path);
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
} elseif (! empty($duplicateSerialCodes)) {
|
||||||
else if (!empty($duplicateSerialCodes)) {
|
|
||||||
Notification::make()
|
Notification::make()
|
||||||
->title('Duplicate Serial Numbers')
|
->title('Duplicate Serial Numbers')
|
||||||
->body('The following serial numbers are already exist in imported excel:<br>'.implode(', ', $duplicateSerialCodes))
|
->body('The following serial numbers are already exist in imported excel:<br>'.implode(', ', $duplicateSerialCodes))
|
||||||
@@ -557,6 +538,7 @@ class InvoiceValidationResource extends Resource
|
|||||||
if ($disk->exists($path)) {
|
if ($disk->exists($path)) {
|
||||||
$disk->delete($path);
|
$disk->delete($path);
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -569,6 +551,7 @@ class InvoiceValidationResource extends Resource
|
|||||||
if ($disk->exists($path)) {
|
if ($disk->exists($path)) {
|
||||||
$disk->delete($path);
|
$disk->delete($path);
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -584,8 +567,7 @@ class InvoiceValidationResource extends Resource
|
|||||||
|
|
||||||
$missingCodes = array_diff($uniqueCodes, $matchedCodes);
|
$missingCodes = array_diff($uniqueCodes, $matchedCodes);
|
||||||
|
|
||||||
if (!empty($missingCodes))
|
if (! empty($missingCodes)) {
|
||||||
{
|
|
||||||
$missingCount = count($missingCodes);
|
$missingCount = count($missingCodes);
|
||||||
|
|
||||||
$message = $missingCount > 10 ? "'$missingCount' item codes are not found in database." : 'The following item codes are not found in database:<br>'.implode(', ', $missingCodes);
|
$message = $missingCount > 10 ? "'$missingCount' item codes are not found in database." : 'The following item codes are not found in database:<br>'.implode(', ', $missingCodes);
|
||||||
@@ -599,6 +581,7 @@ class InvoiceValidationResource extends Resource
|
|||||||
if ($disk->exists($path)) {
|
if ($disk->exists($path)) {
|
||||||
$disk->delete($path);
|
$disk->delete($path);
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -608,8 +591,7 @@ class InvoiceValidationResource extends Resource
|
|||||||
->pluck('item.code')
|
->pluck('item.code')
|
||||||
->toArray();
|
->toArray();
|
||||||
|
|
||||||
if (count($invalidCodes) > 10)
|
if (count($invalidCodes) > 10) {
|
||||||
{
|
|
||||||
Notification::make()
|
Notification::make()
|
||||||
->title('Invalid item codes found')
|
->title('Invalid item codes found')
|
||||||
->body(''.count($invalidCodes).'item codes found have material type.')
|
->body(''.count($invalidCodes).'item codes found have material type.')
|
||||||
@@ -619,10 +601,9 @@ class InvoiceValidationResource extends Resource
|
|||||||
if ($disk->exists($path)) {
|
if ($disk->exists($path)) {
|
||||||
$disk->delete($path);
|
$disk->delete($path);
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
} elseif (count($invalidCodes) > 0) {
|
||||||
else if (count($invalidCodes) > 0)
|
|
||||||
{
|
|
||||||
Notification::make()
|
Notification::make()
|
||||||
->title('Invalid item codes found')
|
->title('Invalid item codes found')
|
||||||
->body('Material invoice Item Codes found : '.implode(', ', $invalidCodes))
|
->body('Material invoice Item Codes found : '.implode(', ', $invalidCodes))
|
||||||
@@ -632,10 +613,9 @@ class InvoiceValidationResource extends Resource
|
|||||||
if ($disk->exists($path)) {
|
if ($disk->exists($path)) {
|
||||||
$disk->delete($path);
|
$disk->delete($path);
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
// Save full file path to session
|
// Save full file path to session
|
||||||
session(['uploaded_invoice_path' => $fullPath]);
|
session(['uploaded_invoice_path' => $fullPath]);
|
||||||
Notification::make()
|
Notification::make()
|
||||||
@@ -656,6 +636,7 @@ class InvoiceValidationResource extends Resource
|
|||||||
// ->options(Plant::pluck('name', 'id')->toArray()) // Fetch plant names and IDs
|
// ->options(Plant::pluck('name', 'id')->toArray()) // Fetch plant names and IDs
|
||||||
->options(function (callable $get) {
|
->options(function (callable $get) {
|
||||||
$userHas = Filament::auth()->user()->plant_id;
|
$userHas = Filament::auth()->user()->plant_id;
|
||||||
|
|
||||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
|
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
|
||||||
})
|
})
|
||||||
->label('Select Plant')
|
->label('Select Plant')
|
||||||
@@ -695,42 +676,37 @@ class InvoiceValidationResource extends Resource
|
|||||||
$fullPath = Storage::disk('local')->path($path);
|
$fullPath = Storage::disk('local')->path($path);
|
||||||
|
|
||||||
$totQuan = InvoiceValidation::where('invoice_number', $originalNameOnly)->count();
|
$totQuan = InvoiceValidation::where('invoice_number', $originalNameOnly)->count();
|
||||||
if ($totQuan > 0)
|
if ($totQuan > 0) {
|
||||||
{
|
|
||||||
$scanMQuan = InvoiceValidation::where('invoice_number', $originalNameOnly)->whereNotNull('serial_number')->where('serial_number', '!=', '')->count();
|
$scanMQuan = InvoiceValidation::where('invoice_number', $originalNameOnly)->whereNotNull('serial_number')->where('serial_number', '!=', '')->count();
|
||||||
if ($totQuan == $scanMQuan)
|
if ($totQuan == $scanMQuan) {
|
||||||
{
|
|
||||||
$invoiceFirst = InvoiceValidation::with('plant')->where('invoice_number', $originalNameOnly)->first();
|
$invoiceFirst = InvoiceValidation::with('plant')->where('invoice_number', $originalNameOnly)->first();
|
||||||
$plantName = $invoiceFirst ? (String)$invoiceFirst->plant->name : null;
|
$plantName = $invoiceFirst ? (string) $invoiceFirst->plant->name : null;
|
||||||
|
|
||||||
Notification::make()
|
Notification::make()
|
||||||
->title("Material invoice number : '$originalNameOnly' already completed the scanning process for plant : '$plantName'.")
|
->title("Material invoice number : '$originalNameOnly' already completed the scanning process for plant : '$plantName'.")
|
||||||
->danger()
|
->danger()
|
||||||
->send();
|
->send();
|
||||||
|
|
||||||
if ($disk->exists($path))
|
if ($disk->exists($path)) {
|
||||||
{
|
|
||||||
$disk->delete($path);
|
$disk->delete($path);
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
$invoiceFirst = InvoiceValidation::with('plant')->where('invoice_number', $originalNameOnly)->first();
|
$invoiceFirst = InvoiceValidation::with('plant')->where('invoice_number', $originalNameOnly)->first();
|
||||||
// $plantCode = $invoiceFirst ? (String)$invoiceFirst->plant->code : null;
|
// $plantCode = $invoiceFirst ? (String)$invoiceFirst->plant->code : null;
|
||||||
$plantName = $invoiceFirst ? (String)$invoiceFirst->plant->name : null;
|
$plantName = $invoiceFirst ? (string) $invoiceFirst->plant->name : null;
|
||||||
$invoicePlantId = $invoiceFirst->plant_id;
|
$invoicePlantId = $invoiceFirst->plant_id;
|
||||||
if ($plantId != $invoicePlantId)
|
if ($plantId != $invoicePlantId) {
|
||||||
{
|
|
||||||
Notification::make()
|
Notification::make()
|
||||||
->title("Material invoice number : '$originalNameOnly' already exists for plant : '$plantName'.<br>Choose the valid 'Plant' to proceed!")
|
->title("Material invoice number : '$originalNameOnly' already exists for plant : '$plantName'.<br>Choose the valid 'Plant' to proceed!")
|
||||||
->danger()
|
->danger()
|
||||||
->send();
|
->send();
|
||||||
|
|
||||||
if ($disk->exists($path))
|
if ($disk->exists($path)) {
|
||||||
{
|
|
||||||
$disk->delete($path);
|
$disk->delete($path);
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -739,8 +715,7 @@ class InvoiceValidationResource extends Resource
|
|||||||
$totQuan = InvoiceValidation::where('invoice_number', $originalNameOnly)->where('plant_id', $plantId)->count();
|
$totQuan = InvoiceValidation::where('invoice_number', $originalNameOnly)->where('plant_id', $plantId)->count();
|
||||||
$scanMQuan = InvoiceValidation::where('invoice_number', $originalNameOnly)->whereNotNull('serial_number')->where('serial_number', '!=', '')->where('plant_id', $plantId)->count();
|
$scanMQuan = InvoiceValidation::where('invoice_number', $originalNameOnly)->whereNotNull('serial_number')->where('serial_number', '!=', '')->where('plant_id', $plantId)->count();
|
||||||
|
|
||||||
if ($totQuan > 0 && $totQuan == $scanMQuan)
|
if ($totQuan > 0 && $totQuan == $scanMQuan) {
|
||||||
{
|
|
||||||
Notification::make()
|
Notification::make()
|
||||||
->title('Material invoice already completed the scanning process for selected plant.')
|
->title('Material invoice already completed the scanning process for selected plant.')
|
||||||
->danger()
|
->danger()
|
||||||
@@ -748,15 +723,14 @@ class InvoiceValidationResource extends Resource
|
|||||||
if ($disk->exists($path)) {
|
if ($disk->exists($path)) {
|
||||||
$disk->delete($path);
|
$disk->delete($path);
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($fullPath && file_exists($fullPath))
|
if ($fullPath && file_exists($fullPath)) {
|
||||||
{
|
|
||||||
$rows = Excel::toArray(null, $fullPath)[0];
|
$rows = Excel::toArray(null, $fullPath)[0];
|
||||||
|
|
||||||
if ((count($rows) - 1) <= 0)
|
if ((count($rows) - 1) <= 0) {
|
||||||
{
|
|
||||||
Notification::make()
|
Notification::make()
|
||||||
->title('Records Not Found')
|
->title('Records Not Found')
|
||||||
->body("Import the valid 'Material Invoice' file to proceed..!")
|
->body("Import the valid 'Material Invoice' file to proceed..!")
|
||||||
@@ -766,6 +740,7 @@ class InvoiceValidationResource extends Resource
|
|||||||
if ($disk->exists($path)) {
|
if ($disk->exists($path)) {
|
||||||
$disk->delete($path);
|
$disk->delete($path);
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -776,9 +751,10 @@ class InvoiceValidationResource extends Resource
|
|||||||
$invalidMaterialQuan = [];
|
$invalidMaterialQuan = [];
|
||||||
$validRowsFound = false;
|
$validRowsFound = false;
|
||||||
|
|
||||||
foreach ($rows as $index => $row)
|
foreach ($rows as $index => $row) {
|
||||||
{
|
if ($index == 0) {
|
||||||
if ($index == 0) continue; // Skip header
|
continue;
|
||||||
|
} // Skip header
|
||||||
|
|
||||||
$materialCode = trim($row[0]);
|
$materialCode = trim($row[0]);
|
||||||
$materialQuantity = trim($row[1]);
|
$materialQuantity = trim($row[1]);
|
||||||
@@ -788,33 +764,21 @@ class InvoiceValidationResource extends Resource
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (! empty($materialCode)) {
|
if (! empty($materialCode)) {
|
||||||
if (Str::length($materialCode) < 6 || !ctype_alnum($materialCode))
|
if (Str::length($materialCode) < 6 || ! ctype_alnum($materialCode)) {
|
||||||
{
|
|
||||||
$invalidMatCodes[] = $materialCode;
|
$invalidMatCodes[] = $materialCode;
|
||||||
}
|
} else {
|
||||||
else
|
if ($materialQuantity == 0) {
|
||||||
{
|
|
||||||
if ($materialQuantity == 0)
|
|
||||||
{
|
|
||||||
$invalidMaterialQuan[] = $materialCode;
|
$invalidMaterialQuan[] = $materialCode;
|
||||||
}
|
} elseif (empty($materialQuantity)) {
|
||||||
else if (empty($materialQuantity))
|
|
||||||
{
|
|
||||||
$missingQuantities[] = $materialCode;
|
$missingQuantities[] = $materialCode;
|
||||||
}
|
} elseif (! is_numeric($materialQuantity)) {
|
||||||
else if (!is_numeric($materialQuantity))
|
|
||||||
{
|
|
||||||
$invalidMatQuan[] = $materialCode;
|
$invalidMatQuan[] = $materialCode;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
$materialCodes[] = $materialCode;
|
$materialCodes[] = $materialCode;
|
||||||
$validRowsFound = true;
|
$validRowsFound = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -834,32 +798,35 @@ class InvoiceValidationResource extends Resource
|
|||||||
if ($disk->exists($path)) {
|
if ($disk->exists($path)) {
|
||||||
$disk->delete($path);
|
$disk->delete($path);
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! empty($uniqueaplhaMat)) {
|
if (! empty($uniqueaplhaMat)) {
|
||||||
Notification::make()
|
Notification::make()
|
||||||
->title('Invalid Material Quantity')
|
->title('Invalid Material Quantity')
|
||||||
->body("The following item codes material quantity must be a numeric values :<br>" . implode(', ', $uniqueaplhaMat))
|
->body('The following item codes material quantity must be a numeric values :<br>'.implode(', ', $uniqueaplhaMat))
|
||||||
->danger()
|
->danger()
|
||||||
->send();
|
->send();
|
||||||
|
|
||||||
if ($disk->exists($path)) {
|
if ($disk->exists($path)) {
|
||||||
$disk->delete($path);
|
$disk->delete($path);
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! empty($uniqueZeroMat)) {
|
if (! empty($uniqueZeroMat)) {
|
||||||
Notification::make()
|
Notification::make()
|
||||||
->title('Invalid Material Quantity')
|
->title('Invalid Material Quantity')
|
||||||
->body("The following item codes material quantity should be greater than 0:<br>" . implode(', ', $uniqueZeroMat))
|
->body('The following item codes material quantity should be greater than 0:<br>'.implode(', ', $uniqueZeroMat))
|
||||||
->danger()
|
->danger()
|
||||||
->send();
|
->send();
|
||||||
|
|
||||||
if ($disk->exists($path)) {
|
if ($disk->exists($path)) {
|
||||||
$disk->delete($path);
|
$disk->delete($path);
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -873,6 +840,7 @@ class InvoiceValidationResource extends Resource
|
|||||||
if ($disk->exists($path)) {
|
if ($disk->exists($path)) {
|
||||||
$disk->delete($path);
|
$disk->delete($path);
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -886,6 +854,7 @@ class InvoiceValidationResource extends Resource
|
|||||||
if ($disk->exists($path)) {
|
if ($disk->exists($path)) {
|
||||||
$disk->delete($path);
|
$disk->delete($path);
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -901,8 +870,7 @@ class InvoiceValidationResource extends Resource
|
|||||||
|
|
||||||
$missingCodes = array_diff($uniqueCodes, $matchedCodes);
|
$missingCodes = array_diff($uniqueCodes, $matchedCodes);
|
||||||
|
|
||||||
if (!empty($missingCodes))
|
if (! empty($missingCodes)) {
|
||||||
{
|
|
||||||
$missingCount = count($missingCodes);
|
$missingCount = count($missingCodes);
|
||||||
|
|
||||||
$message = $missingCount > 10
|
$message = $missingCount > 10
|
||||||
@@ -918,6 +886,7 @@ class InvoiceValidationResource extends Resource
|
|||||||
if ($disk->exists($path)) {
|
if ($disk->exists($path)) {
|
||||||
$disk->delete($path);
|
$disk->delete($path);
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -926,8 +895,7 @@ class InvoiceValidationResource extends Resource
|
|||||||
->pluck('item.code')
|
->pluck('item.code')
|
||||||
->toArray();
|
->toArray();
|
||||||
|
|
||||||
if (count($invalidCodes) > 10)
|
if (count($invalidCodes) > 10) {
|
||||||
{
|
|
||||||
$invalidCodes = array_unique($invalidCodes);
|
$invalidCodes = array_unique($invalidCodes);
|
||||||
Notification::make()
|
Notification::make()
|
||||||
->title('Invalid item codes found')
|
->title('Invalid item codes found')
|
||||||
@@ -938,10 +906,9 @@ class InvoiceValidationResource extends Resource
|
|||||||
if ($disk->exists($path)) {
|
if ($disk->exists($path)) {
|
||||||
$disk->delete($path);
|
$disk->delete($path);
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
} elseif (count($invalidCodes) > 0) {
|
||||||
else if (count($invalidCodes) > 0)
|
|
||||||
{
|
|
||||||
$invalidCodes = array_unique($invalidCodes);
|
$invalidCodes = array_unique($invalidCodes);
|
||||||
Notification::make()
|
Notification::make()
|
||||||
->title('Invalid item codes found')
|
->title('Invalid item codes found')
|
||||||
@@ -952,6 +919,7 @@ class InvoiceValidationResource extends Resource
|
|||||||
if ($disk->exists($path)) {
|
if ($disk->exists($path)) {
|
||||||
$disk->delete($path);
|
$disk->delete($path);
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -959,24 +927,22 @@ class InvoiceValidationResource extends Resource
|
|||||||
$zeroQtyCodes = [];
|
$zeroQtyCodes = [];
|
||||||
$notDivisibleCodes = [];
|
$notDivisibleCodes = [];
|
||||||
|
|
||||||
foreach ($matchedItems as $sticker)
|
foreach ($matchedItems as $sticker) {
|
||||||
{
|
|
||||||
$code = $sticker->item->code;
|
$code = $sticker->item->code;
|
||||||
$materialType = $sticker->material_type;
|
$materialType = $sticker->material_type;
|
||||||
|
|
||||||
if ($materialType == 2)
|
if ($materialType == 2) {
|
||||||
{
|
|
||||||
$bundleQty = $sticker->bundle_quantity ?? 0;
|
$bundleQty = $sticker->bundle_quantity ?? 0;
|
||||||
$totalExcelQty = 0;
|
$totalExcelQty = 0;
|
||||||
|
|
||||||
foreach ($rows as $index => $row)
|
foreach ($rows as $index => $row) {
|
||||||
{
|
if ($index == 0) {
|
||||||
if ($index == 0) continue; // Skip header
|
continue;
|
||||||
|
} // Skip header
|
||||||
|
|
||||||
$excelCode = trim($row[0]);
|
$excelCode = trim($row[0]);
|
||||||
$excelMatQty = trim($row[1]);
|
$excelMatQty = trim($row[1]);
|
||||||
|
|
||||||
|
|
||||||
if ($excelCode == $code && is_numeric($excelMatQty)) {
|
if ($excelCode == $code && is_numeric($excelMatQty)) {
|
||||||
$totalExcelQty += $excelMatQty; // Sum up the quantities
|
$totalExcelQty += $excelMatQty; // Sum up the quantities
|
||||||
}
|
}
|
||||||
@@ -993,7 +959,9 @@ class InvoiceValidationResource extends Resource
|
|||||||
}
|
}
|
||||||
|
|
||||||
$showValidationNotification = function (array $codes, string $message) {
|
$showValidationNotification = function (array $codes, string $message) {
|
||||||
if (count($codes) == 0) return;
|
if (count($codes) == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$uniqueCodes = array_unique($codes);
|
$uniqueCodes = array_unique($codes);
|
||||||
$codeList = implode(', ', $uniqueCodes);
|
$codeList = implode(', ', $uniqueCodes);
|
||||||
@@ -1009,19 +977,17 @@ class InvoiceValidationResource extends Resource
|
|||||||
$zeroQtyCodes = array_unique($zeroQtyCodes);
|
$zeroQtyCodes = array_unique($zeroQtyCodes);
|
||||||
$notDivisibleCodes = array_unique($notDivisibleCodes);
|
$notDivisibleCodes = array_unique($notDivisibleCodes);
|
||||||
|
|
||||||
$showValidationNotification($nonNumericQtyCodes, "The following item codes contains invalid bundle quantity:");
|
$showValidationNotification($nonNumericQtyCodes, 'The following item codes contains invalid bundle quantity:');
|
||||||
$showValidationNotification($zeroQtyCodes, "The following item codes quantity should be greater than '0':");
|
$showValidationNotification($zeroQtyCodes, "The following item codes quantity should be greater than '0':");
|
||||||
$showValidationNotification($notDivisibleCodes, "The following item codes quantity is not divisible by bundle quantity.");
|
$showValidationNotification($notDivisibleCodes, 'The following item codes quantity is not divisible by bundle quantity.');
|
||||||
|
|
||||||
if ($nonNumericQtyCodes || $zeroQtyCodes || $notDivisibleCodes) {
|
if ($nonNumericQtyCodes || $zeroQtyCodes || $notDivisibleCodes) {
|
||||||
if ($disk->exists($path))
|
if ($disk->exists($path)) {
|
||||||
{
|
|
||||||
$disk->delete($path);
|
$disk->delete($path);
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
// Save full file path to session
|
// Save full file path to session
|
||||||
session(['uploaded_material_invoice' => $fullPath]);
|
session(['uploaded_material_invoice' => $fullPath]);
|
||||||
Notification::make()
|
Notification::make()
|
||||||
@@ -1052,11 +1018,50 @@ class InvoiceValidationResource extends Resource
|
|||||||
Radio::make('invoice_type')
|
Radio::make('invoice_type')
|
||||||
->label('Type ?')
|
->label('Type ?')
|
||||||
->boolean()
|
->boolean()
|
||||||
->options([
|
// ->options([
|
||||||
|
// 'Serial' => 'Serial',
|
||||||
|
// 'Material' => 'Material',
|
||||||
|
// ])
|
||||||
|
->options(function () {
|
||||||
|
$userRights = Filament::auth()->user();
|
||||||
|
$hasBoth = ($userRights->hasRole(['Super Admin', 'Sales Employee', 'Sales Supervisor Hub', 'Sales Manager']) ?? null);
|
||||||
|
|
||||||
|
$hasSerial = ($userRights->hasRole(['Sales Supervisor 1', 'Sales Supervisor Inventory', 'Sales Employee Inventory']) ?? null);
|
||||||
|
|
||||||
|
$hasMaterial = $userRights->hasRole('Sales Supervisor 2') ?? null;
|
||||||
|
|
||||||
|
$retRes = [
|
||||||
'Serial' => 'Serial',
|
'Serial' => 'Serial',
|
||||||
'Material' => 'Material'
|
'Material' => 'Material',
|
||||||
])
|
];
|
||||||
->default('Serial')
|
|
||||||
|
if ($hasBoth) {
|
||||||
|
return $retRes;
|
||||||
|
} elseif ($hasSerial) {
|
||||||
|
return ['Serial' => 'Serial'];
|
||||||
|
} elseif ($hasMaterial) {
|
||||||
|
return ['Material' => 'Material'];
|
||||||
|
} else {
|
||||||
|
return ['Serial' => 'Serial']; // return [];
|
||||||
|
}
|
||||||
|
})
|
||||||
|
// ->default('Serial')
|
||||||
|
->default(function () {
|
||||||
|
$userRights = Filament::auth()->user();
|
||||||
|
$hasBoth = ($userRights->hasRole(['Super Admin', 'Sales Employee', 'Sales Supervisor Hub', 'Sales Manager']) ?? null);
|
||||||
|
|
||||||
|
$hasSerial = ($userRights->hasRole(['Sales Supervisor 1', 'Sales Supervisor Inventory', 'Sales Employee Inventory']) ?? null);
|
||||||
|
|
||||||
|
$hasMaterial = $userRights->hasRole('Sales Supervisor 2') ?? null;
|
||||||
|
|
||||||
|
if ($hasBoth || $hasSerial) {
|
||||||
|
return 'Serial';
|
||||||
|
} elseif ($hasMaterial) {
|
||||||
|
return 'Material';
|
||||||
|
} else {
|
||||||
|
return 'Serial'; // return [];
|
||||||
|
}
|
||||||
|
})
|
||||||
->inlineLabel(false)
|
->inlineLabel(false)
|
||||||
->inline(),
|
->inline(),
|
||||||
Select::make('Plant')
|
Select::make('Plant')
|
||||||
@@ -1067,6 +1072,7 @@ class InvoiceValidationResource extends Resource
|
|||||||
// })
|
// })
|
||||||
->options(function (callable $get) {
|
->options(function (callable $get) {
|
||||||
$userHas = Filament::auth()->user()->plant_id;
|
$userHas = Filament::auth()->user()->plant_id;
|
||||||
|
|
||||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
|
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
|
||||||
})
|
})
|
||||||
->reactive()
|
->reactive()
|
||||||
@@ -1085,6 +1091,7 @@ class InvoiceValidationResource extends Resource
|
|||||||
->nullable()
|
->nullable()
|
||||||
->options(function (callable $get) {
|
->options(function (callable $get) {
|
||||||
$pId = $get('Plant');
|
$pId = $get('Plant');
|
||||||
|
|
||||||
// if (empty($pId)) {
|
// if (empty($pId)) {
|
||||||
// return [];
|
// return [];
|
||||||
// }
|
// }
|
||||||
@@ -1111,12 +1118,9 @@ class InvoiceValidationResource extends Resource
|
|||||||
->nullable()
|
->nullable()
|
||||||
->options(function (callable $get) {
|
->options(function (callable $get) {
|
||||||
$plantId = $get('Plant');
|
$plantId = $get('Plant');
|
||||||
if (!$plantId)
|
if (! $plantId) {
|
||||||
{
|
|
||||||
return InvoiceValidation::whereNotNull('operator_id')->select('operator_id')->distinct()->pluck('operator_id', 'operator_id');
|
return InvoiceValidation::whereNotNull('operator_id')->select('operator_id')->distinct()->pluck('operator_id', 'operator_id');
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
return InvoiceValidation::where('plant_id', $plantId)->whereNotNull('operator_id')->select('operator_id')->distinct()->pluck('operator_id', 'operator_id');
|
return InvoiceValidation::where('plant_id', $plantId)->whereNotNull('operator_id')->select('operator_id')->distinct()->pluck('operator_id', 'operator_id');
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -1136,13 +1140,13 @@ class InvoiceValidationResource extends Resource
|
|||||||
->query(function ($query, array $data) {
|
->query(function ($query, array $data) {
|
||||||
// Hide all records initially if no filters are applied
|
// Hide all records initially if no filters are applied
|
||||||
if (empty($data['invoice_type']) || (empty($data['Plant']) && empty($data['invoice_number']) && empty($data['serial_number']) && empty($data['created_from']) && empty($data['created_to']) && empty($data['operator_id']) && empty($data['scanned_status']) && empty($data['sticker_master_id']))) {
|
if (empty($data['invoice_type']) || (empty($data['Plant']) && empty($data['invoice_number']) && empty($data['serial_number']) && empty($data['created_from']) && empty($data['created_to']) && empty($data['operator_id']) && empty($data['scanned_status']) && empty($data['sticker_master_id']))) {
|
||||||
if (empty($data['invoice_type']))
|
if (empty($data['invoice_type'])) {
|
||||||
{
|
|
||||||
Notification::make()
|
Notification::make()
|
||||||
->title('Please, choose invoice type to filter.')
|
->title('Please, choose invoice type to filter.')
|
||||||
->danger()
|
->danger()
|
||||||
->send();
|
->send();
|
||||||
}
|
}
|
||||||
|
|
||||||
return $query->whereRaw('1 = 0');
|
return $query->whereRaw('1 = 0');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1154,7 +1158,7 @@ class InvoiceValidationResource extends Resource
|
|||||||
$query->whereNotNull('scanned_status')->where('scanned_status', '!=', '');
|
$query->whereNotNull('scanned_status')->where('scanned_status', '!=', '');
|
||||||
} elseif ($data['scanned_status'] == 'Pending') {
|
} elseif ($data['scanned_status'] == 'Pending') {
|
||||||
// $query->whereNull('scanned_status')->orWhere('scanned_status', '');
|
// $query->whereNull('scanned_status')->orWhere('scanned_status', '');
|
||||||
$query->where(function ($query) use ($data) {
|
$query->where(function ($query) {
|
||||||
// if (empty($data['scanned_status']) || $data['scanned_status'] == 'Pending') {
|
// if (empty($data['scanned_status']) || $data['scanned_status'] == 'Pending') {
|
||||||
$query->whereNull('scanned_status')->orWhere('scanned_status', '!=', 'Scanned');
|
$query->whereNull('scanned_status')->orWhere('scanned_status', '!=', 'Scanned');
|
||||||
// }
|
// }
|
||||||
@@ -1168,7 +1172,7 @@ class InvoiceValidationResource extends Resource
|
|||||||
if ($data['scanned_status'] == 'Scanned') {
|
if ($data['scanned_status'] == 'Scanned') {
|
||||||
$query->whereNotNull('serial_number')->where('serial_number', '!=', '');
|
$query->whereNotNull('serial_number')->where('serial_number', '!=', '');
|
||||||
} elseif ($data['scanned_status'] == 'Pending') {
|
} elseif ($data['scanned_status'] == 'Pending') {
|
||||||
$query->where(function ($query) use ($data) {
|
$query->where(function ($query) {
|
||||||
$query->whereNull('serial_number')->orWhere('serial_number', '=', '');
|
$query->whereNull('serial_number')->orWhere('serial_number', '=', '');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -1246,7 +1250,7 @@ class InvoiceValidationResource extends Resource
|
|||||||
}
|
}
|
||||||
|
|
||||||
return $indicators;
|
return $indicators;
|
||||||
})
|
}),
|
||||||
])
|
])
|
||||||
->filtersFormMaxHeight('280px')
|
->filtersFormMaxHeight('280px')
|
||||||
->actions([
|
->actions([
|
||||||
@@ -1258,7 +1262,7 @@ class InvoiceValidationResource extends Resource
|
|||||||
Tables\Actions\DeleteBulkAction::make(),
|
Tables\Actions\DeleteBulkAction::make(),
|
||||||
Tables\Actions\ForceDeleteBulkAction::make(),
|
Tables\Actions\ForceDeleteBulkAction::make(),
|
||||||
Tables\Actions\RestoreBulkAction::make(),
|
Tables\Actions\RestoreBulkAction::make(),
|
||||||
FilamentExportBulkAction::make('export')
|
FilamentExportBulkAction::make('export'),
|
||||||
]),
|
]),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user