1
0
Fork 0
app.sixfold.org/www/index.php

69 lines
4.1 KiB
PHP

<?php
$description = "View the most recent games.";
$title = 'Dashboard';
include "partials/head.php"; ?>
<body>
<?php include "partials/header.php" ?>
<main id="main" class="flow">
<header>
<h1><?= $title ?></h1>
</header>
<?php if (!LOGGED_IN) : ?>
<p>You must log in to view this page.</p>
<?php
http_response_code(401);
include "partials/login-form.php";
else:
$sql = "SELECT games.id, games.name, games.submitstart, games.status_id, games.submitend, games.onestart, games.twostart, games.threestart, games.gameend FROM games JOIN game_status ON games.status_id = game_status.id ORDER BY games.id DESC LIMIT 2";
$stmt = $db['data']->query($sql);
while ($game = $stmt->fetch()) {
$dates = [
'submitstart' => DateTimeImmutable::createFromFormat('U', $game['submitstart'])->setTimezone($time_zone),
'submitend' => DateTimeImmutable::createFromFormat('U', $game['submitend'])->setTimezone($time_zone),
'onestart' => DateTimeImmutable::createFromFormat('U', $game['onestart'])->setTimezone($time_zone),
'twostart' => DateTimeImmutable::createFromFormat('U', $game['twostart'])->setTimezone($time_zone),
'threestart' => DateTimeImmutable::createFromFormat('U', $game['threestart'])->setTimezone($time_zone),
'gameend' => DateTimeImmutable::createFromFormat('U', $game['gameend'])->setTimezone($time_zone),
];
?>
<article class="flow">
<header>
<h3><?= $game['name'] ?></h3>
<p><span>Status: </span><?= get_status_message($game['status_id']) ?></p>
</header>
<dl>
<?php if ($game['status_id'] === STATUS_ENROLLING) : ?>
<dt>Submissions</dt>
<dd><span>Open: </span><time datetime="<?= $dates['submitstart']->format('c') ?>"><?= $dates['submitstart']->format('l, j F, o \a\t h:i A T') ?></time></dd>
<dd><span>Close: </span><time datetime="<?= $dates['submitend']->format('c') ?>"><?= $dates['submitend']->format('l, j F, o \a\t h:i A T') ?></time></dd>
<?php endif; ?>
<?php if ($game['status_id'] === STATUS_ROUND_ONE) : ?>
<dt>Round One</dt>
<dd><span>Open: </span><time datetime="<?= $dates['onestart']->format('c') ?>"><?= $dates['onestart']->format('l, j F, o \a\t h:i A T') ?></time></dd>
<dd><span>Close: </span><time datetime="<?= $dates['twostart']->sub($one_second)->format('c') ?>"><?= $dates['twostart']->sub($one_second)->format('l, j F, o \a\t h:i A T') ?></time></dd>
<?php endif; ?>
<?php if ($game['status_id'] === STATUS_ROUND_TWO) : ?>
<dt>Round Two</dt>
<dd><span>Open: </span><time datetime="<?= $dates['twostart']->format('c') ?>"><?= $dates['twostart']->format('l, j F, o \a\t h:i A T') ?></time></dd>
<dd><span>Close: </span><time datetime="<?= $dates['threestart']->sub($one_second)->format('c') ?>"><?= $dates['threestart']->sub($one_second)->format('l, j F, o \a\t h:i A T') ?></time></dd>
<?php endif; ?>
<?php if ($game['status_id'] === STATUS_ROUND_THREE) : ?>
<dt>Round Three</dt>
<dd><span>Open: </span><time datetime="<?= $dates['threestart']->format('c') ?>"><?= $dates['threestart']->format('l, j F, o \a\t h:i A T') ?></time></dd>
<dd><span>Close: </span><time datetime="<?= $dates['gameend']->format('c') ?>"><?= $dates['gameend']->format('l, j F, o \a\t h:i A T') ?></time></dd>
<?php endif; ?>
<?php if ($game['status_id'] === STATUS_REVIEW) : ?>
<p>Round One begins on <time datetime="<?= $dates['onestart']->format('c') ?>"><?= $dates['onestart']->format('l, j F, o \a\t h:i A T') ?></time></p>
<?php endif; ?>
</dl>
<p><a href="/games/<?= $game['id'] ?>" class="call-to-action"><?= $game['name'] ?> details</a></p>
</article>
<?php } ?>
<p><a href="/games">View previously completed games</a></p>
<?php endif; ?>
</main>
<?php include "partials/footer.php"; ?>