Menu

#275 Weekly Multi-Room View.

open
nobody
None
1
2019-12-10
2014-07-25
Anonymous
No

I'd like to have the option of generating a weekly view that on the vertical column shows the day of the week and the horizontal row shows the rooms. Similar to how the yearly calendar just lists the times they're scheduled off to the side. I'm likely going to try to get this working myself after I creep through the code a bit more. I was just wondering if this is something you guys had thought about attempting or had an easy way for me to do it?

Related

DO NOT USE - Feature Requests: #275

Discussion

1 2 > >> (Page 1 of 2)
  • Woodroffe UC Webmaster

    I created a page like, this, but left off the links to allow editing of meetings. We use it to print a copy of the weekly schedule. The screen shot shows what it looks like.

     
    • Anonymous

      Anonymous - 2017-11-13

      Your code is amazing! Thank you. May I ask:
      1) How do you get some of the bookings in bold?
      2) How you get vertical line between rooms down through the days?

      see attached screenshot of our version

       

      Last edit: Anonymous 2017-11-15
  • Woodroffe UC Webmaster

    Here is the code for the weekly summary report (week_summary.php).
    This page is called from a link I've added to week.php, of course, with appropriate styles added to css/mrbs.css.php:

    echo make_room_select_html('week.php', $area, $room, $year, $month, $day);
    
    // *** Added by Jamie Hockin Aug 2014
    // *** Display link to week_summary
    echo "<div id=\"print_summary\"><h3>Print summary</h3>\n";
    echo "<a href=\"week_summary.php?year=$year&amp;month=$month&amp;day=$day&amp;area=$area&amp;room=$room\">";
    echo "... for this week</a></div>";
    // *** End of addition
    
    // Draw the three month calendars
    if (!$display_calendar_bottom)
    {
      minicals($year, $month, $day, $area, $room, 'week');
    }
    
     
    • Anonymous

      Anonymous - 2016-07-27

      Hello Woodroffe UC Webmaster,

      The above is exactly what I've been looking for, so thank you for creating this - and for sharing. I've tried the instructions above, and the link appears on the week view page, but when you click it, it returns a fatal error saying the database is not available at the moment - is there something else I should be changing somewhere? I hope you get to see this as your post is obviously almost two years ago.

      Many thanks again.

      Rob.

       
  • Woodroffe UC Webmaster

    Hi Rob,
    The problem will be that I have a custom field real_start_time in the SQL on line 165 of weekly_summary.php. The SQL error triggers the 'database not available' error message.
    You will have to remove all references to this field in the code. If that is a problem, let me know and I'll revise the code.
    Jamie

     
  • Anonymous

    Anonymous - 2016-07-27

    Hi Jamie,

    Thanks for the response. I've just tried to remove the appropriate code, but I'm not a SQL guy, so I still can't get it to work - If you could revise it, I'd be REALLY greatful thanks.

    Rob.

     
  • Woodroffe UC Webmaster

    Here is the generic version. It will not work for installations that use periods. It also ignores Area and will try to show all rooms (I think).
    Jamie

     
  • Lance Jones

    Lance Jones - 2017-06-30

    That is very kind of you Sir, I am so grateful. It worked first time. Bless you.

     
  • Woodroffe UC Webmaster

    Sorry about that. This is not our production version yet. This one fixes the problem.

    However, it seems to put some bookings on the wrong day for me. I'll look at it later today.

     

    Last edit: Woodroffe UC Webmaster 2017-06-30
  • Lance Jones

    Lance Jones - 2017-06-30

    Thank you Sir

     
  • Woodroffe UC Webmaster

    Do you mean that the day names are not in the correct language? The names come from the PHP date function, which follows the default locale for your server. They should be the same names shown elsewhere in MRBS as far as I can see.

     
  • Campbell Morrison

    Unfortunately date() doesn't respect locales and everything comes out in English. The rest of MRBS uses strftime(), or rather the MRBS function utf8_strfime() which wraps the standard PHP function in a multi-byte safe wrapper.

     
  • Woodroffe UC Webmaster

    Thanks. We are spoiled, working in English. I've modified week_summary to use utf8_strftime. I'll plan to stay with the MRBS standard approach for any future modifications.

     
  • Anonymous

    Anonymous - 2017-11-15

    Your code is amazing! Thank you. May I ask:
    1) How do you get some of the bookings in bold?
    2) How you get vertical line between rooms down through the days?
    I can't find it in the css

     
    • Woodroffe UC Webmaster

      Each booking listing is wrapped in <span class=sum_x> ... </span> so you can add styles in mrbs.css.php like
      span.sum_I {font-weight: bold;}
      to make all of the entries with type I bold (or any other block styling you want)

       
      • Campbell Morrison

        Even better would be to put any changes you want to make in a custom CSS file (see systemdefaults.inc.php for how). That way they will survive a release upgrade.

         
  • Anonymous

    Anonymous - 2017-11-17

    I am sorry to be annoying but I am really struggling with some code and I would be ever so grateful if one of you fine gentlemen could help me. I am trying to make vertical grey column lines on the weekly Summary and I think I need to insert some code for border-left inside the table. I have tried all sorts of things like:

    echo "<p style='border-left:1px grey solid;'>".$main_table_body_v_border_color."</p>";
    

    But that doesn;t really help. I think I should be making an edit to mrbs.css but I don't know.
    Can anyone help me?

    This is a link to the page:
    http://www.addlestonecommunityassociation.org/mrbs-1.6.1/web/week_summary.php?year=2017&month=11&day=17&area=1&room=1

    And the weekly summary code is:

    <?php
    // $Id: week_summary.php 
    
    namespace MRBS;
    
    global $week_first_day;
    global $page_level;
    require_once "defaultincludes.inc";
    require_once "mincals.inc";
    require_once "functions_table.inc";
    
    // week_summary_table_innerhtml 
    // This function is called by week_summary.php via a link that appears in the header
    // Create the summary table showing all bookings for one week, by room
    
    // Check the user is authorised for this page
    $page_level['week_summary.php']  = ($auth['deny_public_access']) ? 1 : 0;
    checkAuthorised();
    $num_of_days=7; // days in a week
    
    $inner_html = week_summary_table_innerhtml($day, $month, $year, $room, $area, $num_of_days);
    
    function week_summary_table_innerhtml($day, $month, $year, $room, $area, $num_of_days)
    {
      global $tbl_entry, $tbl_room, $tbl_area;
      global $times_along_top, $row_labels_both_sides, $column_labels_both_ends;
      global $resolution, $morningstarts, $morningstarts_minutes, $eveningends, $eveningends_minutes;
      global $weekstarts, $strftime_format;
      global $week_first_day;
    
      // ensure that $morningstarts_minutes defaults to zero if not set
      if (!isset($morningstarts_minutes))
      {
        $morningstarts_minutes = 0;
      }
    
      // Calculate how many days to skip back to get to the start of the week
      $time = mktime(12, 0, 0, $month, $day, $year);
      $skipback = (date("w", $time) - $weekstarts + 7) % 7;
      $day_start_week = $day - $skipback-0;
      // We will use $day for links and $day_start_week for anything to do with showing the bookings,
      // because we want the booking display to start on the first day of the week (eg Sunday if $weekstarts is 0)
      // but we want to preserve the notion of the current day (or 'sticky day') when switching between pages
    
      // start of week
      $first_start = get_start_first_slot($month,$day_start_week,$year);
      $last_end = get_start_last_slot($month, $day_start_week+7, $year);
    
      // now want to get bookings for each day
      // We need to know what all the rooms are called, so we can show them all.
      // Pull the data from the db and store it. Conveniently we can print the room
      // headings and capacities at the same time
    
      $rooms = get_rooms($area);
    
      // It might be that there are no rooms defined for this area.
      // If there are none then show an error and don't bother doing anything
      // else
      if (! $rooms)
      {
        trigger_error(sql_error(), E_USER_WARNING);
        fatal_error(FALSE, " Oops - no rooms found - Week summary query");
      }
    
      // TABLE HEADER
      $thead = "<thead>\n";
      $header_inner = "<tr>\n";
    
      // the standard view, with rooms along the top and days down the side
      $header_inner .= "<th class='first_last'>" . "Day" . ":</th>";
    
      $column_width = (int)(95 / sizeOf($rooms));
    
      foreach ($rooms as $row)
      {
        // Put the room_id in a data attribute so that JavaScript can pick it up
        $header_inner .= "<th data-room='" . $row['id'] . "' style='width: $column_width%'>
                          <a href='week.php?year=$year&amp;month=$month&amp;day=$day&amp;area=$area&amp;room=".$row['id'] . "'
                          title=''" . get_vocab("viewweek") . " &#10;&#10;" . $row['description']."'>" .
                          htmlspecialchars($row['room_name']) . "</a></th>";
    //    save room name as it won't come with entry
        $room_name[$row['id']] = $row['room_name'];
      }
    
      // next line to display times on right side
      if ( FALSE != $row_labels_both_sides )
      {
        $header_inner .= "<th class='first_last'>" . get_vocab("time") . ":</th>";
      }
    
      $thead .= $header_inner;
      $thead .= "</thead>\n";
      // Now repeat the header in a footer if required
      $tfoot = ($column_labels_both_ends) ? "<tfoot>\n$header_inner</tfoot>\n" : '';
    
      // TABLE BODY LISTING BOOKINGS
      $tbody = "<tbody>\n";
    
    // find all meetings for the week (Sunday to Sunday)
      $entries = get_entries_by_area($area,$first_start,$last_end);
      foreach($entries as $mtg)
      {
        $room = $mtg['room_id'];
        $dow = floor(($mtg['start_time']-$first_start)/86400);
    // key 'n' holds the number of bookings for this room on this day
        if (isset($week_map[$room][$dow][0]['n']))
        {
            $n = ++$week_map[$room][$dow][0]['n'];
        }
        else
        {
            $n = $week_map[$room][$dow][0]['n'] = 0;
        }
    
    // temp variables for fields used
            $this_desc = $mtg['name'];
            $this_start = utf8_strftime(hour_min_format(),$mtg['start_time']);
            $this_end = utf8_strftime(hour_min_format(),$mtg['end_time']);
            $this_type = $mtg['type'];
        $this_info = $mtg['description'];
            $this_room = $room_name[$room];
    
    // save required fields for calendar display
            $week_map[$room][$dow][$n]['desc'] = $this_desc;
            $week_map[$room][$dow][$n]['start_time'] = $this_start;
            $week_map[$room][$dow][$n]['end_time'] = $this_end;
            $week_map[$room][$dow][$n]['type'] = $this_type;
    
    // add all types to list of all meetings
            $all_mtg[$dow][] = "$this_start-$this_end $this_room</td><td>$this_desc</td><td>$this_setup $this_custodian" ;
      }
    
    // now loop through days to print out meetings for rooms in this area
      $row_class="";
      for ($j = 0; $j<$num_of_days ; $j++)
      {
          if ($row_class=="even") {
            $row_class = "odd";
          } else {
            $row_class = "even";
          }
        $this_day = get_start_first_slot($month,$day_start_week+$j,$year);
    // make a view with rooms across the top, day on the left and times/descriptions in the cells for today
    
        $tbody .= "<tr class='$row_class'>\n";
    // display partial date from $am7
        $tbody .= "<td><h2>" . date("l",$this_day) . "<br>" . date("d",$this_day) . "</h2></td>";
    
        // Loop through the list of rooms we have for this area
        foreach($rooms as $row)
        {
          $room_id = $row["id"];
      // fill a cell with the bookings for each room
    
            $tbody .= "<td>";
            $room_mtg = $week_map[$room_id][$j];
            if (isset($room_mtg[0]))
            {
                $imax = $room_mtg[0]['n'];
                    for ($i = 0; $i<= $imax; $i++)
                    {
                        $amtg = $room_mtg[$i];
                        $tbody .= "<span class=sum_" . $amtg['type'] . ">" . $amtg['start_time'] . "-" . $amtg['end_time'];
                        $tbody .= " " . $amtg['desc'] . "</span><br />";
    
                    }
            }
          }
    
        $tbody .= "</tr>\n";
      }
      $tbody .= "</tbody>\n";
    
    // save first day of the week for header
      $week_first_day = "<div id='dwm'><h1>" .
        get_vocab("Week Commencing") .
        "<br>" .
        date('l j F, Y',$first_start) .
        "</h1></div>\n";
    
      return $thead . $tbody . $tfoot ;
    } // function week_summary_table_innerhtml
    
    // print the page header
    print_header($day, $month, $year, $area, isset($room) ? $room : "");
    
    // Skip the section with areas, rooms, minicals.
    
    // Show the dates for this week
    print $week_first_day;
    
    //y? are year, month and day of the previous week.
    //t? are year, month and day of the next week.
    
    $i= mktime(12,0,0,$month,$day-7,$year);
    $yy = date("Y",$i);
    $ym = date("m",$i);
    $yd = date("d",$i);
    
    $i= mktime(12,0,0,$month,$day+7,$year);
    $ty = date("Y",$i);
    $tm = date("m",$i);
    $td = date("d",$i);
    
    // Show Go to week before and after links
    $before_after_links_html = "
    <div class='screenonly'>
      <nav class='date_nav'>
        <a class='date_before' href='week_summary.php?year=$yy&amp;month=$ym&amp;day=$yd&amp;area=$area&amp;room=$room'>"
          .get_vocab("weekbefore")."
          </a>" .
    // Centre link returns to normal week view
        "<a class='date_now' href='week.php?area=$area&amp;room=$room'>
              ".get_vocab("Return To This Week")."
          </a>" .
    //
        "<a class='date_after' href='week_summary.php?year=$ty&amp;month=$tm&amp;day=$td&amp;area=$area&amp;room=$room'>
              ".get_vocab("weekafter").
          "</a>
    </nav>"
    ;
    print $before_after_links_html;
    echo "<h4>";
    
    echo "<table class='dwm_main' id='week_main'>";
    echo $inner_html;
    echo "</table>\n";
    
    print $before_after_links_html;
    
    require_once "trailer.inc";
    
    ?>
    
     
  • Woodroffe UC Webmaster

    You should not add any styling code to the line that displays the cells. The default borders for your MRBS theme are used to show the lines (or not).

    In Themes/default/styling.inc, line 29 sets the vertical border colours for the main table. In the default theme, this is provided 'out of the box' as:

    $main_table_body_v_border_color = $body_background_color;

    i.e. the borders are not visible.
    I suggest you change this to:

    $main_table_body_v_border_color = "#ffffff";

    Then it will match the horizontal lines.

    There were two extra lines in week_summary-1.6.1b.php (that did not cause any problem but may lead to PHP warnings) and I've removed them in this version.

     
1 2 > >> (Page 1 of 2)
MongoDB Logo MongoDB