428 lines
15 KiB
HTML
428 lines
15 KiB
HTML
{% extends "users/base.html" %}
|
|
{% block content %}
|
|
{% load crispy_forms_tags %}
|
|
{% load counter_tag %}
|
|
{% load l10n %}
|
|
{% load mathfilters %}
|
|
{% if request.user.profile.agency.module_timemanagement %}
|
|
<div class="content-section col-8">
|
|
|
|
<h3>Abwesenheit von {{absence.user.first_name}} {{absence.user.last_name}} Bearbeiten</h3>
|
|
{% getLastEditedAbsence absence as absencehistorie %}
|
|
|
|
{% if absencehistorie.history_user != None %}
|
|
<small>Zuletzt bearbeitet von {{absencehistorie.history_user.first_name}} {{absencehistorie.history_user.last_name}} am {{absencehistorie.history_date|date:"d.m.Y, H:i"}}</small>
|
|
{% endif %}
|
|
<hr>
|
|
<div class="row">
|
|
<div class="col-6">
|
|
<form method="POST" class="">
|
|
{% csrf_token %}
|
|
{{form.media}}
|
|
<div class="row">
|
|
<div class="col-6">
|
|
{{form.start |as_crispy_field }}
|
|
{{form.startday_info |as_crispy_field }}
|
|
</div>
|
|
<div class="col-6">
|
|
{{form.end |as_crispy_field }}
|
|
{{form.endday_info |as_crispy_field }}
|
|
</div>
|
|
</div>
|
|
<hr>
|
|
<div class="row" >
|
|
<div class="col-6">
|
|
{{form.reason|as_crispy_field}}
|
|
</div>
|
|
<div class="col-6">
|
|
{{form.representator|as_crispy_field}}
|
|
</div>
|
|
</div>
|
|
<div class="row">
|
|
<div class="col-12">
|
|
<h5>Begründung</h5>
|
|
<p>{{absence.info}}</p>
|
|
</div>
|
|
</div>
|
|
<hr>
|
|
<div class="row">
|
|
<div class="col-12">
|
|
<h5>An- oder Ablehnung</h5>
|
|
<p>{{absence.confirm_info}}</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="col-5 ml-3">
|
|
<div id="restholidays_container">
|
|
<h5>Übersicht Urlaubstage</h5>
|
|
<!-- ONE YEAR -->
|
|
<h5>
|
|
<b style="color: red">
|
|
<span id="detail_tocontract"></span> Tage / <span id="restholidays"></span> verbleibend im Jahr <span id="holidayyear"></span>
|
|
</b>
|
|
</h5>
|
|
<!-- TWO YEARS -->
|
|
<div id="two_years" style="display: none;">
|
|
<h5><b style="color: red"><span id="detail_tocontract_next"></span> Tage / <span id="restholidays_next"></span> verbleibend im Jahr <span id="holidayyear_next"></span></b>
|
|
</h5>
|
|
</div>
|
|
<div id="holiday_detail_div">
|
|
<div class="col-12" style="margin-left: -10px">
|
|
<table class="table table-sm">
|
|
<tbody>
|
|
<tr>
|
|
<td>Gewünschte Tage</td>
|
|
<td><span id="detail_tocontract_overall"></span></td>
|
|
</tr>
|
|
<tr>
|
|
<td>Resturlaub</td>
|
|
<td><span id="detail_rest"></span></td>
|
|
</tr>
|
|
<tr>
|
|
<td>Urlaub nächstes Jahr</td>
|
|
<td><span id="detail_next"></span> + Rest (<span id="detail_next_rest"></span>)</td>
|
|
</tr>
|
|
<tr>
|
|
<td><b>Summe Urlaubstage</b></td>
|
|
<td><b><span id="detail_sum"></span></b></td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
<div id="otherholidays" style="display: none;">
|
|
<hr>
|
|
In diesem Zeitraum haben bereits folgende Mitarbeiter Abwesenheiten:
|
|
<br />
|
|
<div id="otherholidays_users"></div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div id="noholidays_container" style="display: none;">
|
|
<h5>Abwesenheitsgrund ohne Urlaubsanspruch</h5>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<hr>
|
|
<div style="display: none;">
|
|
{{form.holidays_normal}}
|
|
{{form.holidays_rest}}
|
|
{{form.holidays_normal_next}}
|
|
{{form.holidays_rest_next}}
|
|
</div>
|
|
|
|
<a class="btn" href="{% url 'tma-management' %} ">Abbrechen</a>
|
|
<button type="submit" class="btn btn-primary" style="float: right" id="updateAbsence">Abwesenheit aktualisieren</button>
|
|
</form>
|
|
|
|
<script type="text/javascript">
|
|
|
|
var sameday = false;
|
|
|
|
$(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}}";
|
|
|
|
$('#id_reason option[value="{{absence.reason.pk}}"]').attr("selected",true);
|
|
$('#id_representator option[value="{{absence.representator.pk}}"]').attr("selected",true);
|
|
$('#id_startday_info option[value="{{absence.startday_info}}"]').attr("selected",true);
|
|
$('#id_endday_info option[value="{{absence.endday_info}}"]').attr("selected",true);
|
|
|
|
$("#id_holidays_normal").val({{absence.holidays_normal|unlocalize}});
|
|
$("#id_holidays_rest").val({{absence.holidays_rest|unlocalize}});
|
|
$("#id_holidays_normal_next").val({{absence.holidays_normal_next|unlocalize}});
|
|
$("#id_holidays_rest_next").val({{absence.holidays_rest_next|unlocalize}});
|
|
|
|
new_start = date_start.split(".");
|
|
new_end = date_end.split(".");
|
|
|
|
date_start = new Date(new_start[2], (parseInt(new_start[1])-1), new_start[0]);
|
|
date_end = new Date(new_end[2], (parseInt(new_end[1])-1), new_end[0]);
|
|
|
|
$("#id_start").data("DateTimePicker").date(date_start);
|
|
$("#id_end").data("DateTimePicker").date(date_end);
|
|
|
|
if(+new_start == +new_end){
|
|
sameday = true;
|
|
}
|
|
else{
|
|
sameday = false;
|
|
}
|
|
|
|
if(sameday){
|
|
date_end = date_start;
|
|
new_end = new_start;
|
|
}
|
|
|
|
reasonid = $('#id_reason :selected').val();
|
|
//Get required-rep
|
|
$.ajax(
|
|
{
|
|
type: "GET",
|
|
url: "{% url 'tm-ajax' %}",
|
|
data:{
|
|
action : "checkrequired",
|
|
rid : reasonid
|
|
},
|
|
success : function(data){
|
|
//CHANGE REPRESENTOR
|
|
if(data["isreq"]){
|
|
$("#id_representator").prop('required',true);
|
|
$("label[for*='id_representator']").html("Vertreter*");
|
|
}
|
|
else{
|
|
$("#id_representator").prop('required',false);
|
|
$("label[for*='id_representator']").html("Vertreter");
|
|
}
|
|
//CHANGE HOLIDAYCOUNT
|
|
if(data["isholiday"] == false){
|
|
$("#noholidays_container").show();
|
|
$("#restholidays_container").hide();
|
|
$("#start_absence_contract").prop("disabled", false);
|
|
}
|
|
else{
|
|
$("#noholidays_container").hide();
|
|
$("#restholidays_container").show();
|
|
}
|
|
}
|
|
});
|
|
|
|
$.ajax({
|
|
type: "GET",
|
|
url: "{% url 'tm-ajax' %}",
|
|
data:{
|
|
action : "getrestholidays",
|
|
userid : {{absence.user.pk}},
|
|
startdate : date_start.getFullYear() + "__" + (date_start.getMonth()+1) + "__" + date_start.getDate(),
|
|
enddate : date_end.getFullYear() + "__" + (date_end.getMonth()+1) + "__" + date_end.getDate(),
|
|
startday_info : $("#id_startday_info").val(),
|
|
endday_info : $("#id_endday_info").val(),
|
|
},
|
|
success : function(data){
|
|
|
|
|
|
if(data["other_absences"] != false){
|
|
$("#otherholidays").show();
|
|
$("#otherholidays_users").html(data["other_absences"]);
|
|
}
|
|
else{
|
|
$("#otherholidays").hide();
|
|
}
|
|
|
|
$("#restholidays").html(data["restholiday_thisyear"] + parseFloat($("#id_holidays_normal").val()) + parseFloat($("#id_holidays_rest").val()));
|
|
$("#detail_rest").html(data["restholiday_thisyear"] + parseFloat($("#id_holidays_normal").val()) + parseFloat($("#id_holidays_rest").val()));
|
|
$("#detail_resthol").html(data["restholiday_lastyear"]);
|
|
$("#detail_next").html(data["restholiday_nextyear"] + parseFloat($("#id_holidays_normal_next").val()) + parseFloat($("#id_holidays_rest_next").val()));
|
|
$("#holidayyear").html(new_start[2]);
|
|
$("#detail_sum").html(data["restholiday_thisyear"]+data["restholiday_lastyear"]+data["restholiday_nextyear"]+data["restholiday_nextyear_rest"] + parseFloat($("#id_holidays_normal").val()) + parseFloat($("#id_holidays_rest").val()));
|
|
|
|
$("#detail_tocontract").html(data["need_days"]);
|
|
$("#detail_tocontract_overall").html(data["need_days"]);
|
|
|
|
$("#detail_next_rest").html(data["restholiday_nextyear_rest"]+parseFloat($("#id_holidays_rest_next").val()));
|
|
|
|
if(data["two_years"] == true){
|
|
$("#detail_tocontract").html(data["need_days_this"]);
|
|
$("#two_years").show();
|
|
$("#holidayyear_next").html(new_end[2]);
|
|
$("#detail_next").html(data["restholiday_nextyear"]);
|
|
$("#detail_tocontract_next").html(data["need_days_next"]);
|
|
$("#restholidays_next").html(data["restholiday_nextyear"]);
|
|
$("#detail_tocontract_overall").html(data["need_days_next"]+data["need_days_this"]);
|
|
}
|
|
else{
|
|
$("#two_years").hide();
|
|
}
|
|
|
|
if(data["other_absences"] != false){
|
|
$("#otherholidays").show();
|
|
$("#otherholidays_users").html(data["other_absences"]);
|
|
}
|
|
else{
|
|
$("#otherholidays").hide();
|
|
}
|
|
|
|
if(data["restholiday_thisyear"] < 0 || data["restholiday_lastyear"] < 0 || data["restholiday_nextyear"] < 0){
|
|
$("#start_absence_contract").prop("disabled", true);
|
|
}
|
|
else{
|
|
$("#start_absence_contract").prop("disabled", false);
|
|
}
|
|
}
|
|
});
|
|
|
|
});
|
|
|
|
|
|
/*
|
|
CHANGE LISTENER
|
|
*/
|
|
$("#id_start").blur(function(){
|
|
recalculateChoosenDays();
|
|
})
|
|
|
|
$("#id_end").blur(function(){
|
|
recalculateChoosenDays();
|
|
})
|
|
|
|
/*
|
|
$("#id_start_ishalf").change(function(){
|
|
recalculateChoosenDays();
|
|
})
|
|
|
|
$("#id_end_ishalf").change(function(){
|
|
recalculateChoosenDays();
|
|
})
|
|
*/
|
|
$("#id_startday_info").change(function(){
|
|
recalculateChoosenDays();
|
|
})
|
|
|
|
$("#id_endday_info").change(function(){
|
|
recalculateChoosenDays();
|
|
})
|
|
|
|
|
|
|
|
|
|
function recalculateChoosenDays(){
|
|
|
|
date_start = $("#id_start").datepicker().val();
|
|
date_end = $("#id_end").datepicker().val();
|
|
|
|
new_start = date_start.split(".");
|
|
new_end = date_end.split(".");
|
|
|
|
date_start = new Date(new_start[2], (parseInt(new_start[1])-1), new_start[0]);
|
|
date_end = new Date(new_end[2], (parseInt(new_end[1])-1), new_end[0]);
|
|
$('.ui-datepicker-calendar').hide();
|
|
$('.ui-datepicker-header').hide();
|
|
|
|
|
|
$.ajax({
|
|
type: "GET",
|
|
url: "{% url 'tm-ajax' %}",
|
|
data:{
|
|
action : "getrestholidays",
|
|
userid : {{absence.user.pk}},
|
|
startdate : date_start.getFullYear() + "__" + (date_start.getMonth()+1) + "__" + date_start.getDate(),
|
|
enddate : date_end.getFullYear() + "__" + (date_end.getMonth()+1) + "__" + date_end.getDate(),
|
|
//start_half : $("#id_start_ishalf").prop("checked"),
|
|
//end_half : $("#id_end_ishalf").prop("checked"),
|
|
startday_info : $("#id_startday_info").val(),
|
|
endday_info : $("#id_endday_info").val(),
|
|
},
|
|
success : function(data){
|
|
|
|
if(data["other_absences"] != false){
|
|
$("#otherholidays").show();
|
|
$("#otherholidays_users").html(data["other_absences"]);
|
|
}
|
|
else{
|
|
$("#otherholidays").hide();
|
|
}
|
|
|
|
$("#restholidays").html(data["restholiday_thisyear"] + parseFloat($("#id_holidays_normal").val()) + parseFloat($("#id_holidays_rest").val()));
|
|
$("#detail_rest").html(data["restholiday_thisyear"] + parseFloat($("#id_holidays_normal").val()) + parseFloat($("#id_holidays_rest").val()));
|
|
$("#detail_resthol").html(data["restholiday_lastyear"]);
|
|
$("#detail_next").html(data["restholiday_nextyear"] + parseFloat($("#id_holidays_normal_next").val()) + parseFloat($("#id_holidays_rest_next").val()));
|
|
$("#holidayyear").html(new_start[2]);
|
|
$("#detail_sum").html(data["restholiday_thisyear"]+data["restholiday_lastyear"]+data["restholiday_nextyear"]+data["restholiday_nextyear_rest"] + parseFloat($("#id_holidays_normal").val()) + parseFloat($("#id_holidays_rest").val()));
|
|
|
|
$("#holidayyear").html(date_start.getFullYear());
|
|
$("#detail_next_rest").html(data["restholiday_nextyear_rest"]);
|
|
$("#detail_tocontract").html(data["need_days"]);
|
|
$("#detail_tocontract_overall").html(data["need_days"]);
|
|
|
|
if(data["two_years"] == true){
|
|
$("#detail_tocontract").html(data["need_days_this"]);
|
|
$("#two_years").show();
|
|
$("#holidayyear_next").html(new_end[2]+parseFloat($("#id_holidays_normal").val()));
|
|
$("#detail_next_rest").html(data["restholiday_nextyear_rest"]+ parseFloat($("#id_holidays_rest").val()));
|
|
$("#detail_next").html(data["restholiday_nextyear"]+ parseFloat($("#id_holidays_normal").val()));
|
|
$("#detail_tocontract_next").html(data["need_days_next"]);
|
|
$("#restholidays_next").html(data["restholiday_nextyear"]+ parseFloat($("#id_holidays_normal").val()));
|
|
$("#detail_tocontract_overall").html(data["need_days_next"]+data["need_days_this"]);
|
|
}
|
|
else{
|
|
$("#two_years").hide();
|
|
}
|
|
|
|
$("#detail_sum").html(data["restholiday_thisyear"]+data["restholiday_lastyear"]+data["restholiday_nextyear"]+data["restholiday_nextyear_rest"]);
|
|
|
|
sum_thisyear = data["restholiday_thisyear"] + parseFloat($("#id_holidays_normal").val()) + parseFloat($("#id_holidays_rest").val());
|
|
|
|
sum_nextyear = data["restholiday_nextyear"]+ parseFloat($("#id_holidays_normal").val())
|
|
|
|
if(+date_start == +date_end){
|
|
if(data["restholiday_thisyear"] < 0 || data["restholiday_lastyear"] < 0 || data["restholiday_nextyear"] < 0 || sum_thisyear < 0 || sum_nextyear < 0){
|
|
$("#updateAbsence").prop("disabled", true);
|
|
}
|
|
else{
|
|
$("#updateAbsence").prop("disabled", false);
|
|
}
|
|
}
|
|
else if(+date_start < +date_end == true){
|
|
if(data["restholiday_thisyear"] < 0 || data["restholiday_lastyear"] < 0 || data["restholiday_nextyear"] < 0 || sum_thisyear < 0 || sum_nextyear < 0){
|
|
$("#updateAbsence").prop("disabled", true);
|
|
}
|
|
else{
|
|
$("#updateAbsence").prop("disabled", false);
|
|
}
|
|
}
|
|
else{
|
|
$("#updateAbsence").prop("disabled", true);
|
|
}
|
|
|
|
}
|
|
});
|
|
|
|
}
|
|
|
|
//Set required repr or not
|
|
document.getElementById("id_reason").addEventListener("change", function(){
|
|
reasonid = $('#id_reason :selected').val();
|
|
//Get required-rep
|
|
$.ajax(
|
|
{
|
|
type: "GET",
|
|
url: "{% url 'tm-ajax' %}",
|
|
data:{
|
|
action : "checkrequired",
|
|
rid : reasonid
|
|
},
|
|
success : function(data){
|
|
//CHANGE REPRESENTOR
|
|
if(data["isreq"]){
|
|
$("#id_representator").prop('required',true);
|
|
$("label[for*='id_representator']").html("Vertreter*");
|
|
}
|
|
else{
|
|
$("#id_representator").prop('required',false);
|
|
$("label[for*='id_representator']").html("Vertreter");
|
|
}
|
|
//CHANGE HOLIDAYCOUNT
|
|
if(data["isholiday"] == false){
|
|
$("#noholidays_container").show();
|
|
$("#restholidays_container").hide();
|
|
$("#start_absence_contract").prop("disabled", false);
|
|
}
|
|
else{
|
|
$("#noholidays_container").hide();
|
|
$("#restholidays_container").show();
|
|
recalculateChoosenDays();
|
|
}
|
|
}
|
|
});
|
|
})
|
|
</script>
|
|
|
|
{% endif %}
|
|
{% endblock content %}
|