Bugs, Navbar fix

This commit is contained in:
Holger Trampe 2020-05-29 00:16:04 +02:00
parent f8b21c8f8d
commit 7294336e96
12 changed files with 189 additions and 147 deletions

View File

@ -1,20 +0,0 @@
{% extends "users/base.html" %}
{% load crispy_forms_tags %}
{% block content %}
{% if request.user.profile.agency.module_timemanagement %}
<div class="content-section col-6">
<h3>Feiertage anlegen</h3>
<hr>
<form method="POST" enctype="multipart/form-data">
{% csrf_token %}
{{form.media}}
{{ form|crispy }}
<hr>
<button type="submit" class="btn btn-primary">Feiertage anlegen</button>&nbsp;
<a class="btn" href="{% url 'tm-managemenetfreedays' %} ">Abbrechen</a>
</form>
</div>
{% else %}
<h3>Das Modul Abwesenheitsplanung wurden in ihrer Agentur deaktiviert.</h3>
{% endif %}
{% endblock content %}

View File

@ -29,7 +29,7 @@
<td> <td>
{% if user|usergperm:"moduleorganizer" %} {% if user|usergperm:"moduleorganizer" %}
<a style="float: right" class="btn btn-secondary btn-sm ml-2" href="{% url 'freeday-delete' fd.pk %}"> <a style="float: right" class="btn btn-secondary btn-sm ml-2" href="{% url 'freeday-delete' fd.pk %}">
<small><i class="fas fa-trash"></i></small>
</a> </a>
{% endif %} {% endif %}
</td> </td>
@ -38,6 +38,7 @@
</tbody> </tbody>
</table> </table>
</div> </div>
<button class="btn btn-secondary mt-2" onclick="javascript:$('#allDel').modal('toggle');" style="float: left;"><small><i class="fas fa-trash"></i></small></button>
</div> </div>
<div class="modal fade" tabindex="-1" role="dialog" id="freedays_initloadinginfo" data-backdrop="static"> <div class="modal fade" tabindex="-1" role="dialog" id="freedays_initloadinginfo" data-backdrop="static">
<div class="modal-dialog" role="document"> <div class="modal-dialog" role="document">
@ -126,6 +127,27 @@
</div> </div>
</div> </div>
<!-- Load freedays by year -->
<div class="modal fade" tabindex="-1" role="dialog" id="allDel" data-backdrop="static">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Alle Feiertage löschen</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
Möchten Sie wirklich alle gespeicherten Feiertage löschen?
</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary" onclick="javascript:doDelAll()" >Alle löschen</button>
<button type="button" class="btn" data-dismiss="modal">Abbrechen</button>
</div>
</div>
</div>
</div>
<script type="text/javascript"> <script type="text/javascript">
$(document).ready(function(){ $(document).ready(function(){
@ -153,6 +175,26 @@
}); });
}) })
function doDelAll(){
$("#allDel").modal("toggle");
$.ajax(
{
type: "GET",
url: "{% url 'dasettings-ajax' %}",
data:{
action : "delallfreedays",
},
success: function( data )
{
if(data["success"]){
window.location.href = "{% url 'tm-managemenetfreedays' %}";
}
else{
$("#plz_error").modal("toggle");
}
}
});
}
function loadFreeDays() function loadFreeDays()
{ {

View File

@ -152,7 +152,7 @@
{% if newuser == 1 %} {% if newuser == 1 %}
<button type="submit" class="btn btn-primary" style="float: right">Profilerstellung abschließen</button> <button type="submit" class="btn btn-primary" style="float: right">Profilerstellung abschließen</button>
{% else %} {% else %}
<button type="submit" name="submitprof" class="btn btn-primary" style="float: right">Speichern</button> <button type="submit" name="submitprof" class="btn btn-primary" style="float: right">Profildaten aktualisieren</button>
{% endif %} {% endif %}
</form> </form>

View File

@ -707,17 +707,14 @@ def SettingsAjaxRouter(request):
#tempdays_year = False #tempdays_year = False
if(request.GET["land"] == "true"): if(request.GET["land"] == "true"):
tempdays_year = loadingFreeDaysMulti(request.user.profile.agency.plz, request.GET["year"], True) tempdays_year = loadingFreeDaysMulti(request.user.profile.agency.plz, request.GET["year"], True)
if(tempdays_year != False): if(tempdays_year != False):
#for k in tempdays_year: for k in tempdays_year.keys():
# tempdate = tempdays_year[k][1].split("-") tempdate = tempdays_year[k].split("-")
# FreeDays(agency=request.user.profile.agency, name=k, day=datetime.datetime(int(tempdate[0]),int(tempdate[1]),int(tempdate[2])), year=int(request.GET["year"])).save() FreeDays(agency=request.user.profile.agency, name=k, day=datetime.datetime(int(tempdate[0]),int(tempdate[1]),int(tempdate[2])), year=int(request.GET["year"])).save()
#messages.success(request, f'Feiertage erfolgreich gespeichert!')
tempdays_year = json.loads(tempdays_year)
print(tempdays_year)
messages.success(request, f'Feiertage erfolgreich gespeichert!')
success = True success = True
else: else:
success = False success = False
@ -737,11 +734,25 @@ def SettingsAjaxRouter(request):
else: else:
data = {"userfullname" : tempuser.first_name + " " + tempuser.last_name} data = {"userfullname" : tempuser.first_name + " " + tempuser.last_name}
success = False success = False
# DELETE ALL FREE DAYS
elif request.method == 'GET' and request.GET['action'] == "delallfreedays" :
if(request.user.has_perm('users.modulesconfig')):
FreeDays.objects.filter(agency=request.user.profile.agency).delete()
messages.success(request, f'Feiertage erfolgreich entfernt!')
success = True
else:
data = {"userfullname" : tempuser.first_name + " " + tempuser.last_name}
success = False
#return render(request, 'dasettings/change_absence_yeardata.html', context)
# HOLIDAYS UPDATE
elif request.method == 'GET' and request.GET['action'] == "update_holidays" : elif request.method == 'GET' and request.GET['action'] == "update_holidays" :
context = { context = {
"user_years" : UserYearAbsenceInfo.objects.filter(user=User.objects.get(pk=request.GET["userid"])), "user_years" : UserYearAbsenceInfo.objects.filter(user=User.objects.get(pk=request.GET["userid"])),
} }
return render(request, 'dasettings/change_absence_yeardata.html', context) return render(request, 'dasettings/change_absence_yeardata.html', context)
# UPDATE HOLIDAYS SAVE
elif request.method == 'GET' and request.GET['action'] == "update_holidays_save" : elif request.method == 'GET' and request.GET['action'] == "update_holidays_save" :
# GET ELEMENTS # GET ELEMENTS
newHolidayData = request.GET["new_data_info"].split("___") newHolidayData = request.GET["new_data_info"].split("___")

Binary file not shown.

Before

Width:  |  Height:  |  Size: 44 KiB

After

Width:  |  Height:  |  Size: 0 B

View File

@ -1,63 +0,0 @@
'''
elif request.GET["action"] == "getrestholidays":
user = User.objects.get(pk=request.GET["userid"])
usertimedata = UserTime.objects.get(user=user)
today = date.today()
if(user.profile.agency == request.user.profile.agency and request.user.has_perm("users.absencemanager")):
# Alle Abwesenheiten laden, die bestätigt oder angefragt sind UND Urlaub sind
absences = Absence.objects.filter(user=user, confirm_status=0, reason__is_holiday=True) | Absence.objects.filter(user=user, confirm_status=1, reason__is_holiday=True)
start_day = request.GET["startdate"].split("__")
start_day_ob = datetime.date(int(start_day[0]), int(start_day[1]), int(start_day[2]))
end_day = request.GET["enddate"].split("__")
end_day_obj = datetime.date(int(end_day[0]), int(end_day[1]), int(end_day[2]))
start_half = True
if request.GET["start_half"] == "false":
start_half = False
end_half = True
if request.GET["end_half"] == "false":
end_half = False
# USER HAS NO ABSENCE
if(len(absences) == 0):
# Hier Urlaubstage bei Einstellung mit berücksichtigen
if(start_day_ob.year == usertimedata.startdate.year):
data = {
"restholiday" : calculateHolidays(request, usertimedata.holiday_start + usertimedata.holiday, start_day_ob, end_day_obj, start_half, end_half)
}
# Hier Einstellungstage irrelevant und da noch keine Abwesenheiten eingetragen wurden, einfach aus Profil laden
else:
data = {
"restholiday" : calculateHolidays(request, usertimedata.holiday, start_day_ob, end_day_obj, start_half, end_half)
}
# ABSENCE-Data found, calculating rest-Days
else:
finalholidays = 0
# Besteht noch Anspruch aus Einstellungsjahr?
if(start_day_ob.year == usertimedata.startdate.year):
finalholidays += usertimedata.holiday_start + usertimedata.holiday
# Hier Einstellungstage irrelevant und da noch keine Abwesenheiten eingetragen wurden, einfach normal
else:
finalholidays += usertimedata.holiday
# Berechne pro Abwesenheits die verbrauchen Urlaubstage
for absence in absences:
finalholidays -= calculatingHolidaysByAbsence(request, absence)
data = {
"restholiday" : calculateHolidays(request, finalholidays, start_day_ob, end_day_obj, start_half, end_half)
}
# REQUEST USER NO RIGHTS
else:
data = {
"success" : False
}
'''

View File

@ -207,6 +207,7 @@ document.getElementById("id_reason").addEventListener("change", function(){
if(data["isholiday"] == false){ if(data["isholiday"] == false){
$("#noholidays_container").show(); $("#noholidays_container").show();
$("#restholidays_container").hide(); $("#restholidays_container").hide();
$("#start_absence_contract").prop("disabled", false);
} }
else{ else{
$("#noholidays_container").hide(); $("#noholidays_container").hide();
@ -267,6 +268,7 @@ function nextMonth(){
var selectedElements = []; var selectedElements = [];
var active_row = ""; var active_row = "";
var sameday = false;
var user_has_right = "{{user|usergperm:"absencemanager"}}"; var user_has_right = "{{user|usergperm:"absencemanager"}}";
if(user_has_right == "True"){ if(user_has_right == "True"){
@ -287,6 +289,13 @@ function recalculateChoosenDays(){
date_start = new Date(seldates[0]) date_start = new Date(seldates[0])
date_end = new Date(seldates[seldates.length-1]) date_end = new Date(seldates[seldates.length-1])
if(+date_start == +date_end){
sameday = true;
}
else{
sameday = false;
}
$("#div_id_end").show(); $("#div_id_end").show();
$("#div_id_end_ishalf").show(); $("#div_id_end_ishalf").show();
@ -334,12 +343,23 @@ function recalculateChoosenDays(){
} }
function recalculateChoosenDaysAfterInit(){ function recalculateChoosenDaysAfterInit(){
console.log(sameday);
new_start = $("#id_start").datepicker().val(); new_start = $("#id_start").datepicker().val();
new_end = $("#id_end").datepicker().val(); new_end = $("#id_end").datepicker().val();
new_start = new_start.split("."); new_start = new_start.split(".");
new_end = new_end.split("."); new_end = new_end.split(".");
behindcheck_start = new Date(new_start[2], (parseInt(new_start[1])-1), new_start[0]);
behindcheck_end = new Date(new_end[2], (parseInt(new_end[1])-1), new_end[0]);
if(sameday){
behindcheck_end = behindcheck_start;
new_end = new_start;
}
$.ajax({ $.ajax({
type: "GET", type: "GET",
url: "{% url 'tm-ajax' %}", url: "{% url 'tm-ajax' %}",
@ -362,8 +382,16 @@ function recalculateChoosenDaysAfterInit(){
$("#detail_tocontract").html(data["need_days"]); $("#detail_tocontract").html(data["need_days"]);
if(data["restholiday_thisyear"] < 0 || data["restholiday_lastyear"] < 0 || data["restholiday_nextyear"] < 0){ behindcheck = false;
$("#start_absence_contract").prop("disabled", true); if(+behindcheck_start == +behindcheck_end){
behindcheck = true;
}
else if(+behindcheck_start < +behindcheck_end == true){
behindcheck = true;
}
if(behindcheck == false || data["restholiday_thisyear"] < 0 || data["restholiday_lastyear"] < 0 || data["restholiday_nextyear"] < 0 && data["startendcheck"]){
$("#start_absence_contract").prop("disabled", true);
} }
else{ else{
$("#start_absence_contract").prop("disabled", false); $("#start_absence_contract").prop("disabled", false);
@ -507,3 +535,5 @@ $( function() {
}); });
} ); } );
</script> </script>

View File

@ -10,11 +10,7 @@
</h3> </h3>
<hr> <hr>
{% if yearinfo != False %}
<p>Verbrauchte Urlaubstage: {{yearinfo.days_inuse}} | Verfügbar: {{yearinfo.days}}</p>
{% else %}
<p>Keine Abwesenheitsinformationen vorhanden</p>
{% endif %}
<div > <div >
<ul class="nav nav-tabs " id="absencetabs" role="tablist" > <ul class="nav nav-tabs " id="absencetabs" role="tablist" >
@ -41,9 +37,7 @@
{% endif %} {% endif %}
</ul> </ul>
<div class="chart-container" style="position: absolute; height:160px; width:160px; margin-bottom: -150px; right: -15px; top:54px">
<canvas id="datainfo_restdays"></canvas>
</div>
</div> </div>
<div class="tab-content" id="absencetabsContent"> <div class="tab-content" id="absencetabsContent">
@ -478,24 +472,6 @@ $('#absencetabs a').on('click', function (e) {
</script> </script>
<script>
var ctx = document.getElementById("datainfo_restdays");
var myChart = new Chart(ctx, {
type: 'doughnut',
data: {
labels: ['Kontigent', 'Genutzt'],
datasets: [{
backgroundColor: ['green','#ff304f'],
data: [{{kontingent}}, {{inuse}}]
}]
},
options : {
legend: {
display: false
}
}
});
</script>
{% else %} {% else %}

View File

@ -1,4 +1,39 @@
<div class="row col-12 mt-3" > {% load l10n %}
{% load mathfilters %}
<div class="row mt-3">
<div class="col-4 mr-2">
<div class="card">
<div class="card-body">
<!-- CANVAS -->
<div class="chart-container" style="">
<canvas id="datainfo_restdays"></canvas>
</div>
<hr>
<h6>Übersicht</h6>
<table class="table table-sm">
<tbody>
<tr>
<td>Gesamturlaub</td>
<td>{{yearinfo.days}}&nbsp;Tage</td>
</tr>
<tr>
<td>Genommener Urlaub</td>
<td>{{yearinfo.days_inuse}}&nbsp;Tage</td>
</tr>
<tr>
<td>Resturlaub</td>
<td>{{yearinfo.days|sub:yearinfo.days_inuse}}&nbsp;Tage</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<div class="col-7">
<div class="table-responsive"> <div class="table-responsive">
<table class="table table-hover" id="table_userownab"> <table class="table table-hover" id="table_userownab">
<thead> <thead>
@ -23,10 +58,11 @@
</tbody> </tbody>
</table> </table>
</div> </div>
</div><!-- END TABLE -->
</div> </div>
<script type="text/javascript"> <script type="text/javascript">
$(document).ready(function(){ $(document).ready(function(){
$('#table_userownab').DataTable({ $('#table_userownab').DataTable({
"language": { "language": {
"search" : "Suche", "search" : "Suche",
@ -44,7 +80,25 @@
"buttons" : { "buttons" : {
"className" : "btn-danger" "className" : "btn-danger"
} }
}); });
}); });
</script>
<script>
var ctx = document.getElementById("datainfo_restdays");
var myChart = new Chart(ctx, {
type: 'doughnut',
data: {
labels: ['Verfügbarer Urlaub', 'Genommener Urlaub'],
datasets: [{
backgroundColor: ['green','#ff304f'],
data: [{{kontingent|unlocalize}}, {{inuse|unlocalize}}]
}]
},
options : {
legend: {
display: true,
position: 'bottom',
}
}
});
</script> </script>

View File

@ -19,6 +19,7 @@ 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
# Load freedays
def loadingFreeDays(plz): def loadingFreeDays(plz):
# Getting land # Getting land
@ -158,8 +159,8 @@ def AbsenceManagmenet(request, activemonth=False, activeyear=False):
yearinfo = False yearinfo = False
try: try:
yearinfo = list(UserYearAbsenceInfo.objects.filter(year=activeyear, user=request.user))[0] yearinfo = list(UserYearAbsenceInfo.objects.filter(year=activeyear, user=request.user))[0]
inuse = int(yearinfo.days_inuse) inuse = yearinfo.days_inuse
kontingent = int(yearinfo.days) kontingent = yearinfo.days - inuse
except: except:
pass pass
@ -404,7 +405,7 @@ def TimeAjax(request):
end_day = request.GET["enddate"].split("__") end_day = request.GET["enddate"].split("__")
end_day_obj = datetime.date(int(end_day[0]), int(end_day[1]), int(end_day[2])) end_day_obj = datetime.date(int(end_day[0]), int(end_day[1]), int(end_day[2]))
try: try:
holidayloose_date = datetime.date(start_day_obj.year, int(usertimedata.loose_holidedate.split(".")[1]), int(usertimedata.loose_holidedate.split(".")[0])) holidayloose_date = datetime.date(start_day_obj.year, int(usertimedata.loose_holidedate.split(".")[1]), int(usertimedata.loose_holidedate.split(".")[0]))
except: except:

View File

@ -279,7 +279,7 @@
</script> </script>
{% endif %} {% endif %}
<nav class="navbar navbar-expand navbar-light bg-white topbar mb-4 static-top shadow"> <nav id="topnavbarmain" class="navbar navbar-expand navbar-light bg-white topbar fixed-top mb-4 static-top shadow" style="margin-left: 224px;">
@ -413,20 +413,21 @@
<!-- End of Topbar --> <!-- End of Topbar -->
<!-- Begin Page Content --> <!-- Begin Page Content -->
<div class="container-fluid" > <div class="container-fluid" >
<!-- MESSAGES --> <div id="searchcontent" style="min-height: 100%; margin-top: 85px;">
{% if messages %}
{% for message in messages %}
<div class="alert alert-{{ message.tags }} alert-dismissible fade show col-6" role="alert" id="message_{{forloop.counter}}">
{{ message }}
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
{% endfor %}
{% endif %}
<div id="searchcontent">
</div> </div>
<div id="maincontent" styl="min-height: 100%">
<div id="maincontent" style="min-height: 100%; margin-top: 85px;" >
<!-- MESSAGES -->
{% if messages %}
{% for message in messages %}
<div class="alert alert-{{ message.tags }} alert-dismissible fade show col-6" role="alert" id="message_{{forloop.counter}}">
{{ message }}
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
{% endfor %}
{% endif %}
{% block content %} {% block content %}
{% endblock %} {% endblock %}
</div> </div>
@ -561,6 +562,9 @@ $(document).ready(function(){
{ {
$("#accordionSidebar").addClass("toggled"); $("#accordionSidebar").addClass("toggled");
$("#content-wrapper").css("margin-left" , "0px"); $("#content-wrapper").css("margin-left" , "0px");
$("#topnavbarmain").css("margin-left" , "0px");
sidebar_hidden = false; sidebar_hidden = false;
} }
}); });
@ -571,11 +575,15 @@ function toggleSidebar(){
if(sidebar_hidden == false){ if(sidebar_hidden == false){
$("#accordionSidebar").addClass("toggled"); $("#accordionSidebar").addClass("toggled");
$("#content-wrapper").css("margin-left" , "105px"); $("#content-wrapper").css("margin-left" , "105px");
$("#topnavbarmain").css("margin-left" , "105px");
sidebar_hidden = true; sidebar_hidden = true;
} }
else{ else{
$("#accordionSidebar").removeClass("toggled"); $("#accordionSidebar").removeClass("toggled");
$("#content-wrapper").css("margin-left" , "0px"); $("#content-wrapper").css("margin-left" , "0px");
$("#topnavbarmain").css("margin-left" , "0px");
sidebar_hidden = false; sidebar_hidden = false;
} }
} }
@ -584,12 +592,15 @@ $( window ).resize(function() {
if($( window ).width() < 750) if($( window ).width() < 750)
{ {
$("#accordionSidebar").addClass("toggled"); $("#accordionSidebar").addClass("toggled");
$("#content-wrapper").css("margin-left" , "0px"); $("#content-wrapper").css("margin-left" , "0px");
$("#topnavbarmain").css("margin-left" , "0px");
sidebar_hidden = false; sidebar_hidden = false;
} }
else{ else{
$("#accordionSidebar").removeClass("toggled"); $("#accordionSidebar").removeClass("toggled");
$("#content-wrapper").css("margin-left" , "212px"); $("#content-wrapper").css("margin-left" , "212px");
$("#topnavbarmain").css("margin-left" , "224px");
sidebar_hidden = true; sidebar_hidden = true;
} }
}); });