public static function delete($appointmentId) { try { $dbConnection = DatabaseManager::getConnection(); try { $dbConnection->beginTransaction(); $prevTransFromParent = false; } catch (PDOException $e) { $prevTransFromParent = true; } ReportFetcher::deleteWithAppointmentId($appointmentId); AppointmentHasStudentFetcher::delete($appointmentId); $query = "DELETE FROM `" . App::getDbName() . "`.`" . self::DB_TABLE . "`\n\t\t\t\tWHERE `" . self::DB_TABLE . "`.`" . self::DB_COLUMN_ID . "` = :appointment_id"; $query = $dbConnection->prepare($query); $query->bindParam(':appointment_id', $appointmentId, PDO::PARAM_INT); $query->execute(); if (!$prevTransFromParent) { $dbConnection->commit(); } return $query->rowCount(); } catch (Exception $e) { if (isset($dbConnection)) { $dbConnection->rollback(); } Mailer::sendDevelopers($e->getMessage(), __FILE__); throw new Exception("Could not delete appointment data." . $e->getMessage()); } return false; }
public static function deleteWithAppointmentId($appointmentId) { try { $reports = ReportFetcher::retrieveAllWithAppointmentId($appointmentId); $dbConnection = DatabaseManager::getConnection(); try { $dbConnection->beginTransaction(); $prevTransFromParent = false; } catch (PDOException $e) { $prevTransFromParent = true; } foreach ($reports as $report) { $reportId = $report[self::DB_COLUMN_ID]; ConclusionWrapUpFetcher::delete($reportId); StudentBroughtAlongFetcher::delete($reportId); PrimaryFocusOfConferenceFetcher::delete($reportId); AppointmentHasStudentFetcher::disconnectReport($reportId); self::delete($reportId); } AppointmentFetcher::updateLabel($appointmentId, Appointment::LABEL_MESSAGE_ADMIN_DISABLED, Appointment::LABEL_COLOR_CANCELED); if (!$prevTransFromParent) { $dbConnection->commit(); } return true; } catch (Exception $e) { if (isset($dbConnection)) { $dbConnection->rollback(); } throw new Exception($e->getMessage()); } return false; }
<?php /** * Created by PhpStorm. * User: rdok * Date: 10/15/2014 * Time: 10:52 PM */ require __DIR__ . '/../app/init.php'; $reports = ReportFetcher::retrieveAll(); foreach ($reports as $report) { $reportId = $report[ReportFetcher::DB_COLUMN_ID]; if (!StudentBroughtAlongFetcher::exists($reportId)) { StudentBroughtAlongFetcher::insert($reportId); } if (!PrimaryFocusOfConferenceFetcher::exists($reportId)) { PrimaryFocusOfConferenceFetcher::insert($reportId); } if (!ConclusionWrapUpFetcher::exists($reportId)) { ConclusionWrapUpFetcher::insert($reportId); } }
*/ require __DIR__ . '/app/init.php'; $general->loggedOutProtect(); $user->allowDoctorKatsas(); $section = "appointments-terms"; $pageTitle = "All Tutors"; if (empty($_GET['term-id'])) { $appointments = AppointmentFetcher::retrieveForCurrentTerms(); $allReports = ReportFetcher::retrieveAllOfCurrTerms(); $students = AppointmentHasStudentFetcher::retrieveAllOnCurTerm(); $instructors = AppointmentHasStudentFetcher::retrieveInstructorsOnCurTerm(); $termTitle = 'current terms'; } else { $termId = $_GET['term-id']; $appointments = AppointmentFetcher::retrieveForTerm($termId); $allReports = ReportFetcher::findWithTermId($termId); $students = AppointmentHasStudentFetcher::retrieveForTerm($termId); $instructors = AppointmentHasStudentFetcher::retrieveInstructorsForTerm($termId); $termTitle = $appointments[0][TermFetcher::DB_TABLE . "_" . TermFetcher::DB_COLUMN_NAME]; } $terms = TermFetcher::retrieveAll(); function getStudentsIds($students, $appointmentId) { $studentsIds = ""; foreach ($students as $student) { if (strcmp($student[AppointmentHasStudentFetcher::DB_COLUMN_APPOINTMENT_ID], $appointmentId) === 0) { $studentsIds = $student[StudentFetcher::DB_COLUMN_STUDENT_ID] . ", " . $studentsIds; } } return rtrim($studentsIds, ", "); }
ReportFetcher::updateLabel($formReportId, Report::LABEL_MESSAGE_PENDING_VALIDATION, Report::LABEL_COLOR_WARNING); } else { // user is secretary confirming report ReportFetcher::updateLabel($formReportId, Report::LABEL_MESSAGE_COMPLETE, Report::LABEL_COLOR_SUCCESS); } } if (!$updateDone) { throw new Exception("No new data inserted."); } } if (isUrlRqstngManualReportEnable()) { if ($studentsAppointmentData[0][AppointmentHasStudentFetcher::DB_COLUMN_REPORT_ID] === null && $nowDateTime > $startDateTime) { $students = AppointmentHasStudentFetcher::retrieveStudentsWithAppointment($appointmentId); $appointment = Appointment::getSingle($appointmentId); foreach ($students as $student) { $reportId = ReportFetcher::insert($student[AppointmentHasStudentFetcher::DB_COLUMN_STUDENT_ID], $student[AppointmentHasStudentFetcher::DB_COLUMN_ID], $student[AppointmentHasStudentFetcher::DB_COLUMN_INSTRUCTOR_ID]); } AppointmentFetcher::updateLabel($appointmentId, Appointment::LABEL_MESSAGE_COMPLETE, Appointment::LABEL_COLOR_SUCCESS); if (!$user->isTutor()) { Mailer::sendTutorNewReportsCronOnly($appointment); } } } else { if (isUrlRqstngAppointmentCancelByStudent()) { AppointmentFetcher::updateLabel($appointmentId, Appointment::LABEL_MESSAGE_STUDENT_CANCELED, Appointment::LABEL_COLOR_CANCELED); } else { if (isBtnUpdateAppointmentPrsd() && ($user->isSecretary() && strcmp($studentsAppointmentData[0][AppointmentFetcher::DB_COLUMN_LABEL_MESSAGE], Appointment::LABEL_MESSAGE_COMPLETE) !== 0 || $user->isAdmin())) { $updateDone = Appointment::updateStudents($appointmentId, $studentsAppointmentData, $_POST['studentsIds']); $updateDone = Appointment::updateInstructors($appointmentId, $studentsAppointmentData, $_POST['instructorIds']) || $updateDone; $updateDone = Appointment::updateCourse($appointmentId, $studentsAppointmentData[0][AppointmentFetcher::DB_COLUMN_COURSE_ID], $_POST['courseId']) || $updateDone; // TODO: validate new date times.
$general->loggedOutProtect(); $section = "appointments"; if (isset($_SESSION['success'])) { $successMessage[] = $_SESSION['success']; unset($_SESSION['success']); } if ($user->isTutor()) { $pageTitle = "" . $user->getFirstName() . " " . $user->getLastName(); $appointments = AppointmentFetcher::retrieveAllOfCurrTermsByTutor($user->getId()); $allReports = ReportFetcher::retrieveAllOfCurrTermsByTutor($user->getId()); // TODO: add sepearate retrieval function for tutor. currently retrieves all students \/ $students = AppointmentHasStudentFetcher::retrieveAllOnCurTerm(); } else { $pageTitle = "All Tutors"; $appointments = AppointmentFetcher::retrieveAllOfCurrTerms(); $allReports = ReportFetcher::retrieveAllOfCurrTerms(); $students = AppointmentHasStudentFetcher::retrieveAllOnCurTerm(); } function getStudentsIds($students, $appointmentId) { $studentsIds = ""; foreach ($students as $student) { if (strcmp($student[AppointmentHasStudentFetcher::DB_COLUMN_APPOINTMENT_ID], $appointmentId) === 0) { $studentsIds = $student[StudentFetcher::DB_COLUMN_STUDENT_ID] . ", " . $studentsIds; } } return rtrim($studentsIds, ", "); } function requestRequiresPendingAppointmentsAndReports() { if (!isset($_GET['appointments']) || !isset($_GET['reports'])) {
public static function updateAllFields($reportId, $projectTopicOtherNew, $otherTextArea, $studentsConcernsTextArea, $relevantFeedbackGuidelines, $studentBroughtAlongNew, $studentBroughtAlongOld, $conclusionAdditionalComments, $primaryFocusOfConferenceNew, $primaryFocusOfConferenceOld, $conclusionWrapUpNew, $conclusionWrapUpOld) { self::validateId($reportId); self::validateTextArea($projectTopicOtherNew, false); self::validateTextArea($otherTextArea, true); self::validateTextArea($studentsConcernsTextArea, false); self::validateTextArea($relevantFeedbackGuidelines, true); self::validateOptionsStudentBroughtAlong($studentBroughtAlongNew); self::validateOptionsPrimaryFocusOfConference($primaryFocusOfConferenceNew); self::validateOptionsConclusionWrapUp($conclusionWrapUpNew); self::validateTextArea($conclusionAdditionalComments, true); return ReportFetcher::updateAllColumns($reportId, $projectTopicOtherNew, $otherTextArea, $studentsConcernsTextArea, $relevantFeedbackGuidelines, $studentBroughtAlongNew, $studentBroughtAlongOld, $conclusionAdditionalComments, $primaryFocusOfConferenceNew, $primaryFocusOfConferenceOld, $conclusionWrapUpNew, $conclusionWrapUpOld); }
/** * Notify tutors with pending appointments and or reports. */ require __DIR__ . "/../public_html/app/config/app.php"; // run script only during working hours //if (!App::isWorkingDateTimeOn()) //{ // exit(); //} $pendingAppointments = AppointmentFetcher::retrieveCmpltWithoutRptsOnCurTerms(); // retrieve all tutors // foreach tutor store his/her pending appointments // foreach tutor store his/her pending report $tutors = TutorFetcher::retrieveActive(); foreach ($tutors as $tutor) { try { $pendingAppointments = AppointmentFetcher::retrievePendingForCurrentTerms($tutor[TutorFetcher::DB_COLUMN_USER_ID]); $pendingReports = ReportFetcher::retrievePendingForCurrentTerms($tutor[TutorFetcher::DB_COLUMN_USER_ID]); $existPendingAppointments = !empty($pendingAppointments); $existsPendingReports = !empty($pendingReports); if ($existPendingAppointments || $existsPendingReports) { $buttonsPending[App::APPOINTMENT_BTN_URL] = $existPendingAppointments ? App::getAppointmentsListUrl() : $existPendingAppointments; $buttonsPending[App::REPORT_BTN_URL] = $existsPendingReports ? App::getReportsListUrl() : $existsPendingReports; $fullName = $tutor[UserFetcher::DB_COLUMN_FIRST_NAME] . " " . $tutor[UserFetcher::DB_COLUMN_LAST_NAME]; Mailer::sendPending($buttonsPending, $tutor[TutorFetcher::DB_COLUMN_USER_ID], $tutor[UserFetcher::DB_COLUMN_EMAIL], $fullName); } } catch (Exception $e) { var_dump($e->getMessage()); } } // end foreach