netgescon-day0/resources/views/admin/tabelle-millesimali/show.blade.php

124 lines
6.2 KiB
PHP

@extends('admin.layouts.netgescon')
@section('page-title', 'Dettaglio Tabella Millesimale')
@section('content')
<div class="space-y-6 netgescon-fade-in">
<!-- Header -->
<div class="netgescon-card">
<div class="flex items-center justify-between">
<div>
<h2 class="netgescon-title">
<i class="fas fa-table text-green-500 mr-3"></i>
{{ $tabellaMillesimale->nome_tabella }}
</h2>
<p class="netgescon-text mt-2">
Codice: <span class="font-mono">{{ $tabellaMillesimale->codice_tabella ?? 'N/D' }}</span> ·
Stabile: {{ $tabellaMillesimale->stabile->denominazione ?? 'N/D' }} ·
Stato:
<span class="inline-flex items-center px-2 py-0.5 rounded text-xs font-medium {{ $tabellaMillesimale->attiva ? 'bg-green-100 text-green-800' : 'bg-yellow-100 text-yellow-800' }}">
{{ $tabellaMillesimale->attiva ? 'Attiva' : 'Sospesa' }}
</span>
</p>
</div>
<div class="flex gap-2">
<a href="{{ route('admin.tabelle-millesimali.configura-millesimi', $tabellaMillesimale) }}" class="netgescon-btn netgescon-btn-primary">
<i class="fas fa-calculator mr-2"></i>Configura Millesimi
</a>
<button type="button" onclick="bilanciaTabella()" class="netgescon-btn netgescon-btn-secondary">
<i class="fas fa-balance-scale mr-2"></i>Bilancia
</button>
</div>
</div>
</div>
<!-- Statistiche -->
<div class="grid grid-cols-1 md:grid-cols-4 gap-4">
<div class="bg-blue-50 p-4 rounded">
<p class="text-sm text-blue-600">Unità configurate</p>
<p class="text-2xl font-bold text-blue-900">{{ $statistiche['unita_configurate'] }}</p>
</div>
<div class="bg-green-50 p-4 rounded">
<p class="text-sm text-green-600">Unità totali stabile</p>
<p class="text-2xl font-bold text-green-900">{{ $statistiche['unita_totali'] }}</p>
</div>
<div class="bg-purple-50 p-4 rounded">
<p class="text-sm text-purple-600">Millesimi assegnati</p>
<p class="text-2xl font-bold text-purple-900">{{ number_format($statistiche['millesimi_assegnati'], 4, ',', '.') }}</p>
</div>
<div class="bg-yellow-50 p-4 rounded">
<p class="text-sm text-yellow-600">Millesimi residui</p>
<p class="text-2xl font-bold text-yellow-900">{{ number_format($statistiche['millesimi_residui'], 4, ',', '.') }}</p>
</div>
</div>
<!-- Dettagli millesimi per unità -->
<div class="netgescon-card">
<div class="netgescon-card-header">
<h3 class="netgescon-card-title">
<i class="fas fa-home mr-2"></i>
Millesimi per Unità
<span class="text-sm font-normal text-gray-500 ml-2">({{ $tabellaMillesimale->dettagliTabelle->count() }} righe)</span>
</h3>
</div>
@if($tabellaMillesimale->dettagliTabelle->count())
<div class="overflow-x-auto">
<table class="min-w-full divide-y divide-gray-200">
<thead class="bg-gray-50">
<tr>
<th class="px-4 py-2 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Unità</th>
<th class="px-4 py-2 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Scala/Piano/Interno</th>
<th class="px-4 py-2 text-right text-xs font-medium text-gray-500 uppercase tracking-wider">Millesimi</th>
</tr>
</thead>
<tbody class="bg-white divide-y divide-gray-200">
@foreach($tabellaMillesimale->dettagliTabelle->sortBy(fn($d) => $d->unitaImmobiliare?->interno) as $det)
<tr>
<td class="px-4 py-2">
<div class="text-sm font-medium text-gray-900">
{{ $det->unitaImmobiliare->codice_unita ?? ('Unità #' . $det->unita_immobiliare_id) }}
</div>
<div class="text-xs text-gray-500">
{{ ucfirst(str_replace('_',' ', $det->unitaImmobiliare->tipo_unita ?? '')) }}
</div>
</td>
<td class="px-4 py-2 text-sm text-gray-700">
<span class="mr-3">Scala: <span class="font-mono">{{ $det->unitaImmobiliare->scala ?? '-' }}</span></span>
<span class="mr-3">Piano: <span class="font-mono">{{ $det->unitaImmobiliare->piano ?? '-' }}</span></span>
<span>Interno: <span class="font-mono">{{ $det->unitaImmobiliare->interno ?? '-' }}</span></span>
</td>
<td class="px-4 py-2 text-right font-mono">
{{ number_format($det->millesimi, 4, ',', '.') }}
</td>
+ </tr>
+ @endforeach
+ </tbody>
+ </table>
+ </div>
+ @else
+ <div class="text-center py-10 text-gray-500">
+ Nessun millesimo configurato. Usa "Configura Millesimi" per iniziare.
+ </div>
+ @endif
+ </div>
+</div>
+
+<script>
+function bilanciaTabella() {
+ fetch("{{ route('admin.tabelle-millesimali.bilancia', $tabellaMillesimale) }}", {
+ method: 'POST',
+ headers: {
+ 'X-CSRF-TOKEN': '{{ csrf_token() }}',
+ 'Accept': 'application/json'
+ }
+ }).then(r => r.json()).then(data => {
+ if (data.success) {
+ location.reload();
+ } else {
+ alert(data.message || 'Errore nel bilanciamento');
+ }
+ }).catch(() => alert('Errore nel bilanciamento'));
+}
+</script>
+@endsection