Changeset:
fca2b62201c1
https://sourceforge.net/p/mrbs/hg-code/ci/fca2b62201c17b9ae6d0afc025a3444265cad2c1
Author:
Campbell Morrison <[email protected]>
Date:
Tue Mar 28 18:59:44 2017 +0100
Log message:
Added day/week/month navigation buttons
diffstat:
web/css/mrbs.css.php | 14 ++++++++++++--
web/functions.inc | 38 ++++++++++++++++++++++++++++++++++++++
web/index.php | 28 +++++++++++++++++++++++++++-
web/view_entry.php | 37 -------------------------------------
4 files changed, 77 insertions(+), 40 deletions(-)
diffs (169 lines):
diff -r 81853131ccbc -r fca2b62201c1 web/css/mrbs.css.php
--- a/web/css/mrbs.css.php Tue Mar 28 17:33:23 2017 +0100
+++ b/web/css/mrbs.css.php Tue Mar 28 18:59:44 2017 +0100
@@ -1479,7 +1479,17 @@
border-right: 0;
}
+nav.view {
+ display: table;
+ margin-top: 2em;
+}
+nav.view form {
+ display: table-cell;
+ width: 33.333%;
+ padding: 0 0.5em;
+}
-
-
+nav.view input {
+ width: 100%;
+}
diff -r 81853131ccbc -r fca2b62201c1 web/functions.inc
--- a/web/functions.inc Tue Mar 28 17:33:23 2017 +0100
+++ b/web/functions.inc Tue Mar 28 18:59:44 2017 +0100
@@ -1754,6 +1754,44 @@
}
+// Generates a single button. Parameters in the array $params
+//
+// Manadatory parameters
+// action The form action attribute
+// value The value of the button
+// inputs An array of hidden form inputs
+//
+// Optional parameters
+// button_attributes An array of attributes to be used for the button.
+function generate_button(array $params, array $button_attributes=array())
+{
+ // Note that until IE supports the form attribute on the button tag, we can't
+ // use a <button> here and have to use the <input type="submit"> to create
the
+ // button. This unfortunately means that styling options on the button are
limited.
+
+ $html = '';
+
+ $html .= "<form method=\"post\" action=\"" .
htmlspecialchars($params['action']) . "\">\n";
+
+ foreach ($params['inputs'] as $key => $value)
+ {
+ $html .= '<input type="hidden" name="' . htmlspecialchars($key) . '"' .
+ ' value="' . htmlspecialchars($value) . "\">\n";
+ }
+
+ $html .= '<input type="submit" value="' . htmlspecialchars($params['value'])
. '"';
+ foreach($button_attributes as $key => $value)
+ {
+ $html .= " $key=\"" . htmlspecialchars($value) . '"';
+ }
+ $html .= ">\n";
+
+ $html .= "</form>\n";
+
+ echo $html;
+}
+
+
// Escape a PHP string for use in JavaScript
//
// Based on a function contributed by kongaspar at gmail dot com at
diff -r 81853131ccbc -r fca2b62201c1 web/index.php
--- a/web/index.php Tue Mar 28 17:33:23 2017 +0100
+++ b/web/index.php Tue Mar 28 18:59:44 2017 +0100
@@ -4,6 +4,31 @@
require "defaultincludes.inc";
+function print_view_nav()
+{
+ global $area, $year, $month, $day;
+
+ echo "<nav class=\"view\">\n";
+
+ $views = array('day', 'week', 'month');
+
+ foreach ($views as $view)
+ {
+ $params = array('action' => this_page(),
+ 'value' => $view,
+ 'inputs' => array('view' => $view,
+ 'area' => $area,
+ 'year' => $year,
+ 'month' => $month,
+ 'day' => $day)
+ );
+ generate_button($params);
+ }
+
+ echo "</nav>\n";
+}
+
+
// Gets the booking interval (start first slot to end last slot)
// for a given view. Returns an array indexed by 'start' and 'end'.
function get_interval($view, $month, $day, $year)
@@ -278,7 +303,7 @@
exit;
}
-$view = 'day';
+$view = get_form_var('view', 'string', $default_view);
$interval = get_interval($view, $month, $day, $year);
$entries = get_entries_by_area($area, $interval['start'], $interval['end']);
$map = get_map($area, $entries, $interval);
@@ -287,5 +312,6 @@
print_header($day, $month, $year, $area, isset($room) ? $room : null);
// Show all available areas
echo make_area_select_html('index.php', $area, $year, $month, $day);
+print_view_nav();
echo get_table($map);
output_trailer();
diff -r 81853131ccbc -r fca2b62201c1 web/view_entry.php
--- a/web/view_entry.php Tue Mar 28 17:33:23 2017 +0100
+++ b/web/view_entry.php Tue Mar 28 18:59:44 2017 +0100
@@ -5,43 +5,6 @@
require_once "mrbs_sql.inc";
require_once "functions_view.inc";
-// Generates a single button. Parameters in the array $params
-//
-// Manadatory parameters
-// action The form action attribute
-// value The value of the button
-// inputs An array of hidden form inputs
-//
-// Optional parameters
-// button_attributes An array of attributes to be used for the button.
-function generate_button(array $params, array $button_attributes=array())
-{
- // Note that until IE supports the form attribute on the button tag, we can't
- // use a <button> here and have to use the <input type="submit"> to create
the
- // button. This unfortunately means that styling options on the button are
limited.
-
- $html = '';
-
- $html .= "<form method=\"post\" action=\"" .
htmlspecialchars($params['action']) . "\">\n";
-
- foreach ($params['inputs'] as $key => $value)
- {
- $html .= '<input type="hidden" name="' . htmlspecialchars($key) . '"' .
- ' value="' . htmlspecialchars($value) . "\">\n";
- }
-
- $html .= '<input type="submit" value="' . htmlspecialchars($params['value'])
. '"';
- foreach($button_attributes as $key => $value)
- {
- $html .= " $key=\"" . htmlspecialchars($value) . '"';
- }
- $html .= ">\n";
-
- $html .= "</form>\n";
-
- echo $html;
-}
-
// Generates the Approve, Reject and More Info buttons
function generateApproveButtons($id, $series)
------------------------------------------------------------------------------
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