Merge branch 'spidev' into 'master'

Spidev

See merge request fronk/thetool!242
This commit is contained in:
Frank Schubert
2024-02-12 10:52:54 +00:00
25 changed files with 1343 additions and 357 deletions
+2 -2
View File
@@ -138,7 +138,7 @@ table.dataTable.table-sm > thead > tr > th:not(.sorting_disabled) {
{
color:#0d6efd;
font-size: 30px;
margin-right:20px;
margin-right:10px;
cursor: pointer;
}
.active-calendar
@@ -216,7 +216,7 @@ table.dataTable.table-sm > thead > tr > th:not(.sorting_disabled) {
{
font-size:35px;
margin-top:5px;
margin-right:30px;
margin-right:10px;
margin-bottom:20px;
}
+8 -1
View File
@@ -38,7 +38,14 @@ $('#filterrow th').each(function (i) {
});
table = $('#datatable').DataTable({
responsive: true,
responsive: {
breakpoints: [
{name: 'desktop', width: Infinity},
{name: 'tablet', width: 1024},
{name: 'fablet', width: 768},
{name: 'phone', width: 480}
]
},
buttons: [
{
extend: 'excelHtml5',
+36 -10
View File
@@ -19,6 +19,7 @@ if (typeof columnfilter === "undefined") {
var columnfilter;
columnfilter = "";
}
if (typeof columnoptions === "undefined") {
var columnoptions;
columnoptions = "";
@@ -78,10 +79,13 @@ table = $('#datatable').DataTable({
d.dataweek = $('#dataweek').val();
d.datamonth = $('#datamonth').val();
d.datayear = $('#datayear').val();
},
"dataSrc": function (json) {
$('#is-time').text(json.time.is);
$('#must-time').text(json.time.must);
$('#holidays').text(json.time.holidays);
$('#plushours').text(json.time.plushours);
return json.data;
}
@@ -120,8 +124,8 @@ table = $('#datatable').DataTable({
}
, {
"data": {
_: "commend.commend",
"sort": "commend.order"
_: "comment.comment",
"sort": "comment.order"
},
className: "text-center"
}, {
@@ -206,9 +210,9 @@ $(document).ready(function () {
})
}
if (parseInt($(this).find(':selected').data('comment')) === 1) {
$('#commend').prop("required", true);
$('#comment').prop("required", true);
} else {
$('#commend').prop("required", false);
$('#comment').prop("required", false);
}
});
$("body").on("change", "#date", function () {
@@ -216,6 +220,8 @@ $(document).ready(function () {
if ($('#date').val() > $('#enddate').val()) {
$('#enddate').prop("min", $('#date').val());
$('#enddate').val($('#date').val());
} else {
$('#enddate').prop("min", $('#date').val());
}
}
});
@@ -237,7 +243,7 @@ $(document).ready(function () {
$('#start').val($(this).data('start'));
$('#end').val($(this).data('end'));
$('#enddate').val($(this).data('enddate'));
$('#commend').val($(this).data('commend'));
$('#comment').val($(this).data('comment'));
$('.alert-success').remove();
window.scrollTo(0, 0);
});
@@ -248,7 +254,7 @@ $(document).ready(function () {
$('#id').val('');
});
$("body").on("change", "#dataweek,#datamonth", function () {
$("body").on("change", "#dataweek,#datamonth,#datayear", function () {
table.ajax.reload();
});
$("body").on("click", ".display-calendar", function () {
@@ -258,15 +264,36 @@ $(document).ready(function () {
$(this).addClass('active-calendar');
if ($(this).data('datatype') == "1") {
console.log($(this).data('datatype'));
$('#dataweek-col').show();
$('#dynamictime-div').show();
$('#datamonth-col').hide();
$('#datayear-col').hide();
} else if ($(this).data('datatype') == "2") {
$('#datamonth-col').show();
$('#dynamictime-div').show();
$('#dataweek-col').hide();
$('#datayear-col').hide();
} else if ($(this).data('datatype') == "3") {
$('#datayear-col').show();
$('#dynamictime-div').hide();
$('#datamonth-col').hide();
$('#dataweek-col').hide();
}
$(".select2").select2();
table.ajax.reload();
});
$("body").on("click", "#businesstrip", function () {
if ($(this).prop('checked') == true) {
$('#businesstrip_info').show();
$('#businesstrip_info').prop('required', true);
} else {
$('#businesstrip_info').hide();
$('#businesstrip_info').val('');
$('#businesstrip_info').prop('required', false);
}
});
$("body").on("click", ".delete-item", function () {
if (confirm('Buchung wirklich löschen?')) {
@@ -274,11 +301,10 @@ $(document).ready(function () {
id: $.trim($(this).data('id')),
ajax: 1
}).done(function (data) {
table.ajax.reload();
});
}
})
});
$('form').submit(function (e) {
e.preventDefault();
@@ -290,7 +316,7 @@ $(document).ready(function () {
enddate: $.trim($('#enddate').val()),
start: $.trim($('#start').val()),
end: $.trim($('#end').val()),
commend: $.trim($('#commend').val()),
comment: $.trim($('#comment').val()),
ajax: 1
}).done(function (data) {
var result = $.parseJSON(data);
@@ -0,0 +1,360 @@
let table;
if (typeof hidesearch === "undefined") {
var hidesearch;
hidesearch = [100];
}
if (typeof cstmdom === "undefined") {
var cstmdom;
cstmdom = "flBrtip";
}
if (typeof columndefs === "undefined") {
var columndefs;
columndefs = "";
}
if (typeof columnfilter === "undefined") {
var columnfilter;
columnfilter = "";
}
if (typeof columnoptions === "undefined") {
var columnoptions;
columnoptions = "";
}
$('#filterrow th').each(function (i) {
let title = $('#datatable thead th').eq($(this).index()).text();
if (hidesearch.includes($(this).index())) {
} else if (columnfilter.includes($(this).index())) {
$(this).html('<select style="padding: 0;height: 28px;;text-align: center;" id="selectsearch" class="form-control form-control-select form-control-special" data-index="' + i + '">' + columnoptions + '</select>');
} else {
$(this).html('<input type="text" placeholder="' + title + '" class="form-control" data-index="' + i + '" value="" />');
}
});
table = $('#datatable').DataTable({
responsive: true,
"order": [[1, "desc"]],
buttons: [
{
extend: 'excelHtml5',
text: 'XLSX Export',
className: 'btn-success margina d-none d-lg-block',
exportOptions: {
columns: ['th:not(:last-child)']
}
}
], columnDefs: [
columndefs
],
"language": {
"url": "/datatables/json/german.json?v1"
},
orderCellsTop: true,
stateSave: true,
"initComplete": function () {
$('#datatable_filter').append('<i id="clear_cookie" class="fas fa-times clear-fa" title="Filter löschen" aria-hidden="true" ></i>');
$('#clear_cookie').click(function () {
$('#filterrow input').val('');
$('#filterrow select').val('');
table.search('').columns().search('').draw();
});
},
"dom": cstmdom,
"ajax": {
"url": requestUrl,
"type": "GET",
"data": function (d) {
$('.display-calendar').each(function (index) {
if ($(this).hasClass('active-calendar')) {
d.datatype = $(this).data('datatype');
}
})
d.dataweek = $('#dataweek').val();
d.datamonth = $('#datamonth').val();
d.datayear = $('#datayear').val();
},
"dataSrc": function (json) {
$('#is-time').text(json.time.is);
$('#must-time').text(json.time.must);
$('#holidays').text(json.time.holidays);
$('#plushours').text(json.time.plushours);
return json.data;
}
},
"columns": [
{
"data": {
_: "user.user",
"sort": "user.order"
},
className: "text-nowrap"
},
{
"data": {
_: "date.date",
"sort": "date.order"
},
className: "text-nowrap"
}, {
"data": {
_: "start.start",
"sort": "start.order"
},
className: "text-center"
}, {
"data": {
_: "end.end",
"sort": "end.order"
},
className: "text-center"
}, {
"data": {
_: "sum.sum",
"sort": "sum.order"
},
className: "text-center"
}, {
"data": {
_: "category.category",
"sort": "category.order"
},
className: ""
}
, {
"data": {
_: "comment.comment",
"sort": "comment.order"
},
className: "text-center"
}, {
"data": {
_: "edit.edit",
"sort": "edit.order"
},
className: "edit-td"
}
]
});
$('#filterrow').on('keyup', 'input', function () {
table
.column($(this).data('index'))
.search(this.value)
.draw();
});
$('#selectsearch').change(function () {
table
.column($(this).data('index'))
.search(this.value)
.draw();
});
let state = table.state.loaded();
if (state) {
table.columns().eq(0).each(function (colIdx) {
var colSearch = state.columns[colIdx].search;
if (colSearch.search) {
$('#filterrow').find("[data-index='" + colIdx + "']").val(colSearch.search);
}
});
table.draw();
}
$(document).ready(function () {
$(".select2").select2();
$("body").on("change", "#timerecordingCategory_id", function () {
if (parseInt($(this).find(':selected').data('hourday')) === 2) {
$("#endtime-div").hide();
$("#endtime-div").find('input').each(function () {
$(this).prop("required", false);
});
$("#enddate-div").show();
$("#enddate-div").find('input').each(function () {
$(this).prop("required", true);
$(this).prop("min", $('#date').val());
$(this).val($('#date').val());
})
} else if (parseInt($(this).find(':selected').data('hourday')) === 1) {
$("#endtime-div").show();
$("#endtime-div").find('input').each(function () {
$(this).prop("required", true);
$(this).prop("disabled", false);
});
$("#enddate-div").hide();
$("#enddate-div").find('input').each(function () {
$(this).prop("required", false);
$(this).prop("min", '');
$(this).val('');
})
} else if (parseInt($(this).find(':selected').data('hourday')) === 3 || parseInt($(this).find(':selected').data('hourday')) === 4) {
$("#endtime-div").hide();
$("#endtime-div").find('input').each(function () {
$(this).prop("required", false);
$(this).prop("disabled", true);
});
$("#enddate-div").hide();
$("#enddate-div").find('input').each(function () {
$(this).prop("required", false);
$(this).prop("min", '');
$(this).val('');
})
}
if (parseInt($(this).find(':selected').data('comment')) === 1) {
$('#comment').prop("required", true);
} else {
$('#comment').prop("required", false);
}
});
$("body").on("change", "#date", function () {
if ($('#enddate-div').css('display') === "block") {
if ($('#date').val() > $('#enddate').val()) {
$('#enddate').prop("min", $('#date').val());
$('#enddate').val($('#date').val());
} else {
$('#enddate').prop("min", $('#date').val());
}
}
});
$("body").on("change", "#start", function () {
if ($('#start').val() > $('#end').val()) {
$('#end').val($('#start').val());
}
$('#end').prop("min", $('#start').val());
});
$("body").on("click", ".edit-button", function () {
$('#submit-button').hide().removeClass('btn-primary').addClass('btn-danger').show();
$('#submit-button').text('Ändern');
$('#cancel-button').show();
$('#timerecordingCategory_id').val($(this).data('category')).change();
$('#user_id_select').prop('disabled', true);
$('#user_id_input').prop('disabled', false);
$('#user_id_select').val($(this).data('userid')).change();
$('#user_id_input').val($(this).data('userid'));
$('#id').val($(this).data('id'));
$('#date').val($(this).data('date'));
$('#start').val($(this).data('start'));
$('#end').val($(this).data('end'));
$('#enddate').val($(this).data('enddate'));
$('#comment').val($(this).data('comment'));
$('.alert-success').remove();
window.scrollTo(0, 0);
});
$("body").on("click", "#cancel-button", function () {
$('#submit-button').text('Speichern');
$('#cancel-button').hide();
$('#user_id_select').prop('disabled', false);
$('#user_id_input').prop('disabled', true);
$('#user_id_select').change();
$('#timerecordingCategory_id').val($(this).data('category')).change();
$('#id').val('');
});
$("body").on("change", "#dataweek,#datamonth,#datayear", function () {
table.ajax.reload(null, false);
});
$("body").on("click", ".display-calendar", function () {
$('.display-calendar').each(function (index) {
$(this).removeClass('active-calendar');
});
$(this).addClass('active-calendar');
if ($(this).data('datatype') == "1") {
$('#dataweek-col').show();
$('#dynamictime-div').show();
$('#datamonth-col').hide();
$('#datayear-col').hide();
} else if ($(this).data('datatype') == "2") {
$('#datamonth-col').show();
$('#dynamictime-div').show();
$('#dataweek-col').hide();
$('#datayear-col').hide();
} else if ($(this).data('datatype') == "3") {
$('#datayear-col').show();
$('#dynamictime-div').hide();
$('#datamonth-col').hide();
$('#dataweek-col').hide();
}
$(".select2").select2();
table.ajax.reload(null, false);
});
$("body").on("click", ".delete-item", function () {
if (confirm('Buchung wirklich löschen?')) {
$.post(deleteUrl, {
id: $.trim($(this).data('id')),
ajax: 1
}).done(function (data) {
table.ajax.reload(null, false);
});
}
})
$('form').submit(function (e) {
e.preventDefault();
$('#alert-box').remove();
var userid;
if ($.trim($('#id').val())) {
userid = $('#user_id_input').val();
}
$.post(insertUrl, {
id: $.trim($('#id').val()),
user_id: userid,
timerecordingCategory_id: $.trim($('#timerecordingCategory_id').val()),
date: $.trim($('#date').val()),
enddate: $.trim($('#enddate').val()),
start: $.trim($('#start').val()),
end: $.trim($('#end').val()),
comment: $.trim($('#comment').val()),
ajax: 1
}).done(function (data) {
var result = $.parseJSON(data);
if (result.state === "success") {
$('.wrapper .container-fluid').prepend(`<div id="alert-box" class="row">
<div class="col-md-1"></div>
<div class="col-md-10 alert alert-success alert-dismissible">
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
<h5><i class="icon fas fa-check"></i> Erfolgreich</h5>
` + result.message + `</div>
</div>`);
}
if (result.state === "error") {
$('.wrapper .container-fluid').prepend(`<div id="alert-box" class="row">
<div class="col-md-1"></div>
<div class="col-md-10 alert alert-danger alert-dismissible">
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
<h5><i class="icon fas fa-ban"></i> Fehler</h5>
` + result.error + `</div>
</div>`);
}
$('#submit-button').hide().removeClass('btn-danger').addClass('btn-primary').show();
$('#submit-button').text('Speichern');
$('#cancel-button').hide();
$('#user_id_select').prop('disabled', false);
$('#user_id_input').prop('disabled', true);
$('#user_id_select').change();
$('#id').val('');
table.ajax.reload(null, false);
});
});
})
;