Zeiterfassung
This commit is contained in:
parent
b63c458df4
commit
5a015fe583
|
|
@ -3,66 +3,50 @@
|
||||||
{% load counter_tag %}
|
{% load counter_tag %}
|
||||||
{% if request.user.profile.agency.module_timemanagement %}
|
{% if request.user.profile.agency.module_timemanagement %}
|
||||||
<div class="content-section col-12">
|
<div class="content-section col-12">
|
||||||
<h3>Zeiterfassung <small><i data-toggle="tooltip" data-placement="top" title="Bearbeiten Sie hier Ihre Zeiterfassung." class="far fa-question-circle"></i></small></h3>
|
<h3>Zeiterfassung <small><i data-toggle="tooltip" data-placement="top" title="Bearbeiten Sie hier Ihre Zeiterfassung." class="far fa-question-circle"></i></small>
|
||||||
|
<button type="button" class="btn btn-primary btn-sm" style="position: relative; float: right !important;" onclick=""><i class="fas fa-plus"></i> Arbeitstag</button>
|
||||||
|
</h3>
|
||||||
<hr>
|
<hr>
|
||||||
<div class="table-responsive ">
|
|
||||||
<table class="table table-hover" id="table_timemanagement" >
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th scope="col">#</th>
|
|
||||||
<th scope="col">Start</th>
|
|
||||||
<th scope="col">Ende</th>
|
|
||||||
<th scope="col">Arbeitszeit</th>
|
|
||||||
<th scope="col">Pausen</th>
|
|
||||||
<th scope="col">Gesamtzeit</th>
|
|
||||||
<th scope="col">Gleitzeit</th>
|
|
||||||
<th scope="col"> </th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody id="table_contacts" >
|
|
||||||
{% for workday in workdays %}
|
|
||||||
<tr id="wd_{{workday.pk}}">
|
|
||||||
<td>
|
|
||||||
{{forloop.counter}}
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
{{workday.start|date:"d.m.y H:i"}}
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
{{workday.end|date:"d.m.y H:i"}}
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
{% getsumworkdayexcludebreak workday as sumworkday %}
|
|
||||||
{{ sumworkday }}
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
{% getsumbreak workday as sumbreakofday %}
|
|
||||||
{{sumbreakofday}} min. ({{workday.breaks.all|length}})
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
{% getsumworkday workday as sumwd %}
|
|
||||||
{{sumwd}}
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
{% gettimeoveralldiff workday user as erg%}
|
|
||||||
{% if erg.1 == 0 %}
|
|
||||||
<span style="color: green">+{{erg.0}}</span>
|
|
||||||
{% elif erg.1 == 1 %}
|
|
||||||
<span>{{erg.0}}</span>
|
|
||||||
{% else %}
|
|
||||||
<span style="color: red">-{{erg.0}}</span>
|
|
||||||
{% endif %}
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<button class="btn btn-secondary btn-sm ml-2" onclick="window.location.href='{% url 'tm-update' workday.pk %}'"><small><i class="fas fa-pen"></i></small></button>
|
|
||||||
<button class="btn btn-secondary btn-sm " onclick="javascript:$('#confirm-delete_{{workday.pk}}').modal('toggle')"><small><i class="fas fa-trash"></i></small></button>
|
|
||||||
</td>
|
|
||||||
|
|
||||||
</tr>
|
|
||||||
{% endfor %}
|
<!-- TODO: Hier noch Jahr speichern und Monat usw. -->
|
||||||
</tbody>
|
<div class="btn-group" role="group" aria-label="" style="min-width: 100% !important">
|
||||||
</table>
|
<button type="button" class="btn btn-primary mr-1" onclick="{% url 'tm-management' prev_month 2020 %}" ><i class="fas fa-arrow-circle-left"></i></button>
|
||||||
</div>
|
<button type="button" class="btn btn-primary mr-1" style="min-width: 150px !important;" onclick="">{{active_month}}</button>
|
||||||
|
<button type="button" class="btn btn-primary mr-1" onclick="{% url 'tm-management' next_month 2020 %}"><i class="fas fa-arrow-circle-right"></i></button>
|
||||||
|
</div>
|
||||||
|
<hr>
|
||||||
|
{% for workday in workdays %}
|
||||||
|
{% if workday.start.weekday == 0 %}
|
||||||
|
{{workday.start|date:"W"}}. Woche
|
||||||
|
<hr>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
<div class="card col-2">
|
||||||
|
<div class="card-body">
|
||||||
|
<h5 class="card-title">{{workday.start|date:"l"}}, {{workday.start|date:"d.m"}}</h5>
|
||||||
|
Von {{workday.start|date:"H:i"}} bis {{workday.end|date:"H:i"}}<br />
|
||||||
|
<small>
|
||||||
|
{% getsumworkdayexcludebreak workday as sumworkday %}
|
||||||
|
Arbeitszeit: {{ sumworkday }}<br />
|
||||||
|
{% getsumbreak workday as sumbreakofday %}
|
||||||
|
Pausen: {{sumbreakofday}} min. ({{workday.breaks.all|length}})
|
||||||
|
{% getsumworkday workday as sumwd %}
|
||||||
|
Gesamtzeit: {{sumwd}}<br />
|
||||||
|
Gleitzeit:
|
||||||
|
{% gettimeoveralldiff workday user as erg%}
|
||||||
|
{% if erg.1 == 0 %}
|
||||||
|
<span style="color: green">+{{erg.0}}</span>
|
||||||
|
{% elif erg.1 == 1 %}
|
||||||
|
<span>{{erg.0}}</span>
|
||||||
|
{% else %}
|
||||||
|
<span style="color: red">-{{erg.0}}</span>
|
||||||
|
{% endif %}
|
||||||
|
</small>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{% endfor %}
|
||||||
|
|
||||||
{% 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">
|
||||||
|
|
@ -115,10 +99,11 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
|
||||||
$(document).ready(function(){
|
$(document).ready(function(){
|
||||||
$("#initialload").modal("toggle");
|
//$("#initialload").modal("toggle");
|
||||||
});
|
});
|
||||||
|
|
||||||
function loadInitiDays(){
|
function loadInitiDays(){
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,214 @@
|
||||||
|
{% extends "users/base.html" %}
|
||||||
|
{% block content %}
|
||||||
|
{% load counter_tag %}
|
||||||
|
{% if request.user.profile.agency.module_timemanagement %}
|
||||||
|
<div class="content-section col-12">
|
||||||
|
<h3>Zeiterfassung <small><i data-toggle="tooltip" data-placement="top" title="Bearbeiten Sie hier Ihre Zeiterfassung." class="far fa-question-circle"></i></small></h3>
|
||||||
|
<hr>
|
||||||
|
<div class="table-responsive ">
|
||||||
|
<table class="table table-hover" id="table_timemanagement" >
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th scope="col">#</th>
|
||||||
|
<th scope="col">Start</th>
|
||||||
|
<th scope="col">Ende</th>
|
||||||
|
<th scope="col">Arbeitszeit</th>
|
||||||
|
<th scope="col">Pausen</th>
|
||||||
|
<th scope="col">Gesamtzeit</th>
|
||||||
|
<th scope="col">Gleitzeit</th>
|
||||||
|
<th scope="col"> </th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody id="table_contacts" >
|
||||||
|
{% for workday in workdays %}
|
||||||
|
<tr id="wd_{{workday.pk}}">
|
||||||
|
<td>
|
||||||
|
{{forloop.counter}}
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
{{workday.start|date:"d.m.y H:i"}}
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
{{workday.end|date:"d.m.y H:i"}}
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
{% getsumworkdayexcludebreak workday as sumworkday %}
|
||||||
|
{{ sumworkday }}
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
{% getsumbreak workday as sumbreakofday %}
|
||||||
|
{{sumbreakofday}} min. ({{workday.breaks.all|length}})
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
{% getsumworkday workday as sumwd %}
|
||||||
|
{{sumwd}}
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
{% gettimeoveralldiff workday user as erg%}
|
||||||
|
{% if erg.1 == 0 %}
|
||||||
|
<span style="color: green">+{{erg.0}}</span>
|
||||||
|
{% elif erg.1 == 1 %}
|
||||||
|
<span>{{erg.0}}</span>
|
||||||
|
{% else %}
|
||||||
|
<span style="color: red">-{{erg.0}}</span>
|
||||||
|
{% endif %}
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<button class="btn btn-secondary btn-sm ml-2" onclick="window.location.href='{% url 'tm-update' workday.pk %}'"><small><i class="fas fa-pen"></i></small></button>
|
||||||
|
<button class="btn btn-secondary btn-sm " onclick="javascript:$('#confirm-delete_{{workday.pk}}').modal('toggle')"><small><i class="fas fa-trash"></i></small></button>
|
||||||
|
</td>
|
||||||
|
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{% if user.usertime.usetime_start == None %}
|
||||||
|
<div class="modal fade" tabindex="-1" role="dialog" data-backdrop="static" id="missingdatainfo">
|
||||||
|
<div class="modal-dialog" role="document">
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header">
|
||||||
|
<h5 class="modal-title">Fehlende Informationen</h5>
|
||||||
|
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||||
|
<span aria-hidden="true">×</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
Achtung! Es wurde kein Datum gefunden, ab wann die Zeiterfassung beginnen soll. Bitte tragen Sie dies in Ihrem Mitarbeiterkonto unter Einstellungen, Mitarbeiter, Ihre Vertragsdaten nach.
|
||||||
|
<br />
|
||||||
|
<small>Dies können nur Mitarbeiter eintragen, die das Recht haben, Mitarbeiter zu verwalten.</small>
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
<button type="button" class="btn btn-primary" data-dismiss="modal">Schließen</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<script type="text/javascript">
|
||||||
|
$(document).ready(function(){
|
||||||
|
$("#missingdatainfo").modal("toggle");
|
||||||
|
})
|
||||||
|
|
||||||
|
$('#missingdatainfo').on('hidden.bs.modal', function (e) {
|
||||||
|
location.href = "{% url 'dasettings' %}";
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
{% elif workdays|length == 0 %}
|
||||||
|
<div class="modal fade" tabindex="-1" role="dialog" data-backdrop="static" id="initialload">
|
||||||
|
<div class="modal-dialog" role="document">
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header">
|
||||||
|
<h5 class="modal-title">Arbeitstage auffüllen</h5>
|
||||||
|
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||||
|
<span aria-hidden="true">×</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
Es wurden keine Arbeitstage bis zum Beginn der Zeiterfassung am {{user.usertime.usetime_start|date:"d.m.Y"}} gefunden. Sollen diese Tage mit der Regelarbeitszeit aufgefüllt werden, welche bei den Vertragsdaten hinterlegt wurde?
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
<button type="button" class="btn btn-primary" onclick="javascript:loadInitiDays()">Ja</button>
|
||||||
|
<button type="button" class="btn btn" data-dismiss="modal">Nein</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<script type="text/javascript">
|
||||||
|
|
||||||
|
$(document).ready(function(){
|
||||||
|
$("#initialload").modal("toggle");
|
||||||
|
});
|
||||||
|
|
||||||
|
function loadInitiDays(){
|
||||||
|
$.ajax(
|
||||||
|
{
|
||||||
|
type: "GET",
|
||||||
|
url: "{% url 'tm-ajax' %}",
|
||||||
|
data:{
|
||||||
|
action : "initial_load",
|
||||||
|
},
|
||||||
|
success: function( data )
|
||||||
|
{
|
||||||
|
location.href = location.href;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
</script>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% for workday in workdays %}
|
||||||
|
<div class="modal fade" id="confirm-delete_{{workday.pk}}" tabindex="-1" role="dialog" aria-labelledby="" aria-hidden="true">
|
||||||
|
<div class="modal-dialog">
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header">
|
||||||
|
<h5 class="modal-title">Arbeitstag löschen</h5>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
Möchten Sie wirklich den Arbeitstag am {{workday.start|date:"d.m"}} löschen?
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
<button class="btn btn-primary" id="dodel_{{workday.pk}}" >Löschen</button>
|
||||||
|
<button type="button" class="btn" data-dismiss="modal">Abbrechen</button>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<script type="text/javascript">
|
||||||
|
|
||||||
|
$("#dodel_{{workday.pk}}").click(function(){
|
||||||
|
$.ajax(
|
||||||
|
{
|
||||||
|
type: "GET",
|
||||||
|
url: "{% url 'tm-ajax' %}",
|
||||||
|
data:{
|
||||||
|
action : "remove_workday",
|
||||||
|
workday: {{workday.pk}},
|
||||||
|
},
|
||||||
|
success: function( data )
|
||||||
|
{
|
||||||
|
$("#wd_{{workday.pk}}").remove();
|
||||||
|
$("#confirm-delete_{{workday.pk}}").modal("toggle");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
{% endfor %}
|
||||||
|
<style>
|
||||||
|
/* DATATABLES */
|
||||||
|
.paginate_button {
|
||||||
|
padding: 0px !important;
|
||||||
|
border: 0px !important;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<script>
|
||||||
|
$(document).ready(function(){
|
||||||
|
|
||||||
|
$('#table_timemanagement').DataTable({
|
||||||
|
"language": {
|
||||||
|
"search" : "Suche",
|
||||||
|
"info": "Zeige _START_ bis _END_ von _TOTAL_ Einträgen",
|
||||||
|
"lengthMenu": "Zeige _MENU_ Einträge",
|
||||||
|
"zeroRecords": "Nichts gefunden",
|
||||||
|
"infoEmpty": "Keine Einträge",
|
||||||
|
"paginate": {
|
||||||
|
"first": "Erste",
|
||||||
|
"last": "Letzte",
|
||||||
|
"next": "Nächste",
|
||||||
|
"previous": "Zurück"
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"buttons" : {
|
||||||
|
"className" : "btn-danger"
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
</script>
|
||||||
|
{% else %}
|
||||||
|
<h3>Das Modul Abwesenheits- und Zeiterfassung wurde in ihrer Agentur deaktiviert oder die Zeiterfassung wurde im Modul deaktiviert.</h3>
|
||||||
|
{% endif %}
|
||||||
|
{% endblock content %}
|
||||||
|
|
@ -7,6 +7,7 @@ Permissions definiert in models.py bei USERS und dann hier vor die View geschrie
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path('', TimeManagement, name='tm-management'),
|
path('', TimeManagement, name='tm-management'),
|
||||||
|
path('<int:activemonth>/<int:activeyear>', TimeManagement, name='tm-management'),
|
||||||
path('update/<int:pk>', TimeUpdate, name='tm-update'),
|
path('update/<int:pk>', TimeUpdate, name='tm-update'),
|
||||||
path('update/<int:pk>/addbreak/', AddBreak, name='add-break'),
|
path('update/<int:pk>/addbreak/', AddBreak, name='add-break'),
|
||||||
path('abs/', AbsenceManagmenet, name='tma-management'),
|
path('abs/', AbsenceManagmenet, name='tma-management'),
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@ from users.models import UserTime
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
from django.db.models.signals import post_save
|
from django.db.models.signals import post_save
|
||||||
from users.signals import save_newabsence
|
from users.signals import save_newabsence
|
||||||
|
import locale
|
||||||
|
|
||||||
# Load freedays
|
# Load freedays
|
||||||
def loadingFreeDays(plz):
|
def loadingFreeDays(plz):
|
||||||
|
|
@ -277,15 +278,37 @@ def AbsenceManagmenet(request, activemonth=False, activeyear=False):
|
||||||
"needtoconfirm" : Absence.objects.filter(agency=request.user.profile.agency, confirm_status=1).order_by("-start"),
|
"needtoconfirm" : Absence.objects.filter(agency=request.user.profile.agency, confirm_status=1).order_by("-start"),
|
||||||
"allabsences" : Absence.objects.filter(agency=request.user.profile.agency).order_by("-start")
|
"allabsences" : Absence.objects.filter(agency=request.user.profile.agency).order_by("-start")
|
||||||
})
|
})
|
||||||
|
|
||||||
return render(request, 'timemanagement/tm_ab_management.html', context)
|
return render(request, 'timemanagement/tm_ab_management.html', context)
|
||||||
|
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
def TimeManagement(request):
|
def TimeManagement(request, activemonth=False, activeyear=False):
|
||||||
# TODO: Abwesenheiten mit berücksichtigen!
|
# TODO: Abwesenheiten mit berücksichtigen!
|
||||||
|
|
||||||
|
locale.setlocale(locale.LC_TIME, 'de_DE.UTF-8')
|
||||||
|
|
||||||
|
# TODO: Hier noch umbauen, dass das Datum beim Wechsel mit auf diesen Monat gesetzt wird
|
||||||
|
# TODO: Jahr fehlt auch noch :)
|
||||||
|
if(activemonth == False):
|
||||||
|
today = datetime.datetime.today()
|
||||||
|
active_month = str(today.strftime("%B"))
|
||||||
|
else:
|
||||||
|
today = datetime.datetime(2020, activemonth, 1)
|
||||||
|
active_month = activemonth
|
||||||
|
active_month = str(today.strftime("%B"))
|
||||||
|
|
||||||
|
next_month = today.month + 1
|
||||||
|
if(next_month == 13):
|
||||||
|
next_month = 1
|
||||||
|
|
||||||
|
prev_month = today.month - 1
|
||||||
|
if(prev_month == 0):
|
||||||
|
prev_month = 12
|
||||||
|
|
||||||
context = {
|
context = {
|
||||||
|
"next_month" : next_month,
|
||||||
|
"prev_month" : prev_month,
|
||||||
|
"active_month" : active_month,
|
||||||
"active_link" : "timemanagement",
|
"active_link" : "timemanagement",
|
||||||
"workdays" : Workday.objects.filter(agency=request.user.profile.agency, user=request.user).order_by("-start").exclude(end=None)
|
"workdays" : Workday.objects.filter(agency=request.user.profile.agency, user=request.user).order_by("-start").exclude(end=None)
|
||||||
}
|
}
|
||||||
|
|
@ -965,6 +988,3 @@ def calculatingHolidaysByAbsence(request, absence):
|
||||||
def daterange(date1, date2):
|
def daterange(date1, date2):
|
||||||
for n in range(int ((date2 - date1).days)+1):
|
for n in range(int ((date2 - date1).days)+1):
|
||||||
yield date1 + timedelta(n)
|
yield date1 + timedelta(n)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue