diff --git a/adm/templates/adm/adm_bills.html b/adm/templates/adm/adm_bills.html index bbd0ad6..50271d0 100644 --- a/adm/templates/adm/adm_bills.html +++ b/adm/templates/adm/adm_bills.html @@ -19,7 +19,6 @@ {% for ele in bills %} - {{ele.agency.name}} {{ele.billnumber}} diff --git a/timemanagement/forms.py b/timemanagement/forms.py index 83499cf..905c100 100644 --- a/timemanagement/forms.py +++ b/timemanagement/forms.py @@ -59,6 +59,7 @@ class UpdateAbsence(forms.ModelForm): "reason" : "Abwesenheitsgrund", "representator" : "Vertreter", "info" : "Begründung", + "confirm_info" : "Begründung zur An- oder Ablehnung", "startday_info" : "", "endday_info" : "" } @@ -69,13 +70,14 @@ class UpdateAbsence(forms.ModelForm): #fields = ['start', 'start_ishalf', 'end','end_ishalf', 'reason', "representator", 'info'] - fields = ['start', 'startday_info', 'end','endday_info', 'reason', "representator", 'info', 'holidays_normal', 'holidays_rest', 'holidays_normal_next', 'holidays_rest_next' ] + fields = ['start', 'startday_info', 'end','endday_info', 'reason', "representator", 'info', 'holidays_normal', 'holidays_rest', 'holidays_normal_next', 'holidays_rest_next', 'confirm_info' ] def __init__(self, *arg, **kwargs): super(UpdateAbsence, self).__init__(*arg, **kwargs) self.fields['reason'].queryset = AbsenceReason.objects.filter(agency=kwargs['instance'].profile.agency).order_by('-name') self.fields['representator'].queryset = UserFullName.objects.filter(profile__agency=kwargs['instance'].profile.agency, ) self.fields['info'].widget.attrs['rows'] = 3 + self.fields['confirm_info'].widget.attrs['rows'] = 3 self.fields['start'].required = True self.fields['end'].required = True self.fields['reason'].required = True diff --git a/timemanagement/templates/timemanagement/tm_ab_update.html b/timemanagement/templates/timemanagement/tm_ab_update.html index fa47d65..e30dfb2 100644 --- a/timemanagement/templates/timemanagement/tm_ab_update.html +++ b/timemanagement/templates/timemanagement/tm_ab_update.html @@ -33,9 +33,17 @@ {{form.representator|as_crispy_field}} +
+
+
Begründung
+

{{absence.info}}

+
+
+
- {{form.info|as_crispy_field}} +
An- oder Ablehnung
+

{{absence.confirm_info}}

@@ -108,6 +116,11 @@ $(document).ready(function(){ + $("#id_info").val("{{absence.info}}"); + $("#id_info").prop("disabled", true); + $("#id_confirm_info").val("{{absence.confirm_info}}"); + $("#id_confirm_info").prop("disabled", true); + date_start = "{{start}}"; date_end = "{{end}}"; diff --git a/timemanagement/views.py b/timemanagement/views.py index 514e32b..0a1f2be 100644 --- a/timemanagement/views.py +++ b/timemanagement/views.py @@ -19,6 +19,8 @@ from datetime import timedelta from django.db.models.signals import post_save from users.signals import save_newabsence import locale +from django.template.loader import render_to_string +from django.core.mail import send_mail # Load freedays def loadingFreeDays(plz): @@ -107,13 +109,14 @@ def AbsenceUpdate(request, pk): absence.startday_info = str(formtocheck.cleaned_data["startday_info"]) absence.endday_info = str(formtocheck.cleaned_data["endday_info"]) absence.reason = formtocheck.cleaned_data["reason"] + absence.info = formtocheck.cleaned_data["info"] + absence.confirm_info = formtocheck.cleaned_data["confirm_info"] rep = None if(formtocheck.cleaned_data["representator"] != None): rep = User.objects.get(pk=formtocheck.cleaned_data["representator"].pk) + absence.representator = rep - absence.info = formtocheck.cleaned_data["info"] - absence.holidays_normal = 0.0 absence.holidays_rest = 0.0 absence.holidays_normal_next = 0.0 @@ -883,6 +886,21 @@ def TimeAjax(request): absence.save() post_save.connect(save_newabsence, sender=Absence) messages.success(request, f'Abwesenheit gespeichert!') + + if(absence.user.usernotifications.absence_created_mail): + notificationtext = " es wurde eine Abwesenheit bearbeitet!" + + msg_html = render_to_string('notificsys/notification_mail.html', {'username': absence.user.first_name + " " + absence.user.last_name, 'notificationtext' : notificationtext, 'linktarget' : ""}) + + send_mail( + 'Agentur-Benachrichtigung', + 'Hallo ' + absence.user.first_name + " " + absence.user.last_name + '! ' + notificationtext, + 'noreply@digitale-agentur.com', + [absence.user.email], + html_message=msg_html, + fail_silently=True + ) + else: messages.success(request, f'Das dürfen Sie nicht!') diff --git a/users/signals.py b/users/signals.py index c293063..a3e5cd1 100644 --- a/users/signals.py +++ b/users/signals.py @@ -646,6 +646,11 @@ def save_newabsence(sender, instance, **kwargs): usersofagency = User.objects.filter(profile__agency=instance.user.profile.agency) for user in usersofagency: + + if(user == instance.user and user.usernotifications.time_data_changed_mail): + sendMailNoti(" es wurde eine Abwesenheit erstellt!", user) + + # Benutzer erhält Benachrichtigung bei Abwesenheit, wenn er Rechte hat if(user.has_perm("users.absencemanager")): if(user.usernotifications.absence_created_mail): @@ -674,6 +679,11 @@ def save_newabsence(sender, instance, **kwargs): usersofagency = User.objects.filter(profile__agency=instance.user.profile.agency) for user in usersofagency: + # TASK: Hier die Signals eintragen, damit die Mails verschickt werden + if(user == instance.user and user.usernotifications.time_data_changed_mail): + sendMailNoti(" es wurde eine Abwesenheit verändert!", user) + + # Benutzer erhält Benachrichtigung bei Abwesenheit, wenn er Rechte hat if(user.has_perm("users.absencemanager")): if(user.usernotifications.time_data_changed_mail): @@ -741,6 +751,9 @@ def delete_absence(sender, instance, **kwargs): if(instance.reason.is_holiday): newdata = getFinalHolidayData(instance) + if(instance.user.usernotifications.time_data_changed_mail): + sendMailNoti(" die Abwesenheit vom " + str(instance.start) + " bis " + str(instance.start) + " wurde gelöscht.", instance.user) + abinfo = list(UserYearAbsenceInfo.objects.filter(user=instance.user, year=instance.start.year))[0] abinfo_lastyear = "" abinfo_nextyear = ""