155 lines
9.3 KiB
PHP
155 lines
9.3 KiB
PHP
@extends('layouts.adminlte')
|
|
|
|
@section('title', 'Ricerca per Tag')
|
|
@section('page_title', 'Ricerca per Tag')
|
|
|
|
@section('content')
|
|
<div class="card">
|
|
<div class="card-header">
|
|
<h3 class="card-title"><i class="fas fa-tags mr-2"></i>
|
|
@isset($selectedTags)
|
|
Risultati per:
|
|
@foreach($selectedTags as $t)
|
|
<span class="badge" style="background-color: {{ $t->color ?? '#6c757d' }}; color: #fff; font-size: 0.9rem; margin: 0 2px;">{{ $t->name }}</span>
|
|
@endforeach
|
|
@if(count($tagSlugs) > 1)
|
|
<small class="text-muted ml-1">(intersezione — tutti i tag richiesti)</small>
|
|
@endif
|
|
@else
|
|
Seleziona uno o più tag
|
|
@endisset
|
|
</h3>
|
|
</div>
|
|
<div class="card-body">
|
|
@if(!isset($selectedTags) || $selectedTags->isEmpty())
|
|
<p class="text-muted">Clicca sui tag per selezionarli (Ctrl+click per più tag).</p>
|
|
<form method="GET" action="{{ route('ricerca.index') }}" id="tag-form">
|
|
<div style="display:flex;flex-wrap:wrap;gap:8px;">
|
|
@foreach($allTags as $t)
|
|
<label class="btn btn-sm" style="background-color: {{ $t->color ?? '#6c757d' }}; color: #fff; border-radius: 14px; cursor:pointer; opacity: 0.7;">
|
|
<input type="checkbox" name="tag[]" value="{{ $t->slug }}" class="tag-checkbox" style="display:none;" onchange="this.closest('label').style.opacity = this.checked ? '1' : '0.7'">
|
|
{{ $t->name }}
|
|
</label>
|
|
@endforeach
|
|
@if($allTags->isEmpty())
|
|
<p class="text-muted">Nessun tag disponibile. <a href="{{ route('impostazioni.index') }}#tag">Crea i tag</a> nelle Impostazioni.</p>
|
|
@endif
|
|
</div>
|
|
@if($allTags->isNotEmpty())
|
|
<div class="mt-3">
|
|
<button type="submit" class="btn btn-primary"><i class="fas fa-search mr-1"></i> Cerca</button>
|
|
</div>
|
|
@endif
|
|
</form>
|
|
@else
|
|
<div class="row">
|
|
@php
|
|
$indexRoutes = [
|
|
'individui' => 'individui.index',
|
|
'gruppi' => 'gruppi.index',
|
|
'eventi' => 'eventi.index',
|
|
'documenti' => 'documenti.index',
|
|
'mailingLists' => 'mailing-liste.index',
|
|
];
|
|
$tagParams = collect($tagSlugs)->map(fn($s) => "tag[]={$s}")->implode('&');
|
|
@endphp
|
|
|
|
@foreach([
|
|
['key' => 'individui', 'color' => 'info', 'icon' => 'fa-user', 'label' => 'Individui'],
|
|
['key' => 'gruppi', 'color' => 'success', 'icon' => 'fa-users', 'label' => 'Gruppi'],
|
|
['key' => 'eventi', 'color' => 'warning', 'icon' => 'fa-calendar-alt', 'label' => 'Eventi'],
|
|
['key' => 'documenti', 'color' => 'secondary', 'icon' => 'fa-file', 'label' => 'Documenti'],
|
|
['key' => 'mailingLists', 'color' => 'purple', 'icon' => 'fa-list', 'label' => 'Mailing List'],
|
|
] as $box)
|
|
<div class="col-md-6 col-lg-3 mb-4">
|
|
<div class="info-box bg-{{ $box['color'] }}">
|
|
<span class="info-box-icon"><i class="fas {{ $box['icon'] }}"></i></span>
|
|
<div class="info-box-content">
|
|
<span class="info-box-text">{{ $box['label'] }}</span>
|
|
<span class="info-box-number">{{ $totals[$box['key']] }}</span>
|
|
@if($totals[$box['key']] > 0 && isset($indexRoutes[$box['key']]))
|
|
<a href="{{ route($indexRoutes[$box['key']]) . '?' . $tagParams }}" class="small" style="color:#fff;">Vedi tutti »</a>
|
|
@endif
|
|
</div>
|
|
</div>
|
|
</div>
|
|
@endforeach
|
|
</div>
|
|
|
|
@php
|
|
$sections = [
|
|
'individui' => ['color' => 'info', 'icon' => 'fa-user', 'title' => 'Individui', 'cols' => ['Cognome', 'Nome', 'Email'], 'fields' => ['cognome', 'nome', 'email_primaria']],
|
|
'gruppi' => ['color' => 'success', 'icon' => 'fa-users', 'title' => 'Gruppi', 'cols' => ['Nome', 'Descrizione'], 'fields' => ['nome', 'descrizione_limit']],
|
|
'eventi' => ['color' => 'warning', 'icon' => 'fa-calendar-alt', 'title' => 'Eventi', 'cols' => ['Evento', 'Data', 'Ora'], 'fields' => ['nome_evento', 'data', 'ora']],
|
|
'documenti' => ['color' => 'secondary', 'icon' => 'fa-file', 'title' => 'Documenti', 'cols' => ['Nome File', 'Tipo'], 'fields' => ['nome_file', 'tipo']],
|
|
'mailingLists' => ['color' => 'purple', 'icon' => 'fa-list', 'title' => 'Mailing List', 'cols' => ['Nome', 'Contatti', 'Stato'], 'fields' => ['nome', 'contatti_count', 'stato']],
|
|
];
|
|
@endphp
|
|
|
|
@foreach($sections as $key => $section)
|
|
@if($totals[$key] > 0)
|
|
<div class="card card-{{ $section['color'] }} card-outline">
|
|
<div class="card-header">
|
|
<h5 class="card-title"><i class="fas {{ $section['icon'] }} mr-2"></i>{{ $section['title'] }} ({{ $totals[$key] }})</h5>
|
|
</div>
|
|
<div class="card-body p-0">
|
|
<table class="table table-bordered table-hover mb-0">
|
|
<thead><tr>
|
|
@foreach($section['cols'] as $col)<th>{{ $col }}</th>@endforeach
|
|
<th></th>
|
|
</tr></thead>
|
|
<tbody>
|
|
@foreach($results[$key] as $item)
|
|
<tr>
|
|
@if($key === 'individui')
|
|
<td>{{ $item->cognome }}</td>
|
|
<td>{{ $item->nome }}</td>
|
|
<td>{{ $item->email_primaria ?? '-' }}</td>
|
|
<td><a href="{{ route('individui.show', $item) }}" class="btn btn-xs btn-primary"><i class="fas fa-eye"></i></a></td>
|
|
@elseif($key === 'gruppi')
|
|
<td>{{ $item->nome }}</td>
|
|
<td>{{ Str::limit($item->descrizione, 80) ?? '-' }}</td>
|
|
<td><a href="{{ route('gruppi.show', $item) }}" class="btn btn-xs btn-primary"><i class="fas fa-eye"></i></a></td>
|
|
@elseif($key === 'eventi')
|
|
<td>{{ $item->nome_evento }}</td>
|
|
<td>{{ $item->data_specifica ? $item->data_specifica->format('d/m/Y') : ($item->tipo_recorrenza ?? '-') }}</td>
|
|
<td>{{ $item->ora_inizio ? $item->ora_inizio->format('H:i') : '-' }}</td>
|
|
<td><a href="{{ route('eventi.show', $item) }}" class="btn btn-xs btn-primary"><i class="fas fa-eye"></i></a></td>
|
|
@elseif($key === 'documenti')
|
|
<td>{{ $item->nome_file }}</td>
|
|
<td><span class="badge badge-info">{{ $item->tipo ?? '-' }}</span></td>
|
|
<td><a href="{{ url('/documenti/' . $item->id . '/edit') }}" class="btn btn-xs btn-primary"><i class="fas fa-eye"></i></a></td>
|
|
@elseif($key === 'mailingLists')
|
|
<td>{{ $item->nome }}</td>
|
|
<td><span class="badge badge-info">{{ $item->contatti->count() }}</span></td>
|
|
<td>
|
|
@if($item->attiva)
|
|
<span class="badge badge-success">Attiva</span>
|
|
@else
|
|
<span class="badge badge-secondary">Disattiva</span>
|
|
@endif
|
|
</td>
|
|
<td><a href="{{ route('mailing-liste.show', $item) }}" class="btn btn-xs btn-primary"><i class="fas fa-eye"></i></a></td>
|
|
@endif
|
|
</tr>
|
|
@endforeach
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
@endif
|
|
@endforeach
|
|
|
|
@if(array_sum($totals) === 0)
|
|
<div class="alert alert-info">
|
|
<i class="fas fa-info-circle mr-2"></i> Nessun elemento trovato con tutti i tag selezionati.
|
|
</div>
|
|
@endif
|
|
|
|
<div class="mt-3">
|
|
<a href="{{ route('ricerca.index') }}" class="btn btn-secondary"><i class="fas fa-arrow-left mr-1"></i> Nuova ricerca</a>
|
|
</div>
|
|
@endisset
|
|
</div>
|
|
</div>
|
|
@endsection |