{{-- Top Bar / Search & Quick Actions --}}
{{-- Gmail Search Box --}}
@if($searchQuery) @endif
{{-- Stabile Filter Dropdown --}}
Configura IMAP
{{-- Main Layout: Sidebar + Message List / Detail --}}
{{-- Left Navigation Sidebar --}}
{{-- Compose Button --}} {{-- Folder Navigation --}}
@php $counts = $this->folderCounts; @endphp
{{-- Type indicator Card --}}
@if($tipoCasella === 'pec') Canale PEC Certificato @else Posta Ordinaria / Gmail @endif

I messaggi scaricati vengono salvati integralmente come file .EML nello storage dello stabile.

{{-- Main Message Center --}}
@if($this->selectedMessage) {{-- MESSAGE DETAIL READER VIEW --}} @php $msg = $this->selectedMessage; $meta = is_array($msg->metadata) ? $msg->metadata : []; $attachments = is_array($msg->attachments) ? $msg->attachments : []; $isStarred = $meta['is_starred'] ?? false; @endphp
{{-- Top Action Toolbar --}}
@if(! $msg->ticket_id) @else Ticket #{{ $msg->ticket_id }} Collegato @endif
{{-- Message Header --}}

{{ $meta['subject'] ?? '(Nessun Oggetto)' }}

@if($msg->stabile) {{ $msg->stabile->codice_stabile }} - {{ $msg->stabile->denominazione }} @endif
{{ strtoupper(substr($msg->sender_name ?: 'A', 0, 1)) }}
{{ $msg->sender_name ?: ($meta['sender_email'] ?? 'Mittente Sconosciuto') }}
A: {{ $meta['recipient_email'] ?? 'Amministrazione' }}
{{ $msg->received_at ? \Illuminate\Support\Carbon::parse($msg->received_at)->translatedFormat('d F Y, H:i') : '' }}
Canale: {{ $msg->channel }}
{{-- Message Body Content --}}
@if(!empty($meta['body_html']))
{!! $meta['body_html'] !!}
@else
{{ $msg->message_text }}
@endif
{{-- Attachments Section --}} @if(!empty($attachments))

Allegati del messaggio ({{ count($attachments) }})

@foreach($attachments as $att) @php $fname = $att['filename'] ?? 'allegato'; $fsize = $att['size'] ?? 0; $fpath = $att['path'] ?? ''; $ftype = $att['content_type'] ?? 'application/octet-stream'; $isImg = str_starts_with($ftype, 'image/'); $isPdf = str_contains($ftype, 'pdf') || str_ends_with(strtolower($fname), '.pdf'); @endphp
@if($isImg) ๐Ÿ–ผ๏ธ @elseif($isPdf) ๐Ÿ“„ @else ๐Ÿ“Ž @endif
{{ $fname }}
{{ number_format($fsize / 1024, 1) }} KB
@endforeach
@endif
@else {{-- MESSAGES LIST VIEW (GMAIL STYLE) --}} @php $messages = $this->messages; @endphp
{{-- Action Bar --}}
{{ $currentFolder === 'inbox' ? 'Posta in arrivo' : ($currentFolder === 'sent' ? 'Messaggi inviati' : ($currentFolder === 'starred' ? 'Messaggi speciali' : 'Con allegati')) }} @if($selectedStabileId) Filtro Stabile attivo @endif
{{ $messages->total() }} messaggi totali
{{-- Rows Table --}}
@forelse($messages as $msg) @php $meta = is_array($msg->metadata) ? $msg->metadata : []; $attachments = is_array($msg->attachments) ? $msg->attachments : []; $isUnread = $msg->status === 'received' && $msg->direction === 'inbound'; $isStarred = $meta['is_starred'] ?? false; $dateStr = $msg->received_at ? \Illuminate\Support\Carbon::parse($msg->received_at)->diffForHumans() : ''; if ($msg->received_at) { $dt = \Illuminate\Support\Carbon::parse($msg->received_at); $dateFormatted = $dt->isToday() ? $dt->format('H:i') : ($dt->isCurrentYear() ? $dt->translatedFormat('j M') : $dt->format('d/m/Y')); } else { $dateFormatted = ''; } @endphp
{{-- Left: Checkbox + Star + Sender --}}
{{ $msg->sender_name ?: ($meta['sender_email'] ?? 'Sconosciuto') }}
{{-- Middle: Stabile Pill + Subject + Snippet + Attachment Pills --}}
@if($msg->stabile) {{ $msg->stabile->codice_stabile }} @endif
{{ $meta['subject'] ?? '(Nessun oggetto)' }} - {{ Str::limit(strip_tags($msg->message_text), 70) }}
{{-- Attachment Chips (Like Gmail) --}} @if(!empty($attachments))
@foreach(array_slice($attachments, 0, 2) as $att) @php $fname = $att['filename'] ?? 'allegato'; $isPdf = str_ends_with(strtolower($fname), '.pdf'); $isImg = preg_match('/\.(jpg|jpeg|png|webp|gif)$/i', $fname); @endphp @if($isPdf) PDF @elseif($isImg) IMG @else ๐Ÿ“Ž @endif {{ $fname }} @endforeach @if(count($attachments) > 2) +{{ count($attachments) - 2 }} @endif
@endif
{{-- Right: Date & Quick Actions on Hover --}}
@if($msg->ticket_id) ๐ŸŽŸ๏ธ #{{ $msg->ticket_id }} @endif {{ $dateFormatted }}
@empty
Nessun messaggio presente in questa cartella

Se non hai ancora configurato la casella IMAP o PEC, puoi inserire parametri e credenziali per abilitare lo scaricamento e la visualizzazione automatica.

@endforelse
{{-- Pagination Footer --}} @if($messages->hasPages())
{{ $messages->links() }}
@endif
@endif
{{-- Compose Modal --}} @if($isComposing)
Nuovo Messaggio ({{ strtoupper($tipoCasella) }})
@endif {{-- Attachment Preview Modal --}} @if($showAttachmentModal && $activeAttachment)
{{ $activeAttachment['filename'] }}
@php $fname = $activeAttachment['filename']; $ftype = $activeAttachment['content_type']; $fpath = $activeAttachment['path']; $exists = $activeAttachment['exists']; $isImg = str_starts_with($ftype, 'image/') || preg_match('/\.(jpg|jpeg|png|webp|gif)$/i', $fname); $isPdf = str_contains($ftype, 'pdf') || str_ends_with(strtolower($fname), '.pdf'); @endphp @if(! $exists)
Il file dell'allegato non รจ al momento presente nel filesystem locale.
@elseif($isImg) @php $b64 = base64_encode(file_get_contents($fpath)); @endphp {{ $fname }} @elseif($isPdf) @php $b64 = base64_encode(file_get_contents($fpath)); @endphp @else
{{ $fname }}
Tipo: {{ $ftype }}
@endif
@endif