397 lines
12 KiB
JavaScript
397 lines
12 KiB
JavaScript
var isEnddateSet;
|
|
var numberOfDocumentationTypes;
|
|
|
|
var canvasWidth;
|
|
|
|
$(document).ready(function() {
|
|
startBeWoMobile();
|
|
});
|
|
|
|
function startBeWoMobile() {
|
|
if (!$("#zeiterfassung").length) {
|
|
return;
|
|
}
|
|
|
|
initializeDocumentationTextareas();
|
|
|
|
checkEndDate();
|
|
|
|
initBeWoMobile(loadGoalsUrl);
|
|
|
|
var 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();
|
|
|
|
var count = 0;
|
|
|
|
if (typeof vm !== "undefined") {
|
|
count = vm.vorname.getSubscriptionsCount();
|
|
}
|
|
|
|
vm = new KlientenVM();
|
|
|
|
if (count === 0) {
|
|
ko.applyBindings(vm);
|
|
}
|
|
|
|
var width = $("body").width();
|
|
canvasWidth = width * scaleFactor;
|
|
|
|
$("#sketchpad").prop("width", canvasWidth);
|
|
|
|
loadSettingsAccordingToBWP();
|
|
}
|
|
|
|
var scaleFactor = .95;
|
|
$(window).resize(function() {
|
|
var bodyWidth = $("body").width();
|
|
|
|
if ($("#sketchpad").css("display") === "inline") {
|
|
$("#sketchpad").prop("width", bodyWidth * scaleFactor);
|
|
}
|
|
});
|
|
|
|
function initBeWoMobile(actionPath) {
|
|
try {
|
|
var selectedServiceCategory = $("#scDropDown").find(":selected").val();
|
|
var shouldLoadServiceDescriptions = true;
|
|
|
|
if (isInGroupBookingMode() && isInEditingMode()) {
|
|
if (getGroupEditingFlag().flag === false) {
|
|
loadSavedValuesIntoForm();
|
|
} else {
|
|
var serviceCategoryOid = $("#selectedServiceCategoryOidHolder").val();
|
|
var serviceDescriptionOid = $("#selectedServiceDescriptionOidHolder").val();
|
|
|
|
shouldLoadServiceDescriptions = false;
|
|
|
|
showSanduhr();
|
|
makeAjaxCall("GET", window.loadServiceCategoriesUrl, function (result) {
|
|
if (isEmptyOrSpaces(result)) {
|
|
window.location.href = window.redirectLink;
|
|
return;
|
|
}
|
|
|
|
if (result === "SessionTimeout") {
|
|
window.location.href = redirectLink;
|
|
return;
|
|
}
|
|
|
|
var kategorienSelect = $("#kategorien_select");
|
|
|
|
kategorienSelect.val(serviceCategoryOid);
|
|
|
|
var liste = $.parseJSON(result);
|
|
var leistungenSelect = $("#leistungen_select");
|
|
leistungenSelect.empty();
|
|
leistungenSelect.val("");
|
|
|
|
$.each(liste, function (index, leistung) {
|
|
leistungenSelect.append('<option value="' + leistung.ServiceDescriptionOid + '">' + leistung.Name + '</option>');
|
|
});
|
|
|
|
leistungenSelect.val(serviceDescriptionOid);
|
|
|
|
makeAjaxCall("GET", window.setServiceDescriptionUrl, function () {
|
|
hideSanduhr();
|
|
|
|
saveFormValuesLocally();
|
|
}, { pServiceDescriptionOid: serviceDescriptionOid }, null);
|
|
}, { pServiceCategoryOid: serviceCategoryOid }, null);
|
|
}
|
|
|
|
setGroupEditingFlag(false);
|
|
}
|
|
|
|
var shouldActivateForm = isInGroupBookingMode() ? $("#leftContent input:checked").length > 0 : selectedServiceCategory !== "-1";
|
|
|
|
if (shouldActivateForm) {
|
|
activateInputForm(actionPath, shouldLoadServiceDescriptions);
|
|
} else {
|
|
deactivateInputForm();
|
|
}
|
|
|
|
$(".not-required-input").on("click blur change focus",
|
|
function() {
|
|
var v = $(this).attr("id");
|
|
setTimeout(function() { toggleLabel(v); }, 1);
|
|
}
|
|
);
|
|
|
|
$("#start_textbox").on("blur", function() {
|
|
var startHasValue = $("#start_textbox").val() !== "";
|
|
var endHasValue = $("#ende_textbox").val() !== "";
|
|
var durationHasValue = $("#duration_textbox").val() !== "";
|
|
|
|
if(startHasValue && endHasValue) {
|
|
calcDurationByStartEnd();
|
|
} else if(startHasValue && durationHasValue) {
|
|
calcEndByStartDuration();
|
|
}
|
|
});
|
|
|
|
$("#ende_textbox").on("blur", function () {
|
|
var startHasValue = $("#start_textbox").val() !== "";
|
|
var endHasValue = $("#ende_textbox").val() !== "";
|
|
var durationHasValue = $("#duration_textbox").val() !== "";
|
|
|
|
if(endHasValue && startHasValue) {
|
|
calcDurationByStartEnd();
|
|
} else if(endHasValue && durationHasValue) {
|
|
calcStartByEndDuration();
|
|
}
|
|
});
|
|
|
|
$("#duration_textbox").on("blur", function () {
|
|
var startHasValue = $("#start_textbox").val() !== "";
|
|
var endHasValue = $("#ende_textbox").val() !== "";
|
|
var durationHasValue = $("#duration_textbox").val() !== "";
|
|
|
|
clearZED();
|
|
|
|
if(durationHasValue && startHasValue) {
|
|
calcEndByStartDuration();
|
|
} else if (durationHasValue && endHasValue) {
|
|
calcStartByEndDuration();
|
|
}
|
|
});
|
|
|
|
var supportConceptTableHasEntries = $("#leftContent input:checked").length;
|
|
var employeesTableHasEntries = $("#employeeCollapsible input:checked").length;
|
|
|
|
if (isInGroupBookingMode()) {
|
|
var value = !(supportConceptTableHasEntries > 0 && employeesTableHasEntries > 0);
|
|
|
|
$("#anlegenEditierenBtn").prop("disabled", value);
|
|
}
|
|
} catch(err) {
|
|
console.log("Fehler: " + err.message);
|
|
}
|
|
}
|
|
|
|
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) {
|
|
var timeOutSettingsString = $.parseJSON(json);
|
|
|
|
timeoutSetting = parseInt(timeOutSettingsString);
|
|
logoutSettingsAccordingToBWP(timeoutSetting);
|
|
}
|
|
});
|
|
}
|
|
|
|
function initializeDocumentationTextareas() {
|
|
makeAjaxCall(
|
|
"GET",
|
|
CheckDokuReiterUrl,
|
|
function (json) {
|
|
var dokuTypes = $.parseJSON(json);
|
|
|
|
numberOfDocumentationTypes = dokuTypes.length;
|
|
|
|
var tabWidth = 100 / numberOfDocumentationTypes;
|
|
$(".doku-tab-link").css("width", tabWidth + "%");
|
|
|
|
if (numberOfDocumentationTypes === 0) {
|
|
$("#tddokureiter").hide();
|
|
$("#trnormalDoku").css("display", "table-row");
|
|
window.focusedDokuTextarea = $("#notiz_textbox");
|
|
} else {
|
|
window.focusedDokuTextarea = $("#notiz_textbox1");
|
|
}
|
|
|
|
if (numberOfDocumentationTypes === 1) {
|
|
$("#tddokureiter").hide();
|
|
$("#trnormalDoku").css("display", "table-row");
|
|
$("#trnormalDokuLabel").val(dokuTypes[0].TypeDescription);
|
|
}
|
|
|
|
if (numberOfDocumentationTypes > 1) {
|
|
var height = 0;
|
|
|
|
for (var i = 0; i < numberOfDocumentationTypes; i++) {
|
|
var idNumber = i + 1;
|
|
|
|
var dokuTab = $("#doku-name-" + idNumber);
|
|
|
|
dokuTab.val(dokuTypes[i].TypeDescription);
|
|
dokuTab.show();
|
|
|
|
var outerHeight = dokuTab.outerHeight();
|
|
|
|
if (outerHeight > height) {
|
|
height = outerHeight;
|
|
}
|
|
}
|
|
|
|
//$(".doku-tab-link").css("height", height + "px");
|
|
}
|
|
|
|
if (numberOfDocumentationTypes > 0) {
|
|
focusOnDoku(1);
|
|
}
|
|
},
|
|
null,
|
|
null
|
|
);
|
|
}
|
|
|
|
|
|
// Formulardaten im Browser speichern, um nach einem erneuten Laden der Seite (z.B. beim Hinzufügen von Hilfeplänen bzw. Gruppen oder Mitarbeitern) die Daten wiederherzustellen.
|
|
var savedEditFormValues = {};
|
|
|
|
$(document).on("change", ".edit-form-input",
|
|
function() {
|
|
saveFormValuesLocally();
|
|
});
|
|
|
|
function saveFormValuesLocally() {
|
|
var 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() {
|
|
var storageData = localStorage.savedEditFormValues;
|
|
|
|
if(storageData !== "undefined") {
|
|
savedEditFormValues = JSON.parse(storageData);
|
|
} else {
|
|
savedEditFormValues = {};
|
|
}
|
|
|
|
return savedEditFormValues.obj;
|
|
}
|
|
|
|
function loadSavedValuesIntoForm() {
|
|
var values = loadSavedEditFormValues();
|
|
|
|
if(values.category !== "undefined") {
|
|
$("#kategorien_select").val(values.category);
|
|
}
|
|
|
|
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);
|
|
}
|
|
|
|
if (values.serviceDescription !== "undefined") {
|
|
$("#leistungen_select").val(values.serviceDescription);
|
|
}
|
|
}
|