var KB_READY = ["Zubereitet","Ready","Preparado"]; var KB_MAX_WAIT = ["Max. Wartezeit: ","Max. waited: ","Tiempo de espera: "]; var KB_TO_MAKE = ["Herzustellen","To prepare","Para preparar"]; var KB_TO_FINISHED = ["Fertig","Ready to serve","Completo"]; var KB_TABLE = ["Tisch","Table","Mesa"]; // user has rights (default: no) var isInitialized = false; var displayWorkToDo = false; var displayFinished = false; var displayHeaderFooter = false; var cookedEntries = null; var entriesToCook = null; var user = ""; // increase performance by calling AJAX a bit later as a thread function declareProductBeCookingOrCooked(queueid,action) { window.setTimeout(function(){declareProductBeCookingOrCooked_orig(queueid,action)},100); } function declareProductBeCookingOrCooked_orig(queueid,action) { var data = { queueid: queueid, action : action}; doAjax("POST","php/contenthandler.php?module=queue&command=declareProductBeCookingOrCooked",data,resultOfProductDeclaration,"could not declare product",false); } function resultOfProductDeclaration(jsonText) { if (jsonText.status != "OK") { alert("Fehler " + jsonText.code + ": " + jsonText.msg); } } function declareProductNOTBeCooked(queueid) { var data = { queueid: queueid }; doAjax("POST","php/contenthandler.php?module=queue&command=declareProductNotBeCooked",data,resultOfProductDeclaration,"could not unmake product"); } function fillTableWithEntriesToCook(allEntriesToCook) { entriesToCook = allEntriesToCook; fillTableWithEntriesToCookCore(); bindEntriesToCook(); } function removeOrRedeclareAnIdFromPrepared(theId,doRemove) { $.each(entriesToCook, function (j, table) { var aList = table.queueitems; var tablename = table.table; // now remove this from the list or change entry! var i=0; var found = false; for (i=0;i'; } var icon = "check"; var status = "not_cooking"; var label = toHtml(entry.longname); if (entry.cooking != '') { theme ='d'; status = "cooking"; label += " (" + entry.cooking + ")"; } var extratxt = createExtraParagraph(entry.extras); var entryToAdd = { name: label + extratxt, cooking: entry.cooking, queueid: entry.id, option: option, waiticon: entry.waiticon }; var setLength = qset.length; qset[setLength] = entryToAdd; }); var grouped = groupItemToMake(qset); // now format these entries var aList = ''; return aList; } function fillTableWithCookedEntries(entries) { cookedEntries = entries; fillTableWithCookedEntriesCore(); bindCookedEntries(); } function bindCookedEntries() { $(".deliveredlistitem").off("click").on("click", function (e) { var idlist = this.id; var idarr = idlist.split("_"); var firstid = idarr[0]; // this is the id to handle! declareProductNOTBeCooked(firstid); getAndDisplayAllEntries(); }); } function fillTableWithCookedEntriesCore() { if ((cookedEntries != null) && (cookedEntries.length > 0)) { var qset = []; $.each(cookedEntries, function (i, entry) { var option = ''; if (entry.option != '') { var theComment = toHtml(entry.option); option = '

' + theComment + '

'; } var label = toHtml(entry.longname); var extratxt = createExtraParagraph(entry.extras); var table = entry.tablename; var entryToAdd = { name: label + extratxt, queueid: entry.id, option: option, extras: extratxt, table: table }; var setLength = qset.length; qset[setLength] = entryToAdd; }); var grouped = groupMadeItems(qset); var theList = ''; $("#listWithCookedEntries").html(theList); $("#listWithCookedEntries").trigger("create"); } else { // remove also headline of list, if list is empty $("#listWithCookedEntries").html(""); } } function handleGlobalRefresh(name) { parent.frames[name].location.reload(); getAndDisplayAllEntries(); } function getAndDisplayAllEntries() { checkForLogIn(); if (isInitialized) { if (displayWorkToDo) { getEntriesToCook(); } if (displayFinished) { getCookedEntries(); } } } function getGeneralConfigItems() { doAjax("GET", "php/contenthandler.php?module=admin&command=getGeneralConfigItems", null, insertGeneralConfigItems, "Fehler Konfigurationsdaten"); doAjax("GET","php/contenthandler.php?module=admin&command=getJsonMenuItemsAndVersion",null,setUser,"Benutzerdaten nicht übermittelt"); } function setUser(userAndVersion) { user = userAndVersion.user; } function insertGeneralConfigItems(configResult) { if (configResult.status == "OK") { var values = configResult.msg; setLanguage(values.userlanguage); isInitialized = true; if (displayHeaderFooter) { initializeMainMenu("#modulemenu"); } else { $("#modulepanel").hide(); $("#menuswitch").hide(); $("#thefooterr").hide(); } initializeEverything(); setHeadlines(); getAndDisplayAllEntries(); } else { setTimeout(function(){document.location.href = "index.html"},250); // not logged in //alert("Fehler beim Aufruf der Seite: " + configResult.msg); } } function setWorkMode(urlsuffix) { displayWorkToDo = true; displayFinished = true; displayHeaderFooter = true; return; } /** * Not possible in setWorkMode, because set Lang would overwrite. * So set headlines in method that can be called later */ function setHeadlines() { if (!displayHeaderFooter) { // then replace by individual footer (embedded in iframe) if (displayWorkToDo) { $("#moduleheadline").html(KB_TO_MAKE[lang]); } else if (displayFinished) { $("#moduleheadline").html(KB_TO_FINISHED[lang]); } $("#headerline").trigger("create"); } } function groupMadeItems(theSet) { var counts = []; var joinedvals = []; var names = []; var options = []; var extras = []; var tables = []; var queueids = []; var grouped = { counts:counts, joinedvals : joinedvals, names: names, options: options, extras: extras, tables: tables, queueids : queueids }; var i=0; for (i=0;i= 0) { // element is already in group grouped.counts[index] = grouped.counts[index] + 1; var queueidsarr = grouped.queueids[index]; // append the current queueid queueidsarr[queueidsarr.length] = queueid; grouped.queueids[index] = queueidsarr; } else { // new element to be inserted in grouped var gLength = grouped.counts.length; grouped.counts[gLength] = 1; grouped.joinedvals[gLength] = joinedNeedle; grouped.names[gLength] = name; grouped.options[gLength] = option; grouped.extras[gLength] = extras; grouped.tables[gLength] = table; grouped.queueids[gLength] = [queueid]; } } return grouped; } function groupItemToMake(theSet) { var counts = []; var joinedvals = []; var names = []; var options = []; var cookings = []; var waiticons = []; var queueids = []; var grouped = { counts:counts, joinedvals : joinedvals, names: names, options: options, cookings: cookings, waiticons: waiticons, queueids : queueids }; var i=0; for (i=0;i= 0) { // element is already in group grouped.counts[index] = grouped.counts[index] + 1; var queueidsarr = grouped.queueids[index]; // append the current queueid queueidsarr[queueidsarr.length] = queueid; grouped.queueids[index] = queueidsarr; } else { // new element to be inserted in grouped var gLength = grouped.counts.length; grouped.counts[gLength] = 1; grouped.joinedvals[gLength] = joinedNeedle; grouped.names[gLength] = name; grouped.options[gLength] = option; grouped.cookings[gLength] = cooking; grouped.waiticons[gLength] = waiticon; grouped.queueids[gLength] = [queueid]; } } return grouped; }