static function removeInstructor() { $id = $_POST['id']; $cursor = Dispatcher::$mysqli->query("select * from instructor where status='default'"); $row = $cursor->fetch_assoc(); $defaultInstructorID = $row['Person_id']; $default_calendar_id = $row['calendar_id']; Dispatcher::$mysqli->query("update custom_intsructor set instructor_id={$defaultInstructorID} where instructor_id={$id}"); Dispatcher::$mysqli->query("update instructor_has_hours set instructor_id={$defaultInstructorID} where instructor_id={$id}"); $cursor = Dispatcher::$mysqli->query("select * from instructor where `Person_id`={$id}"); $row = $cursor->fetch_assoc(); $prev_calendar_id = $row['calendar_id']; $cursor = Dispatcher::$mysqli->query("select * from event where `instructor_Person_id`={$id}"); $instructorCalendarEvents = new InstructorCalendarEvents(); while ($row = $cursor->fetch_assoc()) { $instructorCalendarEvents->setDefaultInstructor($prev_calendar_id, $row['clndr_event_id'], $default_calendar_id); } Dispatcher::$mysqli->query("delete from instructor where `Person_id`='{$id}'"); Dispatcher::$mysqli->query("delete from person where id='{$id}'"); print_r(Dispatcher::$mysqli->error); $instructors_array = self::getInstructors(); get_instructors_view($instructors_array); }
static function booking_create_reservation_summary($reservation_id, $client_id, $resDate, $hours_array, $reserve_type) { $instructorCalendarEvents = new InstructorCalendarEvents(); for ($j = 0; $j < count($hours_array); $j++) { if ($hours_array[$j]['choosen_places'] > 0) { $hour_id = $hours_array[$j]['hours_id']; $cursor = Dispatcher::$mysqli->query("select * from event where hours_id={$hour_id} and date='{$resDate}'"); if ($cursor->num_rows > 0) { $row = $cursor->fetch_assoc(); $instructorCalendarEvents->updateEventAfterReservation($hours_array[$j], $row, $client_id, $resDate, $reservation_id, $reserve_type); } else { $instructorCalendarEvents->addEventAfterReservation($hours_array[$j], $client_id, $resDate, $reservation_id, $reserve_type); } } } print_r(Dispatcher::$mysqli->error); }
static function changeInstructor() { $instructor_id = $_POST['instructor_id']; $prev_instructor_id = $_POST['prev_instructor_id']; $hour_id = $_POST['hour_id']; $hour_create_type = $_POST['hour_create_type']; $clicked_create_type = $_POST['clicked_create_type']; $date = $_POST['date']; if ($hour_create_type == "Date") { Dispatcher::$mysqli->query("update instructor_has_hours set " . "instructor_id={$instructor_id} where " . "instructor_id={$prev_instructor_id} and hours_id={$hour_id}"); } else { if ($hour_create_type == "Default") { $cursor = Dispatcher::$mysqli->query("select * from custom_intsructor where " . "create_type='Default' and date='{$date}' and hours_id={$hour_id} and instructor_id={$prev_instructor_id}"); if ($cursor->num_rows > 0) { Dispatcher::$mysqli->query("update custom_intsructor set " . "instructor_id={$instructor_id} where " . "instructor_id={$prev_instructor_id} " . "and hours_id={$hour_id} and create_type='Default' and date='{$date}'"); } else { Dispatcher::$mysqli->query("insert into custom_intsructor(instructor_id, hours_id, create_type, date) " . "values ({$instructor_id}, {$hour_id}, 'Default', '{$date}')"); } print_r(Dispatcher::$mysqli->error); } else { if ($hour_create_type == "Weekday") { echo '<br><br>' . $date . " " . $hour_id . " " . $prev_instructor_id . " in dateHours<br><br>"; $cursor = Dispatcher::$mysqli->query("select * from custom_intsructor where " . "date='{$date}' and hours_id={$hour_id} and instructor_id={$prev_instructor_id}"); if ($cursor->num_rows > 0) { Dispatcher::$mysqli->query("update custom_intsructor set " . "instructor_id={$instructor_id} where " . "instructor_id={$prev_instructor_id} " . "and hours_id={$hour_id} and date='{$date}'"); } else { Dispatcher::$mysqli->query("insert into custom_intsructor(instructor_id, hours_id, create_type, date) " . "values ({$instructor_id}, {$hour_id}, '', '{$date}')"); } } } } print_r(Dispatcher::$mysqli->error); $hoursInfo = HoursController::getHoursById($hour_id); $instructorInfo = instructorController::getInstructorByID($instructor_id); $prevInsrtuctorInfo = instructorController::getInstructorByID($prev_instructor_id); $reservationsInfo = reservationController::getResevationsByDateHour($date, $hoursInfo); $calendarEventController = new InstructorCalendarEvents(); $calendarEventController->addInstructorCalendarEvent($reservationsInfo, $instructorInfo, $prevInsrtuctorInfo, $hoursInfo); }
static function booking_deleteClientHoursReservation() { $hours_id = $_POST['hours_id']; $date = $_POST['date']; $instructorCursor = Dispatcher::$mysqli->query("select instructor.calendar_id " . "from instructor join instructor_has_hours " . "on instructor.`Person_id`=instructor_has_hours.instructor_id " . "where instructor_has_hours.hours_id={$hours_id}"); $instructorRow = $instructorCursor->fetch_assoc(); $calendarEventsController = new InstructorCalendarEvents(); $calendarEventsController->deleteCalendarEvent($hours_id, $instructorRow, $date); }
HoursController::remove_hours(); } if ($action == 'edit_hours') { HoursController::edit_hours(); } if ($action == 'change_hour_state') { HoursController::change_hour_state(); } if ($action == 'booking_get_instructors_list_for_clndr_render') { echo json_encode(instructorController::getInstructors()); } if ($action == 'get_reservations_for_booking_calendar') { CalendarController::booking_get_reservations(); } if ($action == 'sync_google_clndr') { $calController = new InstructorCalendarEvents(); $calController->syncGoogleClndr(); } if ($action == 'get_reservations_for_booking_calendar_by_dayhours') { clientsTable(CalendarController::getDateHoursReservations()); } if ($action == 'booking_add_instructor') { instructorController::addInstructor(); } if ($action == 'booking_edit_instructor') { instructorController::editInstructor(); } if ($action == 'booking_remove_instructor') { instructorController::removeInstructor(); } if ($action == 'booking_change_instructor') {
static function changeInstructor() { $instructor_id = $_POST['instructor_id']; $prev_instructor_id = $_POST['prev_instructor_id']; $hour_id = $_POST['hour_id']; $hour_create_type = $_POST['hour_create_type']; $clicked_create_type = $_POST['clicked_create_type']; $weekday = $_POST['weekday']; $modul = $_POST['modul']; if ($clicked_create_type == $hour_create_type) { Dispatcher::$mysqli->query("update instructor_has_hours set " . "instructor_id={$instructor_id} where " . "instructor_id={$prev_instructor_id} and hours_id={$hour_id}"); } if ($clicked_create_type == "Default") { $cursor = Dispatcher::$mysqli->query("select * from custom_intsructor where " . "weekday='{$weekday}' and hours_id={$hour_id} and instructor_id={$prev_instructor_id}"); if ($cursor->num_rows > 0) { Dispatcher::$mysqli->query("update custom_intsructor set " . "instructor_id={$instructor_id} where " . "instructor_id={$prev_instructor_id} and hours_id={$hour_id}"); } else { Dispatcher::$mysqli->query("insert into custom_intsructor(instructor_id, hours_id, weekday) " . "values ({$instructor_id}, {$hour_id}, '{$weekday}')"); } print_r(Dispatcher::$mysqli->error); } $weekdayDates = $_POST['weekdayDates']; $hoursInfo = HoursController::getHoursById($hour_id); $instructorInfo = instructorController::getInstructorByID($instructor_id); $previnstructorInfo = instructorController::getInstructorByID($prev_instructor_id); for ($i = 0; $i < count($weekdayDates); $i++) { // $_POST['date'] = $weekdayDates[$i]; $reservationsInfo = reservationController::getResevationsByDateHour($weekdayDates[$i], $hoursInfo); // MainController::printArray($reservationsInfo); $calendarEventController = new InstructorCalendarEvents(); $calendarEventController->addInstructorCalendarEvent($reservationsInfo, $instructorInfo, $previnstructorInfo, $hoursInfo); } print_r(Dispatcher::$mysqli->error); }