Example #1
0
        //			header('Location: ' . BASE_URL . "error-403");
        //			exit();
        //		}
        //
        //		$students = Appointment::getAllStudentsWithAppointment( $appointmentId);
        //		$course = Course::get( $students[0][AppointmentFetcher::DB_COLUMN_COURSE_ID]);
        //		$term = TermFetcher::retrieveSingle( $students[0][AppointmentFetcher::DB_COLUMN_TERM_ID]);
        //
        //		$tutorName = $students[0][UserFetcher::DB_TABLE . "_" . UserFetcher::DB_COLUMN_FIRST_NAME] . " " .
        //			$students[0][UserFetcher::DB_TABLE . "_" . UserFetcher::DB_COLUMN_LAST_NAME];
        //		$startTime = $students[0][AppointmentFetcher::DB_COLUMN_START_TIME];
        //		$endTime = $students[0][AppointmentFetcher::DB_COLUMN_END_TIME];
    } else {
        if (isUrlRequestingAllAppointments()) {
            $pageTitle = "All appointments";
            $terms = TermFetcher::retrieveCurrTerm();
            if ($user->isTutor()) {
                $pageTitle = "All my appointments";
                $requestedTutorId = $user->getId();
            } else {
                $requestedTutorName = $user->getFirstName() . " " . $user->getLastName();
                $requestedTutorId = $user->getId();
            }
        } else {
            header('Location: ' . BASE_URL . "error-403");
            exit;
        }
    }
} catch (Exception $e) {
    $errors[] = $e->getMessage();
}
Example #2
0
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * 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;
Example #3
0
 /**
  * @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);
 }
$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, ", ");
}
function getInstructorNames($instructors, $appointmentId)
{
    $instructorNames = "";
    foreach ($instructors as $instructor) {
        if (strcmp($instructor[AppointmentHasStudentFetcher::DB_COLUMN_APPOINTMENT_ID], $appointmentId) === 0) {
Example #5
0
 public static function validateId($id)
 {
     if (!preg_match('/^[0-9]+$/', $id) || !TermFetcher::idExists($id)) {
         throw new Exception("Data tempering detected.\n\t\t\t<br/>You&#39;re trying to hack this app.<br/>Developers are being notified about this.<br/>Expect Us.");
     }
 }