QS 0.9.1 Bugs bearbeitet

This commit is contained in:
Holger Trampe 2020-06-02 10:06:59 +02:00
parent eb0f5fbe70
commit 1882602a4e
10 changed files with 193 additions and 34 deletions

1
.cred
View File

@ -1,2 +1,3 @@
https://holger.trampe:Zerogoogle123_@git.vhevents.de/ https://holger.trampe:Zerogoogle123_@git.vhevents.de/
https://holger.trampe:Zerogoogle123_@git.vhevents.de/ https://holger.trampe:Zerogoogle123_@git.vhevents.de/
https://holger.trampe:Zerogoogle123_@git.vhevents.de/

View File

@ -942,7 +942,7 @@ def UserProfileUpdate(request, pk, newuser=0):
} }
return render(request, 'dasettings/user_usprof.html', context) return render(request, 'dasettings/user_usprof.html', context)
else: else:
messages.success(request, f'Fehlerhafte Eingabe!') messages.success(request, f'Fehlerhafte Eingabe! Das Verfallsdatum muss im Format TAG.MONAT. sein und existieren!')
context = { context = {
'active_link' : 'dasettings', 'active_link' : 'dasettings',
'user_fullname' : user_fullname, 'user_fullname' : user_fullname,

View File

@ -1,6 +1,6 @@
from django import template from django import template
from django.contrib.auth.models import Group, User from django.contrib.auth.models import Group, User
from users.models import AgencyGroup, Agency, AgencyNetwork, AgencyNetworkPreperation, UserTime from users.models import AgencyGroup, Agency, AgencyNetwork, AgencyNetworkPreperation, UserTime, UserYearAbsenceInfo
from standards.models import Standards, StandardCommentRate, StandardComments from standards.models import Standards, StandardCommentRate, StandardComments
from timemanagement.models import Workday, FreeDays, Absence from timemanagement.models import Workday, FreeDays, Absence
from message.models import Message from message.models import Message
@ -594,3 +594,47 @@ def loadaccounttime(user):
return [final_info, status] return [final_info, status]
'''
Gibt True zurück, wenn ein Mitarbeiter an diesem Tag laut Vertragsdaten NICHT arbeitet.
Gibt False zurück, wenn er an diesem Tag mindestens 0.1 Stunden arbeitet
'''
@register.simple_tag
def getthisdaynotworking(user, day):
stat = False
if(day.isoweekday() == 1):
if user.usertime.wd_mo == 0.0:
stat = True
elif(day.isoweekday() == 2):
if user.usertime.wd_tu == 0.0:#
stat = True
elif(day.isoweekday() == 3):
if user.usertime.wd_we == 0.0:
stat = True
elif(day.isoweekday() == 4):
if user.usertime.wd_th == 0.0:
stat = True
elif(day.isoweekday() == 5):
if user.usertime.wd_fr == 0.0:
stat = True
return stat
'''
Gibt das verfügbare Urlaubskontingent eines Mitarbeiters zurück
'''
@register.simple_tag
def kontingent(user):
kon = 0.0
try:
yearinfo = list(UserYearAbsenceInfo.objects.filter(year=date.today().year, user=user))[0]
inuse = yearinfo.days_inuse
kon = yearinfo.days - inuse
except:
pass
return kon

View File

@ -1,5 +1,9 @@
{% load crispy_forms_tags %} {% load crispy_forms_tags %}
{% load mathfilters %} {% load mathfilters %}
{% load counter_tag %}
{% if user|usergperm:"absencemanager" %}
<h5>Abwesenheit für {{absence.user.first_name}} {{absence.user.last_name}} annehmen/ablehnen</h5> <h5>Abwesenheit für {{absence.user.first_name}} {{absence.user.last_name}} annehmen/ablehnen</h5>
<hr> <hr>
<h6>Informationen der Abwesenheit</h6> <h6>Informationen der Abwesenheit</h6>
@ -49,3 +53,10 @@ Informationen: {{absence.info}}<br />
absencestring_confirm = 'Sicher, dass Sie die Abwesenheit für {{absence.user.first_name}} {{absence.user.last_name}} vom {{absence.start|date:"d.m Y"}} bis {{absence.end|date:"d.m Y"}} <b>annehmen</b> wollen?' absencestring_confirm = 'Sicher, dass Sie die Abwesenheit für {{absence.user.first_name}} {{absence.user.last_name}} vom {{absence.start|date:"d.m Y"}} bis {{absence.end|date:"d.m Y"}} <b>annehmen</b> wollen?'
absencestring_noconfirm = 'Sicher, dass Sie die Abwesenheit für {{absence.user.first_name}} {{absence.user.last_name}} vom {{absence.start|date:"d.m Y"}} bis {{absence.end|date:"d.m Y"}} <b>ablehnen</b> wollen?' absencestring_noconfirm = 'Sicher, dass Sie die Abwesenheit für {{absence.user.first_name}} {{absence.user.last_name}} vom {{absence.start|date:"d.m Y"}} bis {{absence.end|date:"d.m Y"}} <b>ablehnen</b> wollen?'
</script> </script>
{% else %}
<h5>Abwesenheit für {{absence.user.first_name}} {{absence.user.last_name}} annehmen/ablehnen</h5>
<hr>
Diese Daten dürfen Sie nicht abrufen.
{% endif %}

View File

@ -8,8 +8,9 @@
<button type="button" class="btn btn-primary mr-1" onclick="javascript:nextMonth()"><i class="fas fa-arrow-circle-right"></i></button> <button type="button" class="btn btn-primary mr-1" onclick="javascript:nextMonth()"><i class="fas fa-arrow-circle-right"></i></button>
</div> </div>
</td> </td>
{% for da in days_this_month %} {% for da in days_this_month %}
<td id="{{forloop.counter0}}_tableheadid"><small>{{da|date:"d D"}}</small></td> {% isfreeday user da as isfree %}
<td id="{{forloop.counter0}}_tableheadid" {% if today == da %} style="background-color: #F2D488;" {% elif da.weekday == 5 or da.weekday == 6 %} style="background-color: #d3d3d3;" {% elif isfree %} style="background-color: #9C9C9C; color: #ffffff" {% endif %}><small>{{da|date:"d D"}}</small></td>
{% endfor %} {% endfor %}
</tr> </tr>
@ -20,20 +21,26 @@
<td width="21%" id="{{actfcounter}}_{{forloop.counter}}_{{us.pk}}_firstcolum"> <td width="21%" id="{{actfcounter}}_{{forloop.counter}}_{{us.pk}}_firstcolum">
<img class="commentimg mr-2" src="{{ us.profile.get_photo_url }}"> <img class="commentimg mr-2" src="{{ us.profile.get_photo_url }}">
{{us.get_full_name}} {{us.get_full_name}}
{% if user|usergperm:"absencemanager" %}
{% kontingent us as userkontingent %}
<span class="badge badge-primary badge-counter" style="float: right;" >{{userkontingent}}</span>
{% endif %}
</td> </td>
{% for da in days_this_month %} {% for da in days_this_month %}
{% isfreeday user da as isfree %} {% isfreeday user da as isfree %}
{% isfreedayname user da as isfreename %} {% isfreedayname user da as isfreename %}
{% getabscenceday user us da as abday %} {% getabscenceday user us da as abday %}
{% startdatecheck us da as startdatecheck %} {% startdatecheck us da as startdatecheck %}
{% getthisdaynotworking us da as thisdaynotworking %}
{% if isfree %} {% if isfree %}
<!-- FREEDAYS --> <!-- FREEDAYS -->
<td id="{{actfcounter}}_{{forloop.counter}}_{{us.pk}}_free" style="background-color: #9C9C9C" data-toggle="tooltip" data-placement="top" title="{{isfreename}}"> <td id="{{actfcounter}}_{{forloop.counter}}_{{us.pk}}_free" style="background-color: #9C9C9C" data-toggle="tooltip" data-placement="top" title="{{isfreename}}">
<!-- USER NOT STARTED YET --> <!-- USER NOT STARTED YET -->
{% elif startdatecheck == False %} {% elif startdatecheck == False %}
<td id="{{actfcounter}}_{{forloop.counter}}_{{us.pk}}_free" style="background-color: #d3d3d3"> <td id="{{actfcounter}}_{{forloop.counter}}_{{us.pk}}_free" style="background-color: #d3d3d3">
{% elif thisdaynotworking == True %}
<td id="{{actfcounter}}_{{forloop.counter}}_{{us.pk}}_free" style="background-color: #d3d3d3">
{% elif da.weekday == 5 or da.weekday == 6 %} {% elif da.weekday == 5 or da.weekday == 6 %}
<!-- WEEKEND --> <!-- WEEKEND -->
<td id="{{actfcounter}}_{{forloop.counter}}_{{us.pk}}_free" style="background-color: #d3d3d3"> <td id="{{actfcounter}}_{{forloop.counter}}_{{us.pk}}_free" style="background-color: #d3d3d3">
@ -146,9 +153,13 @@
<td id="{{actfcounter}}_{{forloop.counter}}_{{us.pk}}_{{da|date:'Y-m-d'}}" {% if us.pk == user.pk or user|usergperm:"absencemanager" %}class="tm-ab-tdhover"{% endif %}> <td id="{{actfcounter}}_{{forloop.counter}}_{{us.pk}}_{{da|date:'Y-m-d'}}" {% if us.pk == user.pk or user|usergperm:"absencemanager" %}class="tm-ab-tdhover"{% endif %}>
{% endif %} {% endif %}
{% else %}
<!-- NORMAL CHOICE --> <!-- NORMAL CHOICE -->
<td id="{{actfcounter}}_{{forloop.counter}}_{{us.pk}}_{{da|date:'Y-m-d'}}" {% if us.pk == user.pk or user|usergperm:"absencemanager" %}class="tm-ab-tdhover"{% endif %}> <!-- HEutigen Tag einfärben -->
{% elif today == da %}
<td id="{{actfcounter}}_{{forloop.counter}}_{{us.pk}}_{{da|date:'Y-m-d'}}" {% if us.pk == user.pk or user|usergperm:"absencemanager" %}class="tm-ab-tdhover"{% endif %} style="background-color: #F2D488" >
<!-- Ganz normaler Tag -->
{% else %}
<td id="{{actfcounter}}_{{forloop.counter}}_{{us.pk}}_{{da|date:'Y-m-d'}}" {% if us.pk == user.pk or user|usergperm:"absencemanager" %}class="tm-ab-tdhover"{% endif %} >
{% endif %} {% endif %}
</td> </td>
{% endfor %} {% endfor %}
@ -368,7 +379,7 @@ function recalculateChoosenDays(){
}, },
success : function(data){ success : function(data){
console.log(data)
if(data["other_absences"] != false){ if(data["other_absences"] != false){
$("#otherholidays").show(); $("#otherholidays").show();
$("#otherholidays_users").html(data["other_absences"]); $("#otherholidays_users").html(data["other_absences"]);
@ -377,6 +388,16 @@ function recalculateChoosenDays(){
$("#otherholidays").hide(); $("#otherholidays").hide();
} }
if(data["userown_absences"] != false){
$("#ownholidays").show();
$("#ownholidays_users").html(data["userown_absences"]);
}
else{
$("#ownholidays").hide();
}
$("#startAbsenceProgress").modal("show"); $("#startAbsenceProgress").modal("show");
@ -441,6 +462,8 @@ function recalculateChoosenDaysAfterInit(){
}, },
success : function(data){ success : function(data){
console.log(data);
if(data["other_absences"] != false){ if(data["other_absences"] != false){
$("#otherholidays").show(); $("#otherholidays").show();
$("#otherholidays_users").html(data["other_absences"]); $("#otherholidays_users").html(data["other_absences"]);
@ -448,6 +471,14 @@ function recalculateChoosenDaysAfterInit(){
else{ else{
$("#otherholidays").hide(); $("#otherholidays").hide();
} }
if(data["userown_absences"] != false){
$("#ownholidays").show();
$("#ownholidays_users").html(data["userown_absences"]);
}
else{
$("#ownholidays").hide();
}
$("#restholidays").html(data["restholiday_thisyear"]); $("#restholidays").html(data["restholiday_thisyear"]);
$("#detail_rest").html(data["restholiday_thisyear"]); $("#detail_rest").html(data["restholiday_thisyear"]);
@ -482,7 +513,8 @@ function recalculateChoosenDaysAfterInit(){
behindcheck = true; behindcheck = true;
} }
if(behindcheck == false || data["restholiday_thisyear"] < 0 || data["restholiday_lastyear"] < 0 || data["restholiday_nextyear"] < 0 && data["startendcheck"] || data["restholiday_thisyear"] < 0 || data["restholiday_nextyear"] < 0 ){ if(behindcheck == false || data["restholiday_thisyear"] < 0 || data["restholiday_lastyear"] < 0 || data["restholiday_nextyear"] < 0 && data["startendcheck"] || data["restholiday_thisyear"] < 0 || data["restholiday_nextyear"] < 0 || data["userown_absences"] != false)
{
$("#start_absence_contract").prop("disabled", true); $("#start_absence_contract").prop("disabled", true);
} }
else{ else{

View File

@ -63,8 +63,7 @@
</tbody> </tbody>
</table> </table>
</div> </div>
{% if user.usertime.usetime_start == None %} {% if user.usertime.usetime_start == None %}
<div class="modal fade" tabindex="-1" role="dialog" data-backdrop="static" id="missingdatainfo"> <div class="modal fade" tabindex="-1" role="dialog" data-backdrop="static" id="missingdatainfo">
<div class="modal-dialog" role="document"> <div class="modal-dialog" role="document">
@ -92,7 +91,7 @@
}) })
$('#missingdatainfo').on('hidden.bs.modal', function (e) { $('#missingdatainfo').on('hidden.bs.modal', function (e) {
location.href = "{% url 'dasettings' %}"; location.href = "{% url 'dasettings' %}";
}) })
</script> </script>

View File

@ -2,12 +2,12 @@
{% block content %} {% block content %}
{% load crispy_forms_tags %} {% load crispy_forms_tags %}
{% load counter_tag %} {% load counter_tag %}
{% load mathfilters %}
{% if request.user.profile.agency.module_timemanagement %} {% if request.user.profile.agency.module_timemanagement %}
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css"> <link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.1.6/Chart.bundle.min.js"></script> <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.1.6/Chart.bundle.min.js"></script>
<div class="content-section col-12"> <div class="content-section col-12">
<h3>Abwesenheiten{% if request.user.profile.showtooltips %}&nbsp;<small><i data-toggle="tooltip" data-placement="top" title="Bearbeiten Sie hier Ihre Abwesenheiten." class="far fa-question-circle"></i></small>{% endif %} <h3>Abwesenheiten{% if request.user.profile.showtooltips %}&nbsp;<small><i data-toggle="tooltip" data-placement="top" title="Bearbeiten Sie hier Ihre Abwesenheiten." class="far fa-question-circle"></i></small>{% endif %}
</h3> </h3>
<hr> <hr>
@ -166,6 +166,12 @@
<br /> <br />
<div id="otherholidays_users"></div> <div id="otherholidays_users"></div>
</div> </div>
<div id="ownholidays" style="display: none;">
<hr>
In diesem Zeitraum haben Sie bereits folgende Abwesenheiten:
<br />
<div id="ownholidays_users"></div>
</div>
<!-- Fields for rest-logic --> <!-- Fields for rest-logic -->
<div style="display: none;"> <div style="display: none;">
{{abscenceform.nextmonth}} {{abscenceform.nextmonth}}
@ -200,7 +206,7 @@
<div id="confirmcontent"></div> <div id="confirmcontent"></div>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal" onclick="javascript:closeOnly()">Schließen</button> <button type="button" class="btn" data-dismiss="modal" onclick="javascript:closeOnly()">Schließen</button>
</div> </div>
</div> </div>
</div> </div>
@ -328,7 +334,6 @@ $("#show_detailview").hover(
); );
*/ */
function confirmAbscenceFinal(){ function confirmAbscenceFinal(){
$.ajax({ $.ajax({
type: "GET", type: "GET",
@ -491,6 +496,11 @@ $('#absencetabs a').on('click', function (e) {
<script type="text/javascript"> <script type="text/javascript">
$(document).ready(function(){ $(document).ready(function(){
$("#missingdatainfo").modal("toggle"); $("#missingdatainfo").modal("toggle");
$('#missingdatainfo').on('hidden.bs.modal', function (e) {
location.href = "{% url 'dasettings' %}";
})
}) })
</script> </script>
{% endif %} {% endif %}

View File

@ -276,6 +276,7 @@ def AbsenceManagmenet(request, activemonth=False, activeyear=False):
"final_reasons" : final_reasons, "final_reasons" : final_reasons,
"yearinfo" : yearinfo, "yearinfo" : yearinfo,
"kontingent" : kontingent, "kontingent" : kontingent,
"today" : date.today(),
"abscenceform" : AddAbsence(instance=request.user), "abscenceform" : AddAbsence(instance=request.user),
"userown" : Absence.objects.filter(agency=request.user.profile.agency, user=request.user).order_by("-start") "userown" : Absence.objects.filter(agency=request.user.profile.agency, user=request.user).order_by("-start")
} }
@ -569,7 +570,6 @@ def TimeAjax(request):
if(tempTime.startdate == None): if(tempTime.startdate == None):
missinguserdata.append(user) missinguserdata.append(user)
context = { context = {
"active_link" : "abscence", "active_link" : "abscence",
"usersofagency" : User.objects.filter(profile__agency=request.user.profile.agency).order_by("-last_name"), "usersofagency" : User.objects.filter(profile__agency=request.user.profile.agency).order_by("-last_name"),
@ -580,7 +580,8 @@ def TimeAjax(request):
"nextmonth" : nextmonth, "nextmonth" : nextmonth,
"prevmonth" : prevmonth, "prevmonth" : prevmonth,
"nextyear" : nextyear, "nextyear" : nextyear,
"prevyear" : prevyear "prevyear" : prevyear,
"today" : date.today(),
} }
return render(request, "timemanagement/rendered_table.html", context) return render(request, "timemanagement/rendered_table.html", context)
@ -641,7 +642,7 @@ def TimeAjax(request):
new_stat = request.GET["newconfstat"] new_stat = request.GET["newconfstat"]
info = request.GET["info"] info = request.GET["info"]
# Eingeloggter Nutzer hat Rechte, Urlaube einzutragen
if(absence.user.profile.agency == request.user.profile.agency and request.user.has_perm("users.absencemanager")): if(absence.user.profile.agency == request.user.profile.agency and request.user.has_perm("users.absencemanager")):
absence.confirm_status = new_stat absence.confirm_status = new_stat
absence.confirm_info = info absence.confirm_info = info
@ -657,6 +658,7 @@ def TimeAjax(request):
"activemonth" : request.GET["activemonth"], "activemonth" : request.GET["activemonth"],
"activeyear" : request.GET["activeyear"] "activeyear" : request.GET["activeyear"]
} }
# Berechnung starten, da Urlaub vorhanden ist
elif request.GET["action"] == "getrestholidays": elif request.GET["action"] == "getrestholidays":
user = User.objects.get(pk=request.GET["userid"]) user = User.objects.get(pk=request.GET["userid"])
usertimedata = UserTime.objects.get(user=user) usertimedata = UserTime.objects.get(user=user)
@ -709,10 +711,10 @@ def TimeAjax(request):
if(end_day_obj.year == start_day_obj.year): if(end_day_obj.year == start_day_obj.year):
# Startt des Urlaubs NACH Verfallsdatum - nur aktuelles JAhr und die Zahl interessiert # Startt des Urlaubs NACH Verfallsdatum - nur aktuelles JAhr und die Zahl interessiert
if(start_day_obj > holidayloose_date): if(start_day_obj > holidayloose_date):
need_days = (calculateHolidays(request, start_day_obj, end_day_obj, start_half, end_half))*(-1) need_days = (calculateHolidays(request, start_day_obj, end_day_obj, start_half, end_half, user))*(-1)
holiday_thisyear = yeardata.days - yeardata.days_inuse - need_days holiday_thisyear = yeardata.days - yeardata.days_inuse - need_days
else: else:
need_days = (calculateHolidays(request, start_day_obj, end_day_obj, start_half, end_half))*(-1) need_days = (calculateHolidays(request, start_day_obj, end_day_obj, start_half, end_half, user))*(-1)
# Kein Resturlaub # Kein Resturlaub
if(yeardata.restdays == 0.0): if(yeardata.restdays == 0.0):
holiday_thisyear = yeardata.days - yeardata.days_inuse - need_days holiday_thisyear = yeardata.days - yeardata.days_inuse - need_days
@ -732,17 +734,17 @@ def TimeAjax(request):
holiday_lastyear = yeardata.restdays holiday_lastyear = yeardata.restdays
date_splitter = datetime.date(end_day_obj.year, 1, 1) date_splitter = datetime.date(end_day_obj.year, 1, 1)
need_days_this = (calculateHolidays(request, start_day_obj, date_splitter, start_half, False))*(-1) need_days_this = (calculateHolidays(request, start_day_obj, date_splitter, start_half, False), user)*(-1)
need_days_next = (calculateHolidays(request, date_splitter, end_day_obj, False, end_half))*(-1) need_days_next = (calculateHolidays(request, date_splitter, end_day_obj, False, end_half, user))*(-1)
need_days = (calculateHolidays(request, start_day_obj, date_splitter, start_half, False))*(-1) + (calculateHolidays(request, date_splitter, end_day_obj, False, end_half))*(-1) need_days = (calculateHolidays(request, start_day_obj, date_splitter, start_half, False, user))*(-1) + (calculateHolidays(request, date_splitter, end_day_obj, False, end_half))*(-1)
holiday_thisyear = yeardata.days - yeardata.days_inuse - need_days_this holiday_thisyear = yeardata.days - yeardata.days_inuse - need_days_this
days_nextyear_normal = 0 days_nextyear_normal = 0
days_nextyear_rest = 0 days_nextyear_rest = 0
# Urlaub nächstes Jahr MIT und OHNE Rest # Urlaub nächstes Jahr MIT und OHNE Rest
if(holiday_nextyear_rest == 0.0): if(holiday_nextyear_rest == 0.0):
holiday_nextyear = holiday_nextyear - (calculateHolidays(request, date_splitter, end_day_obj, False, end_half))*(-1) holiday_nextyear = holiday_nextyear - (calculateHolidays(request, date_splitter, end_day_obj, False, end_half, user))*(-1)
else: else:
temprest = holiday_nextyear_rest - need_days_next temprest = holiday_nextyear_rest - need_days_next
# Rest reicht! # Rest reicht!
@ -766,6 +768,16 @@ def TimeAjax(request):
for a in other_absences: for a in other_absences:
other_absences_string += a.user.first_name + " " + a.user.last_name + " - Vom " + a.start.strftime("%d.%m.%Y") + " bis " + a.end.strftime("%d.%m.%Y") + "<br />" other_absences_string += a.user.first_name + " " + a.user.last_name + " - Vom " + a.start.strftime("%d.%m.%Y") + " bis " + a.end.strftime("%d.%m.%Y") + "<br />"
# Prüfen, ob der Nutzer selbst schon Abwesenheiten in diesem Zeitraum hat
userown_absences = Absence.objects.filter(start__lte=start_day_obj, end__gte=end_day_obj, agency=request.user.profile.agency, user=user)
print(userown_absences)
userown_absences_string = False
if (len(userown_absences) > 0):
userown_absences_string = ""
for a in userown_absences:
userown_absences_string += a.reason.name + " - Vom " + a.start.strftime("%d.%m.%Y") + " bis " + a.end.strftime("%d.%m.%Y") + "<br />"
data = { data = {
"restholiday_thisyear" : holiday_thisyear, "restholiday_thisyear" : holiday_thisyear,
"restholiday_lastyear" : holiday_lastyear, "restholiday_lastyear" : holiday_lastyear,
@ -775,7 +787,8 @@ def TimeAjax(request):
"need_days" : need_days, "need_days" : need_days,
"need_days_next" : need_days_next, "need_days_next" : need_days_next,
"need_days_this" : need_days_this, "need_days_this" : need_days_this,
"other_absences" : other_absences_string "other_absences" : other_absences_string,
"userown_absences" : userown_absences_string
} }
# REQUEST USER NO RIGHTS # REQUEST USER NO RIGHTS
else: else:
@ -798,7 +811,7 @@ Berücksichtigt sowohl Wochenende als auch in der Agentur hinterlegte Freitage/S
''' '''
@login_required @login_required
def calculateHolidays(request, start, end, start_half, end_half): def calculateHolidays(request, start, end, start_half, end_half, user):
restdays = 0 restdays = 0
allfreedays = FreeDays.objects.filter(agency=request.user.profile.agency) allfreedays = FreeDays.objects.filter(agency=request.user.profile.agency)
if(end == start): if(end == start):
@ -825,7 +838,24 @@ def calculateHolidays(request, start, end, start_half, end_half):
for freeday in allfreedays.all(): for freeday in allfreedays.all():
if(dt == freeday.day): if(dt == freeday.day):
freedaycounter += 1 freedaycounter += 1
# Prüfung, ob der Mitarbeiter an diesem Tag überhaupt arbeitet. Wenn nicht, wird der Freedaycounter einfach erhöht
if(dt.isoweekday() == 1):
if user.usertime.wd_mo == 0.0:
freedaycounter += 1
elif(dt.isoweekday() == 2):
if user.usertime.wd_tu == 0.0:#
freedaycounter += 1
elif(dt.isoweekday() == 3):
if user.usertime.wd_we == 0.0:
freedaycounter += 1
elif(dt.isoweekday() == 4):
if user.usertime.wd_th == 0.0:
freedaycounter += 1
elif(dt.isoweekday() == 5):
if user.usertime.wd_fr == 0.0:
freedaycounter += 1
return restdays - counter + freedaycounter return restdays - counter + freedaycounter
@ -856,10 +886,28 @@ def calculatingHolidaysByAbsence(request, absence):
if dt.isoweekday() not in weekdays: if dt.isoweekday() not in weekdays:
finalholidayinabsence += 1 finalholidayinabsence += 1
# Prüfung, ob freie Tage vorhanden sind
for freeday in allfreedays.all(): for freeday in allfreedays.all():
# FREEDAY FOUND # FREEDAY FOUND
if(dt == freeday.day): if(dt == freeday.day):
freedaycounter += 1 freedaycounter += 1
# Prüfung, ob der Mitarbeiter an diesem Tag überhaupt arbeitet. Wenn nicht, wird der Freedaycounter einfach erhöht
stat = False
if(dt.isoweekday() == 1):
if absence.user.usertime.wd_mo == 0.0:
freedaycounter += 1
elif(dt.isoweekday() == 2):
if absence.user.usertime.wd_tu == 0.0:#
freedaycounter += 1
elif(dt.isoweekday() == 3):
if absence.user.usertime.wd_we == 0.0:
freedaycounter += 1
elif(dt.isoweekday() == 4):
if absence.user.usertime.wd_th == 0.0:
freedaycounter += 1
elif(dt.isoweekday() == 5):
if absence.user.usertime.wd_fr == 0.0:
freedaycounter += 1
return finalholidayinabsence - freedaycounter return finalholidayinabsence - freedaycounter

View File

@ -417,8 +417,7 @@ def save_newabsence(sender, instance, **kwargs):
abinfo_nextyear = list(UserYearAbsenceInfo.objects.filter(user=instance.user, year=instance.start.year+1)) abinfo_nextyear = list(UserYearAbsenceInfo.objects.filter(user=instance.user, year=instance.start.year+1))
if(len(abinfo_nextyear) > 0): if(len(abinfo_nextyear) > 0):
is_nextyear = True is_nextyear = True
abinfo_nextyear = abinfo_nextyear[0] abinfo_nextyear = abinfo_nextyear[0]
multiple_info_needays = False multiple_info_needays = False
if(hasattr(newdata[3], "__len__")): if(hasattr(newdata[3], "__len__")):
@ -463,7 +462,7 @@ def save_newabsence(sender, instance, **kwargs):
abinfo_nextyear.restdays = abinfo_nextyear.restdays - newdata[3][3] abinfo_nextyear.restdays = abinfo_nextyear.restdays - newdata[3][3]
abinfo_nextyear.save() abinfo_nextyear.save()
# Hier werd der REST als vorjahreswert und NORMAL als nächstes Jahr gespeichert # Hier werden alle benötigten Tage von Vor- und Nächstem Jahr gespeichert
instance.holidays_normal = newdata[3][0] instance.holidays_normal = newdata[3][0]
instance.holidays_rest = 0 instance.holidays_rest = 0
instance.holidays_normal_next = newdata[3][1] instance.holidays_normal_next = newdata[3][1]
@ -646,6 +645,21 @@ def calculateHolidays(user, start, end, start_half, end_half):
if(dt == freeday.day): if(dt == freeday.day):
freedaycounter += 1 freedaycounter += 1
if(dt.isoweekday() == 1):
if user.usertime.wd_mo == 0.0:
freedaycounter += 1
elif(dt.isoweekday() == 2):
if user.usertime.wd_tu == 0.0:#
freedaycounter += 1
elif(dt.isoweekday() == 3):
if user.usertime.wd_we == 0.0:
freedaycounter += 1
elif(dt.isoweekday() == 4):
if user.usertime.wd_th == 0.0:
freedaycounter += 1
elif(dt.isoweekday() == 5):
if user.usertime.wd_fr == 0.0:
freedaycounter += 1
return restdays - counter + freedaycounter return restdays - counter + freedaycounter