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.

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