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

Merge pull request #520 from greezybacon/issue/report-timeframe


oops: Fix report time frame interpretation

Reviewed-By: default avatarPeter Rotich <peter@osticket.com>
parents 73a433fd 19c9de50
No related branches found
No related tags found
No related merge requests found
...@@ -37,17 +37,7 @@ class OverviewReportAjaxAPI extends AjaxController { ...@@ -37,17 +37,7 @@ class OverviewReportAjaxAPI extends AjaxController {
function getData() { function getData() {
global $thisstaff; global $thisstaff;
if(($start = $this->get('start', 'last month'))) { list($start, $stop) = $this->_getDateRange();
$stop = $this->get('stop', 'now');
if (substr($stop, 0, 1) == '+')
$stop = $start . $stop;
} else {
$start = 'last month';
$stop = 'now';
}
$start = 'FROM_UNIXTIME('.strtotime($start).')';
$stop = 'FROM_UNIXTIME('.strtotime($stop).')';
$groups = array( $groups = array(
"dept" => array( "dept" => array(
...@@ -172,26 +162,38 @@ class OverviewReportAjaxAPI extends AjaxController { ...@@ -172,26 +162,38 @@ class OverviewReportAjaxAPI extends AjaxController {
'text/csv', $csv); 'text/csv', $csv);
} }
function getPlotData() { function _getDateRange() {
global $cfg;
if(($start = $this->get('start', 'last month'))) { if(($start = $this->get('start', 'last month'))) {
$stop = $this->get('stop', 'now'); $stop = $this->get('period', 'now');
if (substr($stop, 0, 1) == '+')
$stop = $start . $stop;
} else { } else {
$start = 'last month'; $start = 'last month';
$stop = 'now'; $stop = $this->get('period', 'now');
} }
$start = strtotime($start); if ($start != 'last month')
$stop = strtotime($stop); $start = DateTime::createFromFormat($cfg->getDateFormat(),
$start)->format('U');
else
$start = strtotime($start);
if (substr($stop, 0, 1) == '+')
$stop = strftime('%Y-%m-%d ', $start) . $stop;
$start = 'FROM_UNIXTIME('.$start.')';
$stop = 'FROM_UNIXTIME('.strtotime($stop).')';
return array($start, $stop);
}
function getPlotData() {
list($start, $stop) = $this->_getDateRange();
# Fetch all types of events over the timeframe # Fetch all types of events over the timeframe
$res = db_query('SELECT DISTINCT(state) FROM '.TICKET_EVENT_TABLE $res = db_query('SELECT DISTINCT(state) FROM '.TICKET_EVENT_TABLE
.' WHERE timestamp BETWEEN FROM_UNIXTIME('.db_input($start) .' WHERE timestamp BETWEEN '.$start.' AND '.$stop
.') AND FROM_UNIXTIME('.db_input($stop) .' ORDER BY 1');
.') ORDER BY 1');
$events = array(); $events = array();
while ($row = db_fetch_row($res)) $events[] = $row[0]; while ($row = db_fetch_row($res)) $events[] = $row[0];
...@@ -200,9 +202,8 @@ class OverviewReportAjaxAPI extends AjaxController { ...@@ -200,9 +202,8 @@ class OverviewReportAjaxAPI extends AjaxController {
$res = db_query('SELECT state, DATE_FORMAT(timestamp, \'%Y-%m-%d\'), ' $res = db_query('SELECT state, DATE_FORMAT(timestamp, \'%Y-%m-%d\'), '
.'COUNT(ticket_id)' .'COUNT(ticket_id)'
.' FROM '.TICKET_EVENT_TABLE .' FROM '.TICKET_EVENT_TABLE
.' WHERE timestamp BETWEEN FROM_UNIXTIME('.db_input($start) .' WHERE timestamp BETWEEN '.$start.' AND '.$stop
.') AND FROM_UNIXTIME('.db_input($stop) .' AND NOT annulled'
.') AND NOT annulled'
.' GROUP BY state, DATE_FORMAT(timestamp, \'%Y-%m-%d\')' .' GROUP BY state, DATE_FORMAT(timestamp, \'%Y-%m-%d\')'
.' ORDER BY 2, 1'); .' ORDER BY 2, 1');
# Initialize array of plot values # Initialize array of plot values
......
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