@extends('templates.adminlte') @section('content-header')

Ventas

@endsection @section('main-content') @php $saleRows = $sales ->map(function ($sale) { $clientName = trim((string) $sale->client_name); $clientEmail = trim((string) $sale->client_email); $clientPhone = trim((string) $sale->client_phone); $clientAddress = trim((string) ($sale->client_address ?? '')); $clientCity = trim((string) ($sale->client_city ?? '')); $clientState = trim((string) ($sale->client_state ?? '')); $clientCountry = trim((string) ($sale->client_country ?? '')); $location = collect([$clientCity, $clientState, $clientCountry]) ->filter() ->implode(', '); $hasFullProfile = $clientEmail !== '' && $clientPhone !== '' && ($clientAddress !== '' || $location !== ''); $hasContact = $clientEmail !== '' || $clientPhone !== ''; return [ 'id' => $sale->id, 'folio' => 'VTA-' . str_pad((string) $sale->id, 4, '0', STR_PAD_LEFT), 'client_name' => $clientName !== '' ? $clientName : 'Cliente sin nombre', 'client_email' => $clientEmail, 'client_phone' => $clientPhone, 'client_address' => $clientAddress, 'location' => $location !== '' ? $location : 'Ubicacion sin capturar', 'client_type_id' => $sale->client_type_id, 'created_at' => $sale->created_at, 'status' => $hasFullProfile ? 'Completa' : ($hasContact ? 'Seguimiento' : 'Basica'), 'status_tone' => $hasFullProfile ? 'secondary' : ($hasContact ? 'warning' : 'accent'), ]; }) ->values(); $currentMonthStart = now()->copy()->startOfMonth(); $currentMonthEnd = now()->copy()->endOfMonth(); $salesThisMonth = $saleRows->filter(function ($sale) use ($currentMonthStart, $currentMonthEnd) { return $sale['created_at']?->between($currentMonthStart, $currentMonthEnd) ?? false; }); $salesThisWeek = $saleRows->filter(function ($sale) { return $sale['created_at']?->isCurrentWeek() ?? false; }); $totalSales = $saleRows->count(); $uniqueClients = $saleRows->pluck('client_name')->filter()->unique()->count(); $salesWithEmail = $saleRows->filter(fn($sale) => $sale['client_email'] !== '')->count(); $salesWithAddress = $saleRows ->filter(fn($sale) => $sale['client_address'] !== '' || $sale['location'] !== 'Ubicacion sin capturar') ->count(); $latestSale = $saleRows->first(); $latestLocations = $saleRows ->pluck('location') ->filter(fn($location) => $location !== 'Ubicacion sin capturar') ->countBy() ->sortDesc() ->take(4); $kpis = [ [ 'label' => 'Ventas registradas', 'value' => number_format($totalSales), 'helper' => number_format($salesThisMonth->count()) . ' altas durante el mes actual', 'icon' => 'receipt_long', 'tone' => 'secondary', ], [ 'label' => 'Clientes unicos', 'value' => number_format($uniqueClients), 'helper' => 'Base comercial capturada en el modulo', 'icon' => 'groups', 'tone' => 'accent', ], [ 'label' => 'Con correo', 'value' => number_format($salesWithEmail), 'helper' => 'Registros listos para seguimiento digital', 'icon' => 'mail', 'tone' => 'warning', ], [ 'label' => 'Con direccion', 'value' => number_format($salesWithAddress), 'helper' => 'Ubicaciones disponibles para referencia operativa', 'icon' => 'location_on', 'tone' => 'secondary', ], ]; $toneClasses = [ 'secondary' => 'border-secondary/30 bg-secondary/10 text-secondary', 'accent' => 'border-accent/30 bg-accent/10 text-accent', 'warning' => 'border-warning/30 bg-warning/10 text-warning', 'error' => 'border-error/30 bg-error/10 text-error', ]; $toneIconClasses = [ 'secondary' => 'text-secondary', 'accent' => 'text-accent', 'warning' => 'text-warning', 'error' => 'text-error', ]; @endphp
Centro Comercial {{ number_format($salesThisWeek->count()) }} registros esta semana

Seguimiento de Ventas

Clientes, altas y trazabilidad comercial desde una sola vista.

La pantalla concentra el historial de ventas registradas, el estado del perfil de cada cliente y la informacion base para seguimiento operativo y administrativo.

person_add {{ number_format($uniqueClients) }} clientes diferentes capturados
calendar_month {{ number_format($salesThisMonth->count()) }} altas durante el mes
contact_mail {{ number_format($salesWithEmail) }} con correo de contacto

Registros totales

{{ number_format($totalSales) }}

Con contacto util

{{ number_format($saleRows->filter(fn($sale) => $sale['client_email'] !== '' || $sale['client_phone'] !== '')->count()) }}

Ultima alta

{{ $latestSale && $latestSale['created_at'] ? $latestSale['created_at']->format('d M') : '--' }}

@foreach ($kpis as $kpi)
{{ $kpi['icon'] }}

{{ $kpi['label'] }}

{{ $kpi['value'] }}

{{ $kpi['helper'] }}

@endforeach

Historial Comercial

Ventas registradas

Consulta clientes, datos de contacto, ubicacion y fecha de captura de cada venta.

table_view {{ number_format($totalSales) }} filas visibles
@if ($saleRows->isEmpty())
receipt_long

Sin ventas registradas

Registra la primera venta para comenzar a visualizar clientes, contactos y seguimiento comercial.

add_business Registrar venta
@else
@foreach ($saleRows as $sale) @endforeach
Folio Cliente Contacto Ubicacion Registro Perfil

{{ $sale['folio'] }}

{{ $sale['client_name'] }}

Cliente #{{ $sale['id'] }}

{{ $sale['client_email'] !== '' ? $sale['client_email'] : 'Sin correo' }}

{{ $sale['client_phone'] !== '' ? $sale['client_phone'] : 'Sin telefono' }}

{{ $sale['location'] }}

@if ($sale['client_address'] !== '')

{{ $sale['client_address'] }}

@endif
{{ $sale['created_at'] ? $sale['created_at']->format('d/m/Y H:i') : 'Sin fecha' }} {{ $sale['status'] }}
@endif
@endsection