Changeset:
842bd4f37570
https://sourceforge.net/p/mrbs/hg-code/ci/842bd4f37570e16e8ba95367239d82d44c41efa2
Author:
Campbell Morrison <[email protected]>
Date:
Thu Apr 13 11:29:18 2017 +0100
Log message:
Commit of work to date
diffstat:
web/edit_entry.php | 22 ++++++++++++----------
web/js/edit_entry.js.php | 2 +-
2 files changed, 13 insertions(+), 11 deletions(-)
diffs (114 lines):
diff -r d9cdf2b7aafb -r 842bd4f37570 web/edit_entry.php
--- a/web/edit_entry.php Wed Apr 12 17:29:34 2017 +0100
+++ b/web/edit_entry.php Thu Apr 13 11:29:18 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;
@@ -972,6 +970,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 +983,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 +1062,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 +1072,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 +1089,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 +1108,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 d9cdf2b7aafb -r 842bd4f37570 web/js/edit_entry.js.php
--- a/web/js/edit_entry.js.php Wed Apr 12 17:29:34 2017 +0100
+++ b/web/js/edit_entry.js.php Thu Apr 13 11:29:18 2017 +0100
@@ -76,7 +76,7 @@
// by default the current area
var areaConfig = function areaConfig(property, areaId) {
- var properties = ['enable_periods', 'default_duration',
'max_duration_enabled',
+ var properties = ['enable_periods', 'periods', 'default_duration',
'max_duration_enabled',
'max_duration_secs', 'max_duration_periods',
'max_duration_qty',
'max_duration_units', 'timezone'];
var i, p, room;
------------------------------------------------------------------------------
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