} if ($bookingUserID != $_SESSION["netID"] && $class == "Student") { //determine the length of a given booking in hours $response = determineBookingLength($db, $bookingID); $bookingLength = $response[0]; $bookingDate = $response[1]; $hrsSourceList = array(); //retrieve hrsSource for each block retrieveHrsSource($db, $bookingID); //cancel booking deleteBooking($db, $bookingID); //email user who made booking $to = $bookingUserID . "@queensu.ca"; cancelBooking($room, $building, $startDate, $start, $end, $reason, $desc, $numP, $db, $to, true); //determnes which week the booking was booked in $week = determineWhichWeek($bookingDate); //return hours to the appropriate week and group for ($i = 0; $i < count($hrsSourceList); $i++) { if (strtolower($hrsSourceList[$i]) == "weekly") { returnWeeklyHoursToUser($db, $week, $bookingUserID, 0.5); } else { returnSpecialHoursToUser($db, $bookingUserID, $hrsSourceList[$i], 0.5); } } http_response_code(200); //success } else { //otherwise they are admin or deleting a faculty booking deleteBooking($db, $bookingID); //check if admin is deleting a different user's booking if ($bookingUserID != $_SESSION["netID"]) {
} } } } else { if ($department == "") { //how did you get here!?!?! $result['msg'] = "You cannot be found within the Music or Drama department and therefore may not book a room"; http_response_code(406); $bookingDurationError = true; } } } } if (!$bookingDurationError) { //determnes which week the booking was booked in $week = determineWhichWeek($startDate); $hoursRemaining = 0; //confirm if there are weekly hours for that week $sth = $db->prepare("SELECT {$week} FROM User WHERE uID = ?"); $sth->execute(array($uID)); while ($row = $sth->fetch(PDO::FETCH_ASSOC)) { //Get number of blocks $hoursRemaining = $row[$week]; } //if there are more weekly hours remaining than the hours required for the book if ($hoursRemaining >= $duration) { $hrsSource = "Weekly"; //because they used their weekly hours to book it //create booking $bookingID = createBookingInDB($db, $uID, $reason, $desc, $numP, $blocks, $startDate, $room, $totalB, $startTime, $endDate, $endTime, $hrsSource); //Send bookingID to front end