<?php
$setup = array();
$setup['title'] = "Tilføj Event";
$setup['headline'] = "Odense Track - Administration";
$setup['keywords'] = "administration,admin";
$setup['description'] = "Odense Track Administration";

Design::header($setup, 100);

if (isset($_POST['title'])) {
    if (isset($_FILES['thumbnail'])) {
        $uploaded = Upload::handleUpload($_FILES['thumbnail']);
         if ($uploaded == false) {
         // Fail!
         }
    }
    Alter::addEvent($_POST['title'], $_POST['textinput'], $_POST['type'], $_POST['eventdate'], $uploaded);
}
?>

<div class="page">
    <h1>Tilføj Event</h1> <div class="pull_right"><a href="?page=newsadmin">Nyheder</a><span class="seperator"></span><a href="?page=eventadmin">Events</a></div>
    <div class="border"></div>
    <br />
    <div class='editorform'>
        <form method="POST" action="" enctype="multipart/form-data">
            <input type="text" class='editformtitle' required placeholder='Nyhedstitel' name="title" />
            <br /><br />
            <p>Thumbnail</p>
            <input type="file" class='editformtitle' required name="thumbnail" />
            <br /><br />
            <select class='editformtitle' name="type">
                <option value="1">Event</option>
                <option value="2">Baneaktivitet</option>
            </select>
            <br /><br />
            <input type="datetime" class="datetime editformtitle" autocomplete="off" name="eventdate" placeholder="Dato og Tid" />
            <br /><br />
            <textarea name='textinput' class='editor'></textarea>
            <br />
            <input type="submit" class='button btn btn-success pull_right' value="Tilføj" />

        </form>
    </div>
    <div class='clear'></div>
</div>

<?php
Design::footer(true);
