diff --git a/include/class.report.php b/include/class.report.php index 49ee202b59ea3871de7df35c99b3acc4d8135d41..d65fd1cc5a63fac47ff221763c104f148fc71c5d 100644 --- a/include/class.report.php +++ b/include/class.report.php @@ -24,11 +24,34 @@ class OverviewReport { var $start; var $end; - function __construct($start, $end='now') { + var $format; + + function __construct($start, $end='now', $format=null) { + global $cfg; + $this->start = $start; $this->end = $end; + $this->format = $format ?: $cfg->getDateFormat(true); } + + function getStartDate($format=null, $translate=true) { + + if (!$this->start) + return ''; + + $format = $format ?: $this->format; + if ($translate) { + $format = str_replace( + array('y', 'Y', 'm'), + array('yy', 'yyyy', 'mm'), + $format); + } + + return Format::date(Misc::dbtime($this->start), false, $format); + } + + function getDateRange() { global $cfg; diff --git a/include/staff/dashboard.inc.php b/include/staff/dashboard.inc.php index 0feb3f9d9b8b9f20543184e4c58ee02f2a219b2d..d7b35af5ee0485a9b352ad8e2224d2b3c7c24a07 100644 --- a/include/staff/dashboard.inc.php +++ b/include/staff/dashboard.inc.php @@ -19,9 +19,10 @@ $plots = $report->getPlotData(); <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 $_POST['start'] ? - Format::htmlchars($_POST['start']) : ''; ?>" /> + name="start" placeholder="<?php echo __('Last month');?>" + value="<?php + echo Format::htmlchars($report->getStartDate()); + ?>" /> </label> <label> <?php echo __( 'period');?>: