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.

937 lines
33 KiB

4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
  1. 
  2. $(document).ready(function () {
  3. $("#branchRequired").hide();
  4. $(document).on("change", "#" + mId + "receiverMobileNumber", function () {
  5. var isValid = CheckForMobileNumber(this, "Mobile No.");
  6. if (isValid === false) {
  7. $(this).val('');
  8. $(this).focus();
  9. }
  10. });
  11. $("#searchCustomer").click(function () {
  12. ClearAllData();
  13. $('#step2SendRemittance').hide();
  14. $('#step2SendRemittanceAgreement').hide();
  15. $('#signatureDiv').hide();
  16. $('#step2SendRemittanceSaveButton').hide();
  17. var myDDL = GetElement("MainContent_ddlBenedeciary");
  18. $(myDDL).empty();
  19. var reqField = "senderIdNumber,";
  20. if (ValidRequiredFieldWithDoc(reqField) === false) {
  21. return false;
  22. }
  23. var customerIdNumber = $("#" + mId + "senderIdNumber").val();
  24. $("#searchStatement").attr("disabled", "disabled");
  25. var dataToSend = { MethodName: "loadCustomerDataSendPage", CustomerIdNumber: customerIdNumber };
  26. var options =
  27. {
  28. url: '',
  29. data: dataToSend,
  30. dataType: 'JSON',
  31. type: 'POST',
  32. success: function (response) {
  33. debugger
  34. $("#searchCustomer").removeAttr("disabled");
  35. if (response[0].errorCode === 0) {
  36. $('#step2SendRemittance').show();
  37. $('#step2SendRemittanceAgreement').show();
  38. $('#signatureDiv').show();
  39. $('#step2SendRemittanceSaveButton').show();
  40. $("#" + mId + "customerName").text(response[0].CUSTOMERNAME);
  41. $("#" + mId + "membershiId").text(response[0].MEMBERSHIPID);
  42. CustomerSignature();
  43. ParseDDlDynamic(response, 'ddlBenedeciary', 'FULLNAME', 'RECEIVERID', 'Select Beneficiary');
  44. }
  45. else {
  46. alert(response[0].Msg);
  47. $('#step2SendRemittance').hide();
  48. $('#step2SendRemittanceAgreement').hide();
  49. $('#signatureDiv').hide();
  50. $('#step2SendRemittanceSaveButton').hide();
  51. $("#" + mId + "senderIdNumber").val('');
  52. $("#" + mId + "senderIdNumber").focus();
  53. }
  54. }
  55. };
  56. $.ajax(options);
  57. });
  58. $("#MainContent_TransactionAgreement").click(function () {
  59. if ($("#MainContent_TransactionAgreement").is(":checked")) {
  60. $("#" + mId + "Save").removeAttr("disabled");
  61. } else {
  62. $("#" + mId + "Save").attr("disabled", "disabled");
  63. }
  64. });
  65. $("#" + mId + "ddlBenedeciary").on("change", function () {
  66. ClearAllData();
  67. var benefeciaryId = $("#" + mId + "ddlBenedeciary").val();
  68. if (benefeciaryId === null || benefeciaryId === '' || benefeciaryId === undefined) {
  69. return false;
  70. }
  71. var dataToSend = { MethodName: "getBenefeciaryDetails", BenefeciaryId: benefeciaryId };
  72. var options =
  73. {
  74. url: '',
  75. data: dataToSend,
  76. dataType: 'JSON',
  77. type: 'POST',
  78. success: function (response) {
  79. if (response[0].errorCode === 0) {
  80. $("#" + mId + "receiverFullName").val(response[0].fullName);
  81. $("#" + mId + "receiveraddress").val(response[0].address);
  82. $("#" + mId + "receiverMobileNumber").val(response[0].mobile);
  83. $("#" + mId + "purpose").val(response[0].address);
  84. $("#" + mId + "relationship").val(response[0].address);
  85. $("#" + mId + "accountNo").val(response[0].receiverAccountNo);
  86. if (response[0].relationship === '11339') {
  87. $("#" + mId + "otherRelationshipTextBox").val(response[0].relationOther);
  88. $('#otherRelationDiv').show();
  89. }
  90. if (response[0].purposeOfRemit === '11347') {
  91. $('#purposeOtherDiv').show();
  92. $("#" + mId + "purposeOther").val(response[0].purposeOther);
  93. }
  94. if ($.isNumeric(response[0].purposeOfRemit)) {
  95. SetDDLValueSelected(mId + "purpose", response[0].purposeOfRemit);
  96. } else {
  97. SetDDLTextSelected(mId + "purpose", response[0].purposeOfRemit);
  98. }
  99. if ($.isNumeric(response[0].relationship)) {
  100. SetDDLValueSelected(mId + "relationship", response[0].relationship);
  101. } else {
  102. SetDDLTextSelected(mId + "relationship", response[0].relationship);
  103. }
  104. SetDDLTextSelected(mId + "pCountry", response[0].country);
  105. PcountryOnChange('c', response[0].paymentMethod.toUpperCase(), response[0].bankId);
  106. if (response[0].branchDetails) {
  107. if (response[0].manualType === 'Y') {
  108. $("#" + mId + "branch_manual").val(response[0].branchDetails);
  109. }
  110. else {
  111. var dataSelectDDL = {
  112. id: response[0].branchDetails.split('|')[0],
  113. text: response[0].branchDetails.split('|')[1]
  114. };
  115. if (dataSelectDDL.id !== 'N/A') {
  116. var newOption = new Option(dataSelectDDL.text, dataSelectDDL.id, false, false);
  117. $('.js-example-basic-single').append(newOption).trigger('change');
  118. $('.js-example-basic-single').val(dataSelectDDL.id); // Select the option with a value of '1'
  119. $('.js-example-basic-single').trigger('change');
  120. }
  121. }
  122. }
  123. ShowHideAccountNo();
  124. }
  125. else {
  126. alert(response[0].Msg);
  127. }
  128. }
  129. };
  130. $.ajax(options);
  131. });
  132. $("#" + mId + "purpose").on("change", function () {
  133. let purposeValue = $("#" + mId + "purpose option:selected").val();
  134. if (purposeValue === '11347') {
  135. $("#purposeOtherDiv").show();
  136. } else {
  137. $("#purposeOtherDiv").hide();
  138. }
  139. });
  140. $("#" + mId + "relationship").on("change", function () {
  141. let relationValue = $("#" + mId + "relationship option:selected").val();
  142. if (relationValue === '11339') {
  143. $("#otherRelationDiv").show();
  144. } else {
  145. $("#otherRelationDiv").hide();
  146. }
  147. });
  148. $("#accountDiv").hide();
  149. $("#" + mId + "pCountry").on("change", function () {
  150. ResetAmountFields();
  151. $("#" + mId + "branch").empty();
  152. $("#" + mId + "pMode").empty();
  153. $("#" + mId + "pAgent").empty();
  154. $('.same').hide();
  155. $("#" + mId + "branch").removeClass('required');
  156. $("#tdLblBranch").hide();
  157. $("#tdTxtBranch").hide();
  158. $('#txtpBranch_aText').attr("class", "disabled form-control");
  159. $("#txtpBranch_err").hide();
  160. $("#txtpBranch_aValue").val('');
  161. $("#txtpBranch_aText").val('');
  162. $("#" + mId + "txtRecDepAcNo").val('');
  163. $("#" + mId + "lblExCurr").text('');
  164. $("#" + mId + "lblPayCurr").text('');
  165. $("#" + mId + "lblPerTxnLimit").text('0.00');
  166. if ($("#" + mId + "pCountry option:selected ").val() !== "") {
  167. PcountryOnChange('c', "");
  168. }
  169. var pmode = $("#" + mId + "pMode").val();
  170. var partnerId = $("#" + mId + "hddPayoutPartner").val();
  171. if (partnerId === '394130' || pmode === "2") {
  172. $("#" + mId + "branch").addClass('required');
  173. $('.same').show();
  174. }
  175. });
  176. $("#" + mId + "pMode").on("change", function () {
  177. $("#" + mId + "branch").empty();
  178. ClearCalculatedAmount();
  179. $('.displayPayerInfo').hide();
  180. $("#" + mId + "txtRecDepAcNo").val('');
  181. $("#tdLblBranch").hide();
  182. $("#tdTxtBranch").hide();
  183. $('#txtpBranch_aText').attr("class", "disabled form-control");
  184. $("#txtpBranch_err").hide();
  185. $("#txtpBranch_aValue").val('');
  186. $("#txtpBranch_aText").val('');
  187. ReceivingModeOnChange("", "");
  188. GetPayoutPartner();
  189. var pmode = $("#" + mId + "pMode").val();
  190. var partnerId = $("#" + mId + "hddPayoutPartner").val();
  191. if (partnerId === '394130' || pmode === "2") {
  192. $("#" + mId + "branch").addClass('required');
  193. //if ((partnerId === apiPartnerIds[0]) && pmode === "2") {
  194. // $('#agentBranchRequired').hide();
  195. // $("#" + mId + "branch").removeClass('required');
  196. //}
  197. $('.same').show();
  198. //if ((partnerId === apiPartnerIds[0]) && pmode === "2") {
  199. // LoadPayerData();
  200. //}
  201. }
  202. });
  203. $("#" + mId + "pAgent").on("change", function () {
  204. var bankId = $("#" + mId + "pAgent option:selected").val();
  205. if (bankId === "" || bankId === null) {
  206. return;
  207. }
  208. var pmode = $("#" + mId + "pMode").val();
  209. var partnerId = $("#" + mId + "hddPayoutPartner").val();
  210. //$('.same').hide();
  211. $("#" + mId + "branch").removeClass('required');
  212. $('.displayPayerInfo').hide();
  213. PopulateBranch();
  214. });
  215. $(document).on('blur', '#' + mId + 'txtCollAmt', function () {
  216. CollAmtOnChange();
  217. });
  218. $("#" + mId + "pMode").on('change', function () {
  219. ShowHideAccountNo();
  220. });
  221. });
  222. function ShowHideAccountNo() {
  223. var pmode = $("#" + mId + "pMode").val();
  224. if (pmode === "2") {
  225. $("#accountDiv").show();
  226. } else {
  227. $("#accountDiv").hide();
  228. }
  229. }
  230. function ResetAmountFields() {
  231. //Reset Fields
  232. $("#" + mId + "txtPayAmt").val('');
  233. $("#" + mId + "txtPayAmt").attr("readonly", false);
  234. $("#" + mId + "lblSendAmt").val('0.00');
  235. $("#" + mId + "lblServiceChargeAmt").val('0');
  236. $("#" + mId + "lblExRate").text('0.00');
  237. $("#lblDiscAmt").text('0.00');
  238. $("#" + mId + "lblPayCurr").text('');
  239. //GetElement("spnSchemeOffer").innerHTML = "";
  240. //GetElement("spnWarningMsg").innerHTML = "";
  241. }
  242. function PcountryOnChange(obj, pmode, pAgentSelected = "") {
  243. var pCountry = $("#" + mId + "pCountry").val();
  244. if (pCountry === "" || pCountry === null)
  245. return;
  246. var method = "";
  247. if (obj === 'c') {
  248. method = "PaymentModePcountry";
  249. }
  250. if (obj === 'pcurr') {
  251. method = "PCurrPcountry";
  252. }
  253. var country = $("#" + mId + "pCountry option:selected ").text();
  254. if (country.toUpperCase() === 'NEPAL' || country.toUpperCase() === 'VIETNAM') {
  255. $('#branchSelect').hide();
  256. $('#branchManual').show();
  257. }
  258. else {
  259. $('#branchSelect').show();
  260. $('#branchManual').hide();
  261. }
  262. var dataToSend = { MethodName: method, pCountry: pCountry };
  263. var options =
  264. {
  265. url: '',
  266. data: dataToSend,
  267. dataType: 'JSON',
  268. type: 'POST',
  269. async: false,
  270. success: function (response) {
  271. if (obj === 'c') {
  272. LoadPayMode(response, document.getElementById(mId + "pMode"), 'pcurr', "", pmode);
  273. ReceivingModeOnChange("", pAgentSelected);
  274. GetPayoutPartner(response[0].serviceTypeId);
  275. }
  276. else if (obj === 'pcurr') {
  277. if (response === "")
  278. return false;
  279. $("#" + mId + "lblPayCurr").text(response[0].currencyCode);
  280. $("#" + mId + "lblExCurr").text(response[0].currencyCode);
  281. return true;
  282. }
  283. return true;
  284. },
  285. error: function (result) {
  286. alert("Due to unexpected errors we were unable to load data");
  287. }
  288. };
  289. $.ajax(options);
  290. }
  291. function LoadLocationDDL(response) {
  292. var data = response;
  293. var ddl = GetElement(mId + "locationDDL");
  294. $(ddl).empty();
  295. $("#" + mId + "subLocationDDL").empty();
  296. var option;
  297. option = document.createElement("option");
  298. for (var i = 0; i < data.length; i++) {
  299. option = document.createElement("option");
  300. if (data[i].LOCATIONNAME === 'Any State') {
  301. $('#subLocation').hide();
  302. }
  303. option.text = data[i].LOCATIONNAME;
  304. option.value = data[i].LOCATIONID;
  305. if ($("#" + mId + "hddLocation").val()) {
  306. if (option.value === $("#" + mId + "hddLocation").val()) {
  307. option.selected = true;
  308. }
  309. }
  310. try {
  311. ddl.options.add(option);
  312. }
  313. catch (e) {
  314. alert(e);
  315. }
  316. }
  317. if ($("#" + mId + "hddSubLocation").val()) {
  318. LoadSublocation();
  319. }
  320. }
  321. function LoadPayMode(response, myDDL, recall, selectField, obj) {
  322. var data = response;
  323. //CheckSession(data);
  324. $(myDDL).empty();
  325. var option;
  326. if (selectField !== "" && selectField !== undefined) {
  327. option = document.createElement("option");
  328. option.text = selectField;
  329. option.value = "";
  330. myDDL.options.add(option);
  331. }
  332. for (var i = 0; i < data.length; i++) {
  333. option = document.createElement("option");
  334. option.text = data[i].typeTitle;
  335. option.value = data[i].serviceTypeId;
  336. try {
  337. myDDL.options.add(option);
  338. }
  339. catch (e) {
  340. alert(e);
  341. }
  342. }
  343. if (recall === 'pcurr') {
  344. SetDDLTextSelected(mId + "pMode", obj);
  345. }
  346. }
  347. function ReceivingModeOnChange(pModeSelected, pAgentSelected) {
  348. ResetAmountFields();
  349. $("#" + mId + "pAgent").empty();
  350. PaymentModeChange(pModeSelected, pAgentSelected);
  351. }
  352. function PaymentModeChange(pModeSelected, pAgentSelected) {
  353. var pMode = "";
  354. if (pModeSelected === "" || pModeSelected === null)
  355. pMode = $("#" + mId + "pMode option:selected").text();
  356. else {
  357. pMode = pModeSelected;
  358. }
  359. pCountry = GetValue(mId + "pCountry");
  360. $('#trAccno').hide();
  361. $("#" + mId + "txtRecDepAcNo").attr("class", "form-control");
  362. $('#trForCPOB').hide();
  363. //GetElement(mId + "paymentThrough").className = "";
  364. if (pMode === "BANK DEPOSIT") {
  365. $('#trAccno').show();
  366. $("#" + mId + "txtRecDepAcNo").attr("class", "required form-control");
  367. $('#trAccno').show();
  368. }
  369. var dataToSend = { MethodName: "loadAgentBank", pMode: pMode, pCountry: pCountry };
  370. var options =
  371. {
  372. url: '',
  373. data: dataToSend,
  374. dataType: 'JSON',
  375. type: 'POST',
  376. async: false,
  377. success: function (response) {
  378. //LoadAgentSetting();
  379. ParseLoadDDl(response, GetElement(mId + "pAgent"), 'agentSelection', "");
  380. if (pAgentSelected !== "" && pAgentSelected !== null && pAgentSelected !== undefined) {
  381. SetDDLValueSelected(mId + "pAgent", pAgentSelected);
  382. }
  383. var agentId = $("#" + mId + "pAgent").val();
  384. if (agentId !== "" && agentId !== null && agentId !== undefined) {
  385. var payMode = $("#" + mId + "pMode").val();
  386. $('.same').show();
  387. }
  388. }
  389. };
  390. $.ajax(options);
  391. }
  392. function ParseLoadDDl(response, myDDL, recall, selectField) {
  393. var data = response;
  394. //CheckSession(data);
  395. var ddl2 = GetElement(mId + "pAgentDetail");
  396. var ddl3 = GetElement(mId + "pAgentMaxPayoutLimit");
  397. $(ddl2).empty();
  398. $(ddl3).empty();
  399. $(myDDL).empty();
  400. //GetElement("spnPayoutLimitInfo").innerHTML = "";
  401. if ($("#" + mId + "pMode option:selected").val() !== "" && recall === "agentSelection") {
  402. $('#hdnreqAgent').text(data[0].agentSelection);
  403. }
  404. var option;
  405. if (selectField !== "" && selectField !== undefined) {
  406. option = document.createElement("option");
  407. option.text = selectField;
  408. option.value = "";
  409. myDDL.options.add(option);
  410. }
  411. for (var i = 0; i < data.length; i++) {
  412. option = document.createElement("option");
  413. option.text = data[i].AGENTNAME.toUpperCase();
  414. option.value = data[i].bankId;
  415. var option2 = document.createElement("option");
  416. option2.value = data[i].bankId;
  417. option2.text = data[i].FLAG;
  418. var option3 = document.createElement("option");
  419. option3.value = data[i].bankId;
  420. option3.text = data[i].maxPayoutLimit;
  421. try {
  422. myDDL.options.add(option);
  423. ddl2.options.add(option2);
  424. ddl3.options.add(option3);
  425. }
  426. catch (e) {
  427. alert(e);
  428. }
  429. }
  430. if (data[0].AGENTNAME === "[SELECT BANK]") {
  431. $('#pAgent_err').show();
  432. GetElement("pAgent_err").innerHTML = "*";
  433. GetElement(mId + "pAgent").className = "required form-control";
  434. }
  435. else {
  436. $('#pAgent_err').hide();
  437. GetElement("pAgent_err").innerHTML = "";
  438. GetElement(mId + "pAgent").className = "form-control";
  439. }
  440. var pCountry = $("#" + mId + "pCountry option:selected").text();
  441. var pCurr = $("#" + mId + "lblPayCurr").text();
  442. }
  443. function ClearCalculatedAmount() {
  444. $("#" + mId + "txtCollAmt").val('');
  445. $("#" + mId + "lblSendAmt").val(0);
  446. $("#" + mId + "lblServiceChargeAmt").val(0);
  447. $("#" + mId + "lblExRate").val(0);
  448. $("#" + mId + "txtPayAmt").val('');
  449. $("#" + mId + "customerRateFields").hide();
  450. }
  451. function GetPayoutPartner(payMode) {
  452. var pCountry = $("#" + mId + "pCountry").val();
  453. var pMode = $("#" + mId + "pMode").val();
  454. var dataToSend = { MethodName: 'getPayoutPartner', PCountry: pCountry, PMode: pMode };
  455. var options = {
  456. url: '',
  457. data: dataToSend,
  458. dataType: 'JSON',
  459. type: 'POST',
  460. async: false,
  461. success:
  462. function (response) {
  463. var datas = response;
  464. var agentId = "";
  465. if (datas.length > 0) {
  466. agentId = datas[0].agentId;
  467. }
  468. $("#" + mId + "hddPayoutPartner").val(agentId);
  469. },
  470. error: function (result) {
  471. alert("Due to unexpected errors we were unable to load data");
  472. }
  473. };
  474. $.ajax(options);
  475. }
  476. function SetDDLTextSelected(ddl, selectText) {
  477. $("#" + ddl + " option").each(function () {
  478. if ($(this).text() === $.trim(selectText)) {
  479. $(this).prop('selected', true);
  480. return;
  481. }
  482. });
  483. }
  484. function PopulateBranch() {
  485. var dataToSend = {
  486. MethodName: 'PopulateBranch',
  487. payoutPartner: $('#' + mId + 'hddPayoutPartner').val(),
  488. Bank: $('#' + mId + 'pAgent').val(),
  489. Country: $('#' + mId + 'pCountry').val(),
  490. PayMode: $('#' + mId + 'pMode').val(),
  491. };
  492. var options = {
  493. url: '',
  494. data: dataToSend,
  495. dataType: 'JSON',
  496. type: 'POST',
  497. async: false,
  498. success:
  499. function (response) {
  500. ParseBranchDDl(response, GetElement(mId + "branch"), '', "");
  501. },
  502. error: function (result) {
  503. alert("Due to unexpected errors we were unable to load data");
  504. }
  505. };
  506. $.ajax(options);
  507. }
  508. function ParseBranchDDl(response, myDDL, recall, selectField) {
  509. var data = response;
  510. //CheckSession(data);
  511. $(myDDL).empty();
  512. var option;
  513. if (selectField !== "" && selectField !== undefined) {
  514. option = document.createElement("option");
  515. option.text = selectField;
  516. option.value = "";
  517. myDDL.options.add(option);
  518. }
  519. for (var i = 0; i < data.length; i++) {
  520. option = document.createElement("option");
  521. option.text = data[i].agentName.toUpperCase();
  522. option.value = data[i].agentId;
  523. try {
  524. myDDL.options.add(option);
  525. }
  526. catch (e) {
  527. alert(e);
  528. }
  529. }
  530. }
  531. function CollAmtOnChange() {
  532. var collAmt = $("#" + mId + "txtCollAmt").val();
  533. if (collAmt === "")
  534. collAmt = "0";
  535. var collAmtFormatted = CurrencyFormatted(collAmt); //collAmt;
  536. collAmtFormatted = CommaFormatted(collAmtFormatted);
  537. var collCurr = $("#" + mId + "lblPerTxnLimitCurr").text();
  538. if (collAmt === "0") {
  539. ClearCalculatedAmount();
  540. return;
  541. }
  542. checkdata(collAmt, 'cAmt');
  543. }
  544. function CurrencyFormatted(amount) {
  545. var i = parseFloat(amount);
  546. if (isNaN(i)) { i = 0.00; }
  547. var minus = '';
  548. if (i < 0) { minus = '-'; }
  549. i = Math.abs(i);
  550. i = parseInt((i + .005) * 100);
  551. i = i / 100;
  552. s = new String(i);
  553. if (s.indexOf('.') < 0) { s += '.00'; }
  554. if (s.indexOf('.') == (s.length - 2)) { s += '0'; }
  555. //s = minus + s;
  556. //if (amount < 0)
  557. // s = -1 * amount;
  558. return CommaFormatted(s, amount);
  559. }
  560. function CommaFormatted(amount, amountMain) {
  561. var delimiter = ",";
  562. var a = amount.split('.', 2);
  563. var d = a[1];
  564. var i = parseInt(a[0]);
  565. if (isNaN(i)) { return ''; }
  566. var minus = '';
  567. if (i < 0) { minus = '-'; }
  568. i = Math.abs(i);
  569. var n = new String(i);
  570. var a = [];
  571. while (n.length > 3) {
  572. var nn = n.substr(n.length - 3);
  573. a.unshift(nn);
  574. n = n.substr(0, n.length - 3);
  575. }
  576. if (n.length > 0) { a.unshift(n); }
  577. n = a.join(delimiter);
  578. if (d.length < 1) { amount = n; }
  579. else { amount = n + '.' + d; }
  580. amount = minus + amount;
  581. if (amountMain > 0)
  582. return "(" + amount + ")";
  583. else
  584. return amount;
  585. }
  586. function checkdata(amt, obj) {
  587. if (amt > 0)
  588. CalculateTxn(amt, obj);
  589. else
  590. ClearCalculatedAmount();
  591. }
  592. function CalculateTxn(amt, obj, isManualSc) {
  593. var collAmt = parseFloat($("#" + mId + "txtCollAmt").val().replace(',', '').replace(',', '').replace(',', ''));
  594. var customerId = $("#" + mId + "txtSearchData_aValue").val();
  595. if (isManualSc === '' || isManualSc === undefined) {
  596. isManualSc = 'N';
  597. }
  598. if (isManualSc === 'N') {
  599. if (obj === '' || obj === null) {
  600. if (document.getElementById(mId + "txtPayAmt").disabled) {
  601. obj = 'cAmt';
  602. amt = GetValue(mId + "txtCollAmt");
  603. }
  604. else {
  605. obj = 'pAmt';
  606. amt = GetValue(mId + "txtPayAmt");
  607. }
  608. }
  609. }
  610. else {
  611. obj = $("#" + mId + "hddCalcBy").val();
  612. if (obj === 'cAmt') {
  613. amt = GetValue(mId + "txtCollAmt");
  614. }
  615. else {
  616. amt = GetValue(mId + "txtPayAmt");
  617. }
  618. }
  619. var pCountry = GetValue(mId + "pCountry");
  620. var pCountrytxt = $("#" + mId + "pCountry option:selected").text();
  621. var pMode = GetValue(mId + "pMode");
  622. var pModetxt = $("#" + mId + "pMode option:selected").text();
  623. if (pCountry === "" || pCountry === null || pCountry === undefined) {
  624. alert("Please choose payout country");
  625. GetElement(mId + "pCountry").focus();
  626. return false;
  627. }
  628. if (pMode === "" || pMode === null || pMode === undefined) {
  629. alert("Please choose payment mode");
  630. GetElement(mId + "pMode").focus();
  631. return false;
  632. }
  633. var sAgent = $("#" + mId + "sendingAgentOnBehalfDDL option:selected").val();
  634. var pAgent = Number(GetValue(mId + "pAgent"));
  635. var pAgentBranch = GetValue("txtpBranch_aValue");
  636. if (pModetxt === "CASH PAYMENT TO OTHER BANK") {
  637. pAgent = Number($("#" + mId + "paymentThrough option:selected").val());
  638. pAgentBranch = "";
  639. if (pAgent === "" || pAgent === undefined)
  640. pAgent = "";
  641. }
  642. collAmt = GetValue(mId + "txtCollAmt");
  643. var txtCustomerLimit = GetValue("txtCustomerLimit");
  644. var txnPerDayCustomerLimit = GetValue(mId + "txnPerDayCustomerLimit");
  645. var schemeCode = GetValue(mId + "ddlScheme");
  646. if (obj === "cAmt") {
  647. collAmt = amt;
  648. payAmt = 0;
  649. }
  650. if (obj === "pAmt") {
  651. payAmt = amt;
  652. collAmt = 0;
  653. }
  654. var payCurr = $("#" + mId + "pCurrDdl").val();
  655. var collCurr = $("#" + mId + "lblPerTxnLimitCurr").text();
  656. var senderId = $('#finalSenderId').text();
  657. var couponId = $("#" + mId + "iTelCouponId").val();
  658. var sc = $("#" + mId + "lblServiceChargeAmt").val();
  659. if (pCountry === "203" && payCurr === "USD") {
  660. if ((pMode === "1" && pAgent !== 2091) || (pMode !== "12" && pAgent !== 2091)) {
  661. alert('USD receiving is only allow for Door to Door');
  662. ClearCalculatedAmount();
  663. return false;
  664. }
  665. }
  666. var collectAmount = Number($("#" + mId + "txtCollAmt").val());
  667. var payoutAmount = Number($("#" + mId + "txtPayAmt").val());
  668. var payoutPartner = $("#" + mId + "hddPayoutPartner").val();
  669. var IsExrateFromPartner = $("#" + mId + "hddFetchExrateFromPartner").val();
  670. var PCountryCode = $("#" + mId + "hddPCountryCode").val();
  671. if (collectAmount <= 0 && payoutAmount <= 0) {
  672. return;
  673. }
  674. $("#" + mId + "hddCalcBy").val(obj);
  675. var dataToSend = {
  676. MethodName: 'CalculateTxn', pCountry: pCountry, pCountrytxt: pCountrytxt, pMode: pMode, pAgent: pAgent
  677. , pAgentBranch: pAgentBranch, collAmt: collAmt, payAmt: payAmt, payCurr: payCurr, collCurr: collCurr
  678. , pModetxt: pModetxt, senderId: senderId, schemeCode: schemeCode, couponId: couponId, isManualSc: isManualSc
  679. , sc: sc, payoutPartner: payoutPartner, IsExrateFromPartner: IsExrateFromPartner, PCountryCode: PCountryCode
  680. };
  681. var options =
  682. {
  683. url: '',
  684. data: dataToSend,
  685. dataType: 'JSON',
  686. type: 'POST',
  687. async: false,
  688. success: function (response) {
  689. ParseCalculateData(response, obj);
  690. }
  691. };
  692. $.ajax(options);
  693. $("#DivLoad").hide();
  694. return true;
  695. }
  696. function ParseCalculateData(response, amtType) {
  697. var data = response;
  698. if (data[0].ErrCode === '1') {
  699. alert(data[0].Msg);
  700. ClearCalculatedAmount();
  701. return;
  702. }
  703. $("#" + mId + "lblSendAmt").val(parseFloat(Number(data[0].sAmt).toFixed(3))); //
  704. $("#" + mId + "hddTamt").val(parseFloat(Number(data[0].sAmt).toFixed(3))); //
  705. $("#" + mId + "lblExRate").text(roundNumber(data[0].exRate, 8));
  706. $("#" + mId + "lblPayCurr").text(data[0].pCurr);
  707. $("#" + mId + "lblExCurr").text(data[0].pCurr);
  708. if ($("#" + mId + "allowEditSC").val() === 'Y') {
  709. $("#" + mId + "editServiceCharge").attr("disabled", false);
  710. }
  711. $("#" + mId + "lblPerTxnLimit").text(data[0].limit);
  712. $("#" + mId + "lblPerTxnLimitCurr").text(data[0].limitCurr);
  713. if (!$("#" + mId + "editServiceCharge").is(':checked')) {
  714. $("#" + mId + "lblServiceChargeAmt").attr('disabled', 'disabled');
  715. }
  716. $("#" + mId + "lblServiceChargeAmt").val(parseFloat(data[0].scCharge).toFixed(0));
  717. $("#" + mId + "hddServiceCharge").val(parseFloat(data[0].scCharge).toFixed(0));
  718. SetValueById(mId + "txtCollAmt", parseFloat(Number(data[0].collAmt).toFixed(3)), ""); //
  719. SetValueById(mId + "lblSendAmt", parseFloat(Number(data[0].sAmt).toFixed(3)), ""); //
  720. $("#" + mId + "hddTPExRate").val(data[0].tpExRate);
  721. var exRateOffer = data[0].exRateOffer;
  722. var scOffer = data[0].scOffer;
  723. var scDiscount = data[0].scDiscount;
  724. var collectionAmount = Number($("#" + mId + "txtCollAmt").val());
  725. if (collectionAmount > 0) {
  726. $("#" + mId + "customerRateFields").show();
  727. }
  728. }
  729. function roundNumber(rnum, rlength) { // Arguments: number to round, number of decimal places
  730. var newnumber = Math.round(rnum * Math.pow(10, rlength)) / Math.pow(10, rlength);
  731. return parseFloat(newnumber); // Output the result to the form field (change for your purposes)
  732. }
  733. function ValidateDetailsMain() {
  734. var isFormDataValid = ValidateDetails();
  735. if (isFormDataValid === true) {
  736. return CheckSignatureCustomerFromCustomerRegister();
  737. }
  738. else {
  739. return false;
  740. }
  741. }
  742. function ValidateDetails() {
  743. var reqField = "senderIdNumber,receiverFullName,receiveraddress,receiverMobileNumber,pCountry,pMode,txtCollAmt,purpose,relationship,";
  744. //var pmodeId = $("#" + mId + "pMode").val();
  745. //if (pmodeId != "1" && pmodeId != undefined) {
  746. // reqField += "branch,";
  747. // $("#branchRequired").show();
  748. //} else {
  749. // $("#" + mId + "branch").removeClass("required");
  750. // $("#" + mId + "branch").css('background-color', '#FFFFFF');
  751. // $("#branchRequired").hide();
  752. //}
  753. let purposeValue = $("#" + mId + "purpose option:selected").val();
  754. if (purposeValue == '11347') {
  755. reqField += "purposeOther,";
  756. }
  757. let relationValue = $("#" + mId + "relationship option:selected").val();
  758. if (relationValue == '11339') {
  759. reqField += "otherRelationshipTextBox,";
  760. }
  761. if (ValidRequiredFieldWithDoc(reqField) === false) {
  762. return false;
  763. } else {
  764. debugger
  765. var pMode = $("#" + mId + "pMode").val();
  766. var pAgent = $("#" + mId + "pAgent").val();
  767. var pbranch = $("#" + mId + "branch").val();
  768. if (pMode == "2") {
  769. if (pAgent == '' || pAgent == undefined || pAgent == null) {
  770. $("#" + mId + "pAgent").css('background-color', '#FFCCD2');
  771. swal('Required Field(s)\n _____________________________ \n The red fields are required!');
  772. return false
  773. }
  774. }
  775. debugger
  776. $("#" + mId + "hddPmode").val(pMode);
  777. $("#" + mId + "hddPagent").val(pAgent);
  778. $("#" + mId + "hddpBranch").val(pbranch);
  779. return true;
  780. }
  781. }
  782. function SetMessageBox(msg, errorCode) {
  783. alert(msg);
  784. }
  785. function VerifyDetails() {
  786. var dataToSend = {
  787. Methodname: 'ValidateDetails'
  788. , membershipId: $("#" + mId + "senderIdNumber").val()
  789. , receiverName: $("#" + mId + "receiverFullName").val()
  790. }
  791. $.post('', dataToSend, function (response) {
  792. var data = JSON.parse(response);
  793. if (data[0].ERROR_CODE == '0') {
  794. var pMode = $("#" + mId + "pMode").val();
  795. var pgent = $("#" + mId + "pAgent").val();
  796. var pbranch = $("#" + mId + "branch").val();
  797. $("#" + mId + "hddPmode").val(pMode);
  798. $("#" + mId + "hddPagent").val(pgent);
  799. $("#" + mId + "hddpBranch").val(pbranch);
  800. return true;
  801. } else {
  802. alert(data[0].Msg);
  803. return false;
  804. }
  805. }).fail(function (response) {
  806. return false;
  807. });
  808. }
  809. function SetDDLValueSelected(ddl, selectText) {
  810. $("#" + ddl + " option").each(function () {
  811. if ($(this).val() === $.trim(selectText)) {
  812. $(this).prop('selected', true);
  813. return;
  814. }
  815. });
  816. }
  817. function ClearAllData() {
  818. $("#" + mId + "receiverFullName").val('');
  819. $("#" + mId + "receiveraddress").val('');
  820. $("#" + mId + "receiverMobileNumber").val('');
  821. $("#" + mId + "purpose").val('');
  822. $("#" + mId + "relationship").val('');
  823. $("#" + mId + "purposeOther").val('');
  824. $("#" + mId + "otherRelationshipTextBox").val('');
  825. $('#otherRelationDiv').hide();
  826. $('#purposeOtherDiv').hide();
  827. $("#" + mId + "purpose").val('');
  828. $("#" + mId + "relationship").val('');
  829. $("#" + mId + "pCountry").val('');
  830. $("#" + mId + "pAgent").empty();
  831. $("#" + mId + "branch").empty();
  832. SetDDLTextSelected(mId + "pCountry", '');
  833. ClearCalculatedAmount();
  834. }
  835. function CheckForMobileNumber(nField, fieldName) {
  836. var numberPattern = /^[+]?[0-9]{6,16}$/;
  837. test = numberPattern.test(nField.value);
  838. if (!test) {
  839. alert(fieldName + " Is Not Valid !");
  840. nField.value = "";
  841. return false
  842. }
  843. return true;
  844. }