improve WO form: inline client/vehicle create, mechanic filter, category translation, PDF emoji fix
- client_id field: switched to relationship() with createOptionForm so new clients
can be created inline (name, phone, email); search also matches by phone
- vehicle_id field: added createOptionForm (make, model, plate, year, VIN); newly
created vehicle is automatically linked to the currently selected client
- master_id field: now shows only active users with role mechanic/master
- WorksRelationManager: labor catalog select marked optional; added createOptionForm
so new catalog entries can be added without leaving the WO form
- SubcontractJobsRelationManager: category table column now translates value via __()
and shows explicit label(__('Categorie'))
- PDF work-order: replaced 📞 / ✉ / ⚠ emojis with plain-text equivalents so
DomPDF/DejaVu Sans renders them correctly instead of showing "????"
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -84,16 +84,39 @@ class WorkOrderResource extends Resource
|
||||
Forms\Components\Select::make('urgency')->label(__('Urgență'))
|
||||
->options(\App\Support\I18n::opts(\App\Models\Tenant\PricingCoefficient::URGENCY))->default('normal')->required(),
|
||||
Forms\Components\Select::make('client_id')->label(__('Client'))
|
||||
->options(fn () => Client::pluck('name', 'id'))
|
||||
->searchable()->live()->required()->columnSpan(2),
|
||||
->relationship('client', 'name')
|
||||
->getSearchResultsUsing(fn (string $query) =>
|
||||
Client::where(fn ($q) => $q
|
||||
->where('name', 'like', "%{$query}%")
|
||||
->orWhere('phone', 'like', "%{$query}%"))
|
||||
->limit(30)->pluck('name', 'id'))
|
||||
->searchable()->live()->required()->columnSpan(2)
|
||||
->createOptionForm([
|
||||
Forms\Components\TextInput::make('name')->label(__('Nume'))->required(),
|
||||
Forms\Components\TextInput::make('phone')->label(__('Telefon')),
|
||||
Forms\Components\TextInput::make('email')->label(__('Email'))->email(),
|
||||
]),
|
||||
Forms\Components\Select::make('vehicle_id')->label(__('Auto'))
|
||||
->options(fn (Get $get) => $get('client_id')
|
||||
? Vehicle::where('client_id', $get('client_id'))->get()
|
||||
->mapWithKeys(fn ($v) => [$v->id => "{$v->make} {$v->model} {$v->plate}"])->toArray()
|
||||
: [])
|
||||
->searchable()->columnSpan(2),
|
||||
->searchable()->columnSpan(2)
|
||||
->createOptionForm([
|
||||
Forms\Components\TextInput::make('make')->label(__('Marcă'))->required(),
|
||||
Forms\Components\TextInput::make('model')->label(__('Model'))->required(),
|
||||
Forms\Components\TextInput::make('plate')->label(__('Nr. înmatriculare'))->required(),
|
||||
Forms\Components\TextInput::make('year')->label(__('An'))->numeric(),
|
||||
Forms\Components\TextInput::make('vin')->label(__('VIN')),
|
||||
])
|
||||
->createOptionUsing(function (array $data, \Livewire\Component $livewire) {
|
||||
$data['client_id'] = data_get((array) $livewire->data, 'client_id');
|
||||
return Vehicle::create($data)->id;
|
||||
}),
|
||||
Forms\Components\Select::make('master_id')->label(__('Maistru'))
|
||||
->options(fn () => User::where('status', 'active')->pluck('name', 'id'))
|
||||
->options(fn () => User::where('status', 'active')
|
||||
->whereIn('role', ['mechanic', 'master'])
|
||||
->pluck('name', 'id'))
|
||||
->searchable()->columnSpan(2),
|
||||
Forms\Components\TextInput::make('mileage_in')->label(__('Km intrare'))->numeric(),
|
||||
Forms\Components\TextInput::make('mileage_out')->label(__('Km ieșire'))->numeric(),
|
||||
|
||||
Reference in New Issue
Block a user