[ Index ]

Source Code Reference for V1.00

title

Body

[close]

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

   1  <?php /* $Id: day_view.php 38 2008-02-11 11:38:51Z pedroix $ $URL: https://web2project.svn.sourceforge.net/svnroot/web2project/trunk/modules/calendar/day_view.php $ */
   2  if (!defined('W2P_BASE_DIR')) {
   3      die('You should not access this file directly.');
   4  }
   5  
   6  // check permissions for this record

   7  $perms = &$AppUI->acl();
   8  $canRead = $perms->checkModule($m, 'view');
   9  
  10  if (!$canRead) {
  11      $AppUI->redirect('m=public&a=access_denied');
  12  }
  13  
  14  global $tab, $locale_char_set, $date;
  15  $AppUI->savePlace();
  16  
  17  require_once ($AppUI->getModuleClass('tasks'));
  18  
  19  /* Kludge: Backward compatible function to address php5 and php4 date issue */

  20  function php4_clone($object) {
  21      if (version_compare(phpversion(), '5.0') < 0) {
  22          return $object;
  23      } else {
  24          return @clone ($object);
  25      }
  26  }
  27  
  28  // retrieve any state parameters

  29  if (isset($_REQUEST['company_id'])) {
  30      $AppUI->setState('CalIdxCompany', intval(w2PgetParam($_REQUEST, 'company_id', 0)));
  31  }
  32  $company_id = $AppUI->getState('CalIdxCompany', $AppUI->user_company);
  33  
  34  $event_filter = $AppUI->checkPrefState('CalIdxFilter', w2PgetParam($_REQUEST, 'event_filter', ''), 'EVENTFILTER', 'my');
  35  
  36  $AppUI->setState('CalDayViewTab', w2PgetParam($_GET, 'tab', $tab));
  37  $tab = $AppUI->getState('CalDayViewTab', '0');
  38  
  39  // get the prefered date format

  40  $df = $AppUI->getPref('SHDATEFORMAT');
  41  
  42  // get the passed timestamp (today if none)

  43  $ctoday = new CDate();
  44  $today = $ctoday->format(FMT_TIMESTAMP_DATE);
  45  $date = w2PgetParam($_GET, 'date', $today);
  46  // establish the focus 'date'

  47  $this_day = new CDate($date);
  48  $dd = $this_day->getDay();
  49  $mm = $this_day->getMonth();
  50  $yy = $this_day->getYear();
  51  
  52  // get current week

  53  $this_week = Date_calc::beginOfWeek($dd, $mm, $yy, FMT_TIMESTAMP_DATE, LOCALE_FIRST_DAY);
  54  
  55  // prepare time period for 'events'

  56  $first_time = php4_clone($this_day);
  57  $first_time->setTime(0, 0, 0);
  58  $first_time->subtractSeconds(1);
  59  
  60  $last_time = php4_clone($this_day);
  61  $last_time->setTime(23, 59, 59);
  62  
  63  $prev_day = new CDate(Date_calc::prevDay($dd, $mm, $yy, FMT_TIMESTAMP_DATE));
  64  $next_day = new CDate(Date_calc::nextDay($dd, $mm, $yy, FMT_TIMESTAMP_DATE));
  65  
  66  // get the list of visible companies

  67  $company = new CCompany();
  68  global $companies;
  69  $companies = $company->getAllowedRecords($AppUI->user_id, 'company_id,company_name', 'company_name');
  70  $companies = arrayMerge(array('0' => $AppUI->_('All')), $companies);
  71  
  72  // setup the title block

  73  $titleBlock = new CTitleBlock('Day View', 'myevo-appointments.png', $m, $m.'.'.$a);
  74  $titleBlock->addCrumb('?m=calendar&a=year_view&date=' . $this_day->format(FMT_TIMESTAMP_DATE), 'year view');
  75  $titleBlock->addCrumb('?m=calendar&date=' . $this_day->format(FMT_TIMESTAMP_DATE), 'month view');
  76  $titleBlock->addCrumb('?m=calendar&a=week_view&date=' . $this_week, 'week view');
  77  $titleBlock->addCell($AppUI->_('Company') . ':');
  78  $titleBlock->addCell(arraySelect($companies, 'company_id', 'onChange="document.pickCompany.submit()" class="text"', $company_id), '', '<form action="' . $_SERVER['REQUEST_URI'] . '" method="post" name="pickCompany">', '</form>');
  79  $titleBlock->addCell('<input type="submit" class="button" value="' . $AppUI->_('new event') . '">', '', '<form action="?m=calendar&a=addedit&date=' . $this_day->format(FMT_TIMESTAMP_DATE) . '" method="post">', '</form>');
  80  $titleBlock->show();
  81  ?>
  82  <script language="javascript">
  83  function clickDay( idate, fdate ) {
  84          window.location = './index.php?m=calendar&a=day_view&date='+idate+'&tab=0';
  85  }
  86  </script>
  87  
  88  <table class="std" width="100%" cellspacing="0" cellpadding="4">
  89  <tr>
  90          <td valign="top">
  91                  <table border="0" cellspacing="1" cellpadding="2" width="100%" class="motitle">
  92                  <tr>
  93                          <td>
  94                                  <a href="<?php echo '?m=calendar&a=day_view&date=' . $prev_day->format(FMT_TIMESTAMP_DATE); ?>"><img src="<?php echo w2PfindImage('prev.gif'); ?>" width="16" height="16" alt="pre" border="0"></a>
  95                          </td>
  96                          <th width="100%">
  97                                  <?php echo $AppUI->_(htmlentities($this_day->format('%A'), ENT_COMPAT, $locale_char_set)) . ', ' . $this_day->format($df); ?>
  98                          </th>
  99                          <td>
 100                                  <a href="<?php echo '?m=calendar&a=day_view&date=' . $next_day->format(FMT_TIMESTAMP_DATE); ?>"><img src="<?php echo w2PfindImage('next.gif'); ?>" width="16" height="16" alt="next" border="0"></a>
 101                          </td>
 102                  </tr>
 103                  </table>
 104  
 105  <?php
 106  // tabbed information boxes

 107  $tabBox = new CTabBox('?m=calendar&a=day_view&date=' . $this_day->format(FMT_TIMESTAMP_DATE), W2P_BASE_DIR . '/modules/calendar/', $tab);
 108  $tabBox->add('vw_day_events', 'Events');
 109  $tabBox->add('vw_day_tasks', 'Tasks');
 110  $tabBox->show();
 111  ?>
 112          </td>
 113  <?php if ($w2Pconfig['cal_day_view_show_minical']) { ?>
 114          <td valign="top" width="175">
 115  <?php
 116      require_once  (W2P_BASE_DIR . '/modules/calendar/links_tasks.php');
 117      require_once  (W2P_BASE_DIR . '/modules/calendar/links_events.php');
 118  
 119      $minical = new CMonthCalendar($this_day);
 120      $minical->setStyles('minititle', 'minical');
 121      $minical->showArrows = false;
 122      $minical->showWeek = false;
 123      $minical->clickMonth = true;
 124      $minical->setLinkFunctions('clickDay');
 125  
 126      $first_time = new CDate($minical->prev_month);
 127      $first_time->setDay(1);
 128      $first_time->setTime(0, 0, 0);
 129      $last_time = new CDate($minical->prev_month);
 130      $last_time->setDay($minical->prev_month->getDaysInMonth());
 131      $last_time->setTime(23, 59, 59);
 132      $links = array();
 133      getTaskLinks($first_time, $last_time, $links, 20, $company_id, true);
 134      getEventLinks($first_time, $last_time, $links, 20, true);
 135      $minical->setEvents($links);
 136  
 137      $minical->setDate($minical->prev_month);
 138  
 139      echo '<table cellspacing="0" cellpadding="0" border="0" width="100%"><tr>';
 140      echo '<td align="center" >' . $minical->show() . '</td>';
 141      echo '</tr></table><hr noshade size="1">';
 142  
 143      $first_time = new CDate($minical->next_month);
 144      $first_time->setDay(1);
 145      $first_time->setTime(0, 0, 0);
 146      $last_time = new CDate($minical->next_month);
 147      $last_time->setDay($minical->next_month->getDaysInMonth());
 148      $last_time->setTime(23, 59, 59);
 149      $links = array();
 150      getTaskLinks($first_time, $last_time, $links, 20, $company_id, true);
 151      getEventLinks($first_time, $last_time, $links, 20, true);
 152      $minical->setEvents($links);
 153  
 154      $minical->setDate($minical->next_month);
 155  
 156      echo '<table cellspacing="0" cellpadding="0" border="0" width="100%"><tr>';
 157      echo '<td align="center" >' . $minical->show() . '</td>';
 158      echo '</tr></table><hr noshade size="1">';
 159  
 160      $first_time = new CDate($minical->next_month);
 161      $first_time->setDay(1);
 162      $first_time->setTime(0, 0, 0);
 163      $last_time = new CDate($minical->next_month);
 164      $last_time->setDay($minical->next_month->getDaysInMonth());
 165      $last_time->setTime(23, 59, 59);
 166      $links = array();
 167      getTaskLinks($first_time, $last_time, $links, 20, $company_id, true);
 168      getEventLinks($first_time, $last_time, $links, 20, true);
 169      $minical->setEvents($links);
 170  
 171      $minical->setDate($minical->next_month);
 172  
 173      echo '<table cellspacing="0" cellpadding="0" border="0" width="100%"><tr>';
 174      echo '<td align="center" >' . $minical->show() . '</td>';
 175      echo '</tr></table>';
 176  ?>
 177          </td>
 178   <?php } ?>
 179  </tr>
 180  </table>


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