Revision: 1257
          http://mrbs.svn.sourceforge.net/mrbs/?rev=1257&view=rev
Author:   cimorrison
Date:     2009-11-11 21:51:25 +0000 (Wed, 11 Nov 2009)

Log Message:
-----------
Implemented Remind Button and associated email notifications

Modified Paths:
--------------
    mrbs/branches/provisional_bookings/tables.my.sql
    mrbs/branches/provisional_bookings/tables.pg.73and_above.sql
    mrbs/branches/provisional_bookings/tables.pg.sql
    mrbs/branches/provisional_bookings/web/confirm_entry_handler.php
    mrbs/branches/provisional_bookings/web/dbsys.inc
    mrbs/branches/provisional_bookings/web/edit_entry_handler.php
    mrbs/branches/provisional_bookings/web/functions.inc
    mrbs/branches/provisional_bookings/web/functions_mail.inc
    mrbs/branches/provisional_bookings/web/lang.en
    mrbs/branches/provisional_bookings/web/mrbs_sql.inc
    mrbs/branches/provisional_bookings/web/systemdefaults.inc.php
    mrbs/branches/provisional_bookings/web/view_entry.php

Added Paths:
-----------
    mrbs/branches/provisional_bookings/web/upgrade/10/
    mrbs/branches/provisional_bookings/web/upgrade/10/mysql.sql
    mrbs/branches/provisional_bookings/web/upgrade/10/pgsql.sql

Modified: mrbs/branches/provisional_bookings/tables.my.sql
===================================================================
--- mrbs/branches/provisional_bookings/tables.my.sql    2009-11-11 14:36:47 UTC 
(rev 1256)
+++ mrbs/branches/provisional_bookings/tables.my.sql    2009-11-11 21:51:25 UTC 
(rev 1257)
@@ -60,6 +60,7 @@
   description text,
   private     TINYINT(1) NOT NULL DEFAULT 0,
   status      tinyint NOT NULL DEFAULT 1,
+  reminded    int,
 
   PRIMARY KEY (id),
   KEY idxStartTime (start_time),
@@ -82,6 +83,7 @@
   description text,
   rep_num_weeks smallint NULL, 
   private     TINYINT(1) NOT NULL DEFAULT 0,
+  reminded    int,
   
   PRIMARY KEY (id)
 );
@@ -108,6 +110,6 @@
 );
 
 INSERT INTO mrbs_variables (variable_name, variable_content)
-  VALUES ( 'db_version', '9');
+  VALUES ( 'db_version', '10');
 INSERT INTO mrbs_variables (variable_name, variable_content)
   VALUES ( 'local_db_version', '1');

Modified: mrbs/branches/provisional_bookings/tables.pg.73and_above.sql
===================================================================
--- mrbs/branches/provisional_bookings/tables.pg.73and_above.sql        
2009-11-11 14:36:47 UTC (rev 1256)
+++ mrbs/branches/provisional_bookings/tables.pg.73and_above.sql        
2009-11-11 21:51:25 UTC (rev 1257)
@@ -71,7 +71,8 @@
   type        char DEFAULT 'E' NOT NULL,
   description text,
   private     smallint DEFAULT 0 NOT NULL,
-  status      smallint DEFAULT 1 NOT NULL
+  status      smallint DEFAULT 1 NOT NULL,
+  reminded    int
 );
 create index idxStartTime on mrbs_entry(start_time);
 create index idxEndTime on mrbs_entry(end_time);
@@ -91,7 +92,8 @@
   type        char DEFAULT 'E' NOT NULL,
   description text,
   rep_num_weeks smallint DEFAULT 0 NULL,
-  private     smallint DEFAULT 0 NOT NULL
+  private     smallint DEFAULT 0 NOT NULL,
+  reminded    int
 );
 
 CREATE TABLE mrbs_variables
@@ -112,6 +114,6 @@
 );
 
 INSERT INTO mrbs_variables (variable_name, variable_content)
-  VALUES ('db_version', '9');
+  VALUES ('db_version', '10');
 INSERT INTO mrbs_variables (variable_name, variable_content)
   VALUES ('local_db_version', '1');

Modified: mrbs/branches/provisional_bookings/tables.pg.sql
===================================================================
--- mrbs/branches/provisional_bookings/tables.pg.sql    2009-11-11 14:36:47 UTC 
(rev 1256)
+++ mrbs/branches/provisional_bookings/tables.pg.sql    2009-11-11 21:51:25 UTC 
(rev 1257)
@@ -59,7 +59,8 @@
   type        char DEFAULT 'E' NOT NULL,
   description text,
   private     smallint DEFAULT 0 NOT NULL,
-  status      smallint DEFAULT 1 NOT NULL
+  status      smallint DEFAULT 1 NOT NULL,
+  reminded    int
 );
 create index idxStartTime on mrbs_entry(start_time);
 create index idxEndTime on mrbs_entry(end_time);
@@ -79,7 +80,8 @@
   type        char DEFAULT 'E' NOT NULL,
   description text,
   rep_num_weeks smallint DEFAULT NULL NULL,
-  private     smallint DEFAULT 0 NOT NULL
+  private     smallint DEFAULT 0 NOT NULL,
+  reminded    int
 );
 
 CREATE TABLE mrbs_variables
@@ -100,6 +102,6 @@
 );
 
 INSERT INTO mrbs_variables (variable_name, variable_content)
-  VALUES ('db_version', '9');
+  VALUES ('db_version', '10');
 INSERT INTO mrbs_variables (variable_name, variable_content)
   VALUES ('local_db_version', '1');

Modified: mrbs/branches/provisional_bookings/web/confirm_entry_handler.php
===================================================================
--- mrbs/branches/provisional_bookings/web/confirm_entry_handler.php    
2009-11-11 14:36:47 UTC (rev 1256)
+++ mrbs/branches/provisional_bookings/web/confirm_entry_handler.php    
2009-11-11 21:51:25 UTC (rev 1257)
@@ -40,15 +40,18 @@
   exit;
 }
 $user = getUserName();
-// (2) We must also have confirm rights for this room
-if (!auth_can_confirm($user, $room_id))
-{
-  showAccessDenied($day, $month, $year, $area, isset($room) ? $room : "");
-  exit;
-}
+
                   
 if (isset($action))
 {
+  // (2) We must also have confirm rights for this room if necessary
+  if ((($action == "accept") || ($action == "reject")) 
+       && !auth_can_confirm($user, $room_id))
+  {
+    showAccessDenied($day, $month, $year, $area, isset($room) ? $room : "");
+    exit;
+  }
+  
   $need_to_send_mail = ($mail_settings['admin_on_bookings'] or 
$mail_settings['area_admin_on_bookings'] or
                         $mail_settings['room_admin_on_bookings'] or 
$mail_settings['booker'] or
                         $mail_settings['book_admin_on_provisional']);
@@ -68,6 +71,7 @@
     $starttime     = $row['start_time'];
     $endtime       = $row['end_time'];
     $room_name     = $row['room_name'];
+    $room_id       = $row['room_id'];
     $area_name     = $row['area_name'];
     $duration      = ($row['end_time'] - $row['start_time']) - 
cross_dst($row['start_time'], $row['end_time']);
     $rep_type      = $row['rep_type'];
@@ -110,19 +114,33 @@
     }
     elseif ($need_to_send_mail)
     {
-      $result = notifyAdminOnBooking(TRUE, $id, $action);
+      $result = notifyAdminOnBooking(TRUE, $id, $series, $action);
     }
   }
   
   // ACTION = "MORE_INFO"
   if ($action == "more_info")
   {
+    // update the last reminded time (the ball is back in the 
+    // originator's court, so the clock gets reset)
+    mrbsUpdateLastReminded($id, $series);
     if ($need_to_send_mail)
     {
-      $result = notifyAdminOnBooking(TRUE, $id, $action);
+      $result = notifyAdminOnBooking(TRUE, $id, $series, $action);
     }
   }
   
+  // ACTION = "REMIND"
+  if ($action == "remind")
+  {
+    // update the last reminded time
+    mrbsUpdateLastReminded($id, $series);
+    if ($need_to_send_mail)
+    {
+      $result = notifyAdminOnBooking(TRUE, $id, $series, $action);
+    }
+  }
+  
 }
 
 // Now it's all done go back to the previous view

Modified: mrbs/branches/provisional_bookings/web/dbsys.inc
===================================================================
--- mrbs/branches/provisional_bookings/web/dbsys.inc    2009-11-11 14:36:47 UTC 
(rev 1256)
+++ mrbs/branches/provisional_bookings/web/dbsys.inc    2009-11-11 21:51:25 UTC 
(rev 1257)
@@ -15,7 +15,7 @@
 $tbl_variables = $db_tbl_prefix . "variables";
 
 
-$db_schema_version = 9;
+$db_schema_version = 10;
 $local_db_schema_version = 1;
 
 

Modified: mrbs/branches/provisional_bookings/web/edit_entry_handler.php
===================================================================
--- mrbs/branches/provisional_bookings/web/edit_entry_handler.php       
2009-11-11 14:36:47 UTC (rev 1256)
+++ mrbs/branches/provisional_bookings/web/edit_entry_handler.php       
2009-11-11 21:51:25 UTC (rev 1257)
@@ -427,21 +427,24 @@
     {
       $status = STATUS_CONFIRMED;
     }
+    
     if ($edit_type == "series")
     {
-      $new_id = mrbsCreateRepeatingEntrys($starttime,
-                                          $endtime,
-                                          $rep_type,
-                                          $rep_enddate,
-                                          $rep_opt,
-                                          $room_id,
-                                          $create_by,
-                                          $name,
-                                          $type,
-                                          $description,
-                                          isset($rep_num_weeks) ? 
$rep_num_weeks : 0,
-                                          $isprivate,
-                                          $status);
+      $booking = mrbsCreateRepeatingEntrys($starttime,
+                                           $endtime,
+                                           $rep_type,
+                                           $rep_enddate,
+                                           $rep_opt,
+                                           $room_id,
+                                           $create_by,
+                                           $name,
+                                           $type,
+                                           $description,
+                                           isset($rep_num_weeks) ? 
$rep_num_weeks : 0,
+                                           $isprivate,
+                                           $status);
+      $new_id = $booking['id'];
+
       // Send a mail to the Administrator
       if ($mail_settings['admin_on_bookings'] or 
$mail_settings['area_admin_on_bookings'] or
           $mail_settings['room_admin_on_bookings'] or $mail_settings['booker'] 
or
@@ -473,7 +476,7 @@
           {
             $mail_previous = getPreviousEntryData($id, 1);
           }
-          $result = notifyAdminOnBooking(!isset($id), $new_id);
+          $result = notifyAdminOnBooking(!isset($id), $new_id, 
$booking['series']);
         }
       }
     }
@@ -532,7 +535,7 @@
           {
             $mail_previous = getPreviousEntryData($id, 0);
           }
-          $result = notifyAdminOnBooking(!isset($id), $new_id);
+          $result = notifyAdminOnBooking(!isset($id), $new_id, ($edit_type == 
"series"));
         }
       }
     }

Modified: mrbs/branches/provisional_bookings/web/functions.inc
===================================================================
--- mrbs/branches/provisional_bookings/web/functions.inc        2009-11-11 
14:36:47 UTC (rev 1256)
+++ mrbs/branches/provisional_bookings/web/functions.inc        2009-11-11 
21:51:25 UTC (rev 1257)
@@ -663,6 +663,16 @@
   return $modification;
 }
 
+// Returns the difference in seconds between two timestamps, $now and $then
+// It gives $now - $then
+// TO DO: exclude weekends, or preferably a set of days of the week defined 
+// as a config setting
+function working_time_diff($now, $then)
+{
+  $diff = $now - $then;
+  return $diff;
+}
+
 // checks whether a given day of the week is supposed to be hidden in the 
display
 function is_hidden_day ($dow)
 {

Modified: mrbs/branches/provisional_bookings/web/functions_mail.inc
===================================================================
--- mrbs/branches/provisional_bookings/web/functions_mail.inc   2009-11-11 
14:36:47 UTC (rev 1256)
+++ mrbs/branches/provisional_bookings/web/functions_mail.inc   2009-11-11 
21:51:25 UTC (rev 1257)
@@ -184,6 +184,17 @@
   return $email;
 }
 
+// get the list of email addresses that are allowed to approve
+// provisional bookings for the room with id $room_id
+// (At the moment this is just the admin email address, but this could
+// be extended.)
+function get_approvers_email($room_id)
+{
+  global $mail_settings;
+  
+  return $mail_settings['recipients'];
+}
+
 // }}}
 // {{{ notifyAdminOnBooking()
 
@@ -194,10 +205,10 @@
  * @param int     $new_id       used for create a link to the new entry
  * @return bool                 TRUE or PEAR error object if fails
  */
-function notifyAdminOnBooking($new_entry , $new_id, $action="book")
+function notifyAdminOnBooking($new_entry , $new_id, $series, $action="book")
 {
   global $url_base, $returl, $name, $description, $area_name;
-  global $room_name, $starttime, $duration, $dur_units, $end_date, $endtime;
+  global $room_name, $room_id, $starttime, $duration, $dur_units, $end_date, 
$endtime;
   global $rep_enddate, $typel, $type, $status, $create_by, $rep_type, 
$enable_periods;
   global $rep_opt, $rep_num_weeks;
   global $tbl_room, $tbl_area, $tbl_entry, $tbl_users, $tbl_repeat;
@@ -210,7 +221,7 @@
   {
     $new_entry = TRUE;
   }
-  
+
   $recipients = array();
   $cc = array();
   $cc[] = $mail_settings['cc'];
@@ -231,6 +242,12 @@
     $from = $mail_settings['from'];
   }
   
+  if ($provisional_enabled)
+  {
+    // get the list of email addresses of approvers for this room
+    $recipients[] = get_approvers_email($room_id);
+  }
+  
   $id_table = ($rep_type > 0) ? "rep" : "e";
   ($mail_settings['admin_on_bookings']) ? $recipients[] = 
$mail_settings['recipients'] : '';
   if ($mail_settings['area_admin_on_bookings'])
@@ -329,6 +346,10 @@
       $body .= get_mail_vocab("info_requested") . ": ";
       $body .= convertToMailCharset($note) . "\n\n";
       break;
+    case "remind":
+      $subject = get_mail_vocab("mail_subject_reminder");
+      $body = get_mail_vocab("mail_body_reminder") . "\n\n";
+      break;
     default:
       $subject = get_mail_vocab("mail_subject_entry");
       if ($new_entry)
@@ -352,7 +373,7 @@
     ('' != $returl) ? $url = explode(basename($returl), $returl) : '';
     $body .= $url[0] . "view_entry.php?id=$new_id";
   }
-  if ($rep_type > 0)
+  if ($series)
   {
     $body .= "&series=1";
   }

Modified: mrbs/branches/provisional_bookings/web/lang.en
===================================================================
--- mrbs/branches/provisional_bookings/web/lang.en      2009-11-11 14:36:47 UTC 
(rev 1256)
+++ mrbs/branches/provisional_bookings/web/lang.en      2009-11-11 21:51:25 UTC 
(rev 1257)
@@ -109,7 +109,8 @@
 $vocab["provisional"]        = "Provisional booking";
 $vocab["accept"]             = "Accept";
 $vocab["reject"]             = "Reject";
-$vocab["more_info"]          = "More Info";  
+$vocab["more_info"]          = "More Info";
+$vocab["remind_admin"]       = "Remind Admin";
 $vocab["series"]             = "Series";
 $vocab["request_more_info"]  = "Please list the extra information you require";
 $vocab["reject_reason"]      = "Please give a reason for your rejection of 
this reservation request";

Modified: mrbs/branches/provisional_bookings/web/mrbs_sql.inc
===================================================================
--- mrbs/branches/provisional_bookings/web/mrbs_sql.inc 2009-11-11 14:36:47 UTC 
(rev 1256)
+++ mrbs/branches/provisional_bookings/web/mrbs_sql.inc 2009-11-11 21:51:25 UTC 
(rev 1257)
@@ -479,8 +479,11 @@
  * $status      - Status code
  * 
  * Returns:
- *   0        - An error occured while inserting the entry
- *   non-zero - The entry's ID
+ *   an array
+ *   ['id']      - 0 if an error occurred, otherwise an id
+ *   ['series']  - boolean: TRUE if the id refers to the repeat table
+ *                          FALSE if the id refers to the entry table
+ *
  */
 function mrbsCreateRepeatingEntrys($starttime, $endtime, $rep_type,
                                    $rep_enddate, $rep_opt, $room_id, $owner,
@@ -488,6 +491,8 @@
                                    $private, $status)
 {
   global $max_rep_entrys;
+  
+  $result = array('id' => 0, 'series' => FALSE);
   $private = $private ? 1 : 0 ;
    
   $reps = mrbsGetRepeatEntryList($starttime, $rep_enddate,
@@ -496,23 +501,26 @@
 
   if (count($reps) > $max_rep_entrys)
   {
-    return 0;
+    $result['id'] = 0;
+    return $result;;
   }
 
   if (empty($reps))
   {
-    $ent = mrbsCreateSingleEntry($starttime, $endtime, 0, 0,
-                                 $room_id, $owner, $name, $type,
-                                 $description, $private, $status);
-    return $ent;
+    $id = mrbsCreateSingleEntry($starttime, $endtime, 0, 0,
+                                $room_id, $owner, $name, $type,
+                                $description, $private, $status);
+    $result['id'] = $id;
+    $result['series'] = FALSE;
+    return $result;
   }
    
-  $ent = mrbsCreateRepeatEntry($starttime, $endtime, $rep_type,
-                               $rep_enddate, $rep_opt, $room_id,
-                               $owner, $name, $type, $description,
-                               $rep_num_weeks, $private);
+  $id = mrbsCreateRepeatEntry($starttime, $endtime, $rep_type,
+                              $rep_enddate, $rep_opt, $room_id,
+                              $owner, $name, $type, $description,
+                              $rep_num_weeks, $private);
     
-  if ($ent)
+  if ($id)
   {
     for ($i = 0; $i < count($reps); $i++)
     {
@@ -524,7 +532,7 @@
       $ent_id = mrbsCreateSingleEntry($reps[$i],
                                       $reps[$i] + $diff,
                                       1,
-                                      $ent,
+                                      $id,
                                       $room_id,
                                       $owner,
                                       $name,
@@ -534,9 +542,47 @@
                                       $status);
     }
   }
-  return $ent;
+  $result['id'] = $id;
+  $result['series'] = TRUE;
+  return $result;
 }
 
+// Update the time of last reminding.
+// If the entry is part of a repeating series, then also increment
+// the last reminder time in the repeat table and all the individual 
+// entries.
+// Returns the number of tuples affected if OK (a number >= 0).
+// Returns -1 on error; use sql_error to get the error message.
+function mrbsUpdateLastReminded($id, $series)
+{
+  global $tbl_entry, $tbl_repeat;
+  
+  $now = time();
+  if ($series)
+  {
+    $sql = "UPDATE $tbl_repeat SET reminded=$now WHERE id=$id";
+    if (sql_command($sql) >= 0)
+    {
+      $sql = "UPDATE $tbl_entry SET reminded=$now WHERE repeat_id=$id";
+      return sql_command($sql);
+    }
+  }
+  else
+  {
+    $sql = "UPDATE $tbl_entry SET reminded=$now WHERE id=$id";
+    if (sql_command($sql) > 0)
+    {
+      $repeat_id = sql_query1("SELECT repeat_id FROM $tbl_entry WHERE id=$id 
LIMIT 1");
+      if ($repeat_id >= 0)
+      {
+        $sql = "UPDATE $tbl_repeat SET reminded=$now WHERE id=$repeat_id";
+        return sql_command($sql);
+      }
+    }
+  }
+  return -1;
+}
+
 // mrbsConfirmEntry($id, $series)
 //
 // Confirm an entry with id $id.   If series is set to TRUE
@@ -582,9 +628,11 @@
             $tbl_repeat.description,
             $tbl_repeat.create_by,
             $tbl_room.room_name,
+            $tbl_repeat.room_id,
             $tbl_area.area_name,
             $tbl_room.area_id,
             $tbl_repeat.type,
+            $tbl_repeat.reminded,
             $tbl_repeat.private,
             $tbl_repeat.room_id,
             " . sql_syntax_timestamp_to_unix("$tbl_repeat.timestamp") . " AS 
last_updated,
@@ -609,10 +657,12 @@
             $tbl_entry.description,
             $tbl_entry.create_by,
             $tbl_room.room_name,
+            $tbl_entry.room_id,
             $tbl_room.area_id,
             $tbl_area.area_name,
             $tbl_entry.type,
             $tbl_entry.status,
+            $tbl_entry.reminded,
             $tbl_entry.private,
             $tbl_entry.room_id,
             " . sql_syntax_timestamp_to_unix("$tbl_entry.timestamp") . " AS 
last_updated,

Modified: mrbs/branches/provisional_bookings/web/systemdefaults.inc.php
===================================================================
--- mrbs/branches/provisional_bookings/web/systemdefaults.inc.php       
2009-11-11 14:36:47 UTC (rev 1256)
+++ mrbs/branches/provisional_bookings/web/systemdefaults.inc.php       
2009-11-11 21:51:25 UTC (rev 1257)
@@ -371,7 +371,15 @@
 // bookings confirmed by an admin.
 $provisional_enabled = FALSE;  // Set to TRUE to enable provisional bookings
 
+// Set to FALSE if you don't want users to be able to send reminders
+// to admins if provisional bookings have not been approved
+$reminders_enabled = TRUE;
 
+// Interval before reminders can be issued (in seconds). (At the moment
+// weekends are included in the calculation.  Ideally they should be
+// excluded)
+$reminder_interval = 60*60*24*4;  // 4 days
+
 /***********************************************
  * Authentication settings - read AUTHENTICATION
  ***********************************************/

Added: mrbs/branches/provisional_bookings/web/upgrade/10/mysql.sql
===================================================================
--- mrbs/branches/provisional_bookings/web/upgrade/10/mysql.sql                 
        (rev 0)
+++ mrbs/branches/provisional_bookings/web/upgrade/10/mysql.sql 2009-11-11 
21:51:25 UTC (rev 1257)
@@ -0,0 +1,12 @@
+# $Id$
+#
+# Add column to record the last time a reminder was sent.
+# (Unfortunately, timestamps in PostgreSQL are not automatically
+# updated on UPDATE, so updating the reminders count does not have
+# the effect of changing the timestamp, as it does in MySQL).
+
+ALTER TABLE %DB_TBL_PREFIX%entry
+ADD COLUMN reminded            int;
+
+ALTER TABLE %DB_TBL_PREFIX%repeat
+ADD COLUMN reminded            int;


Property changes on: mrbs/branches/provisional_bookings/web/upgrade/10/mysql.sql
___________________________________________________________________
Added: svn:keywords
   + Id
Added: svn:eol-style
   + native

Added: mrbs/branches/provisional_bookings/web/upgrade/10/pgsql.sql
===================================================================
--- mrbs/branches/provisional_bookings/web/upgrade/10/pgsql.sql                 
        (rev 0)
+++ mrbs/branches/provisional_bookings/web/upgrade/10/pgsql.sql 2009-11-11 
21:51:25 UTC (rev 1257)
@@ -0,0 +1,12 @@
+-- $Id$
+--
+-- Add column to record the last time a reminder was sent.
+-- (Unfortunately, timestamps in PostgreSQL are not automatically
+-- updated on UPDATE, so updating the reminders count does not have
+-- the effect of changing the timestamp, as it does in MySQL).
+
+ALTER TABLE %DB_TBL_PREFIX%entry
+ADD COLUMN reminded            int;
+
+ALTER TABLE %DB_TBL_PREFIX%repeat
+ADD COLUMN reminded            int;


Property changes on: mrbs/branches/provisional_bookings/web/upgrade/10/pgsql.sql
___________________________________________________________________
Added: svn:keywords
   + Id
Added: svn:eol-style
   + native

Modified: mrbs/branches/provisional_bookings/web/view_entry.php
===================================================================
--- mrbs/branches/provisional_bookings/web/view_entry.php       2009-11-11 
14:36:47 UTC (rev 1256)
+++ mrbs/branches/provisional_bookings/web/view_entry.php       2009-11-11 
21:51:25 UTC (rev 1257)
@@ -27,7 +27,7 @@
 {
   global $returl, $PHP_SELF;
   
-  $this_page = htmlspecialchars(basename($PHP_SELF));
+  $this_page = basename($PHP_SELF);
   
   echo "<tr>\n";
   echo "<td>" . ($series ? get_vocab("series") : get_vocab("entry")) . 
":</td>\n";
@@ -41,6 +41,26 @@
 
 function generateOwnerButtons($id, $series)
 {
+  global $user, $create_by, $status, $area;
+  global $PHP_SELF, $reminders_enabled, $last_reminded, $reminder_interval;
+  
+  $this_page = basename($PHP_SELF);
+  
+  // Remind button if you're the owner AND there's a provisional
+  // booking outstanding AND sufficient time has passed since the last reminder
+  // AND we want reminders in the first place
+  if (($reminders_enabled) &&
+      ($user == $create_by) && 
+      ($status == STATUS_PROVISIONAL) &&
+      (working_time_diff(time(), $last_reminded) >= $reminder_interval))
+  {
+    echo "<tr>\n";
+    echo "<td>&nbsp;</td>\n";
+    echo "<td>\n";
+    generateButton("confirm_entry_handler.php", $id, $series, "remind", 
$this_page . "?id=$id&amp;area=$area", get_vocab("remind_admin"));
+    echo "</td>\n";
+    echo "</tr>\n";
+  } 
 }
 
 function generateTextArea($form_action, $id, $series, $action_type, $returl, 
$submit_value, $caption)
@@ -134,21 +154,22 @@
 
 $row = mrbsGetBookingInfo($id, $series);
 
-$name         = htmlspecialchars($row['name']);
-$description  = htmlspecialchars($row['description']);
-$create_by    = htmlspecialchars($row['create_by']);
-$room_name    = htmlspecialchars($row['room_name']);
-$area_name    = htmlspecialchars($row['area_name']);
-$type         = $row['type'];
-$status       = $row['status'];
-$private      = $row['private'];
-$room_id      = $row['room_id'];
-$updated      = time_date_string($row['last_updated']);
+$name          = htmlspecialchars($row['name']);
+$description   = htmlspecialchars($row['description']);
+$create_by     = htmlspecialchars($row['create_by']);
+$room_name     = htmlspecialchars($row['room_name']);
+$area_name     = htmlspecialchars($row['area_name']);
+$type          = $row['type'];
+$status        = $row['status'];
+$private       = $row['private'];
+$room_id       = $row['room_id'];
+$updated       = time_date_string($row['last_updated']);
+$last_reminded = (empty($row['reminded'])) ? $row['last_updated'] : 
$row['reminded'];
 // need to make DST correct in opposite direction to entry creation
 // so that user see what he expects to see
-$duration     = $row['duration'] - cross_dst($row['start_time'],
-                                             $row['end_time']);
-$writeable = getWritable($row['create_by'], $user);
+$duration      = $row['duration'] - cross_dst($row['start_time'],
+                                              $row['end_time']);
+$writeable     = getWritable($row['create_by'], $user);
 
 
 // Get the area settings for the entry's area.   In particular we want
@@ -436,7 +457,7 @@
       echo "<a href=\"edit_entry.php?id=$id&amp;returl=$link_returl\">". 
get_vocab("editentry") ."</a>";
     }
     
-    if (!empty($repeat_id))
+    if (!empty($repeat_id)  && !$series)
     {
       echo " - ";
     }
@@ -457,7 +478,7 @@
       echo "<a 
href=\"edit_entry.php?id=$id&amp;copy=1&amp;returl=$link_returl\">". 
get_vocab("copyentry") ."</a>";
     }
        
-    if (!empty($repeat_id))
+    if (!empty($repeat_id) && !$series)
     {
       echo " - ";
     }
@@ -476,7 +497,7 @@
       echo "<a 
href=\"del_entry.php?id=$id&amp;series=0&amp;returl=$link_returl\" 
onclick=\"return 
confirm('".get_vocab("confirmdel")."');\">".get_vocab("deleteentry")."</a>";
     }
     
-    if (!empty($repeat_id))
+    if (!empty($repeat_id) && !$series)
     {
       echo " - ";
     }


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