home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 April / CMCD0404.ISO / Software / Freeware / Programare / groupoffice-com-2.01 / modules / calendar / list_view.inc < prev    next >
Text File  |  2004-03-08  |  4KB  |  87 lines

  1. <?php
  2. $calendar_module_url = isset($calendar_module_url) ? $calendar_module_url : $GO_MODULES->url;
  3.  
  4. //show_days is the number of days to show (defined in index.php)
  5. //max_columns (defined in index.php)
  6. //day_start is the first day of the week (defined in index.php)
  7.  
  8. $link_back = isset($link_back) ? $link_back : $_SERVER['REQUEST_URI'];
  9.  
  10. if ($show_days > 29)
  11. {
  12.     //display month
  13.     $interval_start_time = mktime(0,0,0,$month, 1, $year)-($_SESSION['GO_SESSION']['timezone']*3600);
  14.     $interval_end_time = mktime(0,0,0,$month+1, 0, $year)-($_SESSION['GO_SESSION']['timezone']*3600);
  15. }else
  16. {
  17.     if ($show_days > 4)
  18.     {
  19.         //calculate the first day to display in the week view.
  20.         $weekday = date("w", $local_browse_time);
  21.         $tmpday = $day - $weekday + $_SESSION['GO_SESSION']['first_weekday'];
  22.         if ($tmpday > $day)
  23.         {
  24.             $tmpday = $tmpday -7;
  25.         }
  26.         $new_time = mktime(0,0,0,$month, $tmpday, $year);
  27.         $day = date("j", $new_time);
  28.         $month = date('m', $new_time);
  29.         $year = date('Y', $new_time);
  30.     }
  31.  
  32.     $interval_start_time = mktime(0,0,0,$month, $day, $year)-($_SESSION['GO_SESSION']['timezone']*3600);
  33.     $interval_end_time = mktime(0,0,0,$month, $day+$show_days, $year)-($_SESSION['GO_SESSION']['timezone']*3600)-1;
  34. }
  35.  
  36. $contact_id = isset($contact_id) ? $contact_id : 0;
  37.  
  38. echo '<input type="hidden" name="contact_id" value="'.$contact_id.'" />';
  39.  
  40. $events = $cal->get_events_in_array($calendar_id, $contact_id, $interval_start_time, $interval_end_time, $day, $month, $year, $_SESSION['GO_SESSION']['timezone'], 0, $index_date='Ymd', false);
  41.  
  42. $events = array_merge($events['all_day'], $events['timed']);
  43. krsort($events);
  44. echo '<table border="0"><tr><td><h3>';
  45. echo $sc_view.': </h3></td><td>';
  46. $dropbox = new dropbox();
  47. $dropbox->add_value('1', '1 '.$sc_day);
  48. $dropbox->add_value('2', '2 '.$sc_days);
  49. $dropbox->add_value('5', '5 '.$sc_days);
  50. $dropbox->add_value('7', '1 '.$sc_week);
  51. $dropbox->add_value('14', '2 '.$sc_weeks);
  52. $dropbox->add_value('21', '3 '.$sc_weeks);
  53. $dropbox->add_value('35', '1 '.$sc_month);
  54. $dropbox->print_dropbox("show_days", $show_days, 'onchange="javascript:document.forms[0].submit()"');
  55.  
  56. echo '</td><td><h3><a href="javascript:goto_date('.($day-$show_days).', '.$month.', '.$year.');"><<</a> ';
  57. echo date($_SESSION['GO_SESSION']['date_format'], $interval_start_time+($_SESSION['GO_SESSION']['timezone']*3600)).' - '.date($_SESSION['GO_SESSION']['date_format'], $interval_end_time+($_SESSION['GO_SESSION']['timezone']*3600));
  58. echo ' <a href="javascript:goto_date('.($day+$show_days).', '.$month.', '.$year.');">>></a>';
  59. echo '</h3></td></tr></table>';
  60.  
  61. echo '<table cellspacing="0" cellpadding="0">';
  62. echo '<tr height="20">';
  63. echo '<td class="TableHead2" width="100" nowrap>'.$sc_start_time.'</td>';
  64. echo '<td class="TableHead2" width="100" nowrap>'.$sc_end_time.'</td>';
  65. echo '<td class="TableHead2" width="100" nowrap>'.$strName.'</td>';
  66. echo '</tr>';
  67. if (count($events) > 0)
  68. {
  69.     while($event_date = array_shift($events))
  70.     {
  71.         while($event = array_shift($event_date))
  72.         {
  73.             $link = $event['write_permission'] ? $calendar_module_url.'event.php' : $calendar_module_url.'show_event.php';
  74.  
  75.             $date_format = $event['all_day_event'] == '1' ? $_SESSION['GO_SESSION']['date_format'] : $_SESSION['GO_SESSION']['date_format'].' '.$_SESSION['GO_SESSION']['time_format'];
  76.             echo '<tr style="background-color: #'.$event['background'].'" height="16"><td>'.date($date_format, $event['start_time']).' </td>';
  77.             echo '<td>'.date($date_format, $event['end_time']).' </td>';
  78.             echo '<td><a class="normal" href="'.$link.'?event_id='.$event['id'].'&return_to='.rawurlencode($link_back).'">'.$event['name'].'</a> </td></tr>';
  79.             echo '<tr><td colspan="99" height="1"><img src="'.$GO_THEME->images['cccccc'].'" border="0" height="1" width="100%" /></td></tr>';
  80.         }
  81.     }
  82. }else
  83. {
  84.     echo '<tr><td colspan="99">'.$sc_no_events.'</td></tr>';
  85.     echo '<tr><td colspan="99" height="1"><img src="'.$GO_THEME->images['cccccc'].'" border="0" height="1" width="100%" /></td></tr>';
  86. }
  87. echo '</table>';