close #1053 Added: Dashboard date filter

This commit is contained in:
Cüneyt Şentürk
2019-12-30 12:30:30 +03:00
parent 237b161fe0
commit bd0598b4d4
14 changed files with 152 additions and 56 deletions

View File

@ -0,0 +1,18 @@
// Get Url Paramater
function getQueryVariable(variable) {
var query = window.location.search.substring(1);
var vars = query.split("&");
for (var i = 0; i < vars.length; i++) {
var pair = vars[i].split("=");
if (pair[0] == variable) {
return pair[1];
}
}
return(false);
}
export {getQueryVariable}

View File

@ -9,6 +9,7 @@ require('./../../bootstrap');
import Vue from 'vue';
import Global from './../../mixins/global';
import {getQueryVariable} from './../../plugins/functions';
import AkauntingDashboard from './../../components/AkauntingDashboard';
import AkauntingWidget from './../../components/AkauntingWidget';
@ -49,38 +50,20 @@ const dashboard = new Vue({
sort: 0,
widget_id: 0
},
pickerOptions: {
shortcuts: [{
text: 'Last week',
onClick(picker) {
const end = new Date();
const start = new Date();
start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
picker.$emit('pick', [start, end]);
}
}, {
text: 'Last month',
onClick(picker) {
const end = new Date();
const start = new Date();
start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
picker.$emit('pick', [start, end]);
}
}, {
text: 'Last 3 months',
onClick(picker) {
const end = new Date();
const start = new Date();
start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
picker.$emit('pick', [start, end]);
}
}]
},
value2: ''
filter_date: [],
};
},
mounted() {
let start_date = getQueryVariable('start_date');
if (start_date) {
let end_date = getQueryVariable('end_date');
this.filter_date.push(start_date);
this.filter_date.push(end_date);
}
this.getWidgets();
},
@ -166,5 +149,13 @@ const dashboard = new Vue({
this.widget.sort = 0;
this.widget.widget_id = 0;
},
onChangeFilterDate() {
if (this.filter_date) {
window.location.href = url + '?start_date=' + this.filter_date[0] + '&end_date=' + this.filter_date[1];
} else {
window.location.href = url;
}
},
}
});

View File

@ -134,6 +134,7 @@ return [
'difference' => 'Difference',
'footer' => 'Footer',
'start_date' => 'Start Date',
'end_date' => 'End Date',
'basis' => 'Basis',
'accrual' => 'Accrual',
'cash' => 'Cash',

View File

@ -92,19 +92,84 @@
@section('new_button')
<!--Dashboard General Filter-->
<el-date-picker
v-model="value2"
type="daterange"
align="right"
unlink-panels
:class="datepicker"
:format="'yyyy-MM-dd'"
:default-time="['00:00:00', '23:59:59']"
range-separator="To"
start-placeholder="Start date"
end-placeholder="End date"
:picker-options="pickerOptions">
</el-date-picker>
<el-date-picker
v-model="filter_date"
type="daterange"
align="right"
unlink-panels
:format="'yyyy-MM-dd'"
value-format="yyyy-MM-dd"
@change="onChangeFilterDate"
range-separator="{{ trans('general.to')}}"
start-placeholder="{{ trans('general.start_date')}}"
end-placeholder="{{ trans('general.end_date')}}"
:picker-options="{
shortcuts: [
{
text: '{{ trans("reports.this_year") }}',
onClick(picker) {
const end = new Date('{{ $financial_start }}');
const start = new Date('{{ $financial_start }}');
end.setFullYear(start.getFullYear() + 1);
end.setTime(end.getTime() - 3600 * 1000 * 24 * 1);
picker.$emit('pick', [start, end]);
}
},
{
text: '{{ trans("reports.previous_year") }}',
onClick(picker) {
const end = new Date('{{ $financial_start }}');
const start = new Date('{{ $financial_start }}');
start.setTime(start.getTime() - 3600 * 1000 * 24 * 365);
end.setFullYear(start.getFullYear() + 1);
end.setTime(end.getTime() - 3600 * 1000 * 24 * 1);
picker.$emit('pick', [start, end]);
}
},
{
text: '{{ trans("reports.this_quarter") }}',
onClick(picker) {
const now = new Date();
const quarter = Math.floor((now.getMonth() / 3));
const start = new Date(now.getFullYear(), quarter * 3, 1);
const end = new Date(start.getFullYear(), start.getMonth() + 3, 0);
picker.$emit('pick', [start, end]);
}
},
{
text: '{{ trans("reports.previous_quarter") }}',
onClick(picker) {
const now = new Date();
const quarter = Math.floor((now.getMonth() / 3));
const start = new Date(now.getFullYear(), quarter * 3, 1);
const end = new Date(start.getFullYear(), start.getMonth() + 3, 0);
start.setMonth(start.getMonth() - 3);
end.setMonth(end.getMonth() - 3);
picker.$emit('pick', [start, end]);
}
},
{
text: '{{ trans("reports.last_12_months") }}',
onClick(picker) {
const end = new Date();
const start = new Date();
start.setTime(start.getTime() - 3600 * 1000 * 24 * 365);
picker.$emit('pick', [start, end]);
}
}
]
}">
</el-date-picker>
@endsection
@section('content')