369 lines
12 KiB
JavaScript
369 lines
12 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);
|
|
|
|
initGroupBookingForm();
|
|
|
|
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");
|
|
|
|
initializeDocumentationTextareas();
|
|
|
|
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);
|
|
$(".gruppenbuchungsCheckboxContainer").css("width", height);
|
|
|
|
//if(localStorage.getItem("Zeitdaten") != null || localStorage.getItem("Kalenderdaten") != null) {
|
|
// console.log("a service record has been found in the local storage");
|
|
// if($("#ErrorZeiterfassungAfterCrashSchalter").value == 1 ||
|
|
// $("#ErrorZeiterfassungAfterCrashSchalter").value == null ||
|
|
// $("#ErrorZeiterfassungAfterCrashSchalter").value == 0) {
|
|
// console.log("loading service records...");
|
|
// LoadOnly(1, 2);
|
|
// clearLocalStorage(1);
|
|
// clearLocalStorage(2);
|
|
// } else {
|
|
// showErrorAfterCrash();
|
|
// console.log("an error occurred")
|
|
// }
|
|
//} 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(isInGroupBookingMode() && isInEditingMode()) {
|
|
if(getGroupEditingFlag().flag === false) {
|
|
loadSavedValuesIntoForm();
|
|
} else {
|
|
saveFormValuesLocally();
|
|
}
|
|
|
|
setGroupEditingFlag(false);
|
|
}
|
|
|
|
const shouldActivateForm = isInGroupBookingMode() ? $("#gruppenbuchungsSupportConceptTable tr").length > 0 : selectedServiceCategory !== "-1";
|
|
|
|
if(shouldActivateForm) {
|
|
$("#recordLoader_select").prop("disabled", false);
|
|
|
|
activateForm(actionPath);
|
|
|
|
if(!isInEditingMode()) {
|
|
$("#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();
|
|
}
|
|
});
|
|
|
|
const supportConceptTableHasEntries = $("#gruppenbuchungsSupportConceptTable").has("td").length;
|
|
const employeesTableHasEntries = $("#gruppenbuchungsEmployeeTable").has("td").length;
|
|
|
|
if(isInGroupBookingMode()) {
|
|
$("#anlegenEditierenBtn").prop("disabled", (supportConceptTableHasEntries === 0 || employeesTableHasEntries === 0));
|
|
}
|
|
} 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 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);
|
|
}
|
|
}
|
|
});
|
|
}
|
|
|
|
var savedEditFormValues = {};
|
|
|
|
$(document).on("change", ".edit-form-input",
|
|
function() {
|
|
saveFormValuesLocally();
|
|
});
|
|
|
|
function saveFormValuesLocally() {
|
|
const recordObject = {
|
|
category: $("#kategorien_select").val(),
|
|
serviceDescription: $("#leistungen_select").val(),
|
|
startDate: $("#datum_textbox").val(),
|
|
endDate: $("#enddatum_textbox").val(),
|
|
startTime: $("#start_textbox").val(),
|
|
endTime: $("#ende_textbox").val(),
|
|
duration: $("#duration_textbox").val(),
|
|
distance: $("#distance_textbox").val(),
|
|
notice: $("#notiz_textbox").val(),
|
|
notice2: $("#notiz_textbox2").val(),
|
|
notice3: $("#notiz_textbox3").val(),
|
|
notice4: $("#notiz_textbox4").val(),
|
|
notice5: $("#notiz_textbox5").val()
|
|
};
|
|
|
|
savedEditFormValues.obj = recordObject;
|
|
|
|
localStorage.savedEditFormValues = JSON.stringify(savedEditFormValues);
|
|
}
|
|
|
|
function deleteSavedEditFormValues() {
|
|
localStorage.savedEditFormValues = undefined;
|
|
savedEditFormValues = undefined;
|
|
}
|
|
|
|
function loadSavedEditFormValues() {
|
|
const storageData = localStorage.savedEditFormValues;
|
|
|
|
if(storageData !== "undefined") {
|
|
savedEditFormValues = JSON.parse(storageData);
|
|
} else {
|
|
savedEditFormValues = {};
|
|
}
|
|
|
|
return savedEditFormValues.obj;
|
|
}
|
|
|
|
function loadSavedValuesIntoForm() {
|
|
const values = loadSavedEditFormValues();
|
|
|
|
if(values.category !== "undefined") {
|
|
$("#kategorien_select").val(values.category);
|
|
}
|
|
|
|
if(values.serviceDescription !== "undefined") {
|
|
$("#leistungen_select").val(values.serviceDescription);
|
|
}
|
|
|
|
if(values.startDate !== "undefined") {
|
|
$("#datum_textbox").val(values.startDate);
|
|
}
|
|
|
|
if(values.endDate !== "undefined") {
|
|
$("#enddatum_textbox").val(values.endDate);
|
|
}
|
|
|
|
if(values.startTime !== "undefined") {
|
|
$("#start_textbox").val(values.startTime);
|
|
}
|
|
|
|
if(values.endTime !== "undefined") {
|
|
$("#ende_textbox").val(values.endTime);
|
|
}
|
|
|
|
if(values.duration !== "undefined") {
|
|
$("#duration_textbox").val(values.duration);
|
|
}
|
|
|
|
if(values.distance !== "undefined") {
|
|
$("#distance_textbox").val(values.distance);
|
|
}
|
|
|
|
if(values.notice !== "undefined") {
|
|
$("#notiz_textbox").val(values.notice);
|
|
}
|
|
|
|
if(values.notice1 !== "undefined") {
|
|
$("#notiz_textbox1").val(values.notice);
|
|
}
|
|
|
|
if(values.notice2 !== "undefined") {
|
|
$("#notiz_textbox2").val(values.notice2);
|
|
}
|
|
|
|
if(values.notice3 !== "undefined") {
|
|
$("#notiz_textbox3").val(values.notice3);
|
|
}
|
|
|
|
if(values.notice4 !== "undefined") {
|
|
$("#notiz_textbox4").val(values.notice4);
|
|
}
|
|
|
|
if(values.notice5 !== "undefined") {
|
|
$("#notiz_textbox5").val(values.notice5);
|
|
}
|
|
} |