Added rfq dashboard and rfq overview pages
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Gemini PR Review / Gemini PR Review (pull_request) Successful in 14s
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Successful in 10s
Laravel Larastan / larastan (pull_request) Failing after 2m24s
Laravel Pint / pint (pull_request) Failing after 2m35s

This commit is contained in:
dhanabalan
2026-01-23 12:56:11 +05:30
parent 14844f1e1e
commit 8fc963dc0a
4 changed files with 249 additions and 0 deletions

View File

@@ -0,0 +1,163 @@
<?php
namespace App\Filament\Pages;
use Filament\Pages\Page;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Form;
use Filament\Pages\Dashboard\Concerns\HasFiltersForm;
use Filament\Tables\Filters\SelectFilter;
use Illuminate\Support\Facades\DB;
use App\Models\Plant;
use App\Models\RequestQuotation;
use App\Models\RfqTransporterBid;
use Filament\Facades\Filament;
use Filament\Widgets\Widget;
use Illuminate\Support\Facades\Auth;
use Filament\Forms\Components\Section;
use Filament\Forms;
use Filament\Forms\Concerns\InteractsWithForms;
use Filament\Forms\Contracts\HasForms;
class RfqDashboard extends Page
{
protected static ?string $navigationIcon = 'heroicon-o-document-text';
protected static string $view = 'filament.pages.rfq-dashboard';
protected static ?string $navigationGroup = 'RFQ Dashboard';
use HasFiltersForm;
public function mount(): void
{
session()->forget(['transport_name']);
session()->forget(['rfq_number']);
$this->filtersForm->fill([
'transport_name' => null,
'rfq_number' => null
]);
}
public function filtersForm(Form $form): Form
{
return $form
->statePath('filters')
->schema([
Section::make('')
->schema([
// Select::make('plant')
// ->label('Select Plant')
// ->reactive()
// ->options(function (callable $get) {
// $userHas = Filament::auth()->user()->plant_id;
// return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
// })
// ->afterStateUpdated(function ($state,callable $set) {
// session(['selected_plant' => $state]);
// // $set('rfq_number', null);
// session()->forget('rfq_number');
// }),
Select::make('rfq_number')
->label('Select RFQ Number')
->reactive()
->options(function (callable $get) {
return RequestQuotation::orderBy('rfq_number')
->pluck('rfq_number', 'id')
->toArray();
})
->afterStateUpdated(function ($state, callable $set) {
session(['rfq_id' => $state]);
$set('transport_name', null);
session()->forget('transport_name');
}),
Select::make('transport_name')
->label('User name')
->reactive()
->options(function (callable $get) {
$rfqId = $get('rfq_number');
if (!$rfqId) {
return [];
}
$user = Filament::auth()->user();
if ($user->hasRole(['Super Admin', 'Rfq Supervisor'])) {
return RfqTransporterBid::query()
->where('request_quotation_id', $rfqId)
->whereNotNull('transporter_name')
->distinct()
->pluck('transporter_name', 'transporter_name')
->toArray();
}
return RfqTransporterBid::query()
->where('request_quotation_id', $rfqId)
->where('transporter_name', $user->name)
->distinct()
->pluck('transporter_name', 'transporter_name')
->toArray();
})
->afterStateUpdated(function ($state, callable $set) {
session(['transport_name' => $state]);
}),
// Select::make('transport_name')
// ->label('User name')
// ->reactive()
// ->options(function () {
// $user = Filament::auth()->user();
// if ($user->hasRole(['Super Admin', 'Rfq Supervisor'])) {
// return RfqTransporterBid::query()
// ->whereNotNull('transporter_name')
// ->distinct()
// ->pluck('transporter_name', 'transporter_name')
// ->toArray();
// }
// return RfqTransporterBid::query()
// ->where('transporter_name', $user->name)
// ->distinct()
// ->pluck('transporter_name', 'transporter_name')
// ->toArray();
// })
// ->afterStateUpdated(function ($state, callable $set) {
// session(['transport_name' => $state]);
// $set('rfq_number', null);
// session()->forget('rfq_number');
// }),
// Select::make('rfq_number')
// ->label('Select RFQ Number')
// ->reactive()
// ->options(function (callable $get) {
// $transportName = $get('transport_name');
// if (!$transportName) {
// return [];
// }
// return RequestQuotation::where('transporter_name', $transportName)
// ->pluck('rfq_number', 'rfq_number')
// ->toArray();
// })
// ->afterStateUpdated(function ($state) {
// session(['rfq_number' => $state]);
// }),
])
->columns(2),
]);
}
public static function canAccess(): bool
{
return Auth::check() && Auth::user()->can('view rfq dashboard');
}
}

View File

@@ -0,0 +1,58 @@
<?php
namespace App\Filament\Pages;
use App\Models\RequestQuotation;
use Filament\Pages\Page;
use Filament\Forms\Components\Section;
use Filament\Forms\Components\Select;
use Filament\Forms\Form;
use Filament\Pages\Dashboard\Concerns\HasFiltersForm;
use Illuminate\Support\Facades\Auth;
class RfqOverview extends Page
{
protected static ?string $navigationIcon = 'heroicon-o-document-text';
protected static string $view = 'filament.pages.rfq-overview';
protected static ?string $navigationGroup = 'RFQ Dashboard';
use HasFiltersForm;
public function mount(): void
{
session()->forget(['rfq_id']);
$this->filtersForm->fill([
'rfq_id' => null
]);
}
public function filtersForm(Form $form): Form
{
return $form
->statePath('filters')
->schema([
Section::make('')
->schema([
Select::make('rfq_number')
->label('Select RFQ Number')
->reactive()
->options(function (callable $get) {
return RequestQuotation::orderBy('rfq_number')
->pluck('rfq_number', 'id')
->toArray();
})
->afterStateUpdated(function ($state, callable $set) {
session(['rfq_id' => $state]);
}),
])
->columns(1),
]);
}
public static function canAccess(): bool
{
return Auth::check() && Auth::user()->can('view rfq overview dashboard');
}
}