$sql = "
SELECT *
FROM schedules
- WHERE page = :page";
+ WHERE page = :page
+ ORDER BY schedule_year";
$stmt = $this->dbh->prepare($sql);
$stmt->bindParam(':page', $pageId, PDO::PARAM_INT);
$stmt->execute();
- $scheduleData = $stmt->fetch(PDO::FETCH_ASSOC);
+ $scheduleData = $stmt->fetchAll(PDO::FETCH_ASSOC);
if (!$scheduleData) {
return false;
*/
public function toHtml($pageId)
{
+ $calendars = '';
// load ZendConfig
$this->config = new Zend_Config_Ini(
BASE . 'Toolkit/Schedule/application.ini',
$cals = new Toolkit_Schedule_Calendar();
// get the active schedule if no active schedule is found then return
// nothing
- $scheduleData = $this->hasSchedule($pageId);
- if (!$scheduleData) {
+ $scheduleDataArray = $this->hasSchedule($pageId);
+ if (!$scheduleDataArray) {
return false;
}
- $scheduleId = (string)$scheduleData['id'];
- $scheduleName = $scheduleData['name'];
- $year = $scheduleData['schedule_year'];
-
- $colors
- = ($scheduleId)
- ? $cals->getDepartureColors($scheduleId)
- : null;
$style = '';
- if ($colors) {
- foreach ($colors as $departId => $color) {
- $style .= ".depart{$departId} {background-color:{$color};}\n";
+ foreach ($scheduleDataArray as $scheduleData) {
+ $scheduleId = (string)$scheduleData['id'];
+ $scheduleName = $scheduleData['name'];
+ $year = $scheduleData['schedule_year'];
+
+ $colors
+ = ($scheduleId)
+ ? $cals->getDepartureColors($scheduleId)
+ : null;
+
+ if ($colors) {
+ foreach ($colors as $departId => $color) {
+ $style .= ".depart{$departId} {background-color:{$color};}\n";
+ }
}
- }
- $selected = $cals->getDepartureDates($scheduleId);
-// echo '<pre>'.print_r($selected, true).'</pre>';
-// exit;
- $year
- = ($year)
- ? $year
- : date('Y');
- $page = new stdClass();
- $startingMonth = $this->config->months->start;
- $endingMonth = $this->config->months->end;
- for ($i = $startingMonth; $i <= $endingMonth; ++$i) {
- if (in_array($i, $cals->months)) {
- $page->calendarsHtml .= $cals->buildCalendar($i, $year, $selected);
+ $selected = $cals->getDepartureDates($scheduleId);
+ $year
+ = ($year)
+ ? $year
+ : date('Y');
+ $page = new stdClass();
+ $startingMonth = $this->config->months->start;
+ $endingMonth = $this->config->months->end;
+ for ($i = $startingMonth; $i <= $endingMonth; ++$i) {
+ if (in_array($i, $cals->months)) {
+ $page->calendarsHtml .= $cals->buildCalendar($i, $year, $selected);
+ }
}
+ $tpl = new HTML_Template_Flexy($this->flexyOptions);
+ $page->style = $style;
+ $page->appBase = GLM_APP_BASE_URL;
+ $page->baseUrl = BASE_URL;
+ $page->scheduleId = $scheduleId;
+ $page->scheduleName = $scheduleName;
+ $page->departByDate = $this->getDeparturesForDate();
+ $ScheduleEdit = new Toolkit_Schedule_EditSchedule();
+ $page->departures = $ScheduleEdit->getDeparturesForSchedules(
+ $this,
+ $scheduleId
+ );
+ $tpl->compile('departuresScheduleCalendar.html');
+ $calendars .= $tpl->bufferedOutputObject($page);
}
- $tpl = new HTML_Template_Flexy($this->flexyOptions);
- $page->style = $style;
- $page->appBase = GLM_APP_BASE_URL;
- $page->baseUrl = BASE_URL;
- $page->scheduleId = $scheduleId;
- $page->scheduleName = $scheduleName;
- $page->departByDate = $this->getDeparturesForDate();
- $ScheduleEdit = new Toolkit_Schedule_EditSchedule();
- $page->departures = $ScheduleEdit->getDeparturesForSchedules(
- $this,
- $scheduleId
- );
- $tpl->compile('departuresScheduleCalendar.html');
- $calendars = $tpl->bufferedOutputObject($page);
return $calendars;
}
}