Changeset:
84a027ad97c1
https://sourceforge.net/p/mrbs/hg-code/ci/84a027ad97c11b58488344fbb13f51653af32337
Author:
Campbell Morrison <[email protected]>
Date:
Mon May 15 17:47:08 2017 +0100
Log message:
Merge
diffstat:
web/css/mrbs.css.php | 6 +++++-
web/edit_area_room.php | 13 +++++++++----
web/edit_entry.php | 23 +++++++++++++----------
web/functions.inc | 35 +++++++++++++++++++----------------
web/functions_view.inc | 16 ++++++++--------
web/js/edit_area_room.js.php | 7 +++++++
web/js/edit_entry.js.php | 5 +++--
web/month.php | 6 +++---
web/mrbs_sql.inc | 29 ++++++++++++++++++++++++++++-
web/pending.php | 2 +-
web/report.php | 6 +++---
web/search.php | 2 +-
12 files changed, 100 insertions(+), 50 deletions(-)
diffs (truncated from 478 to 300 lines):
diff -r d3c2becfe197 -r 84a027ad97c1 web/css/mrbs.css.php
--- a/web/css/mrbs.css.php Tue Apr 25 19:25:56 2017 +0100
+++ b/web/css/mrbs.css.php Mon May 15 17:47:08 2017 +0100
@@ -682,7 +682,9 @@
.js .delete_period {
display: inline-block;
- margin-left: 1em;
+ visibility: hidden; <?php // gets switched on by JavaScript ?>
+ padding: 0 1em;
+ opacity: 0.7;
}
.delete_period::after {
@@ -692,6 +694,8 @@
.delete_period:hover {
cursor: pointer;
+ opacity: 1;
+ font-weight: bold;
}
.js #period_settings button {
diff -r d3c2becfe197 -r 84a027ad97c1 web/edit_area_room.php
--- a/web/edit_area_room.php Tue Apr 25 19:25:56 2017 +0100
+++ b/web/edit_area_room.php Mon May 15 17:47:08 2017 +0100
@@ -464,11 +464,18 @@
{
global $periods;
- foreach ($periods as $period)
+ // For the JavaScript to work, and MRBS to make sense, there has to be at
least
+ // one period defined. So if for some reason, which shouldn't happen, there
aren't
+ // any periods defined, then force there to be one by creating a single
period name
+ // with an empty string. Because the input is a required input, then it
will have
+ // to be saved with a period name.
+ $period_names = empty($periods) ? array('') : $periods;
+
+ foreach ($period_names as $period_name)
{
echo "<div class=\"period_name\">\n";
echo "<label class=\"no_suffix\"></label>";
- echo "<input name=\"area_periods[]\" required value=\"" .
htmlspecialchars($period) . "\">";
+ echo "<input name=\"area_periods[]\" required value=\"" .
htmlspecialchars($period_name) . "\">";
echo "<span class=\"delete_period\"><span>\n";
echo "</div>\n";
}
@@ -498,7 +505,6 @@
echo "</fieldset>\n";
- /*
// and vice versa for the period settings
echo "<fieldset id=\"period_settings\"" .
(($enable_periods) ? '' : ' class="js_none"') .
@@ -508,7 +514,6 @@
create_fields_period_settings();
echo "</fieldset>\n";
- */
}
diff -r d3c2becfe197 -r 84a027ad97c1 web/edit_entry.php
--- a/web/edit_entry.php Tue Apr 25 19:25:56 2017 +0100
+++ b/web/edit_entry.php Mon May 15 17:47:08 2017 +0100
@@ -50,7 +50,7 @@
require "defaultincludes.inc";
require_once "mrbs_sql.inc";
-
+
$fields = db()->field_info($tbl_entry);
$custom_fields = array();
@@ -127,8 +127,6 @@
// $is_start Boolean. Whether this is the start
selector. Default FALSE
function genSlotSelector($area, $id, $name, $current_s, $display_none=FALSE,
$disabled=FALSE, $is_start=FALSE)
{
- global $periods;
-
$html = '';
// Check that $resolution is positive to avoid an infinite loop below.
@@ -177,7 +175,7 @@
{
if ($area['enable_periods'])
{
- $options[$s] = $periods[intval(($s-$base)/60)];
+ $options[$s] = $area['periods'][intval(($s-$base)/60)];
}
else
{
@@ -292,7 +290,7 @@
function create_field_entry_start_date($disabled=FALSE)
{
- global $start_time, $areas, $area_id, $periods, $id;
+ global $start_time, $areas, $area_id;
$date = getbookingdate($start_time);
$current_s = (($date['hours'] * 60) + $date['minutes']) * 60;
@@ -319,7 +317,7 @@
function create_field_entry_end_date($disabled=FALSE)
{
- global $end_time, $areas, $area_id, $periods, $multiday_allowed;
+ global $end_time, $areas, $area_id, $multiday_allowed;
$date = getbookingdate($end_time, TRUE);
$current_s = (($date['hours'] * 60) + $date['minutes']) * 60;
@@ -434,6 +432,7 @@
$attributes[] = 'style="display: none"';
// Put in some data about the area for use by the JavaScript
$attributes[] = 'data-enable_periods=' .
(($areas[$a]['enable_periods']) ? 1 : 0);
+ $attributes[] = 'data-n_periods=' .
count($areas[$a]['periods']);
$attributes[] = 'data-default_duration=' .
((isset($areas[$a]['default_duration']) && ($areas[$a]['default_duration'] !=
0)) ? $areas[$a]['default_duration'] : SECONDS_PER_HOUR);
$attributes[] = 'data-default_duration_all_day=' .
(($areas[$a]['default_duration_all_day']) ? 1 : 0);
$attributes[] = 'data-max_duration_enabled=' .
(($areas[$a]['max_duration_enabled']) ? 1 : 0);
@@ -972,6 +971,7 @@
}
$end_time = $start_time + $duration;
+
// Make sure the end_time falls within a booking day. So if there are no
// restrictions, bring it back to the nearest booking day. If the user
is not
// allowed multi-day bookings then make sure it is on the first booking
day.
@@ -984,7 +984,7 @@
$end_time = min($end_time, get_end_last_slot($month, $day, $year));
}
}
-
+
$rep_id = 0;
if (!isset($rep_type)) // We might have set it through a drag selection
{
@@ -1063,7 +1063,7 @@
// Get the details of all the enabled areas
$areas = array();
$sql = "SELECT id, area_name, resolution, default_duration,
default_duration_all_day,
- enable_periods, timezone,
+ enable_periods, periods, timezone,
morningstarts, morningstarts_minutes, eveningends ,
eveningends_minutes,
max_duration_enabled, max_duration_secs, max_duration_periods
FROM $tbl_area
@@ -1073,6 +1073,9 @@
for ($i = 0; ($row = $res->row_keyed($i)); $i++)
{
+ // Periods are JSON encoded in the database
+ $row['periods'] = json_decode($row['periods']);
+
// Make sure we've got the correct resolution when using periods (it's
// probably OK anyway, but just in case)
if ($row['enable_periods'])
@@ -1087,7 +1090,7 @@
{
$first = 12*SECONDS_PER_HOUR;
// If we're using periods we just go to the end of the last slot
- $last = $first + (count($periods) * $row['resolution']);
+ $last = $first + (count($row['periods']) * $row['resolution']);
}
else
{
@@ -1106,7 +1109,7 @@
// would be longer than the maximum duration allowed.
$row['show_all_day'] = $is_admin ||
!$row['max_duration_enabled'] ||
- ( ($row['enable_periods'] &&
($row['max_duration_periods'] >= count($periods))) ||
+ ( ($row['enable_periods'] &&
($row['max_duration_periods'] >= count($row['periods']))) ||
(!$row['enable_periods'] &&
($row['max_duration_secs'] >= ($last - $first))) );
// Clean up the settings, getting rid of any nulls and casting boolean
fields into bools
diff -r d3c2becfe197 -r 84a027ad97c1 web/functions.inc
--- a/web/functions.inc Tue Apr 25 19:25:56 2017 +0100
+++ b/web/functions.inc Mon May 15 17:47:08 2017 +0100
@@ -696,15 +696,15 @@
// $end_time int end time as a Unix timestamp
// $enable_periods boolean whether we are using periods
// $translate boolean whether to translate into the browser language
-function get_duration($start_time, $end_time, $enable_periods, $translate=TRUE)
+function get_duration($start_time, $end_time, $enable_periods, $area_id,
$translate=true)
{
- global $periods;
+ $result = array();
- $result = array();
+ $period_names = get_period_names();
if ($enable_periods)
{
- $periods_per_day = count($periods);
+ $periods_per_day = count($period_names[$area_id]);
$n_periods = get_period_interval($start_time, $end_time); // this handles
DST
if (($n_periods % $periods_per_day) == 0)
{
@@ -2145,28 +2145,31 @@
}
-function period_date_string($t, $mod_time=0)
+function period_date_string($t, $area_id, $mod_time=0)
{
- global $periods, $strftime_format;
-
+ global $strftime_format;
+
+ $period_names = get_period_names();
+
$time = getdate($t);
$p_num = $time["minutes"] + $mod_time;
if( $p_num < 0 )
{
$p_num = 0;
}
- if( $p_num >= count($periods) - 1 )
+ if( $p_num >= count($period_names[$area_id]) - 1 )
{
- $p_num = count($periods ) - 1;
+ $p_num = count($period_names[$area_id]) - 1;
}
- // I have made the separator a ',' as a '-' leads to an ambiguious
+ // The separator is a ',' as a '-' leads to an ambiguious
// display in report.php when showing end times.
- return array($p_num, $periods[$p_num] . utf8_strftime(", " .
$strftime_format['date'], $t));
+ return array($p_num, $period_names[$area_id][$p_num] . utf8_strftime(", " .
$strftime_format['date'], $t));
}
-function period_time_string($t, $mod_time=0)
+
+function period_time_string($t, $area_id, $mod_time=0)
{
- global $periods;
+ $period_names = get_period_names();
$time = getdate($t);
$p_num = $time["minutes"] + $mod_time;
@@ -2174,11 +2177,11 @@
{
$p_num = 0;
}
- if ( $p_num >= count($periods) - 1 )
+ if ( $p_num >= count($period_names[$area_id]) - 1 )
{
- $p_num = count($periods ) - 1;
+ $p_num = count($period_names[$area_id]) - 1;
}
- return $periods[$p_num];
+ return $period_names[$area_id][$p_num];
}
function time_date_string($t)
diff -r d3c2becfe197 -r 84a027ad97c1 web/functions_view.inc
--- a/web/functions_view.inc Tue Apr 25 19:25:56 2017 +0100
+++ b/web/functions_view.inc Mon May 15 17:47:08 2017 +0100
@@ -5,7 +5,7 @@
// a table row of details. The first column is the $label and the second
column
// the $value. $class is an optional class name which can be applied to the
// second column.
-function create_details_row($label, $value, $as_html=FALSE, $class='')
+function create_details_row($label, $value, $as_html=false, $class='')
{
$result = '';
if ($as_html)
@@ -27,13 +27,13 @@
// Returns a string containg a set of details for $data consisting of a
label/value
-// pair for each data element in the array $data. If $as_html is TRUE then
the string
+// pair for each data element in the array $data. If $as_html is true then
the string
// is the HTML for a table body, ie looks like "<tbody> ... </tbody>".
-// $keep_private boolean if TRUE then any private fields will be given
the class 'private';
+// $keep_private boolean if true then any private fields will be given
the class 'private';
// note that $data must already have had values
substituted
// for private fields
-// $room_disabled boolean if TRUE then a note will be added that the
room is disabled
-function create_details_body($data, $as_html=FALSE, $keep_private=FALSE,
$room_disabled=FALSE)
+// $room_disabled boolean if true then a note will be added that the
room is disabled
+function create_details_body($data, $as_html=false, $keep_private=false,
$room_disabled=false)
{
global $enable_periods, $confirmation_enabled, $approval_enabled;
global $is_private_field, $standard_fields;
@@ -45,7 +45,7 @@
if (!isset($data['duration']))
{
// We will translate the units later
- $d = get_duration($data['start_time'], $data['end_time'], $enable_periods,
FALSE);
+ $d = get_duration($data['start_time'], $data['end_time'], $enable_periods,
$data['area_id'], false);
$data['duration'] = $d['duration'];
$data['dur_units'] = $d['dur_units'];
}
@@ -121,7 +121,7 @@
// Start date
if ($enable_periods)
{
- list($start_period, $start_date) =
period_date_string($data['start_time']);
+ list($start_period, $start_date) =
period_date_string($data['start_time'], $data['area_id']);
}
else
{
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Mrbs-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mrbs-commits