$(document).ready(function () { $("#branchRequired").hide(); $('#branchSelect').hide(); $('#branchManual').hide(); $(document).on("change", "#" + mId + "receiverMobileNumber", function () { var isValid = CheckForMobileNumber(this, "Mobile No."); if (isValid === false) { $(this).val(''); $(this).focus(); } }); $("#searchCustomer").click(function () { ClearAllData(); $('#step2SendRemittance').hide(); $('#step2SendRemittanceCustomer').hide(); $('#step2SendRemittanceCustomer').hide(); $('#step2SendRemittanceAgreement').hide(); $('#signatureDiv').hide(); $('#step2SendRemittanceSaveButton').hide(); var myDDL = GetElement("MainContent_ddlBenedeciary"); $(myDDL).empty(); var reqField = "customerId,"; if (ValidRequiredFieldWithDoc(reqField) === false) { return false; } var customerIdNumber = $("#" + mId + "customerId").val(); var searchBy = $("#" + mId + "ddlCustomerType").val(); $("#searchStatement").attr("disabled", "disabled"); var dataToSend = { MethodName: "loadCustomerDataSendPage", CustomerSearchType: searchBy, CustomerIdNumber: customerIdNumber }; var options = { url: '', data: dataToSend, dataType: 'JSON', type: 'POST', success: function (response) { $("#searchCustomer").removeAttr("disabled"); if (response[0].errorCode === 0) { $('#step2SendRemittance').show(); $('#step2SendRemittanceCustomer').show(); $('#step2SendRemittanceAgreement').show(); $('#signatureDiv').show(); $('#step2SendRemittanceSaveButton').show(); $("#" + mId + "customerName").text(response[0].CUSTOMERNAME); $("#" + mId + "membershiId").text(response[0].MEMBERSHIPID); $("#" + mId + "hdnCustomerId").val(response[0].CUSTOMERID); CustomerSignature(); ParseDDlDynamic(response, 'ddlBenedeciary', 'FULLNAME', 'RECEIVERID', 'Select Beneficiary'); } else { alert(response[0].Msg); $('#step2SendRemittance').hide(); $('#step2SendRemittanceCustomer').hide(); $('#step2SendRemittanceAgreement').hide(); $('#signatureDiv').hide(); $('#step2SendRemittanceSaveButton').hide(); $("#" + mId + "customerId").val(''); $("#" + mId + "customerId").focus(); } } }; $.ajax(options); }); $("#MainContent_TransactionAgreement").click(function () { if ($("#MainContent_TransactionAgreement").is(":checked")) { $("#" + mId + "Save").removeAttr("disabled"); } else { $("#" + mId + "Save").attr("disabled", "disabled"); } }); $("#" + mId + "ddlBenedeciary").on("change", function () { ClearAllData(); var benefeciaryId = $("#" + mId + "ddlBenedeciary").val(); if (benefeciaryId === null || benefeciaryId === '' || benefeciaryId === undefined) { return false; } var dataToSend = { MethodName: "getBenefeciaryDetails", BenefeciaryId: benefeciaryId }; var options = { url: '', data: dataToSend, dataType: 'JSON', type: 'POST', success: function (response) { if (response[0].errorCode === 0) { $("#" + mId + "receiverFullName").val(response[0].fullName); $("#" + mId + "receiveraddress").val(response[0].address); $("#" + mId + "receiverMobileNumber").val(response[0].mobile); $("#" + mId + "purpose").val(response[0].address); $("#" + mId + "relationship").val(response[0].address); $("#" + mId + "accountNo").val(response[0].receiverAccountNo); if (response[0].relationship === '11339') { $("#" + mId + "otherRelationshipTextBox").val(response[0].relationOther); $('#otherRelationDiv').show(); } if (response[0].purposeOfRemit === '11347') { $('#purposeOtherDiv').show(); $("#" + mId + "purposeOther").val(response[0].purposeOther); } if ($.isNumeric(response[0].purposeOfRemit)) { SetDDLValueSelected(mId + "purpose", response[0].purposeOfRemit); } else { SetDDLTextSelected(mId + "purpose", response[0].purposeOfRemit); } if ($.isNumeric(response[0].relationship)) { SetDDLValueSelected(mId + "relationship", response[0].relationship); } else { SetDDLTextSelected(mId + "relationship", response[0].relationship); } SetDDLTextSelected(mId + "pCountry", response[0].country); PcountryOnChange('c', response[0].paymentMethod.toUpperCase(), response[0].bankId); if (response[0].branchDetails) { if (response[0].manualType === 'Y') { $("#" + mId + "branch_manual").val(response[0].branchDetails); } else { var dataSelectDDL = { id: response[0].branchDetails.split('|')[0], text: response[0].branchDetails.split('|')[1] }; if (dataSelectDDL.id !== 'N/A') { var newOption = new Option(dataSelectDDL.text, dataSelectDDL.id, false, false); $('.js-example-basic-single').append(newOption).trigger('change'); $('.js-example-basic-single').val(dataSelectDDL.id); // Select the option with a value of '1' $('.js-example-basic-single').trigger('change'); } } } ShowHideAccountNo(); } else { alert(response[0].Msg); } } }; $.ajax(options); }); $("#" + mId + "purpose").on("change", function () { let purposeValue = $("#" + mId + "purpose option:selected").val(); if (purposeValue === '11347') { $("#purposeOtherDiv").show(); } else { $("#purposeOtherDiv").hide(); } }); $("#" + mId + "relationship").on("change", function () { let relationValue = $("#" + mId + "relationship option:selected").val(); if (relationValue === '11339') { $("#otherRelationDiv").show(); } else { $("#otherRelationDiv").hide(); } }); $("#accountDiv").hide(); $("#" + mId + "pCountry").on("change", function () { debugger ResetAmountFields(); $("#" + mId + "branch").empty(); $("#" + mId + "pMode").empty(); $("#" + mId + "pAgent").empty(); $('.same').hide(); $("#" + mId + "branch").removeClass('required'); $("#tdLblBranch").hide(); $("#tdTxtBranch").hide(); $('#txtpBranch_aText').attr("class", "disabled form-control"); $("#txtpBranch_err").hide(); $("#txtpBranch_aValue").val(''); $("#txtpBranch_aText").val(''); $("#" + mId + "txtRecDepAcNo").val(''); $("#" + mId + "lblExCurr").text(''); $("#" + mId + "lblPayCurr").text(''); $("#" + mId + "lblPerTxnLimit").text('0.00'); if ($("#" + mId + "pCountry option:selected ").val() !== "") { PcountryOnChange('c', ""); SetPayCurrency($("#" + mId + "pCountry").val()); } var pmode = $("#" + mId + "pMode").val(); var partnerId = $("#" + mId + "hddPayoutPartner").val(); if (partnerId === '394130' || pmode === "2") { $("#" + mId + "branch").addClass('required'); $('.same').show(); } }); $("#" + mId + "pMode").on("change", function () { $("#" + mId + "branch").empty(); ClearCalculatedAmount(); $('.displayPayerInfo').hide(); $("#" + mId + "txtRecDepAcNo").val(''); $("#tdLblBranch").hide(); $("#tdTxtBranch").hide(); $('#txtpBranch_aText').attr("class", "disabled form-control"); $("#txtpBranch_err").hide(); $("#txtpBranch_aValue").val(''); $("#txtpBranch_aText").val(''); ReceivingModeOnChange("", ""); GetPayoutPartner(); var pmode = $("#" + mId + "pMode").val(); var partnerId = $("#" + mId + "hddPayoutPartner").val(); CheckForBranchShowIde(); if (partnerId === '394130' || pmode === "2") { $("#" + mId + "branch").addClass('required'); //if ((partnerId === apiPartnerIds[0]) && pmode === "2") { // $('#agentBranchRequired').hide(); // $("#" + mId + "branch").removeClass('required'); //} $('.same').show(); //if ((partnerId === apiPartnerIds[0]) && pmode === "2") { // LoadPayerData(); //} } }); $("#" + mId + "pAgent").on("change", function () { var bankId = $("#" + mId + "pAgent option:selected").val(); if (bankId === "" || bankId === null) { return; } var pmode = $("#" + mId + "pMode").val(); var partnerId = $("#" + mId + "hddPayoutPartner").val(); //$('.same').hide(); $("#" + mId + "branch").removeClass('required'); $('.displayPayerInfo').hide(); PopulateBranch(); }); $(document).on('blur', '#' + mId + 'txtCollAmt', function () { CollAmtOnChange(); }); $("#" + mId + "pMode").on('change', function () { ShowHideAccountNo(); }); }); function ShowHideAccountNo() { var pmode = $("#" + mId + "pMode").val(); if (pmode === "2") { $("#accountDiv").show(); } else { $("#accountDiv").hide(); } } function ResetAmountFields() { //Reset Fields $("#" + mId + "txtPayAmt").val(''); $("#" + mId + "txtPayAmt").attr("readonly", false); $("#" + mId + "lblSendAmt").val('0.00'); $("#" + mId + "lblServiceChargeAmt").val('0'); $("#" + mId + "lblExRate").text('0.00'); $("#lblDiscAmt").text('0.00'); $("#" + mId + "lblPayCurr").text(''); //GetElement("spnSchemeOffer").innerHTML = ""; //GetElement("spnWarningMsg").innerHTML = ""; } function PcountryOnChange(obj, pmode, pAgentSelected = "") { var pCountry = $("#" + mId + "pCountry").val(); if (pCountry === "" || pCountry === null) return; var method = ""; if (obj === 'c') { method = "PaymentModePcountry"; } if (obj === 'pcurr') { method = "PCurrPcountry"; } var dataToSend = { MethodName: method, pCountry: pCountry }; var options = { url: '', data: dataToSend, dataType: 'JSON', type: 'POST', async: false, success: function (response) { if (obj === 'c') { LoadPayMode(response, document.getElementById(mId + "pMode"), 'pcurr', "", pmode); ReceivingModeOnChange("", pAgentSelected); GetPayoutPartner(response[0].serviceTypeId); CheckForBranchShowIde(); } else if (obj === 'pcurr') { if (response === "") return false; $("#" + mId + "lblPayCurr").text(response[0].currencyCode); $("#" + mId + "lblExCurr").text(response[0].currencyCode); return true; } return true; }, error: function (result) { alert("Due to unexpected errors we were unable to load data"); } }; $.ajax(options); } function CheckForBranchShowIde() { var country = $("#" + mId + "pCountry option:selected ").text(); if (country.toUpperCase() === 'NEPAL' || country.toUpperCase() === 'VIETNAM') { $('#branchSelect').hide(); $('#branchManual').show(); if ($('#MainContent_pMode').val() === '1' && country.toUpperCase() === 'NEPAL') { $('#branchSelect').hide(); $('#branchManual').hide(); } } else { $('#branchSelect').show(); $('#branchManual').hide(); } } function LoadLocationDDL(response) { var data = response; var ddl = GetElement(mId + "locationDDL"); $(ddl).empty(); $("#" + mId + "subLocationDDL").empty(); var option; option = document.createElement("option"); for (var i = 0; i < data.length; i++) { option = document.createElement("option"); if (data[i].LOCATIONNAME === 'Any State') { $('#subLocation').hide(); } option.text = data[i].LOCATIONNAME; option.value = data[i].LOCATIONID; if ($("#" + mId + "hddLocation").val()) { if (option.value === $("#" + mId + "hddLocation").val()) { option.selected = true; } } try { ddl.options.add(option); } catch (e) { alert(e); } } if ($("#" + mId + "hddSubLocation").val()) { LoadSublocation(); } } function LoadPayMode(response, myDDL, recall, selectField, obj) { var data = response; //CheckSession(data); $(myDDL).empty(); var option; if (selectField !== "" && selectField !== undefined) { option = document.createElement("option"); option.text = selectField; option.value = ""; myDDL.options.add(option); } for (var i = 0; i < data.length; i++) { option = document.createElement("option"); option.text = data[i].typeTitle; option.value = data[i].serviceTypeId; try { myDDL.options.add(option); } catch (e) { alert(e); } } if (recall === 'pcurr') { SetDDLTextSelected(mId + "pMode", obj); } } function ReceivingModeOnChange(pModeSelected, pAgentSelected) { ResetAmountFields(); $("#" + mId + "pAgent").empty(); PaymentModeChange(pModeSelected, pAgentSelected); } function PaymentModeChange(pModeSelected, pAgentSelected) { var pMode = ""; if (pModeSelected === "" || pModeSelected === null) pMode = $("#" + mId + "pMode option:selected").text(); else { pMode = pModeSelected; } pCountry = GetValue(mId + "pCountry"); $('#trAccno').hide(); $("#" + mId + "txtRecDepAcNo").attr("class", "form-control"); $('#trForCPOB').hide(); //GetElement(mId + "paymentThrough").className = ""; if (pMode === "BANK DEPOSIT") { $('#trAccno').show(); $("#" + mId + "txtRecDepAcNo").attr("class", "required form-control"); $('#trAccno').show(); } var dataToSend = { MethodName: "loadAgentBank", pMode: pMode, pCountry: pCountry }; var options = { url: '', data: dataToSend, dataType: 'JSON', type: 'POST', async: false, success: function (response) { //LoadAgentSetting(); ParseLoadDDl(response, GetElement(mId + "pAgent"), 'agentSelection', ""); if (pAgentSelected !== "" && pAgentSelected !== null && pAgentSelected !== undefined) { SetDDLValueSelected(mId + "pAgent", pAgentSelected); } var agentId = $("#" + mId + "pAgent").val(); if (agentId !== "" && agentId !== null && agentId !== undefined) { var payMode = $("#" + mId + "pMode").val(); $('.same').show(); } } }; $.ajax(options); } function ParseLoadDDl(response, myDDL, recall, selectField) { var data = response; //CheckSession(data); var ddl2 = GetElement(mId + "pAgentDetail"); var ddl3 = GetElement(mId + "pAgentMaxPayoutLimit"); $(ddl2).empty(); $(ddl3).empty(); $(myDDL).empty(); //GetElement("spnPayoutLimitInfo").innerHTML = ""; if ($("#" + mId + "pMode option:selected").val() !== "" && recall === "agentSelection") { $('#hdnreqAgent').text(data[0].agentSelection); } var option; if (selectField !== "" && selectField !== undefined) { option = document.createElement("option"); option.text = selectField; option.value = ""; myDDL.options.add(option); } for (var i = 0; i < data.length; i++) { option = document.createElement("option"); option.text = data[i].AGENTNAME.toUpperCase(); option.value = data[i].bankId; var option2 = document.createElement("option"); option2.value = data[i].bankId; option2.text = data[i].FLAG; var option3 = document.createElement("option"); option3.value = data[i].bankId; option3.text = data[i].maxPayoutLimit; try { myDDL.options.add(option); ddl2.options.add(option2); ddl3.options.add(option3); } catch (e) { alert(e); } } if (data[0].AGENTNAME === "[SELECT BANK]") { $('#pAgent_err').show(); GetElement("pAgent_err").innerHTML = "*"; GetElement(mId + "pAgent").className = "required form-control"; } else { $('#pAgent_err').hide(); GetElement("pAgent_err").innerHTML = ""; GetElement(mId + "pAgent").className = "form-control"; } var pCountry = $("#" + mId + "pCountry option:selected").text(); var pCurr = $("#" + mId + "lblPayCurr").text(); } function ClearCalculatedAmount() { $("#" + mId + "txtCollAmt").val(''); $("#" + mId + "lblSendAmt").val(0); $("#" + mId + "lblServiceChargeAmt").val(0); $("#" + mId + "lblExRate").val(0); $("#" + mId + "txtPayAmt").val(''); $("#" + mId + "customerRateFields").hide(); } function GetPayoutPartner(payMode) { var pCountry = $("#" + mId + "pCountry").val(); var pMode = $("#" + mId + "pMode").val(); var dataToSend = { MethodName: 'getPayoutPartner', PCountry: pCountry, PMode: pMode }; var options = { url: '', data: dataToSend, dataType: 'JSON', type: 'POST', async: false, success: function (response) { var datas = response; var agentId = ""; if (datas.length > 0) { agentId = datas[0].agentId; } $("#" + mId + "hddPayoutPartner").val(agentId); $("#" + mId + "hddFetchExrateFromPartner").val(datas[0].exRateCalByPartner); $("#" + mId + "hddPCountryCode").val(datas[0].COUNTRYCODE); }, error: function (result) { alert("Due to unexpected errors we were unable to load data"); } }; $.ajax(options); } function SetDDLTextSelected(ddl, selectText) { $("#" + ddl + " option").each(function () { if ($(this).text() === $.trim(selectText)) { $(this).prop('selected', true); return; } }); } function PopulateBranch() { var dataToSend = { MethodName: 'PopulateBranch', payoutPartner: $('#' + mId + 'hddPayoutPartner').val(), Bank: $('#' + mId + 'pAgent').val(), Country: $('#' + mId + 'pCountry').val(), PayMode: $('#' + mId + 'pMode').val(), }; var options = { url: '', data: dataToSend, dataType: 'JSON', type: 'POST', async: false, success: function (response) { ParseBranchDDl(response, GetElement(mId + "branch"), '', ""); }, error: function (result) { alert("Due to unexpected errors we were unable to load data"); } }; $.ajax(options); } function ParseBranchDDl(response, myDDL, recall, selectField) { var data = response; //CheckSession(data); $(myDDL).empty(); var option; if (selectField !== "" && selectField !== undefined) { option = document.createElement("option"); option.text = selectField; option.value = ""; myDDL.options.add(option); } for (var i = 0; i < data.length; i++) { option = document.createElement("option"); option.text = data[i].agentName.toUpperCase(); option.value = data[i].agentId; try { myDDL.options.add(option); } catch (e) { alert(e); } } } function CollAmtOnChange() { var collAmt = $("#" + mId + "txtCollAmt").val(); if (collAmt === "") collAmt = "0"; var collAmtFormatted = CurrencyFormatted(collAmt); //collAmt; collAmtFormatted = CommaFormatted(collAmtFormatted); var collCurr = $("#" + mId + "lblPerTxnLimitCurr").text(); if (collAmt === "0") { ClearCalculatedAmount(); return; } checkdata(collAmt, 'cAmt'); } function CurrencyFormatted(amount) { var i = parseFloat(amount); if (isNaN(i)) { i = 0.00; } var minus = ''; if (i < 0) { minus = '-'; } i = Math.abs(i); i = parseInt((i + .005) * 100); i = i / 100; s = new String(i); if (s.indexOf('.') < 0) { s += '.00'; } if (s.indexOf('.') == (s.length - 2)) { s += '0'; } //s = minus + s; //if (amount < 0) // s = -1 * amount; return CommaFormatted(s, amount); } function CommaFormatted(amount, amountMain) { var delimiter = ","; var a = amount.split('.', 2); var d = a[1]; var i = parseInt(a[0]); if (isNaN(i)) { return ''; } var minus = ''; if (i < 0) { minus = '-'; } i = Math.abs(i); var n = new String(i); var a = []; while (n.length > 3) { var nn = n.substr(n.length - 3); a.unshift(nn); n = n.substr(0, n.length - 3); } if (n.length > 0) { a.unshift(n); } n = a.join(delimiter); if (d.length < 1) { amount = n; } else { amount = n + '.' + d; } amount = minus + amount; if (amountMain > 0) return "(" + amount + ")"; else return amount; } function checkdata(amt, obj) { if (amt > 0) CalculateTxn(amt, obj); else ClearCalculatedAmount(); } function CalculateTxn(amt, obj, isManualSc) { var collAmt = parseFloat($("#" + mId + "txtCollAmt").val().replace(',', '').replace(',', '').replace(',', '')); var customerId = $("#" + mId + "txtSearchData_aValue").val(); if (isManualSc === '' || isManualSc === undefined) { isManualSc = 'N'; } if (isManualSc === 'N') { if (obj === '' || obj === null) { if (document.getElementById(mId + "txtPayAmt").disabled) { obj = 'cAmt'; amt = GetValue(mId + "txtCollAmt"); } else { obj = 'pAmt'; amt = GetValue(mId + "txtPayAmt"); } } } else { obj = $("#" + mId + "hddCalcBy").val(); if (obj === 'cAmt') { amt = GetValue(mId + "txtCollAmt"); } else { amt = GetValue(mId + "txtPayAmt"); } } var pCountry = GetValue(mId + "pCountry"); var pCountrytxt = $("#" + mId + "pCountry option:selected").text(); var pMode = GetValue(mId + "pMode"); var pModetxt = $("#" + mId + "pMode option:selected").text(); if (pCountry === "" || pCountry === null || pCountry === undefined) { alert("Please choose payout country"); GetElement(mId + "pCountry").focus(); return false; } if (pMode === "" || pMode === null || pMode === undefined) { alert("Please choose payment mode"); GetElement(mId + "pMode").focus(); return false; } var sAgent = $("#" + mId + "sendingAgentOnBehalfDDL option:selected").val(); var pAgent = Number(GetValue(mId + "pAgent")); var pAgentBranch = GetValue("txtpBranch_aValue"); if (pModetxt === "CASH PAYMENT TO OTHER BANK") { pAgent = Number($("#" + mId + "paymentThrough option:selected").val()); pAgentBranch = ""; if (pAgent === "" || pAgent === undefined) pAgent = ""; } collAmt = GetValue(mId + "txtCollAmt"); var txtCustomerLimit = GetValue("txtCustomerLimit"); var txnPerDayCustomerLimit = GetValue(mId + "txnPerDayCustomerLimit"); var schemeCode = GetValue(mId + "ddlScheme"); if (obj === "cAmt") { collAmt = amt; payAmt = 0; } if (obj === "pAmt") { payAmt = amt; collAmt = 0; } var payCurr = $("#" + mId + "pCurrDdl").val(); var collCurr = $("#" + mId + "lblPerTxnLimitCurr").text(); var senderId = $('#finalSenderId').text(); var couponId = $("#" + mId + "iTelCouponId").val(); var sc = $("#" + mId + "lblServiceChargeAmt").val(); if (pCountry === "203" && payCurr === "USD") { if ((pMode === "1" && pAgent !== 2091) || (pMode !== "12" && pAgent !== 2091)) { alert('USD receiving is only allow for Door to Door'); ClearCalculatedAmount(); return false; } } var collectAmount = Number($("#" + mId + "txtCollAmt").val()); var payoutAmount = Number($("#" + mId + "txtPayAmt").val()); var payoutPartner = $("#" + mId + "hddPayoutPartner").val(); var IsExrateFromPartner = $("#" + mId + "hddFetchExrateFromPartner").val(); var PCountryCode = $("#" + mId + "hddPCountryCode").val(); if (collectAmount <= 0 && payoutAmount <= 0) { return; } $("#" + mId + "hddCalcBy").val(obj); var dataToSend = { MethodName: 'CalculateTxn', pCountry: pCountry, pCountrytxt: pCountrytxt, pMode: pMode, pAgent: pAgent , pAgentBranch: pAgentBranch, collAmt: collAmt, payAmt: payAmt, payCurr: payCurr, collCurr: collCurr , pModetxt: pModetxt, senderId: senderId, schemeCode: schemeCode, couponId: couponId, isManualSc: isManualSc , sc: sc, payoutPartner: payoutPartner, IsExrateFromPartner: IsExrateFromPartner, PCountryCode: PCountryCode }; var options = { url: '', data: dataToSend, dataType: 'JSON', type: 'POST', async: false, success: function (response) { ParseCalculateData(response, obj); } }; $.ajax(options); $("#DivLoad").hide(); return true; } function ParseCalculateData(response, amtType) { var data = response; if (data[0].ErrCode === '1') { alert(data[0].Msg); ClearCalculatedAmount(); return; } $("#" + mId + "lblSendAmt").val(parseFloat(Number(data[0].sAmt).toFixed(3))); // $("#" + mId + "hddTamt").val(parseFloat(Number(data[0].sAmt).toFixed(3))); // $("#" + mId + "lblExRate").text(roundNumber(data[0].exRate, 8)); $("#" + mId + "lblPayCurr").text(data[0].pCurr); $("#" + mId + "lblExCurr").text(data[0].pCurr); if ($("#" + mId + "allowEditSC").val() === 'Y') { $("#" + mId + "editServiceCharge").attr("disabled", false); } $("#" + mId + "lblPerTxnLimit").text(data[0].limit); $("#" + mId + "lblPerTxnLimitCurr").text(data[0].limitCurr); if (!$("#" + mId + "editServiceCharge").is(':checked')) { $("#" + mId + "lblServiceChargeAmt").attr('disabled', 'disabled'); } $("#" + mId + "lblServiceChargeAmt").val(parseFloat(data[0].scCharge).toFixed(0)); $("#" + mId + "hddServiceCharge").val(parseFloat(data[0].scCharge).toFixed(0)); SetValueById(mId + "txtCollAmt", parseFloat(Number(data[0].collAmt).toFixed(3)), ""); // SetValueById(mId + "lblSendAmt", parseFloat(Number(data[0].sAmt).toFixed(3)), ""); // $("#" + mId + "hddTPExRate").val(data[0].tpExRate); var exRateOffer = data[0].exRateOffer; var scOffer = data[0].scOffer; var scDiscount = data[0].scDiscount; var collectionAmount = Number($("#" + mId + "txtCollAmt").val()); if (collectionAmount > 0) { $("#" + mId + "customerRateFields").show(); } } function roundNumber(rnum, rlength) { // Arguments: number to round, number of decimal places var newnumber = Math.round(rnum * Math.pow(10, rlength)) / Math.pow(10, rlength); return parseFloat(newnumber); // Output the result to the form field (change for your purposes) } function ValidateDetailsMain() { var isFormDataValid = ValidateDetails(); if (isFormDataValid === true) { // return CheckSignatureCustomerFromCustomerRegister(); // return true; SendTransactionJS(); } else { return false; } } function ValidateDetails() { var reqField = "customerId,receiverFullName,receiveraddress,ddlCollMode,receiverMobileNumber,pCountry,pMode,txtCollAmt,purpose,relationship,"; //var pmodeId = $("#" + mId + "pMode").val(); //if (pmodeId != "1" && pmodeId != undefined) { // reqField += "branch,"; // $("#branchRequired").show(); //} else { // $("#" + mId + "branch").removeClass("required"); // $("#" + mId + "branch").css('background-color', '#FFFFFF'); // $("#branchRequired").hide(); //} let purposeValue = $("#" + mId + "purpose option:selected").val(); if (purposeValue === '11347') { reqField += "purposeOther,"; } let relationValue = $("#" + mId + "relationship option:selected").val(); if (relationValue === '11339') { reqField += "otherRelationshipTextBox,"; } if (ValidRequiredFieldWithDoc(reqField) === false) { return false; } else { var pMode = $("#" + mId + "pMode").val(); var pAgent = $("#" + mId + "pAgent").val(); var pbranch = $("#" + mId + "branch").val(); var accountNo = $("#" + mId + "accountNo").val(); if (pMode === "2") { if (pAgent === '' || pAgent === undefined || pAgent === null) { $("#" + mId + "pAgent").css('background-color', '#FFCCD2'); alert('Required Field(s)\n _____________________________ \n The red fields are required!'); return false; } if (accountNo === '' || accountNo === undefined || accountNo === null) { $("#" + mId + "accountNo").css('background-color', '#FFCCD2'); alert('Required Field(s)\n _____________________________ \n The red fields are required!'); return false; } } $("#" + mId + "hddPmode").val(pMode); $("#" + mId + "hddPagent").val(pAgent); $("#" + mId + "hddpBranch").val(pbranch); var country = $("#" + mId + "pCountry option:selected ").text(); $("#" + mId + "hddPagentName").val($("#" + mId + "pAgent option:selected").text()); if (country.toUpperCase() === 'NEPAL' || country.toUpperCase() === 'VIETNAM') { $("#" + mId + "hddPBranchName").val($("#" + mId + "branch_manual").val()); } else { $("#" + mId + "hddPBranchName").val($("#" + mId + "branch option:selected").text()); } return true; } } function SetMessageBox(msg, errorCode) { alert(msg); } function SetDDLValueSelected(ddl, selectText) { $("#" + ddl + " option").each(function () { if ($(this).val() === $.trim(selectText)) { $(this).prop('selected', true); return; } }); } function CheckForMobileNumber(nField, fieldName) { var numberPattern = /^[+]?[0-9]{6,16}$/; test = numberPattern.test(nField.value); if (!test) { alert(fieldName + " Is Not Valid !"); nField.value = ""; return false } return true; } function SetPayCurrency(pCountry) { var dataToSend = { MethodName: 'PCurrPcountry', pCountry: pCountry }; var options = { url: '', data: dataToSend, dataType: 'JSON', type: 'POST', async: false, success: function (response) { var data = response; var ddl = GetElement(mId + "pCurrDdl"); $(ddl).empty(); var option; for (var i = 0; i < data.length; i++) { option = document.createElement("option"); option.text = data[i].currencyCode; option.value = data[i].currencyCode; try { ddl.options.add(option); if (data[i].isDefault === "Y") { $("#" + mId + "pCurrDdl").val(data[i].currencyCode); } } catch (e) { alert(e); } } }, error: function (result) { alert("Due to unexpected errors we were unable to load data"); } }; $.ajax(options); } $(document).on('click', '#calc', function () { if (ValidateDetailsMain() == "true") { SendTransactionJS(); } /* GetAdditionalCDDIForm();*/ }); function SendTransactionJS() { var customerId = $("#" + mId + "hdnCustomerId").val(); var receiverFullNameValue = $("#" + mId + "receiverFullName").val(); var receiveraddressValue = $("#" + mId + "receiveraddress").val(); var receiverMobileNumberValue = $("#" + mId + "receiverMobileNumber").val(); var pCountryId = $("#" + mId + "pCountry").val(); var pmodeId = $("#" + mId + "pMode").val(); var pagentId = $("#" + mId + "pAgent").val(); var branchId = $("#" + mId + "branch").val(); var accountnoValue = $("#" + mId + "accountNo").val(); var cAmt = $("#" + mId + "txtCollAmt").val(); var tamt = $("#" + mId + "lblSendAmt").val(); var serviceCharge = $("#" + mId + "lblServiceChargeAmt").val(); var purposeOfRemittanceId = $("#" + mId + "purpose").val(); var otherPurpose = $("#" + mId + "purposeOther").val(); var relationShipId = $("#" + mId + "relationShip").val(); var otherRelation = $("#" + mId + "otherRelationshipTextBox").val(); var referralNameValue = $("#" + mId + "referralName").val(); var collectionMode = $("#" + mId + "ddlCollMode").val(); var deliveryMethod = $("#" + mId + "pMode").val(); var isCDDI = $("#" + mId + "hddIsAdditionalCDDI").val(); var hddAgentRefId = $("#" + mId + "hddAgentRefId").val(); var xmlDataForCDDI = ''; if (isCDDI === 'Y') { xmlDataForCDDI = GetXMLData(); //sessionStorage.setItem("XmlDataForCDDI", xmlDataForCDDI); } var dataToSend = { MethodName: 'sendTransaction', customerId: customerId, receiverFullNameValue: receiverFullNameValue, receiveraddressValue: receiveraddressValue, receiverMobileNumberValue: receiverMobileNumberValue, pCountryId: pCountryId, pmodeId: pmodeId, pagentId: pagentId, branchId: branchId, accountnoValue: accountnoValue, cAmt: cAmt, tamt: tamt, serviceCharge: serviceCharge, purposeOfRemittanceId: purposeOfRemittanceId, otherPurpose: otherPurpose, relationShipId: relationShipId, otherRelation: otherRelation, referralNameValue: referralNameValue, collectionMode: collectionMode, deliveryMethod: deliveryMethod, hddAgentRefId: hddAgentRefId, isCDDI: isCDDI, xmlDataForCDDI: xmlDataForCDDI }; $.ajax({ type: "POST", data: dataToSend, async: true, success: function (response) { var data = jQuery.parseJSON(response); if (data[0][0].errorCode !== 0) { $("#" + mId + "complianceField").show(); $("#" + mId + "divCompliance").show(); if (data[0][0].errorCode == "100") // 100 means ofac { var result = data[0][0].id.split('|'); $("#" + mId + "hdnOfacRes").val(result[0]); $("#" + mId + "hdnOfacReason").val(result[1]); $("#" + mId + "hdnTrackBy").val(data[0][0].extra); if (data.table.row.count > 0) { LoadOfacList(data[0], data[1], data[0][0].receiverFullName); } if (data.table.count > 2) { if (data[3].row.count > 0 && data[2][0].errorCode != "0") { LoadCompliance(data[2], data[3], "tran"); // add agentRefId ShowDuplicateTxn(data[5], data[6]); } else { ShowDuplicateTxn(data[3], data[4]); } } } else if (data[0][0].errorCode == "101" || data[0][0].errorCode == "102" || data[0][0].errorCode == "103") { ShowDuplicateTxn(data[3], data[4]); LoadCompliance(data[0], data[1], "questionnaire"); // add agentRefId } else { ShowDuplicateTxn(data[1], data[2]); } } else { SaveTransaction(); } // $('#btnSaveAdditionalCDDI').attr('disabled', false); }, fail: function () { $('#calc').attr('disabled', false); alert("Error fetching data"); } }); } function ClearAllCustomerInfo() { $('.infoDiv').css('pointer-events', 'auto'); $('#' + mId + "Manage").hide(); $('#' + mId + "additionalCDDI").hide(); $("#" + mId + "calc").attr('disabled', false); $("#" + mId + "hddIsAdditionalCDDI").val('N'); $("#" + mId + "hddAgentRefId").val(''); // ClearCDDIInfo(); $("#" + mId + "customerId").val(''); $("#" + mId + "receiverFullName").val(''); $("#" + mId + "receiveraddress").val(''); $("#" + mId + "receiverMobileNumber").val(''); $("#" + mId + "pCountry").val(''); $("#" + mId + "pmode").val(''); $("#" + mId + "pagent").val(''); $("#" + mId + "branch").val(''); $("#" + mId + "accountno").val(''); $("#" + mId + "txtCollAmt").val(''); $("#" + mId + "lblSendAmt").val(''); $("#" + mId + "lblServiceChargeAmt").val(''); $("#" + mId + "purpose").val(''); $("#" + mId + "purposeOther").val(''); $("#" + mId + "relationShip").val(''); $("#" + mId + "otherRelationshipTextBox").val(''); $("#" + mId + "referralName").val(''); $("#" + mId + "ddlCollMode").val(''); $("#" + mId + "pmode").val(''); } function ClearAllData() { $("#" + mId + "receiverFullName").val(''); $("#" + mId + "receiveraddress").val(''); $("#" + mId + "receiverMobileNumber").val(''); $("#" + mId + "purpose").val(''); $("#" + mId + "relationship").val(''); $("#" + mId + "purposeOther").val(''); $("#" + mId + "otherRelationshipTextBox").val(''); $('#otherRelationDiv').hide(); $('#purposeOtherDiv').hide(); $("#" + mId + "purpose").val(''); $("#" + mId + "relationship").val(''); $("#" + mId + "pCountry").val(''); $("#" + mId + "pAgent").empty(); $("#" + mId + "branch").empty(); SetDDLTextSelected(mId + "pCountry", ''); ClearCalculatedAmount(); } $(document).on('click', '#btnSendTxnCDDI', function () { var isValid = 'Y'; $(".requiredCompliance").each(function () { if (!$.trim($(this).val())) { $(this).addClass('error'); isValid = 'N'; } }); if (isValid === 'N') { return alert("Required Field(s)\n _____________________________ \n The red fields are required!") } SaveTransaction(); }); function SaveTransaction() { var customerId = $("#" + mId + "hdnCustomerId").val(); var receiverFullNameValue = $("#" + mId + "receiverFullName").val(); var receiveraddressValue = $("#" + mId + "receiveraddress").val(); var receiverMobileNumberValue = $("#" + mId + "receiverMobileNumber").val(); var pCountryId = $("#" + mId + "pCountry").val(); var pmodeId = $("#" + mId + "pMode").val(); var pagentId = $("#" + mId + "pAgent").val(); var branchId = $("#" + mId + "branch").val(); var accountnoValue = $("#" + mId + "accountNo").val(); var cAmt = $("#" + mId + "txtCollAmt").val(); var tamt = $("#" + mId + "lblSendAmt").val(); var serviceCharge = $("#" + mId + "lblServiceChargeAmt").val(); var purposeOfRemittanceId = $("#" + mId + "purpose").val(); var otherPurpose = $("#" + mId + "purposeOther").val(); var relationShipId = $("#" + mId + "relationShip").val(); var otherRelation = $("#" + mId + "otherRelationshipTextBox").val(); var referralNameValue = $("#" + mId + "referralName").val(); var collectionMode = $("#" + mId + "ddlCollMode").val(); var deliveryMethod = $("#" + mId + "pMode").val(); var isCDDI = $("#" + mId + "hddIsAdditionalCDDI").val(); var hddAgentRefId = $("#" + mId + "hddAgentRefId").val(); var xmlDataForCDDI = ''; if (isCDDI === 'Y') { xmlDataForCDDI = GetXMLData(); //sessionStorage.setItem("XmlDataForCDDI", xmlDataForCDDI); } var dataToSend = { MethodName: 'saveTransaction', customerId: customerId, receiverFullNameValue: receiverFullNameValue, receiveraddressValue: receiveraddressValue, receiverMobileNumberValue: receiverMobileNumberValue, pCountryId: pCountryId, pmodeId: pmodeId, pagentId: pagentId, branchId: branchId, accountnoValue: accountnoValue, cAmt: cAmt, tamt: tamt, serviceCharge: serviceCharge, purposeOfRemittanceId: purposeOfRemittanceId, otherPurpose: otherPurpose, relationShipId: relationShipId, otherRelation: otherRelation, referralNameValue: referralNameValue, collectionMode: collectionMode, deliveryMethod: deliveryMethod, hddAgentRefId: hddAgentRefId, isCDDI: isCDDI, xmlDataForCDDI: xmlDataForCDDI }; $.ajax({ type: "POST", data: dataToSend, async: true, success: function (response) { var data = jQuery.parseJSON(response); //alert(data[0][0].Msg); if (data.errorCode = "0") { var id = data.Extra.split('|')[1]; window.location.replace("PrintSendMoneyRequestDetails.aspx?customerId=" + id + "&rowId=" + data.Id); } alert(data.Msg); }, fail: function () { $('#calc').attr('disabled', false); alert("Error fetching data"); } }); }