Changeset: 86cc17606b3e https://sourceforge.net/p/mrbs/hg-code/ci/86cc17606b3e757b960f5ad1cc86c171e58f904c Author: Campbell Morrison <cimorri...@hg.code.sf.net> Date: Wed Apr 12 17:19:52 2017 +0100 Log message:
Fixed durations diffstat: web/functions.inc | 15 +++++---------- web/functions_view.inc | 12 ++++++------ web/mrbs_sql.inc | 9 ++++++++- web/report.php | 2 +- 4 files changed, 20 insertions(+), 18 deletions(-) diffs (114 lines): diff -r 17f9683caa60 -r 86cc17606b3e web/functions.inc --- a/web/functions.inc Wed Apr 12 12:40:19 2017 +0100 +++ b/web/functions.inc Wed Apr 12 17:19:52 2017 +0100 @@ -691,15 +691,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) { @@ -2144,12 +2144,7 @@ { global $strftime_format; - static $period_names = null; - - if (!isset($period_names)) - { - $period_names = get_period_names(); - } + $period_names = get_period_names(); $time = getdate($t); $p_num = $time["minutes"] + $mod_time; diff -r 17f9683caa60 -r 86cc17606b3e web/functions_view.inc --- a/web/functions_view.inc Wed Apr 12 12:40:19 2017 +0100 +++ b/web/functions_view.inc Wed Apr 12 17:19:52 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']; } diff -r 17f9683caa60 -r 86cc17606b3e web/mrbs_sql.inc --- a/web/mrbs_sql.inc Wed Apr 12 12:40:19 2017 +0100 +++ b/web/mrbs_sql.inc Wed Apr 12 17:19:52 2017 +0100 @@ -1378,7 +1378,7 @@ // Now get the duration. // Don't translate the units at this stage. We'll translate them later. - $d = get_duration($row['start_time'], $row['end_time'], $row['enable_periods'], FALSE); + $d = get_duration($row['start_time'], $row['end_time'], $row['enable_periods'], $row['area_id'], false); $row['duration'] = $d['duration']; $row['dur_units'] = $d['dur_units']; @@ -1631,6 +1631,13 @@ { global $tbl_area; + static $period_names = null; + + if (isset($period_names)) + { + return $period_names; + } + $period_names = array(); $sql = "SELECT id, periods FROM $tbl_area"; diff -r 17f9683caa60 -r 86cc17606b3e web/report.php --- a/web/report.php Wed Apr 12 12:40:19 2017 +0100 +++ b/web/report.php Wed Apr 12 17:19:52 2017 +0100 @@ -747,7 +747,7 @@ // changes so that the user sees what he expects to see $duration_seconds = $data['end_time'] - $data['start_time']; $duration_seconds -= cross_dst($data['start_time'], $data['end_time']); - $d = get_duration($data['start_time'], $data['end_time'], $data['enable_periods']); + $d = get_duration($data['start_time'], $data['end_time'], $data['enable_periods'], $data['area_id']); $d_string = $d['duration'] . ' ' . $d['dur_units']; $d_string = escape($d_string); case 'start_time': ------------------------------------------------------------------------------ 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 Mrbs-commits@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mrbs-commits