Files
autocrm/resources/views/emails/service-reminder.blade.php
Vasyka 09fd0bada2 Faza 2 (din continuare): Email notifications
4 Mailables auto-trigger pe model events:
- WorkOrderReadyMail: la WO.status → 'ready', către client.email
  • Atașat PDF fișa lucru (via WorkOrderPdfService)
  • Total/achitat/rest, recomandări (warning box)
- PaymentReceivedMail: la Payment::created, confirmare cu sumă/metodă/ref
- AppointmentConfirmedMail: la Appointment::created status='scheduled'
- ServiceReminderMail: dispatch manual (vehicle, type=itp/oil/general, note)

Layout email branded (resources/views/emails/layout.blade.php):
- Header cu logo tenant + theme_color border-bottom
- Footer cu telefon/email/disclaimer
- Stiluri inline (compatibil tot mail client)

Settings page extins cu 4 toggle:
- 'Mașina e gata de ridicat'
- 'Confirmare plată primită'
- 'Programare confirmată'
- 'Reminder ITP / revizie'
Salvate în companies.settings.notify (JSON), default true.

NotificationDispatcher service centralizat:
- Verifică isEnabled() pe settings.notify[$key]
- Skip dacă client n-are email
- Try/catch + Log::warning pe eșec (nu crapă request-ul)

Mailables folosesc UsesTenantBranding trait pentru context unitar.
Test prin Mailpit: https://mailpit.service.mir.md (capturează toate).
2026-05-07 13:20:19 +00:00

47 lines
2.0 KiB
PHP

@php
$titles = [
'itp' => '🛡️ Reminder ITP',
'oil' => '🛢️ Reminder schimb ulei',
'general' => '🔧 Reminder revizie',
];
$body = [
'itp' => 'ITP-ul autoturismului dvs. expiră în curând. Programați-vă din timp pentru a evita amenzile.',
'oil' => 'A trecut o perioadă de la ultimul schimb de ulei. Recomandăm o nouă verificare.',
'general' => 'Vă reamintim că autoturismul dvs. necesită o verificare programată.',
];
@endphp
@component('emails.layout', [
'companyName' => $companyName,
'themeColor' => $themeColor,
'phone' => $phone ?? null,
'email' => $email ?? null,
'city' => $city ?? null,
'logoUrl' => $logoUrl ?? null,
'title' => $titles[$reminderType] ?? 'Reminder',
])
<h2 style="margin:0 0 12px;font-size:20px;color:{{ $themeColor }};">{{ $titles[$reminderType] ?? 'Reminder' }}</h2>
<p>Bună ziua{{ $client?->name ? ', ' . $client->name : '' }},</p>
<p>{{ $body[$reminderType] ?? 'Vă reamintim despre vehiculul dvs.' }}</p>
<table role="presentation" width="100%" cellpadding="0" cellspacing="0" style="margin:16px 0;border:1px solid #e5e7eb;border-radius:8px;">
<tr><td style="padding:14px;">
<div style="font-size:11px;text-transform:uppercase;color:#6b7280;letter-spacing:.5px;">Vehicul</div>
<div style="font-size:16px;font-weight:700;margin-top:4px;">
{{ $vehicle->make }} {{ $vehicle->model }} {{ $vehicle->year ?? '' }}
@if ($vehicle->plate) <span style="color:{{ $themeColor }};">[{{ $vehicle->plate }}]</span> @endif
</div>
@if ($vehicle->mileage)
<div style="font-size:12px;color:#6b7280;margin-top:4px;">Kilometraj: {{ number_format($vehicle->mileage, 0, '.', ' ') }} km</div>
@endif
</td></tr>
</table>
@if ($note)
<div style="background:#fef3c7;border-left:4px solid #f59e0b;padding:12px;margin:16px 0;border-radius:6px;font-size:13px;">
{{ $note }}
</div>
@endif
<p>Programați- online sau sunați la <b>{{ $phone ?? '—' }}</b>.</p>
@endcomponent