[ Index ]

Source Code Reference for V1.00

title

Body

[close]

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

   1  <?php /* $Id: links_events.php 187 2008-07-21 10:17:07Z pedroix $ $URL: https://web2project.svn.sourceforge.net/svnroot/web2project/trunk/modules/calendar/links_events.php $ */
   2  if (!defined('W2P_BASE_DIR')) {
   3      die('You should not access this file directly.');
   4  }
   5  
   6  /**
   7   * Sub-function to collect events within a period
   8   * @param Date the starting date of the period
   9   * @param Date the ending date of the period
  10   * @param array by-ref an array of links to append new items to
  11   * @param int the length to truncate entries by
  12   * @author Andrew Eddie <eddieajau@users.sourceforge.net>
  13   */
  14  function getEventLinks($startPeriod, $endPeriod, &$links, $strMaxLen, $minical = false) {
  15      global $event_filter;
  16      $events = CEvent::getEventsForPeriod($startPeriod, $endPeriod, $event_filter);
  17  
  18      // assemble the links for the events
  19      foreach ($events as $row) {
  20          $start = new CDate($row['event_start_date']);
  21          $end = new CDate($row['event_end_date']);
  22          $date = $start;
  23          $cwd = explode(',', $GLOBALS['w2Pconfig']['cal_working_days']);
  24  
  25          for ($i = 0, $i_cmp = $start->dateDiff($end); $i <= $i_cmp; $i++) {
  26              // the link
  27              // optionally do not show events on non-working days
  28              if (($row['event_cwd'] && in_array($date->getDayOfWeek(), $cwd)) || !$row['event_cwd']) {
  29                  if ($minical) {
  30                      $link = array();
  31                  } else {
  32                      $url = '?m=calendar&a=view&event_id=' . $row['event_id'];
  33                      $link['href'] = '';
  34                      $link['alt'] = '';
  35                      $link['text'] = w2PtoolTip($row['event_title'], getEventTooltip($row['event_id']), true) . w2PshowImage('event' . $row['event_type'] . '.png', 16, 16, '', '', 'calendar') . '</a>&nbsp;' . '<a href="' . $url . '"><span class="event">' . $row['event_title'] . '</span></a>' . w2PendTip();
  36                  }    
  37                  $links[$date->format(FMT_TIMESTAMP_DATE)][] = $link;
  38              }
  39              $date = $date->getNextDay();
  40          }
  41      }
  42  }
  43  
  44  function getEventTooltip($event_id) {
  45      global $AppUI;
  46  
  47      if (!$event_id) {
  48          return '';    
  49      }
  50  
  51      $df = $AppUI->getPref('SHDATEFORMAT');
  52      $tf = $AppUI->getPref('TIMEFORMAT');
  53  
  54      // load the record data
  55      $q = new DBQuery;
  56      $q->addTable('events', 'e');
  57      $q->addQuery('event_start_date, event_end_date, event_project, event_type, event_recurs, event_times_recuring, event_description, project_name, company_name');
  58      $q->leftJoin('projects', 'p', 'event_project = project_id');
  59      $q->leftJoin('companies', 'c', 'project_company = company_id');
  60      $q->addWhere('event_id = ' . (int)$event_id);
  61      $row = $q->loadHash();
  62      $q->clear();
  63  
  64      // load the event types
  65      $types = w2PgetSysVal('EventType');
  66  
  67      // load the event recurs types
  68      $recurs = array('Never', 'Hourly', 'Daily', 'Weekly', 'Bi-Weekly', 'Every Month', 'Quarterly', 'Every 6 months', 'Every Year');
  69  
  70      $obj = new CEvent();
  71      $obj->event_id = $event_id;
  72      $assigned = $obj->getAssigned();
  73  
  74      $start_date = $row['event_start_date'] ? new CDate($row['event_start_date']) : null;
  75      $end_date = $row['event_end_date'] ? new CDate($row['event_end_date']) : null;
  76      if ($row['event_project']) {
  77          $event_project = $row['project_name'];
  78          $event_company = $row['company_name'];
  79      }
  80  
  81      $tt = '<table border="0" cellpadding="0" cellspacing="0" width="96%">';
  82      $tt .= '<tr>';
  83      $tt .= '    <td valign="top" width="50%">';
  84      $tt .= '        <strong>' . $AppUI->_('Details') . '</strong>';
  85      $tt .= '        <table cellspacing="3" cellpadding="2" width="100%">';
  86      $tt .= '        <tr>';
  87      $tt .= '            <td style="text-color:white;border: 1px solid white;-moz-border-radius:3.5px;-webkit-border-radius:3.5px;" align="right" nowrap="nowrap">' . $AppUI->_('Type') . '</td>';
  88      $tt .= '            <td width="100%" nowrap="nowrap">' . $AppUI->_($types[$row['event_type']]) . '</td>';
  89      $tt .= '        </tr>    ';
  90      if ($row['event_project']) {
  91          $tt .= '        <tr>';
  92          $tt .= '            <td style="border: 1px solid white;-moz-border-radius:3.5px;-webkit-border-radius:3.5px;" align="right" nowrap="nowrap">' . $AppUI->_('Company') . '</td>';
  93          $tt .= '            <td width="100%">' . $event_company . '</td>';
  94          $tt .= '        </tr>';
  95          $tt .= '        <tr>';
  96          $tt .= '            <td style="border: 1px solid white;-moz-border-radius:3.5px;-webkit-border-radius:3.5px;" align="right" nowrap="nowrap">' . $AppUI->_('Project') . '</td>';
  97          $tt .= '            <td width="100%">' . $event_project . '</td>';
  98          $tt .= '        </tr>';
  99      }
 100      $tt .= '        <tr>';
 101      $tt .= '            <td style="border: 1px solid white;-moz-border-radius:3.5px;-webkit-border-radius:3.5px;" align="right" nowrap="nowrap">' . $AppUI->_('Starts') . '</td>';
 102      $tt .= '            <td nowrap="nowrap">' . ($start_date ? $start_date->format($df . ' ' . $tf) : '-') . '</td>';
 103      $tt .= '        </tr>';
 104      $tt .= '        <tr>';
 105      $tt .= '            <td style="border: 1px solid white;-moz-border-radius:3.5px;-webkit-border-radius:3.5px;" align="right" nowrap="nowrap">' . $AppUI->_('Ends') . '</td>';
 106      $tt .= '            <td nowrap="nowrap">' . ($end_date ? $end_date->format($df . ' ' . $tf) : '-') . '</td>';
 107      $tt .= '        </tr>';
 108      $tt .= '        <tr>';
 109      $tt .= '            <td style="border: 1px solid white;-moz-border-radius:3.5px;-webkit-border-radius:3.5px;" align="right" nowrap="nowrap">' . $AppUI->_('Recurs') . '</td>';
 110      $tt .= '            <td nowrap="nowrap">' . $AppUI->_($recurs[$row['event_recurs']]) . ($row['event_recurs'] ? ' (' . $row['event_times_recuring'] . '&nbsp;' . $AppUI->_('times') . ')' : '') . '</td>';
 111      $tt .= '        </tr>';
 112      $tt .= '        <tr>';
 113      $tt .= '            <td style="border: 1px solid white;-moz-border-radius:3.5px;-webkit-border-radius:3.5px;" align="right" nowrap="nowrap">' . $AppUI->_('Attendees') . '</td>';
 114      $tt .= '            <td nowrap="nowrap">';
 115      if (is_array($assigned)) {
 116          $start = false;
 117          foreach ($assigned as $user) {
 118              if ($start) {
 119                  $tt .= '<br />';
 120              } else {
 121                  $start = true;
 122              }
 123              $tt .= $user;
 124          }
 125      }
 126      $tt .= '        </tr>';
 127      $tt .= '        </table>';
 128      $tt .= '    </td>';
 129      $tt .= '    <td width="50%" valign="top">';
 130      $tt .= '        <strong>' . $AppUI->_('Note') . '</strong>';
 131      $tt .= '        <table cellspacing="0" cellpadding="2" border="0" width="100%">';
 132      $tt .= '        <tr>';
 133      $tt .= '            <td style="border: 1px solid white;-moz-border-radius:3.5px;-webkit-border-radius:3.5px;">';
 134      $tt .= '                ' . str_replace(chr(10), "<br />", $row['event_description']) . '&nbsp;';
 135      $tt .= '            </td>';
 136      $tt .= '        </tr>';
 137      $tt .= '        </table>';
 138      $tt .= '    </td>';
 139      $tt .= '</tr>';
 140      $tt .= '</table>';
 141      return $tt;
 142  }
 143  ?>


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