Added view rights against plant on view report and Updated alignments and load available item code logic on resource
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 10s
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Successful in 13s
Gemini PR Review / Gemini PR Review (pull_request) Failing after 28s
Laravel Pint / pint (pull_request) Successful in 2m31s
Laravel Larastan / larastan (pull_request) Failing after 3m37s
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 10s
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Successful in 13s
Gemini PR Review / Gemini PR Review (pull_request) Failing after 28s
Laravel Pint / pint (pull_request) Successful in 2m31s
Laravel Larastan / larastan (pull_request) Failing after 3m37s
This commit is contained in:
@@ -5,14 +5,10 @@ namespace App\Filament\Resources;
|
|||||||
use App\Filament\Exports\WeightValidationExporter;
|
use App\Filament\Exports\WeightValidationExporter;
|
||||||
use App\Filament\Imports\WeightValidationImporter;
|
use App\Filament\Imports\WeightValidationImporter;
|
||||||
use App\Filament\Resources\WeightValidationResource\Pages;
|
use App\Filament\Resources\WeightValidationResource\Pages;
|
||||||
use App\Filament\Resources\WeightValidationResource\RelationManagers;
|
|
||||||
use App\Models\Item;
|
use App\Models\Item;
|
||||||
use App\Models\Line;
|
|
||||||
use App\Models\Plant;
|
use App\Models\Plant;
|
||||||
use App\Models\QualityValidation;
|
|
||||||
use App\Models\StickerMaster;
|
use App\Models\StickerMaster;
|
||||||
use App\Models\WeightValidation;
|
use App\Models\WeightValidation;
|
||||||
use Filament\Actions\Action;
|
|
||||||
use Filament\Facades\Filament;
|
use Filament\Facades\Filament;
|
||||||
use Filament\Forms;
|
use Filament\Forms;
|
||||||
use Filament\Forms\Components\DateTimePicker;
|
use Filament\Forms\Components\DateTimePicker;
|
||||||
@@ -26,14 +22,13 @@ use Filament\Resources\Resource;
|
|||||||
use Filament\Tables;
|
use Filament\Tables;
|
||||||
use Filament\Tables\Actions\ExportAction;
|
use Filament\Tables\Actions\ExportAction;
|
||||||
use Filament\Tables\Actions\ImportAction;
|
use Filament\Tables\Actions\ImportAction;
|
||||||
|
use Filament\Tables\Filters\Filter;
|
||||||
use Filament\Tables\Table;
|
use Filament\Tables\Table;
|
||||||
use Filament\Widgets\StatsOverviewWidget\Stat;
|
|
||||||
use Illuminate\Database\Eloquent\Builder;
|
use Illuminate\Database\Eloquent\Builder;
|
||||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||||
use Illuminate\Support\Facades\Storage;
|
use Illuminate\Support\Facades\Storage;
|
||||||
use Maatwebsite\Excel\Facades\Excel;
|
use Maatwebsite\Excel\Facades\Excel;
|
||||||
use Str;
|
use Str;
|
||||||
use Filament\Tables\Filters\Filter;
|
|
||||||
|
|
||||||
class WeightValidationResource extends Resource
|
class WeightValidationResource extends Resource
|
||||||
{
|
{
|
||||||
@@ -51,6 +46,7 @@ class WeightValidationResource extends Resource
|
|||||||
->relationship('plant', 'name')
|
->relationship('plant', 'name')
|
||||||
->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();
|
||||||
})
|
})
|
||||||
->required(),
|
->required(),
|
||||||
@@ -80,7 +76,7 @@ class WeightValidationResource extends Resource
|
|||||||
Forms\Components\TextInput::make('picked_weight')
|
Forms\Components\TextInput::make('picked_weight')
|
||||||
->label('Picked Weight'),
|
->label('Picked Weight'),
|
||||||
Forms\Components\TextInput::make('scanned_by')
|
Forms\Components\TextInput::make('scanned_by')
|
||||||
->label('Scanned By')
|
->label('Scanned By'),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -98,6 +94,7 @@ class WeightValidationResource 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('plant.name')
|
Tables\Columns\TextColumn::make('plant.name')
|
||||||
@@ -157,9 +154,6 @@ class WeightValidationResource extends Resource
|
|||||||
->sortable()
|
->sortable()
|
||||||
->toggleable(isToggledHiddenByDefault: true),
|
->toggleable(isToggledHiddenByDefault: true),
|
||||||
])
|
])
|
||||||
// ->filters([
|
|
||||||
// Tables\Filters\TrashedFilter::make(),
|
|
||||||
// ])
|
|
||||||
->filters([
|
->filters([
|
||||||
Tables\Filters\TrashedFilter::make(),
|
Tables\Filters\TrashedFilter::make(),
|
||||||
Filter::make('advanced_filters')
|
Filter::make('advanced_filters')
|
||||||
@@ -173,6 +167,7 @@ class WeightValidationResource 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(),
|
||||||
@@ -180,18 +175,33 @@ class WeightValidationResource extends Resource
|
|||||||
// $set('sticker_master_id', null);
|
// $set('sticker_master_id', null);
|
||||||
// $set('sap_msg_status', null);
|
// $set('sap_msg_status', null);
|
||||||
// }),
|
// }),
|
||||||
|
|
||||||
Select::make('Item Code')
|
Select::make('Item Code')
|
||||||
->label('Search by Item Code')
|
->label('Search by Item Code')
|
||||||
->nullable()
|
->nullable()
|
||||||
|
// ->options(function (callable $get) {
|
||||||
|
// $plantId = $get('Plant');
|
||||||
|
// if (! $plantId) {
|
||||||
|
// return [];
|
||||||
|
// }
|
||||||
|
|
||||||
|
// return Item::where('plant_id', $plantId)->pluck('code', 'id');
|
||||||
|
// })
|
||||||
->options(function (callable $get) {
|
->options(function (callable $get) {
|
||||||
$plantId = $get('Plant');
|
$plantId = $get('Plant');
|
||||||
if (!$plantId) {
|
if (! $plantId) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
return Item::where('plant_id', $plantId)->pluck('code', 'id');
|
|
||||||
|
return Item::whereHas('weightValidations', function ($query) use ($plantId) {
|
||||||
|
if ($plantId) {
|
||||||
|
$query->where('plant_id', $plantId);
|
||||||
|
}
|
||||||
|
})->pluck('code', 'id');
|
||||||
})
|
})
|
||||||
->searchable()
|
->searchable()
|
||||||
->reactive(),
|
->reactive(),
|
||||||
|
|
||||||
TextInput::make('Obd Number')
|
TextInput::make('Obd Number')
|
||||||
->label('OBD Number')
|
->label('OBD Number')
|
||||||
->placeholder('Enter OBD Number'),
|
->placeholder('Enter OBD Number'),
|
||||||
@@ -201,7 +211,7 @@ class WeightValidationResource extends Resource
|
|||||||
->options(function (callable $get) {
|
->options(function (callable $get) {
|
||||||
$plantId = $get('Plant');
|
$plantId = $get('Plant');
|
||||||
|
|
||||||
if (!$plantId) {
|
if (! $plantId) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -243,6 +253,7 @@ class WeightValidationResource extends Resource
|
|||||||
->placeholder(placeholder: 'Select From DateTime')
|
->placeholder(placeholder: 'Select From DateTime')
|
||||||
->reactive()
|
->reactive()
|
||||||
->native(false),
|
->native(false),
|
||||||
|
|
||||||
DateTimePicker::make('created_to')
|
DateTimePicker::make('created_to')
|
||||||
->label('Created To')
|
->label('Created To')
|
||||||
->placeholder(placeholder: 'Select To DateTime')
|
->placeholder(placeholder: 'Select To DateTime')
|
||||||
@@ -250,118 +261,129 @@ class WeightValidationResource extends Resource
|
|||||||
->native(false),
|
->native(false),
|
||||||
])
|
])
|
||||||
->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['Plant']) && empty($data['Item Code']) && empty($data['Line']) && empty($data['Obd Number']) && empty($data['Batch']) && empty($data['Actual Weight']) && empty($data['Vehicle Number']) && empty($data['Heat Number']) && empty($data['Bundle Number']) && empty($data['Scanned By']) && empty($data['created_from']) && empty($data['created_to'])) {
|
if (empty($data['Plant']) && empty($data['Item Code']) && empty($data['Line']) && empty($data['Obd Number']) && empty($data['Batch']) && empty($data['Actual Weight']) && empty($data['Vehicle Number']) && empty($data['Heat Number']) && empty($data['Bundle Number']) && empty($data['Scanned By']) && empty($data['created_from']) && empty($data['created_to'])) {
|
||||||
return $query->whereRaw('1 = 0');
|
return $query->whereRaw('1 = 0');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($data['Plant'])) {
|
if (! empty($data['Plant'])) {
|
||||||
$query->where('plant_id', $data['Plant']);
|
$query->where('plant_id', $data['Plant']);
|
||||||
|
} else {
|
||||||
|
$userHas = Filament::auth()->user()->plant_id;
|
||||||
|
|
||||||
|
if ($userHas && strlen($userHas) > 0) {
|
||||||
|
return $query->whereRaw('1 = 0');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($data['Item Code'])) {
|
if (! empty($data['Item Code'])) {
|
||||||
$query->where('item_id', $data['Item Code']);
|
$query->where('item_id', $data['Item Code']);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($data['Line'])) {
|
if (! empty($data['Line'])) {
|
||||||
$query->where('line_number', $data['Line']);
|
$query->where('line_number', $data['Line']);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($data['Obd Number'])) {
|
if (! empty($data['Obd Number'])) {
|
||||||
$query->where('obd_number', $data['Obd Number']);
|
$query->where('obd_number', $data['Obd Number']);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($data['Batch'])) {
|
if (! empty($data['Batch'])) {
|
||||||
$query->where('batch_number', $data['Batch']);
|
$query->where('batch_number', $data['Batch']);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($data['Actual Weight'])) {
|
if (! empty($data['Actual Weight'])) {
|
||||||
$query->where('actual_weight', $data['Actual Weight']);
|
$query->where('actual_weight', $data['Actual Weight']);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($data['Vehicle Number'])) {
|
if (! empty($data['Vehicle Number'])) {
|
||||||
$query->where('vehicle_number',$data['Vehicle Number']);
|
$query->where('vehicle_number', $data['Vehicle Number']);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($data['Heat Number'])) {
|
if (! empty($data['Heat Number'])) {
|
||||||
$query->where('heat_number',$data['Heat Number']);
|
$query->where('heat_number', $data['Heat Number']);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($data['Bundle Number'])) {
|
if (! empty($data['Bundle Number'])) {
|
||||||
$query->where('bundle_number',$data['Bundle Number']);
|
$query->where('bundle_number', $data['Bundle Number']);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($data['Scanned By'])) {
|
if (! empty($data['Scanned By'])) {
|
||||||
$query->where('scanned_by', $data['Scanned By']);
|
$query->where('scanned_by', $data['Scanned By']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (! empty($data['created_from'])) {
|
||||||
if (!empty($data['created_from'])) {
|
|
||||||
$query->where('created_at', '>=', $data['created_from']);
|
$query->where('created_at', '>=', $data['created_from']);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($data['created_to'])) {
|
if (! empty($data['created_to'])) {
|
||||||
$query->where('created_at', '<=', $data['created_to']);
|
$query->where('created_at', '<=', $data['created_to']);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
->indicateUsing(function (array $data) {
|
->indicateUsing(function (array $data) {
|
||||||
$indicators = [];
|
$indicators = [];
|
||||||
|
|
||||||
if (!empty($data['Plant'])) {
|
if (! empty($data['Plant'])) {
|
||||||
$indicators[] = 'Plant: ' . Plant::where('id', $data['Plant'])->value('name');
|
$indicators[] = 'Plant: '.Plant::where('id', $data['Plant'])->value('name');
|
||||||
|
} else {
|
||||||
|
$userHas = Filament::auth()->user()->plant_id;
|
||||||
|
|
||||||
|
if ($userHas && strlen($userHas) > 0) {
|
||||||
|
return 'Plant: Choose plant to filter records.';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($data['Item Code'])) {
|
if (! empty($data['Item Code'])) {
|
||||||
$indicators[] = 'Item Code: ' . $data['Item Code'];
|
$indicators[] = 'Item Code: '.$data['Item Code'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($data['Line'])) {
|
if (! empty($data['Line'])) {
|
||||||
$indicators[] = 'Line: ' . $data['Line'];
|
$indicators[] = 'Line: '.$data['Line'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($data['Obd Number'])) {
|
if (! empty($data['Obd Number'])) {
|
||||||
$indicators[] = 'OBD Number: ' . $data['Obd Number'];
|
$indicators[] = 'OBD Number: '.$data['Obd Number'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($data['Batch'])) {
|
if (! empty($data['Batch'])) {
|
||||||
$indicators[] = 'Batch Number: ' . $data['Batch'];
|
$indicators[] = 'Batch Number: '.$data['Batch'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($data['Actual Weight'])) {
|
if (! empty($data['Actual Weight'])) {
|
||||||
$indicators[] = 'Actual Weight: ' . $data['Actual Weight'];
|
$indicators[] = 'Actual Weight: '.$data['Actual Weight'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($data['Vehicle Number'])) {
|
if (! empty($data['Vehicle Number'])) {
|
||||||
$indicators[] = 'Vehicle Number: ' . $data['Vehicle Number'];
|
$indicators[] = 'Vehicle Number: '.$data['Vehicle Number'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($data['Heat Number'])) {
|
if (! empty($data['Heat Number'])) {
|
||||||
$indicators[] = 'Heat Number: ' . $data['Heat Number'];
|
$indicators[] = 'Heat Number: '.$data['Heat Number'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($data['Bundle Number'])) {
|
if (! empty($data['Bundle Number'])) {
|
||||||
$indicators[] = 'Bundle Number: ' . $data['Bundle Number'];
|
$indicators[] = 'Bundle Number: '.$data['Bundle Number'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($data['Scanned By'])) {
|
if (! empty($data['Scanned By'])) {
|
||||||
$indicators[] = 'Scanned By: ' . $data['Scanned By'];
|
$indicators[] = 'Scanned By: '.$data['Scanned By'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($data['created_from'])) {
|
if (! empty($data['created_from'])) {
|
||||||
$indicators[] = 'From: ' . $data['created_from'];
|
$indicators[] = 'From: '.$data['created_from'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($data['created_to'])) {
|
if (! empty($data['created_to'])) {
|
||||||
$indicators[] = 'To: ' . $data['created_to'];
|
$indicators[] = 'To: '.$data['created_to'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($data['sticker_master_id'])) {
|
if (! empty($data['sticker_master_id'])) {
|
||||||
$itemCode = Item::find($data['sticker_master_id'])->code ?? 'Unknown';
|
$itemCode = Item::find($data['sticker_master_id'])->code ?? 'Unknown';
|
||||||
$indicators[] = 'Item Codes: ' . $itemCode;
|
$indicators[] = 'Item Codes: '.$itemCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $indicators;
|
return $indicators;
|
||||||
})
|
}),
|
||||||
])
|
])
|
||||||
->filtersFormMaxHeight('280px')
|
->filtersFormMaxHeight('280px')
|
||||||
->actions([
|
->actions([
|
||||||
@@ -383,6 +405,7 @@ class WeightValidationResource extends Resource
|
|||||||
// ->options(Plant::pluck('name', 'id')->toArray())
|
// ->options(Plant::pluck('name', 'id')->toArray())
|
||||||
->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')
|
||||||
@@ -401,8 +424,8 @@ class WeightValidationResource extends Resource
|
|||||||
->storeFiles(false) // prevent auto-storing, we will store manually
|
->storeFiles(false) // prevent auto-storing, we will store manually
|
||||||
->reactive()
|
->reactive()
|
||||||
->required()
|
->required()
|
||||||
->disk('local') //'local' refers to the local storage disk defined in config/filesystems.php, typically pointing to storage/app.
|
->disk('local') // 'local' refers to the local storage disk defined in config/filesystems.php, typically pointing to storage/app.
|
||||||
->visible(fn (Get $get) => !empty($get('plant_id')))
|
->visible(fn (Get $get) => ! empty($get('plant_id')))
|
||||||
->directory('uploads/temp'),
|
->directory('uploads/temp'),
|
||||||
])
|
])
|
||||||
->action(function (array $data) {
|
->action(function (array $data) {
|
||||||
@@ -425,20 +448,20 @@ class WeightValidationResource 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 = WeightValidation::where('obd_number',$originalNameOnly)->where('plant_id', $plantId)->count();
|
$totQuan = WeightValidation::where('obd_number', $originalNameOnly)->where('plant_id', $plantId)->count();
|
||||||
$scanSQuan = WeightValidation::where('obd_number',$originalNameOnly)->where('plant_id', $plantId)->whereNotNull('vehicle_number')->where('vehicle_number', '!=', '')->count();
|
$scanSQuan = WeightValidation::where('obd_number', $originalNameOnly)->where('plant_id', $plantId)->whereNotNull('vehicle_number')->where('vehicle_number', '!=', '')->count();
|
||||||
|
|
||||||
if($totQuan == $scanSQuan && $totQuan > 0) {
|
if ($totQuan == $scanSQuan && $totQuan > 0) {
|
||||||
Notification::make()
|
Notification::make()
|
||||||
->title('Completed: OBD invoice')
|
->title('Completed: OBD invoice')
|
||||||
->body('OBD invoice already completed the scanning process for selected plant.')
|
->body('OBD 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -458,7 +481,7 @@ class WeightValidationResource extends Resource
|
|||||||
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 'OBD Invoice' file to proceed..!")
|
->body("Import the valid 'OBD Invoice' file to proceed..!")
|
||||||
@@ -469,6 +492,7 @@ class WeightValidationResource extends Resource
|
|||||||
if ($disk->exists($path)) {
|
if ($disk->exists($path)) {
|
||||||
$disk->delete($path);
|
$disk->delete($path);
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -482,9 +506,10 @@ class WeightValidationResource extends Resource
|
|||||||
$lineNumbers = [];
|
$lineNumbers = [];
|
||||||
$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]);
|
||||||
$lineNumber = trim($row[1]);
|
$lineNumber = trim($row[1]);
|
||||||
@@ -496,32 +521,24 @@ class WeightValidationResource 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;
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
$materialCodes[] = $materialCode;
|
$materialCodes[] = $materialCode;
|
||||||
|
|
||||||
$validData = true;
|
$validData = true;
|
||||||
if(Str::length($lineNumber) < 1 || !is_numeric($lineNumber))
|
if (Str::length($lineNumber) < 1 || ! is_numeric($lineNumber)) {
|
||||||
{
|
|
||||||
$validData = false;
|
$validData = false;
|
||||||
$invalidLines[] = $materialCode;
|
$invalidLines[] = $materialCode;
|
||||||
}
|
} elseif (in_array($lineNumber, $lineNumbers)) {
|
||||||
else if (in_array($lineNumber, $lineNumbers))
|
|
||||||
{
|
|
||||||
$duplicateLines[] = $materialCode;
|
$duplicateLines[] = $materialCode;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
$lineNumbers[] = $lineNumber;
|
$lineNumbers[] = $lineNumber;
|
||||||
}
|
}
|
||||||
if(Str::length($batchNumber) < 8 || !is_numeric($batchNumber))//ctype_alnum
|
if (Str::length($batchNumber) < 8 || ! is_numeric($batchNumber)) {// ctype_alnum
|
||||||
{
|
|
||||||
$validData = false;
|
$validData = false;
|
||||||
$invalidBatch[] = $materialCode;
|
$invalidBatch[] = $materialCode;
|
||||||
}
|
}
|
||||||
@@ -530,29 +547,25 @@ class WeightValidationResource extends Resource
|
|||||||
// $validData = false;
|
// $validData = false;
|
||||||
// $invalidHeat[] = $materialCode;
|
// $invalidHeat[] = $materialCode;
|
||||||
// }
|
// }
|
||||||
if(Str::length($actualWeight) < 1 || !is_numeric($actualWeight))//ctype_alnum
|
if (Str::length($actualWeight) < 1 || ! is_numeric($actualWeight)) {// ctype_alnum
|
||||||
{
|
|
||||||
$validData = false;
|
$validData = false;
|
||||||
$invalidWeight[] = $materialCode;
|
$invalidWeight[] = $materialCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($validData)
|
if ($validData) {
|
||||||
{
|
|
||||||
$validRowsFound = true;
|
$validRowsFound = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$uniqueInvalidCodes = array_unique($invalidMatCodes);
|
$uniqueInvalidCodes = array_unique($invalidMatCodes);
|
||||||
if (!empty($uniqueInvalidCodes)) {
|
if (! empty($uniqueInvalidCodes)) {
|
||||||
Notification::make()
|
Notification::make()
|
||||||
->title('Invalid: Item Codes')
|
->title('Invalid: Item Codes')
|
||||||
->body('The following item codes should contain minimum 6 digit alpha numeric values:<br>' . implode(', ', $uniqueInvalidCodes))
|
->body('The following item codes should contain minimum 6 digit alpha numeric values:<br>'.implode(', ', $uniqueInvalidCodes))
|
||||||
->danger()
|
->danger()
|
||||||
->seconds(2)
|
->seconds(2)
|
||||||
->send();
|
->send();
|
||||||
@@ -560,14 +573,15 @@ class WeightValidationResource extends Resource
|
|||||||
if ($disk->exists($path)) {
|
if ($disk->exists($path)) {
|
||||||
$disk->delete($path);
|
$disk->delete($path);
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$uniqueInvalidLines = array_unique($invalidLines);
|
$uniqueInvalidLines = array_unique($invalidLines);
|
||||||
if (!empty($uniqueInvalidLines)) {
|
if (! empty($uniqueInvalidLines)) {
|
||||||
Notification::make()
|
Notification::make()
|
||||||
->title('Invalid: Line Numbers')
|
->title('Invalid: Line Numbers')
|
||||||
->body('Line number should contain minimum 1 digit numeric values!<br>Following item codes has invalid line number:<br>' . implode(', ', $uniqueInvalidLines))
|
->body('Line number should contain minimum 1 digit numeric values!<br>Following item codes has invalid line number:<br>'.implode(', ', $uniqueInvalidLines))
|
||||||
->danger()
|
->danger()
|
||||||
->seconds(2)
|
->seconds(2)
|
||||||
->send();
|
->send();
|
||||||
@@ -575,14 +589,15 @@ class WeightValidationResource extends Resource
|
|||||||
if ($disk->exists($path)) {
|
if ($disk->exists($path)) {
|
||||||
$disk->delete($path);
|
$disk->delete($path);
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$uniqueDupLines = array_unique($duplicateLines);
|
$uniqueDupLines = array_unique($duplicateLines);
|
||||||
if (!empty($uniqueDupLines)) {
|
if (! empty($uniqueDupLines)) {
|
||||||
Notification::make()
|
Notification::make()
|
||||||
->title('Duplicate: Line Numbers')
|
->title('Duplicate: Line Numbers')
|
||||||
->body('The following item codes contains duplicate line numbers in invoice excel:<br>' . implode(', ', $uniqueDupLines))
|
->body('The following item codes contains duplicate line numbers in invoice excel:<br>'.implode(', ', $uniqueDupLines))
|
||||||
->danger()
|
->danger()
|
||||||
->seconds(2)
|
->seconds(2)
|
||||||
->send();
|
->send();
|
||||||
@@ -590,14 +605,15 @@ class WeightValidationResource extends Resource
|
|||||||
if ($disk->exists($path)) {
|
if ($disk->exists($path)) {
|
||||||
$disk->delete($path);
|
$disk->delete($path);
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$uniqueInvalidBatch = array_unique($invalidBatch);
|
$uniqueInvalidBatch = array_unique($invalidBatch);
|
||||||
if (!empty($uniqueInvalidBatch)) {
|
if (! empty($uniqueInvalidBatch)) {
|
||||||
Notification::make()
|
Notification::make()
|
||||||
->title('Invalid: Batch Numbers')
|
->title('Invalid: Batch Numbers')
|
||||||
->body('Batch number should contain minimum 8 digit numeric values!<br>Following item codes has invalid batch number:<br>' . implode(', ', $uniqueInvalidBatch))
|
->body('Batch number should contain minimum 8 digit numeric values!<br>Following item codes has invalid batch number:<br>'.implode(', ', $uniqueInvalidBatch))
|
||||||
->danger()
|
->danger()
|
||||||
->seconds(2)
|
->seconds(2)
|
||||||
->send();
|
->send();
|
||||||
@@ -605,6 +621,7 @@ class WeightValidationResource extends Resource
|
|||||||
if ($disk->exists($path)) {
|
if ($disk->exists($path)) {
|
||||||
$disk->delete($path);
|
$disk->delete($path);
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -624,10 +641,10 @@ class WeightValidationResource extends Resource
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
$uniqueInvalidWeight = array_unique($invalidWeight);
|
$uniqueInvalidWeight = array_unique($invalidWeight);
|
||||||
if (!empty($uniqueInvalidWeight)) {
|
if (! empty($uniqueInvalidWeight)) {
|
||||||
Notification::make()
|
Notification::make()
|
||||||
->title('Invalid: Actual Weights')
|
->title('Invalid: Actual Weights')
|
||||||
->body('Actual weight should contain minimum 1 digit numeric value!<br>Following item codes has invalid actual weight:<br>' . implode(', ', $uniqueInvalidWeight))
|
->body('Actual weight should contain minimum 1 digit numeric value!<br>Following item codes has invalid actual weight:<br>'.implode(', ', $uniqueInvalidWeight))
|
||||||
->danger()
|
->danger()
|
||||||
->seconds(2)
|
->seconds(2)
|
||||||
->send();
|
->send();
|
||||||
@@ -635,12 +652,13 @@ class WeightValidationResource extends Resource
|
|||||||
if ($disk->exists($path)) {
|
if ($disk->exists($path)) {
|
||||||
$disk->delete($path);
|
$disk->delete($path);
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$uniqueCodes = array_unique($materialCodes);
|
$uniqueCodes = array_unique($materialCodes);
|
||||||
|
|
||||||
//itemNotFound.
|
// itemNotFound.
|
||||||
$matchedItems = Item::whereIn('code', $uniqueCodes)->get();
|
$matchedItems = Item::whereIn('code', $uniqueCodes)->get();
|
||||||
|
|
||||||
// // Get all codes that exist in the database for the given plant_id
|
// // Get all codes that exist in the database for the given plant_id
|
||||||
@@ -653,13 +671,13 @@ class WeightValidationResource extends Resource
|
|||||||
// ->pluck('item.code')
|
// ->pluck('item.code')
|
||||||
// ->toArray();
|
// ->toArray();
|
||||||
|
|
||||||
$matchedCodes = $matchedItems->pluck('code')->toArray(); //item.code
|
$matchedCodes = $matchedItems->pluck('code')->toArray(); // item.code
|
||||||
$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);
|
||||||
|
|
||||||
Notification::make()
|
Notification::make()
|
||||||
->title('Unknown: Item Codes')
|
->title('Unknown: Item Codes')
|
||||||
@@ -671,19 +689,20 @@ class WeightValidationResource extends Resource
|
|||||||
if ($disk->exists($path)) {
|
if ($disk->exists($path)) {
|
||||||
$disk->delete($path);
|
$disk->delete($path);
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//plantNotFound
|
// plantNotFound
|
||||||
$matchedItems = Item::whereIn('code', $uniqueCodes)->where('plant_id', $plantId)->get();
|
$matchedItems = Item::whereIn('code', $uniqueCodes)->where('plant_id', $plantId)->get();
|
||||||
|
|
||||||
$matchedCodes = $matchedItems->pluck('code')->toArray();
|
$matchedCodes = $matchedItems->pluck('code')->toArray();
|
||||||
$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 for choosed plant." : 'The following item codes are not found in database for choosed plant:<br>' . implode(', ', $missingCodes);
|
$message = $missingCount > 10 ? "'$missingCount' item codes are not found in database for choosed plant." : 'The following item codes are not found in database for choosed plant:<br>'.implode(', ', $missingCodes);
|
||||||
|
|
||||||
Notification::make()
|
Notification::make()
|
||||||
->title('Unknown: Item Codes')
|
->title('Unknown: Item Codes')
|
||||||
@@ -695,10 +714,11 @@ class WeightValidationResource extends Resource
|
|||||||
if ($disk->exists($path)) {
|
if ($disk->exists($path)) {
|
||||||
$disk->delete($path);
|
$disk->delete($path);
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$validRowsFound) {
|
if (! $validRowsFound) {
|
||||||
Notification::make()
|
Notification::make()
|
||||||
->title('Invalid OBD Invoice')
|
->title('Invalid OBD Invoice')
|
||||||
->danger() // This makes the notification red to indicate an error
|
->danger() // This makes the notification red to indicate an error
|
||||||
@@ -709,30 +729,32 @@ class WeightValidationResource extends Resource
|
|||||||
if ($disk->exists($path)) {
|
if ($disk->exists($path)) {
|
||||||
$disk->delete($path);
|
$disk->delete($path);
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$updateInv = WeightValidation::where('plant_id', $plantId)->where('obd_number', $originalNameOnly)->first()?->exists();
|
$updateInv = WeightValidation::where('plant_id', $plantId)->where('obd_number', $originalNameOnly)->first()?->exists();
|
||||||
|
|
||||||
$availLines = WeightValidation::where('plant_id', $plantId)->where('obd_number', $originalNameOnly)->where(function($query) {
|
$availLines = WeightValidation::where('plant_id', $plantId)->where('obd_number', $originalNameOnly)->where(function ($query) {
|
||||||
$query->whereNull('vehicle_number')->orWhere('vehicle_number', '');
|
$query->whereNull('vehicle_number')->orWhere('vehicle_number', '');
|
||||||
})->pluck('line_number')->toArray();
|
})->pluck('line_number')->toArray();
|
||||||
|
|
||||||
$updated = WeightValidation::where('plant_id', $plantId)->where('obd_number', $originalNameOnly)->where(function($query) {
|
$updated = WeightValidation::where('plant_id', $plantId)->where('obd_number', $originalNameOnly)->where(function ($query) {
|
||||||
$query->whereNull('vehicle_number')->orWhere('vehicle_number', '');
|
$query->whereNull('vehicle_number')->orWhere('vehicle_number', '');
|
||||||
})->count();
|
})->count();
|
||||||
|
|
||||||
WeightValidation::where('plant_id', $plantId)->where('obd_number', $originalNameOnly)->where(function($query) {
|
WeightValidation::where('plant_id', $plantId)->where('obd_number', $originalNameOnly)->where(function ($query) {
|
||||||
$query->whereNull('vehicle_number')->orWhere('vehicle_number', '');
|
$query->whereNull('vehicle_number')->orWhere('vehicle_number', '');
|
||||||
})
|
})
|
||||||
->forceDelete();
|
->forceDelete();
|
||||||
|
|
||||||
$inserted = 0;
|
$inserted = 0;
|
||||||
// $updated = 0;
|
// $updated = 0;
|
||||||
foreach ($rows as $index => $row)
|
foreach ($rows as $index => $row) {
|
||||||
{
|
|
||||||
// Skip header
|
// Skip header
|
||||||
if ($index === 0) { continue; }
|
if ($index === 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
$materialCode = trim($row[0]);
|
$materialCode = trim($row[0]);
|
||||||
$lineNumber = trim($row[1]);
|
$lineNumber = trim($row[1]);
|
||||||
@@ -744,31 +766,27 @@ class WeightValidationResource extends Resource
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($materialCode)) {
|
if (! empty($materialCode)) {
|
||||||
$recordExist = WeightValidation::where('plant_id', $plantId)->where('obd_number', $originalNameOnly)->where('line_number', $lineNumber)->first();
|
$recordExist = WeightValidation::where('plant_id', $plantId)->where('obd_number', $originalNameOnly)->where('line_number', $lineNumber)->first();
|
||||||
|
|
||||||
$masItem = Item::where('plant_id', $plantId)->where('code', $materialCode)->first();
|
$masItem = Item::where('plant_id', $plantId)->where('code', $materialCode)->first();
|
||||||
if($recordExist) {
|
if ($recordExist) {
|
||||||
$skipUpd = $recordExist->vehicle_number ?? null;
|
$skipUpd = $recordExist->vehicle_number ?? null;
|
||||||
if($skipUpd)
|
if ($skipUpd) {
|
||||||
{
|
|
||||||
continue;
|
continue;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
if ($masItem) {
|
if ($masItem) {
|
||||||
$recordExist->update([
|
$recordExist->update([
|
||||||
'item_id' => $masItem->id,
|
'item_id' => $masItem->id,
|
||||||
'batch_number' => $batchNumber,
|
'batch_number' => $batchNumber,
|
||||||
//'heat_number' => $heatNumber,
|
// 'heat_number' => $heatNumber,
|
||||||
'obd_weight' => $actualWeight,
|
'obd_weight' => $actualWeight,
|
||||||
'updated_at' => now(),
|
'updated_at' => now(),
|
||||||
]);
|
]);
|
||||||
$updated++;
|
$updated++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
if ($masItem) {
|
if ($masItem) {
|
||||||
WeightValidation::create([
|
WeightValidation::create([
|
||||||
'item_id' => $masItem->id,
|
'item_id' => $masItem->id,
|
||||||
@@ -776,15 +794,12 @@ class WeightValidationResource extends Resource
|
|||||||
'obd_number' => $originalNameOnly,
|
'obd_number' => $originalNameOnly,
|
||||||
'line_number' => $lineNumber,
|
'line_number' => $lineNumber,
|
||||||
'batch_number' => $batchNumber,
|
'batch_number' => $batchNumber,
|
||||||
//'heat_number' => $heatNumber,
|
// 'heat_number' => $heatNumber,
|
||||||
'obd_weight' => $actualWeight,
|
'obd_weight' => $actualWeight,
|
||||||
]);
|
]);
|
||||||
if (in_array($lineNumber, $availLines))
|
if (in_array($lineNumber, $availLines)) {
|
||||||
{
|
|
||||||
continue;
|
continue;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
$inserted++;
|
$inserted++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -792,10 +807,10 @@ class WeightValidationResource extends Resource
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if($updateInv) {
|
if ($updateInv) {
|
||||||
if ($updated > 0) {
|
if ($updated > 0) {
|
||||||
Notification::make()
|
Notification::make()
|
||||||
->title("Start the scanning process!")
|
->title('Start the scanning process!')
|
||||||
->body("'$updated' OBD lines were updated and<br>'$inserted' OBD lines were inserted for<br>imported OBD Invoice : '$originalNameOnly'.")
|
->body("'$updated' OBD lines were updated and<br>'$inserted' OBD lines were inserted for<br>imported OBD Invoice : '$originalNameOnly'.")
|
||||||
->info()
|
->info()
|
||||||
// ->success()
|
// ->success()
|
||||||
@@ -806,24 +821,20 @@ class WeightValidationResource extends Resource
|
|||||||
$totalQuantity = WeightValidation::where('obd_number', $originalNameOnly)->where('plant_id', $plantId)->count();
|
$totalQuantity = WeightValidation::where('obd_number', $originalNameOnly)->where('plant_id', $plantId)->count();
|
||||||
$scannedQuantity = WeightValidation::where('obd_number', $originalNameOnly)->where('plant_id', $plantId)->whereNotNull('vehicle_number')->where('vehicle_number', '!=', '')->count();
|
$scannedQuantity = WeightValidation::where('obd_number', $originalNameOnly)->where('plant_id', $plantId)->whereNotNull('vehicle_number')->where('vehicle_number', '!=', '')->count();
|
||||||
|
|
||||||
if ($totalQuantity === $scannedQuantity)
|
if ($totalQuantity === $scannedQuantity) {
|
||||||
{
|
|
||||||
if ($disk->exists($path)) {
|
if ($disk->exists($path)) {
|
||||||
$disk->delete($path);
|
$disk->delete($path);
|
||||||
}
|
}
|
||||||
// $this->dispatch('refreshCompletedInvoice', invoiceNumber: $originalNameOnly, plantId: $plantId);
|
// $this->dispatch('refreshCompletedInvoice', invoiceNumber: $originalNameOnly, plantId: $plantId);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
if ($disk->exists($path)) {
|
if ($disk->exists($path)) {
|
||||||
$disk->delete($path);
|
$disk->delete($path);
|
||||||
}
|
}
|
||||||
// $this->dispatch('refreshInvoiceData', invoiceNumber: $originalNameOnly, plantId: $plantId);
|
// $this->dispatch('refreshInvoiceData', invoiceNumber: $originalNameOnly, plantId: $plantId);
|
||||||
}
|
}
|
||||||
}
|
} elseif ($inserted > 0) {
|
||||||
else if ($inserted > 0) {
|
|
||||||
Notification::make()
|
Notification::make()
|
||||||
->title("Start the scanning process!")
|
->title('Start the scanning process!')
|
||||||
->body("'$inserted' OBD lines were inserted for imported OBD Invoice : '$originalNameOnly'.")
|
->body("'$inserted' OBD lines were inserted for imported OBD Invoice : '$originalNameOnly'.")
|
||||||
->info()
|
->info()
|
||||||
// ->success()
|
// ->success()
|
||||||
@@ -834,24 +845,20 @@ class WeightValidationResource extends Resource
|
|||||||
$totalQuantity = WeightValidation::where('obd_number', $originalNameOnly)->where('plant_id', $plantId)->count();
|
$totalQuantity = WeightValidation::where('obd_number', $originalNameOnly)->where('plant_id', $plantId)->count();
|
||||||
$scannedQuantity = WeightValidation::where('obd_number', $originalNameOnly)->where('plant_id', $plantId)->whereNotNull('vehicle_number')->where('vehicle_number', '!=', '')->count();
|
$scannedQuantity = WeightValidation::where('obd_number', $originalNameOnly)->where('plant_id', $plantId)->whereNotNull('vehicle_number')->where('vehicle_number', '!=', '')->count();
|
||||||
|
|
||||||
if ($totalQuantity === $scannedQuantity)
|
if ($totalQuantity === $scannedQuantity) {
|
||||||
{
|
|
||||||
if ($disk->exists($path)) {
|
if ($disk->exists($path)) {
|
||||||
$disk->delete($path);
|
$disk->delete($path);
|
||||||
}
|
}
|
||||||
// $this->dispatch('refreshCompletedInvoice', invoiceNumber: $originalNameOnly, plantId: $plantId);
|
// $this->dispatch('refreshCompletedInvoice', invoiceNumber: $originalNameOnly, plantId: $plantId);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
if ($disk->exists($path)) {
|
if ($disk->exists($path)) {
|
||||||
$disk->delete($path);
|
$disk->delete($path);
|
||||||
}
|
}
|
||||||
// $this->dispatch('refreshInvoiceData', invoiceNumber: $originalNameOnly, plantId: $plantId);
|
// $this->dispatch('refreshInvoiceData', invoiceNumber: $originalNameOnly, plantId: $plantId);
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
Notification::make()
|
Notification::make()
|
||||||
->title("Import Failed: OBD Invoice")
|
->title('Import Failed: OBD Invoice')
|
||||||
->body("No exist records were updated for imported OBD Invoice : '$originalNameOnly'.")
|
->body("No exist records were updated for imported OBD Invoice : '$originalNameOnly'.")
|
||||||
->danger()
|
->danger()
|
||||||
->seconds(2)
|
->seconds(2)
|
||||||
@@ -863,14 +870,14 @@ class WeightValidationResource extends Resource
|
|||||||
if ($disk->exists($path)) {
|
if ($disk->exists($path)) {
|
||||||
$disk->delete($path);
|
$disk->delete($path);
|
||||||
}
|
}
|
||||||
|
|
||||||
// $this->dispatch('refreshEmptyInvoice', invoiceNumber: $originalNameOnly, plantId: $plantId);
|
// $this->dispatch('refreshEmptyInvoice', invoiceNumber: $originalNameOnly, plantId: $plantId);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
if ($inserted > 0) {
|
if ($inserted > 0) {
|
||||||
Notification::make()
|
Notification::make()
|
||||||
->title("Start the scanning process!")
|
->title('Start the scanning process!')
|
||||||
->body("'$inserted' OBD lines were inserted for imported OBD Invoice : '$originalNameOnly'.")
|
->body("'$inserted' OBD lines were inserted for imported OBD Invoice : '$originalNameOnly'.")
|
||||||
->info()
|
->info()
|
||||||
// ->success()
|
// ->success()
|
||||||
@@ -881,24 +888,20 @@ class WeightValidationResource extends Resource
|
|||||||
$totalQuantity = WeightValidation::where('obd_number', $originalNameOnly)->where('plant_id', $plantId)->count();
|
$totalQuantity = WeightValidation::where('obd_number', $originalNameOnly)->where('plant_id', $plantId)->count();
|
||||||
$scannedQuantity = WeightValidation::where('obd_number', $originalNameOnly)->where('plant_id', $plantId)->whereNotNull('vehicle_number')->where('vehicle_number', '!=', '')->count();
|
$scannedQuantity = WeightValidation::where('obd_number', $originalNameOnly)->where('plant_id', $plantId)->whereNotNull('vehicle_number')->where('vehicle_number', '!=', '')->count();
|
||||||
|
|
||||||
if ($totalQuantity === $scannedQuantity)
|
if ($totalQuantity === $scannedQuantity) {
|
||||||
{
|
|
||||||
if ($disk->exists($path)) {
|
if ($disk->exists($path)) {
|
||||||
$disk->delete($path);
|
$disk->delete($path);
|
||||||
}
|
}
|
||||||
// $this->dispatch('refreshCompletedInvoice', invoiceNumber: $originalNameOnly, plantId: $plantId);
|
// $this->dispatch('refreshCompletedInvoice', invoiceNumber: $originalNameOnly, plantId: $plantId);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
if ($disk->exists($path)) {
|
if ($disk->exists($path)) {
|
||||||
$disk->delete($path);
|
$disk->delete($path);
|
||||||
}
|
}
|
||||||
// $this->dispatch('refreshInvoiceData', invoiceNumber: $originalNameOnly, plantId: $plantId);
|
// $this->dispatch('refreshInvoiceData', invoiceNumber: $originalNameOnly, plantId: $plantId);
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
Notification::make()
|
Notification::make()
|
||||||
->title("Import Failed: OBD Invoice")
|
->title('Import Failed: OBD Invoice')
|
||||||
->body("No new records were inserted for imported OBD Invoice : '$originalNameOnly'.")
|
->body("No new records were inserted for imported OBD Invoice : '$originalNameOnly'.")
|
||||||
->danger()
|
->danger()
|
||||||
->seconds(2)
|
->seconds(2)
|
||||||
@@ -910,27 +913,28 @@ class WeightValidationResource extends Resource
|
|||||||
if ($disk->exists($path)) {
|
if ($disk->exists($path)) {
|
||||||
$disk->delete($path);
|
$disk->delete($path);
|
||||||
}
|
}
|
||||||
|
|
||||||
// $this->dispatch('refreshEmptyInvoice', invoiceNumber: $originalNameOnly, plantId: $plantId);
|
// $this->dispatch('refreshEmptyInvoice', invoiceNumber: $originalNameOnly, plantId: $plantId);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
->visible(function() {
|
->visible(function () {
|
||||||
return Filament::auth()->user()->can('view import obd number validations');
|
return Filament::auth()->user()->can('view import obd number validations');
|
||||||
}),
|
}),
|
||||||
ImportAction::make()
|
ImportAction::make()
|
||||||
->label('Import OBD Invoice')
|
->label('Import OBD Invoice')
|
||||||
->color('warning')
|
->color('warning')
|
||||||
->importer(WeightValidationImporter::class)
|
->importer(WeightValidationImporter::class)
|
||||||
->visible(function() {
|
->visible(function () {
|
||||||
return Filament::auth()->user()->can('view import weight validation');
|
return Filament::auth()->user()->can('view import weight validation');
|
||||||
}),
|
}),
|
||||||
ExportAction::make()
|
ExportAction::make()
|
||||||
->label('Export OBD Invoices')
|
->label('Export OBD Invoices')
|
||||||
->color('warning')
|
->color('warning')
|
||||||
->exporter(WeightValidationExporter::class)
|
->exporter(WeightValidationExporter::class)
|
||||||
->visible(function() {
|
->visible(function () {
|
||||||
return Filament::auth()->user()->can('view export weight validation');
|
return Filament::auth()->user()->can('view export weight validation');
|
||||||
}),
|
}),
|
||||||
]);
|
]);
|
||||||
|
|||||||
Reference in New Issue
Block a user