Bugs und Zeiterfassung QS
This commit is contained in:
parent
a38e6e682e
commit
5d49d05ebd
|
|
@ -4,7 +4,7 @@
|
|||
{% load counter_tag %}
|
||||
{% if request.user.profile.agency.module_timemanagement %}
|
||||
<div class="content-section col-5">
|
||||
<h3>Arbeitstag hinzufügen</h3>
|
||||
<h3>Arbeitstag {% if team == 1 %} von {{user.get_full_name}} {% endif %} hinzufügen</h3>
|
||||
<hr>
|
||||
<h5>Start- und Endzeitpunkt</h5>
|
||||
<div class="col-6" style="margin-left: -10px;">
|
||||
|
|
|
|||
|
|
@ -1 +0,0 @@
|
|||
ÜBERSICHT
|
||||
|
|
@ -16,8 +16,8 @@
|
|||
<tbody id="tableresults">
|
||||
{% for item in usersofagency %}
|
||||
<tr>
|
||||
<td><a href="{% url 'user_updateprofile' item.pk 0 %}">{{item.first_name }}</a></td>
|
||||
<td><a href="{% url 'user_updateprofile' item.pk 0 %}">{{ item.last_name }}</a></td>
|
||||
<td>{{item.first_name }}</td>
|
||||
<td>{{ item.last_name }}</td>
|
||||
<td>{{ item.email }}</td>
|
||||
<td>{% if item.profile.func == None %}-{%else%}{{ item.profile.func }}{%endif%}</td>
|
||||
<td>
|
||||
|
|
@ -34,8 +34,9 @@
|
|||
</td>
|
||||
<td>{% if item.last_login != Nonte %}{{ item.last_login }}{% endif %}</td>
|
||||
<td>
|
||||
{% if item != request.user %}
|
||||
<a href="{% url 'users-delete' item.pk %}" ><button class="btn btn-sm btn-secondary"><i class="fas fa-trash"></i></button></a>
|
||||
{% if item.usertime.usetime %}
|
||||
<a href="{% url 'tm-team-single' item.pk %}" ><button class="btn btn-sm btn-primary"><i class="fas fa-eye"></i></button></a>{% else %}
|
||||
Mitarbeiter macht keine Zeiterfassung.
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
|
|
@ -43,12 +44,10 @@
|
|||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
|
||||
<script>
|
||||
$(document).ready(function(){
|
||||
|
||||
$('#usertableall').DataTable({
|
||||
"order" : [],
|
||||
"language": {
|
||||
"search" : "Suche",
|
||||
"info": "Zeige _START_ bis _END_ von _TOTAL_ Einträgen",
|
||||
|
|
@ -62,11 +61,12 @@ $(document).ready(function(){
|
|||
"previous": "Zurück"
|
||||
},
|
||||
},
|
||||
"pageLength": 50,
|
||||
"buttons" : {
|
||||
"className" : "btn-danger"
|
||||
}
|
||||
},
|
||||
"pageLength": 50,
|
||||
"order": [[ 1, "asc" ]]
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
</script>
|
||||
|
|
@ -0,0 +1,431 @@
|
|||
{% extends "users/base.html" %}
|
||||
{% block content %}
|
||||
{% load counter_tag %}
|
||||
<h3>Zeiterfassung von {{user.get_full_name}} bearbeiten
|
||||
<a type="button" class="btn btn-primary btn-sm" style="position: relative; float: right !important;" href="{% url 'tm-add' 1 user.pk %}"><i class="fas fa-plus"></i> Arbeitstag</a>
|
||||
</h3>
|
||||
<hr>
|
||||
<div class="btn-group" role="group" aria-label="" style="min-width: 100% !important">
|
||||
<a type="button" class="btn btn-primary mr-1" href="{% url 'tm-team-single' user.pk prev_month prev_year %}" ><i class="fas fa-arrow-circle-left"></i></a>
|
||||
<button type="button" class="btn btn-primary mr-1" style="min-width: 150px !important;" onclick="javascript:fastChangeModal()">{{active_month}} {{active_year}}</button>
|
||||
<a type="button" class="btn btn-primary mr-1" href="{% url 'tm-team-single' user.pk next_month next_year %}"><i class="fas fa-arrow-circle-right"></i></a>
|
||||
</div>
|
||||
<hr>
|
||||
<div class="table-responsive ">
|
||||
<table class="table table-hover" id="table_timemanagement" >
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col"></th>
|
||||
<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 da in days_this_month %}
|
||||
|
||||
{% getabscenceday user user da as abday %}
|
||||
|
||||
<tr id="da_{{da|date:"d-m-y"}}"
|
||||
{% if da.weekday == 5 or da.weekday == 6 %}
|
||||
style="background-color: #d3d3d3;"
|
||||
{% elif abday != False %}
|
||||
style="background-color: {{abday.reason.color}}; color: #ffffff"
|
||||
{% endif %}>
|
||||
<td>
|
||||
{{da|date:"l"}}
|
||||
</td>
|
||||
<td>
|
||||
{{da|date:"d.m.y"}}
|
||||
</td>
|
||||
<td {% if abday != False %} colspan="3" {% endif %}>
|
||||
{% if abday != False %}
|
||||
{{abday.reason}}
|
||||
{% if abday.start == da%}
|
||||
{% if abday.startday_info == "1" %}
|
||||
(nur Vormittags)
|
||||
{% for workday in workdays %}
|
||||
{% if workday.start|date:"d-m-y" == da|date:"d-m-y" %}
|
||||
<br />
|
||||
{{workday.start|date:"H:i"}} - {{workday.end|date:"H:i"}},
|
||||
{% getsumworkdayexcludebreak workday as sumworkday %}
|
||||
{{ sumworkday }},
|
||||
{% getsumbreak workday as sumbreakofday %}
|
||||
{{sumbreakofday}} min. ({{workday.breaks.all|length}}),
|
||||
{% getsumworkday workday as sumwd %}
|
||||
{{sumwd}},
|
||||
{% 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 %}
|
||||
|
||||
<button class="btn btn-secondary btn-sm ml-2" onclick="window.location.href='{% url 'tm-update' workday.pk 1 %}'"><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>
|
||||
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
|
||||
|
||||
|
||||
{% elif abday.startday_info == "2" %}
|
||||
(nur Nachmittags)
|
||||
|
||||
{% for workday in workdays %}
|
||||
{% if workday.start|date:"d-m-y" == da|date:"d-m-y" %}
|
||||
<br />
|
||||
{{workday.start|date:"H:i"}} - {{workday.end|date:"H:i"}}
|
||||
{% getsumworkdayexcludebreak workday as sumworkday %}
|
||||
{{ sumworkday }},
|
||||
{% getsumbreak workday as sumbreakofday %}
|
||||
{{sumbreakofday}} min. ({{workday.breaks.all|length}}),
|
||||
{% getsumworkday workday as sumwd %}
|
||||
{{sumwd}},
|
||||
{% 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 %}
|
||||
|
||||
|
||||
<button class="btn btn-secondary btn-sm ml-2" onclick="window.location.href='{% url 'tm-update' workday.pk 1 %}'"><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>
|
||||
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
|
||||
{% endif %}
|
||||
{% elif abday.end == da%}
|
||||
{% if abday.endday_info == "1" %}
|
||||
(nur Vormittags)
|
||||
|
||||
|
||||
|
||||
{% for workday in workdays %}
|
||||
{% if workday.start|date:"d-m-y" == da|date:"d-m-y" %}
|
||||
<br />
|
||||
{{workday.start|date:"H:i"}} - {{workday.end|date:"H:i"}}
|
||||
{% getsumworkdayexcludebreak workday as sumworkday %}
|
||||
{{ sumworkday }},
|
||||
{% getsumbreak workday as sumbreakofday %}
|
||||
{{sumbreakofday}} min. ({{workday.breaks.all|length}}),
|
||||
{% getsumworkday workday as sumwd %}
|
||||
{{sumwd}},
|
||||
{% 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 %}
|
||||
|
||||
|
||||
<button class="btn btn-secondary btn-sm ml-2" onclick="window.location.href='{% url 'tm-update' workday.pk 1 %}'"><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>
|
||||
|
||||
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
|
||||
{% elif abday.endday_info == "2" %}
|
||||
(nur Nachmittags)
|
||||
|
||||
|
||||
|
||||
{% for workday in workdays %}
|
||||
{% if workday.start|date:"d-m-y" == da|date:"d-m-y" %}
|
||||
<br />
|
||||
{{workday.start|date:"H:i"}} - {{workday.end|date:"H:i"}}
|
||||
{% getsumworkdayexcludebreak workday as sumworkday %}
|
||||
{{ sumworkday }},
|
||||
{% getsumbreak workday as sumbreakofday %}
|
||||
{{sumbreakofday}} min. ({{workday.breaks.all|length}}),
|
||||
{% getsumworkday workday as sumwd %}
|
||||
{{sumwd}},
|
||||
{% 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 %}
|
||||
|
||||
|
||||
<button class="btn btn-secondary btn-sm ml-2" onclick="window.location.href='{% url 'tm-update' workday.pk 1 %}'"><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>
|
||||
|
||||
{% 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 %}
|
||||
<br />
|
||||
{% endif %}
|
||||
|
||||
|
||||
{% counterWDUp %}
|
||||
{{workday.start|date:"H:i"}}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</td>
|
||||
{% if abday == False %}
|
||||
<td>
|
||||
{% counterWDreset %}
|
||||
{% for workday in workdays %}
|
||||
{% if workday.end|date:"d-m-y" == da|date:"d-m-y" %}
|
||||
|
||||
{% getCounterWD as wd_counter %}
|
||||
|
||||
{% if wd_counter > 0 %}
|
||||
<br />
|
||||
{% endif %}
|
||||
|
||||
|
||||
{% counterWDUp %}
|
||||
|
||||
{{workday.end|date:"H:i"}}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
|
||||
</td>
|
||||
<td>
|
||||
{% 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 %}
|
||||
<br />
|
||||
{% endif %}
|
||||
|
||||
|
||||
{% counterWDUp %}
|
||||
|
||||
{% getsumworkdayexcludebreak workday as sumworkday %}
|
||||
{{ sumworkday }}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
|
||||
</td>
|
||||
<td>
|
||||
{% 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 %}
|
||||
<br />
|
||||
{% endif %}
|
||||
|
||||
{% counterWDUp %}
|
||||
|
||||
{% getsumbreak workday as sumbreakofday %}
|
||||
{{sumbreakofday}} min. ({{workday.breaks.all|length}})
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
|
||||
</td>
|
||||
<td>
|
||||
|
||||
{% 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 %}
|
||||
<br />
|
||||
{% endif %}
|
||||
|
||||
|
||||
{% counterWDUp %}
|
||||
|
||||
{% getsumworkday workday as sumwd %}
|
||||
{{sumwd}}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
|
||||
</td>
|
||||
<td>
|
||||
|
||||
{% 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 %}
|
||||
<br />
|
||||
{% endif %}
|
||||
{% counterWDUp %}
|
||||
{% 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 %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
|
||||
</td>
|
||||
<td>
|
||||
|
||||
{% 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 %}
|
||||
<br />
|
||||
{% endif %}
|
||||
|
||||
|
||||
{% counterWDUp %}
|
||||
|
||||
<button class="btn btn-secondary btn-sm ml-2" onclick="window.location.href='{% url 'tm-update' workday.pk 1 %}'"><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>
|
||||
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</td>
|
||||
{% else %}
|
||||
<td></td><td></td><td></td><td></td><td style="display: none;"></td><td style="display: none;"></td>
|
||||
{% endif %}
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="modal fade" tabindex="-1" id="fastjumpmodal" data-backdrop="static">
|
||||
<div class="modal-dialog" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title">Zeitraum auswählen</h5>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="form-group">
|
||||
<label for="exampleFormControlSelect1">Jahr auswählen</label>
|
||||
{% getsomeyears active_year as years %}
|
||||
<select class="form-control" id="choosenyear">
|
||||
{% for y in years %}
|
||||
<option val="{{y}}" {% if y == active_year %} selected {% endif %}>{{y}}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
{% getsomemonths as months %}
|
||||
{% for m in months %}
|
||||
<button class="btn
|
||||
{% if forloop.counter == activemonth %} btn-primary {% else %} btn-secondary {% endif %}
|
||||
btn-sm mr-2 mb-2" onclick="javascript:goFastToMonth({{forloop.counter}})">{{m}}</button>
|
||||
{% endfor %}
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-primary " data-dismiss="modal">Schließen</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% 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 von {{user.get_full_name}} 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 )
|
||||
{
|
||||
location.href = location.href;
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
{% endfor %}
|
||||
|
||||
|
||||
|
||||
<script type="text/javascript">
|
||||
function fastChangeModal(){
|
||||
$("#fastjumpmodal").modal("toggle");
|
||||
}
|
||||
|
||||
$(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"
|
||||
},
|
||||
"pageLength": 50,
|
||||
"order": [[ 1, "asc" ]]
|
||||
});
|
||||
});
|
||||
|
||||
</script>
|
||||
{% endblock content %}
|
||||
|
|
@ -5,7 +5,7 @@
|
|||
{% if request.user.profile.agency.module_timemanagement %}
|
||||
<div class="content-section col-5">
|
||||
|
||||
<h3>Arbeitstag am {{workday.start|date:"d.m.Y"}} bearbeiten</h3>
|
||||
<h3>Arbeitstag am {{workday.start|date:"d.m.Y"}} {% if team == 1 %} von {{user.get_full_name}} {% endif %} bearbeiten</h3>
|
||||
<hr>
|
||||
<h5>Start- und Endzeitpunkt</h5>
|
||||
<div class="col-6" style="margin-left: -10px;">
|
||||
|
|
@ -16,7 +16,11 @@
|
|||
</div>
|
||||
<hr>
|
||||
<h5>Pausen
|
||||
{% if team == 1 %}
|
||||
<a class="btn btn-primary btn-sm" style="float: right" href="{% url 'add-break' workday.pk 1 %}"><i class="fas fa-plus"></i></a>
|
||||
{% else %}
|
||||
<a class="btn btn-primary btn-sm" style="float: right" href="{% url 'add-break' workday.pk %}"><i class="fas fa-plus"></i></a>
|
||||
{% endif %}
|
||||
</h5>
|
||||
<div col="col-10">
|
||||
<table class="table table-hover" >
|
||||
|
|
@ -41,7 +45,11 @@
|
|||
</table>
|
||||
</div>
|
||||
<hr>
|
||||
{% if team == 1 %}
|
||||
<a class="btn" href="{% url 'tm-management' %} ">Abbrechen</a>
|
||||
{% else %}
|
||||
<a class="btn" href="{% url 'tm-team-single' user.pk workday.start.month workday.start.year %} ">Abbrechen</a>
|
||||
{% endif %}
|
||||
<button type="submit" class="btn btn-primary" style="float: right" id="addbreakbutton">Arbeitstag aktualisieren</button>
|
||||
</form>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -1,18 +1,24 @@
|
|||
from django.urls import path
|
||||
from django.contrib.auth.decorators import login_required, permission_required
|
||||
from .views import TimeManagement, TimeAjax, AbsenceManagmenet, AbsenceUpdate, TimeUpdate, AddBreak, TimeAdd
|
||||
from .views import TimeManagement, TimeAjax, AbsenceManagmenet, AbsenceUpdate, TimeUpdate, AddBreak, TimeAdd, TimeManagementTeamSingle
|
||||
'''
|
||||
Permissions definiert in models.py bei USERS und dann hier vor die View geschrieben!
|
||||
'''
|
||||
|
||||
urlpatterns = [
|
||||
path('', TimeManagement, name='tm-management'),
|
||||
path('tm/team/<int:pk>', TimeManagementTeamSingle, name='tm-team-single'),
|
||||
path('tm/team/<int:pk>/<int:activemonth>/<int:activeyear>', TimeManagementTeamSingle, name='tm-team-single'),
|
||||
path('<int:activemonth>/<int:activeyear>', TimeManagement, name='tm-management'),
|
||||
path('update/<int:pk>', TimeUpdate, name='tm-update'),
|
||||
path('update/<int:pk>/<int:team>', TimeUpdate, name='tm-update'),
|
||||
path('add/', TimeAdd, name='tm-add'),
|
||||
path('add/<int:team>/<int:pk>', TimeAdd, name='tm-add'),
|
||||
path('update/<int:pk>/addbreak/', AddBreak, name='add-break'),
|
||||
path('update/<int:pk>/addbreak/<int:team>', AddBreak, name='add-break'),
|
||||
path('abs/', AbsenceManagmenet, name='tma-management'),
|
||||
path('abs/<int:activemonth>/<int:activeyear>', AbsenceManagmenet, name='tma-management'),
|
||||
path('ajax/', TimeAjax, name='tm-ajax'),
|
||||
path('abs/update/<int:pk>/', AbsenceUpdate, name='tma-update'),
|
||||
|
||||
]
|
||||
|
|
|
|||
|
|
@ -285,6 +285,71 @@ def AbsenceManagmenet(request, activemonth=False, activeyear=False):
|
|||
return render(request, 'timemanagement/tm_ab_management.html', context)
|
||||
|
||||
|
||||
@login_required
|
||||
def TimeManagementTeamSingle(request, pk, activemonth=False, activeyear=False):
|
||||
if(request.user.has_perm("users.usersmanager")):
|
||||
# Setzt die Monatsausgabe auf Deutsch
|
||||
locale.setlocale(locale.LC_TIME, 'de_DE.UTF-8')
|
||||
user = User.objects.get(pk=pk)
|
||||
# Hier wird der Monat und das Jahr für die Buttons gebaut
|
||||
if(activemonth == False):
|
||||
today = datetime.datetime.today()
|
||||
active_month = str(today.strftime("%B"))
|
||||
active_year = str(today.strftime("%Y"))
|
||||
activemonth = today.month
|
||||
else:
|
||||
today = datetime.datetime(activeyear, activemonth, 1)
|
||||
active_month = activemonth
|
||||
active_month = str(today.strftime("%B"))
|
||||
active_year = str(today.strftime("%Y"))
|
||||
|
||||
prev_year = active_year
|
||||
next_year = active_year
|
||||
|
||||
next_month = today.month + 1
|
||||
if(next_month == 13):
|
||||
next_month = 1
|
||||
next_year = int(next_year) + 1
|
||||
|
||||
prev_month = today.month - 1
|
||||
if(prev_month == 0):
|
||||
prev_month = 12
|
||||
prev_year = int(prev_year) - 1
|
||||
|
||||
# Initialprüfung, ob Arbeitstage vorliegen
|
||||
tempworkday = Workday.objects.filter(agency=request.user.profile.agency, user=user).order_by("start").exclude(end=None)[:1]
|
||||
|
||||
user_has_workdays = False
|
||||
if len(tempworkday) == 1:
|
||||
user_has_workdays = True
|
||||
|
||||
# Hier werden nur die Arbeitstage gefiltert, die auch aktuell zur Ansicht stehen sollen
|
||||
context = {
|
||||
"next_month" : next_month,
|
||||
"breakmonthline" : date.today() - timedelta(days=30),
|
||||
"prev_month" : prev_month,
|
||||
"next_year" : next_year,
|
||||
"prev_year" : prev_year,
|
||||
"active_year" : int(active_year),
|
||||
"active_month" : active_month,
|
||||
"activemonth" : activemonth,
|
||||
"active_link" : "timemanagement",
|
||||
"days_this_month" : get_datetime_range(int(active_year), int(activemonth)),
|
||||
"workdays" : Workday.objects.filter(agency=request.user.profile.agency, user=user, start__month=activemonth, start__year=active_year).order_by("start").exclude(end=None),
|
||||
"userhasworkdays" : user_has_workdays,
|
||||
"user" : user
|
||||
}
|
||||
|
||||
return render(request, 'timemanagement/timemanagement_teamview_single.html', context)
|
||||
|
||||
|
||||
|
||||
# Requestet User has no rights...
|
||||
else:
|
||||
messages.success(request, f'Das würfen Sie nicht!')
|
||||
return redirect("timemanagement")
|
||||
|
||||
|
||||
@login_required
|
||||
def TimeManagement(request, activemonth=False, activeyear=False):
|
||||
# Setzt die Monatsausgabe auf Deutsch
|
||||
|
|
@ -344,10 +409,15 @@ def TimeManagement(request, activemonth=False, activeyear=False):
|
|||
return render(request, 'timemanagement/timemanagement_management.html', context)
|
||||
|
||||
@login_required
|
||||
def TimeUpdate(request, pk):
|
||||
if(request.method == "POST"):
|
||||
form = UpdateWorkdayForm(request.POST, instance=request.user)
|
||||
def TimeUpdate(request, pk, team=0):
|
||||
workday = Workday.objects.get(pk=pk)
|
||||
user = workday.user
|
||||
|
||||
if(request.method == "POST"):
|
||||
if(team == 0):
|
||||
form = UpdateWorkdayForm(request.POST, instance=request.user)
|
||||
else:
|
||||
form = UpdateWorkdayForm(request.POST, instance=user)
|
||||
|
||||
start = datetime.datetime(int(workday.start.year), int(workday.start.month), int(workday.start.day), int(((str(form["start"].value()).split(":"))[0])), int(((str(form["start"].value()).split(":"))[1])))
|
||||
|
||||
|
|
@ -358,74 +428,112 @@ def TimeUpdate(request, pk):
|
|||
workday.target = form["target"].value()
|
||||
workday.save()
|
||||
messages.success(request, f'Arbeitstag aktualisiert')
|
||||
|
||||
if(team == 1):
|
||||
return redirect('tm-team-single', user.pk, workday.start.month, workday.start.year)
|
||||
else:
|
||||
return redirect('tm-management')
|
||||
else:
|
||||
context = {
|
||||
"active_link" : "timemanagement",
|
||||
"workday" : Workday.objects.get(pk=pk),
|
||||
"form" : UpdateWorkdayForm(instance= Workday.objects.get(pk=pk))
|
||||
"form" : UpdateWorkdayForm(instance= Workday.objects.get(pk=pk)),
|
||||
"team" : team,
|
||||
"user" : workday.user
|
||||
}
|
||||
return render(request, 'timemanagement/timemanagement_update.html', context)
|
||||
|
||||
@login_required
|
||||
def TimeAdd(request):
|
||||
if(request.method == "POST"):
|
||||
def TimeAdd(request, team=0, pk=0):
|
||||
if(team == 0):
|
||||
user = request.user
|
||||
form = AddWorkdayForm(request.POST, instance=request.user)
|
||||
else:
|
||||
user = User.objects.get(pk=pk)
|
||||
form = AddWorkdayForm(request.POST, instance=user)
|
||||
|
||||
if(request.method == "POST"):
|
||||
if form.is_valid():
|
||||
#start = datetime.datetime(int(workday.start.year), int(workday.start.month), int(workday.start.day), int(((str(form["start"].value()).split(":"))[0])), int(((str(form["start"].value()).split(":"))[1])))
|
||||
|
||||
#end = datetime.datetime(int(workday.end.year), int(workday.end.month), int(workday.end.day), int(((str(form["end"].value()).split(":"))[0])), int(((str(form["end"].value()).split(":"))[1])))
|
||||
|
||||
workday = Workday(start=form.cleaned_data["start"], end=form.cleaned_data["end"], target=form.cleaned_data["target"], user=request.user, agency=request.user.profile.agency)
|
||||
workday = Workday(start=form.cleaned_data["start"], end=form.cleaned_data["end"], target=form.cleaned_data["target"], user=user, agency=request.user.profile.agency)
|
||||
|
||||
if workday.start.day != workday.end.day or workday.start.month != workday.end.month or workday.start.year != workday.end.year or workday.start > workday.end:
|
||||
messages.success(request, f'Der Arbeitstag darf nur an einem Tag stattfinden und das Ende muss nach dem Anfang liegen.')
|
||||
context = {
|
||||
"active_link" : "timemanagement",
|
||||
"form" : AddWorkdayForm()
|
||||
"form" : AddWorkdayForm(),
|
||||
"team" : team,
|
||||
"user" : user
|
||||
}
|
||||
return render(request, 'timemanagement/timemanagement_add.html', context)
|
||||
else:
|
||||
workday.save()
|
||||
messages.success(request, f'Arbeitstag hinzugefügt')
|
||||
|
||||
if (team == 1):
|
||||
return redirect('tm-team-single', user.pk, workday.start.month, workday.start.year)
|
||||
else:
|
||||
return redirect('tm-management')
|
||||
else:
|
||||
messages.success(request, f'Bitte valide Daten eingeben!')
|
||||
context = {
|
||||
"active_link" : "timemanagement",
|
||||
"form" : AddWorkdayForm()
|
||||
"form" : AddWorkdayForm(),
|
||||
"team" : team,
|
||||
"user" : user
|
||||
}
|
||||
return render(request, 'timemanagement/timemanagement_add.html', context)
|
||||
else:
|
||||
context = {
|
||||
"active_link" : "timemanagement",
|
||||
"form" : AddWorkdayForm()
|
||||
"form" : AddWorkdayForm(),
|
||||
"team" : team,
|
||||
"user" : user
|
||||
}
|
||||
return render(request, 'timemanagement/timemanagement_add.html', context)
|
||||
|
||||
@login_required
|
||||
def AddBreak(request, pk):
|
||||
if(request.method == "POST"):
|
||||
def AddBreak(request, pk, team=0):
|
||||
workday = Workday.objects.get(pk=pk)
|
||||
user = workday.user
|
||||
if(request.method == "POST"):
|
||||
if(team == 0):
|
||||
form = AddBreakForm(request.POST, instance=request.user)
|
||||
else:
|
||||
form = AddBreakForm(request.POST, instance=user)
|
||||
|
||||
start = datetime.datetime(int(workday.start.year), int(workday.start.month), int(workday.start.day), int(((str(form["start"].value()).split(":"))[0])), int(((str(form["start"].value()).split(":"))[1])))
|
||||
|
||||
end = datetime.datetime(int(workday.end.year), int(workday.end.month), int(workday.end.day), int(((str(form["end"].value()).split(":"))[0])), int(((str(form["end"].value()).split(":"))[1])))
|
||||
|
||||
if(team == 0):
|
||||
newbreak = Breaks.objects.create(workday=workday, user=request.user, agency=request.user.profile.agency, start=start, end=end)
|
||||
else:
|
||||
newbreak = Breaks.objects.create(workday=workday, user=user, agency=user.profile.agency, start=start, end=end)
|
||||
|
||||
workday.breaks.add(newbreak)
|
||||
workday.save()
|
||||
messages.success(request, f'Pause hinzugefügt')
|
||||
|
||||
if(team == 0):
|
||||
return redirect('tm-update', pk=pk)
|
||||
else:
|
||||
return redirect('tm-team-single', user.pk, workday.start.month, workday.start.year)
|
||||
else:
|
||||
if(team == 0):
|
||||
context = {
|
||||
"active_link" : "timemanagement",
|
||||
"workday" : Workday.objects.get(pk=pk),
|
||||
"form" : AddBreakForm(instance=request.user)
|
||||
}
|
||||
else:
|
||||
context = {
|
||||
"active_link" : "timemanagement",
|
||||
"workday" : Workday.objects.get(pk=pk),
|
||||
"form" : AddBreakForm(instance=user)
|
||||
}
|
||||
return render(request, 'timemanagement/timemanagement_break.html', context)
|
||||
|
||||
@login_required
|
||||
|
|
@ -511,7 +619,7 @@ def TimeAjax(request):
|
|||
# REMOVE WORKDAY
|
||||
elif request.GET["action"] == "remove_workday":
|
||||
wd = Workday.objects.get(pk=request.GET.get("workday"))
|
||||
if(wd.user == request.user and wd.agency == request.user.profile.agency):
|
||||
if(wd.agency == request.user.profile.agency):
|
||||
wd.delete()
|
||||
data = {
|
||||
"success" : True
|
||||
|
|
@ -521,7 +629,7 @@ def TimeAjax(request):
|
|||
# REMOVE BREAK
|
||||
elif request.GET["action"] == "remove_break":
|
||||
breakwd = Breaks.objects.get(pk=request.GET.get("break"))
|
||||
if(breakwd.user == request.user and breakwd.agency == request.user.profile.agency):
|
||||
if(breakwd.agency == request.user.profile.agency):
|
||||
breakwd.delete()
|
||||
data = {
|
||||
"success" : True
|
||||
|
|
|
|||
Loading…
Reference in New Issue