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.

408 lines
17 KiB

  1. var dtFormat = "dd-mm-yy";
  2. //if (window.opener && !window.opener.closed) {
  3. // dtFormat = window.opener.getAgentDTFormat();
  4. //}
  5. //else {
  6. // dtFormat = window.parent.getAgentDTFormat();
  7. //}
  8. //////alert(dtFormat);
  9. function ShowCalDefault(cal) {
  10. $(document).ready(function () {
  11. $(function () {
  12. $(cal).datepicker({
  13. changeMonth: true,
  14. changeYear: true,
  15. dateFormat: dtFormat,
  16. showOn: "button",
  17. buttonImage: "/ukime/images/calendar.gif",
  18. buttonImageOnly: true,
  19. maxDate: "-0D",
  20. onClose: function () {
  21. this.focus();
  22. }
  23. });
  24. });
  25. });
  26. }
  27. function CalReceiverDOB(cal) {
  28. $(function () {
  29. $(cal).datepicker({
  30. changeMonth: true,
  31. changeYear: true,
  32. dateFormat: dtFormat,
  33. showOn: "both",
  34. buttonImage: "/ukime/images/calendar.gif",
  35. buttonImageOnly: true,
  36. yearRange: "-90:-18", //18 years or older up until 115yo (oldest person ever, can be sensibly set to something much smaller in most cases)
  37. maxDate: "-18Y", //Will only allow the selection of dates more than 18 years ago, useful if you need to restrict this
  38. minDate: "-90Y",
  39. onClose: function (x, y) {
  40. $("#txtRecMobile").focus();
  41. }
  42. });
  43. });
  44. }
  45. function CalFromToday(cal) {
  46. $(function () {
  47. $(cal).datepicker({
  48. changeMonth: true,
  49. changeYear: true,
  50. dateFormat: dtFormat,
  51. showOn: "both",
  52. buttonImage: "/ukime/images/calendar.gif",
  53. buttonImageOnly: true,
  54. yearRange: "-90:-18", //18 years or older up until 115yo (oldest person ever, can be sensibly set to something much smaller in most cases)
  55. maxDate: "+10Y", //Will only allow the selection of dates more than 18 years ago, useful if you need to restrict this
  56. minDate: "+0",
  57. onClose: function (x, y) {
  58. $("#txtRecMobile").focus();
  59. }
  60. });
  61. });
  62. }
  63. function CalFromYesterdayToToday(cal) {
  64. $(function () {
  65. $(cal).datepicker({
  66. changeMonth: true,
  67. changeYear: true,
  68. dateFormat: dtFormat,
  69. showOn: "both",
  70. buttonImage: "/ukime/images/calendar.gif",
  71. buttonImageOnly: true,
  72. yearRange: "-90:-18", //18 years or older up until 115yo (oldest person ever, can be sensibly set to something much smaller in most cases)
  73. maxDate: "+0", //Will only allow the selection of dates more than 18 years ago, useful if you need to restrict this
  74. minDate: "-1",
  75. onClose: function (x, y) {
  76. $("#txtRecMobile").focus();
  77. }
  78. });
  79. });
  80. }
  81. function CalUpToToday(cal) {
  82. $(function () {
  83. $(cal).datepicker({
  84. changeMonth: true,
  85. changeYear: true,
  86. dateFormat: dtFormat,
  87. showOn: "both",
  88. buttonImage: "/ukime/images/calendar.gif",
  89. buttonImageOnly: true,
  90. // yearRange: "-90:-18", //18 years or older up until 115yo (oldest person ever, can be sensibly set to something much smaller in most cases)
  91. maxDate: "+0", //Will only allow the selection of dates more than 18 years ago, useful if you need to restrict this
  92. minDate: "-3Y",
  93. onClose: function (x, y) {
  94. $("#txtRecMobile").focus();
  95. }
  96. });
  97. });
  98. }
  99. //function CalSenderDOB(cal) {
  100. // $(function () {
  101. // $(cal).datepicker({
  102. // changeMonth: true,
  103. // changeYear: true,
  104. // dateFormat: dtFormat,
  105. // showOn: "both",
  106. // buttonImage: "/ukime/images/calendar.gif",
  107. // buttonImageOnly: true,
  108. // yearRange: "-90:-16", //16 years or older up until 115yo (oldest person ever, can be sensibly set to something much smaller in most cases)
  109. // maxDate: "-16Y", //Will only allow the selection of dates more than 16 years ago, useful if you need to restrict this
  110. // minDate: "-90Y",
  111. // onClose: function (x, y) {
  112. // //$("#txtSendMobile").focus();
  113. // }
  114. // });
  115. // });
  116. //}
  117. function CalIdIssueDate(cal) {
  118. $(function () {
  119. $(cal).datepicker({
  120. changeMonth: true,
  121. changeYear: true,
  122. dateFormat: dtFormat,
  123. showOn: "both",
  124. buttonImage: "/ukime/images/calendar.gif",
  125. buttonImageOnly: true,
  126. //yearRange: "-18", //18 years or older up until 115yo (oldest person ever, can be sensibly set to something much smaller in most cases)
  127. maxDate: "0Y", //Will only allow the selection of dates more than 18 years ago, useful if you need to restrict this
  128. minDate: "-90Y",
  129. onClose: function (x, y) {
  130. //$("#txtSendIdIssueDate").focus();
  131. }
  132. });
  133. });
  134. }
  135. function VisaValidDate(cal) {
  136. $(function () {
  137. $(cal).datepicker({
  138. changeMonth: true,
  139. changeYear: true,
  140. dateFormat: dtFormat,
  141. showOn: "both",
  142. buttonImage: "/ukime/images/calendar.gif",
  143. buttonImageOnly: true,
  144. //yearRange: "-60:-18", //18 years or older up until 115yo (oldest person ever, can be sensibly set to something much smaller in most cases)
  145. maxDate: "+10Y", //Will only allow the selection of dates more than 18 years ago, useful if you need to restrict this
  146. minDate: "+1",
  147. onClose: function () {
  148. this.focus();
  149. }
  150. });
  151. });
  152. }
  153. function VisaValidDateSend(cal) {
  154. $(function () {
  155. $(cal).datepicker({
  156. changeMonth: true,
  157. changeYear: true,
  158. dateFormat: dtFormat,
  159. showOn: "both",
  160. buttonImage: "/ukime/images/calendar.gif",
  161. buttonImageOnly: true,
  162. //yearRange: "-60:-18", //18 years or older up until 115yo (oldest person ever, can be sensibly set to something much smaller in most cases)
  163. maxDate: "+10Y", //Will only allow the selection of dates more than 18 years ago, useful if you need to restrict this
  164. minDate: "+1",
  165. onClose: function (x, y) {
  166. //$("#txtSendMobile").focus();
  167. }
  168. });
  169. });
  170. }
  171. function VisaValidDateRec(cal) {
  172. $(function () {
  173. $(cal).datepicker({
  174. changeMonth: true,
  175. changeYear: true,
  176. dateFormat: dtFormat,
  177. showOn: "both",
  178. buttonImage: "/ukime/images/calendar.gif",
  179. buttonImageOnly: true,
  180. //yearRange: "-60:-18", //18 years or older up until 115yo (oldest person ever, can be sensibly set to something much smaller in most cases)
  181. maxDate: "+10Y", //Will only allow the selection of dates more than 18 years ago, useful if you need to restrict this
  182. minDate: "+1",
  183. onClose: function (x, y) {
  184. $("#txtRecMobile").focus();
  185. }
  186. });
  187. });
  188. }
  189. function ShowCalFromTo(calFrom, calTo, nom) {
  190. if (nom == null || nom == "" || nom == undefined) nom = 1;
  191. $(function () {
  192. if (calFrom !== undefined && calFrom.length > 0) {
  193. $(calFrom).datepicker({
  194. //defaultDate: "+1w",
  195. changeMonth: true,
  196. changeYear: true,
  197. numberOfMonths: 1,
  198. showOn: "both",
  199. dateFormat: dateFormatType,
  200. //buttonImage: imgPath,
  201. // buttonImageOnly: true,
  202. maxDate: "+0",
  203. minDate: "-2Y",
  204. onSelect: function (selectedDate) {
  205. $(calTo).datepicker("option", "minDate", selectedDate);
  206. }
  207. });
  208. var fromDateIdNameOnly = calFrom.split('#')[1];
  209. document.getElementById(fromDateIdNameOnly).setAttribute("onchange", "return DateValidation('" + fromDateIdNameOnly + "','t')");
  210. }
  211. if (calTo !== undefined && calTo.length > 0) {
  212. $(calTo).datepicker({
  213. //defaultDate: "+1w",
  214. changeMonth: true,
  215. changeYear: true,
  216. numberOfMonths: nom,
  217. showOn: "both",
  218. //buttonImage: imgPath,
  219. //buttonImageOnly: true,
  220. dateFormat: dateFormatType,
  221. maxDate: "+0",
  222. minDate: "-2Y",
  223. onSelect: function (selectedDate) {
  224. $(calFrom).datepicker("option", "maxDate", selectedDate);
  225. }
  226. });
  227. var fromDateIdNameOnly = calFrom.split('#')[1];
  228. if (calTo !== undefined && calTo.length > 0) {
  229. document.getElementById(fromDateIdNameOnly).removeAttribute("onchange");
  230. toDateIdNameOnly = calTo.split("#")[1];
  231. document.getElementById(fromDateIdNameOnly).setAttribute("onchange", "return DateValidation('" + fromDateIdNameOnly + "','t','" + toDateIdNameOnly + "')");
  232. document.getElementById(toDateIdNameOnly).setAttribute("onchange", "return DateValidation('" + fromDateIdNameOnly + "','t','" + toDateIdNameOnly + "')");
  233. }
  234. }
  235. });
  236. }
  237. function ShowCalFromToUpToTodayForInput(calFrom, calTo, nom) {
  238. if (nom == null || nom == "" || nom == undefined) nom = 1;
  239. $(function () {
  240. var fromDateIdNameOnly = calFrom.split('#')[1];
  241. var selectedDate = $(calFrom).val();
  242. if (selectedDate.length > 0) {
  243. $(calTo).datepicker("option", "minDate", selectedDate);
  244. document.getElementById(fromDateIdNameOnly).setAttribute("onchange", "return DateValidation('" + fromDateIdNameOnly + "','t')");
  245. }
  246. if (calTo !== undefined) {
  247. var toDate = $(calTo).val();
  248. if (toDate.length > 0) {
  249. $(calFrom).datepicker("option", "maxDate", toDate);
  250. }
  251. if (calTo !== undefined && calTo.length > 0) {
  252. document.getElementById(fromDateIdNameOnly).removeAttribute("onchange");
  253. toDateIdNameOnly = calTo.split("#")[1];
  254. document.getElementById(fromDateIdNameOnly).setAttribute("onchange", "return DateValidation('" + fromDateIdNameOnly + "','t','" + toDateIdNameOnly + "')");
  255. document.getElementById(toDateIdNameOnly).setAttribute("onchange", "return DateValidation('" + fromDateIdNameOnly + "','t','" + toDateIdNameOnly + "')");
  256. }
  257. }
  258. });
  259. }
  260. //// Input Date Validation
  261. function DateValidation(id, typeVal, compareId, compareTypeVal) {
  262. var firstDate = '';
  263. var firstId = id;
  264. var inputDate = document.getElementById(id).value;
  265. var dates = inputDate.split("-");
  266. if (id != undefined && id.length > 0 && inputDate.length > 0) {
  267. if (dates.length == 3 && dates[0].length == 4 && dates[1].length <= 2 && dates[1] > 0 && dates[1] <= 12 && dates[2].length <= 2 && dates[2] > 0 && dates[2] <= 31) {
  268. var currentDate = new Date(Date.now()).toLocaleDateString();
  269. var currentDates = currentDate.split('/');
  270. if (dates[1] <= 9 && dates[1].length <= 1) {
  271. dates[1] = '0' + dates[1];
  272. }
  273. if (dates[2] <= 9 && dates[2].length <= 1) {
  274. dates[2] = '0' + dates[2];
  275. }
  276. if (currentDates[0] <= 9 && currentDates[0].length <= 1) {
  277. currentDates[0] = '0' + currentDates[0];
  278. }
  279. if (currentDates[1] <= 9 && currentDates[1].length <= 1) {
  280. currentDates[1] = '0' + currentDates[1];
  281. }
  282. inputDate = dates[0] + "-" + dates[1] + "-" + dates[2];
  283. currentDate = currentDates[2] + '-' + currentDates[0] + '-' + currentDates[1];
  284. if (typeVal == "dob") {
  285. CalSenderDOB("#" + id);
  286. var dobValidDate = currentDates[2] - 16 + '-' + currentDates[0] + '-' + currentDates[1];
  287. if (inputDate <= dobValidDate) {
  288. }
  289. else {
  290. SetValueById(id, '', '');
  291. alert("Date Of Birth Must Be At Least 16 Years Old.");
  292. return document.getElementById(id).focus();
  293. }
  294. }
  295. else if (typeVal == "t") {
  296. ShowCalFromToUpToToday("#" + id);
  297. var ValidDate = currentDates[2] - 2 + '-' + currentDates[0] + '-' + currentDates[1];
  298. if (inputDate < ValidDate) {
  299. SetValueById(id, '', '');
  300. return document.getElementById(id).focus();
  301. }
  302. if (inputDate > currentDate) {
  303. SetValueById(id, '', '');
  304. alert("You Cannot Input Future Date.");
  305. return document.getElementById(id).focus();
  306. }
  307. }
  308. else if (typeVal == "f") {
  309. AllowFutureDate("#" + id);
  310. if (inputDate < currentDate) {
  311. SetValueById(id, '', '');
  312. alert("You Cannot Input Past Date.");
  313. return document.getElementById(id).focus();
  314. }
  315. }
  316. else if (typeVal == "i") {
  317. CalTillToday("#" + id);
  318. if (inputDate > currentDate) {
  319. SetValueById(id, '', '');
  320. alert("You Cannot Input Future Date.");
  321. return document.getElementById(id).focus();
  322. }
  323. }
  324. firstDate = inputDate;
  325. $("#" + id).val(inputDate);
  326. }
  327. else {
  328. SetValueById(id, '');
  329. alert("Invalid Date Format ! Please Enter yyyy-mm-dd format");
  330. return document.getElementById(id).focus();
  331. }
  332. }
  333. if (compareId != undefined && compareId.length > 0) {
  334. var compareDate = document.getElementById(compareId).value;
  335. if (compareDate.length > 0) {
  336. if (compareTypeVal !== undefined && compareTypeVal.length > 0) {
  337. typeVal = '';
  338. typeVal = compareTypeVal;
  339. }
  340. var dates = compareDate.split("-");
  341. if (dates.length == 3 && dates[0].length == 4 && dates[1].length <= 2 && dates[1] > 0 && dates[1] <= 12 && dates[2].length <= 2 && dates[2] > 0 && dates[2] <= 31) {
  342. var currentDate = new Date(Date.now()).toLocaleDateString();
  343. var currentDates = currentDate.split('/');
  344. if (dates[1] <= 9 && dates[1].length <= 1) {
  345. dates[1] = '0' + dates[1];
  346. }
  347. if (dates[2] <= 9 && dates[2].length <= 1) {
  348. dates[2] = '0' + dates[2];
  349. }
  350. if (currentDates[0] <= 9 && currentDates[0].length <= 1) {
  351. currentDates[0] = '0' + currentDates[0];
  352. }
  353. if (currentDates[1] <= 9 && currentDates[1].length <= 1) {
  354. currentDates[1] = '0' + currentDates[1];
  355. }
  356. compareDate = dates[0] + "-" + dates[1] + "-" + dates[2];
  357. currentDate = currentDates[2] + '-' + currentDates[0] + '-' + currentDates[1];
  358. if (typeVal == "t") {
  359. var ValidDate = currentDates[2] - 2 + '-' + currentDates[0] + '-' + currentDates[1];
  360. if (compareDate < ValidDate) {
  361. SetValueById(compareId, '', '');
  362. compareDate = '';
  363. document.getElementById(compareId).focus();
  364. }
  365. if (compareDate > currentDate) {
  366. SetValueById(compareId, '', '');
  367. compareDate = '';
  368. alert("You Cannot Input Future Date.");
  369. document.getElementById(compareId).focus();
  370. }
  371. }
  372. if (firstDate.length === 10) {
  373. if (firstDate > compareDate) {
  374. SetValueById(compareId, '');
  375. compareDate = '';
  376. alert("To Date Must Be Greater Or Equal To From Date");
  377. document.getElementById(id).focus();
  378. }
  379. }
  380. $("#" + compareId).val(compareDate);
  381. }
  382. else {
  383. SetValueById(compareId, '');
  384. alert("Invalid Date Format ! Please Enter yyyy-mm-dd format");
  385. return document.getElementById(compareId).focus();
  386. }
  387. }
  388. ShowCalFromToUpToTodayForInput("#" + id, "#" + compareId);
  389. }
  390. }