63 lines
2.4 KiB
Python
63 lines
2.4 KiB
Python
'''
|
|
elif request.GET["action"] == "getrestholidays":
|
|
user = User.objects.get(pk=request.GET["userid"])
|
|
usertimedata = UserTime.objects.get(user=user)
|
|
today = date.today()
|
|
if(user.profile.agency == request.user.profile.agency and request.user.has_perm("users.absencemanager")):
|
|
|
|
# Alle Abwesenheiten laden, die bestätigt oder angefragt sind UND Urlaub sind
|
|
absences = Absence.objects.filter(user=user, confirm_status=0, reason__is_holiday=True) | Absence.objects.filter(user=user, confirm_status=1, reason__is_holiday=True)
|
|
|
|
start_day = request.GET["startdate"].split("__")
|
|
start_day_ob = datetime.date(int(start_day[0]), int(start_day[1]), int(start_day[2]))
|
|
|
|
end_day = request.GET["enddate"].split("__")
|
|
end_day_obj = datetime.date(int(end_day[0]), int(end_day[1]), int(end_day[2]))
|
|
|
|
start_half = True
|
|
if request.GET["start_half"] == "false":
|
|
start_half = False
|
|
|
|
end_half = True
|
|
if request.GET["end_half"] == "false":
|
|
end_half = False
|
|
|
|
|
|
# USER HAS NO ABSENCE
|
|
if(len(absences) == 0):
|
|
# Hier Urlaubstage bei Einstellung mit berücksichtigen
|
|
if(start_day_ob.year == usertimedata.startdate.year):
|
|
|
|
data = {
|
|
"restholiday" : calculateHolidays(request, usertimedata.holiday_start + usertimedata.holiday, start_day_ob, end_day_obj, start_half, end_half)
|
|
}
|
|
# Hier Einstellungstage irrelevant und da noch keine Abwesenheiten eingetragen wurden, einfach aus Profil laden
|
|
else:
|
|
data = {
|
|
"restholiday" : calculateHolidays(request, usertimedata.holiday, start_day_ob, end_day_obj, start_half, end_half)
|
|
}
|
|
# ABSENCE-Data found, calculating rest-Days
|
|
else:
|
|
finalholidays = 0
|
|
|
|
# Besteht noch Anspruch aus Einstellungsjahr?
|
|
if(start_day_ob.year == usertimedata.startdate.year):
|
|
finalholidays += usertimedata.holiday_start + usertimedata.holiday
|
|
# Hier Einstellungstage irrelevant und da noch keine Abwesenheiten eingetragen wurden, einfach normal
|
|
else:
|
|
finalholidays += usertimedata.holiday
|
|
|
|
# Berechne pro Abwesenheits die verbrauchen Urlaubstage
|
|
for absence in absences:
|
|
finalholidays -= calculatingHolidaysByAbsence(request, absence)
|
|
|
|
data = {
|
|
"restholiday" : calculateHolidays(request, finalholidays, start_day_ob, end_day_obj, start_half, end_half)
|
|
}
|
|
# REQUEST USER NO RIGHTS
|
|
else:
|
|
data = {
|
|
"success" : False
|
|
}
|
|
|
|
''' |