var Bizgaze; (function (Bizgaze) { let Apps; (function (Apps) { let Hrms; (function (Hrms) { let Components; (function (Components) { class Leaves extends Unibase.Platform.Core.BaseComponent { loaddata(fromdate, todate, employeeid, leavetypeid, totalDayPropertyId, durationProperyId, totaldaysleavehistoryProperyId) { var instance = this; var fdate = moment(fromdate.replaceAll("/", "-"), "DD/MM/YYYY").format("YYYY/MM/DD"); var tdate = moment(todate.replaceAll("/", "-"), "DD/MM/YYYY").format("YYYY/MM/DD"); var iWeeks = 0; var iDateDiff = 0; var iAdjust = 0; var dd; instance.fileCacheHelper.loadJsFiles(["apps/hrms/components/leavetype.js", "apps/hrms/managers/leavemanager.js", "apps/hrms/managers/leavemanager.js", "apps/hrms/enums/leavetypes.js"], function () { Bizgaze.Apps.Hrms.Managers.LeaveManager.Instance().getleavescountData(employeeid, leavetypeid).then(function (response) { var totaldays = 0; var result = ""; if (response.result != null && response.result != "") { result = response.result; totaldays = response.result.totaldays; } Bizgaze.Apps.Hrms.Managers.LeaveManager.Instance().Getleavetypedata(leavetypeid).then(function (response) { if (response.result != null && response.result != "") { result = response.result; var fromvalidity = response.result.fromvalidity; var accuraldate = response.result.accuraldate; var mothname = response.result.mothname; var jan = response.result.jan; var feb = response.result.feb; var mar = response.result.mar; var apr = response.result.apr; var may = response.result.may; var jun = response.result.jun; var jul = response.result.jul; var aug = response.result.aug; var sep = response.result.sep; var oct = response.result.oct; var nov = response.result.nov; var dec = response.result.dec; var jantojun = response.result.jantojun; var jultodec = response.result.jultodec; var jantoaprl = response.result.jantoaprl; var maytoaug = response.result.maytoaug; var septodec = response.result.septodec; } var leaveType = Hrms.Enums.LeaveTypes.None; 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) { leaveType = Hrms.Enums.LeaveTypes.Monthly; } else if (jantojun != 0 || jultodec != 0) { leaveType = Hrms.Enums.LeaveTypes.HalfYearly; } else if (jantoaprl != 0 || maytoaug != 0 || septodec != 0) { leaveType = Hrms.Enums.LeaveTypes.Quarterly; } var leavefromyear = moment(fdate, "YYYY/MM/DD").year(); var leavefromonth = 1 + moment(fdate, "YYYY/MM/DD").month(); var leavefromdate = moment(fdate, "YYYY/MM/DD").date(); var leavetodateyear = moment(tdate, "YYYY/MM/DD").year(); var leavetodatemonth = 1 + moment(tdate, "YYYY/MM/DD").month(); var leavetodate = moment(tdate, "YYYY/MM/DD").date(); var months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]; var month = months.indexOf(mothname); todate = new Date(tdate); fromdate = new Date(fdate); if (todate < fromdate) return 0; var iWeekday1 = fromdate.getDay(); var iWeekday2 = todate.getDay(); iWeekday1 = (iWeekday1 == 0) ? 7 : iWeekday1; iWeekday2 = (iWeekday2 == 0) ? 7 : iWeekday2; if ((iWeekday1 > 5) && (iWeekday2 > 5)) iAdjust = 1; iWeekday1 = (iWeekday1 > 5) ? 5 : iWeekday1; iWeekday2 = (iWeekday2 > 5) ? 5 : iWeekday2; iWeeks = Math.floor((todate.getTime() - fromdate.getTime()) / 604800000); if (iWeekday1 < iWeekday2) { iDateDiff = (iWeeks * 5) + (iWeekday2 - iWeekday1); } if ((leavefromyear == leavetodateyear) && (leavefromonth == leavetodatemonth) && (leavefromdate == leavetodate)) { if (iWeekday1 == iWeekday2) { iDateDiff = 0; } } else if (fromdate != todate) { if (iWeekday1 == iWeekday2) { iDateDiff = ((0 + 1) * 5) - (iWeekday1 - iWeekday2); } else if (iWeekday1 != iWeekday2) { iDateDiff = ((iWeeks + 1) * 5) - (iWeekday1 - iWeekday2); } } else { iDateDiff = ((iWeeks + 1) * 5) - (iWeekday1 - iWeekday2); } iDateDiff -= iAdjust; dd = iDateDiff + 1; if (totaldays > 0) { dd = dd + totaldays; } $("#" + totalDayPropertyId).val(dd); $("#" + totaldaysleavehistoryProperyId).val(dd); var FulDay = dd + " " + "Days"; var HalfDay = "HalfDay"; var QuaterDay = "QuaterDay"; var Hourly = "Hourly"; var duration = Number($("#" + durationProperyId).val()); if (duration == 1) { if (leaveType == Hrms.Enums.LeaveTypes.Monthly) { if (leavefromonth == 1 && leavetodatemonth == 1) { var jan = response.result.jan; if (dd <= jan) { alert("these days are applicable for this month"); $("#divSectionProperties_Totalcountdays_ActionProperty").html(FulDay); } else { alert("these days are not applicable for this month"); $("#divSectionProperties_Totalcountdays_ActionProperty").html(""); } } else if (leavefromonth == 2 && leavetodatemonth == 2) { var feb = response.result.feb; if (dd <= feb) { alert("these days are applicable for this month"); $("#divSectionProperties_Totalcountdays_ActionProperty").html(FulDay); } else { alert("these days are not applicable for this month"); $("#divSectionProperties_Totalcountdays_ActionProperty").html(""); } } else if (leavefromonth == 3 && leavetodatemonth == 3) { var mar = response.result.mar; if (dd <= mar) { alert("these days are applicable for this month"); $("#divSectionProperties_Totalcountdays_ActionProperty").html(FulDay); } else { alert("these days are not applicable for this month"); $("#divSectionProperties_Totalcountdays_ActionProperty").html(""); } } else if (leavefromonth == 4 && leavetodatemonth == 4) { var apr = response.result.apr; if (dd <= apr) { alert("these days are applicable for this month"); $("#divSectionProperties_Totalcountdays_ActionProperty").html(FulDay); } else { alert("these days are not applicable for this month"); $("#divSectionProperties_Totalcountdays_ActionProperty").html(""); } } else if (leavefromonth == 5 && leavetodatemonth == 5) { var may = response.result.may; if (dd <= may) { alert("these days are applicable for this month"); $("#divSectionProperties_Totalcountdays_ActionProperty").html(FulDay); } else { alert("these days are not applicable for this month"); $("#divSectionProperties_Totalcountdays_ActionProperty").html(""); } } else if (leavefromonth == 6 && leavetodatemonth == 6) { var jun = response.result.jun; if (dd <= jun) { alert("these days are applicable for this month"); $("#divSectionProperties_Totalcountdays_ActionProperty").html(FulDay); } else { alert("these days are not applicable for this month"); $("#divSectionProperties_Totalcountdays_ActionProperty").html(""); } } else if (leavefromonth == 7 && leavetodatemonth == 7) { var jul = response.result.jul; if (dd <= jul) { alert("these days are applicable for this month"); $("#divSectionProperties_Totalcountdays_ActionProperty").html(FulDay); } else { alert("these days are not applicable for this month"); $("#divSectionProperties_Totalcountdays_ActionProperty").html(""); } } else if (leavefromonth == 8 && leavetodatemonth == 8) { var aug = response.result.aug; if (dd <= aug) { alert("these days are applicable for this month"); $("#divSectionProperties_Totalcountdays_ActionProperty").html(FulDay); } else { alert("these days are not applicable for this month"); $("#divSectionProperties_Totalcountdays_ActionProperty").html(""); } } else if (leavefromonth == 9 && leavetodatemonth == 9) { var sep = response.result.sep; if (dd <= sep) { alert("these days are applicable for this month"); $("#divSectionProperties_Totalcountdays_ActionProperty").html(FulDay); } else { alert("these days are not applicable for this month"); $("#divSectionProperties_Totalcountdays_ActionProperty").html(""); } } else if (leavefromonth == 10 && leavetodatemonth == 10) { var oct = response.result.oct; if (dd <= oct) { alert("these days are applicable for this month"); $("#divSectionProperties_Totalcountdays_ActionProperty").html(FulDay); } else { alert("these days are not applicable for this month"); $("#divSectionProperties_Totalcountdays_ActionProperty").html(""); } } else if (leavefromonth == 11 && leavetodatemonth == 11) { var nov = response.result.nov; if (dd <= nov) { alert("these days are applicable for this month"); $("#divSectionProperties_Totalcountdays_ActionProperty").html(FulDay); } else { alert("these days are not applicable for this month"); $("#divSectionProperties_Totalcountdays_ActionProperty").html(""); } } else if (leavefromonth == 12 && leavetodatemonth == 12) { var dec = response.result.dec; if (dd <= dec) { alert("these days are applicable for this month"); $("#divSectionProperties_Totalcountdays_ActionProperty").html(FulDay); } else { alert("these days are not applicable for this month"); $("#divSectionProperties_Totalcountdays_ActionProperty").html(""); } } } else if (leaveType == Hrms.Enums.LeaveTypes.HalfYearly) { if (leavefromonth == 1 || leavetodatemonth <= 6) { var jantojun = response.result.jantojun; if (dd <= jantojun) { alert("these days are applicable for this month"); $("#divSectionProperties_Totalcountdays_ActionProperty").html(FulDay); } else { alert("these days are not applicable for this month"); $("#divSectionProperties_Totalcountdays_ActionProperty").html(""); } } else if (leavefromonth == 7 || leavetodatemonth <= 12) { var jultodec = response.result.jultodec; if (dd <= jultodec) { alert("these days are applicable for this month"); $("#divSectionProperties_Totalcountdays_ActionProperty").html(FulDay); } else { alert("these days are not applicable for this month"); $("#divSectionProperties_Totalcountdays_ActionProperty").html(""); } } } else if (leaveType == Hrms.Enums.LeaveTypes.Quarterly) { if (leavefromonth == 1 || leavetodatemonth <= 4) { var jantoaprl = response.result.jantoaprl; if (dd <= jantoaprl) { alert("these days are applicable for this month"); $("#divSectionProperties_Totalcountdays_ActionProperty").html(FulDay); } else { alert("these days are not applicable for this month"); $("#divSectionProperties_Totalcountdays_ActionProperty").html(""); } } else if (leavefromonth == 5 || leavetodatemonth <= 8) { var maytoaug = response.result.maytoaug; if (dd <= maytoaug) { alert("these days are applicable for this month"); $("#divSectionProperties_Totalcountdays_ActionProperty").html(FulDay); } else { alert("these days are not applicable for this month"); $("#divSectionProperties_Totalcountdays_ActionProperty").html(""); } } else if (leavefromonth == 9 || leavetodatemonth <= 12) { var septodec = response.result.septodec; if (dd <= septodec) { alert("these days are applicable for this month"); $("#divSectionProperties_Totalcountdays_ActionProperty").html(FulDay); } else { alert("these days are not applicable for this month"); $("#divSectionProperties_Totalcountdays_ActionProperty").html(""); } } else { alert("these days are not applicable for this month"); } } } else if (duration == 2) { $("#divSectionProperties_Totalcountdays_ActionProperty").html(Hourly); } else if (duration == 3) { $("#divSectionProperties_Totalcountdays_ActionProperty").html(QuaterDay); } else if (duration == 4) { $("#divSectionProperties_Totalcountdays_ActionProperty").html(HalfDay); } }); }); }); } static Instance() { if (this._instance === undefined) this._instance = new Leaves(); return this._instance; } } Components.Leaves = Leaves; })(Components = Hrms.Components || (Hrms.Components = {})); })(Hrms = Apps.Hrms || (Apps.Hrms = {})); })(Apps = Bizgaze.Apps || (Bizgaze.Apps = {})); })(Bizgaze || (Bizgaze = {}));