admin home stats

This commit is contained in:
Etienne Roudeix
2013-10-30 17:00:38 +01:00
committed by Manuel Raynaud
parent bc454124f3
commit 689de106c7
2 changed files with 115 additions and 115 deletions

View File

@@ -43,7 +43,7 @@ class HomeController extends BaseAdminController
{
$data = new \stdClass();
$data->title = "Stats on [...]";
$data->title = "Stats on " . $this->getRequest()->request->get('month', date('m')) . "/" . $this->getRequest()->request->get('month', date('Y'));
/* sales */
$saleSeries = new \stdClass();

View File

@@ -268,9 +268,7 @@
<script>
(function($, window, document){
$(function(){
jQuery(function($){
var $elem = $('#jqplot');
@@ -318,9 +316,34 @@
}
};
// Get data Json
// Get initial data Json
$.getJSON(url)
.done(function(data) {
.done(jsonSuccessLoad)
.fail(jsonFailLoad);
function initJqplotData(series, seriesColors, options, json){
$('[data-toggle="jqplot-serie"].active').each(function(i){
var position = $(this).index() - 1;
series.push(json.series[position].data);
seriesColors.push(json.series[position].color);
});
// Number of days to display ( = data.length in one serie)
days = json.series[0].data.length;
// Graph title
options.title = json.title;
// Graph series colors
options.seriesColors = seriesColors;
}
function jsonFailLoad(data) {
$elem.append('<div class="alert alert-danger">An error occurred while reading from JSON file</div>');
}
function jsonSuccessLoad(data) {
// Init series data and colors
initJqplotData(series, seriesColors, options, data);
@@ -366,33 +389,10 @@
jqplot.replot( { resetAxes: true } );
});
})
.fail(function() {
$elem.append('<div class="alert alert-danger">An error occurred while reading from JSON file</div>');
});
function initJqplotData(series, seriesColors, options, json){
$('[data-toggle="jqplot-serie"].active').each(function(i){
var position = $(this).index() - 1;
series.push(json.series[position].data);
seriesColors.push(json.series[position].color);
});
// Number of days to display ( = data.length in one serie)
days = json.series[0].data.length;
// Graph title
options.title = json.title;
// Graph series colors
options.seriesColors = seriesColors;
}
});
}(window.jQuery, window, document));
</script>
{/javascripts}
{/block}