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.

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