$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); $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']);
//gather request and accommodation data $request = $model->getExamRequestById($_POST['request_id']); $examAccs = $model->getExamAccommodationsById($_POST['request_id']); $studentAccs = $model->getAllStudentActiveExamAndTranscriptionAccommodations($_POST['student_id'], $_POST['exam_date'], $request[0]['course_code'], $request[0]['course_section'], $request[0]['session']); if (!empty($studentAccs)) { $studentAccs = array_values($studentAccs); } $l10n->addResource(__DIR__ . '/l10n/confirmed-requests.json'); $l10n->localizeArray($examAccs, 'name'); $l10n->localizeArray($studentAccs, 'name'); //set up response array $details = array("request" => $request, "exam_accommodations" => $examAccs, "student_accommodations" => $studentAccs); //if the request also has a seat associated with it recover the appropriate room and seat information if (!is_null($request[0]['seat_id'])) { //gather room and seat data $rooms = $seatManagement->getRooms($request[0]['building_id']); $seats = $seatManagement->getSeatsForRoom($request[0]['room_id']); $details['rooms'] = $rooms; $details['seats'] = $seats; //save a list of exams booked on the same seat at the same time as the one retrieved $bookings = $seatManagement->getSeatBookings($request[0]['seat_id'], $request[0]['exam_date']); $conflicts = ""; foreach ($bookings as $b) { if ($request[0]['request_id'] !== $b['request_id'] && !(strtotime($request[0]['official_evaluation_starttime']) >= strtotime($b['official_evaluation_endtime']) || strtotime($request[0]['official_evaluation_endtime']) <= strtotime($b['official_evaluation_starttime']))) { $conflicts .= $b['request_id'] . ","; } } if ($conflicts !== "") { $details['request'][0]['seat_conflicts'] = substr($conflicts, 0, -1); } }