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

@ -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) {

View File

@ -19,7 +19,7 @@
</div>
</div>
<div class="row">
<div class="col-sm-12 col-md-4 col-lg-3">
<div class="col-sm-12 col-md-4 col-lg-3">
<div class="card">
<div class="card-body">
<h6 class="mb-3">Uang Masuk</h6>
@ -118,7 +118,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 }}",
@ -176,59 +176,79 @@
};
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 = {
table: null,
table: null,
activate: function() {
DTable.reload();
DTable.eventChildRow();
DTable.eventChildRow();
},
reload: function() {
// $('#tLedgerBl').DataTable();
@ -277,19 +297,19 @@
// searchable: true,
// render: function(data, type, row, meta) {
// let action = `
// <a href="${State.url_view_detail}?code=${row.ord_code}" class="">
// <span class="icon ion-eye text-danger fz-16"></span>
// </a>
// `;
// <a href="${State.url_view_detail}?code=${row.ord_code}" class="">
// <span class="icon ion-eye text-danger fz-16"></span>
// </a>
// `;
// return action;
// }
// },
{
"className": 'dt-control',
"orderable": false,
"data": null,
"defaultContent": '',
},
{
"className": 'dt-control',
"orderable": false,
"data": null,
"defaultContent": '',
},
{
data: 'ord_code',
className: 'text-start text-nowrap',
@ -339,7 +359,7 @@
searchable: true,
render: function(data, type, row, meta) {
return (new Intl.NumberFormat('id-ID')).format(data);
// return (new Intl.NumberFormat('id-ID')).format(row.total_in - row.total_out);
// return (new Intl.NumberFormat('id-ID')).format(row.total_in - row.total_out);
},
},
],
@ -354,72 +374,74 @@
$('#totAllIn').text((new Intl.NumberFormat('id-ID')).format(total_in));
$('#totAllOut').text((new Intl.NumberFormat('id-ID')).format(total_out));
},
eventChildRow: function() {
$('#tLedgerBl tbody').on('click', 'td.dt-control', function () {
var tr = $(this).closest('tr');
var row = DTable.table.row( tr );
if ( row.child.isShown() ) {
// This row is already open - close it
row.child.hide();
tr.removeClass('shown');
}
else {
// Open this row
row.child( DTable.formatChildRow(row.data()) ).show();
tr.addClass('shown');
}
} );
},
formatChildRow: function(d) {
// `d` is the original data object for the row
// let template = `<table cellpadding="5" cellspacing="0" border="0" style="padding-left:50px;">
let template = `<table class="table table-bordered table-hover">
<thead style="border-style:none;">
<tr>
<th>Item</th>
<th class="text-end">Jumlah</th>
<th>Satuan</th>
<th class="text-center">Invoice (Rp)</th>
<th class="text-center">Pembayaran (Rp)</th>
<th class="text-center">Masuk (Rp)</th>
<th class="text-center">Keluar (Rp)</th>
<th class="text-center">Balance (Rp)</th>
</tr>
</thead>
<tbody>`
for (let item of d.a_items) {
// perlu diperbaiki cara if di query, jika kalkulasi ke vendor maka is_aprv = , jika ke client is_bill_aprv = 1
if (item.calc_to_vdr == State.calc_to_vdr.yes && item.is_aprv != State.is_aprv.yes) continue;
if (item.invc_to_client == State.invc_to_client.yes && item.is_bill_aprv != State.is_aprv.yes) continue;
eventChildRow: function() {
$('#tLedgerBl tbody').on('click', 'td.dt-control', function() {
var tr = $(this).closest('tr');
var row = DTable.table.row(tr);
let small_desc = '', amt_in = 0, amt_out = 0, amt_bl = 0;
if (item.is_bill_paid == State.is_a_item_paid.paid) {
amt_in = item.amt_in;
small_desc += `<br><small>waktu dibayarkan <span class="text-success">${moment.unix(item.paid_bill_at).format('DD MMM YYYY HH:mm:ss')}</span></small>`;
if (row.child.isShown()) {
// This row is already open - close it
row.child.hide();
tr.removeClass('shown');
} else {
// Open this row
row.child(DTable.formatChildRow(row.data())).show();
tr.addClass('shown');
}
if (item.is_paid == State.is_a_item_paid.paid) {
amt_out = item.amt_out;
small_desc += `<br><small>waktu keluar <span class="text-danger">${moment.unix(item.paid_at).format('DD MMM YYYY HH:mm:ss')}</span></small>`;
}
if (amt_in != 0 || amt_out != 0) {
amt_bl = item.amt_bl;
}
template += `<tr>
<td>${item.item_desc}${small_desc}</td>
<td class="text-end">${item.unit_qty}</td>
<td>${item.unit_type_name}</td>
<td class="text-end">${(new Intl.NumberFormat('id-ID')).format(item.amt_in)}</td>
<td class="text-end">${(new Intl.NumberFormat('id-ID')).format(item.amt_out)}</td>
<td class="text-end text-success">${(new Intl.NumberFormat('id-ID')).format(amt_in)}</td>
<td class="text-end text-danger">${(new Intl.NumberFormat('id-ID')).format(amt_out)}</td>
<td class="text-end">${(new Intl.NumberFormat('id-ID')).format(amt_bl)}</td>
</tr>`;
});
},
formatChildRow: function(d) {
// `d` is the original data object for the row
// let template = `<table cellpadding="5" cellspacing="0" border="0" style="padding-left:50px;">
let template = `<table class="table table-bordered table-hover">
<thead style="border-style:none;">
<tr>
<th>Item</th>
<th class="text-end">Jumlah</th>
<th>Satuan</th>
<th class="text-center">Invoice (Rp)</th>
<th class="text-center">Pembayaran (Rp)</th>
<th class="text-center">Masuk (Rp)</th>
<th class="text-center">Keluar (Rp)</th>
<th class="text-center">Balance (Rp)</th>
</tr>
</thead>
<tbody>`
for (let item of d.a_items) {
// perlu diperbaiki cara if di query, jika kalkulasi ke vendor maka is_aprv = , jika ke client is_bill_aprv = 1
if (item.calc_to_vdr == State.calc_to_vdr.yes && item.is_aprv != State.is_aprv.yes) continue;
if (item.invc_to_client == State.invc_to_client.yes && item.is_bill_aprv != State.is_aprv.yes) continue;
let small_desc = '',
amt_in = 0,
amt_out = 0,
amt_bl = 0;
if (item.is_bill_paid == State.is_a_item_paid.paid) {
amt_in = item.amt_in;
small_desc += `<br><small>waktu dibayarkan <span class="text-success">${moment.unix(item.paid_bill_at).format('DD MMM YYYY HH:mm:ss')}</span></small>`;
}
template += `</tbody>
</table>`;
if (item.is_paid == State.is_a_item_paid.paid) {
amt_out = item.amt_out;
small_desc += `<br><small>waktu keluar <span class="text-danger">${moment.unix(item.paid_at).format('DD MMM YYYY HH:mm:ss')}</span></small>`;
}
if (amt_in != 0 || amt_out != 0) {
amt_bl = item.amt_bl;
}
template += `<tr>
<td>${item.item_desc}${small_desc}</td>
<td class="text-end">${item.unit_qty}</td>
<td>${item.unit_type_name}</td>
<td class="text-end">${(new Intl.NumberFormat('id-ID')).format(item.amt_in)}</td>
<td class="text-end">${(new Intl.NumberFormat('id-ID')).format(item.amt_out)}</td>
<td class="text-end text-success">${(new Intl.NumberFormat('id-ID')).format(amt_in)}</td>
<td class="text-end text-danger">${(new Intl.NumberFormat('id-ID')).format(amt_out)}</td>
<td class="text-end">${(new Intl.NumberFormat('id-ID')).format(amt_bl)}</td>
</tr>`;
}
template += `</tbody>
</table>`;
return template
},
},
};
Wrapper.activate();

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() {