function updateSubArticlesDiv() { let popupAreaDiv = document.getElementById("editPositionArea"); if (popupAreaDiv == null || popupAreaDiv.hidden || popupAreaDiv.style.display != "block") { return; } let extrasAreaDiv = document.getElementById("extrasArea"); if (extrasAreaDiv != null) { extrasAreaDiv.style.height = "auto"; const extrasAreaHeight = extrasAreaDiv.offsetHeight; const footerHeight = document.getElementsByTagName("footer")[0].offsetHeight; const headerDivHeight = document.getElementById("posHeader").offsetHeight + 5; const extrasHeaderDiv = document.getElementById("extrasHeader"); let extrasHeaderHeight = 0; if (extrasHeaderDiv != null) { extrasHeaderHeight = extrasHeaderDiv.offsetHeight + 5; } let marginHeight = 30 + 20; if (window.innerWidth < 950) { marginHeight = 0; } let maxHeight = window.innerHeight - marginHeight - headerDivHeight - extrasHeaderHeight - footerHeight; if (extrasAreaHeight > maxHeight) { extrasAreaDiv.style.height = "" + maxHeight + "px"; } } } function closePositionEditPopup() { currentOrderPosition = null; hideDiv("editPositionArea"); } function closeSalesHelpPopup() { currentOrderPosition = null; hideDiv("salesHelpArea"); abortAllSalesHelpItems(); } function deleteMenuPositionByPosId(paramPosId) { var formData = new FormData(); formData.append("command", "deleteMenuPosition"); formData.append("positionId", paramPosId); fetch("do", { method: "POST", body: new URLSearchParams(formData) }) .then(response => response.json()) .then(dataObj => updateOrderView(dataObj)) .catch(error => console.log("deleteMenuPositionByPosId() --> Fehler bei der Ausführung: " + error)); } function addExtrasToPosition(paramPosId) { if (currentOrderPosition == null) { console.log("addExtrasToPosition(): currentOrderPosition is null.") return; } var bookedExtras = []; for (let extraArtObj of currentOrderPosition.subExtrasPositions) { if (extraArtObj.count > 0) { let bookedExtraObj = {}; bookedExtraObj.articlePriceObjid = "" + extraArtObj.articlePriceObjid; bookedExtraObj.type = extraArtObj.type; bookedExtraObj.count = extraArtObj.count; bookedExtras.push(bookedExtraObj); } } var formData = new FormData(); formData.append("command", "addSubPositions"); formData.append("positionId", "" + paramPosId); formData.append("extras", JSON.stringify(bookedExtras)); fetch("do", { method: "POST", body: new URLSearchParams(formData) }).then(response => response.json()) .then(dataObj => { document.getElementById("editPositionArea").style.display = "none"; currentOrderPosition = null; updateOrderView(dataObj); }) .catch(error => console.log("addExtrasToPosition() --> Fehler bei fetch-Verarbeitung: " + error)); }