85 lines
3.1 KiB
PHP
85 lines
3.1 KiB
PHP
<?php
|
|
|
|
namespace App\Filament\Resources\Contracts\Tables;
|
|
|
|
use Filament\Actions\BulkActionGroup;
|
|
use Filament\Actions\DeleteBulkAction;
|
|
use Filament\Actions\EditAction;
|
|
use Filament\Tables\Columns\TextColumn;
|
|
use Filament\Tables\Columns\BadgeColumn;
|
|
use Filament\Tables\Table;
|
|
|
|
class ContractsTable
|
|
{
|
|
public static function configure(Table $table): Table
|
|
{
|
|
return $table
|
|
->columns([
|
|
TextColumn::make('contract_number')
|
|
->label('Số HĐMB')
|
|
->searchable()
|
|
->sortable()
|
|
->copyable()
|
|
->description(fn ($record) => "Lô: {$record->product?->code}"),
|
|
|
|
TextColumn::make('customers.full_name')
|
|
->label('Khách hàng')
|
|
->searchable()
|
|
->listWithLineBreaks()
|
|
->bulleted(),
|
|
|
|
TextColumn::make('signing_date')
|
|
->label('Ngày ký')
|
|
->date('d/m/Y')
|
|
->sortable(),
|
|
|
|
TextColumn::make('total_value')
|
|
->label('Giá trị HĐ')
|
|
->money('VND')
|
|
->sortable()
|
|
->summarize(\Filament\Tables\Columns\Summarizers\Sum::make()->label('Tổng doanh thu')->money('VND')),
|
|
|
|
TextColumn::make('transfer_order')
|
|
->label('Đời CN')
|
|
->badge()
|
|
->color(fn ($state) => $state == 0 ? 'success' : 'gray')
|
|
->formatStateUsing(fn ($state) => $state == 0 ? 'Hiện tại' : "F{$state}")
|
|
->alignCenter(),
|
|
|
|
TextColumn::make('status')
|
|
->label('Trạng thái')
|
|
->badge()
|
|
->color(fn (string $state): string => match ($state) {
|
|
'Đang hiệu lực' => 'success',
|
|
'Đã hoàn thành' => 'primary',
|
|
'Đã hủy' => 'danger',
|
|
default => 'gray',
|
|
}),
|
|
])
|
|
->filters([
|
|
\Filament\Tables\Filters\SelectFilter::make('status')
|
|
->label('Trạng thái')
|
|
->options([
|
|
'Đang hiệu lực' => 'Đang hiệu lực',
|
|
'Đã hoàn thành' => 'Đã hoàn thành',
|
|
'Đã hủy' => 'Đã hủy',
|
|
]),
|
|
\Filament\Tables\Filters\TernaryFilter::make('is_current')
|
|
->label('Chủ sở hữu hiện tại')
|
|
->queries(
|
|
true: fn ($query) => $query->where('transfer_order', 0),
|
|
false: fn ($query) => $query->where('transfer_order', '>', 0),
|
|
)
|
|
])
|
|
->recordActions([
|
|
EditAction::make(),
|
|
])
|
|
->bulkActions([
|
|
BulkActionGroup::make([
|
|
DeleteBulkAction::make(),
|
|
]),
|
|
])
|
|
->defaultSort('created_at', 'desc');
|
|
}
|
|
}
|