<?php

declare(strict_types=1);

require_once __DIR__ . '/helpers.php';

player_module_boot();

$playerRecord = find_player_or_abort((int) ($_GET['id'] ?? 0));
$pageTitle = 'Delete Player';

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">Danger zone</p>
            <h2 class="h4 mb-0">Delete <?php echo e(player_full_name($playerRecord)); ?></h2>
        </div>
    </div>
    <p class="text-muted">This will remove the player profile, photo, and uploaded documents. Deletion is blocked if the player already has dependent match or discipline records.</p>
    <form method="post" action="<?php echo e(base_url('app/modules/players/actions.php')); ?>">
        <?php echo csrf_input(); ?>
        <input type="hidden" name="action" value="delete">
        <input type="hidden" name="id" value="<?php echo e((string) $playerRecord['id']); ?>">
        <div class="d-flex gap-2">
            <button class="btn btn-danger" type="submit">Delete player</button>
            <a class="btn btn-outline-jlfc" href="<?php echo e(base_url('app/modules/players/view.php?id=' . (int) $playerRecord['id'])); ?>">Cancel</a>
        </div>
    </form>
</section>
<?php require dirname(__DIR__, 2) . '/includes/footer.php'; ?>