$date = date('Y-m-d', $stamp);
 // Get and sort the events
 $calendar = new reasonCalendar(array('start_date' => $date, 'end_date' => $date, 'view' => 'daily', 'show_statuses' => array('show', 'tentative', 'cancelled')));
 $calendar->run();
 $events = $calendar->get_all_events();
 usort($events, 'compare_times');
 // Figure out the URL for the borrow action
 parse_str(trim($_REQUEST['params'], '?'), $params);
 $editing_id = $params['id'];
 $params['cur_module'] = 'DoBorrow';
 echo '<h4>Other events for ' . date('l, F jS', $stamp) . ':</h4>';
 if (count($events)) {
     // Ask the admin page class for the token that will allow us
     // to complete the borrow action.
     $admin = new AdminPage();
     $params['admin_token'] = $admin->get_admin_token();
     echo '<p>Click an event to add it to the <em>' . $_REQUEST['site'] . '</em> calendar:</p>';
     echo '<ul class="preview_list">';
     foreach ($events as $event) {
         $classes = array($event->get_value('show_hide') . '_status');
         if ($editing_id == $event->get_value('id')) {
             $classes[] = 'current';
         }
         echo '<li class="' . join(' ', $classes) . '">';
         $params['id'] = $event->get_value('id');
         if (substr($event->get_value('datetime'), 11) != '00:00:00') {
             $time = prettify_mysql_datetime($event->get_value('datetime'), 'g:ia');
         } else {
             $time = 'All day';
         }
         if ($event->get_value('show_hide') == 'tentative') {