feat: partial payment field + photo upload from dashboard
- WorkOrderResource: pay_status is now live(); added _partial_amount TextInput (visible only when pay_status=partial) that shows current paid amount and accepts a new total — dehydrated so it does not save directly; _achitat hidden when partial is selected to avoid confusion - EditWorkOrder.afterSave: creates a Payment record for the difference when pay_status=partial and entered amount > existing paidAmount - WorkOrderDashboard: WithFileUploads + uploadPhotos / deletePhoto methods using Spatie MediaLibrary - Dashboard blade: Foto tab replaced with upload form + gallery with per-photo delete buttons Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -148,7 +148,7 @@ class WorkOrderResource extends Resource
|
||||
Schemas\Components\Section::make(__('Plată & total'))
|
||||
->columns(3)->collapsible()->collapsed()->compact()
|
||||
->schema([
|
||||
Forms\Components\Select::make('pay_status')->label(__('Statut plată'))->options(\App\Support\I18n::opts(WorkOrder::PAY_STATUSES))->default('unpaid')->required(),
|
||||
Forms\Components\Select::make('pay_status')->label(__('Statut plată'))->options(\App\Support\I18n::opts(WorkOrder::PAY_STATUSES))->default('unpaid')->required()->live(),
|
||||
Forms\Components\TextInput::make('discount_pct')
|
||||
->label(__('Reducere %'))
|
||||
->numeric()
|
||||
@@ -177,10 +177,18 @@ class WorkOrderResource extends Resource
|
||||
->label(__('Total (MDL)'))
|
||||
->numeric()->readOnly()->dehydrated(false)
|
||||
->extraAttributes(['style' => 'font-weight:600']),
|
||||
Forms\Components\TextInput::make('_partial_amount')
|
||||
->label(__('Sumă achitată (MDL)'))
|
||||
->numeric()->minValue(0)->step(0.01)
|
||||
->dehydrated(false)
|
||||
->default(fn ($record) => $record ? $record->paidAmount() : 0)
|
||||
->visible(fn (Get $get) => $get('pay_status') === 'partial')
|
||||
->helperText(__('Introduceți suma achitată — se înregistrează automat ca plată la salvare')),
|
||||
Forms\Components\TextInput::make('_achitat')
|
||||
->label(__('Achitat (MDL)'))
|
||||
->readOnly()->dehydrated(false)
|
||||
->default(fn ($record) => $record ? number_format($record->paidAmount(), 2, '.', '') : '0.00')
|
||||
->visible(fn (Get $get) => $get('pay_status') !== 'partial')
|
||||
->extraAttributes(['style' => 'color:#16a34a;font-weight:600']),
|
||||
Forms\Components\TextInput::make('_rest')
|
||||
->label(__('Rest de achitat (MDL)'))
|
||||
|
||||
Reference in New Issue
Block a user