Bei einem Abbruch vom Ändern eines Zeiterfassungseintrags werden sämtliche Doku-Felder geleert.
262 lines
9.2 KiB
JavaScript
262 lines
9.2 KiB
JavaScript
var isEnddateSet;
|
|
var numberOfDocumentationTypes;
|
|
|
|
$(document).ready(function () {
|
|
if(!$("#zeiterfassung").length) {
|
|
return;
|
|
}
|
|
|
|
toggleErrorPopup2('errorPopupDiv2');
|
|
|
|
$("#leistungen_select,#kategorien_select,#recordLoader_select,#textbausteine_select").prop("disabled", false);
|
|
|
|
toggleSelectClassesForElement("#kategorien_select", "#kategorien-select-container");
|
|
toggleSelectClassesForElement("#leistungen_select", "#leistungen-select-container");
|
|
toggleSelectClassesForElement("#recordLoader_select", "#record-loader-select-container");
|
|
toggleSelectClassesForElement("#textbausteine_select", "#textbausteine-select-container");
|
|
|
|
//Lade Dokumentationsreiter aus Bewo
|
|
initializeDocumentationTextareas();
|
|
|
|
//ist EndDate Gewünscht
|
|
checkEndDate();
|
|
|
|
initBeWoMobile(loadGoalsUrl);
|
|
|
|
const height = $("#datum_textbox").css("height");
|
|
|
|
$(".dropdownlist-for").css("height", height);
|
|
|
|
$("#statistik-button").css("height", height);
|
|
$("#statistik-button").css("width", height);
|
|
|
|
$("#statistik-button-td").css("width", height);
|
|
|
|
//if (localStorage.getItem("Zeitdaten") != null || localStorage.getItem("Kalenderdaten") != null) {
|
|
// console.log("Ich bin hier drinne weil Storage vorhanden");
|
|
// if (document.getElementById("ErrorZeiterfassungAfterCrashSchalter").value == 1 ||
|
|
// document.getElementById("ErrorZeiterfassungAfterCrashSchalter").value == null ||
|
|
// document.getElementById("ErrorZeiterfassungAfterCrashSchalter").value == 0) {
|
|
// console.log("Ich bin hier beim Laden einer Zeiterfassung ");
|
|
// LoadOnly(1, 2);
|
|
// deleteLocalStorage(1);
|
|
// deleteLocalStorage(2);
|
|
// } else {
|
|
// ErrorZeiterfassungAfterCrash();
|
|
// console.log(" ich bin hier nach dem Crash ")
|
|
// }
|
|
//} else {
|
|
// console.log("Ich bin hier drinne weil Storage nicht vorhanden");
|
|
//}
|
|
|
|
ErfolgteSpx();
|
|
|
|
vm = new KlientenVM();
|
|
ko.applyBindings(vm);
|
|
|
|
loadSettingsAccordingToBWP();
|
|
});
|
|
|
|
function initBeWoMobile(actionPath) {
|
|
try {
|
|
$("#recordLoader_select, #kategorien_select, #leistungen_select, #textbausteine_select").prop("disabled", true);
|
|
|
|
toggleSelectClassesForElement("#kategorien_select", "#kategorien-select-container");
|
|
toggleSelectClassesForElement("#leistungen_select", "#leistungen-select-container");
|
|
toggleSelectClassesForElement("#recordLoader_select", "#record-loader-select-container");
|
|
toggleSelectClassesForElement("#textbausteine_select", "#textbausteine-select-container");
|
|
|
|
const selectedServiceCategory = $($("#scDropDown")).find(":selected").val();
|
|
|
|
if (selectedServiceCategory !== "-1") {
|
|
$("#recordLoader_select").prop("disabled", false);
|
|
|
|
if ($("#anlegenEditierenBtn").val() === "Anlegen") {
|
|
activateForm(actionPath);
|
|
}
|
|
|
|
$("#datum_textbox").val(getDateStringWithLeadingZeros(new Date()));
|
|
}
|
|
|
|
$(".not-required-input").on("click blur change focus",
|
|
function() {
|
|
const v = $(this).attr("id");
|
|
setTimeout(function() { toggleLabel(v); }, 1);
|
|
}
|
|
);
|
|
|
|
$("#start_textbox").on("blur", function () {
|
|
const startHasValue = $("#start_textbox").val() !== "";
|
|
const endHasValue = $("#ende_textbox").val() !== "";
|
|
const durationHasValue = $("#duration_textbox").val() !== "";
|
|
|
|
if(startHasValue && endHasValue) {
|
|
calcDurationByStartEnd();
|
|
} else if(startHasValue && durationHasValue) {
|
|
calcEndByStartDuration();
|
|
}
|
|
});
|
|
|
|
$("#ende_textbox").on("blur", function () {
|
|
const startHasValue = $("#start_textbox").val() !== "";
|
|
const endHasValue = $("#ende_textbox").val() !== "";
|
|
const durationHasValue = $("#duration_textbox").val() !== "";
|
|
|
|
if (endHasValue && startHasValue) {
|
|
calcDurationByStartEnd();
|
|
} else if (endHasValue && durationHasValue) {
|
|
calcStartByEndDuration();
|
|
}
|
|
});
|
|
|
|
$("#duration_textbox").on("blur", function () {
|
|
const startHasValue = $("#start_textbox").val() !== "";
|
|
const endHasValue = $("#ende_textbox").val() !== "";
|
|
const durationHasValue = $("#duration_textbox").val() !== "";
|
|
|
|
clearZED();
|
|
|
|
if (durationHasValue && startHasValue) {
|
|
calcEndByStartDuration();
|
|
} else if (durationHasValue && endHasValue) {
|
|
calcStartByEndDuration();
|
|
}
|
|
});
|
|
} catch (err) {
|
|
console.log(`Fehler: ${err.message}`);
|
|
}
|
|
}
|
|
|
|
function toggleSelectClassesForElement(elementIdentifier, parentElement) {
|
|
const enabled = $(elementIdentifier).prop("disabled") === "false";
|
|
|
|
if (enabled) {
|
|
$(parentElement).removeClass("disabled-select-container");
|
|
$(parentElement).addClass("styled-select-div");
|
|
} else {
|
|
$(parentElement).removeClass("styled-select-div");
|
|
$(parentElement).addClass("disabled-select-container");
|
|
}
|
|
}
|
|
|
|
function toggleErrorPopup2(errorMessage) {
|
|
const isDisplayNone = $("#errorPopupDiv2").css("display") === "none";
|
|
const displayValue = isDisplayNone ? "block" : "none";
|
|
|
|
$("#errorPopupDiv2").css("display", displayValue);
|
|
$(".modalWrapper").css("display", displayValue);
|
|
$(".modalWrapper").css("height", $(document).height());
|
|
|
|
if (isDisplayNone) {
|
|
$("#errorPopupText2").text(errorMessage);
|
|
|
|
let h = 0;
|
|
const t = $("#errorPopupTitle2").outerHeight();
|
|
const u = $("#errorPopupText2").outerHeight();
|
|
const v = $("#errorPopupBtnDiv2").outerHeight();
|
|
const w = $("#errorPopupOkBtn2").outerHeight();
|
|
|
|
h += t + u + v + w + w;
|
|
|
|
$("#errorPopupDiv2").css("height", h + "px");
|
|
|
|
$("#errorPopupDiv2").css("top", window.pageYOffset + window.innerHeight / 2 - h / 2);
|
|
$("#errorPopupDiv2").css("margin-top", "0");
|
|
} else {
|
|
$("#errorPopupDiv2").css("margin-top", "auto");
|
|
}
|
|
}
|
|
|
|
function logoutSettingsAccordingToBWP(timeoutTime) {
|
|
if (timeoutTime > 0) {
|
|
timeoutTime = timeoutTime * 1000 * 60;
|
|
clearTimeout();
|
|
setTimeout(function() {
|
|
$.ajax({
|
|
type: "POST",
|
|
url: LogoutUrl,
|
|
success: function() {
|
|
writeFatalErrorMessage("Ihre Sitzung ist abgelaufen.");
|
|
|
|
setTimeout(function() {
|
|
location.reload();
|
|
}, 3000);
|
|
|
|
},
|
|
error: function() {}
|
|
});
|
|
}, timeoutTime);
|
|
}
|
|
}
|
|
|
|
var timeoutSetting;
|
|
|
|
function loadSettingsAccordingToBWP() {
|
|
$.ajax({
|
|
type: "GET",
|
|
url: LoadSessionSettingsFromBWPUrl,
|
|
success: function (json) {
|
|
const timeOutSettingsString = $.parseJSON(json);
|
|
|
|
timeoutSetting = parseInt(timeOutSettingsString);
|
|
logoutSettingsAccordingToBWP(timeoutSetting);
|
|
}
|
|
});
|
|
}
|
|
|
|
function checkEndDate() {
|
|
$.ajax({
|
|
type: "GET",
|
|
url: CheckEndDateUrl,
|
|
success: function (json) {
|
|
const endDateSettingsString = $.parseJSON(json);
|
|
const endDateSetting = parseInt(endDateSettingsString);
|
|
|
|
if (endDateSetting === 1) {
|
|
$("#EndDate_div").css("display", "block");
|
|
$("#enddatum_textbox").val($("#datum_textbox").val());
|
|
}
|
|
else {
|
|
$("#EndDate_div").css("display", "none");
|
|
}
|
|
}
|
|
});
|
|
}
|
|
|
|
function initializeDocumentationTextareas() {
|
|
$.ajax({
|
|
type: "GET",
|
|
url: CheckDokuReiterUrl,
|
|
success: function (json) {
|
|
const documentationTypes = $.parseJSON(json);
|
|
numberOfDocumentationTypes = documentationTypes.length;
|
|
|
|
if(numberOfDocumentationTypes === 0) {
|
|
$("#tddokureiter").css("display", "none");
|
|
$("#trnormalDoku").css("display", "table-row");
|
|
window.focusedDokuTextarea = $("#notiz_textbox");
|
|
} else {
|
|
window.focusedDokuTextarea = $("#notiz_textbox1");
|
|
}
|
|
|
|
if(numberOfDocumentationTypes === 1) {
|
|
$("#tddokureiter").css("display", "none");
|
|
$("#trnormalDoku").css("display", "table-row");
|
|
$("#trnormalDokuLabel").text(documentationTypes[0].TypeDescription);
|
|
}
|
|
|
|
if (numberOfDocumentationTypes > 1) {
|
|
for(let i = 0; i < numberOfDocumentationTypes; i++) {
|
|
const idNumber = i + 1;
|
|
|
|
$(`#DokName${idNumber}`).text(documentationTypes[i].TypeDescription);
|
|
$(`#Dokumentation${idNumber}`).css("display", "block");
|
|
}
|
|
}
|
|
|
|
if(numberOfDocumentationTypes > 0) {
|
|
focusOnTab(1);
|
|
}
|
|
}
|
|
});
|
|
} |