<?php

declare(strict_types=1);

require_once __DIR__ . '/helpers.php';

awards_module_boot();

$awardRecord = find_award_or_abort((int) ($_GET['id'] ?? 0));
$pageTitle = 'View Award';

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 mb-4">
    <div class="panel-card-header mb-3">
        <div>
            <p class="eyebrow mb-1">Award profile</p>
            <h2 class="h4 mb-0"><?php echo e($awardRecord['title']); ?></h2>
        </div>
        <div class="d-flex gap-2">
            <a class="btn btn-outline-jlfc" href="<?php echo e(base_url('app/modules/awards/edit.php?id=' . (int) $awardRecord['id'])); ?>">Edit</a>
            <a class="btn btn-outline-danger" href="<?php echo e(base_url('app/modules/awards/delete.php?id=' . (int) $awardRecord['id'])); ?>">Delete</a>
        </div>
    </div>
    <div class="row g-3">
        <div class="col-md-4">
            <div class="feature-tile"><i class="bi bi-award"></i>
                <div>
                    <h4>Award type</h4>
                    <p><?php echo e(award_type_label((string) $awardRecord['award_type'])); ?></p>
                </div>
            </div>
        </div>
        <div class="col-md-4">
            <div class="feature-tile"><i class="bi bi-person-vcard"></i>
                <div>
                    <h4>Recipient</h4>
                    <p><?php echo e(award_recipient_name($awardRecord)); ?></p>
                </div>
            </div>
        </div>
        <div class="col-md-4">
            <div class="feature-tile"><i class="bi bi-calendar-range"></i>
                <div>
                    <h4>Season</h4>
                    <p><?php echo e($awardRecord['season_name']); ?></p>
                </div>
            </div>
        </div>
        <div class="col-md-6">
            <div class="feature-tile"><i class="bi bi-trophy"></i>
                <div>
                    <h4>Competition</h4>
                    <p><?php echo e($awardRecord['competition_name'] ?: 'Season-wide award'); ?></p>
                </div>
            </div>
        </div>
        <div class="col-md-6">
            <div class="feature-tile"><i class="bi bi-building"></i>
                <div>
                    <h4>Club context</h4>
                    <p><?php echo e($awardRecord['club_name'] ?: 'No club linked'); ?></p>
                </div>
            </div>
        </div>
    </div>
</section>

<section class="panel-card">
    <div class="panel-card-header mb-3">
        <div>
            <p class="eyebrow mb-1">Narrative</p>
            <h3 class="h5 mb-0">Award notes</h3>
        </div>
    </div>
    <p class="mb-0"><?php echo $awardRecord['description'] !== '' && $awardRecord['description'] !== null ? nl2br(e($awardRecord['description'])) : 'No description added.'; ?></p>
</section>
<?php require dirname(__DIR__, 2) . '/includes/footer.php'; ?>