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.

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