81 lines
3.4 KiB
PHP
81 lines
3.4 KiB
PHP
<?php
|
|
|
|
namespace App\Filament\Resources\Contracts\Schemas;
|
|
|
|
use App\Models\Product;
|
|
use App\Models\PaymentTemplate;
|
|
use Filament\Forms\Components\Select;
|
|
use Filament\Forms\Components\TextInput;
|
|
use Filament\Forms\Components\DatePicker;
|
|
use Filament\Schemas\Components\Section;
|
|
use Filament\Schemas\Schema;
|
|
use Filament\Schemas\Components\Utilities\Get;
|
|
use Filament\Schemas\Components\Utilities\Set;
|
|
|
|
class ContractForm
|
|
{
|
|
public static function configure(Schema $schema): Schema
|
|
{
|
|
return $schema
|
|
->components([
|
|
Section::make('Liên kết & Mẫu thanh toán')
|
|
->columns(2)
|
|
->schema([
|
|
Select::make('product_id')
|
|
->label('Sản phẩm')
|
|
->relationship('product', 'code')
|
|
->required()
|
|
->live()
|
|
->afterStateUpdated(function (Set $set, $state) {
|
|
if ($state) {
|
|
$product = Product::find($state);
|
|
if ($product) {
|
|
$set('total_value', $product->total_price);
|
|
}
|
|
}
|
|
}),
|
|
Select::make('payment_template_id')
|
|
->label('Mẫu thanh toán')
|
|
->options(fn () => PaymentTemplate::pluck('name', 'id'))
|
|
->required()
|
|
->dehydrated(false),
|
|
Select::make('customers')
|
|
->label('Khách hàng')
|
|
->relationship('customers', 'full_name')
|
|
->multiple()
|
|
->required()
|
|
->columnSpanFull(),
|
|
]),
|
|
Section::make('Chi tiết Hợp đồng')
|
|
->columns(2)
|
|
->schema([
|
|
TextInput::make('contract_number')->label('Số HĐ')->required(),
|
|
Select::make('contract_type')
|
|
->label('Loại HĐ')
|
|
->options([
|
|
'HĐMB' => 'HĐMB',
|
|
'HĐGV' => 'HĐGV',
|
|
'HĐDC' => 'HĐDC',
|
|
])
|
|
->default('HĐMB')
|
|
->required(),
|
|
DatePicker::make('signing_date')->label('Ngày ký')->required(),
|
|
TextInput::make('total_value')
|
|
->label('Giá trị HĐ')
|
|
->numeric()
|
|
->required()
|
|
->prefix('VND'),
|
|
Select::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',
|
|
])
|
|
->default('Đang hiệu lực')
|
|
->required(),
|
|
])
|
|
]);
|
|
}
|
|
}
|