home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 April / CMCD0404.ISO / Software / Freeware / Programare / dotproject / modules / calendar / vw_day_events.php < prev    next >
Encoding:
PHP Script  |  2003-08-30  |  2.5 KB  |  82 lines

  1. <?php /* CALENDAR $Id: vw_day_events.php,v 1.3 2003/08/30 07:28:43 ajdonnison Exp $ */
  2. global $this_day, $first_time, $last_time, $company_id;
  3.  
  4. // load the event types
  5. $types = dPgetSysVal( 'EventType' );
  6. $links = array();
  7.  
  8. // assemble the links for the events
  9. $events = CEvent::getEventsForPeriod( $first_time, $last_time );
  10. $events2 = array();
  11.  
  12. foreach ($events as $row) {
  13.     $start = new CDate( $row['event_start_date'] );
  14.  
  15.     $events2[$start->format( "%H%M%S" )][] = $row;
  16. // the link
  17. /*
  18.     $link['href'] = "?m=calendar&a=view&event_id=".$row['event_id'];
  19.     $link['alt'] = $row['event_description'];
  20.     $link['text'] = '<img src="./images/obj/event.gif" width="16" height="16" border="0" alt="" />'
  21.         .'<span class="event">'.$row['event_title'].'</span>';
  22.     $links[$start->format( FMT_TIMESTAMP_DATE )][] = $link;
  23. */
  24. }
  25.  
  26. $tf = $AppUI->getPref('TIMEFORMAT');
  27.  
  28. $dayStamp = $this_day->format( FMT_TIMESTAMP_DATE );
  29.  
  30. $start = $AppUI->getConfig('cal_day_start');
  31. $end = $AppUI->getConfig('cal_day_end');
  32. $inc = $AppUI->getConfig('cal_day_increment');
  33.  
  34. if ($start === null ) $start = 8;
  35. if ($end === null ) $end = 17;
  36. if ($inc === null) $inc = 15;
  37.  
  38.  
  39. $this_day->setTime( $start, 0, 0 );
  40.  
  41. $html = '<table cellspacing="1" cellpadding="2" border="0" width="100%" class="tbl">';
  42. for ($i=0, $n=($end-$start)*60/$inc; $i < $n; $i++) {
  43.     $html .= "\n<tr>";
  44.     
  45.     $tm = $this_day->format( $tf );
  46.     $html .= "\n\t<td width=\"1%\" align=\"right\" nowrap=\"nowrap\">".($this_day->getMinute() ? $tm : "<b>$tm</b>")."</td>";
  47.  
  48.     $timeStamp = $this_day->format( "%H%M%S" );
  49.     if( @$events2[$timeStamp] ) {
  50.         $row = $events2[$timeStamp][0];
  51.  
  52.         $et = new CDate( $row['event_end_date'] );
  53.         $rows = (($et->getHour()*60 + $et->getMinute()) - ($this_day->getHour()*60 + $this_day->getMinute()))/$inc;
  54.  
  55.         $href = "?m=calendar&a=view&event_id=".$row['event_id'];
  56.         $alt = $row['event_description'];
  57.  
  58.         $html .= "\n\t<td class=\"event\" rowspan=\"$rows\" valign=\"top\">";
  59.  
  60.         $html .= "\n<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\"><tr>";
  61.         $html .= "\n<td>" . dPshowImage( dPfindImage( 'event'.$row['event_type'].'.png', 'calendar' ), 16, 16, '' );
  62.         $html .= "</td>\n<td> <b>" . $types[$row['event_type']] . "</b></td></tr></table>";
  63.  
  64.  
  65.         $html .= $href ? "\n\t\t<a href=\"$href\" class=\"event\" title=\"$alt\">" : '';
  66.         $html .= "\n\t\t{$row['event_title']}";
  67.         $html .= $href ? "\n\t\t</a>" : '';
  68.         $html .= "\n\t</td>";
  69.     } else {
  70.         $html .= "\n\t<td></td>";
  71.     }
  72.  
  73.     $html .= "\n</tr>";
  74.  
  75.     $this_day->addSeconds( 60*$inc );
  76. }
  77.  
  78.  
  79. $html .= '</table>';
  80. echo $html;
  81. ?>
  82.