
<?php
echo '<div style="
position:fixed;
left:15px;
bottom:15px;
z-index:999999;
background:#ef4444;
color:#fff;
padding:10px 18px;
border-radius:12px;
font-weight:900;
">
TRACE: '.htmlspecialchars(__FILE__).'
</div>';
?>

<?php
function rd_h($v) {
    return htmlspecialchars((string)$v, ENT_QUOTES, 'UTF-8');
}
function rd_t($key, $fallback) {
    if (function_exists('ec_t')) return ec_t($key, $fallback);
    if (function_exists('t')) return t($key, $fallback);
    return $fallback;
}
function rd_status_label($v) {
    if (function_exists('ec_submission_status_t')) return ec_submission_status_t($v);
    return (string)$v;
}

$role = $role ?? ($_SESSION['conference_role'] ?? $_SESSION['role'] ?? '');
$conference = $conference ?? [];
$stats = $stats ?? [];
$actions = $actions ?? [];
$recentSubmissions = $recentSubmissions ?? [];
$workflowRows = $workflowRows ?? [];
$lang = function_exists('ec_lang') ? ec_lang() : ($_SESSION['lang'] ?? 'ar');

$roleLabel = function_exists('ec_role_layout_role_label')
    ? ec_role_layout_role_label((string)$role)
    : ucwords(str_replace('_',' ', (string)$role));

$confTitle = $lang === 'en'
    ? (($conference['title_en'] ?? '') ?: ($conference['title_ar'] ?? ''))
    : (($conference['title_ar'] ?? '') ?: ($conference['title_en'] ?? ''));
?>

<div class="container-fluid py-3">
    <div class="card border-0 shadow-sm mb-4" style="border-radius:28px;background:linear-gradient(135deg,#0f172a,#2563eb);color:#fff;overflow:hidden;">
        <div class="card-body p-4 p-lg-5">
            <div class="d-flex justify-content-between align-items-start flex-wrap gap-3">
                <div>
                    <div class="badge bg-light text-primary rounded-pill px-3 py-2 mb-3">
                        <?= rd_h($roleLabel) ?>
                    </div>

                    <h2 class="fw-black fw-bold mb-2">
                        <i class="fa fa-gauge-high"></i>
                        <?= rd_h(rd_t('dashboard.role.title','Role Dashboard')) ?>
                    </h2>

                    <div class="opacity-75">
                        <?= rd_h(rd_t('dashboard.role.subtitle','Role-based overview and shortcuts')) ?>
                    </div>

                    <div class="mt-3 small opacity-75">
                        <strong><?= rd_h($conference['short_name'] ?? '') ?></strong>
                        <?php if ($confTitle): ?>
                            — <?= rd_h($confTitle) ?>
                        <?php endif; ?>
                    </div>
                </div>

                <div class="text-end">
                    <div class="rounded-4 p-3" style="background:rgba(255,255,255,.12);border:1px solid rgba(255,255,255,.18);">
                        <div class="small opacity-75"><?= rd_h(rd_t('dashboard.section.role_scope','Current Scope')) ?></div>
                        <div class="fw-bold"><?= rd_h($conference['org_name'] ?? ('Org '.($conference['org_id'] ?? ''))) ?></div>
                        <div class="small opacity-75">Conference #<?= (int)($conference['id'] ?? 0) ?></div>
                    </div>
                </div>
            </div>
        </div>
    

<style>

/* PACK142_ROLE_ANALYTICS */

.roleInsight{

margin-top:24px;

}

.roleGrid{

display:grid;

grid-template-columns:
1.3fr .7fr;

gap:20px;

}

.panel{

background:#fff;

border-radius:26px;

padding:26px;

box-shadow:
0 18px 50px rgba(15,23,42,.08);

}

.panelTitle{

font-size:22px;

font-weight:900;

margin-bottom:20px;

color:#0f172a;

}

.flow{

display:grid;

gap:16px;

}

.flowRow{

display:grid;

grid-template-columns:
170px
1fr
60px;

gap:14px;

align-items:center;

}

.flowBar{

height:16px;

background:#edf2f7;

border-radius:999px;

overflow:hidden;

}

.flowFill{

height:100%;

border-radius:999px;

}

.activity{

display:grid;

gap:14px;

}

.activityItem{

padding:14px;

border-radius:18px;

background:#f8fbff;

display:flex;

gap:14px;

align-items:center;

}

.activityItem i{

width:42px;

height:42px;

display:flex;

align-items:center;

justify-content:center;

background:#2455ff;

color:#fff;

border-radius:12px;

}

.health{

margin-top:18px;

display:grid;

grid-template-columns:1fr 1fr;

gap:14px;

}

.healthBox{

padding:18px;

border-radius:18px;

background:
linear-gradient(
135deg,
#071126,
#2455ff
);

color:#fff;

}

@media(max-width:1200px){

.roleGrid{

grid-template-columns:1fr;

}

}


<style>

/* PACK144_VISUAL */

body{
background:
linear-gradient(
180deg,
#f7faff,
#eef4fb
)!important;
}

.hero{
background:
linear-gradient(
135deg,
#041330,
#173fc9 70%,
#4e78ff
)!important;

border-radius:34px!important;

box-shadow:
0 30px 80px
rgba(37,99,235,.22)!important;
}

.hero h1,
.hero h2,
.hero h3{

font-weight:900!important;

}

.metric,
.metric-card,
.stat-card{

background:#fff!important;

border:none!important;

border-radius:30px!important;

box-shadow:
0 20px 60px
rgba(15,23,42,.08)!important;

transition:.25s;

}

.metric:hover,
.metric-card:hover,
.stat-card:hover{

transform:
translateY(-5px);

}

.metric h2,
.metric .value,
.metric-card .value{

font-size:56px!important;

font-weight:900!important;

color:#071126!important;

}

.metric small,
.metric label,
.metric-card small{

color:#64748b!important;

font-weight:700!important;

}

.workflow,
.workflow-stage{

border-radius:24px!important;

font-weight:900!important;

padding:18px!important;

}

.workflow-stage:nth-child(1){

background:#2563eb!important;

color:#fff!important;

}

.workflow-stage:nth-child(2){

background:#06b6d4!important;

color:#fff!important;

}

.workflow-stage:nth-child(3){

background:#f59e0b!important;

color:#fff!important;

}

.workflow-stage:nth-child(4){

background:#7c3aed!important;

color:#fff!important;

}

.workflow-stage:nth-child(5){

background:#16a34a!important;

color:#fff!important;

}

.quick-actions a,
.action-btn{

border-radius:18px!important;

font-weight:800!important;

padding:18px!important;

background:
linear-gradient(
135deg,
#f7fbff,
#eef4ff
)!important;

}

.progress{

height:16px!important;

border-radius:999px!important;

}

.progress-bar{

background:
linear-gradient(
90deg,
#2563eb,
#4f46e5
)!important;

}

</style>

</style>

<div class="roleInsight">

<div class="roleGrid">

<div class="panel">

<div class="panelTitle">

<i class="fa-solid fa-chart-column"></i>

Submission Funnel

</div>

<div class="flow">

<div class="flowRow">

Submitted

<div class="flowBar">

<div
class="flowFill"
style="
width:100%;
background:#2455ff">

</div>

</div>

14

</div>


<div class="flowRow">

Review

<div class="flowBar">

<div
class="flowFill"
style="
width:76%;
background:#06b6d4">

</div>

</div>

9

</div>


<div class="flowRow">

Revision

<div class="flowBar">

<div
class="flowFill"
style="
width:35%;
background:#f59e0b">

</div>

</div>

3

</div>


<div class="flowRow">

Decision

<div class="flowBar">

<div
class="flowFill"
style="
width:18%;
background:#10b981">

</div>

</div>

2

</div>

</div>

</div>


<div class="panel">

<div class="panelTitle">

<i class="fa-solid fa-bolt"></i>

Activity

</div>

<div class="activity">

<div class="activityItem">

<i class="fa-solid fa-user-check"></i>

Reviewer Assigned

</div>

<div class="activityItem">

<i class="fa-solid fa-file-signature"></i>

Decision Recorded

</div>

<div class="activityItem">

<i class="fa-solid fa-rocket"></i>

Publication Ready

</div>

</div>

<div class="health">

<div class="healthBox">

Health

<h2>98%</h2>

</div>

<div class="healthBox">

Coverage

<h2>84%</h2>

</div>

</div>

</div>

</div>

</div>

</div>

    

<!-- EXEC_REAL_BLOCK -->

<div class="row g-4 mb-4">

<div class="col-lg-8">

<div class="card border-0 shadow-sm"
style="
border-radius:28px;
overflow:hidden;
">

<div class="card-body p-4">

<h4 class="fw-bold mb-4">

📈 Executive Analytics

</h4>

<div class="mb-4">

<div class="d-flex justify-content-between">

<span>Submission Progress</span>

<strong>72%</strong>

</div>

<div class="progress"
style="height:18px">

<div
class="progress-bar
bg-primary"
style="width:72%">

</div>

</div>

</div>

<div class="mb-4">

<div class="d-flex justify-content-between">

<span>Review Completion</span>

<strong>64%</strong>

</div>

<div class="progress"
style="height:18px">

<div
class="progress-bar
bg-info"
style="width:64%">

</div>

</div>

</div>

<div class="mb-4">

<div class="d-flex justify-content-between">

<span>Publication Ready</span>

<strong>28%</strong>

</div>

<div class="progress"
style="height:18px">

<div
class="progress-bar
bg-success"
style="width:28%">

</div>

</div>

</div>

</div>

</div>

</div>


<div class="col-lg-4">

<div class="card border-0 shadow-sm"

style="
border-radius:28px;
height:100%;
">

<div class="card-body">

<h4 class="fw-bold">

⚡ Live Activity

</h4>

<div class="mt-4">

<div class="mb-3">

✓ Reviewer Assigned

</div>

<div class="mb-3">

★ Decision Approved

</div>

<div class="mb-3">

↻ Revision Uploaded

</div>

<div class="mb-3">

🚀 Proceedings Generated

</div>

</div>

</div>

</div>

</div>

</div>


<div class="row g-3 mb-4">
        <?php foreach ($stats as $s): ?>
            <div class="col-xl-3 col-md-6">
                <div class="card border-0 shadow-sm h-100" style="border-radius:22px;">
                    <div class="card-body p-4 d-flex justify-content-between align-items-center">
                        <div>
                            <div class="text-muted small fw-bold"><?= rd_h(rd_t($s['key'] ?? '', $s['label'] ?? '')) ?></div>
                            <div class="fs-2 fw-bold"><?= (int)($s['value'] ?? 0) ?></div>
                        </div>
                        <div class="rounded-circle d-flex align-items-center justify-content-center" style="width:56px;height:56px;background:#eef2ff;color:#1d4ed8;">
                            <i class="fa <?= rd_h($s['icon'] ?? 'fa-circle') ?>"></i>
                        </div>
                    </div>
                </div>
            </div>
        <?php endforeach; ?>
    </div>
<?php

$homepageWorkflowStats = [

    'recommendations' => 0,
    'decisions'       => 0,
    'published'       => 0,
    'archived'        => 0

];

try {

    $db =
        \App\Core\Database::getInstance();

    $rows =
        $db
        ->query("
            SELECT status
            FROM homepage_deployments
        ")
        ->fetchAll(
            PDO::FETCH_ASSOC
        );

    foreach ($rows as $row) {

        $status =
            strtolower(
                (string)$row['status']
            );

        if (
            $status ===
            'under_review'
        ) {

            $homepageWorkflowStats['recommendations']++;

        }

        if (
            in_array(
                $status,
                [
                    'recommend_accept',
                    'recommend_revision',
                    'recommend_reject'
                ],
                true
            )
        ) {

            $homepageWorkflowStats['decisions']++;

        }

        if (
            $status ===
            'published'
        ) {

            $homepageWorkflowStats['published']++;

        }

        if (
            $status ===
            'archived'
        ) {

            $homepageWorkflowStats['archived']++;

        }
    }

} catch (\Throwable $e) {

}

require
BASE_PATH .
'/app/views/admin/conference_home/workflow_dashboard_widget.php';

?>

<?php

require
BASE_PATH .
'/app/views/admin/conference_home/workflow_alerts_dashboard_widget.php';

?>
    <div class="row g-4">
        <div class="col-xl-4">
            <div class="card border-0 shadow-sm h-100" style="border-radius:22px;">
                <div class="card-body p-4">
                    <h5 class="fw-bold mb-3">
                        <i class="fa fa-bolt text-primary"></i>
                        <?= rd_h(rd_t('dashboard.section.quick_actions','Quick Actions')) ?>
                    </h5>

                    <div class="d-grid gap-2">
                        <?php foreach ($actions as $a): ?>
                            <a href="<?= rd_h($a[0]) ?>" class="btn btn-light border d-flex align-items-center justify-content-between rounded-4 p-3 text-start">
                                <span>
                                    <i class="fa <?= rd_h($a[1]) ?> text-primary"></i>
                                    <strong><?= rd_h(rd_t($a[2], $a[3])) ?></strong>
                                </span>
                                <i class="fa fa-chevron-left opacity-50"></i>
                            </a>
                        <?php endforeach; ?>

                        <?php if (!$actions): ?>
                            <div class="text-muted py-4 text-center">
                                <?= rd_h(rd_t('dashboard.section.no_data','No data available.')) ?>
                            </div>
                        <?php endif; ?>
                    </div>
                </div>
            </div>
        </div>

        <div class="col-xl-5">
            <div class="card border-0 shadow-sm h-100" style="border-radius:22px;">
                <div class="card-body p-4">
                    <h5 class="fw-bold mb-3">
                        <i class="fa fa-inbox text-primary"></i>
                        <?= rd_h(rd_t('dashboard.section.recent_submissions','Recent Submissions')) ?>
                    </h5>

                    <div class="table-responsive">
                        <table class="table table-bordered align-middle">
                            <thead class="table-dark">
                            <tr>
                                <th>#</th>
                                <th><?= rd_h(rd_t('submission.title','Title')) ?></th>
                                <th><?= rd_h(rd_t('submission.status','Status')) ?></th>
                            </tr>
                            </thead>
                            <tbody>
                            <?php foreach ($recentSubmissions as $r): ?>
                                <tr>
                                    <td>
                                        <a href="/easychair/admin/submission-workflow?submission_id=<?= (int)$r['id'] ?>" class="fw-bold">
                                            <?= rd_h($r['submission_no'] ?? ('#'.$r['id'])) ?>
                                        </a>
                                    </td>
                                    <td>
                                        <strong><?= rd_h(($r['title'] ?? '') ?: ($r['title_ar'] ?? '')) ?></strong>
                                        <div class="text-muted small"><?= rd_h($r['updated_at'] ?? '') ?></div>
                                    </td>
                                    <td>
                                        <span class="badge bg-info text-dark"><?= rd_h(rd_status_label($r['stage'] ?? $r['status'] ?? '')) ?></span>
                                    </td>
                                </tr>
                            <?php endforeach; ?>

                            <?php if (!$recentSubmissions): ?>
                                <tr>
                                    <td colspan="3" class="text-center text-muted py-4">
                                        <?= rd_h(rd_t('dashboard.section.no_data','No data available.')) ?>
                                    </td>
                                </tr>
                            <?php endif; ?>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>

        <div class="col-xl-3">
            <div class="card border-0 shadow-sm h-100" style="border-radius:22px;">
                <div class="card-body p-4">
                    <h5 class="fw-bold mb-3">
                        <i class="fa fa-diagram-project text-primary"></i>
                        <?= rd_h(rd_t('dashboard.section.workflow_status','Workflow Status')) ?>
                    </h5>

                    <?php foreach ($workflowRows as $w): ?>
                        <?php
                            $total = max(1, array_sum(array_map(fn($x) => (int)($x['total'] ?? 0), $workflowRows)));
                            $pct = min(100, round(((int)$w['total'] / $total) * 100));
                        ?>
                        <div class="mb-3">
                            <div class="d-flex justify-content-between small fw-bold mb-1">
                                <span><?= rd_h(rd_status_label($w['stage_key'] ?? '')) ?></span>
                                <span><?= (int)($w['total'] ?? 0) ?></span>
                            </div>
                            <div class="progress" style="height:10px;border-radius:999px;">
                                <div class="progress-bar" style="width:<?= (int)$pct ?>%;"></div>
                            </div>
                        </div>
                    <?php endforeach; ?>

                    <?php if (!$workflowRows): ?>
                        <div class="text-muted py-4 text-center">
                            <?= rd_h(rd_t('dashboard.section.no_data','No data available.')) ?>
                        </div>
                    <?php endif; ?>
                </div>
            </div>
        </div>
    </div>
</div>


<!-- PACK141_ROLE -->

<style>

.roleAnalytics{

margin-top:28px;

display:grid;

grid-template-columns:
1.2fr .8fr;

gap:22px;

}

.raCard{

background:#fff;

border-radius:28px;

padding:26px;

box-shadow:
0 20px 50px rgba(15,23,42,.08);

}

.raTitle{

font-size:24px;

font-weight:900;

margin-bottom:24px;

color:#081126;

}

.rowA{

display:grid;

grid-template-columns:
160px
1fr
60px;

gap:12px;

align-items:center;

margin-bottom:18px;

}

.bar{

height:16px;

background:#edf2f7;

border-radius:999px;

overflow:hidden;

}

.fill{

height:100%;

border-radius:999px;

}

.feed{

display:grid;

gap:14px;

}

.feedItem{

padding:16px;

border-radius:18px;

background:#f8fbff;

font-weight:700;

}

.health{

display:grid;

grid-template-columns:
1fr 1fr;

gap:14px;

margin-top:22px;

}

.healthBox{

padding:22px;

border-radius:20px;

background:
linear-gradient(
135deg,
#071126,
#2455ff
);

color:#fff;

}

@media(max-width:1200px){

.roleAnalytics{

grid-template-columns:1fr;

}

}

</style>

<div class="roleAnalytics">

<div class="raCard">

<div class="raTitle">

📊 Conference Analytics

</div>

<div class="rowA">

Submitted

<div class="bar">

<div
class="fill"
style="
width:90%;
background:#2455ff">

</div>

</div>

14

</div>

<div class="rowA">

Review

<div class="bar">

<div
class="fill"
style="
width:74%;
background:#06b6d4">

</div>

</div>

9

</div>

<div class="rowA">

Decision

<div class="bar">

<div
class="fill"
style="
width:32%;
background:#7c3aed">

</div>

</div>

3

</div>

<div class="rowA">

Published

<div class="bar">

<div
class="fill"
style="
width:18%;
background:#10b981">

</div>

</div>

1

</div>

</div>


<div class="raCard">

<div class="raTitle">

⚡ Activity & Health

</div>

<div class="feed">

<div class="feedItem">

Reviewer assigned

</div>

<div class="feedItem">

Decision approved

</div>

<div class="feedItem">

Author revision submitted

</div>

</div>

<div class="health">

<div class="healthBox">

Health

<h2>

98%

</h2>

</div>

<div class="healthBox">

Capacity

<h2>

84%

</h2>

</div>

</div>

</div>

</div>

