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.

466 lines
16 KiB

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