Skip to content
Snippets Groups Projects
Commit fbcd756c authored by Peter Rotich's avatar Peter Rotich
Browse files

datepicker: Use consistent date format

To avoid date format ambiguity the datepicker replaces entered date with a
standard 'ISO 8601' date format on form submission. The system however fails
to use datepicker's format on post-back, resulting in invalid date on
subsequent submit.

This pull request addresses the issue by making sure reflected date uses the
format datepicker expects.
parent ae422bb7
No related branches found
No related tags found
No related merge requests found
......@@ -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;
......
......@@ -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');?>:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment