You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

356 lines
13 KiB

function PopulateReceiverDataDDL(response) {
var res = jQuery.parseJSON(response);
var data = res.Table1;
debugger
var ddl = GetElement(mId + "ddlReceiver");
$(ddl).empty();
var option = document.createElement("option");
option.text = 'Select Receiver';
option.value = '';
ddl.options.add(option);
for (var i = 0; i < data.length; i++) {
option = document.createElement("option");
option.text = data[i].fullName.toUpperCase();
option.value = data[i].receiverId;
try {
ddl.options.add(option);
}
catch (e) {
alert(e);
}
}
option = document.createElement("option");
option.text = 'New Receiver';
option.value = '0';
ddl.options.add(option);
}
function DDLReceiverOnChange() {
ClearTxnData();
var receiverId = $("#" + mId + "ddlReceiver").val();
if (receiverId !== '' && receiverId !== undefined && receiverId !== "0") {
SearchReceiverDetails(receiverId);
}
else if (receiverId === "0") {
ClearReceiverData();
PickReceiverFromSender('a');
}
else if (receiverId === null || receiverId === "") {
$('.readonlyOnReceiverSelect').removeAttr("disabled");
ClearReceiverData();
}
}
function SearchReceiverDetails(customerId) {
if (customerId === "" || customerId === null) {
ClearReceiverData();
alert('Invalid receiver selected!');
}
var dataToSend = { MethodName: 'SearchReceiver', customerId: customerId };
$.post('', dataToSend, function (response) {
ParseResponseForReceiverData(response);
}).fail(function () {
});
return true;
}
function ParseResponseForReceiverData(response) {
$('.readonlyOnReceiverSelect').attr("disabled", "disabled");
var data = jQuery.parseJSON(response);
debugger
//CheckSession(data);
if (data[0].errorCode !== 0) {
alert(data[0].msg);
return;
}
if (data.length > 0) {
//****Transaction Detail****
$("#receiverName").text(data[0].firstName + ' ' + data[0].middleName + ' ' + data[0].lastName1);
$("#" + mId + "txtRecFName").val(data[0].firstName);
$("#" + mId + "txtRecMName").val(data[0].middleName);
$("#" + mId + "txtRecLName").val(data[0].lastName1);
$("#" + mId + "txtRecAdd1").val(data[0].address);
$("#" + mId + "txtRecMobile").val(data[0].mobile);
if ($.isNumeric(data[0].purposeOfRemit)) {
SetDDLValueSelected(mId + "purpose", data[0].purposeOfRemit);
} else {
SetDDLTextSelected(mId + "purpose", data[0].purposeOfRemit);
}
if ($.isNumeric(data[0].relationship)) {
SetDDLValueSelected(mId + "relationship", data[0].relationship);
} else {
SetDDLTextSelected(mId + "relationship", data[0].relationship);
}
SetDDLValueSelected(mId + "ddlReceiver", data[0].receiverId);
$("#" + mId + "hddreceiverId").val(data[0].receiverId);
ClearTxnData();
SetDDLTextSelected(mId + "pCountry", data[0].country.toUpperCase());
//$("#" + mId + "txtRecCity").val(data[0].city);
//$("#" + mId + "txtRecTel").val(data[0].homePhone);
//$("#" + mId + "txtRecIdNo").val(data[0].idNumber);
//$("#" + mId + "txtRecEmail").val(data[0].email);
//$("#" + mId + "ddlRecGender").val(data[0].gender);
//$("#" + mId + "ddlRecIdType").val(data[0].idType);
//SetDDLTextSelected(mId + "ddlRecGender", data[0].gender);
//if ($.isNumeric(data[0].purposeOfRemit)) {
// SetDDLValueSelected(mId + "purpose", data[0].purposeOfRemit);
//} else {
// SetDDLTextSelected(mId + "purpose", data[0].purposeOfRemit);
//}
//if ($.isNumeric(data[0].relationship)) {
// SetDDLValueSelected(mId + "relationship", data[0].relationship);
//} else {
// SetDDLTextSelected(mId + "relationship", data[0].relationship);
//}
////****Transaction Detail****
//ClearTxnData();
//SetDDLTextSelected(mId + "pCountry", data[0].country.toUpperCase());
PcountryOnChange('c', data[0].paymentMethod.toUpperCase(), data[0].bankId);
if (data[0].paymentMethod.toUpperCase() === 'BANK DEPOSIT') {
var isBranchByName = 'N';
var branch = '';
PopulateBankDetails(data[0].bankId, 2, isBranchByName, data[0].branchId);
}
$("#branchDetail").text(data[0].branchDetails.split('|')[1]);
$("#payerDetailsHistory").text(data[0].payerDetailsHistory.split('|')[1]);
SetPayCurrency(data[0].COUNTRYID);
PAgentChange();
$("#" + mId + "txtRecDepAcNo").val(data[0].receiverAccountNo);
//ManageHiddenFields(data[0].paymentMethod.toUpperCase());
$(".readonlyOnCustomerSelect").attr("disabled", "disabled");
//RemoveDisableProperty();
$("#txtpBranch_aValue").val('');
$("#txtpBranch_aText").val('');
$("#" + mId + "hddLocation").val(data[0].pState);
$("#" + mId + "hddSubLocation").val(data[0].pDistrict);
//ManageLocationData();
if (data[0].branchDetails) {
if (data[0].manualType === 'Y') {
$('#branch_manual').val(data[0].branchDetails);
}
else {
var dataSelectDDL = {
id: data[0].branchDetails.split('|')[0],
text: data[0].branchDetails.split('|')[1]
};
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');
}
}
$("#" + mId + "hddPayerData").val(data[0].payerDetailsHistory.split('|')[0]);
var a = data[0].payerDetailsHistory.split('|')[0];
var choosePayer = $("#" + mId + "hddChoosePayer").val();
if ($("#" + mId + "hddPayerData").val()) {
if (choosePayer === 'true') {
LoadPayerData();
}
}
$("#" + mId + "hddLocation").val('');
$("#" + mId + "hddSubLocation").val('');
$("#" + mId + "hddPayerData").val('');
}
}
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') {
debugger
LoadPayMode(response, document.getElementById(mId + "pMode"), 'pcurr', "", pmode);
ReceivingModeOnChange("", pAgentSelected);
GetPayoutPartner(response[0].serviceTypeId);
}
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 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 GetPayoutPartner(payMode) {
var pCountry = $("#" + mId + "pCountry").val();
var pMode = $("#" + mId + "pMode").val();
var dataToSend = { MethodName: 'getPayoutPartner', PCountry: pCountry, PMode: pMode };
var options = {
url: 'SendV2.aspx?',
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 + "hddIsRealTimeTxn").val(datas[0].isRealTime);
$("#" + mId + "hddPCountryCode").val(datas[0].COUNTRYCODE);
$("#" + mId + "hddChoosePayer").val(datas[0].ChoosePayer);
},
error: function (result) {
alert("Due to unexpected errors we were unable to load data");
}
};
$.ajax(options);
}
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);
}
function PAgentChange() {
$("#" + mId + "branch").empty();
var pAgent = $(mId + "pAgent").val();
if (pAgent === null || pAgent === "" || pAgent === undefined)
return;
SetDDLValueSelected(mId + "pAgentDetail", pAgent);
var pBankType = $("#" + mId + "pAgentDetail option:selected").text();
var pCountry = $("#" + mId + "pCountry option:selected").val();
var pMode = $("#" + mId + "pMode option:selected").val();
var pModeTxt = $("#" + mId + "pMode option:selected").text();
var dataToSend = { MethodName: "PAgentChange", pCountry: pCountry, pAgent: pAgent, pMode: pMode, pBankType: pBankType };
var options =
{
url: 'SendV2.aspx?x=' + new Date().getTime(),
data: dataToSend,
dataType: 'JSON',
type: 'POST',
success: function (response) {
ApplyAgentSetting(response, pModeTxt);
if (pModeTxt === "CASH PAYMENT TO OTHER BANK")
LoadAgentByExtAgent(pAgent);
LoadCustomerRate();
}
};
$.ajax(options);
}
function ClearReceiverData() {
$('#receiverName').text('');
$('#finalBenId').text('');
SetDDLValueSelected(mId + "ddlReceiver", "");
SetDDLValueSelected(mId + "ddlRecIdType", "");
$("#" + mId + "txtRecFName").val("");
$("#" + mId + "txtRecMName").val("");
$("#" + mId + "txtRecLName").val("");
$("#" + mId + "txtRecSLName").val("");
$("#" + mId + "txtRecAdd1").val("");
$("#" + mId + "txtRecAdd2").val("");
$("#" + mId + "txtRecCity").val("");
$("#" + mId + "txtRecMobile").val("");
$("#" + mId + "txtRecTel").val("");
SetDDLValueSelected(mId + "ddlRecIdType", "");
$("#" + mId + "txtRecIdNo").val("");
SetDDLValueSelected(mId + "ddlRecGender", "");
$("#" + mId + "txtRecPostal").val("");
$("#" + mId + "txtRecEmail").val("");
$("#" + mId + "txtRecIdNo").removeClass('required');
$("#" + mId + "txtRecIdNo_err").hide();
}