@props([ 'automation', 'cardClass' => 'shadow-sm', 'modelId' => null, 'modelType' => null, 'variant' => 'default', // default, history, global 'showContent' => true, 'showProgress' => true, 'showToggle' => true, 'collapsible' => true, 'compact' => true, 'colorClass' => 'blue', 'hasGradient' => false, 'modal' => '', 'disabled' => false, ]) @php $colorClass = $variant === 'global' ? 'indigo' : ($colorClass ?? $automation->type_color ?? 'indigo'); $isGlobal = $variant === 'global'; $isHistory = $variant === 'history'; $showEdit = request()->routeIs('notification_automations_manager') || $automation->scheduledNotification->receiver_id; // Determine if automation is completed $isCompleted = isset($automation->is_active) && !$automation->is_active; // Check if disabled (from prop or automation object) $isDisabled = $disabled || (isset($automation->is_disabled) && $automation->is_disabled); @endphp @if($compact) {{-- Compact Version --}}
{{-- Disabled Status Overlay --}} @if(!$isHistory && ($isDisabled || ! $automation->is_active))
@if($isDisabled)
{{ __('Statut non atteint') }}
@elseif(! $automation->is_active)
{{ __('Automation désactivée') }}
@endif
@endif @if($hasGradient) {{-- Glass Background with Gradient --}}
@endif {{-- Compact Content Layout --}}
{{-- Left Section: Icon & Title --}}
{{ $automation->title }}
{{ $automation->rule_label }} {{ $automation->rule_target_value_label ? ': ' . $automation->rule_target_value_label : '' }} @if($automation->notification_type === 'email') {{ __('E-mail') }} @elseif($automation->notification_type === 'sms') {{ __('SMS') }} @endif {{-- @if(isset($automation->next_scheduled_date) && $automation->next_scheduled_date && !$isHistory)
{{ $automation->next_scheduled_date }}
@endif --}} @if($isHistory && isset($automation->sent_at))
{{ $automation->sent_at }}
@endif
{{-- Right Section: Status & Actions --}}
{{-- --}} {{-- @if($showProgress && isset($automation->progress_percentage) && isset($automation->max_sent_count) && $automation->max_sent_count) @endif --}} {{-- @if($isHistory && isset($automation->sent_count) && $automation->sent_count > 1)
{{ $automation->sent_count }}x
@endif --}}
{{-- Collapsible Details Section --}} @if($collapsible)
{{-- Email Details Section --}} @if($automation->notification_type === 'email')
{{ __('Email Details') }}
@if(isset($automation->scheduledNotification->title) && $automation->scheduledNotification->title)
{{ __('Subject') }} {{ $automation->scheduledNotification->title }}
@endif @if(isset($automation->scheduledNotification->from_email) && $automation->scheduledNotification->from_email)
{{ __('From') }} {{ $automation->scheduledNotification->from_email }}
@endif @if(isset($automation->scheduledNotification->cc_emails) && !empty($automation->scheduledNotification->cc_emails))
{{ __('CC') }} {{ implode(', ', $automation->scheduledNotification->cc_emails) }}
@endif @if(isset($automation->scheduledNotification->bcc_emails) && !empty($automation->scheduledNotification->bcc_emails))
{{ __('BCC') }} {{ implode(', ', $automation->scheduledNotification->bcc_emails) }}
@endif
@if(isset($automation->scheduledNotification->attachment_paths) && !empty($automation->scheduledNotification->attachment_paths))
{{ __('Attachments') }}
@foreach($automation->scheduledNotification->attachment_paths as $attachment) {{ $attachment['original_name'] ?? 'piece-jointe.pdf' }} @endforeach
@endif
@endif @if($showContent && isset($automation->content) && $automation->content) @endif {{-- SMS Details Section --}} @if($automation->notification_type === 'sms')
{{ __('SMS Details') }}
@if(isset($automation->scheduledNotification->sms_origin) && $automation->scheduledNotification->sms_origin)
{{ __('SMS Sender') }} {{ $automation->scheduledNotification->sms_origin }}
@endif @if(isset($automation->content) && $automation->content)
{{ __('Characters') }} {{ strlen($automation->content) }}/500
@endif
@endif {{-- Recipient Information --}} @if(isset($automation->receiver_name) && $automation->receiver_name)
{{ __('Recipient') }}
{{ __('Name') }} {{ $automation->receiver_name }}
@if(isset($automation->receiver_email) && $automation->receiver_email)
{{ __('Email') }} {{ $automation->receiver_email }}
@endif @if(isset($automation->receiver_phone) && $automation->receiver_phone)
{{ __('Phone') }} {{ $automation->receiver_phone }}
@endif
@endif {{-- Additional Details Grid --}}
@if(isset($automation->delay_days) && !is_null($automation->delay_days) && $automation->delay_days > 0) @if(isset($automation->status_change_date) && $automation->status_change_date) @endif @if(isset($automation->delay_end_date) && $automation->delay_end_date) @endif @endif @if(isset($automation->frequency_label) && $automation->frequency_label) @endif @if(isset($automation->max_sent_count) && $automation->max_sent_count) @endif @if(isset($automation->rule_target_value) && $automation->rule_target_value) @endif @if(isset($automation->last_executed_at) && $automation->last_executed_at && $isHistory) @endif
{{-- Company Information --}} @if(isset($automation->company->name))
{{ __('Additional Information') }}
{{ __('Company') }} {{ $automation->company->name }}
@if(isset($automation->created_by_user->name))
{{ __('Created by') }} {{ $automation->created_by_user->name }}
@endif @if(isset($automation->created_at))
{{ __('Created') }} {{ $automation->created_at->format('d/m/Y') }}
@endif
@endif
@endif
@else {{-- Regular Version --}}
{{-- Disabled Status Overlay --}} @if($isDisabled)
{{ __('Statut non atteint') }}
@endif @if($hasGradient) {{-- Glass Background with Gradient --}}
@endif {{-- Global Badge Ribbon (only for global variant) --}} @if($isGlobal)
{{ __('GLOBALE') }}
@endif {{-- History Badge (only for history variant) --}} @if($isHistory && isset($automation->sent_at))
{{ __('Envoyée') }}
@endif {{-- Main Content Container --}}
{{-- Top Row: Icon, Title & Meta Info --}}
{{-- Icon with Glow Effect --}}
{{-- Title & Type Section --}}
{{ $automation->title }}
{{ $automation->type_label }} @if($automation->notification_type === 'email') {{ __('E-mail') }} @elseif($automation->notification_type === 'sms') {{ __('SMS') }} @endif {{-- History: Show sent date --}} @if($isHistory && isset($automation->sent_at)) {{ $automation->sent_at }} @endif
@if($showProgress && isset($automation->progress_percentage) && isset($automation->max_sent_count) && $automation->max_sent_count) @endif @if($isHistory && isset($automation->sent_count) && $automation->sent_count > 1)
{{ $automation->sent_count }}x
@endif
{{-- Collapsible Content --}}
@if($showContent && isset($automation->content) && $automation->content) @endif {{-- Email Details Section --}} @if($automation->notification_type === 'email')
{{ __('Email Details') }}
@if(isset($automation->scheduledNotification->title) && $automation->scheduledNotification->title)
{{ __('Subject') }} {{ $automation->scheduledNotification->title }}
@endif @if(isset($automation->scheduledNotification->from_email) && $automation->scheduledNotification->from_email)
{{ __('From') }} {{ $automation->scheduledNotification->from_email }}
@endif @if(isset($automation->scheduledNotification->cc_emails) && !empty($automation->scheduledNotification->cc_emails))
{{ __('CC') }} {{ implode(', ', $automation->scheduledNotification->cc_emails) }}
@endif @if(isset($automation->scheduledNotification->bcc_emails) && !empty($automation->scheduledNotification->bcc_emails))
{{ __('BCC') }} {{ implode(', ', $automation->scheduledNotification->bcc_emails) }}
@endif @if(isset($automation->scheduledNotification->attachment_paths) && !empty($automation->scheduledNotification->attachment_paths))
{{ __('Attachments') }}
@foreach($automation->scheduledNotification->attachment_paths as $attachment) {{ $attachment['original_name'] ?? 'piece-jointe.pdf' }} @endforeach
@endif
@endif {{-- SMS Details Section --}} @if($automation->notification_type === 'sms')
{{ __('SMS Details') }}
@if(isset($automation->scheduledNotification->sms_origin) && $automation->scheduledNotification->sms_origin)
{{ __('SMS Sender') }} {{ $automation->scheduledNotification->sms_origin }}
@endif @if(isset($automation->content) && $automation->content)
{{ __('Characters') }} {{ strlen($automation->content) }}/500
@endif
@endif {{-- Recipient Information --}} @if(isset($automation->receiver_name) && $automation->receiver_name)
{{ __('Recipient') }}
{{ __('Name') }} {{ $automation->receiver_name }}
@if(isset($automation->receiver_email) && $automation->receiver_email)
{{ __('Email') }} {{ $automation->receiver_email }}
@endif @if(isset($automation->receiver_phone) && $automation->receiver_phone)
{{ __('Phone') }} {{ $automation->receiver_phone }}
@endif
@endif {{-- Automation Configuration --}}
{{ __('Automation Configuration') }}
@if(isset($automation->rule_target_value) && $automation->rule_target_value) @endif @if(isset($automation->next_scheduled_date) && $automation->next_scheduled_date && !$isHistory) @endif @if(isset($automation->frequency_label) && $automation->frequency_label) @endif @if(isset($automation->max_sent_count) && $automation->max_sent_count) @else @endif @if(isset($automation->last_executed_at) && $automation->last_executed_at && $isHistory) @endif
@if(isset($automation->delay_days) && !is_null($automation->delay_days) && $automation->delay_days > 0) @if(isset($automation->status_change_date) && $automation->status_change_date) @endif @if(isset($automation->delay_end_date) && $automation->delay_end_date) @endif @endif
{{-- Scheduling Information --}} @if(isset($automation->scheduledNotification->scheduled_at) || isset($automation->scheduledNotification->schedule_rule))
{{ __('Scheduling Information') }}
@if(isset($automation->scheduledNotification->scheduled_at) && $automation->scheduledNotification->scheduled_at)
{{ __('Scheduled At') }} {{ $automation->scheduledNotification->scheduled_at->format('d/m/Y H:i') }}
@endif @if(isset($automation->scheduledNotification->schedule_rule) && $automation->scheduledNotification->schedule_rule)
{{ __('Schedule Rule') }} {{ $automation->scheduledNotification->schedule_rule }}
@endif @if(isset($automation->scheduledNotification->is_recurring))
{{ __('Recurring') }} @if($automation->scheduledNotification->is_recurring) {{ __('Yes') }} @else {{ __('No') }} @endif
@endif @if(isset($automation->last_executed_at) && $automation->last_executed_at)
{{ __('Last executed') }} {{ $automation->last_executed_at->diffForHumans() }}
@endif
@endif {{-- Company Information --}} @if(isset($automation->company->name))
{{ __('Additional Information') }}
{{ __('Company') }} {{ $automation->company->name }}
@if(isset($automation->created_by_user->name))
{{ __('Created by') }} {{ $automation->created_by_user->name }}
@endif @if(isset($automation->created_at))
{{ __('Created') }} {{ $automation->created_at->format('d/m/Y') }}
@endif
@endif {{-- Bottom Status Bar --}}
@if($isHistory) {{ __('Envoyée') }} @elseif($isGlobal) {{ __('S\'applique à ce destinataire') }} @else {{ isset($automation->is_active) && $automation->is_active ? __('Active') : __('Complétée') }} @endif
@if($showProgress && isset($automation->max_sent_count) && $automation->max_sent_count) @endif
@endif