Built files from Bizgaze WebServer
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.

leaves.js 25KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333
  1. var Bizgaze;
  2. (function (Bizgaze) {
  3. let Apps;
  4. (function (Apps) {
  5. let Hrms;
  6. (function (Hrms) {
  7. let Components;
  8. (function (Components) {
  9. class Leaves extends Unibase.Platform.Core.BaseComponent {
  10. loaddata(fromdate, todate, employeeid, leavetypeid, totalDayPropertyId, durationProperyId, totaldaysleavehistoryProperyId) {
  11. var instance = this;
  12. var fdate = moment(fromdate.replaceAll("/", "-"), "DD/MM/YYYY").format("YYYY/MM/DD");
  13. var tdate = moment(todate.replaceAll("/", "-"), "DD/MM/YYYY").format("YYYY/MM/DD");
  14. var iWeeks = 0;
  15. var iDateDiff = 0;
  16. var iAdjust = 0;
  17. var dd;
  18. instance.fileCacheHelper.loadJsFiles(["apps/hrms/components/leavetype.js", "apps/hrms/managers/leavemanager.js", "apps/hrms/managers/leavemanager.js", "apps/hrms/enums/leavetypes.js"], function () {
  19. Bizgaze.Apps.Hrms.Managers.LeaveManager.Instance().getleavescountData(employeeid, leavetypeid).then(function (response) {
  20. var totaldays = 0;
  21. var result = "";
  22. if (response.result != null && response.result != "") {
  23. result = response.result;
  24. totaldays = response.result.totaldays;
  25. }
  26. Bizgaze.Apps.Hrms.Managers.LeaveManager.Instance().Getleavetypedata(leavetypeid).then(function (response) {
  27. if (response.result != null && response.result != "") {
  28. result = response.result;
  29. var fromvalidity = response.result.fromvalidity;
  30. var accuraldate = response.result.accuraldate;
  31. var mothname = response.result.mothname;
  32. var jan = response.result.jan;
  33. var feb = response.result.feb;
  34. var mar = response.result.mar;
  35. var apr = response.result.apr;
  36. var may = response.result.may;
  37. var jun = response.result.jun;
  38. var jul = response.result.jul;
  39. var aug = response.result.aug;
  40. var sep = response.result.sep;
  41. var oct = response.result.oct;
  42. var nov = response.result.nov;
  43. var dec = response.result.dec;
  44. var jantojun = response.result.jantojun;
  45. var jultodec = response.result.jultodec;
  46. var jantoaprl = response.result.jantoaprl;
  47. var maytoaug = response.result.maytoaug;
  48. var septodec = response.result.septodec;
  49. }
  50. var leaveType = Hrms.Enums.LeaveTypes.None;
  51. if (jan != 0 || feb != 0 || mar != 0 || apr != 0 || may != 0 || jun != 0 || jul != 0 || aug != 0 || sep != 0 || oct != 0 || nov != 0 || dec != 0) {
  52. leaveType = Hrms.Enums.LeaveTypes.Monthly;
  53. }
  54. else if (jantojun != 0 || jultodec != 0) {
  55. leaveType = Hrms.Enums.LeaveTypes.HalfYearly;
  56. }
  57. else if (jantoaprl != 0 || maytoaug != 0 || septodec != 0) {
  58. leaveType = Hrms.Enums.LeaveTypes.Quarterly;
  59. }
  60. var leavefromyear = moment(fdate, "YYYY/MM/DD").year();
  61. var leavefromonth = 1 + moment(fdate, "YYYY/MM/DD").month();
  62. var leavefromdate = moment(fdate, "YYYY/MM/DD").date();
  63. var leavetodateyear = moment(tdate, "YYYY/MM/DD").year();
  64. var leavetodatemonth = 1 + moment(tdate, "YYYY/MM/DD").month();
  65. var leavetodate = moment(tdate, "YYYY/MM/DD").date();
  66. var months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
  67. var month = months.indexOf(mothname);
  68. todate = new Date(tdate);
  69. fromdate = new Date(fdate);
  70. if (todate < fromdate)
  71. return 0;
  72. var iWeekday1 = fromdate.getDay();
  73. var iWeekday2 = todate.getDay();
  74. iWeekday1 = (iWeekday1 == 0) ? 7 : iWeekday1;
  75. iWeekday2 = (iWeekday2 == 0) ? 7 : iWeekday2;
  76. if ((iWeekday1 > 5) && (iWeekday2 > 5))
  77. iAdjust = 1;
  78. iWeekday1 = (iWeekday1 > 5) ? 5 : iWeekday1;
  79. iWeekday2 = (iWeekday2 > 5) ? 5 : iWeekday2;
  80. iWeeks = Math.floor((todate.getTime() - fromdate.getTime()) / 604800000);
  81. if (iWeekday1 < iWeekday2) {
  82. iDateDiff = (iWeeks * 5) + (iWeekday2 - iWeekday1);
  83. }
  84. if ((leavefromyear == leavetodateyear) && (leavefromonth == leavetodatemonth) && (leavefromdate == leavetodate)) {
  85. if (iWeekday1 == iWeekday2) {
  86. iDateDiff = 0;
  87. }
  88. }
  89. else if (fromdate != todate) {
  90. if (iWeekday1 == iWeekday2) {
  91. iDateDiff = ((0 + 1) * 5) - (iWeekday1 - iWeekday2);
  92. }
  93. else if (iWeekday1 != iWeekday2) {
  94. iDateDiff = ((iWeeks + 1) * 5) - (iWeekday1 - iWeekday2);
  95. }
  96. }
  97. else {
  98. iDateDiff = ((iWeeks + 1) * 5) - (iWeekday1 - iWeekday2);
  99. }
  100. iDateDiff -= iAdjust;
  101. dd = iDateDiff + 1;
  102. if (totaldays > 0) {
  103. dd = dd + totaldays;
  104. }
  105. $("#" + totalDayPropertyId).val(dd);
  106. $("#" + totaldaysleavehistoryProperyId).val(dd);
  107. var FulDay = dd + " " + "Days";
  108. var HalfDay = "HalfDay";
  109. var QuaterDay = "QuaterDay";
  110. var Hourly = "Hourly";
  111. var duration = Number($("#" + durationProperyId).val());
  112. if (duration == 1) {
  113. if (leaveType == Hrms.Enums.LeaveTypes.Monthly) {
  114. if (leavefromonth == 1 && leavetodatemonth == 1) {
  115. var jan = response.result.jan;
  116. if (dd <= jan) {
  117. alert("these days are applicable for this month");
  118. $("#divSectionProperties_Totalcountdays_ActionProperty").html(FulDay);
  119. }
  120. else {
  121. alert("these days are not applicable for this month");
  122. $("#divSectionProperties_Totalcountdays_ActionProperty").html("");
  123. }
  124. }
  125. else if (leavefromonth == 2 && leavetodatemonth == 2) {
  126. var feb = response.result.feb;
  127. if (dd <= feb) {
  128. alert("these days are applicable for this month");
  129. $("#divSectionProperties_Totalcountdays_ActionProperty").html(FulDay);
  130. }
  131. else {
  132. alert("these days are not applicable for this month");
  133. $("#divSectionProperties_Totalcountdays_ActionProperty").html("");
  134. }
  135. }
  136. else if (leavefromonth == 3 && leavetodatemonth == 3) {
  137. var mar = response.result.mar;
  138. if (dd <= mar) {
  139. alert("these days are applicable for this month");
  140. $("#divSectionProperties_Totalcountdays_ActionProperty").html(FulDay);
  141. }
  142. else {
  143. alert("these days are not applicable for this month");
  144. $("#divSectionProperties_Totalcountdays_ActionProperty").html("");
  145. }
  146. }
  147. else if (leavefromonth == 4 && leavetodatemonth == 4) {
  148. var apr = response.result.apr;
  149. if (dd <= apr) {
  150. alert("these days are applicable for this month");
  151. $("#divSectionProperties_Totalcountdays_ActionProperty").html(FulDay);
  152. }
  153. else {
  154. alert("these days are not applicable for this month");
  155. $("#divSectionProperties_Totalcountdays_ActionProperty").html("");
  156. }
  157. }
  158. else if (leavefromonth == 5 && leavetodatemonth == 5) {
  159. var may = response.result.may;
  160. if (dd <= may) {
  161. alert("these days are applicable for this month");
  162. $("#divSectionProperties_Totalcountdays_ActionProperty").html(FulDay);
  163. }
  164. else {
  165. alert("these days are not applicable for this month");
  166. $("#divSectionProperties_Totalcountdays_ActionProperty").html("");
  167. }
  168. }
  169. else if (leavefromonth == 6 && leavetodatemonth == 6) {
  170. var jun = response.result.jun;
  171. if (dd <= jun) {
  172. alert("these days are applicable for this month");
  173. $("#divSectionProperties_Totalcountdays_ActionProperty").html(FulDay);
  174. }
  175. else {
  176. alert("these days are not applicable for this month");
  177. $("#divSectionProperties_Totalcountdays_ActionProperty").html("");
  178. }
  179. }
  180. else if (leavefromonth == 7 && leavetodatemonth == 7) {
  181. var jul = response.result.jul;
  182. if (dd <= jul) {
  183. alert("these days are applicable for this month");
  184. $("#divSectionProperties_Totalcountdays_ActionProperty").html(FulDay);
  185. }
  186. else {
  187. alert("these days are not applicable for this month");
  188. $("#divSectionProperties_Totalcountdays_ActionProperty").html("");
  189. }
  190. }
  191. else if (leavefromonth == 8 && leavetodatemonth == 8) {
  192. var aug = response.result.aug;
  193. if (dd <= aug) {
  194. alert("these days are applicable for this month");
  195. $("#divSectionProperties_Totalcountdays_ActionProperty").html(FulDay);
  196. }
  197. else {
  198. alert("these days are not applicable for this month");
  199. $("#divSectionProperties_Totalcountdays_ActionProperty").html("");
  200. }
  201. }
  202. else if (leavefromonth == 9 && leavetodatemonth == 9) {
  203. var sep = response.result.sep;
  204. if (dd <= sep) {
  205. alert("these days are applicable for this month");
  206. $("#divSectionProperties_Totalcountdays_ActionProperty").html(FulDay);
  207. }
  208. else {
  209. alert("these days are not applicable for this month");
  210. $("#divSectionProperties_Totalcountdays_ActionProperty").html("");
  211. }
  212. }
  213. else if (leavefromonth == 10 && leavetodatemonth == 10) {
  214. var oct = response.result.oct;
  215. if (dd <= oct) {
  216. alert("these days are applicable for this month");
  217. $("#divSectionProperties_Totalcountdays_ActionProperty").html(FulDay);
  218. }
  219. else {
  220. alert("these days are not applicable for this month");
  221. $("#divSectionProperties_Totalcountdays_ActionProperty").html("");
  222. }
  223. }
  224. else if (leavefromonth == 11 && leavetodatemonth == 11) {
  225. var nov = response.result.nov;
  226. if (dd <= nov) {
  227. alert("these days are applicable for this month");
  228. $("#divSectionProperties_Totalcountdays_ActionProperty").html(FulDay);
  229. }
  230. else {
  231. alert("these days are not applicable for this month");
  232. $("#divSectionProperties_Totalcountdays_ActionProperty").html("");
  233. }
  234. }
  235. else if (leavefromonth == 12 && leavetodatemonth == 12) {
  236. var dec = response.result.dec;
  237. if (dd <= dec) {
  238. alert("these days are applicable for this month");
  239. $("#divSectionProperties_Totalcountdays_ActionProperty").html(FulDay);
  240. }
  241. else {
  242. alert("these days are not applicable for this month");
  243. $("#divSectionProperties_Totalcountdays_ActionProperty").html("");
  244. }
  245. }
  246. }
  247. else if (leaveType == Hrms.Enums.LeaveTypes.HalfYearly) {
  248. if (leavefromonth == 1 || leavetodatemonth <= 6) {
  249. var jantojun = response.result.jantojun;
  250. if (dd <= jantojun) {
  251. alert("these days are applicable for this month");
  252. $("#divSectionProperties_Totalcountdays_ActionProperty").html(FulDay);
  253. }
  254. else {
  255. alert("these days are not applicable for this month");
  256. $("#divSectionProperties_Totalcountdays_ActionProperty").html("");
  257. }
  258. }
  259. else if (leavefromonth == 7 || leavetodatemonth <= 12) {
  260. var jultodec = response.result.jultodec;
  261. if (dd <= jultodec) {
  262. alert("these days are applicable for this month");
  263. $("#divSectionProperties_Totalcountdays_ActionProperty").html(FulDay);
  264. }
  265. else {
  266. alert("these days are not applicable for this month");
  267. $("#divSectionProperties_Totalcountdays_ActionProperty").html("");
  268. }
  269. }
  270. }
  271. else if (leaveType == Hrms.Enums.LeaveTypes.Quarterly) {
  272. if (leavefromonth == 1 || leavetodatemonth <= 4) {
  273. var jantoaprl = response.result.jantoaprl;
  274. if (dd <= jantoaprl) {
  275. alert("these days are applicable for this month");
  276. $("#divSectionProperties_Totalcountdays_ActionProperty").html(FulDay);
  277. }
  278. else {
  279. alert("these days are not applicable for this month");
  280. $("#divSectionProperties_Totalcountdays_ActionProperty").html("");
  281. }
  282. }
  283. else if (leavefromonth == 5 || leavetodatemonth <= 8) {
  284. var maytoaug = response.result.maytoaug;
  285. if (dd <= maytoaug) {
  286. alert("these days are applicable for this month");
  287. $("#divSectionProperties_Totalcountdays_ActionProperty").html(FulDay);
  288. }
  289. else {
  290. alert("these days are not applicable for this month");
  291. $("#divSectionProperties_Totalcountdays_ActionProperty").html("");
  292. }
  293. }
  294. else if (leavefromonth == 9 || leavetodatemonth <= 12) {
  295. var septodec = response.result.septodec;
  296. if (dd <= septodec) {
  297. alert("these days are applicable for this month");
  298. $("#divSectionProperties_Totalcountdays_ActionProperty").html(FulDay);
  299. }
  300. else {
  301. alert("these days are not applicable for this month");
  302. $("#divSectionProperties_Totalcountdays_ActionProperty").html("");
  303. }
  304. }
  305. else {
  306. alert("these days are not applicable for this month");
  307. }
  308. }
  309. }
  310. else if (duration == 2) {
  311. $("#divSectionProperties_Totalcountdays_ActionProperty").html(Hourly);
  312. }
  313. else if (duration == 3) {
  314. $("#divSectionProperties_Totalcountdays_ActionProperty").html(QuaterDay);
  315. }
  316. else if (duration == 4) {
  317. $("#divSectionProperties_Totalcountdays_ActionProperty").html(HalfDay);
  318. }
  319. });
  320. });
  321. });
  322. }
  323. static Instance() {
  324. if (this._instance === undefined)
  325. this._instance = new Leaves();
  326. return this._instance;
  327. }
  328. }
  329. Components.Leaves = Leaves;
  330. })(Components = Hrms.Components || (Hrms.Components = {}));
  331. })(Hrms = Apps.Hrms || (Apps.Hrms = {}));
  332. })(Apps = Bizgaze.Apps || (Bizgaze.Apps = {}));
  333. })(Bizgaze || (Bizgaze = {}));