@extends('layouts.app')
@section('title', $customer->name)
@section('content')
@php
$quoteLabels = ['draft' => 'Em aberto', 'converted' => 'Aprovado', 'cancelled' => 'Cancelado'];
$orderLabels = ['draft' => 'Rascunho', 'in_production' => 'Em produção', 'ready' => 'Pronta', 'delivered' => 'Entregue', 'cancelled' => 'Cancelada'];
$appointmentLabels = ['appointment' => 'Atendimento', 'return' => 'Retorno', 'contact' => 'Contato', 'delivery' => 'Entrega', 'reminder' => 'Lembrete'];
$latestMeasurement = $customer->pupilMeasurements->first();
$nextAppointment = $customer->appointments->where('status', 'scheduled')->sortBy('starts_at')->first();
@endphp
{{ $customer->name }}
{{ $customer->active ? 'Ativo' : 'Inativo' }}
{{ $customer->whatsapp ?: $customer->phone ?: 'Sem telefone' }}
@if($customer->email)
· {{ $customer->email }}
@endif
Financeiro
{{ $summary['financial_status'] }}
@if($summary['overdue'] > 0)
R$ {{ number_format($summary['overdue'], 2, ',', '.') }} em atraso
@elseif($summary['outstanding'] > 0)
R$ {{ number_format($summary['outstanding'], 2, ',', '.') }} em aberto
@else
Sem pendências
@endif
Última receita
@if($rx = $summary['latest_prescription'])
{{ $rx->issued_at?->format('d/m/Y') ?: 'Sem data' }}
{{ $rx->lens_usage ?: 'Uso não informado' }}
@else
Nenhuma
Cadastre quando precisar.
@endif
Medidas
@if($latestMeasurement)
DP {{ number_format((float) $latestMeasurement->binocular_pd, 2, ',', '.') }} mm
Medida em {{ $latestMeasurement->measured_at?->format('d/m/Y') ?: '—' }}
@else
Não medidas
Sem DNP/DP registrada.
@endif
Próximo compromisso
@if($nextAppointment)
{{ $nextAppointment->starts_at?->format('d/m H:i') ?: 'Sem horário' }}
{{ $nextAppointment->title }}
@else
Nenhum
Sem retorno agendado.
@endif
Dados do cliente
Cadastro desde {{ $customer->created_at?->format('d/m/Y') ?: '—' }}
Editar dados
CPF
{{ $customer->cpf ?: 'Não informado' }}
Nascimento
{{ $customer->birth_date?->format('d/m/Y') ?: 'Não informado' }}
Contato
{{ $customer->whatsapp ?: $customer->phone ?: 'Não informado' }}
Endereço
{{ collect([$customer->street, $customer->number, $customer->complement, $customer->district, $customer->city, $customer->state])->filter()->implode(', ') ?: 'Não informado' }}
@if($customer->responsible_name)
Responsável
{{ $customer->responsible_name }}
@if($customer->responsible_relationship)
· {{ $customer->responsible_relationship }}
@endif
{{ $customer->responsible_phone ?: 'Sem telefone informado' }}
@endif
@if($customer->notes)
Observações
{{ $customer->notes }}
@endif
Vendas e atendimento
Orçamentos, OS e próximos compromissos do cliente.
Orçamentos{{ $customer->salesQuotes->count() }}
| Código | Total | Status |
@forelse($customer->salesQuotes->take(5) as $quote)
| {{ $quote->code }} {{ $quote->created_at?->format('d/m/Y') ?: '—' }} |
R$ {{ number_format((float) $quote->total_amount, 2, ',', '.') }} |
{{ $quoteLabels[$quote->status] ?? $quote->status }} |
@empty
| Nenhum orçamento. |
@endforelse
Vendas / OS{{ $customer->serviceOrders->count() }}
| OS | Total | Status |
@forelse($customer->serviceOrders->take(5) as $order)
| {{ $order->code }} {{ $order->ordered_at?->format('d/m/Y') ?: '—' }} |
R$ {{ number_format((float) $order->total_amount, 2, ',', '.') }} |
{{ $orderLabels[$order->status] ?? $order->status }} |
@empty
| Nenhuma OS. |
@endforelse
Agenda
| Quando | Compromisso |
@forelse($customer->appointments->where('status', 'scheduled')->sortBy('starts_at')->take(5) as $appointment)
| {{ $appointment->starts_at?->format('d/m H:i') ?: '—' }} |
{{ $appointment->title }} {{ $appointmentLabels[$appointment->type] ?? $appointment->type }} |
@empty
| Nenhum compromisso aberto. |
@endforelse
Receita e medidas
Abra somente quando precisar consultar ou registrar dados ópticos.
@if($rx = $summary['latest_prescription'])
Receita atual · {{ $rx->issued_at?->format('d/m/Y') ?: 'sem data' }}
@if($rx->attachment_path)
Abrir anexo
@endif
| Olho | Esférico | Cilíndrico | Eixo | Adição | DNP |
| OD | {{ $rx->od_sphere ?? '—' }} | {{ $rx->od_cylinder ?? '—' }} | {{ $rx->od_axis ?? '—' }} | {{ $rx->od_addition ?? '—' }} | {{ $rx->od_dnp ?? '—' }} |
| OE | {{ $rx->oe_sphere ?? '—' }} | {{ $rx->oe_cylinder ?? '—' }} | {{ $rx->oe_axis ?? '—' }} | {{ $rx->oe_addition ?? '—' }} | {{ $rx->oe_dnp ?? '—' }} |
@endif
+ Cadastrar nova receita
Medidas pupilares
@include('customers._pupil_measurements')
Histórico de receitas
| Data | Profissional | Uso | Status | Anexo |
@forelse($customer->prescriptions as $prescription)
| {{ $prescription->issued_at?->format('d/m/Y') ?: '—' }} |
{{ $prescription->prescriber_name ?: '—' }} |
{{ $prescription->lens_usage ?: '—' }} |
@if($prescription->is_current)Atual@elseHistórica@endif |
@if($prescription->attachment_path)Abrir@else—@endif |
@empty
| Nenhuma receita. |
@endforelse
Crediário e pagamentos
Limite, parcelas e recebimentos ficam aqui.
Configuração
Nova venda parcelada
@if($summary['credit_account'])
@else
Abra o crediário primeiro.
@endif
@if($summary['credit_account'])
| Parcela | Origem | Vencimento | Valor | Saldo | Status |
@forelse($summary['installment_rows'] as $row)
| {{ $row['installment']->installment_number }}/{{ $row['installment']->total_installments }} |
@if($row['installment']->serviceOrder)
{{ $row['installment']->serviceOrder->code }}
@else
Manual
@endif
|
{{ $row['installment']->due_date?->format('d/m/Y') ?: '—' }} |
R$ {{ number_format($row['gross'], 2, ',', '.') }} |
R$ {{ number_format($row['balance'], 2, ',', '.') }} |
{{ $row['display_status'] }} |
@empty
| Nenhuma parcela lançada. |
@endforelse
Receber pagamento
Últimos pagamentosTotal R$ {{ number_format($summary['total_paid'], 2, ',', '.') }}
| Data | Forma | Valor |
@forelse($summary['recent_payments'] as $payment)
| {{ $payment->paid_at?->format('d/m/Y H:i') ?: '—' }} | {{ $payment->method }} | R$ {{ number_format((float) $payment->amount, 2, ',', '.') }} |
@empty
| Nenhum pagamento. |
@endforelse
@endif
Histórico completo
Tudo que aconteceu com este cliente, em ordem cronológica.
@forelse($timeline as $item)
{{ $item['title'] }}
{{ optional($item['occurred_at'])->format('d/m/Y H:i') }}
@if($item['description'])
{{ $item['description'] }}
@endif
@empty
Ainda não há eventos.
@endforelse
@if(auth()->user()?->role === 'admin')
Ações administrativas
Use somente quando necessário.
@endif
@endsection