} 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);