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.

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