Merge pull request 'Added rfq dashboard and rfq overview pages' (#99) from ranjith-dev into master
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Reviewed-on: #99
This commit was merged in pull request #99.
This commit is contained in:
163
app/Filament/Pages/RfqDashboard.php
Normal file
163
app/Filament/Pages/RfqDashboard.php
Normal 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');
|
||||
}
|
||||
}
|
||||
58
app/Filament/Pages/RfqOverview.php
Normal file
58
app/Filament/Pages/RfqOverview.php
Normal 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');
|
||||
}
|
||||
}
|
||||
14
resources/views/filament/pages/rfq-dashboard.blade.php
Normal file
14
resources/views/filament/pages/rfq-dashboard.blade.php
Normal file
@@ -0,0 +1,14 @@
|
||||
<x-filament-panels::page>
|
||||
<div class="space-y-4">
|
||||
{{-- Render the Select form fields --}}
|
||||
<div class="space-y-4">
|
||||
{{ $this->filtersForm($this->form) }}
|
||||
{{-- {{ $this->form }} --}}
|
||||
</div>
|
||||
|
||||
{{-- Render the chart widget below the form --}}
|
||||
<div class="mt-6">
|
||||
@livewire(\App\Filament\Widgets\RfqChart::class)
|
||||
</div>
|
||||
</div>
|
||||
</x-filament-panels::page>
|
||||
14
resources/views/filament/pages/rfq-overview.blade.php
Normal file
14
resources/views/filament/pages/rfq-overview.blade.php
Normal file
@@ -0,0 +1,14 @@
|
||||
<x-filament-panels::page>
|
||||
<div class="space-y-4">
|
||||
{{-- Render the Select form fields --}}
|
||||
<div class="space-y-4">
|
||||
{{ $this->filtersForm($this->form) }}
|
||||
{{-- {{ $this->form }} --}}
|
||||
</div>
|
||||
|
||||
{{-- Render the chart widget below the form --}}
|
||||
<div class="mt-6">
|
||||
@livewire(\App\Filament\Widgets\RfqRankChart::class)
|
||||
</div>
|
||||
</div>
|
||||
</x-filament-panels::page>
|
||||
Reference in New Issue
Block a user