update
This commit is contained in:
@ -78,8 +78,7 @@
|
||||
<tr class="">
|
||||
<td class="">1</td>
|
||||
<td class="">
|
||||
<a href="{{ route('view_keuangan_billing_view') }}"
|
||||
class="">
|
||||
<a href="{{ route('view_keuangan_billing_view') }}" class="">
|
||||
<span class="icon ion-eye text-danger fz-16"></span>
|
||||
</a>
|
||||
</td>
|
||||
@ -134,7 +133,7 @@
|
||||
file_jimp_worker: "{{ asset('assets/js/worker/jimp.js') }}",
|
||||
storage_lara: "{{ asset('storage') }}/",
|
||||
periodeStartDate: '', // unix timestamps
|
||||
periodeEndDate: '', // unix timestamps
|
||||
periodeEndDate: '', // unix timestamps
|
||||
stts_order: {
|
||||
wait: "{{ App\Models\Orders::STTS_WAIT }}",
|
||||
confirm: "{{ App\Models\Orders::STTS_CONFIRM }}",
|
||||
@ -166,53 +165,73 @@
|
||||
};
|
||||
|
||||
const Filter = {
|
||||
activate: function() {
|
||||
const startDate = moment().startOf('month');
|
||||
const endDate = moment().endOf('month');
|
||||
$('#filter-startDate').val(startDate.format('YYYY-MM-DD')).trigger('change');
|
||||
$('#filter-endDate').val(endDate.format('YYYY-MM-DD')).trigger('change');
|
||||
State.periodeStartDate = startDate.unix();
|
||||
State.periodeEndDate = endDate.unix();
|
||||
Filter.evPeriodeDate();
|
||||
},
|
||||
evPeriodeDate: function() {
|
||||
$('#filter-startDate').on('change', function(e) {
|
||||
const { isValid, data } = Filter.calcPeriodeDate(moment($('#filter-startDate').val()), moment($('#filter-endDate').val()))
|
||||
if (!isValid) return false;
|
||||
activate: function() {
|
||||
const startDate = moment().startOf('month');
|
||||
const endDate = moment().endOf('month');
|
||||
$('#filter-startDate').val(startDate.format('YYYY-MM-DD')).trigger('change');
|
||||
$('#filter-endDate').val(endDate.format('YYYY-MM-DD')).trigger('change');
|
||||
State.periodeStartDate = startDate.unix();
|
||||
State.periodeEndDate = endDate.unix();
|
||||
Filter.evPeriodeDate();
|
||||
},
|
||||
evPeriodeDate: function() {
|
||||
$('#filter-startDate').on('change', function(e) {
|
||||
const {
|
||||
isValid,
|
||||
data
|
||||
} = Filter.calcPeriodeDate(moment($('#filter-startDate').val()), moment($('#filter-endDate').val()))
|
||||
if (!isValid) return false;
|
||||
State.periodeStartDate = data.startDate.unix();
|
||||
State.periodeEndDate = data.endDate.unix();
|
||||
DTable.reload();
|
||||
});
|
||||
$('#filter-endDate').on('change', function(e) {
|
||||
const { isValid, data } = Filter.calcPeriodeDate(moment($('#filter-startDate').val()), moment($('#filter-endDate').val()))
|
||||
if (!isValid) return false;
|
||||
State.periodeEndDate = data.endDate.unix();
|
||||
DTable.reload();
|
||||
});
|
||||
$('#filter-endDate').on('change', function(e) {
|
||||
const {
|
||||
isValid,
|
||||
data
|
||||
} = Filter.calcPeriodeDate(moment($('#filter-startDate').val()), moment($('#filter-endDate').val()))
|
||||
if (!isValid) return false;
|
||||
State.periodeStartDate = data.startDate.unix();
|
||||
State.periodeEndDate = data.endDate.unix();
|
||||
DTable.reload();
|
||||
});
|
||||
},
|
||||
calcPeriodeDate: function(startDate, endDate) {
|
||||
if (startDate.format('YYYY-MM-DD') === 'Invalid date') {
|
||||
Helper.toast('Warning', 'just now', 'Tanggal mulai periode tidak valid');
|
||||
return { isValid: false };
|
||||
}
|
||||
if (endDate.format('YYYY-MM-DD') === 'Invalid date') {
|
||||
Helper.toast('Warning', 'just now', 'Tanggal akhir periode tidak valid');
|
||||
return { isValid: false };
|
||||
}
|
||||
const duration = moment.duration(endDate.diff(startDate));
|
||||
const diffDays = duration.days();
|
||||
if (diffDays > 30) {
|
||||
Helper.toast('Warning', 'just now', 'Maksimal periode 1 bulan');
|
||||
return { isValid: false };
|
||||
}
|
||||
if (diffDays < 0) {
|
||||
Helper.toast('Warning', 'just now', 'Rentang periode tidak valid');
|
||||
return { isValid: false };
|
||||
}
|
||||
return { isValid: true, data: { startDate, endDate } };
|
||||
},
|
||||
}
|
||||
State.periodeEndDate = data.endDate.unix();
|
||||
DTable.reload();
|
||||
});
|
||||
},
|
||||
calcPeriodeDate: function(startDate, endDate) {
|
||||
if (startDate.format('YYYY-MM-DD') === 'Invalid date') {
|
||||
Helper.toast('Warning', 'just now', 'Tanggal mulai periode tidak valid');
|
||||
return {
|
||||
isValid: false
|
||||
};
|
||||
}
|
||||
if (endDate.format('YYYY-MM-DD') === 'Invalid date') {
|
||||
Helper.toast('Warning', 'just now', 'End date of the period is not valid');
|
||||
return {
|
||||
isValid: false
|
||||
};
|
||||
}
|
||||
const duration = moment.duration(endDate.diff(startDate));
|
||||
const diffDays = duration.days();
|
||||
if (diffDays > 30) {
|
||||
Helper.toast('Warning', 'just now', 'Maksimal periode 1 bulan');
|
||||
return {
|
||||
isValid: false
|
||||
};
|
||||
}
|
||||
if (diffDays < 0) {
|
||||
Helper.toast('Warning', 'just now', 'Rentang periode tidak valid');
|
||||
return {
|
||||
isValid: false
|
||||
};
|
||||
}
|
||||
return {
|
||||
isValid: true,
|
||||
data: {
|
||||
startDate,
|
||||
endDate
|
||||
}
|
||||
};
|
||||
},
|
||||
}
|
||||
|
||||
const DTable = {
|
||||
activate: function() {
|
||||
@ -341,7 +360,7 @@
|
||||
return '<span class="text-success">Lunas</span>';
|
||||
} else if (State.is_paid.yes == row.is_invc_paid) {
|
||||
if (row.total_billing !== row.total_payed) {
|
||||
return '<span class="text-danger">Belum lunas</span>';
|
||||
return '<span class="text-danger">Belum lunas</span>';
|
||||
}
|
||||
return '<span class="text-success">Lunas</span>';
|
||||
} else if (State.stts_order.drop == data) {
|
||||
|
||||
Reference in New Issue
Block a user