<?php
require('php/useful.php');
require('php/session.php');
require('php/dbhookup.php');
require('php/mysql-functions.php');

?><!DOCTYPE html>
<html lang="en">
<?php require_once('head.php'); ?>
<body>
    <?php include('header.php'); ?>
    <main>
        <h2>NPSREC <?=$current_year?></h2>
        <p>Welcome to the <?=$current_year?> National Post-Secondary Russian Essay Contest. Online registration and logins are temporarily unavailable while we move to a new system; registration will reopen on the new site next cycle. Contact <a href="mailto:<?=$contact_email?>"><?=$contact_email?></a> with any questions.</p>
        <h3>The NPSREC will follow the schedule below for <?=$current_year?>:</h3>
        <table>
        <?php
        $sql = "SELECT event, deadline, feature_value FROM calendar WHERE active=1 AND deadline>? ORDER BY deadline ASC";
        $params = [];
        $params[] = $current_year."-01-01";
        $formats = "s";
        $events = query_array($conn, $sql, $formats, $params);
        foreach ($events as $event) {
            $event['deadline'] = date("j M Y", strtotime($event['deadline']));
            $time = ($event['feature_value'] == 0) ? "11:59pm" : "12:01am";
            echo "<tr><td>•</td><td>{$event['deadline']} {$time}</td><td>{$event['event']}</td></tr>";
        }
        ?>
        </table>

    </main>
    <?php require('footer.php'); ?>
</body>
</html>