369 lines
9.8 KiB
JavaScript
369 lines
9.8 KiB
JavaScript
|
$(document).ready(function() {
|
||
|
//setFormValidation('#topupForm');
|
||
|
component.initFile();
|
||
|
|
||
|
var tblTopupList = $('#tblTopupList').DataTable({
|
||
|
"processing": true,
|
||
|
"serverSide": true,
|
||
|
'destroy' : true,
|
||
|
'sDom': 'lrtip',
|
||
|
"columns": [
|
||
|
{ "data": null, "orderable" : false},
|
||
|
{ "data": "status",
|
||
|
"render": function ( data, type, row ) {
|
||
|
var color;
|
||
|
var statusDesc;
|
||
|
var status;
|
||
|
if (data.statusCd == 'INP') {
|
||
|
statusDesc = data.statusDesc;
|
||
|
color = 'badge-warning';
|
||
|
} else if (data.statusCd == 'APR') {
|
||
|
statusDesc = data.statusDesc;
|
||
|
color = 'badge-success';
|
||
|
} else if (data.statusCd == 'REJ') {
|
||
|
statusDesc = data.statusDesc;
|
||
|
color = 'badge-danger';
|
||
|
} else if (data.statusCd == 'CCL') {
|
||
|
statusDesc = data.statusDesc;
|
||
|
color = 'badge-secondary';
|
||
|
}
|
||
|
status = "<span class='badge " + color + "'>" + statusDesc + "</span>";
|
||
|
return status;
|
||
|
}
|
||
|
},
|
||
|
{ "data": "payment.paymentRefNo",
|
||
|
"render": function ( data, type, row ) {
|
||
|
if(data){
|
||
|
return data;
|
||
|
}else{
|
||
|
return "-";
|
||
|
}
|
||
|
}
|
||
|
},
|
||
|
{ "data": "approvedDt",
|
||
|
"render": function ( data, type, row ) {
|
||
|
if(data){
|
||
|
return data;
|
||
|
}else{
|
||
|
return "-";
|
||
|
}
|
||
|
}
|
||
|
},
|
||
|
{ "data": "amount",
|
||
|
"render": function ( data, type, row ) {
|
||
|
if(data){
|
||
|
return data;
|
||
|
}else{
|
||
|
return "-";
|
||
|
}
|
||
|
}
|
||
|
},
|
||
|
{ "data": "status", "orderable" : false,
|
||
|
"render": function ( data, type, row) {
|
||
|
var buttons = action.viewButton;
|
||
|
if (data.statusCd == 'INP') {
|
||
|
buttons = buttons + action.abortButton;
|
||
|
}
|
||
|
return buttons;
|
||
|
}
|
||
|
},
|
||
|
],
|
||
|
"ajax": $.fn.dataTable.pipeline({
|
||
|
"pages" : 1,
|
||
|
"type" : "GET",
|
||
|
"url": contextPath + "/topup/topupList/paginated",
|
||
|
"action": 'xhttp',
|
||
|
'beforeSend': dtRequestHeader,
|
||
|
"dataSrc": dtDataSrc,
|
||
|
"data": function ( data ) {
|
||
|
data.bankRefNo = $('input#bankRef').val();
|
||
|
data.status = $('#statusType').val();
|
||
|
},
|
||
|
"error": function(){ // error handling
|
||
|
console.log("error");
|
||
|
}
|
||
|
}),
|
||
|
"initComplete": function(settings, json) {
|
||
|
$('#searchFilter').bind('click', function(e) {
|
||
|
portalUtil.showMainLoading(true);
|
||
|
tblTopupList
|
||
|
.column(2).search($('input#bankRef').val())
|
||
|
.column(1).search($('#statusType').val())
|
||
|
tblTopupList.draw();
|
||
|
$(".em-toggle").click();
|
||
|
});
|
||
|
$('#clearFilter').bind('click', function(e) {
|
||
|
$('input#bankRef').val("")
|
||
|
$("#statusType").val("").select2();
|
||
|
tblTopupList.columns().search("").draw();
|
||
|
$(".em-toggle").click();
|
||
|
});
|
||
|
},
|
||
|
|
||
|
"fnDrawCallback": function ( oSettings ) {
|
||
|
processRowNum(oSettings,0);
|
||
|
/*$('[data-toggle="tooltip"]').tooltip();*/
|
||
|
hidePagination(this,"#tblTopupList");
|
||
|
portalUtil.showMainLoading(false);
|
||
|
}
|
||
|
});
|
||
|
|
||
|
$('#tblTopupList tbody').on( 'click', 'button.view', function () {
|
||
|
var d = tblTopupList.row( $(this).parents('tr') ).data();
|
||
|
location.href = contextPath + "/topup/view?payRefNo=" + d.payment.paymentRefNo;
|
||
|
});
|
||
|
|
||
|
$('#tblTopupList tbody').on( 'click', 'button.deactivate', function () {
|
||
|
var d = tblTopupList.row( $(this).parents('tr') ).data();
|
||
|
Swal.fire({
|
||
|
title: 'Are you sure ?',
|
||
|
text: 'Do you want to cancel the topup application?',
|
||
|
type: 'question',
|
||
|
showCancelButton: true,
|
||
|
showConfirmButton: true,
|
||
|
cancelButtonText: 'Cancel',
|
||
|
confirmButtonText: 'Yes',
|
||
|
allowOutsideClick: false,
|
||
|
allowEscapeKey: false,
|
||
|
cancelButtonColor: '#999999',
|
||
|
confirmButtonColor: '#4CAF50'
|
||
|
}).then((result) => {
|
||
|
if (result.value) {
|
||
|
portalUtil.showMainLoading(true);
|
||
|
$.ajax({
|
||
|
headers : {
|
||
|
'X-CSRF-Token' : csrf_token
|
||
|
},
|
||
|
url : contextPath + '/topup/cancel',
|
||
|
type : 'post',
|
||
|
action : 'xhttp',
|
||
|
data: {
|
||
|
payRefNo: d.payment.paymentRefNo
|
||
|
},
|
||
|
success : function(data) {
|
||
|
Swal.fire({
|
||
|
text: 'Sucessfully cancelled topup application',
|
||
|
type: 'success',
|
||
|
allowOutsideClick: false,
|
||
|
allowEscapeKey: false,
|
||
|
})
|
||
|
.then(function (result) {
|
||
|
if (result.value) {
|
||
|
window.location = contextPath + '/topup';
|
||
|
}
|
||
|
});
|
||
|
}
|
||
|
}).done(function() {
|
||
|
portalUtil.showMainLoading(false);
|
||
|
});
|
||
|
} else if (result.dismiss === swal.DismissReason.cancel) {
|
||
|
return false;
|
||
|
}
|
||
|
});
|
||
|
});
|
||
|
|
||
|
$(".input-currency").each(function() {
|
||
|
var val = $(this).val();
|
||
|
if ($(this).val().indexOf('.') >= 0) {
|
||
|
val = val.split('.')[0];
|
||
|
}
|
||
|
$(this).val(val);
|
||
|
});
|
||
|
|
||
|
$(".input-currency").on('keypress', function(e) {
|
||
|
var value = $(this).val();
|
||
|
alert("currencyMax ::: "+currencyMax);
|
||
|
var remain = parseInt(currencyMax - value.length);
|
||
|
if (remain == 0) {
|
||
|
var keyCode = (e.keyCode ? e.keyCode : e.which);
|
||
|
if (keyCode > 47 && keyCode < 58 || keyCode > 95 && keyCode < 107) {
|
||
|
e.preventDefault();
|
||
|
}
|
||
|
}
|
||
|
});
|
||
|
|
||
|
$(".input-currency").on('blur', function() {
|
||
|
var x = $(this).val();
|
||
|
// Add comma
|
||
|
x = x.toString().replace(/,/g, "").replace(/\B(?=(\d{3})+(?!\d))/g, ",");
|
||
|
$(this).val(x);
|
||
|
});
|
||
|
|
||
|
// Past Date Picker
|
||
|
$(".pastDtPicker").each(function(index, domEle) {
|
||
|
var value = $(this).val();
|
||
|
var id = $(this).attr('id');
|
||
|
$("#" + id).datetimepicker({
|
||
|
format: 'DD/MM/YYYY',
|
||
|
minDate: new Date(new Date().getFullYear() - 60, 01 - 1, 25),
|
||
|
maxDate: new Date(),
|
||
|
defaultDate: false,
|
||
|
icons: {
|
||
|
time: "fa fa-clock-o",
|
||
|
date: "fa fa-calendar",
|
||
|
up: "fa fa-arrow-up",
|
||
|
down: "fa fa-arrow-down",
|
||
|
previous: "fa fa-chevron-left",
|
||
|
next: "fa fa-chevron-right",
|
||
|
today: "fa fa-clock-o",
|
||
|
clear: "fa fa-trash-o"
|
||
|
},
|
||
|
widgetPositioning: {
|
||
|
horizontal: 'right',
|
||
|
vertical: 'auto'
|
||
|
}
|
||
|
}).val(value)
|
||
|
});
|
||
|
|
||
|
if ($("#remarks").length > 0) {
|
||
|
tinymce.init({
|
||
|
selector: "textarea#remarks",
|
||
|
theme: "modern",
|
||
|
height: 100,
|
||
|
menubar: ' ',
|
||
|
force_br_newlines: false,
|
||
|
force_p_newlines: false,
|
||
|
forced_root_block: '',
|
||
|
});
|
||
|
}
|
||
|
});
|
||
|
|
||
|
var formsubmit = 0;
|
||
|
$("form").submit(function() {
|
||
|
|
||
|
/* var fileInput = "uploadDocsBankslip0.file.filename";
|
||
|
|
||
|
console.log("filename : " + $("#"+fileInput).val());
|
||
|
if ($("#"+fileInput).val() != null || $("#"+fileInput).val() != '') {
|
||
|
document.getElementById("lblDocRequired").style.display = null;
|
||
|
return false;
|
||
|
}
|
||
|
else{
|
||
|
document.getElementById("lblDocRequired").style.display = "none";
|
||
|
}*/
|
||
|
|
||
|
if($('form').attr('id') == "topupForm"){
|
||
|
if($("form").valid()){
|
||
|
if( formsubmit == 1 ){
|
||
|
return true;
|
||
|
}
|
||
|
else{
|
||
|
swal({
|
||
|
title:'Submit Transaction Details ?',
|
||
|
text: 'Please check details entered before continue',
|
||
|
type: 'question',
|
||
|
showCancelButton: true,
|
||
|
showConfirmButton: true,
|
||
|
cancelButtonText: 'Cancel',
|
||
|
confirmButtonText: 'Yes',
|
||
|
allowOutsideClick: false,
|
||
|
allowEscapeKey: false,
|
||
|
cancelButtonColor: '#999999',
|
||
|
confirmButtonColor: '#4CAF50'
|
||
|
}).then(result => {
|
||
|
if (result.value == true ) {
|
||
|
formsubmit = 1;
|
||
|
$("form").submit();
|
||
|
}
|
||
|
else {
|
||
|
return false;
|
||
|
}
|
||
|
swal.closeModal();
|
||
|
});
|
||
|
return false;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
});
|
||
|
|
||
|
function onSubmitApproval(){
|
||
|
var statusCd = $("input[name='status']:checked").val();
|
||
|
var statusDesc;
|
||
|
if (statusCd == undefined) {
|
||
|
document.getElementById("lblStatusRequired").style.display = null;
|
||
|
return false;
|
||
|
}
|
||
|
else {
|
||
|
document.getElementById("lblStatusRequired").style.display = "none";
|
||
|
}
|
||
|
if(statusCd == "REJ"){
|
||
|
statusDesc = "Reject";
|
||
|
//check if remarks is empty
|
||
|
var content = $.trim(tinyMCE.get('remarks').getContent({format: 'text'}));
|
||
|
if(content.length == 0){
|
||
|
document.getElementById("lblRemarksRequired").style.display = null;
|
||
|
return false;
|
||
|
}
|
||
|
}
|
||
|
else{
|
||
|
statusDesc = "Appprove";
|
||
|
}
|
||
|
document.getElementById("lblRemarksRequired").style.display = "none";
|
||
|
Swal.fire({
|
||
|
title: 'Are you sure ?',
|
||
|
text: 'Do you want to ' + statusDesc +' this Top-up Application?',
|
||
|
type: 'question',
|
||
|
showCancelButton: true,
|
||
|
showConfirmButton: true,
|
||
|
cancelButtonText: 'Cancel',
|
||
|
confirmButtonText: 'Yes',
|
||
|
allowOutsideClick: false,
|
||
|
allowEscapeKey: false,
|
||
|
cancelButtonColor: '#999999',
|
||
|
confirmButtonColor: '#4CAF50'
|
||
|
}).then((result) => {
|
||
|
if (result.value) {
|
||
|
$("form").submit();
|
||
|
} else if (result.dismiss === swal.DismissReason.cancel) {
|
||
|
return false;
|
||
|
}
|
||
|
});
|
||
|
}
|
||
|
|
||
|
|
||
|
function onChangePaymentType(e) {
|
||
|
$("#trxnRefNo").attr('required', true);
|
||
|
$("#paymentdate").attr('required', true);
|
||
|
$("#bankName").attr('required', true);
|
||
|
|
||
|
var selectedIndex = e.value;
|
||
|
if (selectedIndex == 'on') {
|
||
|
var button_text = document.getElementById('onlinePymntBlock').innerText;
|
||
|
$('#offLinePymntBlock').hide();
|
||
|
|
||
|
$("#trxnRefNo").attr('required', false);
|
||
|
$("#paymentdate").attr('required', false);
|
||
|
$("#bankName").attr('required', false);
|
||
|
|
||
|
} else {
|
||
|
$('#offLinePymntBlock').show();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
$("form").submit(function() {
|
||
|
$('#payRadioError').hide();
|
||
|
|
||
|
Swal.fire({
|
||
|
text: 'Are you sure you want to proceed the Payment?',
|
||
|
type: 'question',
|
||
|
showCancelButton: true,
|
||
|
showConfirmButton: true,
|
||
|
cancelButtonText: 'Cancel',
|
||
|
confirmButtonText: 'Yes',
|
||
|
allowOutsideClick: false,
|
||
|
allowEscapeKey: false,
|
||
|
cancelButtonColor: '#999999',
|
||
|
confirmButtonColor: '#4CAF50'
|
||
|
}).then((result) => {
|
||
|
if (result.value) {
|
||
|
document.forms['topupForm'].submit();
|
||
|
} else if (result.dismiss === swal.DismissReason.cancel) {
|
||
|
return false;
|
||
|
}
|
||
|
});
|
||
|
return false;
|
||
|
|
||
|
|
||
|
});
|
||
|
|