This commit is contained in:
meusinfirmary
2025-06-20 01:17:16 +09:00
parent a4276d9a6a
commit ed42967eef
5 changed files with 350 additions and 235 deletions

View File

@ -122,8 +122,8 @@
const State = {
file_jimp_worker: "{{ asset('assets/js/worker/jimp.js') }}",
storage_lara: "{{ asset('storage') }}/",
periodeStartDate: '', // unix timestamps
periodeEndDate: '', // unix timestamps
periodeStartDate: '', // unix timestamps
periodeEndDate: '', // unix timestamps
stts_order: {
wait: "{{ App\Models\Orders::STTS_WAIT }}",
confirm: "{{ App\Models\Orders::STTS_CONFIRM }}",
@ -147,7 +147,7 @@
const Wrapper = {
activate: function() {
Filter.activate();
Filter.activate();
Wrapper.event();
DTable.activate();
},
@ -157,7 +157,7 @@
return '<span class="text-success">Lunas</span>';
} else if (State.is_paid.yes == row.is_vdr_paid) {
if (row.total_payment !== 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 == stts) {
@ -180,54 +180,74 @@
},
};
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;
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;
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() {