if (!isUserLoggedIn()) { header("Location: ../../"); die; } if (!$loggedInUser->checkPermission(array(2))) { header("Location: ../../"); die; } if (!empty($_GET['errors'])) { $err = explode(',', $_GET['errors']); } if (!empty($_GET['successes'])) { $succ = explode(',', $_GET['successes']); } $hutId = $_GET['id']; $hutName = getHutName($hutId); $hutDetails = fetchHutDetails($hutId); //Fetch information specific to koie $errors = array(); $successes = array(); if (!empty($_POST)) { $errors = array(); foreach ($_POST as $id => $value) { if (is_numeric($id) and is_numeric($value) and isset($value)) { $updateDB = updateDB($id, $value); if (!$updateDB) { $errors[] = lang("DATABASE_NOT_UPDATED"); } } } if (empty($errors)) {
//Last sign in, interpretation if ($userdetails['last_sign_in_stamp'] == '0') { echo "\r\n\t<span class='form-fixcontrol'>-</span>\r\n </div>\r\n </div>\r\n</div>"; } else { echo "\r\n\t<span class='form-fixcontrol'>" . date("j. F Y", $userdetails['sign_up_stamp']) . "</span>\r\n </div>\r\n </div>\r\n</div>"; } echo "\r\n<div class='form-group'>\r\n <label class='col-md-4 control-label' for='id'>Slett:</label> \r\n <div class='col-md-8'>\r\n <div class='radio'>\r\n <input type='checkbox' name='delete[" . $userdetails['id'] . "]' id='delete[" . $userdetails['id'] . "]' value='" . $userdetails['id'] . "'>\r\n </div>\r\n </div>\r\n</div>\r\n</div>\r\n</td>\r\n\r\n<td class='usertable'>\r\n<h3>Tilganger</h3>\r\n\r\n<strong>Fjern tilgang:</strong>"; //List of permission levels user is apart of foreach ($permissionData as $v1) { if (isset($userPermission[$v1['id']])) { echo "\r\n\t\t<div class='form-group'>\r\n <div class='col-md-8'>\r\n <div class='input-group'>\r\n <input type='checkbox' style='margin:12px 12px 0 12px;' name='removePermission[" . $v1['id'] . "]' id='removePermission[" . $v1['id'] . "]' value='" . $v1['id'] . "'> " . $v1['name'] . " \r\n </div>\r\n </div>\r\n</div> "; } } //List of permission levels user is not apart of echo "<strong>Legg til tilgang:</strong>"; foreach ($permissionData as $v1) { if (!isset($userPermission[$v1['id']])) { echo "\r\n\t\t<div class='form-group'>\r\n <div class='col-md-8'>\r\n <div class='input-group'>\r\n <input type='checkbox' style='margin:12px 12px 0 12px; padding: 0;' name='addPermission[" . $v1['id'] . "]' id='addPermission[" . $v1['id'] . "]' value='" . $v1['id'] . "'> " . $v1['name'] . " \r\n </div>\r\n </div>\r\n</div> "; } } echo "\r\n<!-- Button -->\r\n<div style='height: 215px;'>\r\n</div>\r\n<div class='form-group'>\r\n <div class='col-md-4'>\r\n <button id='submit' name='submit' class='btn btn-default'>Oppdater</button>\r\n </div>\r\n</div>\r\n</td>\r\n</tr>\r\n</table>\r\n</fieldset>\r\n</form>\r\n</div>"; echo resultBlock($errors, $successes); echo "\r\n<div class='tablemarginfix'>\r\n<h3>Reservasjoner</h3>\r\n<form name='slettReservasjon' action='" . $_SERVER['PHP_SELF'] . "' method='post'>\r\n<table class='table'>\r\n<thead>\r\n <tr> <th>#</th><th>Koie</th><th>Fra</th><th>Til</th><th>Handling</th></tr></thead>\r\n<tbody>"; asort($orders); foreach ($orders as $order) { echo "<tr><td>" . $order['id_bestilling'] . "</td><td>" . utf8_encode(getHutName($order['id_koie'])) . "</td><td>" . date('d-m-Y', strtotime($order['date_bestilling'])) . "</td><td> " . date('d-m-Y', strtotime($order['date_slutt'])) . "</td><td><input class='btn btn-info btn-xs' type='submit' name='" . $order['id_bestilling'] . "' value='Avbestill' /></td>"; } if (!count($orders)) { echo "<tr style='color: rgb(153, 153, 153);'><td>404</td><td>Ingen reservasjoner</td>\r\n</tr>"; } echo "\r\n</tbody> \r\n</table>\r\n</form>\r\n</div>\r\n</div>\r\n<div id='bottom'></div>\r\n</div>\r\n</div>\r\n</div>\r\n</body>\r\n<script>\r\ndocument.getElementById('brukere').className += 'aktiv';\r\n</script>\r\n</html>";
} if (isset($_GET['errors'])) { $errors[] = $_GET['errors']; } } if (!empty($_POST)) { $id = array_search('Avbestill', $_POST); if (deleteUserOrder($id)) { header('Location: ' . $_SERVER['PHP_SELF'] . "?successes=" . urlencode("Bestilling ble slettet fra databasen")); die; } else { header('Location: ' . $_SERVER['PHP_SELF'] . "?errors=" . urlencode("Noe gikk galt")); die; } } include "header.php"; echo "\n<div id='content'>\n<h2>Alle reservasjoner</h2>\n<div class='left-navbar' id='left-nav'>"; include "left-nav.php"; echo "\n</div>\n<div style='padding-left: 3%' id='main'>\n<div class='tablemargin'>\n<form name='slettReservasjon' action='" . $_SERVER['PHP_SELF'] . "' method='post'>\n<table class='table'>\n<thead>\n <tr> <th>#</th><th>Bruker</th><th>Koie</th><th>Fra</th><th>Til</th><th>Handling</th></tr></thead>\n<tbody>"; asort($orders); foreach ($orders as $order) { echo "<tr><td>" . $order['id_bestilling'] . "</td><td><a href='admin_user.php?id=" . $order['id_user'] . "'>" . getUserName($order['id_user']) . "</td><td>" . utf8_encode(getHutName($order['id_koie'])) . "</td><td>" . date('d-m-Y', strtotime($order['date_bestilling'])) . "</td><td> " . date('d-m-Y', strtotime($order['date_slutt'])) . "</td>"; if (strtotime(date('d-m-Y', strtotime($order['date_bestilling']))) > strtotime(date('d-m-Y'))) { echo "<td><input class='btn btn-info btn-xs' type='submit' name='" . $order['id_bestilling'] . "' value='Avbestill' /></td>"; } else { echo "<td></td>"; } } echo "\n</tbody> \n</table>\n</form>\n</div>"; echo resultBlock($errors, $successes); echo "\n</div>\n<div id='bottom'></div>\n</div>\n</div>\n</div>\n</body>\n<script>\ndocument.getElementById('bestillinger').className += 'aktiv';\n</script>\n</html>";