<div class="container-fluid">

<div class="mb-4">
    <h2 class="fw-bold">
        DOI Management Center
    </h2>
</div>

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

    <div class="col-md-3">
        <div class="card shadow-sm border-0">
            <div class="card-body text-center">
                <div class="text-muted">Total Records</div>
                <h2><?= (int)$stats['total_records'] ?></h2>
            </div>
        </div>
    </div>

    <div class="col-md-3">
        <div class="card shadow-sm border-0">
            <div class="card-body text-center">
                <div class="text-muted">Missing DOI</div>
                <h2><?= (int)$stats['missing_doi'] ?></h2>
            </div>
        </div>
    </div>

    <div class="col-md-3">
        <div class="card shadow-sm border-0">
            <div class="card-body text-center">
                <div class="text-muted">Issue Assigned + Missing DOI</div>
                <h2><?= (int)$stats['assigned_issue_missing_doi'] ?></h2>
            </div>
        </div>
    </div>

    <div class="col-md-3">
        <div class="card shadow-sm border-0">
            <div class="card-body text-center">
                <div class="text-muted">Ready For DOI</div>
                <h2><?= (int)$stats['ready_for_doi'] ?></h2>
            </div>
        </div>
    </div>

</div>

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

    <div class="card-header fw-bold">
        DOI Registry
    </div>

    <div class="table-responsive">

        <table class="table table-striped align-middle mb-0">

            <thead>
            <tr>
                <th>ID</th>
                <th>Submission</th>
                <th>Title</th>
                <th>Current DOI</th>
                <th>Issue</th>
                <th>DOI Prefix</th>
                <th>Preview DOI</th>
            </tr>
            </thead>

            <tbody>

            <?php foreach($rows as $r): ?>

                <tr>

                    <td><?= (int)$r['id'] ?></td>

                    <td>
                        <?= htmlspecialchars($r['submission_no']) ?>
                    </td>

                    <td>
                        <?= htmlspecialchars($r['title']) ?>
                    </td>

                    <td>
                        <?= htmlspecialchars($r['doi'] ?? '') ?>
                    </td>

                    <td>
                        <?= (int)($r['issue_id'] ?? 0) ?>
                    </td>

                    <td>
                        <?= htmlspecialchars($r['doi_prefix'] ?? '') ?>
                    </td>

                    <td>

                        <?php if(!empty($r['doi_prefix'])): ?>

                            <?= htmlspecialchars(
                                $r['doi_prefix']
                                . '/'
                                . $r['id']
                            ) ?>

                        <?php endif; ?>

                    </td>

                </tr>

            <?php endforeach; ?>

            </tbody>

        </table>

    </div>

</div>

</div>
