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.

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