Exemple #1
0
// Load the page requested by the user
//============================================================================================
if (!isset($_GET['page'])) {
    $render = true;
    $thisPage = "seat-management";
    $allBuildings = $model->getAllBuildings();
    foreach ($allBuildings as &$a) {
        $a['rooms'] = $model->getNumberOfRooms($a['building_id']);
    }
    unset($a);
    $l10n->addResource(__DIR__ . '/l10n/seat-management.json');
    $viewFile = 'views/seat-management.php';
} elseif ($_GET['page'] === 'show-rooms') {
    $rooms = $model->getRooms($_POST['buildingId']);
    foreach ($rooms as &$r) {
        $r['seats'] = $model->getNumberOfSeats($r['room_id']);
    }
    unset($r);
    header('Content-Type: application/json; charset=utf-8');
    echo json_encode($rooms);
    exit;
} elseif ($_GET['page'] === 'new-building') {
    $model->insertBuilding($_POST);
    $loggers['audit']->info("Building {$_POST['building_name']} created");
} elseif ($_GET['page'] === 'delete-building') {
    $model->deleteBuilding($_POST['id']);
    $loggers['audit']->info("Building {$_POST['id']} deleted");
} elseif ($_GET['page'] === 'delete-seat') {
    $model->deleteSeat($_POST['id']);
    $loggers['audit']->info("Seat {$_POST['id']} deleted");
} elseif ($_GET['page'] === 'delete-room') {