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.

422 lines
15 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
  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. $("#agentBankBranchDiv").show();
  115. }
  116. else {
  117. $("#" + mId + "receiverAccountNo").hide();
  118. $("#" + mId + "recDDlBankBranch").val("");
  119. $("#agentBankBranchDiv").hide();
  120. }
  121. var data =
  122. {
  123. MethodName: "PopulatePayoutPartner",
  124. country: $("#" + mId + "recDdlCountry option:selected").val(),
  125. paymentMode: $("#" + mId + "recDdlPaymentMode option:selected").text()
  126. };
  127. $.post("", data, function (response) {
  128. PopulaterecDdl(response, "" + mId + "recDdlPayoutPatner", "", "", "");
  129. }).fail(function (error) {
  130. alert("Something went wrong!!!");
  131. });
  132. }
  133. function PopulateBranchDDL(populateData, recDdlId, defaultText) {
  134. var myrecDdl = document.getElementById(recDdlId);
  135. $(myrecDdl).empty();
  136. var option;
  137. if (defaultText != "") {
  138. option = document.createElement("option");
  139. option.text = defaultText;
  140. option.value = "";
  141. myrecDdl.options.add(option);
  142. }
  143. for (var i = 0; i < populateData.length; i++) {
  144. option = document.createElement("option");
  145. option.text = populateData[i].agentName;
  146. option.value = populateData[i].agentId;
  147. try {
  148. myrecDdl.options.add(option);
  149. } catch (e) {
  150. alert(e.message);
  151. }
  152. }
  153. }
  154. function PopulaterecDdl(populateData, recDdlId, selectedId, selectedText, defaultText) {
  155. var myrecDdl = document.getElementById(recDdlId);
  156. $(myrecDdl).empty();
  157. var option;
  158. if (defaultText != "") {
  159. option = document.createElement("option");
  160. option.text = defaultText;
  161. option.value = "";
  162. myrecDdl.options.add(option);
  163. }
  164. for (var i = 0; i < populateData.length; i++) {
  165. option = document.createElement("option");
  166. if (recDdlId == "" + mId + "recDdlPaymentMode") {
  167. option.text = populateData[i].Value;
  168. option.value = populateData[i].Key;
  169. } else {
  170. option.text = populateData[i].AGENTNAME;
  171. option.value = populateData[i].bankId;
  172. }
  173. if (selectedId != "" && selectedId == populateData[i].value) {
  174. option.selected = true;
  175. } else if (selectedText != "" && selectedText.toUpperCase() == populateData[i].Key.toUpperCase()) {
  176. option.selected = true;
  177. }
  178. try {
  179. myrecDdl.options.add(option);
  180. } catch (e) {
  181. alert(e.message);
  182. }
  183. }
  184. }
  185. function getUrlVars() {
  186. var vars = [], hash;
  187. var hashes = window.location.href.slice(window.location.href.indexOf("?") + 1).split("&");
  188. for (var i = 0; i < hashes.length; i++) {
  189. hash = hashes[i].split("=");
  190. vars.push(hash[0]);
  191. vars[hash[0]] = hash[1];
  192. }
  193. return vars;
  194. }
  195. function showTextBox() {
  196. var res = $("#" + mId + "recDdlRelationship").val();
  197. if (res.toUpperCase() == "11339") {
  198. $("#" + mId + "otherRelationDiv").show();
  199. }
  200. else {
  201. $("#" + mId + "otherRelationDiv").hide();
  202. }
  203. }
  204. function CheckFormValidation() {
  205. $("#" + mId + "recDdlIdType").removeAttr("style");
  206. $("#" + mId + "recTxtIdValue").removeAttr("style");
  207. var input = $("#" + mId + "recTxtRecMobileNo");
  208. var mobileNo = input.val();
  209. if (mobileNo != "") {
  210. var countryCode = $(".country.active .dial-code").text();
  211. var maxLength = input.attr("maxLength");
  212. if (mobileNo.indexOf(countryCode) < 0) {
  213. mobileNo = countryCode + mobileNo;
  214. }
  215. if (mobileNo.length > maxLength) {
  216. alert("Mobile No. Can allow input maxmum " + maxLength + " digit only");
  217. $("#" + mId + "recTxtRecMobileNo").val("");
  218. return false;
  219. }
  220. $("#" + mId + "recTxtRecMobileNo").val(mobileNo);
  221. var numberPattern = /^[+]?[0-9]{6,16}$/;
  222. test = numberPattern.test(mobileNo);
  223. if (!test) {
  224. alert("Mobile No Is Not Valid !");
  225. input.val("");
  226. return false
  227. }
  228. }
  229. paymentMode = $("#" + mId + "recDdlPaymentMode").val();
  230. var reqField = "" + mId + "recDdlCountry," + mId + "recDdlBenificiaryType," + mId + "recTxtReceiverFName," + mId + "recTxtReceiverLName," + mId + "recTxtReceiverAddress," + mId + "recDdlPaymentMode," + mId + "recDdlNativeCountry,";
  231. idTypeVal = $("#" + mId + "recDdlIdType").val();
  232. idTypeNumber = $("#" + mId + "recTxtIdValue").val();
  233. if ((idTypeVal !== null && idTypeVal !== "" && idTypeVal !== "0") || (idTypeNumber !== null && idTypeNumber !== "" && idTypeNumber !== "0")) {
  234. reqField += "" + mId + "recDdlIdType," + mId + "recTxtIdValue,";
  235. }
  236. if (ValidRequiredField(reqField) === false) {
  237. return false;
  238. }
  239. $("#" + mId + "register").attr("disabled", "disabled");
  240. };
  241. function save() {
  242. var addType = 'GetReceiverAddType()';
  243. var bankBranch = $("#" + mId + "recDDlBankBranch option:selected").val();
  244. if (bankBranch === undefined || bankBranch === null || bankBranch.length < 0) {
  245. bankBranch = "";
  246. }
  247. var data =
  248. {
  249. MethodName: "SaveReceiverDetails",
  250. nativeCountry: $("#" + mId + "recDdlNativeCountry").val(),
  251. paymentMode: $("#" + mId + "recDdlPaymentMode option:selected").val(),
  252. PayoutPatner: $("#" + mId + "recDdlPayoutPatner option:selected").val(),
  253. Country: $("#" + mId + "recDdlCountry option:selected").text().split("(")[0],
  254. BenificiaryType: $("#" + mId + "recDdlBenificiaryType option:selected").val(),
  255. Email: $("#" + mId + "recTxtEmail").val(),
  256. ReceiverFName: $("#" + mId + "recTxtReceiverFName").val(),
  257. ReceiverMName: $("#" + mId + "recTxtReceiverMName").val(),
  258. ReceiverLName: $("#" + mId + "recTxtReceiverLName").val(),
  259. ReceiverAddress: $("#" + mId + "recTxtReceiverAddress").val(),
  260. ReceiverCity: $("#" + mId + "recTxtReceiverCity").val(),
  261. ContactNo: $("#" + mId + "recTxtContactNo").val(),
  262. SenderMobileNo: $("#" + mId + "recTxtRecMobileNo").val(),
  263. Relationship: $("#" + mId + "recDdlRelationship option:selected").val(),
  264. PlaceOfIssue: $("#" + mId + "recTxtPlaceOfIssue").val(),
  265. TypeId: $("#" + mId + "recDdlIdType option:selected").val(),
  266. TypeValue: $("#" + mId + "recTxtIdValue").val(),
  267. BenificaryAc: $("#" + mId + "receiverAccountNo").val(),
  268. PurposeOfRemitance: $("#" + mId + "recDdlPurposeOfRemitance").val(),
  269. BankLocation: bankBranch,
  270. BankName: $("#" + mId + "recTxtBankName").val(),
  271. Remarks: $("#" + mId + "recTxtRemarksRec").val(),
  272. OtherRelationDescription: $("#" + mId + "otherRelationshipTextBox").val(),
  273. membershipId: $("#" + mId + "hideMembershipId").val(),
  274. ReceiverId: $("#" + mId + "hideBenificialId").val(),
  275. hideCustomerId: $("#" + mId + "hideCustomerId").val(),
  276. hideBenificialId: $("#" + mId + "hideBenificialId").val(),
  277. hddSignatureImage: $("#" + mId + "hddImgURL").val()
  278. };
  279. $.ajax({
  280. url: "",
  281. type: "post",
  282. data: data,
  283. dataType: "json",
  284. success: function (response) {
  285. if (response.ErrorCode == "1") {
  286. alert(response.Msg);
  287. return false;
  288. } else {
  289. if (addType.toLowerCase() == "s") {
  290. CallBack(response.Id);
  291. }
  292. else {
  293. var hide = $("#" + mId + "hideSearchDivVal").val();
  294. if (hide == "true") {
  295. window.location.href = "List.aspx?customerDetails=true&customerId=" + response.Extra + "&hideSearchDiv=true";
  296. } else {
  297. window.location.href = "List.aspx?customerDetails=true&customerId=" + response.Extra + "";
  298. }
  299. return;
  300. }
  301. return true;
  302. }
  303. },
  304. error: function (error) {
  305. alert("Something went wrong!!!");
  306. return false;
  307. }
  308. })
  309. }
  310. var isChrome = navigator.userAgent.toLowerCase().indexOf("chrome") > -1;
  311. function CallBack(res) {
  312. window.returnValue = res;
  313. if (isChrome) {
  314. window.opener.PostMessageToParentAddReceiver(window.returnValue);
  315. }
  316. window.close();
  317. }
  318. $(document).ready(function () {
  319. var a = $("#" + mId + "hideSearchDivVal").val();
  320. if (a == "true") {
  321. $("#" + mId + "hideSearchDivVal").hide();
  322. $(".main-nav").hide();
  323. }
  324. $("#" + mId + "recTxtRecMobileNo").intlTelInput({
  325. nationalMode: true,
  326. formatOnDisplay: false,
  327. utilsScript: "https://cdnjs.cloudflare.com/ajax/libs/intl-tel-input/12.1.3/js/utils.js" // just for formatting/placeholders etc
  328. });
  329. $("#" + mId + "recTxtRecMobileNo").on("change", function () {
  330. var input = $("#" + mId + "recTxtRecMobileNo");
  331. var mobileNo = input.val();
  332. var countryCode = $(".receiver .country.active .dial-code").text();
  333. var maxLength = input.attr("maxLength");
  334. if (mobileNo.indexOf(countryCode) < 0) {
  335. mobileNo = countryCode + mobileNo;
  336. }
  337. if (mobileNo.length > maxLength) {
  338. alert("Mobile No. Can allow input maxmum " + maxLength + " digit only");
  339. return $(this).val("");
  340. }
  341. $(this).val(mobileNo);
  342. CheckForMobileNumber(this, "Mobile No.");
  343. });
  344. PopulateCountryFlagForMobileNumber();
  345. $("#" + mId + "recDdlCountry").on("change", function () {
  346. PopulateCountryFlagForMobileNumber();
  347. PopulatePaymentMethod();
  348. PopulatePayoutPartner();
  349. });
  350. });
  351. function PopulateCountryFlagForMobileNumber() {
  352. $("#" + mId + "recTxtRecMobileNo").attr("disabled", "disabled");
  353. var getCountry = $("#" + mId + "recDdlCountry option:selected").text();
  354. var countryId = $("#" + mId + "recDdlCountry option:selected").val();
  355. if (countryId === "" || countryId === null || countryId === "0") {
  356. return;
  357. }
  358. $("#" + mId + "recTxtRecMobileNo").removeAttr("disabled");
  359. var code = getCountry.split("(");
  360. code = code[1].split(")")[0];
  361. $("#" + mId + "recTxtRecMobileNo").intlTelInput("setCountry", code);
  362. if ($("<%=GetReceiverId()%>") != "") {
  363. CheckMobileNumberorCountryCode();
  364. }
  365. }
  366. function CheckMobileNumberorCountryCode() {
  367. var input = $("#" + mId + "recTxtRecMobileNo");
  368. var mobileNo = input.val();
  369. var newMobile = "";
  370. if (mobileNo.indexOf("+") >= 0 || mobileNo === "") {
  371. return true;
  372. }
  373. if (mobileNo != "") {
  374. var countryCode = $(".country.active .dial-code").text();
  375. var len = countryCode.length;
  376. var firstletters = mobileNo.substring(0, len - 1);
  377. var codeWithoutPlus = countryCode.replace("+", "");
  378. if (codeWithoutPlus === firstletters) {
  379. newMobile = "+" + mobileNo;
  380. }
  381. else {
  382. newMobile = countryCode + mobileNo;
  383. }
  384. $("#" + mId + "recTxtRecMobileNo").val(newMobile);
  385. }
  386. }