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.

1328 lines
40 KiB

4 years ago
  1. var isChrome = navigator.userAgent.toLowerCase().indexOf('chrome') > -1;
  2. function LoadModule(menuType) {
  3. scroll(0, 0);
  4. return true;
  5. switch (menuType.toLowerCase()) {
  6. case "adminstration":
  7. window.open("/Administration.aspx?mtype=adminstration", "mainFrame")
  8. break;
  9. case "customer_management":
  10. window.open("/Administration.aspx?mtype=customer_management", "mainFrame")
  11. break;
  12. case "customer_management":
  13. window.open("/Administration.aspx?mtype=customer_management", "mainFrame")
  14. break;
  15. case "applicationsetting":
  16. window.open("/Administration.aspx?mtype=applicationsetting", "mainFrame")
  17. break;
  18. case "sub_administration":
  19. window.open("/Administration.aspx?mtype=sub_administration", "mainFrame")
  20. break;
  21. case "system_security":
  22. window.open("/Administration.aspx?mtype=system_security", "mainFrame")
  23. break;
  24. case "remittance":
  25. window.open("/Administration.aspx?mtype=remittance", "mainFrame")
  26. break;
  27. case "servicecharge_and_commission":
  28. window.open("/Administration.aspx?mtype=servicecharge_and_commission", "mainFrame")
  29. break;
  30. case "creditrisk_management":
  31. window.open("/Administration.aspx?mtype=creditrisk_management", "mainFrame")
  32. break;
  33. case "transaction":
  34. window.open("/Administration.aspx?mtype=transaction", "mainFrame")
  35. break;
  36. case "report":
  37. window.open("/Administration.aspx?mtype=report", "mainFrame")
  38. break;
  39. case "account":
  40. window.open("/Administration.aspx?mtype=account", "mainFrame")
  41. break;
  42. case "remittance_report":
  43. window.open("/Administration.aspx?mtype=remittance_report", "mainFrame")
  44. break;
  45. case "account_report":
  46. window.open("/Administration.aspx?mtype=account_report", "mainFrame")
  47. break;
  48. case "sub_account":
  49. window.open("/Administration.aspx?mtype=sub_account", "mainFrame")
  50. break;
  51. }
  52. }
  53. function LoadModuleAgentMenu(menuType) {
  54. return true;
  55. switch (menuType.toLowerCase()) {
  56. case "send_money":
  57. window.open("/AgentMenuTileView.aspx?mtype=send_money", "mainFrame");
  58. break;
  59. case "pay_money":
  60. window.open("/AgentMenuTileView.aspx?mtype=pay_money", "mainFrame");
  61. break;
  62. case "reports":
  63. window.open("/AgentMenuTileView.aspx?mtype=reports", "mainFrame");
  64. break;
  65. case "other_services":
  66. window.open("/AgentMenuTileView.aspx?mtype=other_services", "mainFrame");
  67. break;
  68. }
  69. }
  70. Date.prototype.toUSFormat = function () {
  71. var dd = this.getDate();
  72. if (dd < 10) dd = '0' + dd;
  73. var mm = this.getMonth() + 1;
  74. if (mm < 10) mm = '0' + mm;
  75. var yyyy = this.getFullYear();
  76. return String(mm + "\/" + dd + "\/" + yyyy)
  77. }
  78. function OpenInNewWindowModifyChrome(url, param) {
  79. if (param == undefined || param == "") {
  80. param = "width=600,height=400,resizable=1,status=1,toolbar=0,scrollbars=1,center=1";
  81. }
  82. return window.open(url, window.self, param);
  83. }
  84. function PopUpWindowWithCallBackBigSize(url, param) {
  85. if (param == undefined || param == "") {
  86. param = "dialogHeight:1000px;dialogWidth:1100px;dialogLeft:150;dialogTop:50;center:yes";
  87. }
  88. if (isChrome) {
  89. return window.open(url, "_blank", param);
  90. } else {
  91. return window.showModalDialog(url, window.self, param);
  92. }
  93. //return window.showModalDialog(url, window.self, param);
  94. }
  95. function RemoveComma(value) {
  96. return value.replace(/,/g, "");
  97. }
  98. function ConvertDate(dt, seprator) {
  99. var d = new Date(dt),
  100. month = '' + (d.getMonth() + 1),
  101. day = '' + d.getDate(),
  102. year = d.getFullYear();
  103. return [year, month, day].join(seprator);
  104. }
  105. function FilterString(value) {
  106. //alert(value);
  107. value = value.replace("NaN", "");
  108. return value.replace(/[^a-zA-Z0-9 .()]/g, "");
  109. }
  110. function bookmarksite() {
  111. var title = document.title, url = window.location.href;
  112. if (window.sidebar) // firefox
  113. window.sidebar.addPanel(title, url, "");
  114. else if (window.opera && window.print) { // opera
  115. var elem = document.createElement('a');
  116. elem.setAttribute('href', url);
  117. elem.setAttribute('title', title);
  118. elem.setAttribute('rel', 'sidebar');
  119. elem.click();
  120. }
  121. else if (document.all)// ie
  122. window.external.AddFavorite(url, title);
  123. }
  124. function EnableDisableBtn(id, boolDisabled) {
  125. try {
  126. var ctl = GetElement(id);
  127. ctl.disabled = boolDisabled;
  128. var cssClass = "button" + (boolDisabled ? "Disabled" : "");
  129. var thisClass = ctl.className;
  130. thisClass = thisClass.replace("buttonDisabled", "");
  131. thisClass = thisClass.replace("buttonEnabled", "");
  132. cssClass = cssClass + " " + thisClass;
  133. SetCSSByObj(ctl, cssClass);
  134. } catch (ex) { }
  135. }
  136. function LoadRegion(flag, divZip, divDistrict, region) {
  137. if (flag == 'o') { //o - for Other
  138. ShowElement(divZip);
  139. HideElement(divDistrict);
  140. GetElement(region).innerHTML = "State";
  141. return;
  142. }
  143. else if (flag == 'n') { //n - for Nepal
  144. ShowElement(divDistrict);
  145. HideElement(divZip);
  146. GetElement(region).innerHTML = "Zone";
  147. return;
  148. }
  149. }
  150. function MoveWindowToTop() {
  151. var target = window.parent.document.getElementById('Td1');
  152. target.scrollIntoView();
  153. }
  154. function ReadData(id, singleQuote, focusIfNull) {
  155. var obj = document.getElementById(id);
  156. if (obj) return (singleQuote ? "'" + obj.value + "'" : obj.value);
  157. return "null";
  158. }
  159. function IsCSVFile(fileName) {
  160. var file_parts = fileName.split(".");
  161. if (file_parts[file_parts.length - 1].toUpperCase() == "CSV")
  162. return true;
  163. return false;
  164. }
  165. function GetListBoxItems(id, selectedOnly) {
  166. var list = document.getElementById(id);
  167. var valueList = "";
  168. var cnt = list.options.length;
  169. var values = [];
  170. for (var i = 0; i < cnt; i++) {
  171. var item = list.options[i];
  172. if (item.selected || (!selectedOnly)) {
  173. values.push(item.value);
  174. }
  175. }
  176. return values;
  177. }
  178. function HideElement(id) {
  179. ObjHide(GetElement(id));
  180. }
  181. function ObjHide(obj) {
  182. try {
  183. obj.style.display = "none";
  184. } catch (ex) { }
  185. }
  186. function ShowElement(id) {
  187. ObjShow(GetElement(id));
  188. }
  189. function ShowElementNew(id) {
  190. ObjShowNew(GetElement(id));
  191. }
  192. function ObjShowNew(obj) {
  193. try {
  194. obj.style.display = "contents";
  195. } catch (ex) { }
  196. }
  197. function ObjShow(obj) {
  198. try {
  199. obj.style.display = "block";
  200. } catch (ex) { }
  201. }
  202. var guid = (function () {
  203. function s4() {
  204. return Math.floor((1 + Math.random()) * 0x10000)
  205. .toString(16)
  206. .substring(1);
  207. }
  208. return function () {
  209. return s4() + s4() + '' + s4() + '' + s4();
  210. };
  211. })();
  212. function OpenInNewWindow(url) {
  213. url = url + "&srcCode=" + guid;
  214. window.open(url, "", "width=825,height=500,resizable=1,status=1,toolbar=0,scrollbars=1,center=1");
  215. }
  216. function OpenInNewSmallWindow(url) {
  217. url = url + "&srcCode=" + guid;
  218. window.open(url, "", "width=430,height=300,resizable=1,status=1,toolbar=0,scrollbars=1,center=1");
  219. }
  220. function GetValue(id) {
  221. var obj = document.getElementById(id);
  222. if (obj == null || obj == undefined)
  223. return "";
  224. return obj.value;
  225. }
  226. function GetElement(id) {
  227. return document.getElementById(id);
  228. }
  229. function GetDateValue(id) {
  230. var value = GetValue(id);
  231. if (value == "")
  232. return value;
  233. var dateParts = value.split("/");
  234. if (dateParts.length < 3)
  235. return "";
  236. var y = dateParts[0].toString("0000");
  237. var m = dateParts[1].toString("00");
  238. var d = dateParts[2].toString("00");
  239. return y + "/" + m + '/' + d;
  240. }
  241. function SelectOrClearByElement(elements, boolSelect) {
  242. for (var i = 0; i < elements.length; i++) {
  243. try {
  244. elements[i].checked = boolSelect;
  245. } catch (ex) {
  246. }
  247. }
  248. }
  249. function SelectOrClearById(cbContainerId, boolSelect) {
  250. var elements = GetElement(cbContainerId).getElementsByTagName("input");
  251. SelectOrClearByElement(elements, boolSelect);
  252. }
  253. function EnableOrDisableDdlByElement(elements, boolDisabled) {
  254. for (var i = 0; i < elements.length; i++) {
  255. try {
  256. elements[i].disabled = boolDisabled;
  257. } catch (ex) {
  258. }
  259. }
  260. }
  261. function EnableOrDisableDdlById(cbContainerId, boolDisabled) {
  262. var elements = GetElement(cbContainerId).getElementsByTagName("select");
  263. EnableOrDisableDdlByElement(elements, boolDisabled);
  264. }
  265. function PrintWindow() {
  266. window.parent.frames["frmame_main"].focus();
  267. window.parent.frames["frmame_main"].document.execCommand('print', false, null);
  268. return false;
  269. }
  270. function ReportPrint() {
  271. window.print();
  272. return false;
  273. }
  274. function DownloadReport(path) {
  275. url = path + "/Download.aspx?mode=report";
  276. OpenInNewWindow(url);
  277. }
  278. function HasValidExtension(fileName, ext) {
  279. var file_parts = fileName.split(".");
  280. if (file_parts[file_parts.length - 1].toUpperCase() == ext.toUpperCase())
  281. return true;
  282. return false;
  283. }
  284. function DownloadInNewWindow(url) {
  285. window.open(url, "", "width=825,height=500,resizable=1,status=1,toolbar=0,scrollbars=1,center=1");
  286. }
  287. function SelectFunctions(me, parent) {
  288. var elements = document.getElementsByName("functionId");
  289. var cssName = me.className;
  290. var cssLength = cssName.length;
  291. var newCss = "";
  292. var boolChecked = false;
  293. if (cssName.substr(cssLength - 8, cssLength) == "Selected") {
  294. newCss = cssName.substr(0, cssLength - 8);
  295. } else {
  296. newCss = cssName + "Selected";
  297. boolChecked = true;
  298. }
  299. var parentLength = parent.length;
  300. for (var i = 0; i < elements.length; i++) {
  301. if (!elements[i].disabled) {
  302. var value = elements[i].value;
  303. if (value.substr(0, parentLength) == parent) {
  304. elements[i].checked = boolChecked;
  305. }
  306. }
  307. }
  308. me.className = newCss;
  309. }
  310. function Redirect(url) {
  311. window.parent.location = url;
  312. }
  313. function RedirectLocal(url) {
  314. window.location = url;
  315. }
  316. function OpenDialog(url, height, width, left, top) {
  317. if (isChrome) {
  318. var param = "";
  319. if (param == undefined || param == "")
  320. param = "width=1000,height=500,resizable=1,status=1,toolbar=0,scrollbars=1,center=1";
  321. return window.open(url, "_blank", param);
  322. } else {
  323. return window.showModalDialog(url, window.self, "dialogHeight:" + height + "px;dialogWidth:" + width + "px;dialogLeft:" + left + "px;dialogTop:" + top + "px");
  324. }
  325. // return window.showModalDialog(url, window.self, "dialogHeight:" + height + "px;dialogWidth:" + width + "px;dialogLeft:" + left + "px;dialogTop:" + top + "px");
  326. }
  327. function CloseDialog(returnValue) {
  328. window.returnValue = returnValue;
  329. window.close();
  330. }
  331. function GoBack() {
  332. if (confirm("Are you sure to want to go back?")) {
  333. window.history.back(1);
  334. }
  335. }
  336. function OpenWindow(url) {
  337. var browser = navigator.appName;
  338. if (browser == "Microsoft Internet Explorer") {
  339. window.opener = self;
  340. }
  341. window.open(url, "", "width=900,height=750,toolbar=no,scrollbars=yes,location=no,resizable =yes");
  342. window.moveTo(0, 0);
  343. window.resizeTo(screen.width, screen.height - 100);
  344. self.close();
  345. }
  346. function PopUpWindow(url, param) {
  347. if (param == undefined || param == "") {
  348. param = "dialogHeight:500px;dialogWidth:600px;dialogLeft:300;dialogTop:100;center:yes";
  349. }
  350. if (isChrome) {
  351. window.open(url, "_blank", param);
  352. } else {
  353. return window.showModalDialog(url, window.self, param);
  354. }
  355. //return window.showModalDialog(url, window.self, param); //changed instead of showModalDialog()
  356. }
  357. function PopUpWithCallBack(url, param) {
  358. if (param == undefined || param == "") {
  359. param = "dialogHeight:400px;dialogWidth:500px;dialogLeft:300;dialogTop:100;center:yes";
  360. }
  361. if (isChrome) {
  362. window.open(url, "_blank", param);
  363. } else {
  364. window.showModalDialog(url, window.self, param);
  365. }
  366. //errorCode = window.showModalDialog(url, window.self, param);
  367. CallBack();
  368. }
  369. function OpenInNewWindow(url) {
  370. window.open(url, "_blank", "width=825,height=500,resizable=1,status=1,toolbar=0,scrollbars=1,center=1");
  371. }
  372. function PopUpWindowWithCallBack(url, param) {
  373. if (param == undefined || param == "") {
  374. param = "width=1000,height=500,resizable=1,status=1,toolbar=0,scrollbars=1,center=1";
  375. }
  376. if (isChrome) {
  377. return window.open(url, "_blank", param);
  378. } else {
  379. return window.showModalDialog(url, window.self, param);
  380. }
  381. //return window.showModalDialog(url, window.self, param);
  382. }
  383. function downloadInNewWindow(url) {
  384. window.open(url, "", "width=825,height=500,resizable=1,status=1,toolbar=0,scrollbars=1,center=1");
  385. }
  386. function FindPos(obj) {
  387. var curleft = curtop = 0;
  388. if (obj.offsetParent) {
  389. curleft = obj.offsetLeft
  390. curtop = obj.offsetTop
  391. while (obj = obj.offsetParent) {
  392. curleft += obj.offsetLeft
  393. curtop += obj.offsetTop
  394. }
  395. }
  396. return [curleft, curtop];
  397. }
  398. function numericOnly(obj, e, supportDecimal, doNotSupportNegative) {
  399. //var e = event || evt; // for trans-browser compatibility
  400. var evtobj = window.event ? event : e;
  401. if (evtobj.altKey || evtobj.ctrlKey)
  402. return true;
  403. var charCode = e.which || e.keyCode;
  404. if (doNotSupportNegative) {
  405. if (charCode == 189 || charCode == 109) {
  406. return false;
  407. }
  408. }
  409. if (charCode == 46 || charCode == 8 || charCode == 9 || charCode == 37 || charCode == 39 || charCode == 109)
  410. return true;
  411. var char = String.fromCharCode(charCode);
  412. //alert(charCode + " " + char);
  413. if (char == "." || char == "¾" || charCode == 110) {
  414. if (obj.value.indexOf(".") > -1)
  415. return false;
  416. else
  417. return true;
  418. }
  419. // if (isNaN(char))
  420. // return false;
  421. if ((char >= "0" && char <= "9") || (charCode >= 96 && charCode <= 105))
  422. return true;
  423. return false;
  424. }
  425. function TrackChanges(hddField) {
  426. GetElement(hddField).value = 'y';
  427. }
  428. function manageOnPaste(me) {
  429. return true;
  430. }
  431. function resetInput(obj, hint, type, isNum, allowBlank) {
  432. var val = parseFloat(obj.value);
  433. if (type == 1) {
  434. if (val == hint || (isNum && isNaN(obj.value))) { obj.value = ""; }
  435. }
  436. else {
  437. if (val.length == 0 || (isNum && isNaN(obj.value))) {
  438. if (allowBlank) {
  439. obj.value = "";
  440. } else {
  441. obj.value = hint;
  442. }
  443. }
  444. }
  445. }
  446. function ParseMessageToArray(mes) {
  447. var results = mes.split("-:::-");
  448. return results;
  449. }
  450. function GetIds(name) {
  451. var elements = document.getElementsByName(name);
  452. var list = "";
  453. for (var i = 0; i < elements.length; i++) {
  454. try {
  455. if (elements[i].checked) {
  456. list = list + (list != "" ? ", " : "") + elements[i].value;
  457. }
  458. }
  459. catch (ex) {
  460. return "";
  461. }
  462. }
  463. return list;
  464. }
  465. //Textbox with Comma Separation
  466. function CurrencyFormatted(amount) {
  467. var i = parseFloat(amount);
  468. if (isNaN(i)) { i = 0.00; }
  469. var minus = '';
  470. if (i < 0) { minus = '-'; }
  471. i = Math.abs(i);
  472. i = parseInt((i + .005) * 100);
  473. i = i / 100;
  474. s = new String(i);
  475. if (s.indexOf('.') < 0) { s += '.00'; }
  476. if (s.indexOf('.') == (s.length - 2)) { s += '0'; }
  477. s = minus + s;
  478. return s;
  479. }
  480. function CommaFormatted(amount) {
  481. var delimiter = ",";
  482. var a = amount.split('.', 2);
  483. var d = a[1];
  484. var i = parseInt(a[0]);
  485. if (isNaN(i)) { return ''; }
  486. var minus = '';
  487. if (i < 0) { minus = '-'; }
  488. i = Math.abs(i);
  489. var n = new String(i);
  490. var a = [];
  491. while (n.length > 3) {
  492. var nn = n.substr(n.length - 3);
  493. a.unshift(nn);
  494. n = n.substr(0, n.length - 3);
  495. }
  496. if (n.length > 0) { a.unshift(n); }
  497. n = a.join(delimiter);
  498. if (d.length < 1) { amount = n; }
  499. else { amount = n + '.' + d; }
  500. amount = minus + amount;
  501. return amount;
  502. }
  503. function UpdateComma(obj) {
  504. var s = new String();
  505. var amt = obj.value.replace(",", "");
  506. amt = amt.replace(",", "");
  507. amt = amt.replace(",", "");
  508. amt = amt.replace(",", "");
  509. //alert(amt);
  510. s = CurrencyFormatted(amt);
  511. s = CommaFormatted(s);
  512. obj.value = s;
  513. }
  514. function roundNumber(rnum, rlength) { // Arguments: number to round, number of decimal places
  515. var newnumber = Math.round(rnum * Math.pow(10, rlength)) / Math.pow(10, rlength);
  516. return parseFloat(newnumber); // Output the result to the form field (change for your purposes)
  517. }
  518. function roundNumberUp(rnum, rlength) {
  519. var ad = 5 / Math.pow(10, rlength + 1);
  520. return roundNumber(rnum + ad, rlength);
  521. }
  522. function roundNumberDown(rnum, rlength) {
  523. var ad = 5 / Math.pow(10, rlength + 1);
  524. return roundNumber(rnum - ad, rlength);
  525. }
  526. //End
  527. document.onkeydown = KeyDownHandler;
  528. document.onkeyup = KeyUpHandler;
  529. var CTRL = false;
  530. var SHIFT = false;
  531. var ALT = false;
  532. var CHAR_CODE = -1;
  533. function KeyDownHandler(e) {
  534. var x = '';
  535. if (document.all) {
  536. var evnt = window.event;
  537. x = evnt.keyCode;
  538. }
  539. else {
  540. x = e.keyCode;
  541. }
  542. DetectKeys(x, true);
  543. // Lock();
  544. MenuControl();
  545. }
  546. function KeyUpHandler(e) {
  547. var x = '';
  548. if (document.all) {
  549. var evnt = window.event;
  550. x = evnt.keyCode;
  551. }
  552. else {
  553. x = e.keyCode;
  554. }
  555. DetectKeys(x, false);
  556. // Lock();
  557. MenuControl();
  558. }
  559. function MenuControl() {
  560. }
  561. function DetectKeys(KeyCode, IsKeyDown) {
  562. if (KeyCode == '16') {
  563. SHIFT = IsKeyDown;
  564. CHAR_CODE = -1;
  565. }
  566. else if (KeyCode == '17') {
  567. CTRL = IsKeyDown;
  568. CHAR_CODE = -1;
  569. }
  570. else if (KeyCode == '18') {
  571. ALT = IsKeyDown;
  572. CHAR_CODE = -1;
  573. }
  574. else {
  575. if (IsKeyDown)
  576. CHAR_CODE = KeyCode;
  577. else
  578. CHAR_CODE = -1;
  579. }
  580. }
  581. function Lock() {
  582. if (ALT && CHAR_CODE == 76) {
  583. if (confirm("Are you sure you want to lock application?")) {
  584. // Session("url") = document.getElementById("frmame_main").contentWindow.location.href;
  585. var url = window.parent.document.getElementById("frmame_main").contentWindow.location.href;
  586. window.parent.location.replace('/Lock.aspx?url=' + url);
  587. }
  588. }
  589. }
  590. //START RATE MASKING
  591. function checkRateMasking(obj, beforeLength, afterLength) {
  592. if (isNaN(obj.value)) {
  593. alert("Please, Enter valid number !");
  594. setTimeout(function () { obj.focus(); }, 1);
  595. return 1;
  596. }
  597. if (obj.value.indexOf(".") >= 0) {
  598. var resStr = obj.value.split(".");
  599. if (beforeLength != "99" && obj.value != "0" && obj.value != "") {
  600. var bdValue = resStr[0];
  601. var bdValueLength = bdValue.length;
  602. if (parseFloat(obj.value) < 0)
  603. bdValueLength = bdValue.length - 1;
  604. if (bdValueLength > beforeLength) {
  605. if (parseInt(bdValueLength) > parseInt(beforeLength)) {
  606. alert("Error, Only " + beforeLength + " digit(s) are allowed before decimal !");
  607. setTimeout(function () { obj.focus(); }, 1);
  608. return 1;
  609. }
  610. }
  611. }
  612. if (afterLength != "99" && obj.value != "0" && obj.value != "") {
  613. if (resStr[1].length > afterLength) {
  614. if (resStr[1].length > afterLength) {
  615. alert("Error, Only " + afterLength + " digit(s) are allowed after decimal !");
  616. setTimeout(function () { obj.focus(); }, 1);
  617. return 1;
  618. }
  619. }
  620. }
  621. }
  622. else {
  623. if (beforeLength != "99" && obj.value != "0" && obj.value != "") {
  624. bdValue = obj.value;
  625. bdValueLength = bdValue.length;
  626. if (bdValue < 0)
  627. bdValueLength = bdValue.length - 1;
  628. if (parseInt(bdValueLength) > parseInt(beforeLength)) {
  629. alert("Error, Only " + beforeLength + " digit(s) are allowed before decimal !");
  630. setTimeout(function () { obj.focus(); }, 1);
  631. return 1;
  632. }
  633. }
  634. }
  635. return 0;
  636. }
  637. function CheckNumberWithMsg(obj) {
  638. if (isNaN(obj.value)) {
  639. alert("Input value = " + obj.value + "\n\nPlease enter valid number!");
  640. obj.value = 0;
  641. setTimeout(function () { obj.focus(); }, 1);
  642. }
  643. }
  644. function checkRateCapping2(obj, currentValue, min, max, value, id, errorImg) {
  645. if (isNaN(obj.value)) {
  646. alert("Please, Enter valid number !");
  647. setTimeout(function () { obj.focus(); }, 1);
  648. return 1;
  649. }
  650. value = roundNumber(value, 6);
  651. var msg = "";
  652. GetElement("status_" + id).innerHTML = "";
  653. EnableDisableBtn("btnUpdate_" + id, false);
  654. if (value > max) {
  655. msg = "Calculated value = " + value + "\n\nRate must lie between " + min + " and " + max;
  656. alert(msg);
  657. obj.value = currentValue;
  658. if (currentValue > max) {
  659. GetElement("status_" + id).innerHTML = "<img src=\"" + errorImg + "\" border=\"0\" onclick=\"alert('" + msg + "');\"/>";
  660. EnableDisableBtn("btnUpdate_" + id, true);
  661. }
  662. else if (currentValue < min) {
  663. GetElement("status_" + id).innerHTML = "<img src=\"" + errorImg + "\" border=\"0\" onclick=\"alert('" + msg + "');\"/>";
  664. EnableDisableBtn("btnUpdate_" + id, true);
  665. }
  666. else
  667. setTimeout(function () { obj.focus(); }, 1);
  668. return 1;
  669. }
  670. if (value < min) {
  671. msg = "Calculated value = " + value + "\n\nRate must lie between " + min + " and " + max;
  672. alert(msg);
  673. obj.value = currentValue;
  674. if (currentValue > max) {
  675. GetElement("status_" + id).innerHTML = "<img src=\"" + errorImg + "\" border=\"0\" onclick=\"alert('" + msg + "');\"/>";
  676. EnableDisableBtn("btnUpdate_" + id, true);
  677. }
  678. else if (currentValue < min) {
  679. GetElement("status_" + id).innerHTML = "<img src=\"" + errorImg + "\" border=\"0\" onclick=\"alert('" + msg + "');\"/>";
  680. EnableDisableBtn("btnUpdate_" + id, true);
  681. }
  682. else
  683. setTimeout(function () { obj.focus(); }, 1);
  684. return 1;
  685. }
  686. return 0;
  687. }
  688. function checkRateCapping(obj, currentValue, min, max, value) {
  689. if (isNaN(obj.value)) {
  690. alert("Please, Enter valid number !");
  691. setTimeout(function () { obj.focus(); }, 1);
  692. return 1;
  693. }
  694. value = roundNumber(value, 6);
  695. if (value > max) {
  696. alert("Calculated value = " + value + "\n\nRate must lie between " + min + " and " + max);
  697. if (currentValue > max)
  698. currentValue = 0;
  699. obj.value = currentValue;
  700. setTimeout(function () { obj.focus(); }, 1);
  701. return 1;
  702. }
  703. if (value < min) {
  704. alert("Calculated value = " + value + "\n\nRate must lie between " + min + " and " + max);
  705. if (currentValue < min)
  706. currentValue = 0;
  707. obj.value = currentValue;
  708. setTimeout(function () { obj.focus(); }, 1);
  709. return 1;
  710. }
  711. return 0;
  712. }
  713. function checkCrossRateCapping(obj, currentValue, cMin, cMax, pMin, pMax, crossRate, crossRateMaskAd) {
  714. if (isNaN(obj.value)) {
  715. alert("Please, Enter valid number !");
  716. setTimeout(function () { obj.focus(); }, 1);
  717. return 1;
  718. }
  719. var minCustomerRate = pMin / cMax;
  720. minCustomerRate = roundNumber(minCustomerRate, crossRateMaskAd);
  721. var maxCustomerRate = pMax / cMin;
  722. maxCustomerRate = roundNumber(maxCustomerRate, crossRateMaskAd);
  723. if (crossRate > maxCustomerRate) {
  724. alert("Input value = " + crossRate + "\n\nRate must lie between " + minCustomerRate + " and " + maxCustomerRate);
  725. setTimeout(function () { obj.focus(); }, 1);
  726. obj.value = currentValue;
  727. return 1;
  728. }
  729. else if (crossRate < minCustomerRate) {
  730. alert("Input value = " + crossRate + "\n\nRate must lie between " + minCustomerRate + " and " + maxCustomerRate);
  731. setTimeout(function () { obj.focus(); }, 1);
  732. obj.value = currentValue;
  733. return 1;
  734. }
  735. return 0;
  736. }
  737. function ParseResultJsPrint(errorCode, msg, id) {
  738. return errorCode + "-:::-" + msg + "-:::-" + id;
  739. }
  740. function cVal(data) {
  741. var res = parseFloat(data);
  742. if (isNaN(res)) res = 0;
  743. return res;
  744. }
  745. function hideMessageBox() {
  746. var rptCentraizeMassege = document.getElementById("rptCentraizeMassege");
  747. rptCentraizeMassege.innerHTML = "";
  748. rptCentraizeMassege.className = "";
  749. }
  750. function SetValueById(id, value, innerHTML) {
  751. SetValueByObj(GetElement(id), value, innerHTML);
  752. }
  753. function SetValueByObj(obj, value, innerHTML) {
  754. if (innerHTML) {
  755. obj.innerHTML = innerHTML;
  756. } else {
  757. obj.value = value;
  758. }
  759. }
  760. function SetValueIfNotById(id, value, innerHTML, notValue) {
  761. SetValueIfNotByObj(GetElement(id), value, innerHTML, notValue);
  762. }
  763. function SetValueIfNotByObj(obj, value, innerHTML, notValue) {
  764. value1 = GetValueByObj(obj, innerHTML);
  765. if (value1.toLowerCase() != notValue.toLowerCase()) {
  766. if (innerHTML) {
  767. obj.innerHTML = value;
  768. } else {
  769. obj.value = value;
  770. }
  771. }
  772. }
  773. function SetValueIfBlankById(id, value, innerHTML) {
  774. SetValueIfBlankByObj(GetElement(id), value, innerHTML);
  775. }
  776. function SetValueIfBlankByObj(obj, value, innerHTML) {
  777. var value1 = GetValueByObj(obj, innerHTML);
  778. if (value1 == "") {
  779. if (innerHTML) {
  780. obj.innerHTML = value;
  781. } else {
  782. obj.value = value;
  783. }
  784. }
  785. }
  786. function SetValueIfZeroById(id, value, innerHTML) {
  787. SetValueIfZeroByObj(GetElement(id), value, innerHTML);
  788. }
  789. function SetValueIfZeroByObj(obj, value, innerHTML) {
  790. var value1 = parseFloat(GetValueByObj(obj, innerHTML));
  791. if (value1 == 0) {
  792. if (innerHTML) {
  793. obj.innerHTML = value;
  794. } else {
  795. obj.value = value;
  796. }
  797. }
  798. }
  799. function SetCSSById(id, css) {
  800. SetCSSByObj(GetElement(id), css);
  801. }
  802. function SetCSSByObj(obj, css) {
  803. obj.className = css;
  804. }
  805. function CheckNumber(obj) {
  806. obj.value = cVal(obj.value);
  807. }
  808. function IntegerOnly(obj) {
  809. if (isNaN(obj.value)) {
  810. obj.value = "";
  811. return;
  812. }
  813. if (obj.value.indexOf(".") > -1) {
  814. obj.value = "";
  815. return;
  816. }
  817. }
  818. function FloatOnly(obj) {
  819. if (isNaN(obj.value)) {
  820. obj.value = "";
  821. return;
  822. }
  823. }
  824. //END MASKING VALIDATION
  825. function setCookie(c_name, value, exdays) {
  826. var exdate = new Date();
  827. exdate.setDate(exdate.getDate() + exdays);
  828. var c_value = escape(value) + ((exdays == null) ? "" : "; expires=" + exdate.toUTCString());
  829. document.cookie = c_name + "=" + c_value;
  830. }
  831. function getCookie(c_name) {
  832. var i, x, y, ARRcookies = document.cookie.split(";");
  833. for (i = 0; i < ARRcookies.length; i++) {
  834. x = ARRcookies[i].substr(0, ARRcookies[i].indexOf("="));
  835. y = ARRcookies[i].substr(ARRcookies[i].indexOf("=") + 1);
  836. x = x.replace(/^\s+|\s+$/g, "");
  837. if (x == c_name) {
  838. return unescape(y);
  839. }
  840. }
  841. return "";
  842. }
  843. //Fix Decimal and Rounding
  844. function FixDecimalWithRound(num, afterDecimalCount) {
  845. return num.toFixed(afterDecimalCount).replace(/\.?0+$/, "");
  846. }
  847. function SetColorById(id, value) {
  848. if (value < 0)
  849. GetElement(id).setAttribute('style', 'color: red !important;');
  850. else
  851. GetElement(id).setAttribute('style', 'color: green !important;');
  852. }
  853. function datediff(fromDate, interval) {
  854. /*
  855. * DateFormat month/day/year hh:mm:ss
  856. * ex.
  857. * datediff('01/01/2011 12:00:00','01/01/2011 13:30:00','seconds');
  858. */
  859. var second = 1000, minute = second * 60, hour = minute * 60, day = hour * 24, week = day * 7;
  860. var currentDate = new Date()
  861. fromDate = new Date(fromDate);
  862. toDate = new Date(currentDate);
  863. var timediff = toDate - fromDate;
  864. if (isNaN(timediff)) return NaN;
  865. switch (interval) {
  866. case "years": return toDate.getFullYear() - fromDate.getFullYear();
  867. case "months": return (
  868. (toDate.getFullYear() * 12 + toDate.getMonth())
  869. -
  870. (fromDate.getFullYear() * 12 + fromDate.getMonth())
  871. );
  872. case "weeks": return Math.floor(timediff / week);
  873. case "days": return Math.floor(timediff / day);
  874. case "hours": return Math.floor(timediff / hour);
  875. case "minutes": return Math.floor(timediff / minute);
  876. case "seconds": return Math.floor(timediff / second);
  877. default: return undefined;
  878. }
  879. }
  880. function PrintMessage(msg, errorCode) {
  881. window.parent.SetMessageBox(msg, errorCode);
  882. }
  883. function CheckForSpecialCharacter(nField, fieldName) {
  884. var userInput = nField.value;
  885. if (userInput == "" || userInput == undefined) {
  886. return;
  887. }
  888. if (/^[a-zA-Z0-9- ./\\()-]*$/.test(userInput) == false) {
  889. alert('Special Character(e.g. !@#$%^&*) are not allowed in field : ' + fieldName);
  890. setTimeout(function () { nField.focus(); }, 1);
  891. }
  892. }
  893. function CheckForMobileNumber(nField, fieldName) {
  894. var userInput = nField.value;
  895. if (userInput == "" || userInput == undefined) {
  896. return;
  897. }
  898. if (/^[0-9- ./\\()]*$/.test(userInput) == false) {
  899. alert('Special Character(e.g. !@#$%^&*) are not allowed in field : ' + fieldName);
  900. setTimeout(function () { nField.focus(); }, 1);
  901. }
  902. }
  903. function CheckAlfabetOnly(nField, fieldName) {
  904. var userInput = nField.value;
  905. if (userInput == "" || userInput == undefined) {
  906. return;
  907. }
  908. if (/^[a-zA-Z ]*$/.test(userInput) == false) {
  909. alert('Only Character are allowed in field : ' + fieldName);
  910. setTimeout(function () { nField.focus(); }, 1);
  911. }
  912. }
  913. function CheckAddressValidation(nField, fieldName) {
  914. var userInput = nField.value;
  915. if (userInput == "" || userInput == undefined) {
  916. return;
  917. }
  918. if (/^[a-zA-Z .,/\()]*$/.test(userInput) == false) {
  919. alert('Only Character are allowed in field : ' + fieldName);
  920. setTimeout(function () { nField.focus(); }, 1);
  921. }
  922. }
  923. function RemoveElement(id) {
  924. var el = document.getElementById(id);
  925. if (el)
  926. document.body.removeChild(el);
  927. }
  928. function RemoveProcessDiv() {
  929. var id = "divProcess";
  930. RemoveElement(id);
  931. }
  932. function RemoveProcessDivWithMsg(msg) {
  933. var id = "divProcess";
  934. RemoveElement(id);
  935. alert(msg);
  936. }
  937. function Process() {
  938. var id = "divProcess";
  939. RemoveProcessDiv();
  940. var newdiv = document.createElement('div');
  941. newdiv.setAttribute('id', id);
  942. newdiv.style.width = "100%";
  943. var height = document.body.scrollHeight;
  944. if (height <= 826)
  945. height = '826';
  946. var html = "<center>";
  947. html += "<div class=\"still-bg\" id=\"progress\" style=\"height:" + height + "px;\">";
  948. html += "<div class=\"inner-bg\">";
  949. html += "<h3 style=\"color:white;\">Processing... Please wait.</h3>";
  950. html += "</div>";
  951. html += "</div>";
  952. html += "</center>";
  953. //alert(newdiv.innerHTML);
  954. newdiv.innerHTML = html;
  955. document.body.appendChild(newdiv);
  956. return true;
  957. }
  958. function ProcessWithConfirm(msg) {
  959. if (msg == undefined || msg == null) msg = "Are you sure to approve SELECTED transaction?";
  960. if (confirm(msg)) {
  961. return Process();
  962. }
  963. return false;
  964. }
  965. function SpecialCharToLineBreak(val) {
  966. var sep = "-:::-";
  967. var list = val.split(sep);
  968. return list.join("\n");
  969. }
  970. function onlyAlphabets(e, t) {
  971. try {
  972. if (window.event) {
  973. var charCode = window.event.keyCode;
  974. }
  975. else if (e) {
  976. var charCode = e.which;
  977. }
  978. else { return true; }
  979. if ((charCode > 64 && charCode < 91) || (charCode > 96 && charCode < 123) || charCode == 8 || charCode == 32 || charCode == 9 || charCode == 0)
  980. return true;
  981. else
  982. return false;
  983. }
  984. catch (err) {
  985. alert(err.Description);
  986. }
  987. }
  988. function MakeNumericContactNoIdNo(obj, e) {
  989. var evtobj = window.event ? event : e;
  990. if (evtobj.altKey || evtobj.ctrlKey)
  991. return true;
  992. var charCode = e.which || e.keyCode;
  993. if (charCode == 46 || charCode == 8 || charCode == 9 || charCode == 37 || charCode == 39 || charCode == 109 || charCode == 189 || charCode == 111 || charCode == 109)
  994. return true;
  995. var char = String.fromCharCode(charCode);
  996. if (!isNaN(char))
  997. return true;
  998. if ((char >= "0" && char <= "9") || (charCode >= 96 && charCode <= 105 || charCode == 173 || charCode == 191 || charCode == 189 || charCode == 111 || charCode == 109))
  999. return true;
  1000. return false;
  1001. }
  1002. function isInt(value) {
  1003. if (isNaN(value)) {
  1004. return false;
  1005. }
  1006. var x = parseFloat(value);
  1007. return (x | 0) === x;
  1008. }
  1009. function ContactNoValidation(obj) {
  1010. var rIdNo = obj.value;
  1011. var isIntegerVal = isInt(rIdNo);
  1012. if (isIntegerVal == true) {
  1013. var rIdN = parseInt(rIdNo);
  1014. if (rIdN == 0) {
  1015. rIdNo = rIdN;
  1016. }
  1017. }
  1018. if (rIdNo === 0 || rIdNo === "0" || rIdNo === "00" || rIdNo === "1234" || rIdNo.length < 6 || rIdNo.length > 10) {
  1019. alert("Invalid Input.");
  1020. obj.value = "";
  1021. obj.focus();
  1022. return false;
  1023. }
  1024. return true;
  1025. }
  1026. function IdNoValidation(obj) {
  1027. var rIdNo = obj.value;
  1028. var isIntegerVal = isInt(rIdNo);
  1029. if (isIntegerVal == true) {
  1030. var rIdN = parseInt(rIdNo);
  1031. if (rIdN == 0) {
  1032. rIdNo = rIdN;
  1033. }
  1034. }
  1035. if (rIdNo === 0 || rIdNo === "0" || rIdNo === "1234") {
  1036. alert("Invalid Input.");
  1037. obj.value = "";
  1038. obj.focus();
  1039. return false;
  1040. }
  1041. return true;
  1042. }
  1043. function OpenInNewWindowWithCallBack(url, param, callback) {
  1044. if (param == undefined || param == "")
  1045. param = "width=825,height=500,resizable=1,status=1,toolbar=0,scrollbars=1,center=1";
  1046. var res = window.open(url, "", param);
  1047. if (typeof (callback) == "function") {
  1048. try {
  1049. res.attachEvent("onbeforeunload", callback);
  1050. }
  1051. catch (err) {
  1052. res.onbeforeunload = callback;
  1053. }
  1054. }
  1055. }
  1056. // Supports alphabets and numbers no special characters except underscore('_') min 3 and max 20 characters.
  1057. var validchars = /^[A-Za-z0-9\/\\ -]{1,20}$/;
  1058. function checkIfValidChars(strValue) {
  1059. try {
  1060. //1) All alphanumeric characters should be accepted {A to Z, a to z, 0 to 9 and Special character - / \
  1061. if (!validchars.test(strValue)) {
  1062. alert("Cheque number you provided is invalid.");
  1063. return false;
  1064. }
  1065. }
  1066. catch (err) {
  1067. alert(err);
  1068. }
  1069. return true;
  1070. }
  1071. function checkIfAllCharIsSame(strValue) {
  1072. try {
  1073. // 2) Should not allow all characters or all zero as cheque number ( AAAAAA, BBBBBBB, aaaaaa, bbbbbb, 00000000)
  1074. if (strValue.length > 1) {
  1075. var charToCompare = strValue[0];
  1076. var isAllCharSame = true;
  1077. for (var i = 0; i < strValue.length; i++) {
  1078. if (charToCompare != strValue[i]) {
  1079. isAllCharSame = false;
  1080. break;
  1081. }
  1082. }
  1083. if (isAllCharSame) {
  1084. alert("Cheque number you provided is invalid.");
  1085. return false;
  1086. }
  1087. }
  1088. }
  1089. catch (err) {
  1090. alert(err);
  1091. }
  1092. return true;
  1093. }
  1094. function checkIfFistCharIsValid(strValue) {
  1095. try {
  1096. //3) Cheque number cannot be started with - / \
  1097. if (strValue == "-" || strValue == "/" || strValue == "\\") {
  1098. alert("Cheque number cannot started with this value [-/\\].");
  1099. return false;
  1100. }
  1101. }
  1102. catch (err) {
  1103. alert(err);
  1104. }
  1105. return true;
  1106. }
  1107. function checkIfCharsRepeated(strValue) {
  1108. try {
  1109. // Cheque number cannot have values in repetition followed by ( -- // \\ -/ /- -\ \- /\ \/ )
  1110. if (strValue.length > 1) {
  1111. var charToCompare = "-- // \\\\ -/ /- -\\ \\- /\\ \\/".split(" ");
  1112. var isCharRepeated = false;
  1113. for (var i = 0; i < charToCompare.length && !isCharRepeated; i++) {
  1114. for (var j = 0; j < strValue.length - 1; j++) {
  1115. // abc\/f-
  1116. if (charToCompare[i] == strValue.substring(j, j + 2)) {
  1117. isCharRepeated = true;
  1118. break;
  1119. }
  1120. }
  1121. }
  1122. if (isCharRepeated) {
  1123. alert("Cheque number you provided is invalid.");
  1124. return false;
  1125. }
  1126. }
  1127. }
  1128. catch (err) {
  1129. alert(err);
  1130. }
  1131. return true;
  1132. }
  1133. function ValidRequiredField(RequiredField) {
  1134. var Isvalid = true;
  1135. var OtherPersonFld = new Array;
  1136. var fld = RequiredField.split(',');
  1137. for (n = 0; n < fld.length - 1; n++) {
  1138. OtherPersonFld[n] = fld[n];
  1139. }
  1140. for (i = 0; i < OtherPersonFld.length; i++) {
  1141. GetElement(OtherPersonFld[i]).style.background = "#FFFFFF";
  1142. var a = GetElement(OtherPersonFld[i]).value;
  1143. if (GetElement(OtherPersonFld[i]).value == "") {
  1144. GetElement(OtherPersonFld[i]).style.background = "#FFCCD2";
  1145. Isvalid = false;
  1146. }
  1147. }
  1148. if (Isvalid == false) {
  1149. alert("Required Field(s)\n _____________________________ \n The red fields are required!")
  1150. }
  1151. return Isvalid;
  1152. }
  1153. //END MASKING VALIDATION
  1154. function ValidRequiredFieldAC(RequiredField) {
  1155. var Isvalid = true;
  1156. var OtherPersonFld = new Array;
  1157. var fld = RequiredField.split(',');
  1158. for (n = 0; n < fld.length - 1; n++) {
  1159. OtherPersonFld[n] = fld[n];
  1160. }
  1161. for (i = 0; i < OtherPersonFld.length; i++) {
  1162. GetElement(OtherPersonFld[i]).style.background = "#FFFFFF";
  1163. if (GetElement(OtherPersonFld[i]).value == "") {
  1164. GetElement(OtherPersonFld[i]).style.background = "#FFCCD2";
  1165. Isvalid = false;
  1166. }
  1167. }
  1168. if (Isvalid == false) {
  1169. alert("Required Field(s)\n _____________________________ \n The red fields are required!")
  1170. }
  1171. return Isvalid;
  1172. }
  1173. //function DateValidation() {
  1174. // var pattern = "/^(19[0-9][0-9]|20[0-4][0-9]|3050)[/](0?[1-9]|1[0-2])[/](0?[1-9]|[12][0-9]|3[02])$/";
  1175. // var date = .getElementsByClassName('.hasDatepicker');
  1176. // if ((date.test(pattern))) {
  1177. // alert("Date " + date);
  1178. // }
  1179. //}