diff --git a/app/Filament/Pages/Supporto/TicketGestione.php b/app/Filament/Pages/Supporto/TicketGestione.php index 77b6b0a..51f022a 100644 --- a/app/Filament/Pages/Supporto/TicketGestione.php +++ b/app/Filament/Pages/Supporto/TicketGestione.php @@ -387,7 +387,8 @@ private function loadTickets(): void } $query = Ticket::query() - ->with(['categoriaTicket', 'assegnatoAFornitore:id,ragione_sociale,nome,cognome']) + ->with(['categoriaTicket', 'assegnatoAFornitore:id,ragione_sociale,nome,cognome', 'assegnatoAUser:id,name']) + ->withCount('attachments') ->where('stabile_id', $stabileId); if ($this->status === 'open') { diff --git a/app/Filament/Pages/Supporto/TicketMobile.php b/app/Filament/Pages/Supporto/TicketMobile.php index d1955e3..d7630b7 100644 --- a/app/Filament/Pages/Supporto/TicketMobile.php +++ b/app/Filament/Pages/Supporto/TicketMobile.php @@ -290,21 +290,32 @@ public function selezionaCaller(int $rubricaId): void public function creaTicketRapido(): void { $this->validate([ - 'newTicketTitolo' => ['required', 'string', 'max:255'], - 'newTicketDescrizione' => ['required', 'string'], - 'newTicketLuogo' => ['nullable', 'string', 'max:255'], - 'newTicketPriorita' => ['required', 'in:Bassa,Media,Alta,Urgente'], - 'newTicketCategoriaId' => ['nullable', 'integer', 'exists:categorie_ticket,id'], - 'newTicketTipoIntervento' => ['nullable', 'string', 'max:80'], - 'newTicketFotoNote' => ['nullable', 'string', 'max:2000'], - 'newTicketCameraShots' => ['nullable', 'array', 'max:8'], - 'newTicketCameraShots.*' => ['file', 'max:10240', 'mimes:jpg,jpeg,png,webp'], - 'newTicketAttachments' => ['nullable', 'array', 'max:8'], - 'newTicketAttachments.*' => ['file', 'max:10240', 'mimes:jpg,jpeg,png,webp,pdf,doc,docx,xls,xlsx,txt'], + 'newTicketTitolo' => ['required', 'string', 'max:255'], + 'newTicketDescrizione' => ['required', 'string'], + 'newTicketLuogo' => ['nullable', 'string', 'max:255'], + 'newTicketPriorita' => ['required', 'in:Bassa,Media,Alta,Urgente'], + 'newTicketCategoriaId' => ['nullable', 'integer', 'exists:categorie_ticket,id'], + 'newTicketTipoIntervento' => ['nullable', 'string', 'max:80'], + 'newTicketFotoNote' => ['nullable', 'string', 'max:2000'], + 'newTicketCameraShots' => ['nullable', 'array', 'max:10'], + 'newTicketCameraShots.*' => ['file', 'max:10240', 'mimes:jpg,jpeg,png,webp'], + 'newTicketAttachments' => ['nullable', 'array', 'max:10'], + 'newTicketAttachments.*' => ['file', 'max:10240', 'mimes:jpg,jpeg,png,webp,pdf,doc,docx,xls,xlsx,txt'], 'newTicketAttachmentDescriptions' => ['nullable', 'array'], 'newTicketAttachmentDescriptions.*' => ['nullable', 'string', 'max:255'], ]); + $totalUploads = count($this->newTicketCameraShots) + count($this->newTicketAttachments); + if ($totalUploads > 10) { + Notification::make() + ->title('Troppi allegati selezionati') + ->body('Puoi caricare al massimo 10 file totali (foto + documenti) per ticket.') + ->warning() + ->send(); + + return; + } + $user = Auth::user(); if (! $user instanceof User) { return; @@ -375,16 +386,16 @@ public function creaTicketRapido(): void ->success() ->send(); - $this->newTicketTitolo = null; - $this->newTicketDescrizione = null; - $this->newTicketLuogo = null; - $this->newTicketPriorita = 'Media'; - $this->newTicketCategoriaId = null; - $this->newTicketTipoIntervento = 'altro'; - $this->newTicketCameraShots = []; - $this->newTicketAttachments = []; + $this->newTicketTitolo = null; + $this->newTicketDescrizione = null; + $this->newTicketLuogo = null; + $this->newTicketPriorita = 'Media'; + $this->newTicketCategoriaId = null; + $this->newTicketTipoIntervento = 'altro'; + $this->newTicketCameraShots = []; + $this->newTicketAttachments = []; $this->newTicketAttachmentDescriptions = []; - $this->newTicketFotoNote = null; + $this->newTicketFotoNote = null; $this->refreshData(); } @@ -419,7 +430,7 @@ public function removeNewTicketFile(int $index): void */ public function getSelectedUploadsProperty(): array { - $rows = []; + $rows = []; $files = array_merge($this->newTicketCameraShots, $this->newTicketAttachments); foreach ($files as $index => $file) { @@ -427,8 +438,8 @@ public function getSelectedUploadsProperty(): array continue; } - $name = (string) (method_exists($file, 'getClientOriginalName') ? $file->getClientOriginalName() : ('file-' . $index)); - $mime = (string) (method_exists($file, 'getClientMimeType') ? $file->getClientMimeType() : 'application/octet-stream'); + $name = (string) (method_exists($file, 'getClientOriginalName') ? $file->getClientOriginalName() : ('file-' . $index)); + $mime = (string) (method_exists($file, 'getClientMimeType') ? $file->getClientMimeType() : 'application/octet-stream'); $isImage = str_starts_with($mime, 'image/'); $previewUrl = null; @@ -510,7 +521,7 @@ private function salvaAllegatiTicket(Ticket $ticket, int $userId): int private function syncAttachmentDescriptionSlots(): void { $files = array_merge($this->newTicketCameraShots, $this->newTicketAttachments); - $next = []; + $next = []; foreach ($files as $index => $_file) { $next[$index] = (string) ($this->newTicketAttachmentDescriptions[$index] ?? ''); diff --git a/resources/views/filament/pages/supporto/ticket-gestione.blade.php b/resources/views/filament/pages/supporto/ticket-gestione.blade.php index a03de2f..19d7012 100644 --- a/resources/views/filament/pages/supporto/ticket-gestione.blade.php +++ b/resources/views/filament/pages/supporto/ticket-gestione.blade.php @@ -40,6 +40,7 @@ ID Titolo Categoria + Assegnato a Priorita Stato Apertura @@ -50,8 +51,18 @@ @forelse($tickets as $ticket) #{{ (int) $ticket->id }} - {{ $ticket->titolo }} + +
+ {{ $ticket->titolo }} + @if(((int) ($ticket->attachments_count ?? 0)) > 0) + + ATT {{ (int) $ticket->attachments_count }} + + @endif +
+ {{ optional($ticket->categoriaTicket)->nome ?: '-' }} + {{ optional($ticket->assegnatoAUser)->name ?: '-' }} {{ $ticket->priorita }} {{ $ticket->stato }} {{ optional($ticket->data_apertura)->format('d/m/Y H:i') }} @@ -80,7 +91,7 @@ @empty - Nessun ticket per il filtro selezionato. + Nessun ticket per il filtro selezionato. @endforelse diff --git a/resources/views/filament/pages/supporto/ticket-mobile.blade.php b/resources/views/filament/pages/supporto/ticket-mobile.blade.php index 8eb3570..773db58 100644 --- a/resources/views/filament/pages/supporto/ticket-mobile.blade.php +++ b/resources/views/filament/pages/supporto/ticket-mobile.blade.php @@ -140,10 +140,11 @@ -
Dopo ogni scatto puoi aggiungere subito la descrizione. Se servono altre foto usa di nuovo "Scatta foto".
+
Puoi caricare fino a 10 file totali (foto + documenti). Ogni file ha descrizione separata.
+
iPhone: su "Aggiungi allegati" scegli "Sfoglia" per aprire l'app File (iCloud Drive/On My iPhone).
@if(count($this->selectedUploads) > 0)