diff --git a/app/Filament/Admin/Resources/OrderResource.php b/app/Filament/Admin/Resources/OrderResource.php index aa9055b..854342c 100644 --- a/app/Filament/Admin/Resources/OrderResource.php +++ b/app/Filament/Admin/Resources/OrderResource.php @@ -6,7 +6,6 @@ use App\Enums\OrderAttributes; use App\Enums\OrderStatus; use App\Enums\OrderType; -use App\Models\Contact; use App\Models\Customer; use App\Models\Order; use App\Models\OrderProduct; @@ -62,18 +61,8 @@ public static function form(Form $form): Form ->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'), diff --git a/app/Filament/Admin/Resources/QuoteResource.php b/app/Filament/Admin/Resources/QuoteResource.php index 9764112..044dd3d 100644 --- a/app/Filament/Admin/Resources/QuoteResource.php +++ b/app/Filament/Admin/Resources/QuoteResource.php @@ -4,16 +4,18 @@ use App\Enums\IconEnum; use App\Models\Customer; -use App\Models\Order; use App\Models\Quote; -use Filament\Forms\Components\RichEditor; +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; +use Filament\Forms\Components\Textarea; +use Filament\Forms\Components\TextInput; use Filament\Forms\Form; use Filament\Resources\Resource; use Filament\Tables; use Filament\Tables\Table; +use Icetalker\FilamentTableRepeater\Forms\Components\TableRepeater; class QuoteResource extends Resource { @@ -30,28 +32,63 @@ public static function form(Form $form): Form return $form ->schema([ Section::make([ - Split::make([ - Select::make('customer_id') - ->required() - ->label('Customer') - ->options(Customer::all()->pluck('company_name', 'id')) - ->reactive() - ->searchable(), + Select::make('customer_id') + ->required() + ->label('Customer') + ->options(Customer::all()->pluck('company_name', 'id')) + ->reactive() + ->searchable() + ->columnSpan(1), - Select::make('order_id') - ->label('Order') - ->options(fn ($get): array => Order::where('customer_id', $get('customer_id') ?? null) - ->get() - ->pluck('customer_po', 'id') - ->toArray()) - ->searchable(), + DatePicker::make('date') + ->required(), - ])->columnSpan(2), - RichEditor::make('body') + TextArea::make('notes') ->columnSpan(2), - // ->rows(8), - ]), - ])->columns(3); + ]) + ->columns(2), + + TableRepeater::make('embroideryEntries') + ->relationship('embroideryEntries') + ->schema([ + TextInput::make('logo') + ->label('Logo name'), + TextInput::make('placement'), + TextInput::make('quantity') + ->prefix('#'), + TextInput::make('width') + ->suffix('"'), + TextInput::make('height') + ->suffix('"'), + TextInput::make('stitch_count'), + TextInput::make('digitizing_cost') + ->prefix('$'), + TextInput::make('run_charge') + ->prefix('$'), + ]), + + Repeater::make('screenPrintEntries') + ->relationship('screenPrintEntries') + ->schema([ + TextInput::make('logo') + ->label('Logo name'), + ]), + + TableRepeater::make('heatTransferEntries') + ->relationship('heatTransferEntries') + ->schema([ + TextInput::make('logo') + ->label('Logo name'), + TextInput::make('quantity') + ->prefix('#'), + TextInput::make('Width') + ->suffix('"'), + TextInput::make('Height') + ->suffix('"'), + TextInput::make('price') + ->prefix('$'), + ]), + ])->columns(1); } public static function table(Table $table): Table diff --git a/app/Models/EmbroideryEntry.php b/app/Models/EmbroideryEntry.php new file mode 100644 index 0000000..52ea268 --- /dev/null +++ b/app/Models/EmbroideryEntry.php @@ -0,0 +1,26 @@ +belongsTo(Quote::class); + } +} diff --git a/app/Models/HeatTransferEntry.php b/app/Models/HeatTransferEntry.php new file mode 100644 index 0000000..1087cdd --- /dev/null +++ b/app/Models/HeatTransferEntry.php @@ -0,0 +1,23 @@ +belongsTo(Quote::class); + } +} diff --git a/app/Models/Quote.php b/app/Models/Quote.php index e86a67f..5a594e2 100644 --- a/app/Models/Quote.php +++ b/app/Models/Quote.php @@ -5,6 +5,7 @@ use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\BelongsTo; +use Illuminate\Database\Eloquent\Relations\HasMany; class Quote extends Model { @@ -19,4 +20,19 @@ public function order(): BelongsTo { return $this->belongsTo(Order::class); } + + public function embroideryEntries(): HasMany + { + return $this->hasMany(EmbroideryEntry::class); + } + + public function screenPrintEntries(): HasMany + { + return $this->hasMany(ScreenPrintEntry::class); + } + + public function heatTransferEntries(): HasMany + { + return $this->hasMany(HeatTransferEntry::class); + } } diff --git a/app/Models/ScreenPrintEntry.php b/app/Models/ScreenPrintEntry.php new file mode 100644 index 0000000..c732a56 --- /dev/null +++ b/app/Models/ScreenPrintEntry.php @@ -0,0 +1,32 @@ +belongsTo(Quote::class); + } +} diff --git a/database/migrations/020_create_embroidery_entries_table.php b/database/migrations/020_create_embroidery_entries_table.php new file mode 100644 index 0000000..1e013b3 --- /dev/null +++ b/database/migrations/020_create_embroidery_entries_table.php @@ -0,0 +1,40 @@ +id(); + + $table->foreignId('quote_id')->constrained(); + + $table->integer('quantity')->nullable(); + $table->string('logo')->nullable(); + $table->decimal('width', 6, 2)->nullable(); + $table->decimal('height', 6, 2)->nullable(); + $table->string('placement')->nullable(); + $table->string('stitches')->nullable(); + $table->string('digitizing_cost')->nullable(); + $table->string('run_charge')->nullable(); + $table->text('notes')->nullable(); + + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('embroidery_entries'); + } +}; diff --git a/database/migrations/021_create_screen_print_entries_table.php b/database/migrations/021_create_screen_print_entries_table.php new file mode 100644 index 0000000..0cb98fa --- /dev/null +++ b/database/migrations/021_create_screen_print_entries_table.php @@ -0,0 +1,45 @@ +id(); + + $table->foreignId('quote_id')->constrained(); + + $table->integer('quantity')->nullable(); + $table->string('logo')->nullable(); + $table->decimal('width', 6, 2)->nullable(); + $table->decimal('height', 6, 2)->nullable(); + $table->integer('color_amount')->nullable(); + $table->integer('setup_amount')->nullable(); + $table->decimal('run_charge', 8, 2)->nullable(); + $table->boolean('color_change')->default(false); + $table->boolean('color_match')->default(false); + $table->boolean('flash')->default(false); + $table->boolean('fleece')->default(false); + $table->boolean('poly_ink')->default(false); + $table->boolean('other_charges')->default(false); + $table->text('notes')->nullable(); + + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('screen_print_entries'); + } +}; diff --git a/database/migrations/022_create_heat_transfer_entries_table.php b/database/migrations/022_create_heat_transfer_entries_table.php new file mode 100644 index 0000000..d8dd7d6 --- /dev/null +++ b/database/migrations/022_create_heat_transfer_entries_table.php @@ -0,0 +1,36 @@ +id(); + + $table->foreignId('quote_id')->constrained(); + + $table->integer('quantity')->nullable(); + $table->string('logo')->nullable(); + $table->decimal('width', 6, 2)->nullable(); + $table->decimal('height', 6, 2)->nullable(); + $table->decimal('price', 8, 2)->nullable(); + + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('heat_transfer_entries'); + } +};