|
|
|
@ -10,6 +10,7 @@ use App\Models\Contact;
|
|
|
|
|
use App\Models\Customer;
|
|
|
|
|
use App\Models\Order;
|
|
|
|
|
use Filament\Forms\Components\DatePicker;
|
|
|
|
|
use Filament\Forms\Components\Repeater;
|
|
|
|
|
use Filament\Forms\Components\Section;
|
|
|
|
|
use Filament\Forms\Components\Select;
|
|
|
|
|
use Filament\Forms\Components\Split;
|
|
|
|
@ -22,6 +23,9 @@ use Filament\Resources\Resource;
|
|
|
|
|
use Filament\Tables;
|
|
|
|
|
use Filament\Tables\Columns\TextColumn;
|
|
|
|
|
use Filament\Tables\Table;
|
|
|
|
|
use Guava\FilamentClusters\Forms\Cluster;
|
|
|
|
|
use Illuminate\Support\Facades\Blade;
|
|
|
|
|
use Illuminate\Support\HtmlString;
|
|
|
|
|
|
|
|
|
|
class OrderResource extends Resource
|
|
|
|
|
{
|
|
|
|
@ -35,80 +39,23 @@ class OrderResource extends Resource
|
|
|
|
|
{
|
|
|
|
|
return $form->schema([
|
|
|
|
|
Wizard::make([
|
|
|
|
|
// Wizard\Step::make('Production Details')
|
|
|
|
|
// ->schema([
|
|
|
|
|
// Repeater::make('Garments')->schema([
|
|
|
|
|
// Split::make([
|
|
|
|
|
// TextInput::make('sku')->grow(true),
|
|
|
|
|
// TextInput::make('name')->grow(false),
|
|
|
|
|
// TextInput::make('color')->grow(true),
|
|
|
|
|
// ]),
|
|
|
|
|
// Split::make([
|
|
|
|
|
// TextInput::make('xs'),
|
|
|
|
|
// TextInput::make('s'),
|
|
|
|
|
// TextInput::make('m'),
|
|
|
|
|
// TextInput::make('l'),
|
|
|
|
|
// TextInput::make('xl'),
|
|
|
|
|
// TextInput::make('2xl'),
|
|
|
|
|
// TextInput::make('3xl'),
|
|
|
|
|
// TextInput::make('osfa'),
|
|
|
|
|
// ]),
|
|
|
|
|
// ])->grid(2),
|
|
|
|
|
// ]),
|
|
|
|
|
Wizard\Step::make('Order Details')->schema([
|
|
|
|
|
Section::make([
|
|
|
|
|
Select::make('order_type')
|
|
|
|
|
->required()
|
|
|
|
|
->options(OrderType::class)
|
|
|
|
|
->searchable(),
|
|
|
|
|
|
|
|
|
|
Split::make([
|
|
|
|
|
Select::make('customer_id')
|
|
|
|
|
->required()
|
|
|
|
|
->label('Customer')
|
|
|
|
|
->options(Customer::all()->pluck('company_name', 'id'))
|
|
|
|
|
->reactive()
|
|
|
|
|
->searchable(),
|
|
|
|
|
|
|
|
|
|
Select::make('contact_id')
|
|
|
|
|
->label('Contact')
|
|
|
|
|
->options(fn ($get): array => Contact::where('customer_id', $get('customer_id') ?? null)->get()->pluck('full_name', 'id')->toArray())
|
|
|
|
|
->searchable(),
|
|
|
|
|
]),
|
|
|
|
|
|
|
|
|
|
TextInput::make('customer_po')
|
|
|
|
|
->required()
|
|
|
|
|
->label('Customer PO'),
|
|
|
|
|
|
|
|
|
|
Split::make([
|
|
|
|
|
DatePicker::make('order_date')
|
|
|
|
|
->required()
|
|
|
|
|
->default(today()),
|
|
|
|
|
DatePicker::make('due_date')
|
|
|
|
|
->required()
|
|
|
|
|
->default(today()->add('10 days')),
|
|
|
|
|
]),
|
|
|
|
|
])->columnSpan(1),
|
|
|
|
|
|
|
|
|
|
Section::make([
|
|
|
|
|
ToggleButtons::make('status')
|
|
|
|
|
->required()
|
|
|
|
|
->options(OrderStatus::class)
|
|
|
|
|
->inline(),
|
|
|
|
|
|
|
|
|
|
ToggleButtons::make('order_attributes')
|
|
|
|
|
->options(OrderAttributes::class)
|
|
|
|
|
->multiple()
|
|
|
|
|
->inline(),
|
|
|
|
|
|
|
|
|
|
Textarea::make('notes')
|
|
|
|
|
->rows(3),
|
|
|
|
|
|
|
|
|
|
])->columnSpan(1),
|
|
|
|
|
])->columns(2),
|
|
|
|
|
// Wizard\Step::make('Production Details')
|
|
|
|
|
// ->schema([]),
|
|
|
|
|
])->columns(1),
|
|
|
|
|
Wizard\Step::make('Order Details')
|
|
|
|
|
->schema(self::getOrderDetails())
|
|
|
|
|
->columns(2),
|
|
|
|
|
Wizard\Step::make('Garment Details')
|
|
|
|
|
->schema(self::getGarmentDetails()),
|
|
|
|
|
Wizard\Step::make('Production Details')
|
|
|
|
|
->schema(self::getProductionDetails()),
|
|
|
|
|
])
|
|
|
|
|
->skippable()
|
|
|
|
|
->submitAction(new HtmlString(Blade::render(<<<'BLADE'
|
|
|
|
|
<x-filament::button
|
|
|
|
|
type="submit"
|
|
|
|
|
size="sm"
|
|
|
|
|
>
|
|
|
|
|
Submit
|
|
|
|
|
</x-filament::button>
|
|
|
|
|
BLADE))),
|
|
|
|
|
])->columns(1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -179,4 +126,100 @@ class OrderResource extends Resource
|
|
|
|
|
'edit' => Pages\EditOrder::route('/{record}/edit'),
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static function getOrderDetails(): array
|
|
|
|
|
{
|
|
|
|
|
return [
|
|
|
|
|
Section::make([
|
|
|
|
|
Select::make('order_type')
|
|
|
|
|
->required()
|
|
|
|
|
->options(OrderType::class)
|
|
|
|
|
->searchable(),
|
|
|
|
|
|
|
|
|
|
Split::make([
|
|
|
|
|
Select::make('customer_id')
|
|
|
|
|
->required()
|
|
|
|
|
->label('Customer')
|
|
|
|
|
->options(Customer::all()->pluck('company_name', 'id'))
|
|
|
|
|
->reactive()
|
|
|
|
|
->searchable(),
|
|
|
|
|
|
|
|
|
|
Select::make('contact_id')
|
|
|
|
|
->label('Contact')
|
|
|
|
|
->options(fn ($get): array => Contact::where('customer_id', $get('customer_id') ?? null)->get()->pluck('full_name', 'id')->toArray())
|
|
|
|
|
->searchable(),
|
|
|
|
|
]),
|
|
|
|
|
|
|
|
|
|
TextInput::make('customer_po')
|
|
|
|
|
->required()
|
|
|
|
|
->label('Customer PO'),
|
|
|
|
|
|
|
|
|
|
Split::make([
|
|
|
|
|
DatePicker::make('order_date')
|
|
|
|
|
->required()
|
|
|
|
|
->default(today()),
|
|
|
|
|
DatePicker::make('due_date')
|
|
|
|
|
->required()
|
|
|
|
|
->default(today()->add('10 days')),
|
|
|
|
|
]),
|
|
|
|
|
])->columnSpan(1),
|
|
|
|
|
|
|
|
|
|
Section::make([
|
|
|
|
|
ToggleButtons::make('status')
|
|
|
|
|
->required()
|
|
|
|
|
->options(OrderStatus::class)
|
|
|
|
|
->inline(),
|
|
|
|
|
|
|
|
|
|
ToggleButtons::make('order_attributes')
|
|
|
|
|
->options(OrderAttributes::class)
|
|
|
|
|
->multiple()
|
|
|
|
|
->inline(),
|
|
|
|
|
|
|
|
|
|
Textarea::make('notes')
|
|
|
|
|
->rows(3),
|
|
|
|
|
|
|
|
|
|
])->columnSpan(1),
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static function getGarmentDetails(): array
|
|
|
|
|
{
|
|
|
|
|
return [
|
|
|
|
|
Repeater::make('Garments')->schema([
|
|
|
|
|
Split::make([
|
|
|
|
|
TextInput::make('sku')->grow(true),
|
|
|
|
|
TextInput::make('name')->grow(false),
|
|
|
|
|
TextInput::make('color')->grow(true),
|
|
|
|
|
]),
|
|
|
|
|
Split::make([
|
|
|
|
|
Cluster::make([
|
|
|
|
|
TextInput::make('xs')
|
|
|
|
|
->placeholder('xs'),
|
|
|
|
|
TextInput::make('s')
|
|
|
|
|
->placeholder('s'),
|
|
|
|
|
TextInput::make('m')
|
|
|
|
|
->placeholder('m'),
|
|
|
|
|
TextInput::make('l')
|
|
|
|
|
->placeholder('l'),
|
|
|
|
|
TextInput::make('xl')
|
|
|
|
|
->placeholder('xl'),
|
|
|
|
|
TextInput::make('2xl')
|
|
|
|
|
->placeholder('2xl'),
|
|
|
|
|
TextInput::make('3xl')
|
|
|
|
|
->placeholder('3xl'),
|
|
|
|
|
TextInput::make('osfa')
|
|
|
|
|
->placeholder('osfa'),
|
|
|
|
|
])->label('Sizes'),
|
|
|
|
|
]),
|
|
|
|
|
])->grid(2),
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static function getProductionDetails(): array
|
|
|
|
|
{
|
|
|
|
|
return [
|
|
|
|
|
Repeater::make('Production Details')
|
|
|
|
|
->schema([]),
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|