' + data + '
').text(); return $.isNumeric(data.replace(',', '.')) ? data.replace(',', '.') : data; } } } } ] }, topEnd: { pageLength: true } } }); $('#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(); } $(window).scroll(function () { var height = $(window).scrollTop(); if (height > 450) { if ($('#filterrow').is(':visible')) { $('#filterrow').hide(); } } else { if ($('#filterrow').is(':hidden')) { $('#filterrow').show(); } } }); $(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()); }); $('#days-div').hide(); $('#days').prop("required", false); $("#div-calc-overtime").hide(); } else if (parseInt($(this).find(':selected').data('hourday')) === 1 || parseInt($(this).find(':selected').data('hourday')) === 6) { if (parseInt($(this).find(':selected').data('hourday')) === 6) { $("#div-calc-overtime").show(); } else { $("#div-calc-overtime").hide(); } $("#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(''); }); $('#days-div').hide(); $('#days').prop("required", false); } 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); }); $("#div-calc-overtime").hide(); $("#enddate-div").hide(); $("#enddate-div").find('input').each(function () { $(this).prop("required", false); $(this).prop("min", ''); $(this).val(''); }); $('#days-div').hide(); $('#days').prop("required", false); } else if (parseInt($(this).find(':selected').data('hourday')) === 5) { $("#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(''); }); $('#days-div').show(); $('#days-div').find('label').text('Anzahl Tage'); $('#days-div').find('input').attr("step", "1"); $('#days-div').find('input').attr("min", ""); $('#days-div').find('input').val(""); $('#days').prop("required", true); } else if (parseInt($(this).find(':selected').data('hourday')) === 7) { $("#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(''); }) $('#businesstrip_info').val(''); $('#businesstrip_info').show(); $('.car-div-car').show(); } else if (parseInt($(this).find(':selected').data('hourday')) === 8) { $("#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(''); }); $('#days-div').show(); $('#days-div').find('label').text('Anzahl Stunden'); $('#days-div').find('input').attr("step", "0.01"); $('#days-div').find('input').attr("min", ""); $('#days').prop("required", true); $('#days-div').find('input').val(""); } else if (parseInt($(this).find(':selected').data('hourday')) === 9) { $("#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(''); }); $('#days-div').show(); $('#days-div').find('label').text('Anzahl Stunden'); $('#days-div').find('input').attr("step", "0.01"); $('#days-div').find('input').attr("min", "0"); $('#days').prop("required", true); $('#days-div').find('input').val(""); } if (parseInt($(this).find(':selected').data('comment')) === 1) { $('#comment').prop("required", true); } else { $('#comment').prop("required", false); } if (parseInt($(this).find(':selected').data('businesstrip')) === 1) { $('.businesstrip-div').show(); $('#businesstrip').prop("checked", false); $('#businesstrip_info').val(''); $('#businesstrip_info').hide(); $('.car-div').find('input').prop("required", false); $('.car-div').find('input').val(''); $('#timerecordingCar_id').val('').change(); $('.car-div').hide(); } else if (parseInt($(this).find(':selected').data('hourday')) === 7) { $('.businesstrip-div').show(); $('.businesstrip-check-div').hide(); $('#businesstrip').prop("checked", true); $('#businesstrip_info').show(); $('#businesstrip_info').prop('required', true); $('#homeoffice-div').hide(); } else { $('.businesstrip-div').hide(); $('#businesstrip').prop("checked", false); $('#businesstrip_info').val(''); $('#timerecordingCar_id').val('').change(); $('.car-div').find('input').prop("required", false); $('.car-div').find('input').val(''); $('.car-div').hide(); $('#businesstrip_info').hide(); } if (parseInt($(this).find(':selected').data('homeoffice')) === 1) { $('#homeoffice-div').show(); $('#homeoffice').prop("checked", false); } else { $('#homeoffice').prop("checked", false); $('#homeoffice-div').hide(); } }); $("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("change", "#start,#end,#date,#timerecordingCategory_id,#user_id_select", function () { if (parseInt($('#timerecordingCategory_id').find(':selected').data('hourday')) === 6) { var userid; userid = $('#user_id_select').val(); $.post(checkWorkinghoursUrl, { user_id: userid, date: $.trim($('#date').val()), start: $.trim($('#start').val()), end: $.trim($('#end').val()), ajax: 1 }).done(function (data) { var result = $.parseJSON(data); if (result.state === "success") { $('#calc-overtime').html(result.message); } if (result.state === "error") { $('#calc-overtime').html('