Intervallfinder überarbeitet & Bug gefixt, der zu einem Fehler beim Suchen nach freien Intervallen über mehrere Tage geführt hatte, wenn die Enduhrzeit vor der Startuhrzeit lag. Berichte mit Parametern. Verbesserte Mitarbeiter-, Klienten-, Team-, und Organisationsdropdowns mit Suche. Quittierungsbelegresultate (zum Unterschreiben) wird wie die Zeiterfassung paginiert. FaC: neuer Kalender noch nicht fertig.
494 lines
14 KiB
JavaScript
494 lines
14 KiB
JavaScript
function showSpinner() {
|
|
$("#mySpinner").modal(
|
|
{
|
|
backdrop: "static",
|
|
keyboard: false
|
|
}
|
|
);
|
|
}
|
|
|
|
function hideSpinner() {
|
|
$("#mySpinner").modal("hide");
|
|
$("#loading-info-p").text("Lade ...");
|
|
}
|
|
|
|
function showMessagePopup(title, message) {
|
|
$("#popupTitle").text(title);
|
|
|
|
if(message !== null) {
|
|
$("#modal-body").html("<p id=\"popupMessage\"></p>");
|
|
}
|
|
|
|
$("#popupMessage").text(message);
|
|
|
|
$("#messagePopup").modal(
|
|
{
|
|
backdrop: "static",
|
|
keyboard: false
|
|
}
|
|
);
|
|
}
|
|
|
|
function showMessagePopupWithHtml(title, messageAsHtml) {
|
|
$("#popupTitle").text(title);
|
|
|
|
$("#modal-body").html(messageAsHtml);
|
|
|
|
$("#message-popup-ok-btn").off("click");
|
|
|
|
$("#message-popup-ok-btn").on("click", function () {
|
|
$("#messagePopup").modal("hide");
|
|
});
|
|
|
|
$("#messagePopup").modal(
|
|
{
|
|
backdrop: "static",
|
|
keyboard: false
|
|
}
|
|
);
|
|
}
|
|
|
|
function showMessagePopupWithHtmlAndCallback(title, messageAsHtml, callback, executeCallbackByBothButtons) {
|
|
$("#popupTitle").text(title);
|
|
|
|
$("#modal-body").html(messageAsHtml);
|
|
|
|
$("#message-popup-ok-btn").off("click");
|
|
|
|
$("#message-popup-ok-btn").on("click", function () {
|
|
callback();
|
|
});
|
|
|
|
if(executeCallbackByBothButtons === true) {
|
|
$("#message-popup-close-btn, #message-popup-esc-btn").off("click");
|
|
$("#message-popup-close-btn, #message-popup-esc-btn").on("click",
|
|
function () {
|
|
callback();
|
|
});
|
|
}
|
|
|
|
$("#messagePopup").modal(
|
|
{
|
|
backdrop: "static",
|
|
keyboard: false
|
|
}
|
|
);
|
|
}
|
|
|
|
function showMessagePopupWithCallback(title, message, callback, executeCallbackByBothButtons) {
|
|
$("#popupTitle").text(title);
|
|
|
|
if (message !== null) {
|
|
$("#modal-body").html("<p id=\"popupMessage\"></p>");
|
|
}
|
|
|
|
$("#popupMessage").text(message);
|
|
|
|
$("#message-popup-ok-btn").off("click");
|
|
|
|
$("#message-popup-ok-btn").on("click", function() {
|
|
callback();
|
|
});
|
|
|
|
if(executeCallbackByBothButtons === true) {
|
|
$("#message-popup-close-btn, #message-popup-esc-btn").off("click");
|
|
$("#message-popup-close-btn, #message-popup-esc-btn").on("click",
|
|
function() {
|
|
callback();
|
|
});
|
|
}
|
|
|
|
$("#messagePopup").modal(
|
|
{
|
|
backdrop: "static",
|
|
keyboard: false
|
|
}
|
|
);
|
|
}
|
|
|
|
function submitForm(submitButton) {
|
|
if(hasEmptyRequiredFields($(submitButton.form))) {
|
|
return;
|
|
}
|
|
|
|
showSpinner();
|
|
submitButton.form.submit();
|
|
}
|
|
|
|
function hasEmptyRequiredFields(form) {
|
|
var count = 0;
|
|
|
|
form.each(function() {
|
|
var requiredElements = $(this, "input, textarea, select").find("[required]");
|
|
|
|
requiredElements.each(function(index, element) {
|
|
if ($(element).val().length === 0) {
|
|
count++;
|
|
}
|
|
});
|
|
});
|
|
|
|
return count > 0;
|
|
}
|
|
|
|
function showAboutPopup() {
|
|
// Auf deutsch?
|
|
var text = "SignaturePad:<br/>Copyright (c) 2018 Szymon Nowak<br/><br/>Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights<br/>to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:<br/>The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.<br/>THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.";
|
|
|
|
$("#message-popup-ok-btn").unbind();
|
|
$("#message-popup-close-btn").unbind();
|
|
|
|
$("#popupTitle").text("Copyrights");
|
|
|
|
$("#modal-body").html("<p id=\"popupMessage\"></p>");
|
|
|
|
$("#modal-body").html(text);
|
|
|
|
$("#messagePopup").modal(
|
|
{
|
|
backdrop: "static",
|
|
keyboard: false
|
|
}
|
|
);
|
|
}
|
|
|
|
function cloneCanvas(oldCanvas) {
|
|
var newCanvas = document.createElement("canvas");
|
|
var context = newCanvas.getContext("2d", {willReadFrequently: true});
|
|
|
|
newCanvas.width = oldCanvas.width;
|
|
newCanvas.height = oldCanvas.height;
|
|
|
|
context.drawImage(oldCanvas, 0, 0);
|
|
|
|
return newCanvas;
|
|
}
|
|
|
|
function showAlertMessageBoxWithoutCallback(title, message) {
|
|
$("#popupTitle").text(title);
|
|
|
|
$("#messagePopup .modal-body").html(`<div class="row"><div class="col-auto"><span class="fas fa-exclamation-triangle fa-3x text-danger"></span></div><div class="col">${message}</div></div>`);
|
|
|
|
$("#popupMessage").text(message);
|
|
|
|
$("#message-popup-ok-btn").off("click");
|
|
$("#message-popup-close-btn").off("click");
|
|
|
|
$("#messagePopup").modal(
|
|
{
|
|
backdrop: "static",
|
|
keyboard: false
|
|
}
|
|
);
|
|
}
|
|
|
|
function showAlertMessageBox(title, message, callback, executeCallbackByBothButtons) {
|
|
$("#popupTitle").text(title);
|
|
|
|
$("#messagePopup .modal-body").html(`<div class="row"><div class="col-auto"><span class="fas fa-exclamation-triangle fa-3x text-danger"></span></div><div class="col">${message}</div></div>`);
|
|
|
|
$("#popupMessage").text(message);
|
|
|
|
$("#message-popup-ok-btn").off("click");
|
|
$("#message-popup-ok-btn").on("click", function() {
|
|
callback();
|
|
});
|
|
|
|
$("#message-popup-close-btn").off("click");
|
|
|
|
if(executeCallbackByBothButtons === true) {
|
|
$("#message-popup-close-btn").on("click", function() {
|
|
callback();
|
|
});
|
|
}
|
|
|
|
$("#messagePopup").modal(
|
|
{
|
|
backdrop: "static",
|
|
keyboard: false
|
|
}
|
|
);
|
|
}
|
|
|
|
function showWarningMessageBox(title, message, callback, executeCallbackByBothButtons) {
|
|
$("#popupTitle").text(title);
|
|
|
|
$("#messagePopup .modal-body").html(`<div class="row"><div class="col-auto"><span class="fas fa-exclamation-triangle fa-3x text-warning"></span></div><div class="col">${message}</div></div>`);
|
|
|
|
$("#popupMessage").text(message);
|
|
|
|
$("#message-popup-ok-btn").off("click");
|
|
$("#message-popup-ok-btn").on("click", callback);
|
|
|
|
if(executeCallbackByBothButtons === true) {
|
|
$("#message-popup-close-btn").off("click");
|
|
$("#message-popup-close-btn").on("click", callback);
|
|
}
|
|
|
|
$("#messagePopup").modal(
|
|
{
|
|
backdrop: "static",
|
|
keyboard: false
|
|
}
|
|
);
|
|
}
|
|
|
|
function isUndefinedOrNull(obj) {
|
|
return obj == null;
|
|
}
|
|
|
|
function areUndefinedOrNull(array) {
|
|
if (array == null) {
|
|
return true;
|
|
}
|
|
|
|
if (!Array.isArray(array)) {
|
|
return true;
|
|
}
|
|
|
|
for (var i = 0; i < array.length; i++) {
|
|
if(array[i] != null) {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
function cardHeaderClick(chevronId, cardBodyId) {
|
|
try {
|
|
$(cardBodyId).toggle();
|
|
|
|
toggleChevron(chevronId, cardBodyId);
|
|
}
|
|
catch(error) {
|
|
showErrorPopup(error);
|
|
}
|
|
}
|
|
|
|
function cardHeaderClick2(element, callback) {
|
|
try {
|
|
if(element === undefined || element === null) {
|
|
console.logWarning("element is undefined or null!");
|
|
return;
|
|
}
|
|
|
|
var chevronDown = $(element).find(".fa-chevron-down");
|
|
var chevronUp = $(element).find(".fa-chevron-up");
|
|
|
|
chevronDown.removeClass("fa-chevron-down").addClass("fa-chevron-up");
|
|
|
|
chevronUp.removeClass("fa-chevron-up").addClass("fa-chevron-down");
|
|
|
|
$(element).next(".collapse").toggle();
|
|
|
|
if(typeof callback === "function") {
|
|
callback();
|
|
}
|
|
} catch (error) {
|
|
showErrorPopup(error);
|
|
}
|
|
}
|
|
|
|
|
|
// Muss manuell im onclick-Event des Buttons aufgerufen werden
|
|
function cardHeaderButtonClick(cardBodyId) {
|
|
try {
|
|
$(cardBodyId).toggle();
|
|
}
|
|
catch(error) {
|
|
showErrorPopup(error);
|
|
}
|
|
}
|
|
|
|
// ToDo: Hier am 21.08.2023 weitermachen!
|
|
function toggleChevron(chevronId, cardBodyId) {
|
|
try {
|
|
var isDown = $(cardBodyId).css("display") !== "none";
|
|
var chevron = $(chevronId);
|
|
var iconToRemove = isDown ? "fa-chevron-down" : "fa-chevron-up";
|
|
var iconToAdd = isDown ? "fa-chevron-up" : "fa-chevron-down";
|
|
|
|
chevron.removeClass(iconToRemove);
|
|
chevron.addClass(iconToAdd);
|
|
} catch (error) {
|
|
showErrorPopup(error);
|
|
}
|
|
}
|
|
|
|
function validateNonEmptyString(stringValue) {
|
|
return !isUndefinedOrNull(stringValue) && !isEmptyOrSpaces(stringValue) && typeof stringValue === "string";
|
|
}
|
|
|
|
function showCollapsable(collapsableElement) {
|
|
try {
|
|
if (collapsableElement === null || collapsableElement === undefined) {
|
|
return;
|
|
}
|
|
|
|
if (!collapsableElement.hasClass("show")) {
|
|
collapsableElement.addClass("show");
|
|
}
|
|
} catch (error) {
|
|
showErrorPopup(error);
|
|
}
|
|
}
|
|
|
|
function hideCollapsable(collapsableElement) {
|
|
try {
|
|
if (collapsableElement === null || collapsableElement === undefined) {
|
|
return;
|
|
}
|
|
|
|
if (collapsableElement.hasClass("show")) {
|
|
collapsableElement.removeClass("show");
|
|
}
|
|
} catch (error) {
|
|
showErrorPopup(error);
|
|
}
|
|
}
|
|
|
|
function treeSearchOnChange(searchInputId, textClass, cardClass, nameLabelClass, itemListClass) {
|
|
try {
|
|
var text = $("#" + searchInputId).val().toLowerCase();
|
|
|
|
var entries = $("." + textClass);
|
|
|
|
if(text.length === 0 || !text.replace(/\s\g/, '').length) {
|
|
resetTreeSearch(searchInputId, textClass, cardClass);
|
|
return;
|
|
}
|
|
|
|
$.each(entries, function (index, entry) {
|
|
var checkbox = $(entry);
|
|
var treeCard = checkbox.closest("." + cardClass);
|
|
var header = treeCard.find(".tree-card-header");
|
|
var list = treeCard.find(".collapse");
|
|
var treeItemName = checkbox.find("." + nameLabelClass).text().toLowerCase();
|
|
var includesText = treeItemName.includes(text) || header.html().toLowerCase().includes(text);
|
|
|
|
if (includesText) {
|
|
checkbox.show();
|
|
treeCard.show();
|
|
showCollapsable($(list));
|
|
} else {
|
|
checkbox.hide();
|
|
}
|
|
});
|
|
|
|
var lists = $("." + itemListClass);
|
|
|
|
var cardsToHide = [];
|
|
|
|
$.each(lists, function (index, item) {
|
|
var children = $(item).children();
|
|
var hasAtLeastOneVisibleChild = false;
|
|
var card = $(item).parent().parent();
|
|
|
|
for(var i = 0; i < children.length; i++) {
|
|
var child = children[i];
|
|
|
|
hasAtLeastOneVisibleChild = $(child).css("display") === "block";
|
|
|
|
if(hasAtLeastOneVisibleChild === true) {
|
|
break;
|
|
}
|
|
}
|
|
|
|
if(hasAtLeastOneVisibleChild === false) {
|
|
cardsToHide.push(card);
|
|
}
|
|
});
|
|
|
|
$.each(cardsToHide, function (index, item) {
|
|
$(item).hide();
|
|
});
|
|
} catch (error) {
|
|
showErrorPopup(error);
|
|
}
|
|
}
|
|
|
|
function resetTreeSearch(searchInputId, textClass, cardClass) {
|
|
try {
|
|
$("#" + searchInputId).val("");
|
|
|
|
var entries = $("." + textClass);
|
|
var treeCard = $("." + cardClass);
|
|
var collapsable = treeCard.find(".collapse");
|
|
|
|
entries.show();
|
|
treeCard.show();
|
|
|
|
hideCollapsable(collapsable);
|
|
} catch (error) {
|
|
showErrorPopup(error);
|
|
}
|
|
}
|
|
|
|
function showMessagePopupWithHtmlAndCallback(title, messageAsHtml, hasCloseButton, callback, executeCallbackByBothButtons) {
|
|
$("#popupTitle").text(title);
|
|
|
|
if (messageAsHtml !== null) {
|
|
$("#modal-body").html("<p id=\"popupMessage\"></p>");
|
|
}
|
|
|
|
$("#popupMessage").html(messageAsHtml);
|
|
|
|
$("#message-popup-ok-btn").off("click");
|
|
|
|
if(typeof callback === "function") {
|
|
$("#message-popup-ok-btn").on("click", function () {
|
|
callback();
|
|
});
|
|
}
|
|
|
|
if (hasCloseButton === false) {
|
|
$("#message-popup-close-btn").hide();
|
|
} else {
|
|
$("#message-popup-close-btn").show();
|
|
}
|
|
|
|
if(executeCallbackByBothButtons === true && typeof callback === "function") {
|
|
$("#message-popup-close-btn, #message-popup-esc-btn").off("click");
|
|
$("#message-popup-close-btn, #message-popup-esc-btn").on("click",
|
|
function () {
|
|
callback();
|
|
});
|
|
}
|
|
|
|
$("#messagePopup").modal(
|
|
{
|
|
backdrop: "static",
|
|
keyboard: false
|
|
}
|
|
);
|
|
}
|
|
|
|
function stringContainsDoctype(strValue) {
|
|
return strValue !== undefined && strValue !== null && (typeof strValue === "string" || strValue instanceof String) && strValue.length > 0 && strValue.includes("DOCTYPE");
|
|
}
|
|
|
|
function parseJason(jsonToParse) {
|
|
try {
|
|
return $.parseJSON(jsonToParse);
|
|
} catch (error) {
|
|
if(stringContainsDoctype(jsonToParse)) {
|
|
showErrorPopup(error, jsonToParse);
|
|
} else {
|
|
showErrorPopup(error);
|
|
}
|
|
}
|
|
}
|
|
|
|
function getCurrentTimeStamp() {
|
|
var now = new Date(Date.now());
|
|
|
|
var date = String(2).padStart(2, now.getDate().toString());
|
|
var month = String(2).padStart(2, now.getMonth().toString());
|
|
var hours = String(2).padStart(2, now.getHours().toString());
|
|
var minutes = String(2).padStart(2, now.getMinutes().toString());
|
|
var seconds = String(2).padStart(2, now.getSeconds().toString());
|
|
var milliseconds = String(3).padStart(3, now.getMilliseconds().toString());
|
|
|
|
return `${date}.${month}.${now.getFullYear()} ${hours}:${minutes}:${seconds}.${milliseconds}`;
|
|
} |