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

Merge pull request #357 from protich/issue/350

Fix bug on staff group stats
parents bbba2c40 22cc7144
No related branches found
No related tags found
No related merge requests found
...@@ -37,10 +37,15 @@ class OverviewReportAjaxAPI extends AjaxController { ...@@ -37,10 +37,15 @@ class OverviewReportAjaxAPI extends AjaxController {
function getData() { function getData() {
global $thisstaff; global $thisstaff;
$start = $this->get('start', 'last month'); if(($start = $this->get('start', 'last month'))) {
$stop = $this->get('stop', 'now'); $stop = $this->get('stop', 'now');
if (substr($stop, 0, 1) == '+') if (substr($stop, 0, 1) == '+')
$stop = $start . $stop; $stop = $start . $stop;
} else {
$start = 'last month';
$stop = 'now';
}
$start = 'FROM_UNIXTIME('.strtotime($start).')'; $start = 'FROM_UNIXTIME('.strtotime($start).')';
$stop = 'FROM_UNIXTIME('.strtotime($stop).')'; $stop = 'FROM_UNIXTIME('.strtotime($stop).')';
...@@ -72,9 +77,9 @@ class OverviewReportAjaxAPI extends AjaxController { ...@@ -72,9 +77,9 @@ class OverviewReportAjaxAPI extends AjaxController {
"filter" => "filter" =>
('T1.staff_id=S1.staff_id ('T1.staff_id=S1.staff_id
AND AND
(T1.staff_id='.db_input($thisstaff->getDeptId()) (T1.staff_id='.db_input($thisstaff->getId())
.(($depts=$thisstaff->getManagedDepartments())? .(($depts=$thisstaff->getManagedDepartments())?
(' OR T1.staff_id IN('.implode(',', db_input($depts)).')'):'') (' OR T1.dept_id IN('.implode(',', db_input($depts)).')'):'')
.')' .')'
) )
) )
...@@ -166,10 +171,17 @@ class OverviewReportAjaxAPI extends AjaxController { ...@@ -166,10 +171,17 @@ class OverviewReportAjaxAPI extends AjaxController {
} }
function getPlotData() { function getPlotData() {
$start = $this->get('start', 'last month');
$stop = $this->get('stop', 'now');
if (substr($stop, 0, 1) == '+') if(($start = $this->get('start', 'last month'))) {
$stop = $start . $stop; $stop = $this->get('stop', 'now');
if (substr($stop, 0, 1) == '+')
$stop = $start . $stop;
} else {
$start = 'last month';
$stop = 'now';
}
$start = strtotime($start); $start = strtotime($start);
$stop = strtotime($stop); $stop = strtotime($stop);
......
...@@ -9,9 +9,7 @@ ...@@ -9,9 +9,7 @@
$.ajax({ $.ajax({
method: 'GET', method: 'GET',
url: 'ajax.php/report/overview/graph', url: 'ajax.php/report/overview/graph',
data: ((this.start && this.start.value) ? { data: $(this).serialize(),
'start': this.start.value,
'stop': this.period.value} : {}),
dataType: 'json', dataType: 'json',
success: function(json) { success: function(json) {
var times = [], var times = [],
...@@ -136,6 +134,7 @@ ...@@ -136,6 +134,7 @@
start = this.start.value || 'last month'; start = this.start.value || 'last month';
stop = this.period.value || 'now'; stop = this.period.value || 'now';
} }
var group = current_tab.attr('table-group'); var group = current_tab.attr('table-group');
$.ajax({ $.ajax({
method: 'GET', method: 'GET',
...@@ -250,7 +249,7 @@ ...@@ -250,7 +249,7 @@
// ------------------------> Export <----------------------- // ------------------------> Export <-----------------------
$('<a>').attr({'href':'ajax.php/report/overview/table/export?group=' $('<a>').attr({'href':'ajax.php/report/overview/table/export?group='
+group}).append('Export') +group+'&start='+start+'&stop='+stop}).append('Export')
.appendTo($('<li>') .appendTo($('<li>')
.appendTo(p)); .appendTo(p));
...@@ -259,6 +258,10 @@ ...@@ -259,6 +258,10 @@
}); });
return false; return false;
} }
$(refresh);
$(function() { $('#timeframe-form').submit(refresh); }); $(function() {
$('#timeframe-form').submit(refresh);
//Trigger submit now...init.
$('#timeframe-form').submit();
});
})(window.jQuery); })(window.jQuery);
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