diff --git a/include/class.report.php b/include/class.report.php index efa078001d6d60154236e59b7590160a7630d233..49ee202b59ea3871de7df35c99b3acc4d8135d41 100644 --- a/include/class.report.php +++ b/include/class.report.php @@ -35,13 +35,19 @@ class OverviewReport { $start = $this->start ?: 'last month'; $stop = $this->end ?: 'now'; - $start = strtotime($start); - - if (substr($stop, 0, 1) == '+') - $stop = strftime('%Y-%m-%d ', $start) . $stop; + // Convert user time to db time + $start = Misc::dbtime($start); + // Stop time can be relative. + if ($stop[0] == '+') { + // $start time + time(X days) + $now = time(); + $stop = $start + (strtotime($stop, $now)-$now); + } else { + $stop = Misc::dbtime($stop); + } $start = 'FROM_UNIXTIME('.$start.')'; - $stop = 'FROM_UNIXTIME('.strtotime($stop).')'; + $stop = 'FROM_UNIXTIME('.$stop.')'; return array($start, $stop); } diff --git a/include/staff/dashboard.inc.php b/include/staff/dashboard.inc.php index d75ee3ef97621897d87f86439b1b82c465764de3..0feb3f9d9b8b9f20543184e4c58ee02f2a219b2d 100644 --- a/include/staff/dashboard.inc.php +++ b/include/staff/dashboard.inc.php @@ -18,8 +18,10 @@ $plots = $report->getPlotData(); <?php echo csrf_token(); ?> <label> <?php echo __( 'Report timeframe'); ?>: - <input type="text" class="dp input-medium search-query" name="start" placeholder="<?php echo __('Last month');?>"i - value="<?php echo Format::htmlchars($_POST['start']); ?>" /> + <input type="text" class="dp input-medium search-query" + name="start" placeholder="<?php echo __('Last month');?>"i + value="<?php echo $_POST['start'] ? + Format::htmlchars($_POST['start']) : ''; ?>" /> </label> <label> <?php echo __( 'period');?>: