WebCalendar PHP Cross Reference Groupware Applications

Source: /view_r.php - 615 lines - 21335 bytes - Summary - Text - Print

   1  <?php
   2  /* $Id: view_r.php,v 1.49.2.6 2008/02/17 02:26:25 cknudsen Exp $
   3   *
   4   * Page Description:
   5   * This is the "Week by Time" and "Week by Day" view.
   6   * This view will show either a week's worth of events (type='R')
   7   * or a single day of events (type='E')
   8   * using a format with days across the top of the table and time
   9   * showing down the left side. (This is just like the standard
  10   * layout of day.php and week.php.)
  11   * However, each cell will be subdivided into
  12   * however many users are part of this view.
  13   *
  14   * Input Parameters:
  15   * id (*) - specify view id in webcal_view table
  16   * date - specify the starting date of the view.
  17   *   If not specified, current date will be used.
  18   * friendly - if set to 1, then page does not include links or
  19   *   trailer navigation.
  20   * (*) required field
  21   *
  22   * Comments:
  23   * The week view of this page will only show weekends if the
  24   * user has set "display weekends in week view" in their
  25   * user preferences.
  26   *
  27   * The week version of this page has the potential to contain
  28   * a large table. The layout will be skewed to try and fit this
  29   * into a page.
  30   * If you want to allow the table to grow larger than the viewable
  31   * area in the browser, set the $fit_to_window_week to be false below.
  32   * (You can do the same for the day view with $fit_to_window_day.)
  33   *
  34   * Should we make this an option when creating/updating the view?
  35   * If we did make this an option in the UI, we would need to either:
  36   * (A) add a column to the webcal_view table
  37   * (B) use different view types for this option ('E' and 'R' for
  38   *     fit-to-window, 'G' and 'X' for expand?)
  39   *
  40   * Security:
  41   * Must have "allow view others" enabled ($ALLOW_VIEW_OTHER) in
  42   *   System Settings unless the user is an admin user ($is_admin).
  43   * If the view is not global, the user must be owner of the view.
  44   * If the view is global, and user_sees_only_his_groups is
  45   * enabled, then we remove users not in this user's groups
  46   * (except for nonuser calendars... which we allow regardless of group).
  47   */
  48  include_once  'includes/init.php';
  49  include_once  'includes/views.php';
  50  
  51  $error = '';
  52  $can_add = true; // include '+' add icons in this view?
  53  
  54  // Set this to true to allow the table to be larger than the browser's
  55  // viewable area.
  56  // Only if you have more than 7 users, would you need to set this to
  57  // false for the day view.
  58  // On the week view, 3 or more users start to
  59  // get crowded and you may want to set this to true.
  60  $fit_to_window_day = false;
  61  $fit_to_window_week = true;
  62  
  63  // This defines how wide the smallest column will be for the view
  64  $col_pixels_week = 90; // if above is true, how large is each column in table
  65  // This defines how wide the smallest column will be for the view
  66  $col_pixels_day = 150; // if above is true, how large is each column in table
  67  
  68  // Should the time of the event be displayed
  69  $show_time_day = true;
  70  $show_time_week = false;
  71  
  72  // Display abbreviated Timezone name in popup
  73  $DISPLAY_TZ = 2;
  74  
  75  // Should there always be a row for untimed/all-day events?
  76  // Normally we only show this if there are some of these events, but
  77  // if you want to be able to add an all-day event quickly, you can
  78  // double-click in one of these table cells, so it's handy to have
  79  // this row around in all cases.
  80  $show_untimed_row_always = true;
  81  
  82  view_init ( $id );
  83  
  84  // view type 'E' = Day by Time, 'R' = Week by Time
  85  $is_day_view = ( $view_type == 'E' );
  86  $col_pixels = ( $is_day_view ? $col_pixels_day : $col_pixels_week );
  87  $fit_to_window = ( $is_day_view ? $fit_to_window_day : $fit_to_window_week );
  88  $show_time = ( $is_day_view ? $show_time_day : $show_time_week );
  89  
  90  $printerStr = generate_printer_friendly ( 'view_r.php' );
  91  set_today ( $date );
  92  
  93  $INC = array ( 'js/popups.php/true' );
  94  print_header ( $INC );
  95  
  96  $thisdate = sprintf ( "%04d%02d%02d", $thisyear, $thismonth, $thisday );
  97  
  98  if ( $is_day_view )
  99    $next = mktime ( 0, 0, 0, $thismonth, $thisday + 1, $thisyear );
 100  else
 101    $next = mktime ( 0, 0, 0, $thismonth, $thisday + 7, $thisyear );
 102  $nextyear = date ( 'Y', $next );
 103  $nextmonth = date ( 'm', $next );
 104  $nextday = date ( 'd', $next );
 105  $nextdate = sprintf ( "%04d%02d%02d", $nextyear, $nextmonth, $nextday );
 106  
 107  if ( $is_day_view )
 108    $prev = mktime ( 0, 0, 0, $thismonth, $thisday - 1, $thisyear );
 109  else
 110    $prev = mktime ( 0, 0, 0, $thismonth, $thisday - 7, $thisyear );
 111  $prevyear = date ( 'Y', $prev );
 112  $prevmonth = date ( 'm', $prev );
 113  $prevday = date ( 'd', $prev );
 114  $prevdate = sprintf ( "%04d%02d%02d", $prevyear, $prevmonth, $prevday );
 115  
 116  $wkstart = get_weekday_before ( $thisyear, $thismonth, $thisday +1 );
 117  
 118  $wkend = $wkstart + ( ONE_DAY * 7 );
 119  
 120  if ( ! $fit_to_window )
 121    $time_w = '100px';
 122  else
 123    $time_w = '8%'; // 8% for time column
 124  
 125  // Set the day of week range (0=Sun, 6=Sat)
 126  // $start_ind = start of range
 127  // $end_ind = end of range (inclusive)
 128  
 129  if ( $is_day_view ) {
 130    $thistime = mktime ( 0, 0, 0, $thismonth, $thisday, $thisyear );
 131    $start_ind = $end_ind = ( date ( 'w', $thistime ) - $WEEK_START + 7 ) % 7;
 132  } else {
 133    if ( $DISPLAY_WEEKENDS == 'N' ) {
 134      if ( $WEEK_START == 1 ) {
 135        $start_ind = 0;
 136        $end_ind = 4;
 137      } else {
 138        $start_ind = 1;
 139        $end_ind = 5;
 140      }
 141    } else {
 142      $start_ind = 0;
 143      $end_ind = 6;
 144    }
 145  }
 146  
 147  // Generate the column headers for each day and the unix datetime
 148  // values for each date.
 149  for ( $i = $start_ind; $i <= $end_ind; $i++ ) {
 150    $days[$i] = ( $wkstart + ONE_DAY * $i ) + ( 12 * 3600 );
 151    $weekdays[$i] = weekday_name ( ( $i + $WEEK_START ) % 7, $DISPLAY_LONG_DAYS );
 152    $header[$i] = $weekdays[$i] . '<br />' .
 153       month_name ( date ( 'm', $days[$i] ) - 1, 'M' ) .
 154       ' ' . date ( 'd', $days[$i] );
 155    if ( empty ( $first_date ) )
 156      $first_date = date_to_str ( date ( 'Ymd', $days[$i] ), '', false );
 157    $last_date = date_to_str ( date ( 'Ymd', $days[$i] ), '', false );
 158  }
 159  
 160  // The table has dates across the top and times for rows. Since we need
 161  // to spit out an entire row before we can move to the next time slot, we'll
 162  // save up all the HTML for each cell and then print it out when we're
 163  // done.
 164  
 165  $viewusers = view_get_user_list ( $id );
 166  $viewusercnt = count ( $viewusers );
 167  //echo "<pre>"; print_r ( $viewusers ); echo "</pre>\n";
 168  
 169  // Make sure we have at least one user in our view.
 170  // If this is a global view, we may have removed all the users if
 171  // the current user does not have permission to view any of the
 172  // users in the view.
 173  // In theory, we whould always at least have ourselves in the view, right?
 174  if ( $viewusercnt == 0 ) {
 175    // I don't think we need to translate this.
 176    $error = 'No users for this view';
 177  }
 178  
 179  if ( ! empty ( $error ) ) {
 180    echo print_error ( $error );
 181    echo print_trailer ();
 182    exit;
 183  }
 184  
 185  // table_width = width in pixels of entire table
 186  // col_pixels = width of smallest column
 187  // 100 = width of time column on left of table
 188  if ( ! $fit_to_window ) {
 189    $table_width = ( $col_pixels * $viewusercnt ) *
 190      ( $end_ind - $start_ind + 1 ) + 100;
 191  }
 192  //echo "table_width=$table_width<br />\n";
 193  
 194  // tdw is the cell width for each day
 195  if ( ! $fit_to_window )
 196    // pixels
 197    $tdw = floor ( ( $table_width - $time_w ) / ( $end_ind - $start_ind + 1 ) );
 198  else
 199    // %
 200    $tdw = floor ( ( 100 - $time_w ) / ( $end_ind - $start_ind + 1 ) );
 201  
 202  $untimed_found = false;
 203  $get_unapproved = ( $DISPLAY_UNAPPROVED == 'Y' );
 204  // public access events cannot override $DISPLAY_UNAPPROVED
 205  if ( $user == '__public__' && $PUBLIC_ACCESS_VIEW_UNAPPROVED != 'Y' )
 206    $get_unapproved = false;
 207  
 208  // Step through each user and load events for that user.
 209  // Store in $e_save[] (normal events) and $re_save[] (repeating events).
 210  $e_save = array ();
 211  $re_save = array ();
 212  if ( ! $fit_to_window )
 213    $uwf = $col_pixels . 'px';
 214  else
 215    $uwf = sprintf ( "%0.2f", $tdw / $viewusercnt ) . '%';
 216  $uheader = '';
 217  for ( $i = 0; $i < $viewusercnt; $i++ ) {
 218    /* Pre-Load the repeated events for quckier access */
 219    $repeated_events = read_repeated_events ( $viewusers[$i], $wkstart, $wkend, '' );
 220    $re_save[$i] = $repeated_events;
 221    /* Pre-load the non-repeating events for quicker access
 222        subtracting ONE_WEEK to allow cross-day events to display*/
 223    $events = read_events ( $viewusers[$i], $wkstart - ONE_WEEK, $wkend );
 224    $e_save[$i] = $events;
 225    user_load_variables ( $viewusers[$i], 'temp' );
 226    $uheader .= "<th class=\"small\" width=\"$uwf\" style=\"width:$uwf;\">" .
 227      $tempfullname . "</th>\n";
 228    //echo "$viewusers[$i]: loaded " . count ( $events ) . " events<br />\n";
 229  }
 230  $num_users = $viewusercnt;
 231  
 232  // $TIME_SLOTS is set in both admin system settings and user preferences.
 233  if ( empty ( $TIME_SLOTS ) )
 234    $TIME_SLOTS = 24;
 235  $interval = 1440 / $TIME_SLOTS;
 236  $first_slot = (int)( ( ( $WORK_DAY_START_HOUR  ) * 60 ) /
 237    $interval );
 238  $last_slot = (int)( ( ( $WORK_DAY_END_HOUR ) * 60 ) /
 239    $interval );
 240  
 241  ?>
 242  
 243  <div style="width:99%;">
 244  <a title="<?php etranslate ( 'Previous' )?>" class="prev" href="view_r.php?id=<?php echo $id?>&amp;date=<?php echo $prevdate?>"><img src="images/leftarrow.gif" alt="<?php etranslate ( 'Previous' )?>" /></a>
 245  
 246  <a title="<?php etranslate ( 'Next' )?>" class="next" href="view_r.php?id=<?php echo $id?>&amp;date=<?php echo $nextdate?>"><img src="images/rightarrow.gif" class="prevnext" alt="<?php etranslate ( 'Next' )?>" /></a>
 247  <div class="title">
 248  <span class="date"><?php
 249    if ( $is_day_view ) {
 250      echo date_to_str ( date ( 'Ymd', $thistime ), false );
 251    } else {
 252      echo $first_date . "&nbsp;&nbsp;&nbsp; - &nbsp;&nbsp;&nbsp;" .
 253        $last_date;
 254    }
 255  ?></span><br />
 256  <span class="viewname"><?php echo htmlspecialchars ( $view_name ) ?></span>
 257  <?php
 258    if ( $DISPLAY_WEEKNUMBER == 'Y' ) {
 259      echo "<br />\n<span class=\"titleweek\">(" .
 260        translate ( 'Week' ) . ' ' . date('W', $wkstart + ONE_DAY ) . ')</span>';
 261    }
 262  ?>
 263  </div></div><br />
 264  
 265  <?php
 266  $help = ( $can_add ? 'title="' .
 267      translate ( 'Double-click on empty cell to add new entry' ) . '"' : '' );
 268  
 269  if ( ! $fit_to_window ) { ?>
 270  <table <?php echo $help;?> class="main" style="width:<?php
 271    echo $table_width;?>px;" width="<?php echo $table_width;?>">
 272  <?php } else { ?>
 273  <table <?php echo $help;?> class="main" width="100%">
 274  <?php } ?>
 275  
 276  <!-- table header -->
 277  <tr><th class="empty" width="<?php echo $time_w;?>" style="width:<?php echo $time_w;?>;">&nbsp;</th>
 278  <?php
 279    // heading row that displays day of week and date
 280    if ( ! $fit_to_window )
 281      $tdwf = ( $col_pixels * $viewusercnt ) . 'px';
 282    else
 283      $tdwf = sprintf ( "%0.2f", $tdw ) . "%";
 284    $todayYmd = date ( 'Ymd', $today );
 285    for ( $i = $start_ind; $i <= $end_ind; $i++ ) {
 286      if ( is_weekend ( $days[$i] ) && $DISPLAY_WEEKENDS == 'N' ) continue;
 287      if ( $todayYmd == date ( 'Ymd', $days[$i] ) )
 288        $class = 'class="today"';
 289      else if ( is_weekend ( $days[$i] ) )
 290        $class = 'class="weekend"';
 291      else
 292        $class = '';
 293  
 294      echo '<th ' . $class . ' style="width:' . $tdwf . ';" colspan="'
 295       . $num_users . '">' . $header[$i] . "</th>\n";
 296    }
 297  ?>
 298  </tr>
 299  
 300  <tr><th class="empty" width="<?php echo $time_w;?>" style="width:<?php echo $time_w;?>;">&nbsp;</th>
 301  <?php
 302    for ( $i = $start_ind; $i <= $end_ind; $i++ ) {
 303      echo $uheader;
 304    }
 305  ?>
 306  </tr>
 307  <!-- end table header -->
 308  
 309  <?php
 310  
 311  // We need to store all the events and where they go before we begin
 312  // printing any output.
 313  
 314  $all_day = array ();
 315  
 316  //<long-winded-explanation>
 317  // We loop through the events once checking for the start time. If we
 318  // find a start time before the normal work hours, we will reset $first_slot
 319  // to this new time. We do this in a separate loop because all-day events
 320  // will assume a start time slot of the beginning of normal work hours.
 321  // So, if there is an all-day event on Monday, it might use the first_slot
 322  // that represents 8am only to find an event on Thu has a time of 7am which
 323  // would change the first_slot value. There is then a gap above the all-day
 324  // event.
 325  //</long-winded-explanation>
 326  $am_part = array (); // am I a participant array
 327  for ( $d = $start_ind; $d <= $end_ind; $d++ ) {
 328    for ( $u = 0; $u < $viewusercnt; $u++ ) {
 329      $untimed = array ();
 330      $user = $viewusers[$u];
 331      $events = $e_save[$u];
 332      $repeated_events = $re_save[$u];
 333      // get all the repeating events for this date and store in array $rep
 334      $dateYmd = date ( 'Ymd', $days[$d] );
 335      $rep = get_repeating_entries ( $user, $dateYmd );
 336      $repcnt = count ( $rep );
 337      for ( $j = 0; $j < $repcnt; $j++ ) {
 338        if ( ! isset ( $am_part[$rep[$j]->getID ()] ) ) {
 339          $am_part[$rep[$j]->getID ()] =
 340            user_is_participant ( $rep[$j]->getID (), $login );
 341        }
 342        if ( $get_unapproved || $rep[$j]->getStatus () == 'A' ) {
 343          if ( $rep[$j]->getDuration () > 0 &&
 344            $rep[$j]->getDuration () != 1440 ) {
 345            $slot = calc_time_slot ( $rep[$j]->getTime (), false );
 346            if ( $slot < $first_slot ) {
 347              $first_slot = $slot;
 348            }
 349          }
 350        }
 351      }
 352      $ev = get_entries ( $dateYmd, $get_unapproved, 1, 1);
 353      $evcnt = count ( $ev );
 354      for ( $j = 0; $j < $evcnt; $j++ ) {
 355        if ( ! isset ( $am_part[$ev[$j]->getID ()] ) ) {
 356          $am_part[$ev[$j]->getID ()] =
 357            user_is_participant ( $ev[$j]->getID (), $login );
 358        }
 359        if ( $ev[$j]->getDuration () > 0 &&
 360          $ev[$j]->getDuration () != 1440 ) {
 361          $slot = calc_time_slot ( $ev[$j]->getTime (), false );
 362          if ( $slot < $first_slot ) {
 363            $first_slot = $slot;
 364          }
 365        }
 366      }
 367    }
 368  }
 369  
 370  for ( $d = $start_ind; $d <= $end_ind; $d++ ) {
 371    for ( $u = 0; $u < $viewusercnt; $u++ ) {
 372      $untimed = array ();
 373      $user = $viewusers[$u];
 374      $events = $e_save[$u];
 375      $repeated_events = $re_save[$u];
 376      // get all the repeating events for this date and store in array $rep
 377      $dateYmd = date ( 'Ymd', $days[$d] );
 378      $rep = get_repeating_entries ( $user, $dateYmd );
 379      $cur_rep = 0;
 380  
 381      // Get static non-repeating events
 382      $ev = get_entries ( $dateYmd, $get_unapproved, 1, 1 );
 383      $hour_arr = array ();
 384      $rowspan_arr = array ();
 385      $evcnt = count ( $ev );
 386      $repcnt = count ( $rep );
 387      for ( $i = 0; $i < $evcnt; $i++ ) {
 388        // print out any repeating events that are before this one...
 389        while ( $cur_rep < $repcnt &&
 390          $rep[$cur_rep]->getTime () < $ev[$i]->getTime () ) {
 391          if ( $get_unapproved || $rep[$cur_rep]->getStatus () == 'A' ) {
 392            if ( $rep[$cur_rep]->getDuration () == 1440 )
 393              $all_day[$d] = 1;
 394            html_for_event_week_at_a_glance ( $rep[$cur_rep], $dateYmd, 'small', $show_time );
 395          }
 396          $cur_rep++;
 397        }
 398        if ( $get_unapproved || $ev[$i]->getStatus () == 'A' ) {
 399          if ( $ev[$i]->getDuration () == 1440 )
 400            $all_day[$d] = 1;
 401          html_for_event_week_at_a_glance ( $ev[$i], $dateYmd, 'small', $show_time );
 402          //echo "Found event date=$dateYmd name='$viewname'<br />\n";
 403          //print_r ( $rowspan_arr );
 404        }
 405      }
 406      // print out any remaining repeating events
 407      while ( $cur_rep < $repcnt ) {
 408        if ( $get_unapproved || $rep[$cur_rep]->getStatus () == 'A' ) {
 409          if ( $rep[$cur_rep]->getDuration () == 1440 )
 410            $all_day[$d] = 1;
 411          html_for_event_week_at_a_glance ( $rep[$cur_rep], $dateYmd, 'small', $show_time );
 412        }
 413        $cur_rep++;
 414      }
 415  
 416      // squish events that use the same cell into the same cell.
 417      // For example, an event from 8:00-9:15 and another from 9:30-9:45 both
 418      // want to show up in the 8:00-9:59 cell.
 419      $rowspan = 0;
 420      $last_row = -1;
 421      for ( $i = 0; $i < $TIME_SLOTS; $i++ ) {
 422        if ( $rowspan > 1 ) {
 423          if ( !empty ( $hour_arr[$i] ) ) {
 424            if ( $rowspan_arr[$i] > 1 ) {
 425              $rowspan_arr[$last_row] += ( $rowspan_arr[$i] - 1 );
 426              $rowspan += ( $rowspan_arr[$i] - 1 );
 427            } else
 428              $rowspan_arr[$last_row] += $rowspan_arr[$i];
 429            // this will move entries apart that appear in one field,
 430            // yet start on different hours
 431            $start_time = $i;
 432            $diff_start_time = $start_time - $last_row;
 433            for ( $x = $diff_start_time; $x > 0; $x-- )
 434              $hour_arr[$last_row] .= "<br />\n";
 435            $hour_arr[$last_row] .= $hour_arr[$i];
 436            $hour_arr[$i] = '';
 437            $rowspan_arr[$i] = 0;
 438          }
 439          $rowspan--;
 440        } else if ( !empty ( $rowspan_arr[$i] ) && $rowspan_arr[$i] > 1 ) {
 441          $rowspan = $rowspan_arr[$i];
 442          $last_row = $i;
 443        }
 444      }
 445  
 446      // now save the output...
 447      if ( ! empty ( $hour_arr[9999] ) && strlen ( $hour_arr[9999] ) ) {
 448        $untimed[$d] = $hour_arr[9999];
 449        $untimed_found = true;
 450      }
 451      $save_hour_arr[$u][$d] = $hour_arr;
 452      $save_rowspan_arr[$u][$d] = $rowspan_arr;
 453      $save_untimed[$u][$d] = $untimed;
 454    }
 455  }
 456  
 457  // untimed events first
 458  if ( $untimed_found || $show_untimed_row_always ) {
 459    echo '<tr><th class="empty" width="' .$time_w. '" style="width:'
 460     . $time_w . ';">&nbsp;</th>' . "\n";
 461    for ( $d = $start_ind; $d <= $end_ind; $d++ ) {
 462      $dateYmd = date ( 'Ymd', $days[$d] );
 463      $is_weekend = is_weekend ( $days[$d] );
 464      if ( $is_weekend  && $DISPLAY_WEEKENDS == 'N' ) continue;
 465      if ( $dateYmd == $todayYmd )
 466        $class .= 'class="today"';
 467      else if ( $is_weekend )
 468        $class .= 'class="weekend"';
 469      else
 470        $class = '';
 471      for ( $u = 0; $u < $viewusercnt; $u++ ) {
 472        $untimed = $save_untimed[$u][$d];
 473        // Unset class from above if needed.
 474        if ( $class == 'class="hasevents"' )
 475          $class = '';
 476        // Use the class 'hasevents' for any hour block that has events
 477        // in it.
 478        if ( !empty ( $untimed[$d] ) && strlen ( $untimed[$d] ) ) {
 479          $class = 'class="hasevents"';
 480        }
 481  
 482        echo "<td $class ";
 483        if ( $can_add ) {
 484          echo " ondblclick=\"dblclick( '$dateYmd', '$viewusers[$u]' )\"";
 485        }
 486        echo '>';
 487  
 488        if ( !empty ( $untimed[$d] ) && strlen ( $untimed[$d] ) ) {
 489          echo $untimed[$d];
 490        } else {
 491          echo '&nbsp;';
 492        }
 493        echo "</td>\n";
 494      }
 495    }
 496    echo "</tr>\n";
 497  }
 498  
 499  $rowspan_day = array ();
 500  for ( $u = 0; $u < $viewusercnt; $u++ ) {
 501    for ( $d = $start_ind; $d <= $end_ind; $d++ )
 502      $rowspan_day[$u][$d] = 0;
 503  }
 504  
 505  for ( $i = $first_slot; $i <= $last_slot; $i++ ) {
 506    $time_h = ( int ) ( ( $i * $interval ) / 60 );
 507    $time_m = ( $i * $interval ) % 60;
 508    $time = display_time ( ( $time_h * 100 + $time_m ) * 100, 1 );
 509    echo "<tr>\n<th valign=\"top\" class=\"row\" width=\"$time_w" .
 510      '">' . $time . "</th>\n";
 511    //echo "<tr>\n<th valign=\"top\">" . $time . "</th>\n";
 512  
 513    for ( $d = $start_ind; $d <= $end_ind; $d++ ) {
 514      $dateYmd = date ( 'Ymd', $days[$d] );
 515      for ( $u = 0; $u < $viewusercnt; $u++ ) {
 516        $hour_arr = $save_hour_arr[$u][$d];
 517        $rowspan_arr = $save_rowspan_arr[$u][$d];
 518        $is_weekend = is_weekend ( $days[$d] );
 519        if ( $dateYmd == $todayYmd )
 520          $class .= 'class="today"';
 521        else if ( $is_weekend )
 522          $class .= 'class="weekend"';
 523        else
 524          $class = '';
 525        // Use the class 'hasevents' for any hour block that has events
 526        // in it.
 527        if ( ! empty ( $hour_arr[$i] ) && strlen ( $hour_arr[$i] ) ) {
 528          $class = 'class="hasevents"';
 529        }
 530  
 531        if ( $rowspan_day[$u][$d] > 1 ) {
 532          // this might mean there's an overlap, or it could mean one event
 533          // ends at 11:15 and another starts at 11:30.
 534          if ( !empty ( $hour_arr[$i] ) ) {
 535            echo "<td $class>" . $hour_arr[$i]. "</td>\n";
 536          }
 537          $rowspan_day[$u][$d]--;
 538        } else {
 539          if ( empty ( $hour_arr[$i] ) ) {
 540            echo "<td $class ";
 541            if ( $can_add ) {
 542              echo " ondblclick=\"dblclick( '$dateYmd', "
 543                . "'$viewusers[$u]', '$time_h', '$time_m' )\"";
 544            }
 545            echo '>';
 546            //if ( $can_add ) {        //if user can add events...
 547            //  echo html_for_add_icon ( $dateYmd,
 548            //    $time_h, $time_m, $user );        //..then echo the add event icon
 549            //}
 550            echo "&nbsp;</td>\n";
 551          } else {
 552            $rowspan_day[$u][$d] = $save_rowspan_arr[$u][$d][$i];
 553            if ( $rowspan_day[$u][$d] > 1 ) {
 554              echo "<td $class ";
 555              echo ' rowspan="' . $rowspan_day[$u][$d] . '"';
 556              if ( $can_add ) {
 557                echo " ondblclick=\"dblclick( '$dateYmd', "
 558                  . "'$user', '$time_h', '$time_m' )\"";
 559              }
 560              echo '>';
 561              //if ( $can_add ) {
 562              //  echo html_for_add_icon ( $dateYmd, $time_h,
 563              //    $time_m, $user );
 564              //}
 565              echo $hour_arr[$i]."</td>\n";
 566            } else {
 567              echo "<td $class ";
 568              if ( $can_add ) {
 569                echo " ondblclick=\"dblclick( '$dateYmd', "
 570                  . "'$user', '$time_h', '$time_m' )\"";
 571              }
 572              echo '>';
 573              //if ( $can_add ) {
 574              //  echo html_for_add_icon ( $dateYmd, $time_h,
 575              //    $time_m, $user );
 576              //}
 577              echo $hour_arr[$i]."</td>\n";
 578            }
 579          }
 580        }
 581      }
 582    }
 583    echo "</tr>\n";
 584  }
 585  
 586  ?>
 587  
 588  </table>
 589  <script language="javascript" type="text/javascript">
 590  <!-- <![CDATA[
 591  function dblclick ( date, name, hour, minute ) {
 592  
 593   if ( ! minute )
 594    minute = 0;
 595   if ( hour ){
 596     time = "&hour=" + hour + "&minute=" + minute;
 597   } else {
 598     time = "&duration=1440";
 599   }
 600   var url = 'edit_entry.php?date=' + date
 601     + '&defusers=' + name + time;
 602  
 603   window.location.href  = url;
 604  }
 605  //]]> -->
 606  </script>
 607  <?php
 608  
 609  $user = ''; // reset
 610  
 611  if ( ! empty ( $eventinfo ) ) echo $eventinfo;
 612  
 613  echo $printerStr;
 614  echo print_trailer (); ?>
 615  

title

Description

title

Description

title

Description

title

title

Body