diff --git a/app/Filament/Clusters/VisaMasterPayments/Resources/VisaMasterPaymentOrders/Schemas/VisaMasterPaymentOrderForm.php b/app/Filament/Clusters/VisaMasterPayments/Resources/VisaMasterPaymentOrders/Schemas/VisaMasterPaymentOrderForm.php index 41bcabd..4a7c785 100644 --- a/app/Filament/Clusters/VisaMasterPayments/Resources/VisaMasterPaymentOrders/Schemas/VisaMasterPaymentOrderForm.php +++ b/app/Filament/Clusters/VisaMasterPayments/Resources/VisaMasterPaymentOrders/Schemas/VisaMasterPaymentOrderForm.php @@ -2,7 +2,25 @@ namespace App\Filament\Clusters\VisaMasterPayments\Resources\VisaMasterPaymentOrders\Schemas; +use App\Modules\Filament\Traits\HasFilamentUser; +use App\Modules\Region\Repositories\RegionRepository; +use App\Modules\VisaMasterPaymentOrder\Models\VisaMasterPaymentOrder; +use App\Modules\VisaMasterPaymentOrder\Repositories\VisaMasterPaymentOrderRepository; +use Filament\Forms\Components\FileUpload; +use Filament\Forms\Components\Hidden; +use Filament\Forms\Components\KeyValue; +use Filament\Forms\Components\RichEditor; +use Filament\Forms\Components\Select; +use Filament\Forms\Components\Textarea; +use Filament\Forms\Components\TextInput; +use Filament\Forms\Components\Toggle; +use Filament\Schemas\Components\Section; +use Filament\Schemas\Components\Wizard; +use Filament\Schemas\Components\Wizard\Step; use Filament\Schemas\Schema; +use Filament\Support\Icons\Heroicon; +use Illuminate\Database\Eloquent\Builder; +use Illuminate\Support\Facades\Auth; class VisaMasterPaymentOrderForm { @@ -10,7 +28,132 @@ class VisaMasterPaymentOrderForm { return $schema ->components([ - // + Hidden::make('user_id')->default(Auth::id()), + + Section::make(__('Order details')) + ->columnSpan(4) + ->columns(4) + ->components([ + Select::make('status') + ->label(__('Status')) + ->options(VisaMasterPaymentOrderRepository::statusValues()) + ->default(VisaMasterPaymentOrderRepository::defaultStatus()) + ->native(false) + ->columnSpan(2), + + Toggle::make('paid') + ->label(__('Paid')) + ->inline(false) + ->disabled(true) + ->onIcon(Heroicon::CheckCircle) + ->offIcon(Heroicon::XCircle) + ->onColor('success') + ->offColor('danger'), + + RichEditor::make('notes') + ->label(__('Bellik')) + ->columnSpanFull(), + ]), + + Wizard::make([ + Step::make(__('General information')) + ->schema([ + Select::make('type') + ->label(__('Type')) + ->options(VisaMasterPaymentOrder::applicationTypes()) + ->native(false) + ->required(), + + Select::make('branch_id') + ->label(__('Branch')) + ->relationship('branch', 'name', fn (Builder $query) => $query->orderByTranslation('name')) + ->native(false) + ->required(), + ]), + Step::make(__('Personal information')) + ->columns(2) + ->schema([ + TextInput::make('passport_name') + ->label(__('Name')) + ->required() + ->maxLength(255), + + TextInput::make('passport_surname') + ->label(__('Surname')) + ->required() + ->maxLength(255), + + TextInput::make('phone') + ->label(__('Phone')) + ->required() + ->tel(), + + TextInput::make('email') + ->label(__('Email')) + ->email(), + + Select::make('region') + ->label(__('Region')) + ->options(RegionRepository::values()) + ->native(false) + ->required(), + + Textarea::make('address') + ->label(__('Address')) + ->columnSpanFull(), + ]), + + Step::make(__('Sender information')) + ->schema([ + TextInput::make('sender_full_name') + ->label(__('Sender full name')) + ->required(), + + TextInput::make('sender_passport_serie') + ->label(__('Sender passport serie')) + ->required(), + + TextInput::make('sender_passport_number') + ->label(__('Sender passport number')) + ->required(), + + TextInput::make('sender_deposit_account') + ->label(__('Sender deposit account')) + ->required(), + ]), + + Step::make(__('JSON data')) + ->schema([ + KeyValue::make('sender_datas') + ->label(__('Sender data')), + + KeyValue::make('payment_reciever') + ->label(__('Payment receiver')), + ]), + + Step::make(__('Receiver documents')) + ->schema( + collect(VisaMasterPaymentOrder::reciverFiles()) + ->map(function (array $file) { + return FileUpload::make('documents.'.$file['code']) + ->label($file['name']) + ->required($file['required']); + }) + ->toArray() + ), + + Step::make(__('Sender documents')) + ->schema( + collect(VisaMasterPaymentOrder::senderFiles()) + ->map(function (array $file) { + return FileUpload::make('documents.sender.'.$file['code']) + ->label($file['name']) + ->required($file['required']); + }) + ->toArray() + ), + + ])->columnSpanFull(), ]); } } diff --git a/app/Modules/VisaMasterPaymentOrder/Repositories/VisaMasterPaymentOrderRepository.php b/app/Modules/VisaMasterPaymentOrder/Repositories/VisaMasterPaymentOrderRepository.php index 0191801..905842d 100644 --- a/app/Modules/VisaMasterPaymentOrder/Repositories/VisaMasterPaymentOrderRepository.php +++ b/app/Modules/VisaMasterPaymentOrder/Repositories/VisaMasterPaymentOrderRepository.php @@ -2,4 +2,32 @@ namespace App\Modules\VisaMasterPaymentOrder\Repositories; -class VisaMasterPaymentOrderRepository {} +use App\Modules\Makeable; + +class VisaMasterPaymentOrderRepository +{ + use Makeable; + + /** + * Default status + */ + public static function defaultStatus(): string + { + return 'new'; + } + + /** + * Status values + * + * @return array + */ + public static function statusValues(): array + { + return [ + 'new' => __('New'), + 'in_progress' => __('In progress'), + 'completed' => __('Completed'), + 'rejected' => __('Rejected'), + ]; + } +}