<?php
/** @var array<string,mixed> $overview */
/** @var array<string,string> $filters */
/** @var array<int,string> $allowedSites */
$overviewData = is_array($overview ?? null) ? $overview : [];
$summary = is_array($overviewData['summary'] ?? null) ? $overviewData['summary'] : [];
$siteCards = is_array($overviewData['site_cards'] ?? null) ? $overviewData['site_cards'] : [];
$trend = is_array($overviewData['trend'] ?? null) ? $overviewData['trend'] : [];
$topStores = array_slice(is_array($overviewData['top_stores'] ?? null) ? $overviewData['top_stores'] : [], 0, 5);
$topItems = array_slice(is_array($overviewData['top_items'] ?? null) ? $overviewData['top_items'] : [], 0, 5);
$monthOptions = is_array($overviewData['month_options'] ?? null) ? $overviewData['month_options'] : [];
$contract = is_array($overviewData['contract'] ?? null) ? $overviewData['contract'] : [];
$isAr = current_lang() === 'ar';
$tr = static function (string $en, string $ar) use ($isAr): string { return $isAr ? $ar : $en; };
$num = static function ($value, int $decimals = 0): string { return number_format((float)$value, $decimals); };
$money = static function ($value, bool $compact = false) use ($isAr): string {
    $value = (float)$value;
    if ($isAr) {
        if ($compact && abs($value) >= 1000000) { return number_format($value / 1000000, 2) . ' مليون ر.س'; }
        if ($compact && abs($value) >= 1000) { return number_format($value / 1000, 1) . ' ألف ر.س'; }
        return number_format($value, 2) . ' ر.س';
    }
    if ($compact && abs($value) >= 1000000) { return 'SAR ' . number_format($value / 1000000, 2) . 'M'; }
    if ($compact && abs($value) >= 1000) { return 'SAR ' . number_format($value / 1000, 1) . 'K'; }
    return 'SAR ' . number_format($value, 2);
};
$selectedSite = (string)($overviewData['filters']['site'] ?? $filters['site'] ?? 'ALL');
$selectedPeriod = (string)($overviewData['filters']['period'] ?? $filters['period'] ?? 'latest_closed');
$selectedMonth = (string)($overviewData['selected_month'] ?? '');
$requestedMonth = (string)($filters['month'] ?? '');
$partial = !empty($overviewData['partial_coverage']);
$totalCases = (int)($summary['detected_count'] ?? 0);
$critical = (int)($summary['critical_count'] ?? 0);
$high = (int)($summary['high_count'] ?? 0);
$medium = (int)($summary['medium_count'] ?? 0);
$severityTotal = max(1, $totalCases);
$criticalPct = round(($critical / $severityTotal) * 100, 1);
$highPct = round(($high / $severityTotal) * 100, 1);
$mediumPct = round(($medium / $severityTotal) * 100, 1);
$statusLabels = ['CLOSED'=>$tr('Closed','مغلق'),'OPEN'=>$tr('Open','مفتوح'),'MIXED'=>$tr('Mixed','مختلط')];
$messageLabels = [
    'DIAR6A_PENDING'=>$tr('Waiting for DIAR-6A activation on this database.','بانتظار تفعيل DIAR-6A على قاعدة البيانات.'),
    'DIAR6A_OBJECTS_PENDING'=>$tr('Waiting for DIAR-6A activation on this database.','بانتظار تفعيل DIAR-6A على قاعدة البيانات.'),
    'NO_MONTHLY_SNAPSHOT'=>$tr('No monthly snapshot is available yet.','لا توجد نسخة شهرية متاحة حتى الآن.'),
    'NO_SNAPSHOT_FOR_SELECTED_MONTH'=>$tr('No snapshot exists for the selected month.','لا توجد نسخة للشهر المحدد.'),
    'IDENTITY_MISMATCH'=>$tr('Source identity requires technical review.','هوية المصدر تحتاج إلى مراجعة فنية.'),
    'SOURCE_UNAVAILABLE'=>$tr('The database source is temporarily unavailable.','مصدر قاعدة البيانات غير متاح مؤقتًا.'),
];
$highestDay = [];
$avgCases = $trend === [] ? 0 : array_sum(array_map(static function (array $row): int { return (int)($row['detected_count'] ?? 0); }, $trend)) / count($trend);
$aboveAverageCriticalDays = 0;
foreach ($trend as $row) {
    if ($highestDay === [] || (int)($row['detected_count'] ?? 0) > (int)($highestDay['detected_count'] ?? 0)) { $highestDay = $row; }
    if ((int)($row['detected_count'] ?? 0) >= $avgCases && (int)($row['critical_count'] ?? 0) > 0) { $aboveAverageCriticalDays++; }
}
$topStore = $topStores[0] ?? [];
$topItem = $topItems[0] ?? [];
$topStoreShare = $totalCases > 0 ? round(((int)($topStore['case_count'] ?? 0) / $totalCases) * 100, 1) : 0;
$topItemShare = $totalCases > 0 ? round(((int)($topItem['case_count'] ?? 0) / $totalCases) * 100, 1) : 0;
$maxStoreCost = max(1.0, ...array_map(static function (array $row): float { return (float)($row['inventory_cost_abs'] ?? 0); }, $topStores ?: [[]]));
$maxItemCost = max(1.0, ...array_map(static function (array $row): float { return (float)($row['inventory_cost_abs'] ?? 0); }, $topItems ?: [[]]));
$icon = static function (string $key): string {
    $paths = [
        'cases'=>'<path d="M6 3h12v18H6z"/><path d="M9 7h6m-6 4h6m-6 4h4"/>',
        'critical'=>'<path d="m12 3 9 16H3z"/><path d="M12 9v4m0 3h.01"/>',
        'high'=>'<circle cx="12" cy="12" r="9"/><path d="m8 14 4-5 4 5"/>',
        'medium'=>'<circle cx="12" cy="12" r="9"/><path d="M8 12h8"/>',
        'cost'=>'<rect x="3" y="6" width="18" height="13" rx="3"/><path d="M7 10h10m-5 0v5"/>',
        'store'=>'<path d="M4 10h16v10H4zM3 10l2-6h14l2 6"/><path d="M8 14h3v6"/>',
        'item'=>'<path d="m12 3 8 4.5v9L12 21l-8-4.5v-9z"/><path d="m4.5 7.8 7.5 4.3 7.5-4.3M12 12v9"/>',
        'spark'=>'<path d="M4 18 9 12l4 3 7-9"/><path d="M15 6h5v5"/>',
        'shield'=>'<path d="M12 3 5 6v5c0 5 3 8 7 10 4-2 7-5 7-10V6z"/><path d="m9 12 2 2 4-5"/>',
    ];
    return '<svg viewBox="0 0 24 24" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round">'.($paths[$key]??$paths['cases']).'</svg>';
};
$chartData = [
    'locale' => $isAr ? 'ar' : 'en',
    'priority' => ['critical'=>$critical,'high'=>$high,'medium'=>$medium,'total'=>$totalCases],
    'trend' => array_map(static function (array $row): array {
        return [
            'date'=>(string)($row['calendar_day'] ?? ''),
            'label'=>substr((string)($row['calendar_day'] ?? ''), 8, 2),
            'cases'=>(int)($row['detected_count'] ?? 0),
            'critical'=>(int)($row['critical_count'] ?? 0),
            'cost'=>(float)($row['inventory_cost_abs'] ?? 0),
        ];
    }, $trend),
];
?>
<link rel="stylesheet" href="assets/css/diar-executive-overview.css?v=diar-6b-2-r3-1">

<section class="diar-premium-page diar-executive-dashboard" data-diar-r3-executive>
    <header class="executive-dashboard-header">
        <div>
            <nav class="diar-breadcrumb"><a href="<?= e(url_to('diar-portal')) ?>"><?= e($tr('DIAR Platform','منصة DIAR')) ?></a><span>›</span><strong><?= e($tr('Executive Dashboard','لوحة الإدارة العليا')) ?></strong></nav>
            <span class="diar-premium-eyebrow"><?= e($tr('EXECUTIVE DECISION INTELLIGENCE','ذكاء القرار التنفيذي')) ?></span>
            <h1><?= e($tr('DIAR Executive Dashboard','لوحة DIAR للإدارة العليا')) ?> <?= $icon('shield') ?></h1>
            <p><?= e($tr('Executive overview of medication movement anomalies, associated inventory exposure and decision priorities.','عرض تنفيذي لشذوذ حركات الأدوية وقيمة المخزون المرتبطة وأولويات القرار.')) ?></p>
        </div>
        <form class="executive-dashboard-controls" action="index.php" method="get">
            <input type="hidden" name="page" value="diar-executive-overview"><input type="hidden" name="lang" value="<?= e(current_lang()) ?>">
            <label><span><?= e($tr('Hospital scope','نطاق المستشفى')) ?></span><select name="site"><?php if(count($allowedSites)>1): ?><option value="ALL" <?= $selectedSite==='ALL'?'selected':'' ?>><?= e($tr('All available hospitals','كل المستشفيات المتاحة')) ?></option><?php endif; ?><?php foreach($allowedSites as $site): ?><option value="<?= e($site) ?>" <?= $selectedSite===$site?'selected':'' ?>><?= e($site) ?></option><?php endforeach; ?></select></label>
            <label><span><?= e($tr('Period','الفترة')) ?></span><select name="period"><option value="latest_closed" <?= $selectedPeriod==='latest_closed'?'selected':'' ?>><?= e($tr('Latest closed month','أحدث شهر مغلق')) ?></option><option value="current_open" <?= $selectedPeriod==='current_open'?'selected':'' ?>><?= e($tr('Current open month','الشهر المفتوح الحالي')) ?></option></select></label>
            <label><span><?= e($tr('Month','الشهر')) ?></span><select name="month"><option value=""><?= e($tr('Automatic','تلقائي')) ?></option><?php foreach($monthOptions as $option): $monthKey=(string)($option['month_key']??''); ?><option value="<?= e($monthKey) ?>" <?= $requestedMonth===$monthKey?'selected':'' ?>><?= e($monthKey.' · '.($statusLabels[(string)($option['status_code']??'')]??(string)($option['status_code']??''))) ?></option><?php endforeach; ?></select></label>
            <button type="submit"><?= e($tr('Apply','تطبيق')) ?></button>
        </form>
    </header>

    <?php if (!empty($loadError)): ?><div class="executive-banner is-error" role="alert"><?= e($loadError) ?></div><?php endif; ?>
    <?php if ($partial): ?><div class="executive-banner is-warning"><strong><?= e($tr('Partial hospital coverage','تغطية جزئية للمستشفيات')) ?></strong><span><?= e($tr('Totals include available sources only. NJCH joins automatically after its DIAR-6A acceptance.','تشمل الإجماليات المصادر المتاحة فقط، وستنضم NJCH تلقائيًا بعد قبول DIAR-6A عليها.')) ?></span></div><?php endif; ?>

    <div class="executive-evidence-note"><span><?= $icon('shield') ?></span><strong><?= e($tr('Interpretation boundary','حدود التفسير')) ?></strong><p><?= e($tr('All monetary values represent associated inventory cost based on frozen evidence; they are not confirmed financial loss.','جميع القيم المالية تمثل تكلفة مخزون مرتبطة بأدلة مجمدة، وليست خسارة مالية مثبتة.')) ?></p><em><?= e($selectedMonth ?: '—') ?> · <?= e($statusLabels[(string)($overviewData['month_status']??'')]??(string)($overviewData['month_status']??'—')) ?></em></div>

    <section class="executive-kpi-strip" aria-label="<?= e($tr('Executive indicators','المؤشرات التنفيذية')) ?>">
        <?php foreach ([
            ['cases',$tr('Cases requiring review','حالات تحتاج مراجعة'),$totalCases,$tr('Statistical signals','إشارات إحصائية'),'purple'],
            ['critical',$tr('Critical','حرجة'),$critical,$criticalPct.'%','red'],
            ['high',$tr('High','عالية'),$high,$highPct.'%','orange'],
            ['medium',$tr('Medium','متوسطة'),$medium,$mediumPct.'%','amber'],
            ['cost',$tr('Associated inventory cost','تكلفة المخزون المرتبطة'),$money($summary['inventory_cost_abs']??0,true),$tr('Not confirmed loss','ليست خسارة مثبتة'),'teal'],
            ['store',$tr('Affected stores','المخازن المتأثرة'),(int)($summary['store_count']??0),$tr('Distinct scope','نطاق مميز'),'blue'],
            ['item',$tr('Affected items','الأصناف المتأثرة'),(int)($summary['item_count']??0),$tr('Medication items','أصناف أدوية'),'violet'],
        ] as $kpi): ?>
            <article class="executive-kpi-card tone-<?= e((string)$kpi[4]) ?>"><span class="kpi-icon"><?= $icon((string)$kpi[0]) ?></span><div><small><?= e((string)$kpi[1]) ?></small><strong><?= e((string)$kpi[2]) ?></strong><em><?= e((string)$kpi[3]) ?></em></div></article>
        <?php endforeach; ?>
    </section>

    <section class="executive-dashboard-grid executive-grid-top">
        <article class="executive-dashboard-card decision-highlights-card">
            <header><div><span><?= e($tr('DECISION HIGHLIGHTS','نتائج القرار')) ?></span><h2><?= e($tr('What requires leadership attention','ما يحتاج اهتمام الإدارة')) ?></h2></div><a href="<?= e(url_to('diar-cases',['month'=>$selectedMonth])) ?>"><?= e($tr('View cases','عرض الحالات')) ?></a></header>
            <div class="decision-highlight-list">
                <a href="<?= e(url_to('diar-cases',['month'=>$selectedMonth,'severity'=>'CRITICAL'])) ?>"><i class="tone-red"><?= $icon('critical') ?></i><div><strong><?= e($num($critical).' '.$tr('critical cases require priority review','حالة حرجة تحتاج مراجعة ذات أولوية')) ?></strong><span><?= e($criticalPct.'% '.$tr('of the selected review population','من حالات المراجعة المحددة')) ?></span></div><b>›</b></a>
                <a href="<?= e(url_to('diar-cases',['month'=>$selectedMonth,'severity'=>'HIGH'])) ?>"><i class="tone-orange"><?= $icon('high') ?></i><div><strong><?= e($num($high).' '.$tr('high-priority cases require timely review','حالة عالية الأولوية تحتاج مراجعة سريعة')) ?></strong><span><?= e($highPct.'% '.$tr('of review cases','من حالات المراجعة')) ?></span></div><b>›</b></a>
                <?php if($topStore!==[]): ?><a href="<?= e(url_to('diar-cases',['month'=>$selectedMonth,'store'=>(string)$topStore['store_code']])) ?>"><i class="tone-blue"><?= $icon('store') ?></i><div><strong><?= e($tr('Risk concentration is highest in','أعلى تركيز للمخاطر في').' '.(string)$topStore['hospital_code'].' · '.$tr('Store','مخزن').' '.(string)$topStore['store_code']) ?></strong><span><?= e($topStoreShare.'% '.$tr('of selected cases','من الحالات المحددة').' · '.$money($topStore['inventory_cost_abs']??0,true)) ?></span></div><b>›</b></a><?php endif; ?>
                <div><i class="tone-teal"><?= $icon('spark') ?></i><div><strong><?= e($num($aboveAverageCriticalDays).' '.$tr('days were above average and contained critical signals','يومًا تجاوزت المتوسط واحتوت إشارات حرجة')) ?></strong><span><?= e($highestDay!==[] ? $tr('Peak day','أعلى يوم').': '.(string)$highestDay['calendar_day'].' · '.$num($highestDay['detected_count']??0).' '.$tr('cases','حالة') : $tr('No daily trend available','لا يتوفر اتجاه يومي')) ?></span></div></div>
            </div>
        </article>

        <article class="executive-dashboard-card priority-chart-card"><header><div><span><?= e($tr('PRIORITY DISTRIBUTION','توزيع الأولوية')) ?></span><h2><?= e($tr('Review cases by severity','حالات المراجعة حسب الشدة')) ?></h2></div></header><div class="priority-chart-layout"><div id="diar-priority-chart" class="executive-chart" aria-label="<?= e($tr('Priority distribution chart','مخطط توزيع الأولوية')) ?>"><div class="chart-fallback"><strong><?= e($num($totalCases)) ?></strong><span><?= e($tr('Total cases','إجمالي الحالات')) ?></span></div></div><ul><li><i class="critical"></i><span><?= e($tr('Critical','حرجة')) ?></span><strong><?= e($num($critical)) ?></strong><em><?= e($criticalPct.'%') ?></em></li><li><i class="high"></i><span><?= e($tr('High','عالية')) ?></span><strong><?= e($num($high)) ?></strong><em><?= e($highPct.'%') ?></em></li><li><i class="medium"></i><span><?= e($tr('Medium','متوسطة')) ?></span><strong><?= e($num($medium)) ?></strong><em><?= e($mediumPct.'%') ?></em></li></ul></div></article>

        <article class="executive-dashboard-card readiness-card"><header><div><span><?= e($tr('HOSPITAL / SOURCE READINESS','جاهزية المستشفى / المصدر')) ?></span><h2><?= e($tr('Coverage in the selected scope','التغطية في النطاق المحدد')) ?></h2></div></header><div class="readiness-list">
            <?php foreach($siteCards as $siteCode=>$card): $available=(string)($card['status_code']??'')==='AVAILABLE'; $header=(array)($card['header']??[]); $daysExpected=max(1,(int)($header['days_expected']??0)); $coverage=$available?min(100,round(((int)($header['days_analyzed']??0)/$daysExpected)*100)):0; ?>
                <section class="readiness-source <?= $available?'is-ready':'is-pending' ?>"><div class="readiness-title"><strong><?= e((string)$siteCode) ?></strong><span><?= e((string)($card['source_db']??($siteCode==='MNH'?'ORAMNH':'ORANJC'))) ?></span><em><?= e($available?$tr('Live snapshot','نسخة حية'):$tr('Pending activation','بانتظار التفعيل')) ?></em></div><?php if($available): ?><div class="readiness-metrics"><span><?= e($tr('Coverage','التغطية')) ?><b><?= e((string)$coverage) ?>%</b></span><span><?= e($tr('Cases','الحالات')) ?><b><?= e($num($header['detected_count']??0)) ?></b></span><span><?= e($tr('Associated cost','التكلفة المرتبطة')) ?><b><?= e($money($header['inventory_cost_abs']??0,true)) ?></b></span></div><div class="readiness-track"><i style="width:<?= e((string)$coverage) ?>%"></i></div><small>#<?= e($num($header['month_snapshot_id']??0)) ?> · v<?= e($num($header['version_no']??0)) ?> · <?= e((string)($header['status_code']??'')) ?></small><?php else: ?><p><?= e($messageLabels[(string)($card['message_code']??'')]??$tr('This source is not included yet.','هذا المصدر غير مشمول حتى الآن.')) ?></p><?php endif; ?></section>
            <?php endforeach; ?>
        </div></article>
    </section>

    <section class="executive-dashboard-grid executive-grid-analytics">
        <article class="executive-dashboard-card daily-trend-card"><header><div><span><?= e($tr('DAILY TREND','الاتجاه اليومي')) ?></span><h2><?= e($tr('Associated inventory cost and review cases','تكلفة المخزون المرتبطة وحالات المراجعة')) ?></h2></div><em><?= e($overviewData['updated_through']??'—') ?></em></header><div id="diar-daily-trend-chart" class="executive-chart trend-chart" aria-label="<?= e($tr('Daily trend chart','مخطط الاتجاه اليومي')) ?>"><?php if($trend===[]): ?><div class="executive-empty-state"><?= e($tr('No daily trend data is available.','لا تتوفر بيانات اتجاه يومي.')) ?></div><?php endif; ?></div></article>

        <article class="executive-dashboard-card ranking-card"><header><div><span><?= e($tr('TOP RISKY STORES','أعلى المخازن مخاطرة')) ?></span><h2><?= e($tr('By associated cost','حسب التكلفة المرتبطة')) ?></h2></div><a href="<?= e(url_to('diar-cases',['month'=>$selectedMonth])) ?>"><?= e($tr('View all','عرض الكل')) ?></a></header><div class="premium-ranking-list"><?php foreach($topStores as $row): $width=min(100,round(((float)($row['inventory_cost_abs']??0)/$maxStoreCost)*100,1)); ?><a href="<?= e(url_to('diar-cases',['month'=>$selectedMonth,'store'=>(string)$row['store_code']])) ?>"><div><strong><?= e((string)$row['hospital_code'].' · '.$tr('Store','مخزن').' '.(string)$row['store_code']) ?></strong><span><?= e($money($row['inventory_cost_abs']??0,true)) ?></span></div><em><?= e($num($row['case_count']??0).' '.$tr('cases','حالة')) ?></em><i><b style="width:<?= e((string)$width) ?>%"></b></i></a><?php endforeach; ?><?php if($topStores===[]): ?><div class="executive-empty-state"><?= e($tr('No store ranking available.','لا يتوفر ترتيب للمخازن.')) ?></div><?php endif; ?></div></article>

        <article class="executive-dashboard-card ranking-card"><header><div><span><?= e($tr('TOP RISKY ITEMS','أعلى الأصناف مخاطرة')) ?></span><h2><?= e($tr('By associated cost','حسب التكلفة المرتبطة')) ?></h2></div><a href="<?= e(url_to('diar-cases',['month'=>$selectedMonth])) ?>"><?= e($tr('View all','عرض الكل')) ?></a></header><div class="premium-ranking-list item-ranking"><?php foreach($topItems as $row): $width=min(100,round(((float)($row['inventory_cost_abs']??0)/$maxItemCost)*100,1)); ?><a href="<?= e(url_to('diar-cases',['month'=>$selectedMonth,'item'=>(string)$row['item_code']])) ?>"><div><strong><?= e((string)$row['hospital_code'].' · '.$tr('Item','صنف').' '.(string)$row['item_code']) ?></strong><span><?= e($money($row['inventory_cost_abs']??0,true)) ?></span></div><em><?= e($num($row['case_count']??0).' '.$tr('cases','حالة')) ?></em><i><b style="width:<?= e((string)$width) ?>%"></b></i></a><?php endforeach; ?><?php if($topItems===[]): ?><div class="executive-empty-state"><?= e($tr('No item ranking available.','لا يتوفر ترتيب للأصناف.')) ?></div><?php endif; ?></div></article>
    </section>

    <section class="executive-dashboard-card decision-agenda-card"><header><div><span><?= e($tr('DECISION AGENDA','أجندة القرار')) ?></span><h2><?= e($tr('Recommended leadership review sequence','تسلسل المراجعة المقترح للإدارة')) ?></h2></div><a href="<?= e(url_to('diar-investigations')) ?>"><?= e($tr('Open follow-up','فتح المتابعة')) ?></a></header><div class="decision-agenda-table"><div class="agenda-head"><span><?= e($tr('Priority','الأولوية')) ?></span><span><?= e($tr('Required review','المراجعة المطلوبة')) ?></span><span><?= e($tr('Related scope','النطاق المرتبط')) ?></span><span><?= e($tr('Evidence','الدليل')) ?></span><span><?= e($tr('Status','الحالة')) ?></span></div><div><b class="priority-badge critical"><?= e($tr('Critical','حرجة')) ?></b><strong><?= e($tr('Review all critical candidates before lower priorities.','مراجعة كل المرشحات الحرجة قبل الأولويات الأقل.')) ?></strong><span><?= e($selectedMonth ?: '—') ?></span><span><?= e($num($critical).' '.$tr('cases','حالة')) ?></span><em><?= e($tr('Review required','تحتاج مراجعة')) ?></em></div><?php if($topStore!==[]): ?><div><b class="priority-badge high"><?= e($tr('High','عالية')) ?></b><strong><?= e($tr('Validate the concentration pattern in the leading store.','التحقق من نمط التركيز في المخزن الأعلى.')) ?></strong><span><?= e((string)$topStore['hospital_code'].' · '.$tr('Store','مخزن').' '.(string)$topStore['store_code']) ?></span><span><?= e($money($topStore['inventory_cost_abs']??0,true)) ?></span><em><?= e($tr('Analysis required','تحتاج تحليلًا')) ?></em></div><?php endif; ?><?php if($topItem!==[]): ?><div><b class="priority-badge medium"><?= e($tr('Medium','متوسطة')) ?></b><strong><?= e($tr('Assess recurrence and controls for the leading item.','تقييم التكرار والضوابط للصنف الأعلى.')) ?></strong><span><?= e((string)$topItem['hospital_code'].' · '.$tr('Item','صنف').' '.(string)$topItem['item_code']) ?></span><span><?= e($topItemShare.'% '.$tr('of cases','من الحالات')) ?></span><em><?= e($tr('Monitor','متابعة')) ?></em></div><?php endif; ?><?php if($partial): ?><div><b class="priority-badge pending"><?= e($tr('Coverage','تغطية')) ?></b><strong><?= e($tr('Complete NJCH DIAR-6A acceptance before combined hospital comparison.','إكمال قبول DIAR-6A على NJCH قبل المقارنة الموحدة.')) ?></strong><span>NJCH · ORANJC</span><span><?= e($tr('Pending source','مصدر معلق')) ?></span><em><?= e($tr('Pending activation','بانتظار التفعيل')) ?></em></div><?php endif; ?></div></section>

    <footer class="executive-data-trust"><div><span><?= e($tr('Statistical grain','الحبة الإحصائية')) ?></span><strong><?= e((string)($contract['grain']??'—')) ?></strong></div><div><span><?= e($tr('Snapshot references','مراجع النسخ')) ?></span><strong><?= e($num(count((array)($overviewData['snapshot_refs']??[])))) ?></strong></div><div><span><?= e($tr('Transactions represented','المعاملات الممثلة')) ?></span><strong><?= e($num($summary['candidate_txn_count']??0)) ?></strong></div><a href="<?= e(url_to('diar-reports')) ?>"><?= e($tr('Open reports & Excel','فتح التقارير وExcel')) ?></a></footer>
</section>

<script type="application/json" id="diar-executive-chart-data"><?= json_encode($chartData, JSON_UNESCAPED_UNICODE|JSON_UNESCAPED_SLASHES|JSON_HEX_TAG|JSON_HEX_AMP|JSON_HEX_APOS|JSON_HEX_QUOT) ?></script>
<script src="assets/js/diar-premium-executive.js?v=diar-6b-2-r3-1" defer></script>
