close #265 Fixed: Dashboard 'Last 12 months' does not work, 'Custom Range' partially broken

This commit is contained in:
cuneytsenturk
2018-11-05 13:29:55 +03:00
parent 2da5ad838c
commit 9988d49f46
2 changed files with 33 additions and 3 deletions

View File

@ -266,11 +266,13 @@
$('#cashflow-range').on('apply.daterangepicker', function(ev, picker) {
var period = $('#period').val();
range = getRange(picker);
$.ajax({
url: '{{ url("common/dashboard/cashflow") }}',
type: 'get',
dataType: 'html',
data: 'period=' + period + '&start=' + picker.startDate.format('YYYY-MM-DD') + '&end=' + picker.endDate.format('YYYY-MM-DD'),
data: 'period=' + period + '&start=' + picker.startDate.format('YYYY-MM-DD') + '&end=' + picker.endDate.format('YYYY-MM-DD') + '&range=' + range,
success: function(data) {
$('#cashflow').html(data);
}
@ -282,11 +284,13 @@
$('#period').val('month');
range = getRange(picker);
$.ajax({
url: '{{ url("common/dashboard/cashflow") }}',
type: 'get',
dataType: 'html',
data: 'period=month&start=' + picker.startDate.format('YYYY-MM-DD') + '&end=' + picker.endDate.format('YYYY-MM-DD'),
data: 'period=month&start=' + picker.startDate.format('YYYY-MM-DD') + '&end=' + picker.endDate.format('YYYY-MM-DD') + '&range=' + range,
success: function(data) {
$('#cashflow').html(data);
}
@ -298,16 +302,36 @@
$('#period').val('quarter');
range = getRange(picker);
$.ajax({
url: '{{ url("common/dashboard/cashflow") }}',
type: 'get',
dataType: 'html',
data: 'period=quarter&start=' + picker.startDate.format('YYYY-MM-DD') + '&end=' + picker.endDate.format('YYYY-MM-DD'),
data: 'period=quarter&start=' + picker.startDate.format('YYYY-MM-DD') + '&end=' + picker.endDate.format('YYYY-MM-DD') + '&range=' + range,
success: function(data) {
$('#cashflow').html(data);
}
});
});
});
function getRange(picker) {
ranges = {
'{{ trans("reports.this_year") }}': 'this_year',
'{{ trans("reports.previous_year") }}': 'previous_year',
'{{ trans("reports.this_quarter") }}': 'this_quarter',
'{{ trans("reports.previous_quarter") }}': 'previous_quarter',
'{{ trans("reports.last_12_months") }}': 'last_12_months'
};
range = 'custom';
if (ranges[picker.chosenLabel] != undefined) {
range = ranges[picker.chosenLabel];
}
return range;
}
</script>
@endpush