Ejemplo n.º 1
0
\Locale::setDefault($SESSION->lang);
$l10n->setLanguage($SESSION->lang);
//============================================================================================
// Model
//============================================================================================
$model = new Seats($dbo);
$follow = new \Ventus\Specialist\FollowUps($dbo);
//============================================================================================
// 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);