admin home stats
This commit is contained in:
@@ -43,7 +43,7 @@ class HomeController extends BaseAdminController
|
|||||||
{
|
{
|
||||||
$data = new \stdClass();
|
$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 */
|
/* sales */
|
||||||
$saleSeries = new \stdClass();
|
$saleSeries = new \stdClass();
|
||||||
|
|||||||
@@ -268,9 +268,7 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
(function($, window, document){
|
jQuery(function($){
|
||||||
|
|
||||||
$(function(){
|
|
||||||
|
|
||||||
var $elem = $('#jqplot');
|
var $elem = $('#jqplot');
|
||||||
|
|
||||||
@@ -318,9 +316,34 @@
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Get data Json
|
// Get initial data Json
|
||||||
$.getJSON(url)
|
$.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
|
// Init series data and colors
|
||||||
initJqplotData(series, seriesColors, options, data);
|
initJqplotData(series, seriesColors, options, data);
|
||||||
@@ -366,33 +389,10 @@
|
|||||||
jqplot.replot( { resetAxes: true } );
|
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>
|
</script>
|
||||||
{/javascripts}
|
{/javascripts}
|
||||||
{/block}
|
{/block}
|
||||||
Reference in New Issue
Block a user