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:
2026-09-08 08:16:21 +00:00
parent aa231f4b08
commit 1e7ca0fdfe
4 changed files with 83 additions and 4 deletions
@@ -696,12 +696,34 @@
{{-- ── PHOTOS TAB ── --}}
<div x-show="tab === 'photos'" x-cloak>
@php $photos = $wo->getMedia('photos'); @endphp
{{-- Upload --}}
<div style="display:flex;align-items:center;gap:10px;margin-bottom:14px;flex-wrap:wrap;">
<label style="display:inline-flex;align-items:center;gap:6px;padding:7px 14px;background:#f3f4f6;border:1px solid #d1d5db;border-radius:6px;cursor:pointer;font-size:.875rem;font-weight:500;">
📎 {{ __('Alege foto') }}
<input type="file" wire:model="newPhotos" multiple accept="image/*" style="display:none;">
</label>
@if (!empty($newPhotos))
<button type="button" wire:click="uploadPhotos" class="wd-btn wd-btn-primary">
⬆ {{ __('Încarcă') }} ({{ count($newPhotos) }})
</button>
<span wire:loading wire:target="newPhotos" style="font-size:.8rem;color:#6b7280;">{{ __('Se procesează...') }}</span>
@endif
</div>
{{-- Gallery --}}
@if ($photos->isNotEmpty())
<div style="display:grid;grid-template-columns:repeat(auto-fill,minmax(140px,1fr));gap:10px;">
@foreach ($photos as $ph)
<a href="{{ $ph->getFullUrl() }}" target="_blank">
<img src="{{ $ph->getFullUrl() }}" style="width:100%;aspect-ratio:4/3;object-fit:cover;border-radius:6px;border:1px solid var(--wd-border);">
</a>
<div style="position:relative;">
<a href="{{ $ph->getFullUrl() }}" target="_blank">
<img src="{{ $ph->getFullUrl() }}" style="width:100%;aspect-ratio:4/3;object-fit:cover;border-radius:6px;border:1px solid var(--wd-border);">
</a>
<button type="button"
wire:click="deletePhoto({{ $ph->id }})"
wire:confirm="{{ __('Șterge fotografia?') }}"
style="position:absolute;top:4px;right:4px;background:rgba(0,0,0,.55);color:#fff;border:none;border-radius:50%;width:22px;height:22px;font-size:12px;cursor:pointer;line-height:1;">✕</button>
</div>
@endforeach
</div>
@else