Merge pull request #2898 from EnesSacid-Buker/previous-quarter
Previous quarter issue in dashboard
This commit is contained in:
commit
963b46d630
@ -141,10 +141,6 @@ trait DateTime
|
|||||||
$this_quarter = $financial_quarters[0];
|
$this_quarter = $financial_quarters[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isset($previous_quarter)) {
|
|
||||||
$previous_quarter = $financial_quarters[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
$date_picker_shortcuts = [
|
$date_picker_shortcuts = [
|
||||||
trans('reports.this_year') => [
|
trans('reports.this_year') => [
|
||||||
'start' => $financial_year->getStartDate()->format('Y-m-d'),
|
'start' => $financial_year->getStartDate()->format('Y-m-d'),
|
||||||
@ -158,16 +154,19 @@ trait DateTime
|
|||||||
'start' => $this_quarter->getStartDate()->format('Y-m-d'),
|
'start' => $this_quarter->getStartDate()->format('Y-m-d'),
|
||||||
'end' => $this_quarter->getEndDate()->format('Y-m-d'),
|
'end' => $this_quarter->getEndDate()->format('Y-m-d'),
|
||||||
],
|
],
|
||||||
trans('reports.previous_quarter') => [
|
|
||||||
'start' => $previous_quarter->getStartDate()->format('Y-m-d'),
|
|
||||||
'end' => $previous_quarter->getEndDate()->format('Y-m-d'),
|
|
||||||
],
|
|
||||||
trans('reports.last_12_months') => [
|
trans('reports.last_12_months') => [
|
||||||
'start' => $today->copy()->subYear()->startOfDay()->format('Y-m-d'),
|
'start' => $today->copy()->subYear()->startOfDay()->format('Y-m-d'),
|
||||||
'end' => $today->copy()->subDay()->endOfDay()->format('Y-m-d'),
|
'end' => $today->copy()->subDay()->endOfDay()->format('Y-m-d'),
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
|
if (isset($previous_quarter)) {
|
||||||
|
$date_picker_shortcuts[trans('reports.previous_quarter')] = [
|
||||||
|
'start' => $previous_quarter->getStartDate()->format('Y-m-d'),
|
||||||
|
'end' => $previous_quarter->getEndDate()->format('Y-m-d'),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
return $date_picker_shortcuts;
|
return $date_picker_shortcuts;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,51 +47,29 @@
|
|||||||
popper-class="dashboard-picker"
|
popper-class="dashboard-picker"
|
||||||
:picker-options="{
|
:picker-options="{
|
||||||
shortcuts: [
|
shortcuts: [
|
||||||
|
@php
|
||||||
|
$shortcuts = [
|
||||||
|
trans('reports.this_year'),
|
||||||
|
trans('reports.previous_year'),
|
||||||
|
trans('reports.this_quarter'),
|
||||||
|
trans('reports.previous_quarter'),
|
||||||
|
trans('reports.last_12_months')
|
||||||
|
];
|
||||||
|
@endphp
|
||||||
|
|
||||||
|
@foreach ($shortcuts as $shortcut)
|
||||||
|
@continue(! isset($date_picker_shortcuts[$shortcut]))
|
||||||
|
|
||||||
{
|
{
|
||||||
text: '{{ trans("reports.this_year") }}',
|
text: '{{ $shortcut }}',
|
||||||
onClick(picker) {
|
onClick(picker) {
|
||||||
const start = new Date('{{ $date_picker_shortcuts[trans("reports.this_year")]["start"] }}');
|
const start = new Date('{{ $date_picker_shortcuts[$shortcut]["start"] }}');
|
||||||
const end = new Date('{{ $date_picker_shortcuts[trans("reports.this_year")]["end"] }}');
|
const end = new Date('{{ $date_picker_shortcuts[$shortcut]["end"] }}');
|
||||||
|
|
||||||
picker.$emit('pick', [start, end]);
|
picker.$emit('pick', [start, end]);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
@endforeach
|
||||||
text: '{{ trans("reports.previous_year") }}',
|
|
||||||
onClick(picker) {
|
|
||||||
const start = new Date('{{ $date_picker_shortcuts[trans("reports.previous_year")]["start"] }}');
|
|
||||||
const end = new Date('{{ $date_picker_shortcuts[trans("reports.previous_year")]["end"] }}');
|
|
||||||
|
|
||||||
picker.$emit('pick', [start, end]);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
text: '{{ trans("reports.this_quarter") }}',
|
|
||||||
onClick(picker) {
|
|
||||||
const start = new Date('{{ $date_picker_shortcuts[trans("reports.this_quarter")]["start"] }}');
|
|
||||||
const end = new Date('{{ $date_picker_shortcuts[trans("reports.this_quarter")]["end"] }}');
|
|
||||||
|
|
||||||
picker.$emit('pick', [start, end]);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
text: '{{ trans("reports.previous_quarter") }}',
|
|
||||||
onClick(picker) {
|
|
||||||
const start = new Date('{{ $date_picker_shortcuts[trans("reports.previous_quarter")]["start"] }}');
|
|
||||||
const end = new Date('{{ $date_picker_shortcuts[trans("reports.previous_quarter")]["end"] }}');
|
|
||||||
|
|
||||||
picker.$emit('pick', [start, end]);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
text: '{{ trans("reports.last_12_months") }}',
|
|
||||||
onClick(picker) {
|
|
||||||
const start = new Date('{{ $date_picker_shortcuts[trans("reports.last_12_months")]["start"] }}');
|
|
||||||
const end = new Date('{{ $date_picker_shortcuts[trans("reports.last_12_months")]["end"] }}');
|
|
||||||
|
|
||||||
picker.$emit('pick', [start, end]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
]
|
||||||
}">
|
}">
|
||||||
</el-date-picker>
|
</el-date-picker>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user