Revision: 1258
          http://mrbs.svn.sourceforge.net/mrbs/?rev=1258&view=rev
Author:   cimorrison
Date:     2009-11-12 00:35:47 +0000 (Thu, 12 Nov 2009)

Log Message:
-----------
Added pending.php listing outstanding provisional reservations

Modified Paths:
--------------
    mrbs/branches/provisional_bookings/web/Themes/classic126/styling.inc
    mrbs/branches/provisional_bookings/web/Themes/default/header.inc
    mrbs/branches/provisional_bookings/web/Themes/default/styling.inc
    mrbs/branches/provisional_bookings/web/lang.en
    mrbs/branches/provisional_bookings/web/mrbs.css.php

Added Paths:
-----------
    mrbs/branches/provisional_bookings/web/pending.php

Modified: mrbs/branches/provisional_bookings/web/Themes/classic126/styling.inc
===================================================================
--- mrbs/branches/provisional_bookings/web/Themes/classic126/styling.inc        
2009-11-11 21:51:25 UTC (rev 1257)
+++ mrbs/branches/provisional_bookings/web/Themes/classic126/styling.inc        
2009-11-12 00:35:47 UTC (rev 1258)
@@ -87,6 +87,11 @@
     'I' => "#DDFFDD",
     'J' => "#CCCCCC");
      
+// colours used for pending.php and provisional bookings
+$outstanding_color         = "#FF4444"; // font colour for the outstanding 
reservations message in the header
+$pending_header_back_color = $header_back_color; // background colour for 
series headers
+$series_entry_back_color   = "#FFFBC2"; // background colour for entries in a 
series
+$pending_control_color     = "#FFF36C"; // background colour for the series 
+/- controls in pending.php
 
 // ***** DIMENSIONS *******************
 $banner_border_width          = '1';  // (px)  border width for the outside of 
the banner

Modified: mrbs/branches/provisional_bookings/web/Themes/default/header.inc
===================================================================
--- mrbs/branches/provisional_bookings/web/Themes/default/header.inc    
2009-11-11 21:51:25 UTC (rev 1257)
+++ mrbs/branches/provisional_bookings/web/Themes/default/header.inc    
2009-11-12 00:35:47 UTC (rev 1258)
@@ -6,8 +6,11 @@
 function print_theme_header($day, $month, $year, $area, $room)
 {
   global $mrbs_company, $mrbs_company_logo, $mrbs_company_url, 
$mrbs_company_more_info,
-    $search_str, $locale_warning;
+         $search_str, $locale_warning, $provisional_enabled;
+  global $tbl_entry;
   global $PHP_SELF;
+  
+  $page = basename($PHP_SELF, ".php" );
 
   // If we dont know the right date then make it up 
   if (!$day)
@@ -135,13 +138,92 @@
   }
 }
 
+<?php
+if ($page == 'pending')
+{
+?>
+  // test whether array contains element
+  function contains(array, element)
+  {
+    for (var i=0; i<array.length; i++)
+    {
+      if (array[i] == element)
+      {
+        return true;
+      }
+    }
+    return false;
+  }
+  
+  // Remove duplicates from an array
+  function unique(array)
+  {
+    temp = new Array();
+    for (var i=0; i<array.length; i++)
+    {
+      if (!contains(temp, array[i]))
+      {
+        temp.push(array[i]);
+      }
+    }
+    return temp;
+  }
+  
+  // Toggle a sub-table in the pending_list table to make it 
maximised/minimised
+  function toggle_table(id)
+  { 
+    var table = document.getElementById(id);
+    if (table.className == 'minimised')
+    {
+      table.className = 'maximised';
+      table.firstChild.firstChild.firstChild.innerHTML = '-';
+    }
+    else
+    {
+      table.className = 'minimised';
+      table.firstChild.firstChild.firstChild.innerHTML = '+';
+    }
+  }
+
+  
+  // Put a + control in the first cell of all the series headers on the 
pending.php page
+  // and minimise the tables (except for those tables listed in the cookie)
+  function activate_sub_tables()
+  {
+    // Go through each sub-table and minimise it
+    var tables = document.getElementsByTagName('table');
+    for (var i = 0; (element = tables[i]) != null; i++)
+    {
+      if (tables[i].className.indexOf('maximised') >= 0)
+      {
+        tables[i].className = 'minimised';
+        tables[i].firstChild.firstChild.firstChild.innerHTML = '+'; 
+      } 
+    }
+     
+    // now make the table visible (if it's there at all - which it won't be 
when you 
+    // log off from pending.php
+    if (document.getElementById('pending_list'))
+    {
+      document.getElementById('pending_list').style.visibility = 'visible';
+    }
+  }
+  
+  
+  
+<?php
+}
+?>
+
 //]]>
     </script>
   </head>
   <?php
   // Put the filename in as a class to aid styling.   
   // (Use a class rather than id to avoid specificity problems)
-  echo "<body class=\"" . basename($PHP_SELF,".php" ) . "\">\n";
+  $body_tag = "<body class=\"$page\"";
+  $body_tag .= ($page == 'pending') ? " onLoad=\"activate_sub_tables()\"" : "";
+  echo "$body_tag\n";
   ?>
     <div class="screenonly">
 
@@ -214,6 +296,29 @@
             <input type="submit" value="<?php echo get_vocab("goto") ?>">
           </div>
         </form>
+        <?php
+        // Provide a link to the list of outstanding provisional bookings
+        $user = getUserName();
+        if ($provisional_enabled && (authGetUserLevel($user) >= 1))
+        {
+          $is_admin = (authGetUserLevel($user) >= 2);
+          // Find out how many provisional bookings there are
+          $sql = "SELECT COUNT(*) FROM $tbl_entry WHERE status=" . 
STATUS_PROVISIONAL;
+          if (!$is_admin)
+          {
+            // Ordinary users can only see their own
+            $sql .= " AND create_by='" . addslashes($user) . "'";
+          }
+          $n_outstanding = sql_query1($sql);
+          echo "<div id=\"n_outstanding\"" .
+               (($n_outstanding > 0) ? " class=\"outstanding\"" : '') .
+               ">\n";
+          echo "<a 
href=\"pending.php?day=$day&amp;month=$month&amp;year=$year&amp;area=$area" . 
+               ((!empty($room)) ? "&amp;room=$room" : "") . 
+               "\">$n_outstanding " . get_vocab("outstanding") . "</a>\n";
+          echo "</div>\n";
+        }
+        ?>
       </td>
       <?php
       $query_str = "day=$day&amp;month=$month&amp;year=$year";

Modified: mrbs/branches/provisional_bookings/web/Themes/default/styling.inc
===================================================================
--- mrbs/branches/provisional_bookings/web/Themes/default/styling.inc   
2009-11-11 21:51:25 UTC (rev 1257)
+++ mrbs/branches/provisional_bookings/web/Themes/default/styling.inc   
2009-11-12 00:35:47 UTC (rev 1258)
@@ -86,6 +86,11 @@
     'I' => "#99cc66",
     'J' => "#e6ffe6"); 
 
+// colours used for pending.php and provisional bookings
+$outstanding_color         = "#FFF36C"; // font colour for the outstanding 
reservations message in the header
+$pending_header_back_color = $header_back_color;; // background colour for 
series headers
+$series_entry_back_color   = "#FFFCDA"; // background colour for entries in a 
series
+$pending_control_color     = "#FFF36C"; // background colour for the series 
+/- controls in pending.php
     
 // ***** DIMENSIONS *******************
 $banner_border_width          = '0';  // (px)  border width for the outside of 
the banner

Modified: mrbs/branches/provisional_bookings/web/lang.en
===================================================================
--- mrbs/branches/provisional_bookings/web/lang.en      2009-11-11 21:51:25 UTC 
(rev 1257)
+++ mrbs/branches/provisional_bookings/web/lang.en      2009-11-12 00:35:47 UTC 
(rev 1258)
@@ -22,6 +22,7 @@
 $vocab["help"]               = "Help";
 $vocab["search"]             = "Search";
 $vocab["not_php3"]           = "WARNING: This probably doesn't work with PHP3";
+$vocab["outstanding"]        = "pending bookings";
 
 // Used in day.php
 $vocab["bookingsfor"]        = "Bookings for";
@@ -143,6 +144,10 @@
 $vocab["reason"]              = "Reason";
 $vocab["info_requested"]      = "Information requested";
 
+// Used in pending.php
+$vocab["pending"]            = "Provisional bookings awaiting approval";
+$vocab["none_outstanding"]   = "You have no provisional bookings waiting to be 
approved.";
+
 // Authentication stuff
 $vocab["accessdenied"]       = "Access Denied";
 $vocab["norights"]           = "You do not have access rights to modify this 
item.";

Modified: mrbs/branches/provisional_bookings/web/mrbs.css.php
===================================================================
--- mrbs/branches/provisional_bookings/web/mrbs.css.php 2009-11-11 21:51:25 UTC 
(rev 1257)
+++ mrbs/branches/provisional_bookings/web/mrbs.css.php 2009-11-12 00:35:47 UTC 
(rev 1258)
@@ -635,6 +635,8 @@
     border: <?php echo $main_table_cell_border_width ?>px solid <?php echo 
$main_table_body_h_border_color ?>}
 #colour_key td#row_padding {border-right: 0; border-bottom: 0}
 #header_search input {width: 6.0em}
+div#n_outstanding {margin-top: 0.5em}
+#banner .outstanding a {color: <?php echo $outstanding_color ?>}
 
 /* ------------ HELP.PHP ------------------------*/
 table#version_info {border-spacing: 0; border-collapse: collapse}
@@ -659,6 +661,30 @@
 td#sticky_day {border: 1px dotted <?php echo $highlight_font_color ?>}
 td.mincals_week_number { opacity: 0.5; font-size: 60%; }
 
+/* ------------ PENDING.PHP ------------------*/
+table#pending_list {width: 100%}
+#pending_list form {float: left; margin: 0 0.5em}
+#pending_list table {width: 100%; border-spacing: 0px; border-collapse: 
collapse; border: 0}
+#pending_list td.sub_table {padding: 0; margin: 0}
+#pending_list table.minimised tbody {display: none}
+#pending_list table th {border-top: 1px solid <?php echo 
$admin_table_header_sep_color ?>;
+                        background-color: <?php echo 
$pending_header_back_color ?>}
+#pending_list .control {padding-left: 0; padding-right: 0; text-align: center;
+                        color: <?php echo $standard_font_color ?>}
+#pending_list th.control + th {border-left-width: 0}
+#pending_list td.control + td {border-left-width: 0}
+#pending_list table th.control{background-color: <?php echo 
$pending_control_color ?>; cursor: default}
+#pending_list table th a {color: <?php echo $admin_table_header_font_color ?>}
+#pending_list table td {border-color: <?php echo $pending_header_back_color ?>;
+                        background-color: <?php echo $series_entry_back_color 
?>}
+#pending_list .control             {width: 1.2em}
+#pending_list th.header_name       {width: 10%}
+#pending_list th.header_create     {width: 10%}
+#pending_list th.header_area       {width: 10%}
+#pending_list th.header_room       {width: 10%}
+#pending_list th.header_action     {width: 20em}
+#pending_list table th.header_start_time {text-transform: uppercase}
+
 /* ------------ REPORT.PHP ----------------------*/
 .div_report h2, #div_summary h1 {border-top: 2px solid <?php echo 
$report_h2_border_color ?>;
     padding-top: 0.5em; margin-top: 2.0em}

Added: mrbs/branches/provisional_bookings/web/pending.php
===================================================================
--- mrbs/branches/provisional_bookings/web/pending.php                          
(rev 0)
+++ mrbs/branches/provisional_bookings/web/pending.php  2009-11-12 00:35:47 UTC 
(rev 1258)
@@ -0,0 +1,257 @@
+<?php
+// $Id$
+
+require_once "defaultincludes.inc";
+
+function display_buttons($row, $is_series)
+{
+  global $PHP_SELF;
+  global $is_admin, $remind_interval, $user;
+  
+  $last_reminded = (empty($row['reminded'])) ? $row['last_updated'] : 
$row['reminded'];
+  $returl = $PHP_SELF;
+                                    
+  $target_id = ($is_series) ? $row['repeat_id'] : $row['id'];
+  
+  if ($is_admin)
+  {
+    // accept
+    echo "<form action=\"confirm_entry_handler.php\" method=\"post\">\n";
+    echo "<div>\n";
+    echo "<input type=\"hidden\" name=\"action\" value=\"accept\">\n";
+    echo "<input type=\"hidden\" name=\"id\" value=\"$target_id\">\n";
+    echo "<input type=\"hidden\" name=\"series\" value=\"$is_series\">\n";
+    echo "<input type=\"hidden\" name=\"returl\" value=\"" . 
htmlspecialchars($returl) . "\">\n";
+    echo "<input type=\"submit\" value=\"" . get_vocab("accept") . "\">\n";
+    echo "</div>\n";
+    echo "</form>\n";
+    // reject
+    echo "<form action=\"view_entry.php\" method=\"post\">\n";
+    echo "<div>\n";
+    echo "<input type=\"hidden\" name=\"action\" value=\"reject\">\n";
+    echo "<input type=\"hidden\" name=\"id\" value=\"$target_id\">\n";
+    echo "<input type=\"hidden\" name=\"series\" value=\"$is_series\">\n";
+    echo "<input type=\"hidden\" name=\"returl\" value=\"" . 
htmlspecialchars($returl) . "\">\n";
+    echo "<input type=\"submit\" value=\"" . get_vocab("reject") . "\">\n";
+    echo "</div>\n";
+    echo "</form>\n";
+    // more info
+    echo "<form action=\"view_entry.php\" method=\"post\">\n";
+    echo "<div>\n";
+    echo "<input type=\"hidden\" name=\"action\" value=\"more_info\">\n";
+    echo "<input type=\"hidden\" name=\"id\" value=\"$target_id\">\n";
+    echo "<input type=\"hidden\" name=\"series\" value=\"$is_series\">\n";
+    echo "<input type=\"hidden\" name=\"returl\" value=\"" . 
htmlspecialchars($returl) . "\">\n";
+    echo "<input type=\"submit\" value=\"" . get_vocab("more_info") . "\">\n";
+    echo "</div>\n";
+    echo "</form>\n";
+  }
+  else
+  {
+    // Work out whether enough time has elapsed since the last reminder
+    $not_yet_time = working_time_diff(time(), $last_reminded) < 
$remind_interval;
+
+    // if enough time has passed since the last reminder
+    // output a "Remind Admin" button, otherwise nothing
+    if ($not_yet_time)
+    {
+      echo "&nbsp";
+    }
+    else
+    {
+      echo "<form action=\"confirm_entry_handler.php\" method=\"post\">\n";
+      echo "<div>\n";
+      echo "<input type=\"hidden\" name=\"action\" value=\"remind_admin\">\n";
+      echo "<input type=\"hidden\" name=\"id\" value=\"" . $row['id'] . 
"\">\n";
+      echo "<input type=\"hidden\" name=\"returl\" value=\"" . 
htmlspecialchars($returl) . "\">\n";
+      echo "<input type=\"submit\" value=\"" . get_vocab("remind_admin") . 
"\">\n";
+      echo "</div>\n";
+      echo "</form>\n";
+    }
+  }
+}
+
+// display the header row for a series
+function display_series_header($row, $table_id)
+{
+  global $n_cols, $is_admin, $tbl_entry, $user;
+    
+  echo "<tr>";  // no \n so as not to create another child in the DOM
+  echo "<th class=\"control\" 
onClick=\"toggle_table('$table_id')\">&nbsp;</th>\n";
+  // reservation name, with a link to the view_entry page
+  echo "<th class=\"header_name\"><a 
href=\"view_entry.php?id=".$row['repeat_id']."&amp;series=1\">" . 
htmlspecialchars($row['name']) ."</a></th>\n";
+  
+  // create_by, area and room names
+  echo "<th class=\"header_create\">" . htmlspecialchars($row['create_by']) . 
"</th>\n";
+  echo "<th class=\"header_area\">"   . htmlspecialchars($row['area_name']) . 
"</th>\n";
+  echo "<th class=\"header_room\">"   . htmlspecialchars($row['room_name']) . 
"</th>\n";
+  
+  echo "<th class=\"header_start_time\">" . get_vocab("series") . "</th>\n";
+  
+  echo "<th class=\"header_action\">\n";
+  display_buttons($row, TRUE);
+  echo "</th>\n";
+  echo "</tr>\n";
+}
+
+// display an entry in a row
+function display_entry_row($row)
+{
+  global $PHP_SELF;
+  global $enable_periods, $remind_interval;
+  global $is_admin;
+  
+  echo "<tr>\n";
+  echo "<td class=\"control\">&nbsp;</td>\n";
+    
+  // reservation name, with a link to the view_entry page
+  echo "<td>";
+  echo "<a href=\"view_entry.php?id=".$row['id']."\">" . 
htmlspecialchars($row['name']) ."</a></td>\n";
+    
+  // create_by, area and room names
+  echo "<td>" . htmlspecialchars($row['create_by']) . "</td>\n";
+  echo "<td>" . htmlspecialchars($row['area_name']) . "</td>\n";
+  echo "<td>" . htmlspecialchars($row['room_name']) . "</td>\n";
+    
+  // start date, with a link to the day.php
+  $link = getdate($row['start_time']);
+  echo "<td>";
+  echo "<a 
href=\"day.php?day=$link[mday]&amp;month=$link[mon]&amp;year=$link[year]&amp;area=".$row['area_id']."\">";
+  if(empty($enable_periods))
+  {
+    $link_str = time_date_string($row['start_time']);
+  }
+  else
+  {
+    list(,$link_str) = period_date_string($row['start_time']);
+  }
+  echo "$link_str</a></td>";
+    
+  // action buttons
+  echo "<td>\n";
+  display_buttons($row, FALSE);
+  echo "</td>\n";
+  echo "</tr>\n";  
+}
+
+$user = getUserName();
+
+// Get form variables
+$day = get_form_var('day', 'int');
+$month = get_form_var('month', 'int');
+$year = get_form_var('year', 'int');
+$area = get_form_var('area', 'int');
+$room = get_form_var('room', 'int');
+
+// If we dont know the right date then make it up
+if (!isset($day) or !isset($month) or !isset($year))
+{
+  $day   = date("d");
+  $month = date("m");
+  $year  = date("Y");
+}
+if (empty($area))
+{
+  $area = get_default_area();
+}
+
+
+if(!getAuthorised(1))
+{
+  showAccessDenied($day, $month, $year, $area, isset($room) ? $room : "");
+  exit;
+}
+$user = getUserName();
+$is_admin = (authGetUserLevel($user) >= 2);
+
+print_header($day, $month, $year, $area, isset($room) ? $room : "");
+
+echo "<h1>" . get_vocab("pending") . "</h1>\n";
+
+// Get a list of all the provisional bookings
+$sql = "SELECT E.id, E.name, E.start_time, E.create_by, " .
+               sql_syntax_timestamp_to_unix("E.timestamp") . " AS last_updated,
+               E.reminded, E.repeat_id,
+               R.room_name, R.area_id, A.area_name
+        FROM  $tbl_room AS R, $tbl_area AS A, $tbl_entry AS E
+        WHERE E.room_id = R.id
+          AND R.area_id = A.id
+          AND status=" . STATUS_PROVISIONAL;
+
+// Ordinary users can only see their own bookings       
+if (!$is_admin)
+{
+  $sql .= " AND E.create_by='" . addslashes($user) . "'";
+}
+// We want entries for a series to appear together so that we can display
+// them as a separate table below the main entry for the series. 
+$sql .= " ORDER BY E.repeat_id, start_time";
+
+$res = sql_query($sql);
+if (! $res)
+{
+  fatal_error(0, sql_error());
+}
+if (sql_count($res) == 0)
+{
+  echo "<p>" .get_vocab("none_outstanding") . "</p>\n";
+}
+else  // display them in a table
+{
+  echo "<table id=\"pending_list\" class=\"admin_table\">\n";
+  echo "<thead>\n";
+  echo "<tr>\n";
+  $n_cols = 7;
+  echo "<th class=\"control\">&nbsp;</th>\n";
+  echo "<th class=\"header_name\">" . get_vocab("entry") . "</th>\n";
+  echo "<th class=\"header_create\">" . get_vocab("createdby") . "</th>\n";
+  echo "<th class=\"header_area\">" . get_vocab("area") . "</th>\n";
+  echo "<th class=\"header_room\">" . get_vocab("room") . "</th>\n";
+  echo "<th class=\"header_start_time\">" . get_vocab("start_date") . 
"</th>\n";
+  echo "<th class=\"header_action\">" . get_vocab("action") . "</th>\n";
+  echo "</tr>\n";
+  echo "</thead>\n";
+  
+  echo "<tbody>\n";
+  $last_repeat_id = 0;
+  $is_series = FALSE;
+  for ($i = 0; ($row = sql_row_keyed($res, $i)); $i++)
+  { 
+    if ($row['repeat_id'] != $last_repeat_id)
+    // there's some kind of change
+    {
+      $last_repeat_id = $row['repeat_id'];
+      if ($is_series)
+      {
+        // end the last series table if there was one
+        $is_series = FALSE;
+        echo "</tbody></table></td></tr>\n";
+      }
+    
+      if (!empty($row['repeat_id']))
+      {
+        // we're starting a new series
+        $is_series = TRUE;
+        echo "<tr class=\"sub_table\">\n";
+        echo "<td class=\"sub_table\" colspan=\"$n_cols\">";
+        $table_id = "series" . $row['repeat_id'];
+        echo "<table id=\"$table_id\" class=\"maximised\">";  // no \n so as 
not to create another child in the DOM
+        echo "<thead>";  // no \n so as not to create another child in the DOM
+        display_series_header($row, $table_id);
+        echo "</thead>\n";
+        echo "<tbody>\n";
+      }      
+    }
+    display_entry_row($row);
+  }
+  if ($is_series)
+  {
+    // if we were in a series, then close the sub-table
+    echo "</tbody></table></td></tr>\n";
+  }
+  echo "</tbody>\n"; 
+  echo "</table>\n ";
+}
+
+require_once "trailer.inc";
+?>


Property changes on: mrbs/branches/provisional_bookings/web/pending.php
___________________________________________________________________
Added: svn:mime-type
   + text/plain
Added: svn:keywords
   + $Id
Added: svn:eol-style
   + native


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Mrbs-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mrbs-commits

Reply via email to