{{-- resources/views/dashboard.blade.php --}} @extends('layouts.app') @section('title', 'Dashboard') @push('styles') @endpush @section('content') @php $usuario = Auth::user(); $bd = session('db_connection') === 'tarapaca' ? 'Tarapacá' : 'Cosmos 79'; $fechaSistema = session('fecha_sistema', \App\Helpers\FechaHelper::hoy()); $tc = session('tc_sistema', '—'); @endphp
{{-- ============================================================ --}} {{-- SECCIÓN 1: BIENVENIDA Y CONTEXTO --}} {{-- ============================================================ --}}

Principal

{{ $usuario->nombre }} {{ $bd }} {{ $fechaSistema }} TC: {{ $tc }}
{{-- ============================================================ --}} {{-- SECCIÓN 4: ACCIONES RÁPIDAS (atajos visuales) --}} {{-- ============================================================ --}}
{{-- ============================================================ --}} {{-- SECCIÓN 3: MÉTRICAS CLAVE (KPI Cards) --}} {{-- ============================================================ --}}
{{-- Clientes Activos --}}
{{-- Contratos Vigentes --}}
{{-- Cobranza del Mes (Bs) --}}
{{-- Lotes Totales --}}
{{-- En Trámite --}}
{{-- Cuotas Vencidas (crítico) --}}
{{-- ============================================================ --}} {{-- SECCIÓN 5: ESTADO DE LOTES (panorama general) --}} {{-- ============================================================ --}} @php $total = max($loteStats['total'], 1); $loteBars = [ ['key'=>'disponible', 'label'=>'Disponible', 'color'=>'bg-success', 'icon'=>'fa-check-circle'], ['key'=>'reservado', 'label'=>'Reservado', 'color'=>'bg-danger', 'icon'=>'fa-bookmark'], ['key'=>'en_proceso', 'label'=>'En Proceso', 'color'=>'bg-warning', 'icon'=>'fa-spinner'], ['key'=>'vendido', 'label'=>'Vendido', 'color'=>'bg-primary', 'icon'=>'fa-check-double'], ['key'=>'en_tramite', 'label'=>'En Trámite', 'color'=>'bg-info', 'icon'=>'fa-file-alt'], ['key'=>'consolidado', 'label'=>'Consolidado', 'color'=>'bg-secondary','icon'=>'fa-check'], ]; @endphp

Estado de Lotes Total: {{ number_format($loteStats['total']) }} lotes

@foreach($loteBars as $b) @php $pct = round($loteStats[$b['key']] * 100 / $total, 1); @endphp @if($pct > 0) @endif @endforeach
@foreach($loteBars as $b)
{{ $b['label'] }} {{ number_format($loteStats[$b['key']]) }}
@endforeach
{{-- ============================================================ --}} {{-- SECCIÓN 6: TENDENCIAS (Gráficos) --}} {{-- ============================================================ --}}

Evolución de Cobranza

USD

Nuevos Contratos

últimos 6 meses
{{-- ============================================================ --}} {{-- SECCIÓN 7: ACTIVIDAD RECIENTE (contratos, recibos, movimientos) --}} {{-- ============================================================ --}}
{{-- Últimos Contratos --}}

Últimos Contratos

@forelse($ultimosContratos as $c) @empty @endforelse
Cliente Fecha Total Tipo
#{{ $c->id }} {{ $c->nom_cliente }} {{ $c->fecha_local }} ${{ number_format((float)$c->total, 0) }} {{ $c->tipo_label }}
No hay contratos registrados
{{-- Últimos Recibos --}}

Últimos Recibos

@forelse($ultimosRecibos as $r) @empty @endforelse
Cliente Bs USD
#{{ $r->id }} {{ $r->nom_cliente }} Bs {{ number_format((float)$r->montocob, 2) }} $ {{ number_format((float)$r->montocod, 2) }}
No hay recibos registrados
{{-- Actividad del Sistema --}}

Actividad Reciente

@forelse($actividad as $a) @php $badgeClass = match(strtolower($a->tipomov_texto)) { 'nuevo' => 'bg-success', 'modificar' => 'bg-primary', 'eliminar' => 'bg-danger', 'login', 'logout' => 'bg-info', default => 'bg-secondary', }; $iconMap = [ 'nuevo' => 'fa-plus', 'modificar' => 'fa-edit', 'eliminar' => 'fa-trash', 'login' => 'fa-sign-in-alt', 'logout' => 'fa-sign-out-alt', ]; $icon = $iconMap[strtolower($a->tipomov_texto)] ?? 'fa-bell'; @endphp
{{ $a->tipomov_texto }}
{{ $a->tipoid_texto ?: 'Registro' }} · ID {{ $a->id }}
{{ $a->login }}
{{ $a->fecha_local }}
{{ $a->hora }}
@empty

Sin actividad reciente

@endforelse
{{-- ============================================================ --}} {{-- SECCIÓN 8: TOP URBANIZACIONES (contexto geográfico) --}} {{-- ============================================================ --}} @if($topUrbs->count() > 0)

Top Urbanizaciones por cantidad de contratos vigentes

@php $maxUrb = $topUrbs->max('total'); @endphp
@foreach($topUrbs as $u)
{{ $u->nombre }} {{ number_format($u->total) }} contratos
{{ $u->total }}
@endforeach
@endif {{-- ============================================================ --}} {{-- SECCIÓN 9: FOOTER INFORMATIVO (opcional) --}} {{-- ============================================================ --}}
Datos actualizados al {{ $fechaSistema }} Base: {{ $bd }}
@endsection @push('scripts') @endpush