From 8de3d8b5d05754536cb66f3e5b15250440c4ed15 Mon Sep 17 00:00:00 2001 From: Udo Walter Date: Wed, 15 Jan 2020 17:42:44 +0100 Subject: [statistics_reporting] Add date range selection --- modules-available/statistics_reporting/config.json | 3 +- .../statistics_reporting/page.inc.php | 23 ++++++++++--- .../templates/columnChooser.html | 38 ++++++++++++++-------- 3 files changed, 46 insertions(+), 18 deletions(-) diff --git a/modules-available/statistics_reporting/config.json b/modules-available/statistics_reporting/config.json index c439efa8..2bd54eb1 100644 --- a/modules-available/statistics_reporting/config.json +++ b/modules-available/statistics_reporting/config.json @@ -4,6 +4,7 @@ "statistics", "locations", "js_stupidtable", - "js_jqueryui" + "js_jqueryui", + "bootstrap_datepicker" ] } \ No newline at end of file diff --git a/modules-available/statistics_reporting/page.inc.php b/modules-available/statistics_reporting/page.inc.php index cc03e4d8..45f93144 100644 --- a/modules-available/statistics_reporting/page.inc.php +++ b/modules-available/statistics_reporting/page.inc.php @@ -11,7 +11,11 @@ class Page_Statistics_Reporting extends Page /** * @var int */ - private $days; + private $from; + /** + * @var int + */ + private $to; /** * @var int */ @@ -46,7 +50,11 @@ class Page_Statistics_Reporting extends Page $this->action = Request::any('action', 'show', 'string'); $this->type = Request::get('type', 'total', 'string'); - $this->days = Request::get('cutoff', 7, 'int'); + + // Format: yyyy-mm-dd + $fromString = Request::get('from', '-6 days', 'string'); + $toString = Request::get('to', 'today', 'string'); + $this->lower = Request::get('lower', 8, 'int'); $this->upper = Request::get('upper', 20, 'int'); @@ -55,9 +63,13 @@ class Page_Statistics_Reporting extends Page $this->type = 'total'; } + // convert from/to dates to unixtime + $this->from = min(strtotime($fromString.' 00:00:00'), time()); + $this->to = min(strtotime($toString.' 23:59:59'), time()); + // timespan you want to see. default = last 7 days - GetData::$from = strtotime("-" . ($this->days - 1) . " days 00:00:00"); - GetData::$to = time(); + GetData::$from = $this->from; + GetData::$to = $this->to; GetData::$lowerTimeBound = $this->lower; GetData::$upperTimeBound = $this->upper; /* @@ -134,6 +146,9 @@ class Page_Statistics_Reporting extends Page ); } + $data['from'] = date_format(date_timestamp_set(new DateTime(), $this->from), 'Y-m-d'); + $data['to'] = date_format(date_timestamp_set(new DateTime(), $this->to), 'Y-m-d'); + $data['lower'] = $this->lower; $data['upper'] = $this->upper; diff --git a/modules-available/statistics_reporting/templates/columnChooser.html b/modules-available/statistics_reporting/templates/columnChooser.html index d6ff90b7..8664f776 100644 --- a/modules-available/statistics_reporting/templates/columnChooser.html +++ b/modules-available/statistics_reporting/templates/columnChooser.html @@ -14,7 +14,23 @@ {{lang_displaySelection}}
-
+
+
+ From: +
+ + +
+
+
+ To: +
+ + +
+
+
+
-
- -
-
+ +
@@ -37,10 +47,8 @@
-
- -
-
+
+