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

Design::header($setup, 100);

// First we need to know if we are deleting something!

if (isset($_GET['action'])) { // We are deleting this!
    if ($_GET['action'] == 'del') {
        Alter::deleteEvent($_GET['id']);
    }
    die(); // Something went wrong. Dont execute rest of code!
}

$result = Get::ViewEvent($_GET['id']);

if (isset($_POST['title'])) {
    Alter::editEvent($_GET['id'], $_POST['title'], $_POST['textinput'], $_POST['type'], $_POST['eventdate']);
}
?>

<div class="page">
    <h1>Rediger 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="">
            <input type="text" class='editformtitle' required placeholder='Nyhedstitel' value="<?php echo $result['title']; ?>" name="title" />
            <br /><br />
            <select class='editformtitle' name="type">
                <option <?php if ($result['type'] == 1) {
    echo "selected";
} ?> value="1">Event</option>
                <option <?php if ($result['type'] == 2) {
    echo "selected";
} ?> value="2">Baneaktivitet</option>
            </select>
            <br /><br />
            <input type="datetime" class="datetime editformtitle" name="eventdate" autocomplete="off" value="<?php echo date('Y/m/d H:i', $result['time']); ?>" placeholder="Dato og Tid" />
            <br /><br />
            <textarea name='textinput' class='editor'><?php echo strip_tags($result['description'], '<br><p><b><i><u><img><a><strong><pre><em><span><div><h1><h2><h3><h4><h5><h6><h7><sub><sup><blockquote><code>'); ?></textarea>
            <br />
            <input type="submit" class='button btn btn-success pull_right' value="Rediger" />

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

<?php
Design::footer(true);
