Merge pull request #2898 from EnesSacid-Buker/previous-quarter

Previous quarter issue in dashboard
This commit is contained in:
Cüneyt Şentürk 2023-02-22 10:38:03 +03:00 committed by GitHub
commit 963b46d630
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 29 additions and 52 deletions

View File

@ -137,14 +137,10 @@ trait DateTime
break;
}
if (!isset($this_quarter)) {
if (! isset($this_quarter)) {
$this_quarter = $financial_quarters[0];
}
if (!isset($previous_quarter)) {
$previous_quarter = $financial_quarters[0];
}
$date_picker_shortcuts = [
trans('reports.this_year') => [
'start' => $financial_year->getStartDate()->format('Y-m-d'),
@ -158,16 +154,19 @@ trait DateTime
'start' => $this_quarter->getStartDate()->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') => [
'start' => $today->copy()->subYear()->startOfDay()->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;
}

View File

@ -47,51 +47,29 @@
popper-class="dashboard-picker"
:picker-options="{
shortcuts: [
{
text: '{{ trans("reports.this_year") }}',
onClick(picker) {
const start = new Date('{{ $date_picker_shortcuts[trans("reports.this_year")]["start"] }}');
const end = new Date('{{ $date_picker_shortcuts[trans("reports.this_year")]["end"] }}');
@php
$shortcuts = [
trans('reports.this_year'),
trans('reports.previous_year'),
trans('reports.this_quarter'),
trans('reports.previous_quarter'),
trans('reports.last_12_months')
];
@endphp
picker.$emit('pick', [start, end]);
}
},
{
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"] }}');
@foreach ($shortcuts as $shortcut)
@continue(! isset($date_picker_shortcuts[$shortcut]))
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"] }}');
{
text: '{{ $shortcut }}',
onClick(picker) {
const start = new Date('{{ $date_picker_shortcuts[$shortcut]["start"] }}');
const end = new Date('{{ $date_picker_shortcuts[$shortcut]["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]);
}
}
picker.$emit('pick', [start, end]);
}
},
@endforeach
]
}">
</el-date-picker>
@ -120,7 +98,7 @@
{{ trans('general.title.add', ['type' => trans_choice('general.widgets', 1)]) }}
</x-button>
</div>
<x-dropdown.divider />
@endcan