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.

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