public static function validateNewDates($user, $termId, $tutorId, $startDate, $endDate, $existingAppointmentId = false) { $nowDate = new DateTime(); date_default_timezone_set('Europe/Athens'); // TODO: remove hardcoded $user if ($nowDate > $startDate && !$user->isAdmin()) { throw new Exception("Starting datetime cannot be less than current datetime."); } $minutesAppointmentDuration = ($endDate->getTimestamp() - $startDate->getTimestamp()) / 60; if ($minutesAppointmentDuration < 30 || $minutesAppointmentDuration > 480) { throw new Exception("Appointment's duration can be between 30 min and 8 hours."); } if (!$user->isAdmin() && !ScheduleFetcher::existsTutorsSchedulesBetween($tutorId, $termId, $startDate, $endDate)) { throw new Exception("There is a conflict with start/end date with tutor's schedule. "); } if (AppointmentFetcher::existsTutorsAppointmentsBetween($tutorId, $termId, $startDate, $endDate, $existingAppointmentId)) { throw new Exception("There is a conflict with the start/end date with another appointment for selected tutor."); } }
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ /** * @author Rizart Dokollari * @author George Skarlatos * @since 9/19/2014 */ require __DIR__ . '/../app/init.php'; $general->loggedOutProtect(); try { $tutors = TutorFetcher::retrieveActive(); $currentTerms = TermFetcher::retrieveCurrTerm(); $schedules = ScheduleFetcher::retrieveTutorsOnCurrentTerms(); if (isUrlRequestingAllSchedules($user)) { $pageTitle = "All Schedules"; } else { if (isBtnAddSchedulePrsd()) { $pageTitle = "Add schedule"; $days = isset($_POST['day']) ? $_POST['day'] : null; Schedule::add($_POST['tutorId'], $_POST['termId'], $days, $_POST['startsAt'], $_POST['endsAt']); header('Location: ' . BASE_URL . 'staff/schedules/success'); exit; } else { if (isBtnDeletePrsd()) { Schedule::delete($_POST['delScheduleIdModal']); header('Location: ' . BASE_URL . 'staff/schedules/success'); exit; } else {
public static function getTutorsOnTermOnCourse($courseId, $termId) { Course::validateId($courseId); Term::validateId($termId); return ScheduleFetcher::retrieveTutorsOnTermOnCourse($courseId, $termId); }
$general->loggedOutProtect(); $pageTitle = "Personnel"; $section = "staff"; try { // protect again any sql injections on url if (isset($_GET['id']) && preg_match("/^[0-9]+\$/", $_GET['id'])) { $userId = $_GET['id']; $pageTitle = "Profile"; if (($data = User::getSingle($userId)) === false) { header('Location: ' . BASE_URL . 'error-404'); exit; } if (strcmp($data['type'], 'tutor') === 0) { $tutor = TutorFetcher::retrieveSingle($userId); $curUser = new Tutor($data['id'], $data['f_name'], $data['l_name'], $data['email'], $data['mobile'], $data['img_loc'], $data['profile_description'], $data['date'], $data['type'], $data['active'], $tutor[MajorFetcher::DB_COLUMN_NAME]); $schedules = ScheduleFetcher::retrieveCurrWorkingHours($curUser->getId()); $teachingCourses = TutorFetcher::retrieveCurrTermTeachingCourses($curUser->getId()); } else { if (strcmp($data['type'], 'secretary') === 0) { $curUser = new Secretary($data['id'], $data['f_name'], $data['l_name'], $data['email'], $data['mobile'], $data['img_loc'], $data['profile_description'], $data['date'], $data['type'], $data['active']); } else { if (strcmp($data['type'], 'admin') === 0) { $curUser = new Admin($data['id'], $data['f_name'], $data['l_name'], $data['email'], $data['mobile'], $data['img_loc'], $data['profile_description'], $data['date'], $data['type'], $data['active']); } else { throw new Exception("Something terrible has happened with the database. <br/>The software developers will tremble with fear."); } } } } else { if (isBtnInactivePrsd()) { $users = User::retrieveAllInactive();
* the following tutor details (as elements of an array named $jobs): * * * Created by PhpStorm. * Date: 4/1/14 * Time: 3:24 AM * */ $id = $curUser[UserFetcher::DB_COLUMN_ID]; $first_name = $curUser[UserFetcher::DB_COLUMN_FIRST_NAME]; $last_name = $curUser[UserFetcher::DB_COLUMN_LAST_NAME]; $email = $curUser[UserFetcher::DB_COLUMN_EMAIL]; $position = $curUser[UserTypesFetcher::DB_COLUMN_TYPE]; if (User::isUserTypeTutor($position)) { $courses = TutorFetcher::retrieveCurrTermTeachingCourses($id); $schedules = ScheduleFetcher::retrieveCurrWorkingHours($id); } $mobile = $curUser[UserFetcher::DB_COLUMN_MOBILE]; ?> <tr> <td class="text-center"><?php echo $first_name . " " . $last_name; ?> </td> <td class="text-center"><?php echo $email; ?> </td> <td class="text-center"><?php echo $position; ?>