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.

724 lines
24 KiB

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