home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 April / CMCD0404.ISO / Software / Freeware / Programare / dotproject / modules / calendar / week_view.php < prev   
Encoding:
PHP Script  |  2003-09-11  |  4.3 KB  |  138 lines

  1. <?php /* CALENDAR $Id: week_view.php,v 1.21 2003/09/11 02:30:50 gregorerhardt Exp $ */
  2. $AppUI->savePlace();
  3.  
  4. require_once( $AppUI->getModuleClass( 'tasks' ) );
  5.  
  6. // retrieve any state parameters
  7. if (isset( $_REQUEST['company_id'] )) {
  8.     $AppUI->setState( 'CalIdxCompany', intval( $_REQUEST['company_id'] ) );
  9. }
  10. $company_id = $AppUI->getState( 'CalIdxCompany' ) !== NULL ? $AppUI->getState( 'CalIdxCompany' ) : $AppUI->user_company;
  11.  
  12. // get the passed timestamp (today if none)
  13. $date = dPgetParam( $_GET, 'date', null );
  14.  
  15. // establish the focus 'date'
  16. $this_week = new CDate( $date );
  17. $dd = $this_week->getDay();
  18. $mm = $this_week->getMonth();
  19. $yy = $this_week->getYear();
  20.  
  21. // prepare time period for 'events'
  22. $first_time = new CDate( Date_calc::beginOfWeek( $dd, $mm, $yy, FMT_TIMESTAMP_DATE, LOCALE_FIRST_DAY ) );
  23. $first_time->setTime( 0, 0, 0 );
  24. $first_time->subtractSeconds( 1 );
  25. $last_time = new CDate( Date_calc::endOfWeek( $dd, $mm, $yy, FMT_TIMESTAMP_DATE, LOCALE_FIRST_DAY ) );
  26. $last_time->setTime( 23, 59, 59 );
  27.  
  28. $prev_week = new CDate( Date_calc::beginOfPrevWeek( $dd, $mm, $yy, FMT_TIMESTAMP_DATE, LOCALE_FIRST_DAY ) );
  29. $next_week = new CDate( Date_calc::beginOfNextWeek( $dd, $mm, $yy, FMT_TIMESTAMP_DATE, LOCALE_FIRST_DAY ) );
  30.  
  31. $tasks = CTask::getTasksForPeriod( $first_time, $last_time, $company_id );
  32. $events = CEvent::getEventsForPeriod( $first_time, $last_time );
  33.  
  34. $links = array();
  35.  
  36. // assemble the links for the tasks
  37. require_once( $AppUI->getConfig( 'root_dir' )."/modules/calendar/links_tasks.php" );
  38. getTaskLinks( $first_time, $last_time, $links, 50, $company_id );
  39.  
  40. // assemble the links for the events
  41. require_once( $AppUI->getConfig( 'root_dir' )."/modules/calendar/links_events.php" );
  42. getEventLinks( $first_time, $last_time, $links, 50 );
  43.  
  44. // setup the title block
  45. $titleBlock = new CTitleBlock( 'Week View', 'myevo-appointments.png', $m, "$m.$a" );
  46. $titleBlock->addCrumb( "?m=calendar&date=".$this_week->format( FMT_TIMESTAMP_DATE ), "month view" );
  47. $titleBlock->show();
  48. ?>
  49.  
  50. <style type="text/css">
  51. TD.weekDay  {
  52.     height:120px;
  53.     vertical-align: top;
  54.     padding: 1px 4px 1px 4px;
  55.     border-bottom: 1px solid #ccc;
  56.     border-right: 1px solid  #ccc;
  57.     text-align: left;
  58. }
  59. </style>
  60.  
  61. <table border="0" cellspacing="1" cellpadding="2" width="100%" class="motitle">
  62. <tr>
  63.     <td>
  64.         <a href="<?php echo '?m=calendar&a=week_view&date='.$prev_week->format( FMT_TIMESTAMP_DATE ); ?>"><img src="images/prev.gif" width="16" height="16" alt="pre" border="0"></A>
  65.     </td>
  66.     <th width="100%">
  67.         <span style="font-size:12pt"><?php echo $AppUI->_( 'Week' ).' '.$this_week->format( "%U - %Y" ); ?></span>
  68.     </th>
  69.     <td>
  70.         <a href="<?php echo '?m=calendar&a=week_view&date='.$next_week->format( FMT_TIMESTAMP_DATE ); ?>"><img src="images/next.gif" width="16" height="16" alt="next" border="0"></A>
  71.     </td>
  72. </tr>
  73. </table>
  74.  
  75. <table border="0" cellspacing="1" cellpadding="2" width="100%" style="margin-width:4px;background-color:white">
  76. <?php
  77. $column = 0;
  78. $format = array( "<strong>%d</strong> %A", "%A <strong>%d</strong>" );
  79. $show_day = $this_week;
  80.  
  81. $today = new CDate();
  82. $today = $today->format( FMT_TIMESTAMP_DATE );
  83.  
  84. for ($i=0; $i < 7; $i++) {
  85.     $dayStamp = $show_day->format( FMT_TIMESTAMP_DATE );
  86.  
  87.     $day  = $show_day->getDay();
  88.     $href = "?m=calendar&a=day_view&date=$dayStamp";
  89.  
  90.     $s = '';
  91.     if ($column == 0) {
  92.         $s .= '<tr>';
  93.     }
  94.     $s .= '<td class="weekDay" style="width:50%;">';
  95.  
  96.     $s .= '<table style="width:100%;border-spacing:0;">';
  97.     $s .= '<tr>';
  98.     $s .= '<td><a href="'.$href.'"><?php echo $day1 ?>';
  99.  
  100.     $s .= $dayStamp == $today ? '<span style="color:red">' : '';
  101.     $s .= $show_day->format( $format[$column] );
  102.     $s .= $dayStamp == $today ? '</span>' : '';
  103.     $s .= '</a></td></tr>';
  104.  
  105.     $s .= '<tr><td>';
  106.  
  107.     if (isset( $links[$dayStamp] )) {
  108.         foreach ($links[$dayStamp] as $e) {
  109.             $href = isset($e['href']) ? $e['href'] : null;
  110.             $alt = isset($e['alt']) ? $e['alt'] : null;
  111.  
  112.             $s .= "<br />";
  113.             $s .= $href ? "<a href=\"$href\" class=\"event\" title=\"$alt\">" : '';
  114.             $s .= "{$e['text']}";
  115.             $s .= $href ? '</a>' : '';
  116.         }
  117.     }
  118.  
  119.     $s .= '</td></tr></table>';
  120.  
  121.     $s .= '</td>';
  122.     if ($column == 1) {
  123.         $s .= '</tr>';
  124.     }
  125.     $column = 1 - $column;
  126.  
  127. // select next day
  128.     $show_day->addSeconds( 24*3600 );
  129.     echo $s;
  130. }
  131. ?>
  132. <tr>
  133.     <td colspan="2" align="right" bgcolor="#efefe7">
  134.         <a href="./index.php?m=calendar&a=week_view"><?php echo $AppUI->_('today');?></A>
  135.     </td>
  136. </tr>
  137. </table>
  138.