diff --git a/digitaleagentur/utils.py b/digitaleagentur/utils.py index d0bca92..c58ed79 100644 --- a/digitaleagentur/utils.py +++ b/digitaleagentur/utils.py @@ -70,6 +70,32 @@ def checkAbsenceWorkdayCollide(absence): workday.delflag = False workday.save() +def checkAbsenceWorkdayCollideDelete(absence): + # Alle einzelnen Tage der Abwesenheit werden durchgegangen: + for day in daterange(absence.start, absence.end): + # Arbeitstage an diesem Tag werden geladen + workdays = Workday.objects.filter(user=absence.user, start__day=absence.start.day, start__month=absence.start.month, start__year=absence.start.year) + + # Wenn es Arbeitstage gibt, dann wird geprüft, ob die Abwesenheit diesen verändert hat. + for workday in workdays: + # Arbeitstag in Tag ohne Zeit umwandeln + # Wenn die Abwesenheit die Zeiterfassung NICHT ändert, muss diese ggf. geändert werden. Ansonsten bleibt sie gleich. + if absence.reason.is_time == False: + # Prüfung, ob der Tag halb ist oder nicht. Wenn ja, dann Zielarbeitszeit des Tages um die Hälfte reduzieren. + if (workday.start.day == absence.start.day and workday.start.month == absence.start.month and workday.start.year == absence.start.year) or (workday.end.day == absence.end.day and workday.end.month == absence.end.month and workday.end.year == absence.end.year): + if(getIsAbsenceStartEndHalf(absence)): + workday.target = workday.target / 2 + workday.save() + # Ganzer Tag vorhanden, Arbeitstag wird als löschen markiert, aber nicht gelöscht + else: + workday.delflag = False + workday.save() + else: + # Sollte der ganze Tag mal als zu löschen markiert worden sein, wird dies hier zurückgenommen + if workday.delflag == True: + workday.delflag = False + workday.save() + diff --git a/timemanagement/templates/timemanagement/timemanagement_singleview.html b/timemanagement/templates/timemanagement/timemanagement_singleview.html index 68397a8..b1c4d1d 100644 --- a/timemanagement/templates/timemanagement/timemanagement_singleview.html +++ b/timemanagement/templates/timemanagement/timemanagement_singleview.html @@ -238,11 +238,12 @@ {% endif %} {% else %} + {% if abday == False %} {% counterWDreset %} {% for workday in workdays %} {% if workday.start|date:"d-m-y" == da|date:"d-m-y" %} - + {% getCounterWD as wd_counter %} {% if wd_counter > 0 %} @@ -260,7 +261,7 @@ {% endif %} {% endfor %} {% endif %} - {% endif %} + {% endif %} {% if abday == False and isfreename == False %} diff --git a/timemanagement/templates/timemanagement/timemanagement_teamview_single.html b/timemanagement/templates/timemanagement/timemanagement_teamview_single.html index 6829fc3..5e149c9 100644 --- a/timemanagement/templates/timemanagement/timemanagement_teamview_single.html +++ b/timemanagement/templates/timemanagement/timemanagement_teamview_single.html @@ -77,12 +77,10 @@ - {% if abday != False or isfreename != False %} {% if isfreename != False %} {{isfreename}} - - {% for workday in workdays %} + {% for workday in workdays %} {% if workday.start|date:"d-m-y" == da|date:"d-m-y" %}
{{workday.start|date:"H:i"}} - {{workday.end|date:"H:i"}}, @@ -108,9 +106,10 @@ {% endif %} {% endfor %} - {% else %} - {{abday.reason}} - {% endif %} + + {% else %} + {{abday.reason}} + {% endif %} {% if abday.start == da%} {% if abday.startday_info == "1" %} (nur Vormittags) @@ -133,15 +132,16 @@ -{{erg.0}} {% endif %} - + {% if breakmonthline < da %} + - + {% endif %} {% endif %} {% endfor %} - {% elif abday.startday_info == "2" %} + {% elif abday.startday_info == "2" %} (nur Nachmittags) {% for workday in workdays %} @@ -163,10 +163,10 @@ -{{erg.0}} {% endif %} - - + {% if breakmonthline < da %} + - + {% endif %} {% endif %} {% endfor %} @@ -196,10 +196,10 @@ -{{erg.0}} {% endif %} - - + {% if breakmonthline < da %} + - + {% endif %} {% endif %} {% endfor %} @@ -228,22 +228,24 @@ -{{erg.0}} {% endif %} - - + {% if breakmonthline < da %} + - + {% endif %} + {% endif %} {% endfor %} {% endif %} {% endif %} + {% else %} {% if abday == False %} {% counterWDreset %} {% for workday in workdays %} {% if workday.start|date:"d-m-y" == da|date:"d-m-y" %} - + {% getCounterWD as wd_counter %} {% if wd_counter > 0 %} @@ -252,6 +254,7 @@ {% counterWDUp %} + {% if workday.start == workday.end %} Nichts gebucht {% else %} @@ -260,12 +263,13 @@ {% endif %} {% endfor %} {% endif %} - {% endif %} + {% endif %} {% if abday == False and isfreename == False %} + {% counterWDreset %} {% for workday in workdays %} {% if workday.end|date:"d-m-y" == da|date:"d-m-y" %} diff --git a/timemanagement/views.py b/timemanagement/views.py index 517d36d..860a106 100644 --- a/timemanagement/views.py +++ b/timemanagement/views.py @@ -864,6 +864,8 @@ def TimeAjax(request): elif request.GET["action"] == "remove_absence": absence = Absence.objects.get(pk=request.GET["ab"]) + checkAbsenceWorkdayCollideDelete(absence) + if(request.user.has_perm("users.absencemanager") and absence.agency == request.user.profile.agency): absence.delete() data = {