ordersprinter/kitchenbar.js

109 lines
3.4 KiB
JavaScript

function declareProductBeCookingOrCooked(queueid,action) {
var data = { queueid: queueid,
action : action};
doAjax("POST","php/contenthandler.php?module=queue&command=declareProductBeCookingOrCooked",data,resultOfProductDeclaration,"could not declare product");
}
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(entriesToCook) {
var aList = '';
$.each(entriesToCook, function (i, table) {
aList += listOfTable(table);
});
$("#listWithEntriesToCook").html(aList);
$("#listWithEntriesToCook").trigger("create");
$(".preparedlistitem").off("click").on("click", function (e) {
if ($(this).hasClass("cooking")) {
declareProductBeCookingOrCooked($(this).attr("id"),"r");
} else {
declareProductBeCookingOrCooked($(this).attr("id"),"c");
}
getAndDisplayAllEntries();
});
}
function listOfTable(table) {
var tableid = table.tableid;
var tablename = table.table;
var maxWaitTime = table.maxwaittime;
var aList = '<ul data-role="listview" id="' + tableid + '" data-divider-theme="a" data-inset="true">';
aList += '<li data-role="list-divider" data-theme="c" data-role="heading">' + tablename + ' (Max. Wartezeit: ' + maxWaitTime + ' min)</li>';
var itemsForTable = table.queueitems;
$.each(itemsForTable, function (i, entry) {
var option = '';
if (entry.option != '') {
option = '<p>' + entry.option + '</p>';
}
var theme = 'c';
var icon = "check";
var status = "not_cooking";
var label = entry.longname;
if (entry.cooking != '') {
theme ='d';
icon = "arrow-d";
status = "cooking";
label += "<small><i> (" + entry.cooking + ")</i></small>";
}
var img = '<img src="img/waittimes/' + entry.waiticon + '" />';
aList += '<li data-theme="' + theme + '" data-icon="' + icon + '" class="preparedlistitem ' + status + '" + id="'+ entry.id + '"><a href="#">' + img + label + option + '</a></li>';
});
aList += '</ul>';
return aList;
}
function fillTableWithCookedEntries(cookedEntries) {
var theList = '<ul data-role="listview" id="deliveredProdsList" data-divider-theme="a" data-inset="true">';
theList += '<li data-role="list-divider" data-theme="b" data-role="heading" data-icon="check">Zubereitet</li>';
$.each(cookedEntries, function (i, queueentry) {
var prodname = queueentry.longname;
var option = queueentry.option;
var readytime = queueentry.readytime;
var tablename = queueentry.tablename;
var infotext = tablename;
if (option != '') {
infotext = option + ' - ' + tablename;
}
var queue_entry_id = queueentry.id;
var tablename = queueentry.tablename;
theList += '<li data-theme="e" data-icon="arrow-u" id="' + queueentry.id + '" class="deliveredlistitem"><a href="#">' + prodname;
theList += '<p>' + infotext + '</p>';
theList += '</A></LI>';
});
theList += '</ul>';
$("#listWithCookedEntries").html(theList);
$("#listWithCookedEntries").trigger("create");
$(".deliveredlistitem").off("click").on("click", function (e) {
declareProductNOTBeCooked($(this).attr("id"));
getAndDisplayAllEntries();
});
}
function getAndDisplayAllEntries()
{
getEntriesToCook();
getCookedEntries();
}