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.

453 lines
16 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
  1. $(document).ready(function () {
  2. var a = $("#" + mId + "hideSearchDivVal").val();
  3. $("#" + mId + "register").prop("disabled", true);
  4. $("#" + mId + "otherRelationDiv").hide();
  5. $("#divOccupation").hide();
  6. //divOccupation
  7. if (a == "true") {
  8. $("#" + mId + "hideSearchDivVal").hide();
  9. $(".main-nav").hide();
  10. }
  11. $("#" + mId + "recDdlPurposeOfRemitance").on("change", function () {
  12. debugger
  13. let purposeValue = $("#" + mId + "recDdlPurposeOfRemitance option:selected").val();
  14. if (purposeValue == '11347') {
  15. $("#purposeOtherDiv").show();
  16. } else {
  17. $("#purposeOtherDiv").hide();
  18. }
  19. });
  20. $("#" + mId + "register").click(function () {
  21. debugger
  22. var isFormDataValid = CheckFormValidation();
  23. if (isFormDataValid === 'true') {
  24. var customerSignature = CheckSignatureCustomerFromCustomerRegister();
  25. if (customerSignature === 'true') {
  26. save();
  27. }
  28. else {
  29. return false;
  30. }
  31. }
  32. else {
  33. return false;
  34. }
  35. });
  36. $(document).on("change", "#" + mId + "recDdlIdType", function () {
  37. $("#" + mId + "recrecTxtIdValue").val("");
  38. idTypeVal = $(this).val();
  39. if (idTypeVal !== null && idTypeVal !== "" && idTypeVal !== "0") {
  40. $("#" + mId + "recTxtIdValue").removeAttr("disabled");
  41. $("#" + mId + "idNumberErr").show();
  42. }
  43. else {
  44. $("#" + mId + "recTxtIdValue").attr("disabled", "disabled");
  45. $("#" + mId + "idNumberErr").hide();
  46. $("#" + mId + "recDdlIdType").removeAttr("style");
  47. $("#" + mId + "recTxtIdValue").removeAttr("style");
  48. }
  49. });
  50. $(document).on("change", "#" + mId + "recDdlPayoutPatner", function () {
  51. var bankId = $("#" + mId + "recDdlPayoutPatner option:selected").val();
  52. var countryId = $("#" + mId + "recDdlCountry option:selected").val();
  53. var pMode = $("#" + mId + "recDdlPaymentMode option:selected").val();
  54. var data = { MethodName: "GetBankBranch", bankId: bankId, countryId: countryId, pMode: pMode, branchId: null };
  55. $.post("", data, function (response) {
  56. PopulateBranchDDL(response, "MainContent_recDDLBankBranch", "Select Branch");
  57. });
  58. });
  59. hideShowMenuBar();
  60. });
  61. function CheckForMobileNumber(nField, fieldName) {
  62. var numberPattern = /^[+]?[0-9]{6,16}$/;
  63. test = numberPattern.test(nField.value);
  64. if (!test) {
  65. alert(fieldName + " Is Not Valid !");
  66. nField.value = "";
  67. return false
  68. }
  69. return true;
  70. }
  71. function CheckForPhoneNumber(nField, fieldName) {
  72. var numberPattern = /^[+]?[0-9]{6,15}$/;
  73. test = numberPattern.test(nField.value);
  74. if (!test) {
  75. alert(fieldName + " Is Not Valid !");
  76. nField.value = "";
  77. return false
  78. }
  79. return true;
  80. }
  81. function hideShowMenuBar() {
  82. var addType = "GetReceiverAddType()";
  83. if (addType === "s") {
  84. $(".navbar.navbar-inverse.yamm.navbar-fixed-top.main-nav").hide();
  85. $(".listtabs").hide()
  86. }
  87. }
  88. function PopulatePaymentMethod() {
  89. var data =
  90. {
  91. MethodName: "PopulatePaymentMode",
  92. country: $("#" + mId + "recDdlCountry option:selected").text()
  93. };
  94. $.ajax({
  95. url: "",
  96. type: "post",
  97. data: data,
  98. dataType: "json",
  99. async: false,
  100. success: function (response) {
  101. PopulaterecDdl(response, "" + mId + "recDdlPaymentMode", "", "", "");
  102. },
  103. error: function (error) {
  104. alert("Something went wrong!!!")
  105. }
  106. })
  107. }
  108. function PopulatePayoutPartner() {
  109. $("#" + mId + "recDdlPayoutPatner").empty();
  110. $("#" + mId + "recDDlBankBranch").empty();
  111. var pmode = $("#" + mId + "recDdlPaymentMode option:selected").val();
  112. if (pmode == "2") {
  113. $("#" + mId + "receiverAccountNo").show();
  114. }
  115. else {
  116. $("#" + mId + "receiverAccountNo").hide();
  117. $("#" + mId + "recDDlBankBranch").val("");
  118. }
  119. var data =
  120. {
  121. MethodName: "PopulatePayoutPartner",
  122. country: $("#" + mId + "recDdlCountry option:selected").val(),
  123. paymentMode: $("#" + mId + "recDdlPaymentMode option:selected").text()
  124. };
  125. $.post("", data, function (response) {
  126. PopulaterecDdl(response, "" + mId + "recDdlPayoutPatner", "", "", "");
  127. }).fail(function (error) {
  128. alert("Something went wrong!!!");
  129. });
  130. }
  131. function PopulateBranchDDL(populateData, recDdlId, defaultText) {
  132. var myrecDdl = document.getElementById(recDdlId);
  133. $(myrecDdl).empty();
  134. var option;
  135. if (defaultText != "") {
  136. option = document.createElement("option");
  137. option.text = defaultText;
  138. option.value = "";
  139. myrecDdl.options.add(option);
  140. }
  141. for (var i = 0; i < populateData.length; i++) {
  142. option = document.createElement("option");
  143. option.text = populateData[i].agentName;
  144. option.value = populateData[i].agentId;
  145. try {
  146. myrecDdl.options.add(option);
  147. } catch (e) {
  148. alert(e.message);
  149. }
  150. }
  151. }
  152. function PopulaterecDdl(populateData, recDdlId, selectedId, selectedText, defaultText) {
  153. var myrecDdl = document.getElementById(recDdlId);
  154. $(myrecDdl).empty();
  155. var option;
  156. if (defaultText != "") {
  157. option = document.createElement("option");
  158. option.text = defaultText;
  159. option.value = "";
  160. myrecDdl.options.add(option);
  161. }
  162. for (var i = 0; i < populateData.length; i++) {
  163. option = document.createElement("option");
  164. if (recDdlId == "" + mId + "recDdlPaymentMode") {
  165. option.text = populateData[i].Value;
  166. option.value = populateData[i].Key;
  167. } else {
  168. option.text = populateData[i].AGENTNAME;
  169. option.value = populateData[i].bankId;
  170. }
  171. if (selectedId != "" && selectedId == populateData[i].value) {
  172. option.selected = true;
  173. } else if (selectedText != "" && selectedText.toUpperCase() == populateData[i].Key.toUpperCase()) {
  174. option.selected = true;
  175. }
  176. try {
  177. myrecDdl.options.add(option);
  178. } catch (e) {
  179. alert(e.message);
  180. }
  181. }
  182. }
  183. function getUrlVars() {
  184. var vars = [], hash;
  185. var hashes = window.location.href.slice(window.location.href.indexOf("?") + 1).split("&");
  186. for (var i = 0; i < hashes.length; i++) {
  187. hash = hashes[i].split("=");
  188. vars.push(hash[0]);
  189. vars[hash[0]] = hash[1];
  190. }
  191. return vars;
  192. }
  193. function showTextBox() {
  194. var res = $("#" + mId + "recDdlRelationship").val();
  195. if (res.toUpperCase() == "11339") {
  196. $("#" + mId + "otherRelationDiv").show();
  197. }
  198. else {
  199. $("#" + mId + "otherRelationDiv").hide();
  200. }
  201. }
  202. function CheckFormValidation() {
  203. $("#" + mId + "recDdlIdType").removeAttr("style");
  204. $("#" + mId + "recTxtIdValue").removeAttr("style");
  205. var input = $("#" + mId + "recTxtRecMobileNo");
  206. var mobileNo = input.val();
  207. if (mobileNo != "") {
  208. var countryCode = $(".country.active .dial-code").text();
  209. var maxLength = input.attr("maxLength");
  210. if (mobileNo.indexOf(countryCode) < 0) {
  211. mobileNo = countryCode + mobileNo;
  212. }
  213. if (mobileNo.length > maxLength) {
  214. alert("Mobile No. Can allow input maxmum " + maxLength + " digit only");
  215. $("#" + mId + "recTxtRecMobileNo").val("");
  216. return false;
  217. }
  218. $("#" + mId + "recTxtRecMobileNo").val(mobileNo);
  219. var numberPattern = /^[+]?[0-9]{6,16}$/;
  220. test = numberPattern.test(mobileNo);
  221. if (!test) {
  222. alert("Mobile No Is Not Valid !");
  223. input.val("");
  224. return false
  225. }
  226. }
  227. paymentMode = $("#" + mId + "recDdlPaymentMode").val();
  228. var reqField = "" + mId + "recDdlCountry," + mId + "recDdlBenificiaryType," + mId + "recTxtReceiverFName," + mId + "recTxtReceiverLName," + mId + "recTxtReceiverAddress," + mId + "recDdlPaymentMode," + mId + "recDdlNativeCountry,";
  229. idTypeVal = $("#" + mId + "recDdlIdType").val();
  230. idTypeNumber = $("#" + mId + "recTxtIdValue").val();
  231. if ((idTypeVal !== null && idTypeVal !== "" && idTypeVal !== "0") || (idTypeNumber !== null && idTypeNumber !== "" && idTypeNumber !== "0")) {
  232. reqField += "" + mId + "recDdlIdType," + mId + "recTxtIdValue,";
  233. }
  234. if (ValidRequiredField(reqField) === false) {
  235. return false;
  236. }
  237. $("#" + mId + "register").attr("disabled", "disabled");
  238. };
  239. function save() {
  240. var addType = 'GetReceiverAddType()';
  241. var bankBranch = $("#" + mId + "recDDlBankBranch option:selected").val();
  242. if (bankBranch === undefined || bankBranch === null || bankBranch.length < 0) {
  243. bankBranch = "";
  244. }
  245. var data =
  246. {
  247. MethodName: "SaveReceiverDetails",
  248. nativeCountry: $("#" + mId + "recDdlNativeCountry").val(),
  249. paymentMode: $("#" + mId + "recDdlPaymentMode option:selected").val(),
  250. PayoutPatner: $("#" + mId + "recDdlPayoutPatner option:selected").val(),
  251. Country: $("#" + mId + "recDdlCountry option:selected").text().split("(")[0],
  252. BenificiaryType: $("#" + mId + "recDdlBenificiaryType option:selected").val(),
  253. Email: $("#" + mId + "recTxtEmail").val(),
  254. ReceiverFName: $("#" + mId + "recTxtReceiverFName").val(),
  255. ReceiverMName: $("#" + mId + "recTxtReceiverMName").val(),
  256. ReceiverLName: $("#" + mId + "recTxtReceiverLName").val(),
  257. ReceiverAddress: $("#" + mId + "recTxtReceiverAddress").val(),
  258. ReceiverCity: $("#" + mId + "recTxtReceiverCity").val(),
  259. ContactNo: $("#" + mId + "recTxtContactNo").val(),
  260. SenderMobileNo: $("#" + mId + "recTxtRecMobileNo").val(),
  261. Relationship: $("#" + mId + "recDdlRelationship option:selected").val(),
  262. PlaceOfIssue: $("#" + mId + "recTxtPlaceOfIssue").val(),
  263. TypeId: $("#" + mId + "recDdlIdType option:selected").val(),
  264. TypeValue: $("#" + mId + "recTxtIdValue").val(),
  265. BenificaryAc: $("#" + mId + "receiverAccountNo").val(),
  266. PurposeOfRemitance: $("#" + mId + "recDdlPurposeOfRemitance").val(),
  267. BankLocation: bankBranch,
  268. BankName: $("#" + mId + "recTxtBankName").val(),
  269. Remarks: $("#" + mId + "recTxtRemarksRec").val(),
  270. OtherRelationDescription: $("#" + mId + "otherRelationshipTextBox").val(),
  271. membershipId: $("#" + mId + "hideMembershipId").val(),
  272. ReceiverId: $("#" + mId + "hideBenificialId").val(),
  273. hideCustomerId: $("#" + mId + "hideCustomerId").val(),
  274. hideBenificialId: $("#" + mId + "hideBenificialId").val(),
  275. hddSignatureImage: $("#" + mId + "hddImgURL").val()
  276. };
  277. $.ajax({
  278. url: "",
  279. type: "post",
  280. data: data,
  281. dataType: "json",
  282. success: function (response) {
  283. if (response.ErrorCode == "1") {
  284. alert(response.Msg);
  285. return false;
  286. } else {
  287. if (addType.toLowerCase() == "s") {
  288. CallBack(response.Id);
  289. }
  290. else {
  291. var hide = $("#" + mId + "hideSearchDivVal").val();
  292. if (hide == "true") {
  293. window.location.href = "List.aspx?customerDetails=true&customerId=" + response.Extra + "&hideSearchDiv=true";
  294. } else {
  295. window.location.href = "List.aspx?customerDetails=true&customerId=" + response.Extra + "";
  296. }
  297. return;
  298. }
  299. return true;
  300. }
  301. },
  302. error: function (error) {
  303. alert("Something went wrong!!!");
  304. return false;
  305. }
  306. })
  307. }
  308. var isChrome = navigator.userAgent.toLowerCase().indexOf("chrome") > -1;
  309. function CallBack(res) {
  310. window.returnValue = res;
  311. if (isChrome) {
  312. window.opener.PostMessageToParentAddReceiver(window.returnValue);
  313. }
  314. window.close();
  315. }
  316. $(document).ready(function () {
  317. var a = $("#" + mId + "hideSearchDivVal").val();
  318. if (a == "true") {
  319. $("#" + mId + "hideSearchDivVal").hide();
  320. $(".main-nav").hide();
  321. }
  322. $("#" + mId + "recTxtRecMobileNo").intlTelInput({
  323. nationalMode: true,
  324. formatOnDisplay: false,
  325. utilsScript: "https://cdnjs.cloudflare.com/ajax/libs/intl-tel-input/12.1.3/js/utils.js" // just for formatting/placeholders etc
  326. });
  327. $("#" + mId + "recTxtRecMobileNo").on("change", function () {
  328. var input = $("#" + mId + "recTxtRecMobileNo");
  329. var mobileNo = input.val();
  330. var countryCode = $(".receiver .country.active .dial-code").text();
  331. var maxLength = input.attr("maxLength");
  332. if (mobileNo.indexOf(countryCode) < 0) {
  333. mobileNo = countryCode + mobileNo;
  334. }
  335. if (mobileNo.length > maxLength) {
  336. alert("Mobile No. Can allow input maxmum " + maxLength + " digit only");
  337. return $(this).val("");
  338. }
  339. $(this).val(mobileNo);
  340. CheckForMobileNumber(this, "Mobile No.");
  341. });
  342. PopulateCountryFlagForMobileNumber();
  343. $("#" + mId + "recDdlCountry").on("change", function () {
  344. var country = $("#" + mId + "recDdlCountry option:selected ").text().split('(')[0];
  345. debugger
  346. if (country.toUpperCase() === 'NEPAL' || country.toUpperCase() === 'VIETNAM') {
  347. $('#branchSelect').hide();
  348. $('#branchManual').show();
  349. }
  350. else {
  351. $('#branchSelect').show();
  352. $('#branchManual').hide();
  353. }
  354. PopulateCountryFlagForMobileNumber();
  355. PopulatePaymentMethod();
  356. PopulatePayoutPartner();
  357. });
  358. });
  359. function PopulateCountryFlagForMobileNumber() {
  360. $("#" + mId + "recTxtRecMobileNo").attr("disabled", "disabled");
  361. var getCountry = $("#" + mId + "recDdlCountry option:selected").text();
  362. var countryId = $("#" + mId + "recDdlCountry option:selected").val();
  363. if (countryId === "" || countryId === null || countryId === "0") {
  364. return;
  365. }
  366. $("#" + mId + "recTxtRecMobileNo").removeAttr("disabled");
  367. var code = getCountry.split("(");
  368. code = code[1].split(")")[0];
  369. $("#" + mId + "recTxtRecMobileNo").intlTelInput("setCountry", code);
  370. if ($("<%=GetReceiverId()%>") != "") {
  371. CheckMobileNumberorCountryCode();
  372. }
  373. }
  374. function CheckMobileNumberorCountryCode() {
  375. var input = $("#" + mId + "recTxtRecMobileNo");
  376. var mobileNo = input.val();
  377. var newMobile = "";
  378. if (mobileNo.indexOf("+") >= 0 || mobileNo === "") {
  379. return true;
  380. }
  381. if (mobileNo != "") {
  382. var countryCode = $(".country.active .dial-code").text();
  383. var len = countryCode.length;
  384. var firstletters = mobileNo.substring(0, len - 1);
  385. var codeWithoutPlus = countryCode.replace("+", "");
  386. if (codeWithoutPlus === firstletters) {
  387. newMobile = "+" + mobileNo;
  388. }
  389. else {
  390. newMobile = countryCode + mobileNo;
  391. }
  392. $("#" + mId + "recTxtRecMobileNo").val(newMobile);
  393. }
  394. }
  395. function PopulateLocation() {
  396. var pmode = $("#" + mId + "ddlPaymentMode option:selected").val();
  397. if (pmode == "2") {
  398. $("#" + mId + "receiverAccountNo").show();
  399. }
  400. else {
  401. $("#" + mId + "receiverAccountNo").hide();
  402. $("#" + mId + "DDLBankLocation").val("");
  403. }
  404. var data =
  405. {
  406. MethodName: "PopulateLocation",
  407. country: $("#" + mId + "ddlCountry option:selected").val(),
  408. pAgent: $("#" + mId + "ddlPayoutPatner option:selected").val(),
  409. paymentMode: $("#" + mId + "ddlPaymentMode option:selected").val()
  410. };
  411. $.post("", data, function (response) {
  412. PopulateDDL(response, "MainContent_DDLBankLocation", "", "", "");
  413. }).fail(function (error) {
  414. alert("Something went wrong!!!");
  415. });
  416. }