[ Index ]

Source Code Reference for V1.00

title

Body

[close]

/modules/calendar/ -> vw_day_events.php (source)

   1  <?php /* CALENDAR $Id: vw_day_events.php 27 2008-01-21 00:53:02Z pedroix $ */
   2  if (!defined('W2P_BASE_DIR')) {
   3      die('You should not access this file directly.');
   4  }
   5  
   6  global $this_day, $first_time, $last_time, $company_id, $event_filter, $event_filter_list, $AppUI;
   7  
   8  // load the event types
   9  $types = w2PgetSysVal('EventType');
  10  $links = array();
  11  
  12  $perms = &$AppUI->acl();
  13  $user_id = $AppUI->user_id;
  14  $other_users = false;
  15  $no_modify = false;
  16  
  17  if ($perms->checkModule('admin', 'view')) {
  18      $other_users = true;
  19      if (($show_uid = w2PgetParam($_REQUEST, 'show_user_events', 0)) != 0) {
  20          $user_id = $show_uid;
  21          $no_modify = true;
  22          $AppUI->setState('event_user_id', $user_id);
  23      }
  24  }
  25  
  26  // assemble the links for the events
  27  $events = CEvent::getEventsForPeriod($first_time, $last_time, $event_filter, $user_id);
  28  $events2 = array();
  29  
  30  $start_hour = w2PgetConfig('cal_day_start');
  31  $end_hour = w2PgetConfig('cal_day_end');
  32  
  33  foreach ($events as $row) {
  34      $start = new CDate($row['event_start_date']);
  35      $end = new CDate($row['event_end_date']);
  36  
  37      $events2[$start->format('%H%M%S')][] = $row;
  38  
  39      if ($start_hour > $start->format('%H')) {
  40          $start_hour = $start->format('%H');
  41      }
  42      if ($end_hour < $end->format('%H')) {
  43          $end_hour = $end->format('%H');
  44      }
  45  }
  46  
  47  $tf = $AppUI->getPref('TIMEFORMAT');
  48  
  49  $dayStamp = $this_day->format(FMT_TIMESTAMP_DATE);
  50  
  51  $start = $start_hour;
  52  $end = $end_hour;
  53  $inc = w2PgetConfig('cal_day_increment');
  54  
  55  if ($start === null)
  56      $start = 8;
  57  if ($end === null)
  58      $end = 17;
  59  if ($inc === null)
  60      $inc = 15;
  61  
  62  $this_day->setTime($start, 0, 0);
  63  
  64  $html = '<form action="'.$_SERVER['REQUEST_URI'].'" method="post" name="pickFilter">';
  65  $html .= $AppUI->_('Event Filter') . ':' . arraySelect($event_filter_list, 'event_filter', 'onChange="document.pickFilter.submit()" class="text"', $event_filter, true);
  66  if ($other_users) {
  67      $html .= $AppUI->_('Show Events for') . ':' . '<select name="show_user_events" onchange="document.pickFilter.submit()" class="text">';
  68  
  69      if (($rows = w2PgetUsersList())) {
  70          foreach ($rows as $row) {
  71              if ($user_id == $row['user_id'])
  72                  $html .= '<option value="' . $row['user_id'] . '" selected="selected">' . $row['contact_first_name'] . ' ' . $row['contact_last_name'];
  73              else
  74                  $html .= '<option value="' . $row['user_id'] . '">' . $row['contact_first_name'] . ' ' . $row['contact_last_name'];
  75          }
  76      }
  77      $html .= '</select>';
  78  
  79  }
  80  
  81  require_once  (W2P_BASE_DIR . '/modules/calendar/links_events.php');
  82  
  83  $html .= '</form>';
  84  $html .= '<table cellspacing="1" cellpadding="2" border="0" width="100%" class="tbl">';
  85  $rows = 0;
  86  for ($i = 0, $n = ($end - $start) * 60 / $inc; $i < $n; $i++) {
  87      $html .= '<tr>';
  88  
  89      $tm = $this_day->format($tf);
  90      $html .= '<td width="1%" align="right" nowrap="nowrap">' . ($this_day->getMinute() ? $tm : '<b>' . $tm . '</b>') . '</td>';
  91  
  92      $timeStamp = $this_day->format('%H%M%S');
  93      if ($events2[$timeStamp]) {
  94          $count = count($events2[$timeStamp]);
  95          for ($j = 0; $j < $count; $j++) {
  96              $row = $events2[$timeStamp][$j];
  97  
  98              $et = new CDate($row['event_end_date']);
  99              $rows = (($et->getHour() * 60 + $et->getMinute()) - ($this_day->getHour() * 60 + $this_day->getMinute())) / $inc;
 100  
 101              $href = '?m=calendar&a=view&event_id=' . $row['event_id'];
 102              $alt = $row['event_description'];
 103  
 104              $html .= '<td class="event" rowspan="' . $rows . '" valign="top">';
 105  
 106              $html .= '<table cellspacing="0" cellpadding="0" border="0"><tr>';
 107              $html .= '<td>' . w2PshowImage('event' . $row['event_type'] . '.png', 16, 16, '', '', 'calendar');
 108              $html .= '</td><td>&nbsp;<b>' . $AppUI->_($types[$row['event_type']]) . '</b></td></tr></table>';
 109              $html .= w2PtoolTip($row['event_title'], getEventTooltip($row['event_id']), true);
 110              $html .= $href ? '<a href="' . $href . '" class="event">' : '';
 111              $html .= $row['event_title'];
 112              $html .= $href ? '</a>' : '';
 113              $html .= w2PendTip();
 114              $html .= '</td>';
 115          }
 116      } else {
 117          if (--$rows <= 0) {
 118              $html .= '<td></td>';
 119          }
 120      }
 121  
 122      $html .= '</tr>';
 123  
 124      $this_day->addSeconds(60 * $inc);
 125  }
 126  
 127  $html .= '</table>';
 128  echo $html;
 129  ?>


Generated: Wed Jan 7 03:00:01 2009 Cross-referenced by PHPXref 0.7