<?php
$title = "Review Form Criteria";
?>

<div class="card">
    <div class="card-header d-flex justify-content-between">
        <h3>Review Form Criteria</h3>


<a
    href="/easychair/admin/review-form/import-default"
    class="btn btn-warning rounded-pill fw-bold">

    <i class="fa fa-download"></i>
    <?= t('review.import_default', 'Import Default Review Form') ?>

</a>


        <a href="/easychair/admin/review-form/create"
           class="btn btn-primary">
            Add Criterion
        </a>
    </div>

    <div class="card-body">

        <table class="table table-bordered table-striped">

            <thead>
                <tr>
                    <th>#</th>
                    <th>Arabic Label</th>
                    <th>English Label</th>
                    <th>Max Score</th>
                    <th>Weight</th>
                    <th>Status</th>
                    <th width="220">Actions</th>
                </tr>
            </thead>

            <tbody>

<?php if (!empty($criteria)): ?>

<?php foreach ($criteria as $c): ?>

<tr>

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

<td>
<?= htmlspecialchars($c['title_ar'] ?? '') ?>
</td>

<td>
<?= htmlspecialchars($c['title_en'] ?? '') ?>
</td>

<td>
<?= htmlspecialchars($c['max_score'] ?? '') ?>
</td>

<td>
<?= htmlspecialchars($c['weight'] ?? '') ?>
</td>

<td>

<?php if (($c['is_active'] ?? 1) == 1): ?>

<span class="badge bg-success">
Active
</span>

<?php else: ?>

<span class="badge bg-secondary">
Inactive
</span>

<?php endif; ?>

</td>

<td>

<a href="/easychair/admin/review-form/edit?id=<?= (int)$c['id'] ?>"
   class="btn btn-sm btn-warning">
Edit
</a>

<a href="/easychair/admin/review-form/toggle?id=<?= $c['id'] ?>"
   class="btn btn-sm btn-info">
Toggle
</a>

<a href="/easychair/admin/review-form/delete?id=<?= (int)$c['id'] ?>"
   class="btn btn-sm btn-danger"
   onclick="return confirm('Delete this criterion?');">
Delete
</a>

</td>

</tr>

<?php endforeach; ?>

<?php else: ?>

<tr>
<td colspan="7" class="text-center">
No criteria found
</td>
</tr>

<?php endif; ?>

            </tbody>

        </table>

    </div>
</div>
