close #265 Fixed: Dashboard 'Last 12 months' does not work, 'Custom Range' partially broken
This commit is contained in:
parent
2da5ad838c
commit
9988d49f46
@ -126,6 +126,7 @@ class Dashboard extends Controller
|
||||
$start = Date::parse(request('start', $this->today->startOfYear()->format('Y-m-d')));
|
||||
$end = Date::parse(request('end', $this->today->endOfYear()->format('Y-m-d')));
|
||||
$period = request('period', 'month');
|
||||
$range = request('range', 'custom');
|
||||
|
||||
$start_month = $start->month;
|
||||
$end_month = $end->month;
|
||||
@ -135,6 +136,11 @@ class Dashboard extends Controller
|
||||
|
||||
$s = clone $start;
|
||||
|
||||
if ($range == 'last_12_months') {
|
||||
$end_month = 12;
|
||||
$start_month = 1;
|
||||
}
|
||||
|
||||
for ($j = $end_month; $j >= $start_month; $j--) {
|
||||
$labels[$end_month - $j] = $s->format('M Y');
|
||||
|
||||
|
@ -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
|
Loading…
x
Reference in New Issue
Block a user