Revision: 1745
http://mrbs.svn.sourceforge.net/mrbs/?rev=1745&view=rev
Author: cimorrison
Date: 2011-01-20 11:38:37 +0000 (Thu, 20 Jan 2011)
Log Message:
-----------
- Fixed a bug whereby book ahead policies would not be applied when using
periods, depending on what settings were already in the database. See SF
Support Request #3161926
- At the same time removed the restriction that book ahead policies cannot be
set per-area when using periods
Modified Paths:
--------------
mrbs/trunk/web/Themes/default/header.inc
mrbs/trunk/web/edit_area_room.php
mrbs/trunk/web/lang.en
mrbs/trunk/web/mrbs.css.php
mrbs/trunk/web/mrbs_sql.inc
mrbs/trunk/web/systemdefaults.inc.php
Modified: mrbs/trunk/web/Themes/default/header.inc
===================================================================
--- mrbs/trunk/web/Themes/default/header.inc 2011-01-13 11:12:05 UTC (rev
1744)
+++ mrbs/trunk/web/Themes/default/header.inc 2011-01-20 11:38:37 UTC (rev
1745)
@@ -230,7 +230,8 @@
{
speed = 'slow';
}
- if (form.area_enable_periods[0].checked != enablePeriods)
+ var periodsChecked = form.area_enable_periods[0].checked;
+ if (periodsChecked != enablePeriods)
{
enablePeriods = !enablePeriods;
$('#time_settings').animate({
@@ -238,10 +239,19 @@
height: 'toggle'
}, speed);
}
+ <? // Show or Hide the note about periods as appropriate ?>
+ if (periodsChecked)
+ {
+ $('#book_ahead_periods_note').show(speed);
+ }
+ else
+ {
+ $('#book_ahead_periods_note').hide(speed);
+ }
}
// disable the min and max book ahead values and units if the corresponding
- // checkbox isn't checkd; and enable it it is.
+ // checkbox isn't checked; and enable it it is.
function check_book_ahead()
{
var form = document.getElementById('edit_area');
@@ -733,6 +743,7 @@
// We need to hide the sections of the form relating to times
// slots if the form is loaded with periods enabled. We hide
// the times sections instantly by setting speed = 0;
+ // Also show or hide the periods note as appropriate
// [This method works if there are no periods-specific settings.
// When we get those we will have to do something different]
?>
@@ -743,7 +754,12 @@
if (form.area_enable_periods[0].checked)
{
toggleMode(form, 0);
+ $('#book_ahead_periods_note').show();
}
+ else
+ {
+ $('#book_ahead_periods_note').hide();
+ }
check_book_ahead();
}
Modified: mrbs/trunk/web/edit_area_room.php
===================================================================
--- mrbs/trunk/web/edit_area_room.php 2011-01-13 11:12:05 UTC (rev 1744)
+++ mrbs/trunk/web/edit_area_room.php 2011-01-20 11:38:37 UTC (rev 1745)
@@ -326,6 +326,21 @@
// Convert the book ahead times into seconds
fromTimeString($area_min_ba_value, $area_min_ba_units);
fromTimeString($area_max_ba_value, $area_max_ba_units);
+
+ // If we are using periods, round these down to the nearest whole day
+ // (anything less than a day is meaningless when using periods)
+ if ($area_enable_periods)
+ {
+ $secs_in_day = 60*60*24;
+ if (isset($area_min_ba_value))
+ {
+ $area_min_ba_value -= $area_min_ba_value%$secs_in_day;
+ }
+ if (isset($area_max_ba_value))
+ {
+ $area_max_ba_value -= $area_max_ba_value%$secs_in_day;
+ }
+ }
// Convert booleans into 0/1 (necessary for PostgreSQL)
$area_disabled = (!empty($area_disabled)) ? 1 : 0;
@@ -379,25 +394,27 @@
$assign_array[] = "custom_html='" . addslashes($custom_html) . "'";
if (!$area_enable_periods)
{
- // only update the min and max book_ahead_secs fields if the form
values
- // are set; they might be NULL because they've been disabled by
JavaScript
$assign_array[] = "resolution=" . $area_res_mins * 60;
$assign_array[] = "default_duration=" . $area_def_duration_mins * 60;
$assign_array[] = "morningstarts=" . $area_morningstarts;
$assign_array[] = "morningstarts_minutes=" .
$area_morningstarts_minutes;
$assign_array[] = "eveningends=" . $area_eveningends;
$assign_array[] = "eveningends_minutes=" . $area_eveningends_minutes;
- $assign_array[] = "min_book_ahead_enabled=" . $area_min_ba_enabled;
- $assign_array[] = "max_book_ahead_enabled=" . $area_max_ba_enabled;
- if (isset($area_min_ba_value))
- {
- $assign_array[] = "min_book_ahead_secs=" . $area_min_ba_value;
- }
- if (isset($area_max_ba_value))
- {
- $assign_array[] = "max_book_ahead_secs=" . $area_max_ba_value;
- }
}
+
+ // only update the min and max book_ahead_secs fields if the form values
+ // are set; they might be NULL because they've been disabled by
JavaScript
+ $assign_array[] = "min_book_ahead_enabled=" . $area_min_ba_enabled;
+ $assign_array[] = "max_book_ahead_enabled=" . $area_max_ba_enabled;
+ if (isset($area_min_ba_value))
+ {
+ $assign_array[] = "min_book_ahead_secs=" . $area_min_ba_value;
+ }
+ if (isset($area_max_ba_value))
+ {
+ $assign_array[] = "max_book_ahead_secs=" . $area_max_ba_value;
+ }
+
$assign_array[] = "private_enabled=" . $area_private_enabled;
$assign_array[] = "private_default=" . $area_private_default;
$assign_array[] = "private_mandatory=" . $area_private_mandatory;
@@ -845,9 +862,7 @@
//]]>
</script>
- <fieldset id="time_settings">
- <legend></legend>
- <fieldset >
+ <fieldset id="time_settings">
<legend><?php echo get_vocab("time_settings")?>
<span class="js_none"> (<?php echo get_vocab("times_only")
?>)</span>
</legend>
@@ -955,8 +970,11 @@
$max_ba_value = $max_book_ahead_secs;
toTimeString($max_ba_value, $max_ba_units);
echo "<fieldset id=\"booking_policies\">\n";
- echo "<legend>" . get_vocab("booking_policies") .
- "<span class=\"js_none\"> (" . get_vocab("times_only") .
")</span></legend>\n";
+ echo "<legend>" . get_vocab("booking_policies") . "</legend>\n";
+ // Note when using periods
+ echo "<div id=\"book_ahead_periods_note\">\n";
+ echo "<label></label><span>" . get_vocab("book_ahead_note_periods") .
"</span>";
+ echo "</div>\n";
// Minimum book ahead
echo "<div>\n";
echo "<label for=\"area_min_book_ahead\">" . get_vocab("min_book_ahead")
. ":</label>\n";
@@ -993,7 +1011,6 @@
echo "</div>\n";
echo "</fieldset>\n";
?>
- </fieldset>
<fieldset>
<legend><?php echo get_vocab("confirmation_settings")?></legend>
Modified: mrbs/trunk/web/lang.en
===================================================================
--- mrbs/trunk/web/lang.en 2011-01-13 11:12:05 UTC (rev 1744)
+++ mrbs/trunk/web/lang.en 2011-01-20 11:38:37 UTC (rev 1745)
@@ -385,6 +385,7 @@
$vocab["disabled_room_note"] = "If this room is disabled, it will not
appear in the calendar views " .
"and it will not be possible to book it.
However existing bookings " .
"will be preserved and will be visible in
Search and Report results.";
+$vocab["book_ahead_note_periods"] = "When using periods, book ahead times are
rounded down to the nearest whole day.";
// Used in edit_users.php
$vocab["name_empty"] = "You must enter a name.";
Modified: mrbs/trunk/web/mrbs.css.php
===================================================================
--- mrbs/trunk/web/mrbs.css.php 2011-01-13 11:12:05 UTC (rev 1744)
+++ mrbs/trunk/web/mrbs.css.php 2011-01-20 11:38:37 UTC (rev 1745)
@@ -464,6 +464,7 @@
.edit_area_room .form_general fieldset fieldset legend {font-size: small;
font-style: italic; font-weight: normal}
.edit_area_room fieldset#time_settings {padding:0; margin 0}
span#private_display_caution {display: block; margin-top: 1em; font-style:
italic; font-weight: normal}
+#book_ahead_periods_note span {display: block; float: left; width: 24em;
margin: 0 0 1em 1em; font-style: italic}
.edit_area_room .form_general textarea {height: 6em; width: 25em}
.edit_area_room div#custom_html {margin-top: 8px}
Modified: mrbs/trunk/web/mrbs_sql.inc
===================================================================
--- mrbs/trunk/web/mrbs_sql.inc 2011-01-13 11:12:05 UTC (rev 1744)
+++ mrbs/trunk/web/mrbs_sql.inc 2011-01-20 11:38:37 UTC (rev 1745)
@@ -106,17 +106,23 @@
function mrbsCheckPolicy($starttime, $delete=FALSE)
{
global $min_book_ahead_enabled, $max_book_ahead_enabled, $enable_periods;
- global $min_book_ahead_secs, $max_book_ahead_secs, $min_book_ahead_days,
$max_book_ahead_days;
+ global $min_book_ahead_secs, $max_book_ahead_secs;
$error = "";
+ $secs_in_day = 60*60*24;
// Because MRBS has no notion of where we are in the day if we're using
periods,
// we'll just assume that we're at the beginning of the day.
$now = ($enable_periods) ? mktime(0, 0, 0) : time();
+ // We'll also round $min_book_ahead_secs and $max_book_ahead_secs down to
the nearest whole day
if ($min_book_ahead_enabled)
{
- $min_book_ahead = ($enable_periods) ? ($min_book_ahead_days * 60*60*24) :
$min_book_ahead_secs;
+ if ($enable_periods)
+ {
+ $min_book_ahead_secs -= $min_book_ahead_secs%$secs_in_day;
+ }
+ $min_book_ahead = $min_book_ahead_secs;
if (($starttime - $now) < $min_book_ahead)
{
toTimeString($min_book_ahead, $units);
@@ -127,7 +133,11 @@
if ($max_book_ahead_enabled)
{
- $max_book_ahead = ($enable_periods) ? ($max_book_ahead_days * 60*60*24) :
$max_book_ahead_secs;
+ if ($enable_periods)
+ {
+ $max_book_ahead_secs -= $max_book_ahead_secs%$secs_in_day;
+ }
+ $max_book_ahead = $max_book_ahead_secs;
if (($starttime - $now) > $max_book_ahead)
{
toTimeString($max_book_ahead, $units);
Modified: mrbs/trunk/web/systemdefaults.inc.php
===================================================================
--- mrbs/trunk/web/systemdefaults.inc.php 2011-01-13 11:12:05 UTC (rev
1744)
+++ mrbs/trunk/web/systemdefaults.inc.php 2011-01-20 11:38:37 UTC (rev
1745)
@@ -242,43 +242,30 @@
// book more than so far in advance. How the times are determined depends on
whether Periods
// or Times are being used. These settings also apply to the deletion of
bookings.
-// DEFAULT VALUES FOR NEW AREAS (WHEN USING TIMES)
+// DEFAULT VALUES FOR NEW AREAS
$min_book_ahead_enabled = FALSE; // set to TRUE to enforce a minimum
advance booking time
$max_book_ahead_enabled = FALSE; // set to TRUE to enforce a maximum
advance booking time
-// TIMES SETTINGS
-// --------------
-// When times are being used the advance booking limits are measured in
seconds and are
-// set by the two variables below. The relevant time for determining whether
a booking is
-// allowed is the start time of the booking. Values may be negative: for
example setting
-// $min_book_ahead_secs = -300 means that users cannot book more than 5
minutes in the past.
+// The advance booking limits are measured in seconds and are set by the two
variables below.
+// The relevant time for determining whether a booking is allowed is the start
time of the
+// booking. Values may be negative: for example setting $min_book_ahead_secs
= -300 means
+// that users cannot book more than 5 minutes in the past.
// DEFAULT VALUES FOR NEW AREAS
$min_book_ahead_secs = 0; // (seconds) cannot book in the past
$max_book_ahead_secs = 60*60*24*7; // (seconds) no more than one week ahead
-// NOTE: When times are being used, the four book_ahead settings are all set
per area through
-// MRBS and the values are held in the database. They can be set or unset
for each area
-// when editing the area using the web browser. The variables above are in
fact
-// the default settings that are used when a new area is created.
-//
-//
-// PERIODS SETTINGS
-// ----------------
-// If you are using periods, MRBS has no notion of when the periods occur
during the
+// NOTE: If you are using periods, MRBS has no notion of when the periods
occur during the
// day, and so cannot impose policies of the kind "users must book at least
one period
// in advance". However it can impose policies such as "users must book at
least
-// one day in advance" and this is done by setting the two variables below.
As MRBS does
-// not know when the periods occur in the day, there is no way of specifying,
for example,
-// that bookings must be made at least 24 hours in advance. Setting
$min_book_ahead_days=1
+// one day in advance". The two values above are rounded down to the nearest
whole
+// number of days when using periods. For example 86401 will be rounded down
to 86400
+// (one day) and 1 will be rounded down to 0.
+//
+// As MRBS does not know when the periods occur in the day, there is no way of
specifying, for example,
+// that bookings must be made at least 24 hours in advance. Setting
$min_book_ahead_secs=86400
// will allow somebody to make a booking at 11:59 pm for the first period the
next day, which
// which may occur at 8.00 am.
-//
-$min_book_ahead_days = 0; // (days) cannot book in the past
-$max_book_ahead_days = 7; // (days) no more than one week ahead
-//
-// Currently MRBS does not store periods settings per area. So the values
above are
-// applied globally to all periods if they are being used.
/******************
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Protect Your Site and Customers from Malware Attacks
Learn about various malware tactics and how to avoid them. Understand
malware threats, the impact they can have on your business, and how you
can protect your company and customers by using code signing.
http://p.sf.net/sfu/oracle-sfdevnl
_______________________________________________
Mrbs-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mrbs-commits