public function renderSidebar() { if ($this->shouldNotDisplay()) { return; } startbox(); $event = Events::nextEvent(); if ($event['seatingPlan']) { echo '<p>The seating plan is now live! Pay, then choose your seat!</p><div style = "text-align: center">'; echo '<a href = "seatingplan.php?event=' . $event['id'] . '"><img src = "resources/images/seatingPlan.png" alt = "seating plan" /></a></div>'; } if (empty($event)) { echo '<p>No events planned!</p>'; } else { $diff = strtotime($event['dateIso']) - time(); $days = $diff /= 86400; $days = floor($days); echo '<p><a href = "viewEvent.php?id=' . $event['id'] . '">' . $event['name'] . '</a> starts in <strong>' . $days . '</strong> ' . Inflector::quantify('day', $days) . '. </p>'; } stopbox('Countdown!'); }
public static function nextEvent() { global $db; $sql = 'SELECT e.id, e.name, e.date, e.duration, v.name as venue, e.seatingPlan FROM events e, venues v WHERE date_add(e.date, INTERVAL 24 HOUR) > now() AND e.venue = v.id AND e.published = 1 ORDER BY date ASC LIMIT 1'; $result = $db->query($sql); if ($result->numRows() == 0) { return null; } else { $nextEvent = $result->fetchRow(); $nextEvent['endDate'] = date_create($nextEvent['date']); $nextEvent['endDate']->modify('+' . $nextEvent['duration'] . ' hours'); $nextEvent['endDate'] = formatDt($nextEvent['endDate']); $nextEvent['dateIso'] = formatDtIso($nextEvent['date']); $nextEvent['dateUser'] = formatDtString($nextEvent['date']); $nextEvent['date'] = formatDtString($nextEvent['date']); // deprecated $diff = strtotime($nextEvent['dateIso']) - time(); $diff /= 86400; $diff = floor($diff); $nextEvent['countDays'] = $diff; $nextEvent['stringDays'] = Inflector::quantify('day', $nextEvent['countDays']); return $nextEvent; } }