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 {
function getData() {
global $thisstaff;
$start = $this->get('start', 'last month');
$stop = $this->get('stop', 'now');
if (substr($stop, 0, 1) == '+')
$stop = $start . $stop;
if(($start = $this->get('start', 'last month'))) {
$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).')';
......@@ -72,9 +77,9 @@ class OverviewReportAjaxAPI extends AjaxController {
"filter" =>
('T1.staff_id=S1.staff_id
AND
(T1.staff_id='.db_input($thisstaff->getDeptId())
(T1.staff_id='.db_input($thisstaff->getId())
.(($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 {
}
function getPlotData() {
$start = $this->get('start', 'last month');
$stop = $this->get('stop', 'now');
if (substr($stop, 0, 1) == '+')
$stop = $start . $stop;
if(($start = $this->get('start', 'last month'))) {
$stop = $this->get('stop', 'now');
if (substr($stop, 0, 1) == '+')
$stop = $start . $stop;
} else {
$start = 'last month';
$stop = 'now';
}
$start = strtotime($start);
$stop = strtotime($stop);
......
......@@ -9,9 +9,7 @@
$.ajax({
method: 'GET',
url: 'ajax.php/report/overview/graph',
data: ((this.start && this.start.value) ? {
'start': this.start.value,
'stop': this.period.value} : {}),
data: $(this).serialize(),
dataType: 'json',
success: function(json) {
var times = [],
......@@ -136,6 +134,7 @@
start = this.start.value || 'last month';
stop = this.period.value || 'now';
}
var group = current_tab.attr('table-group');
$.ajax({
method: 'GET',
......@@ -250,7 +249,7 @@
// ------------------------> Export <-----------------------
$('<a>').attr({'href':'ajax.php/report/overview/table/export?group='
+group}).append('Export')
+group+'&start='+start+'&stop='+stop}).append('Export')
.appendTo($('<li>')
.appendTo(p));
......@@ -259,6 +258,10 @@
});
return false;
}
$(refresh);
$(function() { $('#timeframe-form').submit(refresh); });
$(function() {
$('#timeframe-form').submit(refresh);
//Trigger submit now...init.
$('#timeframe-form').submit();
});
})(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