pos-gis/resources/views/content/ref/rekaptrx/action.blade.php
2024-10-07 13:13:42 +07:00

204 lines
6.2 KiB
PHP

<script>
// INIT FORM
function clearForm() {
$('#mForm_title').html(`Tambah Data`);
$('#mForm_subTitle').html(`Tambah Data `+title);
$('#get_id').val('');
$("#formData")[0].reset();
$('#formData').bootstrapValidator("resetForm",true);
reInitForm();
}
function edit(id) {
clearForm();
$('#mForm').modal('show');
znLoadingModal('mForm');
$('#mForm_title').html(`Edit Data`);
$('#mForm_subTitle').html(`Edit Data `+title);
let formData = new FormData();
formData.append('id',id);
doPost(routeEdit, formData, function (msg, res) {
console.log(res);
znLoadingModalEnd('mForm');
var data = res.data;
$('#get_id').val(data.id);
$('#description').val(data.description);
$('#is_active').val(data.is_active);
$('#formData').data('bootstrapValidator').validate();
})
}
function detail(type) {
$('#mDetail').modal('show');
znLoadingModal('mDetail');
$('#datatableDetail').DataTable().clear().destroy();
$('#listDetail').html('');
let formData = new FormData();
formData.append('type',type);
formData.append('startDate',$('#berkala_startDate').val());
formData.append('endDate',$('#berkala_endDate').val());
formData.append('merchant',$('#merchant_filter').val());
doPost(routeStoreCustom+'&act=listDetail', formData, function (msg, res) {
console.log(res);
znLoadingModalEnd('mDetail');
res.data.forEach((v,k) => {
let btn_gagal = '';
if (v.transaksi_gagal > 0) {
btn_gagal = `<button onclick="detailGagal('${type}','${v.product_group_id}')" type="button" class="btn btn-danger btn-sm">${v.transaksi_gagal}</button>`;
}else{
btn_gagal = v.transaksi_gagal;
}
$('#listDetail').append(`
<tr>
<td>${k+1}</td>
<td>${v.jenis_transaksi}</td>
<td class="text-right">${v.jumlah_transaksi}</td>
<td class="text-right">${v.transaksi_sukses}</td>
<td class="text-right">${btn_gagal}</td>
<td class="text-right">${v.transaksi_pending}</td>
<td class="text-right">${v.transaksi_batal}</td>
<td class="text-right">${v.prosentase_keberhasilan} %</td>
</tr>
`);
});
$('#datatableDetail').DataTable({
aLengthMenu: [[5, 10, 25, 50, -1], [5, 10, 25, 50, "All"]],
processing: true,
pageLength: 5,
responsive: true,
language: {
'lengthMenu': 'Display _MENU_',
}
});
})
}
function detailGagal(type,service_group) {
$('#mDetailGagal').modal('show');
$('#listDetailGagal').html('');
$('#datatableDetailGagal').DataTable().clear().destroy();
znLoadingModal('mDetailGagal');
let formData = new FormData();
formData.append('service_group',service_group);
formData.append('type',type);
formData.append('startDate',$('#berkala_startDate').val());
formData.append('endDate',$('#berkala_endDate').val());
formData.append('merchant',$('#merchant_filter').val());
$('#mDetailGagal').css('background','#039be5d6');
doPost(routeStoreCustom+'&act=listDetailGagal', formData, function (msg, res) {
console.log(res);
znLoadingModalEnd('mDetailGagal');
res.data.forEach((v,k) => {
$('#listDetailGagal').append(`
<tr>
<td>${k+1}</td>
<td>${v.penyebab_gagal}</td>
<td>${v.jumlah}</td>
<td>${parseFloat(v.pct).toFixed(2)} %</td>
</tr>
`);
});
$('#datatableDetailGagal').DataTable({
aLengthMenu: [[5, 10, 25, 50, -1], [5, 10, 25, 50, "All"]],
processing: true,
pageLength: 5,
responsive: true,
language: {
'lengthMenu': 'Display _MENU_',
}
});
})
}
function getTable() {
let startDate = $('#berkala_startDate').val();
let endDate = $('#berkala_endDate').val();
let merchant = $('#merchant_filter').val();
if (userRole == '2') {
merchant = userMID;
}
table.ajax.url(routeTable+'&startDate='+startDate+'&endDate='+endDate+'&merchant='+merchant).load();
}
//VALIDASI
$(document).ready(function () {
$('.select2').select2({
placeholder: "Silahkan Pilih"
});
$('#berkala_startDate').datepicker({
rtl: KTUtil.isRTL(),
orientation: "bottom left",
todayHighlight: false,
format: 'dd-mm-yyyy',
autoclose: true,
}).on('changeDate', function (selected) {
var minDate = new Date(selected.date.valueOf());
$('#berkala_endDate').datepicker('setStartDate', minDate);
$("#berkala_endDate").datepicker().datepicker("setDate", minDate);
});
$(".znDate").inputmask("99-99-9999", {
"placeholder": "dd-mm-yyyy"
});
$('#berkala_endDate').datepicker({
rtl: KTUtil.isRTL(),
orientation: "bottom left",
todayHighlight: false,
format: 'dd-mm-yyyy',
autoclose: true,
});
$("#formData").bootstrapValidator({
excluded: [':disabled'],
feedbackIcons: {
valid: 'glyphicon glyphicon-ok',
invalid: 'glyphicon glyphicon-remove',
validating: 'glyphicon glyphicon-refresh'
},
fields: {
description: {
validators: {
notEmpty: {
message: 'Tidak Boleh Kosong'
},
stringLength: {
max:50,
message: 'Maksimal 50 Karakter'
}
}
}
}
}).on('success.field.bv', function (e, data) {
var $parent = data.element.parents('.form-group');
$parent.removeClass('has-success');
$parent.find('.form-control-feedback[data-bv-icon-for="' + data.field + '"]').hide();
});
});
</script>