{{-- Main Email Container --}}
{{-- Header Section --}} {{-- Client Greeting Section --}} {{-- Content Area --}} {{-- Footer Section --}}
{{-- Main Title --}}

{{ __('insights.weekly_business') }}
{{ __('insights.insights_email') }}

{{-- Date Range --}}

{{ $startDate->format('F j') }} - {{ $endDate->format('F j, Y') }}

"{{ __('insights.hello') }} {{ $companyName ?? __('insights.client_name') }}, {{ __('insights.heres_your_weekly') }}
{{ __('insights.performance_update') }}"

{{-- Financial Performance Overview Section --}}

{{ __('insights.financial_performance_overview') }}

@if(empty($insights))

{{ __('insights.no_insights_data') }}

@else @php /** * Recursively render metric details as an unordered list so we never miss nested information. * * @param array|string|int|float $data */ $renderMetric = function ($data) use (&$renderMetric) { if (!is_array($data)) { echo e($data); return; } }; // Currency symbol helper - returns SAR icon image or text symbol from settings $currencySymbol = $currency === 'SAR' ? 'SAR' : json_decode(__('settings::currencies.' . $currency), true); // Smaller symbol variant for breakdown boxes $smallCurrencySymbol = str_contains($currencySymbol, '' . $currencySymbol . ''; @endphp {{-- Financial Performance Metrics --}} @foreach($insights['metrics'] ?? [] as $metric => $details) @if(in_array($metric, ['revenue', 'expenses', 'purchases', 'net_profit'])) {{-- Custom card design for business growth metrics --}} @php // Get comparison data for current metric $previousWeekData = $insights['comparisons'][$metric] ?? null; $previousTotal = $previousWeekData['previous_week'] ?? 0; $percentageChange = $previousWeekData['percentage_change'] ?? 0; $trend = $previousWeekData['trend'] ?? 'neutral'; // Metric-specific configurations $metricConfig = [ 'new_customers' => [ 'title' => __('insights.new_customers'), 'icon' => 'đŸ‘Ĩ', 'color' => '#ff7300', 'current' => $details['total'] ?? 0, 'showBreakdown' => false, 'isPositiveTrend' => true // positive growth is good ], 'invoices_sent' => [ 'title' => __('insights.invoices_sent'), 'icon' => '📄', 'color' => '#ff7300', 'current' => $details['total'] ?? 0, 'showBreakdown' => false, 'isPositiveTrend' => true // more invoices is good ], 'revenue' => [ 'title' => __('insights.revenue'), 'icon' => '💰', 'currency' => $currency, 'color' => '#4a90e2', 'current' => $details['total'] ?? 0, 'showBreakdown' => false, 'isPositiveTrend' => true // more revenue is good ], 'expenses' => [ 'title' => __('insights.expenses'), 'icon' => '💸', 'currency' => $currency, 'color' => '#4a90e2', 'current' => $details['total'] ?? 0, 'showBreakdown' => false, 'isPositiveTrend' => false // more expenses is bad ], 'purchases' => [ 'title' => __('insights.purchase_calculation_including_returns'), 'icon' => '🛒', 'currency' => $currency, 'color' => '#4a90e2', 'current' => $details['total'] ?? 0, 'showBreakdown' => false, 'isPositiveTrend' => false // more purchases might be bad (depends on context) ], 'net_profit' => [ 'title' => __('insights.net_profit'), 'icon' => '📈', 'currency' => $currency, 'color' => '#4a90e2', 'current' => $details['total'] ?? 0, 'showBreakdown' => false, 'isPositiveTrend' => true // more profit is good ], 'overdue_payments' => [ 'title' => __('insights.overdue_payments_calculation'), 'icon' => '📋', 'currency' => $currency, 'color' => '#ff7300', 'current' => $details['count'] ?? 0, // count of overdue payments 'total_amount' => $details['total'] ?? 0, // total monetary value 'showBreakdown' => true, 'categories' => $details['categories'] ?? [], 'isPositiveTrend' => false // more overdue payments is bad ] ]; $config = $metricConfig[$metric]; if ($metric === 'overdue_payments') { $countDisplay = $config['current']; $amountDisplay = number_format($config['total_amount'], 2); $currentTotal = $countDisplay.' | '.$amountDisplay; } else { $currentTotal = $config['current']; } // Categories data for overdue payments if ($config['showBreakdown']) { $categories = $config['categories']; $zeroToSeven = $categories['0-7_days'] ?? ['count' => 0, 'total' => 0]; $eightToThirty = $categories['8-30_days'] ?? ['count' => 0, 'total' => 0]; $overThirty = $categories['over_30_days'] ?? ['count' => 0, 'total' => 0]; } // Determine trend arrow and color based on metric context $trendSymbol = $trend === 'up' ? '▲' : ($trend === 'down' ? 'â–ŧ' : '→'); // Color logic based on whether positive trend is good for this metric if ($config['isPositiveTrend']) { // For metrics where increase is good (e.g., revenue, customers) $changeColor = $trend === 'up' ? '#27ae60' : ($trend === 'down' ? '#e74c3c' : '#95a5a6'); } else { // For metrics where increase is bad (expenses, overdue payments, purchases) $changeColor = $trend === 'up' ? '#e74c3c' : ($trend === 'down' ? '#27ae60' : '#95a5a6'); } @endphp {{-- Main Card Container --}} {{-- Header with Orange Accent --}} {{-- Main Content Area --}}

{{ $config['icon'] }} {{ $config['title'] }}

{{ $startDate->toFormattedDateString() }} — {{ $endDate->toFormattedDateString() }}

{{-- Left Section: Main Metric --}} {{-- Right Section: Breakdown (only for overdue payments) --}} @if($config['showBreakdown']) @endif
{{-- Main Number --}} @if($metric === 'overdue_payments')
{!! $currencySymbol !!} {{ number_format($config['total_amount'], 2) }}
{{ $config['icon'] }} {{ $config['current'] }} {{ __('insights.invoices') }}
@else
{{ $config['icon'] }} {!! isset($config['currency']) ? $currencySymbol : '' !!} {{ $currentTotal }}
@endif @if($metric !== 'overdue_payments')

{{ __('insights.this_week') }}

@endif {{-- Comparison with Previous Week --}} @if($previousWeekData)
{{ __('insights.from_last_week') }}
{{ $trendSymbol }} {{ $previousTotal }}
{{ __('insights.change') }}
{{ $trendSymbol }} {{ number_format(abs($percentageChange), 1) }}%
@endif
{{-- 0-7 Days --}} {{-- 8-30 Days --}} {{-- More than 30 Days --}}
{{ __('insights.0_7_days_overdue') }}
{!! $smallCurrencySymbol !!} {{ number_format($zeroToSeven['total'],2) }}
{{ __('insights.8_30_days_overdue') }}
{!! $smallCurrencySymbol !!} {{ number_format($eightToThirty['total'],2) }}
{{ __('insights.more_than_30_days_overdue') }}
{!! $smallCurrencySymbol !!} {{ number_format($overThirty['total'],2) }}
@endif @endforeach {{-- Business Growth Insights Section --}}

{{ __('insights.business_growth_insights') }}

{{-- Business Growth Metrics --}} @foreach($insights['metrics'] ?? [] as $metric => $details) @if(in_array($metric, ['new_customers', 'invoices_sent', 'overdue_payments'])) {{-- Custom card design for business growth metrics --}} @php // Get comparison data for current metric $previousWeekData = $insights['comparisons'][$metric] ?? null; $previousTotal = $previousWeekData['previous_week'] ?? 0; $percentageChange = $previousWeekData['percentage_change'] ?? 0; $trend = $previousWeekData['trend'] ?? 'neutral'; // Metric-specific configurations $metricConfig = [ 'new_customers' => [ 'title' => __('insights.new_customers'), 'icon' => 'đŸ‘Ĩ', 'color' => '#ff7300', 'current' => $details['total'] ?? 0, 'showBreakdown' => false, 'isPositiveTrend' => true // positive growth is good ], 'invoices_sent' => [ 'title' => __('insights.invoices_sent'), 'icon' => '📄', 'color' => '#ff7300', 'current' => $details['total'] ?? 0, 'showBreakdown' => false, 'isPositiveTrend' => true // more invoices is good ], 'overdue_payments' => [ 'title' => __('insights.overdue_payments_calculation'), 'icon' => '📋', 'color' => '#ff7300', 'current' => $details['count'] ?? 0, // count 'total_amount' => $details['total'] ?? 0, // money 'showBreakdown' => true, 'categories' => $details['categories'] ?? [], 'isPositiveTrend' => false // more overdue payments is bad ] ]; $config = $metricConfig[$metric]; $currentTotal = $config['current']; // Categories data for overdue payments if ($config['showBreakdown']) { $categories = $config['categories']; $zeroToSeven = $categories['0-7_days'] ?? ['count' => 0, 'total' => 0]; $eightToThirty = $categories['8-30_days'] ?? ['count' => 0, 'total' => 0]; $overThirty = $categories['over_30_days'] ?? ['count' => 0, 'total' => 0]; } // Determine trend arrow and color based on metric context $trendSymbol = $trend === 'up' ? '▲' : ($trend === 'down' ? 'â–ŧ' : '→'); // Color logic based on whether positive trend is good for this metric if ($config['isPositiveTrend']) { // Increase is beneficial $changeColor = $trend === 'up' ? '#27ae60' : ($trend === 'down' ? '#e74c3c' : '#95a5a6'); } else { // Increase is harmful $changeColor = $trend === 'up' ? '#e74c3c' : ($trend === 'down' ? '#27ae60' : '#95a5a6'); } @endphp {{-- Main Card Container --}} {{-- Header with Orange Accent --}} {{-- Main Content Area --}}

{{ $config['icon'] }} {{ $config['title'] }}

@if($metric === 'overdue_payments') {{ app()->getLocale() === 'ar' ? 'Ø­ØĒŲ‰ ' : 'Until ' }}{{ $endDate->toFormattedDateString() }} @else {{ $startDate->toFormattedDateString() }} — {{ $endDate->toFormattedDateString() }} @endif

{{-- Left Section: Main Metric --}} {{-- Right Section: Breakdown (only for overdue payments) --}} @if($config['showBreakdown']) @endif
{{-- Main Number --}} @if($metric === 'overdue_payments')
{!! $currencySymbol !!} {{ number_format($config['total_amount'], 2) }}
{{ $config['icon'] }} {{ $config['current'] }} {{ __('insights.invoices') }}
@else
{{ $config['icon'] }} {!! isset($config['currency']) ? $currencySymbol : '' !!} {{ $currentTotal }}
@endif @if($metric !== 'overdue_payments')

{{ __('insights.this_week') }}

@endif {{-- Comparison with Previous Week --}} @if($previousWeekData)
{{ __('insights.from_last_week') }}
{{ $trendSymbol }} {{ $previousTotal }}
{{ __('insights.change') }}
{{ $trendSymbol }} {{ number_format(abs($percentageChange), 1) }}%
@endif
{{-- 0-7 Days --}} {{-- 8-30 Days --}} {{-- More than 30 Days --}}
{{ __('insights.0_7_days_overdue') }}
{!! $smallCurrencySymbol !!} {{ number_format($zeroToSeven['total'],2) }}
{{ __('insights.8_30_days_overdue') }}
{!! $smallCurrencySymbol !!} {{ number_format($eightToThirty['total'],2) }}
{{ __('insights.more_than_30_days_overdue') }}
{!! $smallCurrencySymbol !!} {{ number_format($overThirty['total'],2) }}
@endif @endforeach

{{ __('insights.report_details') }}

{{ __('insights.generated_at') }}: {{ isset($insights['generated_at']) ? \Carbon\Carbon::parse($insights['generated_at'])->toDayDateTimeString() : 'N/A' }}

@if(!empty($insights['warnings']))

{{ __('insights.warnings_alerts') }}

@foreach($insights['warnings'] as $warning)
{{ $warning['severity'] === 'critical' ? '🚨' : ($warning['severity'] === 'high' ? 'âš ī¸' : 'â„šī¸') }} {{ __('insights.warning_titles.' . $warning['type']) }}
{{ $warning['message'] }}
@if(isset($warning['action']))
💡 {{ $warning['action'] }}
@endif
@endforeach
@endif @endif
{{-- Action Buttons --}}
{{-- Login Button --}} {{-- Refer a Friend Button --}}
🔐 {{ __('insights.login') }} đŸ‘Ĩ {{ __('insights.refer_friend') }}
{{-- Divider Line --}}
{{-- Contact Information --}}
{{-- Website and Phone --}}

www.getvom.com

+966 50 230 9337

{{-- Links --}}

{{ __('insights.contact_us') }} â€ĸ {{ __('insights.terms_of_use') }} â€ĸ {{ __('insights.privacy_policy') }}

{{-- Generated By --}}

{{ __('insights.generated_automatically') }}