#132: Inches / cm toggle for order page

Also shows size unit on PDFs
This commit is contained in:
Nisse Lommerde 2025-04-11 16:17:51 -04:00
parent f02fb63bfd
commit 2d5688b66e
10 changed files with 55 additions and 11 deletions

View File

@ -1,4 +1,7 @@
# Changelog # Changelog
**2025-04-11**
- Fixed #132 - Inches / cm toggle for order page (and show unit on pdf)
**2025-04-10** **2025-04-10**
- Fixed #145 - Default order sort is incorrect (newest will always show on top now) - Fixed #145 - Default order sort is incorrect (newest will always show on top now)
- Fixed #142 - Packing Slip content field should be required - Fixed #142 - Packing Slip content field should be required

View File

@ -230,7 +230,7 @@ public static function form(Form $form): Form
->prefix('h') ->prefix('h')
->rules('numeric'), ->rules('numeric'),
]) ])
->label('Dimensions (inches)') ->label('Dimensions')
->columnSpan(4), ->columnSpan(4),
TextInput::make('amount') TextInput::make('amount')
@ -247,17 +247,28 @@ public static function form(Form $form): Form
->rules('numeric'), ->rules('numeric'),
]), ]),
Grid::make(9) Grid::make(19)
->schema([ ->schema([
TextInput::make('serviceFileCode') TextInput::make('serviceFileCode')
->label('Code') ->label('Code')
->datalist(ServiceFile::all()->unique('code')->pluck('code')->toArray()) ->datalist(ServiceFile::all()->unique('code')->pluck('code')->toArray())
->columnSpan(1) ->columnSpan(2)
->placeholder('A1234'), ->placeholder('A1234'),
Select::make('serviceFileSizeUnit')
->columnSpan(2)
->selectablePlaceholder(false)
->label('Unit')
->options([
'in' => 'Inches',
'cm' => 'cm',
]),
Textarea::make('notes') Textarea::make('notes')
->placeholder('Thread colors...') ->placeholder('Thread colors... (press enter for new line)')
->columnSpan(8), ->autosize()
->rows(1)
->columnSpan(15),
]), ]),
]) ])
->reorderable() ->reorderable()

View File

@ -63,6 +63,7 @@ protected function handleRecordCreation(array $data): Order
'width' => $service['serviceFileWidth'] ?? null, 'width' => $service['serviceFileWidth'] ?? null,
'height' => $service['serviceFileHeight'] ?? null, 'height' => $service['serviceFileHeight'] ?? null,
'setup_number' => $service['serviceFileSetupNumber'] ?? null, 'setup_number' => $service['serviceFileSetupNumber'] ?? null,
'size_unit' => $service['serviceFileSizeUnit'] ?? 'inch',
]); ]);
ProductService::create([ ProductService::create([

View File

@ -68,6 +68,7 @@ protected function mutateFormDataBeforeFill(array $data): array
'serviceFileHeight' => $service->serviceFile->height ?? '', 'serviceFileHeight' => $service->serviceFile->height ?? '',
'serviceFileCode' => $service->serviceFile->code ?? '', 'serviceFileCode' => $service->serviceFile->code ?? '',
'serviceFileSetupNumber' => $service->serviceFile->setup_number ?? '', 'serviceFileSetupNumber' => $service->serviceFile->setup_number ?? '',
'serviceFileSizeUnit' => $service->serviceFile->size_unit ?? 'inch',
]; ];
} }
@ -139,6 +140,7 @@ public function handleRecordUpdate(Model $record, array $data): Model
'width' => $service['serviceFileWidth'] ?? null, 'width' => $service['serviceFileWidth'] ?? null,
'height' => $service['serviceFileHeight'] ?? null, 'height' => $service['serviceFileHeight'] ?? null,
'setup_number' => $service['serviceFileSetupNumber'] ?? null, 'setup_number' => $service['serviceFileSetupNumber'] ?? null,
'size_unit' => $service['serviceFileSizeUnit'] ?? 'inch',
]); ]);
ProductService::create([ ProductService::create([

View File

@ -26,6 +26,7 @@ class ProductService extends Model
'amount', 'amount',
'amount_price', 'amount_price',
'notes', 'notes',
'size_unit',
]; ];
protected $appends = [ protected $appends = [

View File

@ -19,6 +19,7 @@ class ServiceFile extends Model
'width', 'width',
'height', 'height',
'setup_number', 'setup_number',
'size_unit',
]; ];
/** /**

View File

@ -25,7 +25,7 @@
| or any other location as required by the application or its packages. | or any other location as required by the application or its packages.
*/ */
'version' => '20250410', 'version' => '20250411',
/* /*
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------

View File

@ -19,7 +19,6 @@ public function definition(): array
'name' => $this->faker->word(), 'name' => $this->faker->word(),
'width' => round($this->faker->randomFloat(2, 0, 10), 1), 'width' => round($this->faker->randomFloat(2, 0, 10), 1),
'height' => round($this->faker->randomFloat(2, 0, 10), 1), 'height' => round($this->faker->randomFloat(2, 0, 10), 1),
'unit' => 'inch',
]; ];
} }
} }

View File

@ -0,0 +1,22 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
Schema::table('service_files', function (Blueprint $table) {
$table->string('size_unit')->default('in');
});
}
public function down(): void
{
Schema::table('service_files', function (Blueprint $table) {
$table->dropColumn('size_unit');
});
}
};

View File

@ -155,7 +155,7 @@
<tbody> <tbody>
@foreach($order->orderProducts as $product) @foreach($order->orderProducts as $product)
<tr> <tr>
<td><code>{{$product->sku}}</code></td> <td><code style="font-size: 0.9rem;">{{$product->sku}}</code></td>
<td class="text-uppercase">{{$product->product_name}}</td> <td class="text-uppercase">{{$product->product_name}}</td>
<td class="text-uppercase">{{$product->color}}</td> <td class="text-uppercase">{{$product->color}}</td>
<td style="width: 40px;">{{$product->productSizes()->get()->where('size', 'xs')->first()->amount ?? ''}}</td> <td style="width: 40px;">{{$product->productSizes()->get()->where('size', 'xs')->first()->amount ?? ''}}</td>
@ -190,6 +190,7 @@
<th class="w-50">Logo Name & Instructions</th> <th class="w-50">Logo Name & Instructions</th>
<th>Width</th> <th>Width</th>
<th>Height</th> <th>Height</th>
<th>Unit</th>
<th>QTY</th> <th>QTY</th>
</thead> </thead>
@ -203,17 +204,17 @@
<br> <br>
<div class="text-uppercase"> <div class="text-uppercase">
<code style="font-size: 14px"> <code style="font-size: 14px">
{{$service->serviceFile->code}} {{$service->serviceFile->code ?? ''}}
</code> </code>
</div> </div>
</td> </td>
<td> <td>
<div class="text-uppercase"> <div class="text-uppercase">
{{$service->serviceFile->name}} {{$service->serviceFile->name ?? ''}}
</div> </div>
<br> <br>
<div class="text-uppercase" style="color: #d63384;"> <div class="text-uppercase" style="color: #d63384;">
{{$service->notes}} {{$service->notes ?? ''}}
</div> </div>
</td> </td>
<td> <td>
@ -222,6 +223,9 @@
<td> <td>
{{$service->serviceFile->height}} {{$service->serviceFile->height}}
</td> </td>
<td>
{{$service->serviceFile->size_unit}}
</td>
<td> <td>
{{$service->amount}} {{$service->amount}}
</td> </td>