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; }
* @since 25/4/2015 */ 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, ", ");
/** * @param $termId * @return array * @throws Exception * @throws PHPExcel_Exception */ private static function exportAppointments($termId) { Term::validateId($termId); require_once ROOT_PATH . 'plugins/PHPExcel_1.8.0_doc/Classes/PHPExcel.php'; date_default_timezone_set('Europe/Athens'); $allAppointments = AppointmentFetcher::retrieveForTerm($termId); $appointmentsHaveStudents = AppointmentHasStudentFetcher::retrieveForTerm($termId); $primaryFocusOfConferences = PrimaryFocusOfConferenceFetcher::retrieveForTerm($termId); $termData = TermFetcher::retrieveSingle($termId); $termStart = new DateTime($termData[TermFetcher::DB_COLUMN_START_DATE]); $termEnd = new DateTime($termData[TermFetcher::DB_COLUMN_END_DATE]); $termName = $termData[TermFetcher::DB_COLUMN_NAME]; $objPHPExcel = new PHPExcel(); $objPHPExcel->getProperties()->setCreator(App::getName())->setLastModifiedBy(App::getName())->setTitle(self::TITLE_VISIT_LOG . " - " . $termName)->setSubject("Appointments")->setDescription("List of appointments for {$termName}.")->setKeywords("office sass appointments php")->setCategory("Appointments"); $sheetIndex = 0; for ($workingDateTime = $termStart; $workingDateTime <= $termEnd; $workingDateTime->modify('+1 week')) { $curWeek = $workingDateTime->format('W'); $appointmentsWeekly = self::getAppointments($allAppointments, $curWeek); $startWeekDate = self::getWorkingDates($workingDateTime->format('Y'), $workingDateTime->format('W')); $endWeekDate = self::getWorkingDates($workingDateTime->format('Y'), $workingDateTime->format('W'), false); $periodTime = date("d M", strtotime($startWeekDate)) . "-" . date("d M, o", strtotime('-1 day', strtotime($endWeekDate))); $objPHPExcel->createSheet($sheetIndex); $objPHPExcel->setActiveSheetIndex($sheetIndex)->setCellValue('A1', 'Day')->setCellValue('B1', 'Date')->setCellValue('C1', 'Month')->setCellValue('D1', 'Year')->setCellValue('E1', 'Time')->setCellValue('F1', 'LF Lname')->setCellValue('G1', 'Stud Lname')->setCellValue('H1', 'Stud Fname')->setCellValue('I1', 'Stud ID')->setCellValue('J1', 'Major')->setCellValue('K1', 'Mobile')->setCellValue('L1', 'e-mail')->setCellValue('M1', 'Course Code')->setCellValue('N1', 'Course Instructor')->setCellValue('O1', '# of Students')->setCellValue('P1', 'Outcome')->setCellValue('Q1', 'Actual Duration')->setCellValue('R1', 'Purpose'); $sheetIndex++; $objPHPExcel->getActiveSheet()->getStyle('A1:R1')->applyFromArray(self::$styleVisitLogHeader); $objPHPExcel->getActiveSheet()->getRowDimension('1')->setRowHeight(24); $objPHPExcel->getActiveSheet()->setTitle($periodTime); $row = 2; foreach ($appointmentsWeekly as $appointment) { $appointmentStartDateTime = new DateTime($appointment[AppointmentFetcher::DB_COLUMN_START_TIME]); $appointmentEndDateTime = new DateTime($appointment[AppointmentFetcher::DB_COLUMN_END_TIME]); $appointmentId = $appointment[AppointmentFetcher::DB_COLUMN_ID]; $students = self::getStudentsForAppointment($appointmentsHaveStudents, $appointmentId); $numOfStudents = sizeof($students); // TODO: REMOVE autosize from loop $col = 0; // day $day = $appointmentStartDateTime->format('l'); $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col, $row, $day); $col++; // date $date = $appointmentStartDateTime->format('d'); $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col, $row, $date); $col++; // month $month = $appointmentStartDateTime->format('M'); $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col, $row, $month); $col++; // year $year = $appointmentStartDateTime->format('Y'); $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col, $row, $year); $col++; // time $time = $appointmentStartDateTime->format('H:i'); $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col, $row, $time); $col++; // tutor last name $tutorLastName = $appointment[UserFetcher::DB_COLUMN_LAST_NAME]; $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col, $row, $tutorLastName); // TODO: add student that first requested the appointment. $col++; // student last name $studentLastName = $students[0][StudentFetcher::DB_COLUMN_LAST_NAME]; $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col, $row, $studentLastName); $col++; // student first name $studentFirstName = $students[0][StudentFetcher::DB_COLUMN_FIRST_NAME]; $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col, $row, $studentFirstName); $col++; // student ID $studentId = $students[0][StudentFetcher::DB_COLUMN_STUDENT_ID]; $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col, $row, $studentId); $col++; // student major $majorCode = $students[0][MajorFetcher::DB_COLUMN_CODE]; $objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($col, $row, $majorCode); $col++; // student mobile $mobile = $students[0][StudentFetcher::DB_COLUMN_MOBILE]; $objPHPExcel->getActiveSheet()->setCellValueExplicitByColumnAndRow($col, $row, $mobile); $col++; // student email $email = $students[0][StudentFetcher::DB_COLUMN_EMAIL]; $objPHPExcel->getActiveSheet()->setCellValueExplicitByColumnAndRow($col, $row, $email); $col++; // course code $courseCode = $appointment[CourseFetcher::DB_COLUMN_CODE]; $objPHPExcel->getActiveSheet()->setCellValueExplicitByColumnAndRow($col, $row, $courseCode); $col++; // instructor for first student $instructorLastName = $students[0][InstructorFetcher::DB_COLUMN_LAST_NAME]; $objPHPExcel->getActiveSheet()->setCellValueExplicitByColumnAndRow($col, $row, $instructorLastName); $col++; // instructor for first student $objPHPExcel->getActiveSheet()->setCellValueExplicitByColumnAndRow($col, $row, $numOfStudents); $col++; // appointment outcome $appointmentOutcome = $appointment[AppointmentFetcher::DB_COLUMN_LABEL_MESSAGE]; $objPHPExcel->getActiveSheet()->setCellValueExplicitByColumnAndRow($col, $row, $appointmentOutcome); $col++; // appointment duration $appointmentDuration = ($appointmentEndDateTime->getTimestamp() - $appointmentStartDateTime->getTimestamp()) / 60; $objPHPExcel->getActiveSheet()->setCellValueExplicitByColumnAndRow($col, $row, $appointmentDuration); $col++; // purpose $primaryFocusOfConferencesString = self::getFocusOfConferencesForAppointment($primaryFocusOfConferences, $appointmentId); if (!empty($primaryFocusOfConferencesString)) { $primaryFocusOfConferencesString = Report::convertFocusOfConferenceToString($primaryFocusOfConferencesString[0]); $objPHPExcel->getActiveSheet()->setCellValueExplicitByColumnAndRow($col, $row, $primaryFocusOfConferencesString); //$objPHPExcel->getActiveSheet()->getColumnDimensionByColumn($col)->setAutoSize(true); } switch ($appointment[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; } $styleRow = array('font' => array('bold' => false, 'name' => 'Times New Roman', 'size' => 12), 'alignment' => array('horizontal' => PHPExcel_Style_Alignment::HORIZONTAL_LEFT), 'borders' => array('bottom' => array('style' => PHPExcel_Style_Border::BORDER_THIN), 'right' => array('style' => PHPExcel_Style_Border::BORDER_MEDIUM)), 'fill' => array('type' => PHPExcel_Style_Fill::FILL_GRADIENT_LINEAR, 'rotation' => 90, 'startcolor' => array('argb' => $color), 'endcolor' => array('argb' => $color))); $objPHPExcel->getActiveSheet()->getStyle("A{$row}:R{$row}")->applyFromArray($styleRow); $row++; } // end foreach // enable all filters $objPHPExcel->getActiveSheet()->setAutoFilter($objPHPExcel->getActiveSheet()->calculateWorksheetDimension()); // source: http://stackoverflow.com/a/5578240 - autosize all columns $lastColumn = $objPHPExcel->getActiveSheet()->getHighestColumn(); $lastColumn++; for ($column = 'A'; $column != $lastColumn; $column++) { $objPHPExcel->getActiveSheet()->getColumnDimension($column)->setAutoSize(true); } // end for } // end foreach // Set active sheet index to the first sheet, so Excel opens this as the first sheet $objPHPExcel->setActiveSheetIndex(0); return array($termName, $objPHPExcel); }
} else { $currentTerms = TermFetcher::retrieveCurrTerm(); } $allTerms = TermFetcher::retrieveAll(); $currentTermIds = array_column($currentTerms, 'id'); $now = new DateTime($currentTerms[0]['start_date']); $end = new DateTime($currentTerms[0]['end_date']); $nowString = $currentTerms[0]['start_date']; $endString = $currentTerms[0]['end_date']; $totalAppointments = AppointmentFetcher::countForTermIds($currentTermIds); $achievedAppointments = AppointmentFetcher::countForTermids($currentTermIds, ['complete']); $canceledAppointments = AppointmentFetcher::countForTermids($currentTermIds, ['canceled by student', 'disabled by admin', 'canceled by tutor']); $hourlyAppointments = AppointmentFetcher::retrieveByGroupedDateForTermIds($currentTermIds, ['hour']); $dailyAppointments = AppointmentFetcher::retrieveByGroupedDateForTermIds($currentTermIds, ['date']); $monthlyAppointments = AppointmentFetcher::retrieveByGroupedDateForTermIds($currentTermIds, ['month']); $yearlyAppointments = AppointmentFetcher::retrieveByGroupedDateForTermIds($currentTermIds, ['year']); foreach ($hourlyAppointments as $appointment) { $date = date("H:i", strtotime($appointment['date'])); $hourlyAppointmentsJson[] = ['period' => $date, 'total' => $appointment['total']]; } $hourlyAppointmentsJson = json_encode($hourlyAppointmentsJson); foreach ($dailyAppointments as $appointment) { $date = date("Y-m-d", strtotime($appointment['date'])); $dailyAppointmentsJson[] = ['period' => $date, 'total' => $appointment['total']]; } $dailyAppointmentsJson = json_encode($dailyAppointmentsJson); foreach ($monthlyAppointments as $appointment) { $date = date("F", strtotime($appointment['date'])); $monthlyAppointmentsJson[] = ['period' => $date, 'total' => $appointment['total']]; } $monthlyAppointmentsJson = json_encode($monthlyAppointmentsJson);
function isUrlValid() { return isset($_GET['appointmentId']) && preg_match("/^[0-9]+\$/", $_GET['appointmentId']) && AppointmentFetcher::existsId($_GET['appointmentId']); }
public static function sendTutorNewAppointment($tutorId, $secretaryName) { require_once ROOT_PATH . "plugins/PHPMailer/PHPMailerAutoload.php"; try { $appointment = AppointmentFetcher::retrieveSingle($tutorId); $appointmentStart = new DateTime($appointment[AppointmentFetcher::DB_COLUMN_START_TIME]); $appointmentEnd = new DateTime($appointment[AppointmentFetcher::DB_COLUMN_END_TIME]); $tutorUser = UserFetcher::retrieveSingle($appointment[AppointmentFetcher::DB_COLUMN_TUTOR_USER_ID]); $course = CourseFetcher::retrieveSingle($appointment[AppointmentFetcher::DB_COLUMN_COURSE_ID]); $subject = self::SUBJECT_PREFIX . self::SUBJECT_NEW_SASS_APP_APPOINTMENT; $alternativeEmail = self::EMAIL_DEV_SASS; $alternativeName = self::SASS_APP_AUTOMATIC_SYSTEM_DEVELOPERS; $setViewScheduleLink = "<a style='background-color:#008dd0;color:#fff;border-radius:4px;display:block;\n\t\ttext-decoration:none;margin-top:30px;margin-bottom:15px;margin-right:0px;margin-left:0px;padding-top:20px;\n\t\tpadding-bottom:20px;padding-right:20px;padding-left:20px;text-align:center'\n\t\thref='" . App::getDomainName() . "/appointments/" . $appointment[AppointmentFetcher::DB_COLUMN_ID] . "' target='_blank' >Appointment Details</a>"; $senderEmail = self::NO_REPLY_EMAIL_PREFIX . $_SERVER['SERVER_NAME']; $senderName = $secretaryName; $receiverEmail = $tutorUser[UserFetcher::DB_COLUMN_EMAIL]; $receiverName = $tutorUser[UserFetcher::DB_COLUMN_FIRST_NAME] . " " . $tutorUser[UserFetcher::DB_COLUMN_LAST_NAME]; //Create a new PHPMailer instance $mail = new PHPMailer(); // Set PHPMailer to use the sendmail transport //Set who the message is to be sent from $mail->setFrom($senderEmail, self::SASS_APP_AUTOMATIC_SYSTEM); //Set an alternative reply-to address $mail->addReplyTo($alternativeEmail, $alternativeName); //Set who the message is to be sent to $mail->addAddress($receiverEmail, $receiverName); //Set the subject line $mail->Subject = $subject; $message = "<html><div bgcolor='#fafafa' marginheight='0' marginwidth='0' style='width:100%!important;background:#fafafa'>"; $message .= "<div style='padding:20px 20px 20px 20px!important;width:550px;margin:0 auto'>"; $message .= "<h1 style='margin:0;font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;font-size:40px;letter-spacing:-1px;color:#333;font-weight:normal'>\n\t\t\t\t\tNew Appointment from SASS App</h1>"; $message .= "<span style='margin:0 0 30px 0;font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;font-size:17px;font-weight:300;color:#555'>\n\t\t\t\t\tWe have a new appointment for you, <strong>{$receiverName}</strong></span>."; $message .= "<div style='margin:20px auto!important;width:510px;padding:20px 20px 20px 20px!important;border:1px solid #ddd!important;border-radius:3px!important;background:#ffffff!important'>"; $message .= "<p style='margin:5px 0 15px 0;font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;font-size:14px;font-weight:normal;color:#333;line-height:20px'>\n\t\t\t\t\tHere is an overview the appointment"; $message .= "<br/><strong>Course:</strong> " . $course[CourseFetcher::DB_COLUMN_CODE] . " " . $course[CourseFetcher::DB_COLUMN_NAME]; $message .= "<br/><strong>Date:</strong> " . $appointmentStart->format(self::DATE_FORMAT); $message .= "<br/><strong>Hour:</strong> " . $appointmentStart->format(self::HOUR_FORMAT) . " - " . $appointmentEnd->format(self::HOUR_FORMAT) . "</p>"; $message .= "<p style='margin:0 0 30px 0;font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;font-size:17px;font-weight:300;color:#555'>\n\t\t\t\t\t\t\tFor more details you can visit your {$setViewScheduleLink}</p>"; $message .= "<div style='margin:20px 0;border-top:1px solid #ddd'></div>"; $message .= "<p style='margin:0 0 30px 0;font-family:'Helvetica Neue',Helvetica,Arial,sans-serif;font-size:17px;font-weight:300;color:#555'>Thanks,<br/><strong>{$senderName}</strong></p>"; $message .= "</div>"; $message .= "<div style='margin:20px 0;text-align:center;'>"; $message .= '<img alt="SASS logo" height="40" width="40" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAYAAACM/rhtAAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAC4jAAAuIwF4pT92AAAAB3RJTUUH3gkOEB4GKCv7JwAABOFJREFUWMPt1n+slmUZB/DP9TznvICkiDCcJChUDAMpkR+OR0dkLp0zZz+mbG2t1tYmzZrzZenGakVbnbdcVrjStpxlODVsrTbWahqDR63FiElqwBbNQeuHghyB877nee/+OI9wfDnoH/1D2/v969lzf+/7vq7vfV3f+6aPPvroo48+/hfEGx+NaM6WXIkrgnMTf8VTif0drTTR5NyiBZkVM8PsZ9u+3p2I09CcimV4Hy7BIfwRO9paozUnq8ffj8sSx4Ldwm8zmBTNZZJ7ExdnWfb9rvQErsPPSFPOkNyspP1DptxPTJ6IMBjNGdiYuEnEr0XcR0zD47iwDm4SvoDbE/tSpG8Gf8NX8ZmBhub5KdmIb3S0nu6M6fBcQ/N2YihOidyLT5IvDO+oaM/AsR7lMskdGO5obXDqDDYMas7l5J8PYmUKn+2k1nD996GG5gnJ9AyXI8eLPQd4WKQXRJrg6LKLcGeY9hD5SJKu6GUkzsUabJugrp4NRhqxflDEtXg+Jcd75pc4lGE6BhJTxxO6RqvIPRC5kQnU+xKOZN77S6pXahV6w5iamFWv/+bgIzaniMNSyqW0ANOCwZ4sDqbcbzIcwcLg5lxz4I3xUd9KI6OtIyOjvQ2SLcEdxGMdP36GdCBYfLpK6VhwAjcOal48fqyThg530lCFyli9XRNjDTKO0xrtVK1jea44imtwXca8XLG3Ur76Fo3/PZxPWofXcsUKLM0Higeqbtk91eFFe4xnbbA4U7zeVe4dv1Kl7I7xYi1WZopGmlzsMlqeFCWvlMdzq0piFa7Ch3PFJXmjeK6qyk6PetfjHtIf8IM6kPlYpesXlfLIuM1TrtiVOCe4MVieK1bnihcq5b9P5bv6QKZ7CB8LluSjbsoVr1TKfermUClfrZQ/zRXT8W5cpbImj2LH+E2JLxPLctfe0/ApueUX4p11Yvsq5Z4ehdpd5VOZ4sX6CBfg45ni75PyYt9oKiXbU6XcE1nxRCQrMBe35ooqU+zMexb8/WBWPJmShbgScwes2lopuyJbQncDMw4Oum0geW1NiKJecEZiele55TQv1IyO1t5K+ZNM0QgWBDenFE9Wdhw92ZSpPFopH8sVe7AIt2BvnMH9J+Mr+LyIy9tp6ADZ3dhI3EC1tYe/DVPaWsvf7upqaN5am/eDHa2hM3CWYgjHs4bmh3oJba0TtX+N4BxMG6s9v6L7zAQX5jY0GtZffUq59fMHrV85gT/+CS+HmNfwxWhorp1g/504kMR5WWL1GZJNieFIi/aT3VAH+ijpyOlMm9EgrRxnM/NDWnh6LlFhirCZwQsm9tCxjgxpdxZi9oDme95UN1mzgdUR8e22uxt4BH/G0xOtNMpLxjxv+aC7Lqhvi/PqB0BPLmkp/hUp7RxLypyBcf5bH/EizMGmaMT6R6T0LnynNs2ZxC2kfzSs2zhs3qeJTVhH9/63qK3P4WvYjt2JS4Or8SCxnTRQX31zsKmttbOheRGex6OJLbWxL65VfRw/HyDdhQ9gaf0segn3Jp39wy49gSXYQv4jumcs/sTDwev1K2Vb8DIuG7sE0ifqZ9bvEn/paP2nnvZPXI8i+EjicLArcadG+2CnfV96m57LPkrWrbM+G5FtJfvu2frankncRjbrbA1wSt1lffTRRx999PF/jP8CuIm4fhDynqkAAAAASUVORK5CYII=" />'; $message .= "</div>"; $message .= "</div>"; $message .= "</div></html>"; $email_body = $message; //Set who the message is to be sent from $mail->setFrom($senderEmail, self::SASS_APP_AUTOMATIC_SYSTEM); //Set who the message is to be sent to $mail->addAddress($receiverEmail, $receiverName); //Set the subject line $mail->Subject = $subject; //Read an HTML message body from an external file, convert referenced images to embedded, //convert HTML into a basic plain-text alternative body $mail->msgHTML($email_body); //Attach an image file //$mail->addAttachment('images/phpmailer_mini.gif'); self::safelySendMail($mail); } catch (phpmailerException $e) { throw new Exception("PHPMailer error: " . $e->errorMessage()); //Pretty error messages from PHPMailer } catch (Exception $e) { throw new Exception("Something went wrong with mail. Please re-send mail to user for setting password."); //Pretty error messages from PHPMailer } }
require __DIR__ . '/../app/init.php'; $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() {
} } } $startWeekDate = getWorkingDates($now->format('Y'), $now->format('W')); $endWeekDate = getWorkingDates($now->format('Y'), $now->format('W'), false); $courses = CourseFetcher::retrieveAll(); //TODO: do not fetch all tutors when a tutors is viewing this page. $tutors = TutorFetcher::retrieveAll(); if (!$user->isTutor()) { $appointments = AppointmentFetcher::retrieveBetweenDates($startWeekDate, $endWeekDate); $countAppointmentsForCurWeek = sizeof($appointments); $countAchievedAppointmentsForCurWeek = Appointment::countWithLabelMessage($appointments, Appointment::LABEL_MESSAGE_COMPLETE); $canceledLabelMessagesForWeek = [Appointment::LABEL_MESSAGE_STUDENT_NO_SHOW, Appointment::LABEL_MESSAGE_TUTOR_CANCELED, Appointment::LABEL_MESSAGE_TUTOR_NO_SHOW, Appointment::LABEL_MESSAGE_STUDENT_CANCELED]; $countCanceledAppointmentsForCurWeek = Appointment::countWithLabelMessages($appointments, $canceledLabelMessagesForWeek); } else { $appointments = AppointmentFetcher::retrieveTutorsBetweenDates($user->getId(), $startWeekDate, $endWeekDate); $countAppointmentsForCurWeek = sizeof($appointments); $countAchievedAppointmentsForCurWeek = Appointment::countTutorsWithLabelMessage($user->getId(), $appointments, Appointment::LABEL_MESSAGE_COMPLETE); $canceledLabelMessagesForWeek = [Appointment::LABEL_MESSAGE_STUDENT_NO_SHOW, Appointment::LABEL_MESSAGE_TUTOR_CANCELED, Appointment::LABEL_MESSAGE_TUTOR_NO_SHOW, Appointment::LABEL_MESSAGE_STUDENT_CANCELED]; $countCanceledAppointmentsForCurWeek = Appointment::countTutorsWithLabelMessageS($user->getId(), $appointments, $canceledLabelMessagesForWeek); } } catch (Exception $e) { $errors[] = $e->getMessage(); } // viewers $pageTitle = "Dashboard"; $section = "dashboard"; /** * http://stackoverflow.com/a/4128377/2790481 * * @param $findId
<?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; }
<?php require __DIR__ . '/../app/init.php'; $general->loggedOutProtect(); // redirect if user elevation is not that of secretary or admin if ($user->isTutor()) { header('Location: ' . BASE_URL . "error-403"); exit; } $pageTitle = "Academia - Students"; $section = "academia"; try { $students = StudentFetcher::retrieveAll(); $majors = MajorFetcher::retrieveMajors(); $appointments = AppointmentFetcher::retrievePendingForAllStudents(); if (isBtnAddStudentPrsd()) { $majorId = !empty($_POST['userMajorId']) ? $_POST['userMajorId'] : null; Student::create($_POST['firstName'], $_POST['lastName'], $_POST['email'], $_POST['studentId'], $_POST['mobileNum'], $majorId, $_POST['ciInput'], $_POST['creditsInput']); header('Location: ' . BASE_URL . "academia/students/success"); exit; } else { if (isBtnAddMajorPrsd()) { Major::create($_POST['majorCode'], $_POST['majorName']); header('Location: ' . BASE_URL . "academia/students/success"); } else { if (isBtnUpdatePrsd()) { if (!isset($_POST['idUpdate']) || ($oldStudentData = getStudent($_POST['idUpdate'], $students)) === false) { throw new Exception("Data tempering detected. Process stopped."); } else { $id = $oldStudentData[StudentFetcher::DB_COLUMN_ID]; $newFirstName = $_POST['newFirstName'];
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); }
/** * 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