public function calendar() { $thisYear = date('Y', strtotime('now')); $thisMonth = date('m', strtotime('now')); if ($thisMonth == 12) { $nextMonth = '01'; $nextYear = date('Y', strtotime('+1 year')); } else { $nextMonth = date('m', strtotime('+1 month')); $nextYear = date('Y', strtotime('now')); } $thisMonthData = $this->repo->getCalendar($thisYear, $thisMonth); $nextMonthData = $this->repo->getCalendar($nextYear, $nextMonth); $thisMonthEvents = Calendar::generate($thisYear, $thisMonth, $thisMonthData); $nextMonthEvents = Calendar::generate($nextYear, $nextMonth, $nextMonthData); return view('about.calendar', array('thisMonth' => $thisMonthEvents, 'nextMonth' => $nextMonthEvents, 'pageTitle' => 'Lambda Calendar', 'panelTitle' => 'Lambda Calendar')); }
public function getCalendar($year, $month) { $template = ' {table_open}<table class="calendar" border="0" cellpadding="0" cellspacing="0">{/table_open} {heading_row_start}<tr class="calendar-header">{/heading_row_start} {heading_previous_cell}<th><a href="{previous_url}"><<</a></th>{/heading_previous_cell} {heading_title_cell}<th colspan="{colspan}">{heading}</th>{/heading_title_cell} {heading_next_cell}<th><a href="{next_url}">>></a></th>{/heading_next_cell} {heading_row_end}</tr>{/heading_row_end} {week_row_start}<tr>{/week_row_start} {week_day_cell}<td>{week_day}</td>{/week_day_cell} {week_row_end}</tr>{/week_row_end} {cal_row_start}<tr>{/cal_row_start} {cal_cell_start}<td class="day">{/cal_cell_start} {cal_cell_content}<div class="date">{day}</div><div>{content}</div>{/cal_cell_content} {cal_cell_content_today}<div class="highlight date">{day}</div><div>{content}</div>{/cal_cell_content_today} {cal_cell_no_content}{day}{/cal_cell_no_content} {cal_cell_no_content_today}<div class="highlight">{day}</div>{/cal_cell_no_content_today} {cal_cell_blank} {/cal_cell_blank} {cal_cell_end}</td>{/cal_cell_end} {cal_row_end}</tr>{/cal_row_end} {table_close}</table>{/table_close} '; $config = array('month_type' => 'long', 'day_type' => 'long', 'template' => $template); Calendar::initialize($config); $array = array(); foreach (range(1, 31) as $day) { $dateN = date('N', strtotime($year . '-' . $month . '-' . str_pad($day, 2, 0, STR_PAD_LEFT))); $meetings = Meeting::where('day_index', $dateN)->where('active', 1)->orderBy('meeting_time', 'ASC')->get(); $meetingString = '<h4>Meetings</h4>'; if (count($meetings)) { foreach ($meetings as $meeting) { $meetingString .= '<p>' . date('g:i a', strtotime($meeting->meeting_time)) . '<br/>' . $meeting->meeting . '</p>'; } } else { $meetingString = '<p>No meetings are scehduled for this day.</p>'; } $eventString = '<h4>Events</h4>'; $events = Event::where('datetime', date('Y-m-d', strtotime($year . '-' . $month . '-' . str_pad($day, 2, 0, STR_PAD_LEFT))))->get(); if (count($events)) { foreach ($events as $event) { $eventString .= '<p>' . $event->description; } } else { $eventString .= '<p>No events are scheduled for this day.</p>'; } $array[$day] = $meetingString . $eventString; } return $array; }