Benachrichtigungen weiter, Wochenende in Arbeitszeit eingefügt
This commit is contained in:
parent
814b087b42
commit
0a674f71ca
|
|
@ -273,10 +273,12 @@ class UserTimeForm(forms.ModelForm):
|
|||
"wd_we" : "Mittwoch",
|
||||
"wd_th" : "Donnerstag",
|
||||
"wd_fr" : "Freitag",
|
||||
"wd_sa" : "Samstag",
|
||||
"wd_so" : "Sonntag",
|
||||
"usetime" : "Zeiterfassung" ,
|
||||
"usetime_start" : "Zeiterfassung ab"
|
||||
}
|
||||
fields = ["startdate", "usetime", "usetime_start", "wd_mo", "wd_tu", "wd_we", "wd_th", "wd_fr", "loose_holidedate"]
|
||||
fields = ["startdate", "usetime", "usetime_start", "wd_mo", "wd_tu", "wd_we", "wd_th", "wd_fr", "wd_sa", "wd_so", "loose_holidedate"]
|
||||
widgets = {
|
||||
"startdate" : DatePickerInput(options={"format":'DD.MM.YYYY', "locale":'de'}),
|
||||
"usetime_start" : DatePickerInput(options={"format":'DD.MM.YYYY', "locale":'de'})
|
||||
|
|
|
|||
|
|
@ -190,6 +190,8 @@
|
|||
<td>{{usertime_form.wd_we|as_crispy_field}}</td>
|
||||
<td>{{usertime_form.wd_th|as_crispy_field}}</td>
|
||||
<td>{{usertime_form.wd_fr|as_crispy_field}}</td>
|
||||
<td>{{usertime_form.wd_sa|as_crispy_field}}</td>
|
||||
<td>{{usertime_form.wd_so|as_crispy_field}}</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -619,9 +619,14 @@ def getthisdaynotworking(user, day):
|
|||
elif(day.isoweekday() == 5):
|
||||
if user.usertime.wd_fr == 0.0:
|
||||
stat = True
|
||||
elif(day.isoweekday() == 6):
|
||||
if user.usertime.wd_sa == 0.0:
|
||||
stat = True
|
||||
elif(day.isoweekday() == 7):
|
||||
if user.usertime.wd_so == 0.0:
|
||||
stat = True
|
||||
return stat
|
||||
|
||||
|
||||
'''
|
||||
|
||||
Gibt das verfügbare Urlaubskontingent eines Mitarbeiters zurück
|
||||
|
|
|
|||
|
|
@ -41,9 +41,6 @@
|
|||
<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 %}
|
||||
<!-- WEEKEND -->
|
||||
<td id="{{actfcounter}}_{{forloop.counter}}_{{us.pk}}_free" style="background-color: #d3d3d3">
|
||||
{% elif abday != False %}
|
||||
<!-- USER IS NOT THERE -->
|
||||
{% if abday.confirm_status == 0 %}
|
||||
|
|
@ -159,7 +156,12 @@
|
|||
<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 %} >
|
||||
<!-- Unterscheidung zwischen Wochenende zur Färbung -->
|
||||
{% if da.weekday == 5 or da.weekday == 6 %}
|
||||
<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: #e1e1e1;" >
|
||||
{% 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>
|
||||
{% endfor %}
|
||||
|
|
|
|||
|
|
@ -358,7 +358,11 @@ def TimeAjax(request):
|
|||
elif(today.isoweekday() == 4):
|
||||
targettime = request.user.usertime.wd_th
|
||||
elif(today.isoweekday() == 5):
|
||||
targettime = request.user.usertime.wd_fr
|
||||
targettime = request.user.usertime.wd_fr
|
||||
elif(today.isoweekday() == 6):
|
||||
targettime = request.user.usertime.wd_sa
|
||||
elif(today.isoweekday() == 7):
|
||||
targettime = request.user.usertime.wd_so
|
||||
|
||||
wd = Workday(user=request.user, agency=request.user.profile.agency, start=timezone.now(), target=targettime)
|
||||
wd.save()
|
||||
|
|
@ -504,6 +508,27 @@ def TimeAjax(request):
|
|||
|
||||
Workday.objects.create(user=request.user, agency=request.user.profile.agency, start=start_datetime, end=end_datetime, target=request.user.usertime.wd_fr)
|
||||
|
||||
if(dt.isoweekday() == 6):
|
||||
start_time = datetime.timedelta(hours=8)
|
||||
start_date = datetime.date(int(dt.year), int(dt.month), int(dt.day))
|
||||
end_time = datetime.timedelta(hours=request.user.usertime.wd_sa) + start_time
|
||||
time_start = datetime.datetime.strptime(str(start_time), "%H:%M:%S").time()
|
||||
time_end = datetime.datetime.strptime(str(end_time), "%H:%M:%S").time()
|
||||
start_datetime = datetime.datetime.combine(start_date, time_start)
|
||||
end_datetime = datetime.datetime.combine(start_date, time_end)
|
||||
|
||||
Workday.objects.create(user=request.user, agency=request.user.profile.agency, start=start_datetime, end=end_datetime, target=request.user.usertime.wd_sa)
|
||||
|
||||
if(dt.isoweekday() == 7):
|
||||
start_time = datetime.timedelta(hours=8)
|
||||
start_date = datetime.date(int(dt.year), int(dt.month), int(dt.day))
|
||||
end_time = datetime.timedelta(hours=request.user.usertime.wd_so) + start_time
|
||||
time_start = datetime.datetime.strptime(str(start_time), "%H:%M:%S").time()
|
||||
time_end = datetime.datetime.strptime(str(end_time), "%H:%M:%S").time()
|
||||
start_datetime = datetime.datetime.combine(start_date, time_start)
|
||||
end_datetime = datetime.datetime.combine(start_date, time_end)
|
||||
|
||||
Workday.objects.create(user=request.user, agency=request.user.profile.agency, start=start_datetime, end=end_datetime, target=request.user.usertime.wd_so)
|
||||
# Get Rendered Table
|
||||
elif request.GET["action"] == "getrenderedtable":
|
||||
prevmonth = ""
|
||||
|
|
@ -820,7 +845,7 @@ def calculateHolidays(request, start, end, start_half, end_half, user):
|
|||
if(end_half):
|
||||
counter -= 0.5
|
||||
|
||||
weekdays = [6,7]
|
||||
weekdays = []
|
||||
freedaycounter = 0
|
||||
for dt in daterange(start, end):
|
||||
|
||||
|
|
@ -846,6 +871,12 @@ def calculateHolidays(request, start, end, start_half, end_half, user):
|
|||
elif(dt.isoweekday() == 5):
|
||||
if user.usertime.wd_fr == 0.0:
|
||||
freedaycounter += 1
|
||||
elif(dt.isoweekday() == 6):
|
||||
if user.usertime.wd_sa == 0.0:
|
||||
freedaycounter += 1
|
||||
elif(dt.isoweekday() == 7):
|
||||
if user.usertime.wd_so == 0.0:
|
||||
freedaycounter += 1
|
||||
|
||||
|
||||
return restdays - counter + freedaycounter
|
||||
|
|
@ -871,7 +902,7 @@ def calculatingHolidaysByAbsence(request, absence):
|
|||
if absence.endday_info == "1" or absence.endday_info == "2":
|
||||
finalholidayinabsence -= 0.5
|
||||
|
||||
weekdays = [6,7]
|
||||
weekdays = []
|
||||
freedaycounter = 0
|
||||
for dt in daterange(absence.start, absence.end):
|
||||
|
||||
|
|
@ -899,6 +930,12 @@ def calculatingHolidaysByAbsence(request, absence):
|
|||
elif(dt.isoweekday() == 5):
|
||||
if absence.user.usertime.wd_fr == 0.0:
|
||||
freedaycounter += 1
|
||||
elif(dt.isoweekday() == 6):
|
||||
if absence.user.usertime.wd_sa == 0.0:
|
||||
freedaycounter += 1
|
||||
elif(dt.isoweekday() == 7):
|
||||
if absence.user.usertime.wd_so == 0.0:
|
||||
freedaycounter += 1
|
||||
|
||||
return finalholidayinabsence - freedaycounter
|
||||
|
||||
|
|
|
|||
|
|
@ -255,11 +255,13 @@ class UserTime(models.Model):
|
|||
|
||||
user = models.OneToOneField(User, on_delete=models.CASCADE, blank=True, null=True, default=None)
|
||||
# TIME ELEMENTS
|
||||
wd_mo = models.FloatField(default=8.0)
|
||||
wd_tu = models.FloatField(default=8.0)
|
||||
wd_we = models.FloatField(default=8.0)
|
||||
wd_th = models.FloatField(default=8.0)
|
||||
wd_fr = models.FloatField(default=8.0)
|
||||
wd_mo = models.FloatField(default=0.0)
|
||||
wd_tu = models.FloatField(default=0.0)
|
||||
wd_we = models.FloatField(default=0.0)
|
||||
wd_th = models.FloatField(default=0.0)
|
||||
wd_fr = models.FloatField(default=0.0)
|
||||
wd_sa = models.FloatField(default=0.0)
|
||||
wd_so = models.FloatField(default=0.0)
|
||||
loose_holidedate = models.CharField(default="30.04.", max_length=6)
|
||||
startdate = models.DateField(default=None, blank=True, null=True)
|
||||
usetime = models.BooleanField(default=False)
|
||||
|
|
@ -363,7 +365,6 @@ class UserNotifications(models.Model):
|
|||
absence_user_is_rep_reminder_mail = models.BooleanField(default=True)
|
||||
absence_user_is_rep_reminder_push = models.BooleanField(default=True)
|
||||
|
||||
# Zeiterfassung
|
||||
# Info an den User, wenn seine Zeitdaten verändert wurden
|
||||
time_data_changed_mail = models.BooleanField(default=True)
|
||||
time_data_changed_push = models.BooleanField(default=True)
|
||||
|
|
|
|||
|
|
@ -130,7 +130,7 @@ def sendMailNoti(notificationtext, user_touched, linktarget=""):
|
|||
html_message=msg_html,
|
||||
fail_silently=True
|
||||
)
|
||||
|
||||
|
||||
|
||||
|
||||
# Deletes all Notifications added to to delete news
|
||||
|
|
@ -612,7 +612,63 @@ def save_newabsence(sender, instance, **kwargs):
|
|||
instance.holidays_rest_next = newdata[3][3]
|
||||
instance.save()
|
||||
|
||||
# NEUE ABWESENHEIT ERSTELLT
|
||||
if(kwargs["created"]):
|
||||
|
||||
usersofagency = User.objects.filter(profile__agency=instance.user.profile.agency)
|
||||
|
||||
for user in usersofagency:
|
||||
# Benutzer erhält Benachrichtigung bei Abwesenheit, wenn er Rechte hat
|
||||
if(user.has_perm("users.absencemanager")):
|
||||
if(user.usernotifications.absence_created_mail):
|
||||
sendMailNoti(" es wurde eine neue Abwesenheit für den Mitarbeiter " + instance.user.first_name + " " + instance.user.last_name + " eingetragen!", user)
|
||||
|
||||
if(user.usernotifications.absence_created_push):
|
||||
newnotification = UserNotification(touser=user, notificationtext="Neue Abwesenheit!", notificationtype="", elementid=instance.pk)
|
||||
newnotification.save()
|
||||
|
||||
channel_layer = channels.layers.get_channel_layer()
|
||||
async_to_sync(channel_layer.group_send)("user_" + str(user.pk), {'type' : 'pushhandler', 'pushtext' : "pushnotification__Abwesenheit | Neue Abwesenheit für " + instance.user.first_name + " " + instance.user.last_name + " eingetragen!"})
|
||||
# Benutzer ist Vertreter
|
||||
if(user == instance.representator):
|
||||
if(user.usernotifications.absence_user_is_rep_mail):
|
||||
sendMailNoti(" Sie wurden als Vertreter bei einer Abwesenheit von " + instance.user.first_name + " " + instance.user.last_name + " eingetragen!", user)
|
||||
|
||||
if(user.usernotifications.absence_user_is_rep_push):
|
||||
newnotification = UserNotification(touser=user, notificationtext="Neue Abwesenheitsvertretung!", notificationtype="", elementid=instance.pk)
|
||||
newnotification.save()
|
||||
|
||||
channel_layer = channels.layers.get_channel_layer()
|
||||
async_to_sync(channel_layer.group_send)("user_" + str(user.pk), {'type' : 'pushhandler', 'pushtext' : "pushnotification__Abwesenheit | Sie wurden als Vertreter für " + instance.user.first_name + " " + instance.user.last_name + " eingetragen!"})
|
||||
|
||||
# ABWESENHEIT GEÄNDERT
|
||||
else:
|
||||
usersofagency = User.objects.filter(profile__agency=instance.user.profile.agency)
|
||||
|
||||
for user in usersofagency:
|
||||
# Benutzer erhält Benachrichtigung bei Abwesenheit, wenn er Rechte hat
|
||||
if(user.has_perm("users.absencemanager")):
|
||||
if(user.usernotifications.time_data_changed_mail):
|
||||
sendMailNoti(" es wurde eine Abwesenheit für den Mitarbeiter " + instance.user.first_name + " " + instance.user.last_name + " aktualisiert!", user)
|
||||
|
||||
if(user.usernotifications.time_data_changed_push):
|
||||
newnotification = UserNotification(touser=user, notificationtext="Aktualisierte Abwesenheit!", notificationtype="", elementid=instance.pk)
|
||||
newnotification.save()
|
||||
|
||||
channel_layer = channels.layers.get_channel_layer()
|
||||
async_to_sync(channel_layer.group_send)("user_" + str(user.pk), {'type' : 'pushhandler', 'pushtext' : "pushnotification__Abwesenheit | Abwesenheit für " + instance.user.first_name + " " + instance.user.last_name + " wurde aktualisiert!"})
|
||||
|
||||
# Benutzer ist Vertreter
|
||||
if(user == instance.representator):
|
||||
if(user.usernotifications.absence_user_is_rep_mail):
|
||||
sendMailNoti(" Sie wurden als Vertreter bei einer Abwesenheit von " + instance.user.first_name + " " + instance.user.last_name + " eingetragen!", user)
|
||||
|
||||
if(user.usernotifications.absence_user_is_rep_push):
|
||||
newnotification = UserNotification(touser=user, notificationtext="Neue Abwesenheitsvertretung!", notificationtype="", elementid=instance.pk)
|
||||
newnotification.save()
|
||||
|
||||
channel_layer = channels.layers.get_channel_layer()
|
||||
async_to_sync(channel_layer.group_send)("user_" + str(user.pk), {'type' : 'pushhandler', 'pushtext' : "pushnotification__Abwesenheit | Sie wurden als Vertreter für " + instance.user.first_name + " " + instance.user.last_name + " eingetragen!"})
|
||||
|
||||
else:
|
||||
print("Absence-Object is no holiday...")
|
||||
|
|
@ -780,7 +836,7 @@ def calculateHolidays(user, start, end, start_half, end_half):
|
|||
if(end_half):
|
||||
counter -= 0.5
|
||||
|
||||
weekdays = [6,7]
|
||||
weekdays = []
|
||||
freedaycounter = 0
|
||||
for dt in daterange(start, end):
|
||||
|
||||
|
|
@ -794,7 +850,7 @@ def calculateHolidays(user, start, end, start_half, end_half):
|
|||
if user.usertime.wd_mo == 0.0:
|
||||
freedaycounter += 1
|
||||
elif(dt.isoweekday() == 2):
|
||||
if user.usertime.wd_tu == 0.0:#
|
||||
if user.usertime.wd_tu == 0.0:
|
||||
freedaycounter += 1
|
||||
elif(dt.isoweekday() == 3):
|
||||
if user.usertime.wd_we == 0.0:
|
||||
|
|
@ -805,6 +861,12 @@ def calculateHolidays(user, start, end, start_half, end_half):
|
|||
elif(dt.isoweekday() == 5):
|
||||
if user.usertime.wd_fr == 0.0:
|
||||
freedaycounter += 1
|
||||
elif(dt.isoweekday() == 6):
|
||||
if user.usertime.wd_sa == 0.0:
|
||||
freedaycounter += 1
|
||||
elif(dt.isoweekday() == 7):
|
||||
if user.usertime.wd_so == 0.0:
|
||||
freedaycounter += 1
|
||||
|
||||
return restdays - counter + freedaycounter
|
||||
|
||||
|
|
|
|||
|
|
@ -40,8 +40,8 @@ from asgiref.sync import async_to_sync
|
|||
from channels_presence.models import Room
|
||||
from channels_presence.models import Presence
|
||||
import channels.layers
|
||||
from datetime import date
|
||||
from timemanagement.models import Workday
|
||||
from datetime import date, timedelta
|
||||
from timemanagement.models import Workday, Absence
|
||||
import base64
|
||||
import filetype
|
||||
from django.db.models.signals import m2m_changed
|
||||
|
|
@ -959,7 +959,20 @@ def cronactionsdaily(request, code):
|
|||
wd.end = datetime(wd.start.year, wd.start.month, wd.start.day, 23, 59)
|
||||
wd.save()
|
||||
|
||||
# Erinnerungsmails/Push bei Vertretung verschicken
|
||||
one_week_later = date.today() + timedelta(days=7)
|
||||
repre_absence = Absence.objects.filter(representator=user, start=one_week_later)
|
||||
|
||||
for r in repre_absence:
|
||||
if(r.representator.usernotifications.absence_user_is_rep_reminder_mail):
|
||||
sendMailNoti(" in einer Woche startet Ihre Vertretung für " + r.user.first_name + " " + r.user.last_name + "!", user)
|
||||
if(r.representator.usernotifications.absence_user_is_rep_reminder_push):
|
||||
newnotification = UserNotification(touser=user, notificationtext="Erinnerung für Abwesenheitsvertretung!", notificationtype="", elementid=r.pk)
|
||||
newnotification.save()
|
||||
|
||||
channel_layer = channels.layers.get_channel_layer()
|
||||
async_to_sync(channel_layer.group_send)("user_" + str(user.pk), {'type' : 'pushhandler', 'pushtext' : "pushnotification__Abwesenheit | In einer Woche startet Ihre Vertretung für " + r.user.first_name + " " + r.user.last_name + "!"})
|
||||
|
||||
data.update({"status" : "ok"})
|
||||
|
||||
else:
|
||||
|
|
@ -968,3 +981,15 @@ def cronactionsdaily(request, code):
|
|||
return JsonResponse(data)
|
||||
|
||||
|
||||
def sendMailNoti(notificationtext, user_touched, linktarget=""):
|
||||
|
||||
username = user_touched.first_name + " " + user_touched.last_name
|
||||
msg_html = render_to_string('notificsys/notification_mail.html', {'username': username, 'notificationtext' : notificationtext, 'linktarget' : linktarget})
|
||||
send_mail(
|
||||
'Agentur-Benachrichtigung',
|
||||
'Hallo ' + user_touched.first_name + ' ' + user_touched.last_name + '! ' + notificationtext,
|
||||
'noreply@digitale-agentur.com',
|
||||
[user_touched.email],
|
||||
html_message=msg_html,
|
||||
fail_silently=True
|
||||
)
|
||||
Loading…
Reference in New Issue