<?php /** * Created by PhpStorm. * User: rdok * Date: 9/18/2014 * Time: 2:35 PM */ try { require __DIR__ . "/../public_html/app/config/app.php"; date_default_timezone_set('Europe/Athens'); // run script only during working hours every two hours if (!App::isWorkingDateTimeOn()) { exit; } $appointments = AppointmentFetcher::retrieveCmpltWithoutRptsOnCurTerms(); foreach ($appointments as $appointment) { $students = AppointmentHasStudentFetcher::retrieveStudentsWithAppointment($appointment[AppointmentFetcher::DB_COLUMN_ID]); 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($appointment[AppointmentFetcher::DB_COLUMN_ID], Appointment::LABEL_MESSAGE_COMPLETE, Appointment::LABEL_COLOR_SUCCESS); // Mailer::sendTutorNewReportsCronOnly($appointment); } } catch (Exception $e) { App::storeError($e); exit; }
$updateDone = Report::updateAllFields($reportUpdate[ReportFetcher::DB_COLUMN_ID], $projectTopicOtherNew, $otherTextArea, $studentsConcernsTextArea, $relevantFeedbackGuidelines, $studentBroughtAlongNew, $studentBroughtAlongOld, $conclusionAdditionalComments, $primaryFocusOfConferenceNew, $primaryFocusOfConferenceOld, $conclusionWrapUpNew, $conclusionWrapUpOld); // user is tutor requesting fill report if ($user->isTutor()) { 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']);
public static function getAppointmentsForCourseAndTutor($tutorId, $courseId, $termId) { Tutor::validateId($tutorId); Term::validateId($termId); $appointmentHours = AppointmentFetcher::getAppointmentsForTutorAndCourse($tutorId, $courseId, $termId); $appointmentHoursJSON = []; foreach ($appointmentHours as $appointmentHour) { $appointmentTitle = $appointmentHour[CourseFetcher::DB_COLUMN_CODE] . " - " . $appointmentHour[UserFetcher::DB_COLUMN_FIRST_NAME] . " " . $appointmentHour[UserFetcher::DB_COLUMN_LAST_NAME]; $students = AppointmentHasStudentFetcher::retrieveStudentsWithAppointment($appointmentHour[AppointmentFetcher::DB_COLUMN_ID]); $appointmentTitle .= " - "; foreach ($students as $student) { $appointmentTitle .= $student[StudentFetcher::DB_TABLE . "_" . StudentFetcher::DB_COLUMN_FIRST_NAME] . " " . $student[StudentFetcher::DB_TABLE . "_" . StudentFetcher::DB_COLUMN_LAST_NAME] . ", "; } $appointmentTitle = rtrim($appointmentTitle, ", "); $startDate = new DateTime($appointmentHour[AppointmentFetcher::DB_COLUMN_START_TIME]); $endDate = new DateTime($appointmentHour[AppointmentFetcher::DB_COLUMN_END_TIME]); $appointmentUrl = App::getDomainName() . "/appointments/" . $appointmentHour[UserFetcher::DB_COLUMN_ID]; switch ($appointmentHour[AppointmentFetcher::DB_COLUMN_LABEL_COLOR]) { case Appointment::LABEL_COLOR_PENDING: $color = '#888888'; break; case Appointment::LABEL_COLOR_CANCELED: $color = '#e5412d'; break; case Appointment::LABEL_COLOR_SUCCESS: $color = '#3fa67a'; break; case Appointment::LABEL_COLOR_WARNING: $color = '#f0ad4e'; break; default: $color = '#444'; break; } $appointmentHoursJSON[] = ['title' => $appointmentTitle, 'start' => $startDate->format('Y-m-d H:i:s'), 'end' => $endDate->format('Y-m-d H:i:s'), 'allDay' => false, 'url' => $appointmentUrl, 'color' => $color]; } return json_encode($appointmentHoursJSON); }