@extends('layouts.admin') @section('title', 'CRM settings') @section('content') @php $tabs = [ 'general' => 'General', 'pipeline' => 'Pipeline stages', 'lead-intake' => 'Lead intake', 'stage-emails' => 'Stage emails', 'templates' => 'Email templates', 'delivery' => 'Delivery log', ]; $activeTemplateId = (int) request('template'); @endphp Pipelines board Template library @if(session('status'))
{{ session('status') }}
@endif @if($errors->any())
{{ $errors->first() }}
@endif
@foreach($tabs as $key => $label) {{ $label }} @endforeach
@if($tab === 'general')
@csrf @method('PUT')

Automation master switches

@foreach([ 'automation_enabled' => 'Enable CRM email automation', 'auto_create_opportunity' => 'Auto-create opportunity on new leads', 'queue_delivery' => 'Queue email delivery (recommended)', 'wrap_html_layout' => 'Wrap templates in branded HTML layout', 'scoring_on_lead_create' => 'Score leads on intake', 'routing_on_lead_create' => 'Route / assign owners on intake', 'sla_on_lead_create' => 'Start lead acceptance SLA on intake', 'playbooks_on_stage_change' => 'Run task playbooks on stage change', 'duplicate_email_block' => 'Block duplicate lead emails (hard)', ] as $key => $label) @endforeach

Default sender

@endif @if($tab === 'pipeline')

{{ $pipeline->name }} stages

Edit names, probabilities, won/lost flags, and allowed transitions.

@foreach($pipeline->stages as $stage)
@csrf @method('PUT')
@csrf @method('DELETE')
@endforeach

Add stage

@csrf
@endif @if($tab === 'lead-intake')
@csrf @method('PUT')

When a lead comes in

Choose which HTML templates fire for the lead, the owner, and internal ops.

@endif @if($tab === 'stage-emails')
@csrf @method('PUT')

For each pipeline stage, choose which HTML template the lead, owner, and internal recipients receive when an opportunity enters that stage.

@foreach($pipeline->stages as $stage) @php $auto = $stage->automation; @endphp

{{ $stage->name }} {{ $stage->slug }}

@endforeach
@endif @if($tab === 'templates')
@php $editing = $templates->firstWhere('id', $activeTemplateId) ?? $templates->first(); $latest = $editing?->versions?->sortByDesc('version')->first() ?? $editing?->latestVersion(); @endphp @if($editing)

Edit {{ $editing->name }}

Preview HTML
@csrf @method('PUT')
@endif

Create template

@csrf
@php $defaultTemplateBody = '

Hi {{ name }},

Thanks for reaching out to The Ring Authority.

'; @endphp
@endif @if($tab === 'delivery')
@forelse($recentSends as $send) @php $sendTone = match ($send->status) { 'sent' => 'success', 'failed' => 'danger', default => 'muted', }; @endphp @empty @endforelse
To Subject Trigger Status When
{{ $send->to_email }} {{ $send->subject }} {{ $send->trigger ?? '—' }} {{ $send->status }} {{ $send->sent_at?->diffForHumans() ?? $send->created_at?->diffForHumans() }}
No CRM emails queued yet.
@endif
@endsection