<?php

declare(strict_types=1);

require_once __DIR__ . '/helpers.php';

$disciplineModuleBoot = 'discipline_module_boot';
$findSuspensionOrAbort = 'find_suspension_or_abort';
$canManageDisciplineSuspensions = 'can_manage_discipline_suspensions';
$suspensionStatusOptions = 'suspension_status_options';

$disciplineModuleBoot();

$suspension = $findSuspensionOrAbort((int) ($_GET['id'] ?? 0));
$pageTitle = 'Review Suspension';

require dirname(__DIR__, 2) . '/includes/header.php';
require dirname(__DIR__, 2) . '/includes/sidebar.php';
require dirname(__DIR__, 2) . '/includes/topbar.php';
require dirname(__DIR__, 2) . '/includes/flash.php';
?>
<section class="panel-card">
    <div class="panel-card-header mb-3">
        <div>
            <p class="eyebrow mb-1">Suspension review</p>
            <h2 class="h4 mb-0"><?php echo e(trim($suspension['first_name'] . ' ' . $suspension['last_name'])); ?></h2>
        </div>
    </div>
    <div class="row g-3 mb-4">
        <div class="col-md-4">
            <div class="feature-tile"><i class="bi bi-shield-exclamation"></i>
                <div>
                    <h4>Reason</h4>
                    <p><?php echo e($suspension['reason']); ?></p>
                </div>
            </div>
        </div>
        <div class="col-md-4">
            <div class="feature-tile"><i class="bi bi-building"></i>
                <div>
                    <h4>Club</h4>
                    <p><?php echo e($suspension['club_name']); ?></p>
                </div>
            </div>
        </div>
        <div class="col-md-4">
            <div class="feature-tile"><i class="bi bi-flag"></i>
                <div>
                    <h4>Status</h4>
                    <p><span class="badge <?php echo e(suspension_status_badge_class($suspension['status'])); ?>"><?php echo e(ucfirst($suspension['status'])); ?></span></p>
                </div>
            </div>
        </div>
    </div>
    <?php if ($canManageDisciplineSuspensions()): ?>
        <form method="post" action="<?php echo e(base_url('app/modules/discipline/actions.php')); ?>">
            <?php echo csrf_input(); ?>
            <input type="hidden" name="action" value="update_suspension">
            <input type="hidden" name="id" value="<?php echo e((string) $suspension['id']); ?>">
            <div class="row g-3">
                <div class="col-md-4">
                    <label class="form-label" for="matches_served">Matches served</label>
                    <input class="form-control" id="matches_served" name="matches_served" type="number" min="0" value="<?php echo e((string) $suspension['matches_served']); ?>">
                </div>
                <div class="col-md-4">
                    <label class="form-label" for="status">Status</label>
                    <select class="form-select" id="status" name="status">
                        <?php foreach ($suspensionStatusOptions() as $status): ?>
                            <option value="<?php echo e($status); ?>" <?php echo $suspension['status'] === $status ? 'selected' : ''; ?>><?php echo e(ucfirst($status)); ?></option>
                        <?php endforeach; ?>
                    </select>
                </div>
            </div>
            <div class="d-flex gap-2 mt-4">
                <button class="btn btn-jlfc" type="submit">Save suspension</button>
                <a class="btn btn-outline-jlfc" href="<?php echo e(base_url('app/modules/discipline/index.php')); ?>">Back</a>
            </div>
        </form>
    <?php endif; ?>
</section>
<?php require dirname(__DIR__, 2) . '/includes/footer.php'; ?>