@php $activePeriod = $activePeriod ?? 'today'; $reportDate = $reportDate ?? now('Asia/Jakarta')->format('Y-m-d'); $formattedDate = \Carbon\Carbon::parse($reportDate)->format('d M Y'); $emptyMetrics = [ 'importer_research' => 0, 'offer_sent' => 0, 'offer_replied' => 0, 'web_visitor' => 0, 'doc_download' => 0, 'b2b_inquiry' => 0, ]; $metricsByPeriod = $metricsByPeriod ?? [ 'today' => $emptyMetrics, 'week' => $emptyMetrics, 'month' => $emptyMetrics, 'year' => $emptyMetrics, ]; $detailsByPeriod = $detailsByPeriod ?? [ 'today' => [], 'week' => [], 'month' => [], 'year' => [], ]; $metrics = $metricsByPeriod[$activePeriod] ?? $emptyMetrics; $importers = $importers ?? collect(); @endphp

NOE Executive Report

PT Nusantara Ocean Export • {{ $formattedDate }}

@foreach(['today' => 'Today', 'week' => 'This Week', 'month' => 'This Month', 'year' => 'This Year'] as $key => $label) @endforeach
@php $importersPayload = $importers->map(function ($item) use ($reportDate) { $createdDate = isset($item->created_at) ? \Carbon\Carbon::parse($item->created_at)->timezone('Asia/Jakarta')->format('Y-m-d') : null; $updatedAtTs = isset($item->updated_at) ? \Carbon\Carbon::parse($item->updated_at)->timestamp : (isset($item->created_at) ? \Carbon\Carbon::parse($item->created_at)->timestamp : 0); $sentAtTs = isset($item->offer_sent_at) ? \Carbon\Carbon::parse($item->offer_sent_at)->timestamp : 0; $rawMatch = (string) ($item->match_score ?? '0'); $numericMatch = (int) preg_replace('/[^0-9]/', '', $rawMatch); $rawWebsite = trim((string) ($item->website ?? '')); if ($rawWebsite !== '' && !preg_match('/^https?:\/\//i', $rawWebsite)) { $rawWebsite = 'https://' . $rawWebsite; } $statusStr = (string) ($item->status ?? 'New'); $replyThread = $item->reply_thread ?? collect(); $isReplied = in_array(strtolower($statusStr), ['replied', 'interested'], true) || !empty($item->reply_body) || count($replyThread) > 0; return [ 'id' => $item->id ?? null, 'company_name' => $item->company_name ?? '-', 'website' => $rawWebsite, 'lead_score' => $item->lead_score ?? 'Low', 'status' => $statusStr, 'is_replied' => $isReplied, 'country' => $item->country ?? '-', 'country_code' => strtolower($item->country_code ?? 'un'), 'product_focus' => $item->importer_product_focus ?? '-', 'match_score' => $numericMatch, 'ai_analysis' => $item->ai_analysis ?? '', 'offer_subject' => $item->offer_subject ?? '', 'body_rendered' => $item->body_rendered ?? '', 'reply_body' => $item->reply_body ?? '', 'reply_thread' => $replyThread, 'offer_sent_at' => isset($item->offer_sent_at) ? \Carbon\Carbon::parse($item->offer_sent_at)->timezone('Asia/Jakarta')->format('d M Y, H:i') . ' WIB' : '', 'sent_at_ts' => $sentAtTs, 'is_today' => $createdDate === $reportDate, 'updated_at_ts' => $updatedAtTs, ]; })->values(); @endphp