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.

355 lines
13 KiB

4 years ago
  1. function PopulateReceiverDataDDL(response) {
  2. var res = jQuery.parseJSON(response);
  3. var data = res.Table1;
  4. debugger
  5. var ddl = GetElement(mId + "ddlReceiver");
  6. $(ddl).empty();
  7. var option = document.createElement("option");
  8. option.text = 'Select Receiver';
  9. option.value = '';
  10. ddl.options.add(option);
  11. for (var i = 0; i < data.length; i++) {
  12. option = document.createElement("option");
  13. option.text = data[i].fullName.toUpperCase();
  14. option.value = data[i].receiverId;
  15. try {
  16. ddl.options.add(option);
  17. }
  18. catch (e) {
  19. alert(e);
  20. }
  21. }
  22. option = document.createElement("option");
  23. option.text = 'New Receiver';
  24. option.value = '0';
  25. ddl.options.add(option);
  26. }
  27. function DDLReceiverOnChange() {
  28. ClearTxnData();
  29. var receiverId = $("#" + mId + "ddlReceiver").val();
  30. if (receiverId !== '' && receiverId !== undefined && receiverId !== "0") {
  31. SearchReceiverDetails(receiverId);
  32. }
  33. else if (receiverId === "0") {
  34. ClearReceiverData();
  35. PickReceiverFromSender('a');
  36. }
  37. else if (receiverId === null || receiverId === "") {
  38. $('.readonlyOnReceiverSelect').removeAttr("disabled");
  39. ClearReceiverData();
  40. }
  41. }
  42. function SearchReceiverDetails(customerId) {
  43. if (customerId === "" || customerId === null) {
  44. ClearReceiverData();
  45. alert('Invalid receiver selected!');
  46. }
  47. var dataToSend = { MethodName: 'SearchReceiver', customerId: customerId };
  48. $.post('', dataToSend, function (response) {
  49. ParseResponseForReceiverData(response);
  50. }).fail(function () {
  51. });
  52. return true;
  53. }
  54. function ParseResponseForReceiverData(response) {
  55. $('.readonlyOnReceiverSelect').attr("disabled", "disabled");
  56. var data = jQuery.parseJSON(response);
  57. debugger
  58. //CheckSession(data);
  59. if (data[0].errorCode !== 0) {
  60. alert(data[0].msg);
  61. return;
  62. }
  63. if (data.length > 0) {
  64. //****Transaction Detail****
  65. $("#receiverName").text(data[0].firstName + ' ' + data[0].middleName + ' ' + data[0].lastName1);
  66. $("#" + mId + "txtRecFName").val(data[0].firstName);
  67. $("#" + mId + "txtRecMName").val(data[0].middleName);
  68. $("#" + mId + "txtRecLName").val(data[0].lastName1);
  69. $("#" + mId + "txtRecAdd1").val(data[0].address);
  70. $("#" + mId + "txtRecMobile").val(data[0].mobile);
  71. if ($.isNumeric(data[0].purposeOfRemit)) {
  72. SetDDLValueSelected(mId + "purpose", data[0].purposeOfRemit);
  73. } else {
  74. SetDDLTextSelected(mId + "purpose", data[0].purposeOfRemit);
  75. }
  76. if ($.isNumeric(data[0].relationship)) {
  77. SetDDLValueSelected(mId + "relationship", data[0].relationship);
  78. } else {
  79. SetDDLTextSelected(mId + "relationship", data[0].relationship);
  80. }
  81. SetDDLValueSelected(mId + "ddlReceiver", data[0].receiverId);
  82. $("#" + mId + "hddreceiverId").val(data[0].receiverId);
  83. ClearTxnData();
  84. SetDDLTextSelected(mId + "pCountry", data[0].country.toUpperCase());
  85. //$("#" + mId + "txtRecCity").val(data[0].city);
  86. //$("#" + mId + "txtRecTel").val(data[0].homePhone);
  87. //$("#" + mId + "txtRecIdNo").val(data[0].idNumber);
  88. //$("#" + mId + "txtRecEmail").val(data[0].email);
  89. //$("#" + mId + "ddlRecGender").val(data[0].gender);
  90. //$("#" + mId + "ddlRecIdType").val(data[0].idType);
  91. //SetDDLTextSelected(mId + "ddlRecGender", data[0].gender);
  92. //if ($.isNumeric(data[0].purposeOfRemit)) {
  93. // SetDDLValueSelected(mId + "purpose", data[0].purposeOfRemit);
  94. //} else {
  95. // SetDDLTextSelected(mId + "purpose", data[0].purposeOfRemit);
  96. //}
  97. //if ($.isNumeric(data[0].relationship)) {
  98. // SetDDLValueSelected(mId + "relationship", data[0].relationship);
  99. //} else {
  100. // SetDDLTextSelected(mId + "relationship", data[0].relationship);
  101. //}
  102. ////****Transaction Detail****
  103. //ClearTxnData();
  104. //SetDDLTextSelected(mId + "pCountry", data[0].country.toUpperCase());
  105. PcountryOnChange('c', data[0].paymentMethod.toUpperCase(), data[0].bankId);
  106. if (data[0].paymentMethod.toUpperCase() === 'BANK DEPOSIT') {
  107. var isBranchByName = 'N';
  108. var branch = '';
  109. PopulateBankDetails(data[0].bankId, 2, isBranchByName, data[0].branchId);
  110. }
  111. $("#branchDetail").text(data[0].branchDetails.split('|')[1]);
  112. $("#payerDetailsHistory").text(data[0].payerDetailsHistory.split('|')[1]);
  113. SetPayCurrency(data[0].COUNTRYID);
  114. PAgentChange();
  115. $("#" + mId + "txtRecDepAcNo").val(data[0].receiverAccountNo);
  116. //ManageHiddenFields(data[0].paymentMethod.toUpperCase());
  117. $(".readonlyOnCustomerSelect").attr("disabled", "disabled");
  118. //RemoveDisableProperty();
  119. $("#txtpBranch_aValue").val('');
  120. $("#txtpBranch_aText").val('');
  121. $("#" + mId + "hddLocation").val(data[0].pState);
  122. $("#" + mId + "hddSubLocation").val(data[0].pDistrict);
  123. //ManageLocationData();
  124. if (data[0].branchDetails) {
  125. if (data[0].manualType === 'Y') {
  126. $('#branch_manual').val(data[0].branchDetails);
  127. }
  128. else {
  129. var dataSelectDDL = {
  130. id: data[0].branchDetails.split('|')[0],
  131. text: data[0].branchDetails.split('|')[1]
  132. };
  133. var newOption = new Option(dataSelectDDL.text, dataSelectDDL.id, false, false);
  134. $('.js-example-basic-single').append(newOption).trigger('change');
  135. $('.js-example-basic-single').val(dataSelectDDL.id); // Select the option with a value of '1'
  136. $('.js-example-basic-single').trigger('change');
  137. }
  138. }
  139. $("#" + mId + "hddPayerData").val(data[0].payerDetailsHistory.split('|')[0]);
  140. var a = data[0].payerDetailsHistory.split('|')[0];
  141. var choosePayer = $("#" + mId + "hddChoosePayer").val();
  142. if ($("#" + mId + "hddPayerData").val()) {
  143. if (choosePayer === 'true') {
  144. LoadPayerData();
  145. }
  146. }
  147. $("#" + mId + "hddLocation").val('');
  148. $("#" + mId + "hddSubLocation").val('');
  149. $("#" + mId + "hddPayerData").val('');
  150. }
  151. }
  152. function PcountryOnChange(obj, pmode, pAgentSelected = "") {
  153. var pCountry = $("#" + mId + "pCountry").val();
  154. if (pCountry === "" || pCountry === null)
  155. return;
  156. var method = "";
  157. if (obj === 'c') {
  158. method = "PaymentModePcountry";
  159. }
  160. if (obj === 'pcurr') {
  161. method = "PCurrPcountry";
  162. }
  163. var dataToSend = { MethodName: method, pCountry: pCountry };
  164. var options =
  165. {
  166. url: '',
  167. data: dataToSend,
  168. dataType: 'JSON',
  169. type: 'POST',
  170. async: false,
  171. success: function (response) {
  172. if (obj === 'c') {
  173. debugger
  174. LoadPayMode(response, document.getElementById(mId + "pMode"), 'pcurr', "", pmode);
  175. ReceivingModeOnChange("", pAgentSelected);
  176. GetPayoutPartner(response[0].serviceTypeId);
  177. }
  178. else if (obj === 'pcurr') {
  179. if (response === "")
  180. return false;
  181. $("#" + mId + "lblPayCurr").text(response[0].currencyCode);
  182. $("#" + mId + "lblExCurr").text(response[0].currencyCode);
  183. return true;
  184. }
  185. return true;
  186. },
  187. error: function (result) {
  188. alert("Due to unexpected errors we were unable to load data");
  189. }
  190. };
  191. $.ajax(options);
  192. }
  193. function LoadPayMode(response, myDDL, recall, selectField, obj) {
  194. var data = response;
  195. //CheckSession(data);
  196. $(myDDL).empty();
  197. var option;
  198. if (selectField !== "" && selectField !== undefined) {
  199. option = document.createElement("option");
  200. option.text = selectField;
  201. option.value = "";
  202. myDDL.options.add(option);
  203. }
  204. for (var i = 0; i < data.length; i++) {
  205. option = document.createElement("option");
  206. option.text = data[i].typeTitle;
  207. option.value = data[i].serviceTypeId;
  208. try {
  209. myDDL.options.add(option);
  210. }
  211. catch (e) {
  212. alert(e);
  213. }
  214. }
  215. if (recall === 'pcurr') {
  216. SetDDLTextSelected(mId + "pMode", obj);
  217. }
  218. }
  219. function GetPayoutPartner(payMode) {
  220. var pCountry = $("#" + mId + "pCountry").val();
  221. var pMode = $("#" + mId + "pMode").val();
  222. var dataToSend = { MethodName: 'getPayoutPartner', PCountry: pCountry, PMode: pMode };
  223. var options = {
  224. url: 'SendV2.aspx?',
  225. data: dataToSend,
  226. dataType: 'JSON',
  227. type: 'POST',
  228. async: false,
  229. success:
  230. function (response) {
  231. var datas = response;
  232. var agentId = "";
  233. if (datas.length > 0) {
  234. agentId = datas[0].agentId;
  235. }
  236. $("#" + mId + "hddPayoutPartner").val(agentId);
  237. $("#" + mId + "hddFetchExrateFromPartner").val(datas[0].exRateCalByPartner);
  238. $("#" + mId + "hddIsRealTimeTxn").val(datas[0].isRealTime);
  239. $("#" + mId + "hddPCountryCode").val(datas[0].COUNTRYCODE);
  240. $("#" + mId + "hddChoosePayer").val(datas[0].ChoosePayer);
  241. },
  242. error: function (result) {
  243. alert("Due to unexpected errors we were unable to load data");
  244. }
  245. };
  246. $.ajax(options);
  247. }
  248. function SetPayCurrency(pCountry) {
  249. var dataToSend = { MethodName: 'PCurrPcountry', pCountry: pCountry };
  250. var options = {
  251. url: '',
  252. data: dataToSend,
  253. dataType: 'JSON',
  254. type: 'POST',
  255. async: false,
  256. success:
  257. function (response) {
  258. var data = response;
  259. var ddl = GetElement(mId + "pCurrDdl");
  260. $(ddl).empty();
  261. var option;
  262. for (var i = 0; i < data.length; i++) {
  263. option = document.createElement("option");
  264. option.text = data[i].currencyCode;
  265. option.value = data[i].currencyCode;
  266. try {
  267. ddl.options.add(option);
  268. if (data[i].isDefault === "Y") {
  269. $("#" + mId + "pCurrDdl").val(data[i].currencyCode);
  270. }
  271. }
  272. catch (e) {
  273. alert(e);
  274. }
  275. }
  276. },
  277. error: function (result) {
  278. alert("Due to unexpected errors we were unable to load data");
  279. }
  280. };
  281. $.ajax(options);
  282. }
  283. function PAgentChange() {
  284. $("#" + mId + "branch").empty();
  285. var pAgent = $(mId + "pAgent").val();
  286. if (pAgent === null || pAgent === "" || pAgent === undefined)
  287. return;
  288. SetDDLValueSelected(mId + "pAgentDetail", pAgent);
  289. var pBankType = $("#" + mId + "pAgentDetail option:selected").text();
  290. var pCountry = $("#" + mId + "pCountry option:selected").val();
  291. var pMode = $("#" + mId + "pMode option:selected").val();
  292. var pModeTxt = $("#" + mId + "pMode option:selected").text();
  293. var dataToSend = { MethodName: "PAgentChange", pCountry: pCountry, pAgent: pAgent, pMode: pMode, pBankType: pBankType };
  294. var options =
  295. {
  296. url: 'SendV2.aspx?x=' + new Date().getTime(),
  297. data: dataToSend,
  298. dataType: 'JSON',
  299. type: 'POST',
  300. success: function (response) {
  301. ApplyAgentSetting(response, pModeTxt);
  302. if (pModeTxt === "CASH PAYMENT TO OTHER BANK")
  303. LoadAgentByExtAgent(pAgent);
  304. LoadCustomerRate();
  305. }
  306. };
  307. $.ajax(options);
  308. }
  309. function ClearReceiverData() {
  310. $('#receiverName').text('');
  311. $('#finalBenId').text('');
  312. SetDDLValueSelected(mId + "ddlReceiver", "");
  313. SetDDLValueSelected(mId + "ddlRecIdType", "");
  314. $("#" + mId + "txtRecFName").val("");
  315. $("#" + mId + "txtRecMName").val("");
  316. $("#" + mId + "txtRecLName").val("");
  317. $("#" + mId + "txtRecSLName").val("");
  318. $("#" + mId + "txtRecAdd1").val("");
  319. $("#" + mId + "txtRecAdd2").val("");
  320. $("#" + mId + "txtRecCity").val("");
  321. $("#" + mId + "txtRecMobile").val("");
  322. $("#" + mId + "txtRecTel").val("");
  323. SetDDLValueSelected(mId + "ddlRecIdType", "");
  324. $("#" + mId + "txtRecIdNo").val("");
  325. SetDDLValueSelected(mId + "ddlRecGender", "");
  326. $("#" + mId + "txtRecPostal").val("");
  327. $("#" + mId + "txtRecEmail").val("");
  328. $("#" + mId + "txtRecIdNo").removeClass('required');
  329. $("#" + mId + "txtRecIdNo_err").hide();
  330. }