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 --- .../statistics_reporting/page.inc.php | 23 ++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) (limited to 'modules-available/statistics_reporting/page.inc.php') 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; -- cgit v1.2.3-55-g7522