Ejemplo n.º 1
0
try {
    if (isset($_GET['termIds'])) {
        $termIds = explode(',', $_GET['termIds']);
        $currentTerms = TermFetcher::whereIdIn($termIds);
    } 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) {