diff --git a/include/ajax.reports.php b/include/ajax.reports.php index 7fbe19c89c81605725572e45433ef20ea374fdcf..0ad0640a3d64270eda544011c2aa7ec28d101acb 100644 --- a/include/ajax.reports.php +++ b/include/ajax.reports.php @@ -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); diff --git a/scp/js/dashboard.inc.js b/scp/js/dashboard.inc.js index 0f9e31a54dccdff96388d7304b0187f2d8dc9fad..ba19235f12ec5198cb2c074bc083f37b1344ed4d 100644 --- a/scp/js/dashboard.inc.js +++ b/scp/js/dashboard.inc.js @@ -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);