Revision: 2657
          https://sourceforge.net/p/mrbs/code/2657/
Author:   cimorrison
Date:     2013-01-25 16:45:25 +0000 (Fri, 25 Jan 2013)
Log Message:
-----------
Fixed import so that it works with latest changes (but multiple rooms in a 
LOCATION property not yet supported)

Modified Paths:
--------------
    mrbs/branches/linked_bookings/web/functions_mail.inc
    mrbs/branches/linked_bookings/web/import.php
    mrbs/branches/linked_bookings/web/systemdefaults.inc.php
    mrbs/branches/linked_bookings/web/view_entry.php

Modified: mrbs/branches/linked_bookings/web/functions_mail.inc
===================================================================
--- mrbs/branches/linked_bookings/web/functions_mail.inc        2013-01-25 
16:38:12 UTC (rev 2656)
+++ mrbs/branches/linked_bookings/web/functions_mail.inc        2013-01-25 
16:45:25 UTC (rev 2657)
@@ -405,7 +405,7 @@
   global $enable_periods, $approval_enabled, $confirmation_enabled;
   global $mail_settings, $standard_fields, $url_base;
   global $tbl_entry;
-  global $select_options;
+  global $select_options, $location_separator;
 
   // If we haven't got a previous entry just give it one.   It won't get used,
   // but will prevent a series if undefined index notices.
@@ -559,8 +559,8 @@
                                
     // Room:
     $body .= create_body_table_row (get_mail_vocab("room"),
-                                    implode(', ', $data['room_names']),
-                                    implode(', ', 
$mail_previous['room_names']),
+                                    implode($location_separator, 
$data['room_names']),
+                                    implode($location_separator, 
$mail_previous['room_names']),
                                     $compare, $as_html);
         
     // Start time

Modified: mrbs/branches/linked_bookings/web/import.php
===================================================================
--- mrbs/branches/linked_bookings/web/import.php        2013-01-25 16:38:12 UTC 
(rev 2656)
+++ mrbs/branches/linked_bookings/web/import.php        2013-01-25 16:45:25 UTC 
(rev 2657)
@@ -6,8 +6,7 @@
 require_once "mrbs_sql.inc";
 
 
-// Gets the id of the area/room with the LOCATION property value of $location,
-// creating an area and room if allowed.
+// Gets the id of the area/room with $location, creating an area and room if 
allowed.
 // Returns FALSE if it can't find an id or create an id, with an error message 
in $error
 function get_room_id($location, &$error)
 {
@@ -149,6 +148,27 @@
 }
 
 
+function get_room_ids($locations, &$error)
+{
+  global $location_separator;
+  
+  $room_ids = array();
+  $locations = explode($location_separator, $locations);
+  if (count($locations) > 1)
+  {
+    trigger_error("Multiple locations not yet supported", E_USER_WARNING);
+    // Need to think about what to do about making sure area characteristics
+    // are similar (and also what to do in MRBS generally about a linked 
booking
+    // when area characteristics change after the booking is made)
+  }
+  foreach ($locations as $location)
+  {
+    $room_ids[] = get_room_id($location, $error);
+  }
+  return $room_ids;
+}
+
+
 // Add a VEVENT to MRBS.   Returns TRUE on success, FALSE on failure
 function process_event($vevent)
 {
@@ -219,8 +239,8 @@
         break;
       case 'LOCATION':
         $error = '';
-        $booking['room_id'] = get_room_id($details['value'], $error);
-        if ($booking['room_id'] === FALSE)
+        $booking['rooms'] = get_room_ids($details['value'], $error);
+        if ($booking['rooms'] === FALSE)
         {
           $problems[] = $error;
         }
@@ -297,38 +317,40 @@
   
   // LOCATION is optional in RFC 5545 but is obviously mandatory in MRBS.
   // We could maybe have a default room on the form and use that
-  if (!isset($booking['room_id']))
+  if (!isset($booking['rooms']) || empty($booking['rooms']))
   {
     $problems[] = get_vocab("no_LOCATION");
   }
   
   if (empty($problems))
   {
-    // Get the area settings for this room, if we haven't got them already
-    if (!isset($room_settings[$booking['room_id']]))
+    // Get the area settings for these rooms, if we haven't got them already
+    foreach ($booking['rooms'] as $room_id)
     {
-      get_area_settings(get_area($booking['room_id']));
-      $room_settings[$booking['room_id']]['morningstarts'] = $morningstarts;
-      $room_settings[$booking['room_id']]['morningstarts_minutes'] = 
$morningstarts_minutes;
-      $room_settings[$booking['room_id']]['resolution'] = $resolution;
+      if (!isset($room_settings[$room_id]))
+      {
+        get_area_settings(get_area($room_id));
+        $room_settings[$room_id]['morningstarts'] = $morningstarts;
+        $room_settings[$room_id]['morningstarts_minutes'] = 
$morningstarts_minutes;
+        $room_settings[$room_id]['resolution'] = $resolution;
+      }
     }
     // Round the start and end times to slot boundaries
     $date = getdate($booking['start_time']);
     $m = $date['mon'];
     $d = $date['mday'];
     $y = $date['year'];
-    $am7 = mktime($room_settings[$booking['room_id']]['morningstarts'],
-                  $room_settings[$booking['room_id']]['morningstarts_minutes'],
+    $am7 = mktime($room_settings[$room_id]['morningstarts'],
+                  $room_settings[$room_id]['morningstarts_minutes'],
                   0, $m, $d, $y);
     $booking['start_time'] = round_t_down($booking['start_time'],
-                                          
$room_settings[$booking['room_id']]['resolution'],
+                                          
$room_settings[$room_id]['resolution'],
                                           $am7);
     $booking['end_time'] = round_t_up($booking['end_time'],
-                                      
$room_settings[$booking['room_id']]['resolution'],
+                                      $room_settings[$room_id]['resolution'],
                                       $am7);
-    // Make the bookings
-    $bookings = array($booking);
-    $result = mrbsMakeBookings($bookings, NULL, FALSE, $skip);
+    // Make the booking
+    $result = mrbsMakeBooking($booking, NULL, FALSE, $skip);
     if ($result['valid_booking'])
     {
       return TRUE;

Modified: mrbs/branches/linked_bookings/web/systemdefaults.inc.php
===================================================================
--- mrbs/branches/linked_bookings/web/systemdefaults.inc.php    2013-01-25 
16:38:12 UTC (rev 2656)
+++ mrbs/branches/linked_bookings/web/systemdefaults.inc.php    2013-01-25 
16:45:25 UTC (rev 2657)
@@ -440,6 +440,9 @@
 // string.   For example, with the default setting of ' - ' the room 'Room 1' 
in
 // 'Area A' would become 'Area A - Room 1'.
 $area_room_separator = ' - ';
+// The string to use when listing multiple locations.    For example, with the
+// default setting of ',' one would get 'Area A - Room 1, Area A - Room 2'.
+$location_separator = ', ';
 
 
 /************************

Modified: mrbs/branches/linked_bookings/web/view_entry.php
===================================================================
--- mrbs/branches/linked_bookings/web/view_entry.php    2013-01-25 16:38:12 UTC 
(rev 2656)
+++ mrbs/branches/linked_bookings/web/view_entry.php    2013-01-25 16:45:25 UTC 
(rev 2657)
@@ -390,6 +390,51 @@
 ?>
 </table>
 
+
+
+<?php
+$n_rows = 4;
+$n_cols = 7;
+echo "<table id=\"view_map\">\n";
+for ($i=0; $i<$n_rows; $i++)
+{
+  echo "<tr>";
+  for ($j=0; $j<$n_cols; $j++)
+  {
+    echo "<td>&bull;</td>\n";
+  }
+  if ($i==0)
+  {
+    echo "<td>";
+    $params = array('name'    => 'this_room',
+                    'options' => array('1' => get_vocab('this_room_only')));
+    generate_radio($params);
+    echo "</td>\n";
+  }
+  elseif ($i==1)
+  {
+    echo "<td rowspan=\"" . ($n_rows - 1) . "\">";
+    $params = array('name'    => 'this_room',
+                    'options' => array('0' => get_vocab('all_linked_rooms')));
+    generate_radio($params);
+    echo "</td>\n";
+  }
+  echo "</tr>\n";
+}
+echo "</table>\n";
+
+$options = array(0 => 'edit$$',
+                 1 => 'delete$$',
+                 2 => 'copy$$',
+                 3 => 'export$$');
+$params = array('name'    => 'action',
+                'label'   => '',
+                'options' => $options);
+generate_radio_group($params);
+?>
+
+
+
 <div id="view_entry_nav">
   <?php
   // Only show the links for Edit and Delete if the room is enabled.    We're
------------------------------------------------------------------------------
Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
MVPs and experts. ON SALE this month only -- learn more at:
http://p.sf.net/sfu/learnnow-d2d
_______________________________________________
Mrbs-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mrbs-commits

Reply via email to