1418 lines
48 KiB
HTML
1418 lines
48 KiB
HTML
<html>
|
||
<head>
|
||
<title>Ansicht Kasse</title>
|
||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||
<meta http-equiv="content-type" content="text/html; charset=utf-8">
|
||
<meta name="author" content="Stefan Pichel">
|
||
|
||
<link rel="stylesheet" type="text/css" href="css/bestformat.css?v=1.1.12">
|
||
<link rel="stylesheet" href="php/3rdparty/orderstyle/orderstyle.min.css" />
|
||
<link rel="stylesheet" href="php/3rdparty/orderstyle/jquery.mobile.icons.min.css" />
|
||
|
||
<link rel="stylesheet" href="php/3rdparty/jquery.mobile-1.4.0.min.css" type="text/css" />
|
||
<script src="php/3rdparty/jquery-2.0.3.min.js"></script>
|
||
<script src="php/3rdparty/jquery.mobile-1.4.0.min.js"></script>
|
||
<script src="utilities.js"></script>
|
||
<script src="receiptutils.js"></script>
|
||
<script src="elements/tablemap.js"></script>
|
||
<script src="elements/localprint.js"></script>
|
||
<script src="elements/grouping.js"></script>
|
||
</head>
|
||
|
||
<body>
|
||
|
||
<style>
|
||
@media screen
|
||
{
|
||
.receipttable {width: 70%; background-color: #cccccc;}
|
||
}
|
||
@media print
|
||
{
|
||
.receipttable,#partToPrint {width: 100%;};
|
||
}
|
||
@media print
|
||
{
|
||
#thefooter,#theheader,#modulemenu,#oben,#untenarea,#payWithoutPrint,#paybuttongroup,#hostbuttongroup {display: none;}
|
||
}
|
||
</style>
|
||
|
||
<script>
|
||
|
||
// for the receipt
|
||
|
||
var P_DESCR = ["Beschreibung","Description","Descripción"];
|
||
|
||
var P_PRICE = ["Preis","Price","Precio"];
|
||
var P_TOTAL = ["Total","Total","Total"];
|
||
|
||
var P_ID = ["Id:","Id:","Id:"];
|
||
|
||
|
||
// for the UI
|
||
var P_ROOMSEL = ["Raumauswahl","Room selection","Selección de espacio"];
|
||
var P_PAYDESK_ACTIONS = ["Kassenaktionen","Paydesk actions","Acciones de caja"];
|
||
var P_BAR_INPUT = ["Bareinlage","Input money","Insertar dinero"];
|
||
var P_BAR_GET = ["Barentnahme","Take money","Sacar dinero"];
|
||
var P_BAR_SUM = ["Einnahmen","Revenue","Cobro"];
|
||
var P_TITLE = ["Kasse","Paydesk","Caja"];
|
||
var P_TABLE = ["Tisch","Table","Mesa"];
|
||
var P_TABLE_SEL = ["Tischauswahl","Select table","Qué mesa?"];
|
||
var P_NOT_PAID = ["Ausstehend für ","Not paid for ","Impagado para "];
|
||
var P_ALL = ["Alles","All","Todo"];
|
||
var P_CONTENT_RECEIPT = ["Inhalt Kassenbon","Content of receipt","Contenido del tique"];
|
||
var P_ONLY_PAY = ["Nur Zahlung","Only pay","Solo pagar"];
|
||
var P_PAY_PRINT = ["Bondruck","Pay+Print","Pagar+Imprimir"];
|
||
var P_PAYWAY = ["Zahlungsart","Payment type","Modo de pago"];
|
||
var P_CHOOSE_PAYWAY = ["Auswahl der Zahlungsart","Selection of method of payment","Selección del modo de pago"];
|
||
var P_CANCEL = ["Abbrechen","Cancel","Cancelar"];
|
||
var P_CASHTAKEOUT = ["Barentnahme aus der Kasse","Cash take-out","Sacar dinero"];
|
||
var P_CASHTAKIN = ["Bareinlage in die Kasse","Cash insert","Insertar dinero"];
|
||
var P_AMOUNT = ["Betrag:","Amount:","Valor:"];
|
||
var P_OVERVIEW = ["Übersicht Kellnerkasse", "Overview waiter purse","Resumen cartera de bolsillo"];
|
||
var P_PUT_IN = ["Einlegen","Insert","Insertar"];
|
||
var P_TAKE_OUT = ["Entnehmen","Take out","Sacar"];
|
||
|
||
var P_OVERV_DETAILS = ["Diese Übersicht enthält die Bar-Bewirtungseinnahme durch den Kellner seit der letzten Tageslosung sowie als weiteren Wert den Kassenstand unter Berücksichtigung der eigenen Eingaben und Entnahmen.",
|
||
"This overview contains the cash amount of money of this waiter since the last closing as well as the total amount of money including the own cash insert and take-out actions.",
|
||
"Este resumen contiene todo el dinero al contado por cobro para el camarero, y también el dinero incluido con acciones de insertar y sacar."];
|
||
var P_CASH_SUM = ["Bewirtungseinnahmen:","Cash by payment:", "Cobro:"];
|
||
var P_INCLUDE_OWN = ["inkl. eigener Kassen-Eingaben/Entnahmen:","incl. own cash insert/take-outs:","incl. tomas y entradas proprias:"];
|
||
|
||
var P_NO_ELEM = ["Keine Rechnungselemente","No items selected","Ningún producto selecionado"];
|
||
var P_NO_ELEM_DETAILS = ["Es wurden keine abrechenbaren Produkte festgelegt (der Bon ist leer!).",
|
||
"There are no selected items. The receipt is empty!",
|
||
"No hay ningún elemento seleccionado para pagar."];
|
||
var P_CASHACTION_OK = ["Kassenaktion abgeschlossen.","Action completed.","Acción terminado."];
|
||
var P_NAV = ["Navigation","Navigation","Navigación"];
|
||
var P_ORDER_ACTION = ["-> Bestellansicht","-> Order view", "-> Vista de Orden"];
|
||
var P_TO_PAY = ["Zu zahlen: ","To pay: ", "Pagar total: "];
|
||
var P_PAY_RETURN = ["Zurück: ", "Return: ","Torna: "];
|
||
var P_CALC_PAYBACK = ["Berechne","Calculate","Calcular"];
|
||
var P_HAS_PAID = ["Bezahlt: ","Paid: ","Pagado: "];
|
||
var P_TOGO = ["Außer-Haus-Verkauf","Sale with Tax No 2","Venta IVA 2"];
|
||
|
||
var lang = 0;
|
||
var receiptfontsize = 12;
|
||
var paymentconfig = 0;
|
||
|
||
var decpoint = '.';
|
||
var currency = '';
|
||
|
||
var osroombtnsize = 0;
|
||
var ostablebtnsize = 0;
|
||
var osprodbtnsize = 0;
|
||
|
||
// REM* info for each room about the availability of a graphical map, and about the positions
|
||
var tminfo = null;
|
||
|
||
// REM* are there several rooms or only a table selection?
|
||
var hasRooms = true;
|
||
|
||
// REM* if the waiter has pressed the paydesk button after ordering the payment shall also delete the
|
||
// REM* the orders from the undelivered list in the order view. Otherwise waiters forever see the products
|
||
// REM* in case they never want to print work receipts or send to digital workflow.
|
||
var cameFromOrdering = 0;
|
||
|
||
// REM* this are the values that shall be send to server as brutto value
|
||
var billbrutto = 0.0;
|
||
var billnetto = 0.0;
|
||
|
||
// REM* info about items to pay and the table - after products are retrieved for table
|
||
// REM* this is the list of items, including double entries:
|
||
var prodsToPayList = [];
|
||
// REM* this is the list that is grouped of all items in the "oben" list, i.e. still not on the receipt
|
||
var prodsToPayListGrouping = [];
|
||
// REM* this is the tablename that shall appear on the receipt and on the lists
|
||
var payTable = "";
|
||
//REM* this is the list of items, including double entries, of all entries already marked as being on the receipt
|
||
var prodsOnReceiptList = [];
|
||
// REM* this is the list that is grouped of all items in the "unten" list, i.e. on the receipt
|
||
var prodsOnReceiptListGrouping = [];
|
||
|
||
function getGeneralConfigItems() {
|
||
doAjax("GET", "php/contenthandler.php?module=admin&command=getGeneralConfigItems", null, insertGeneralConfigItems, "Fehler Konfigurationsdaten");
|
||
}
|
||
|
||
function getPayments() {
|
||
doAjax("GET", "php/contenthandler.php?module=admin&command=getPayments", null, insertPayments, "Fehler Zahlungswege");
|
||
}
|
||
|
||
function insertGeneralConfigItems(configResult) {
|
||
if (configResult.status == "OK") {
|
||
var values = configResult.msg;
|
||
|
||
decpoint = values.decpoint;
|
||
$("#info-page").data("decpoint",values.decpoint);
|
||
currency = values.currency;
|
||
var taxval = values.tax;
|
||
var usstGerVal = taxval.replace(".", decpoint);
|
||
$("#info-page").data("usstGerVal",usstGerVal);
|
||
$("#info-page").data("usst",taxval);
|
||
|
||
taxval = values.togotax;
|
||
usstGerVal = taxval.replace(".", decpoint);
|
||
$("#info-page").data("togoTaxGerVal",usstGerVal);
|
||
$("#info-page").data("togotax",taxval);
|
||
|
||
$("#info-page").data("companyinfo",values.companyinfo);
|
||
$("#info-page").data("payPrintType",values.payprinttype);
|
||
$("#info-page").data("currency",values.currency);
|
||
$("#info-page").data("billlanguage",values.billlanguage);
|
||
$("#info-page").data("userlanguage",values.userlanguage);
|
||
receiptfontsize = parseInt(values.receiptfontsize);
|
||
|
||
$("#receiptpart").css("font-size",receiptfontsize + "px");
|
||
paymentconfig = values.paymentconfig;
|
||
|
||
$("#curtopay").html(" " + values.currency);
|
||
$("#curtopay2").html(" " + values.currency);
|
||
|
||
setLanguage(values.userlanguage);
|
||
} else {
|
||
$("#contentpart").hide();
|
||
setTimeout(function(){document.location.href = "index.html"},250); // not logged in
|
||
//alert("Fehler beim Aufruf der Seite: " + configResult.msg);
|
||
}
|
||
}
|
||
|
||
function setLanguage(language) {
|
||
$("#roomsel").html(P_ROOMSEL[language]);
|
||
$("#oben").listview("refresh");
|
||
lang = language;
|
||
|
||
var html= '<li data-role="list-divider" data-theme="b" data-role="heading">' + P_PAYDESK_ACTIONS[lang] + '</li>'
|
||
+ '<li data-theme="e"><a href="#" id="cashinsert" class="info-go cashaction">' + P_BAR_INPUT[lang] + '</a></li>'
|
||
+ '<li data-theme="e"><a href="#" id="cashtakeout" class="info-go cashaction">' + P_BAR_GET[lang] + '</a></li>'
|
||
+ '<li data-theme="e"><a href="#" id="cashoverview" class="info-go cashaction">' + P_BAR_SUM[lang] + '</a></li>';
|
||
|
||
$("#cashactions").html(html);
|
||
$("#cashactions").listview("refresh");
|
||
|
||
$("#navtitle").html(P_NAV[lang]);
|
||
$("#nav2order").html(P_ORDER_ACTION[lang]);
|
||
$("#navactions").listview("refresh");
|
||
|
||
$("#paydesktitle").html(P_TITLE[lang]);
|
||
|
||
$("#OnlyPayTxt").html(P_ONLY_PAY[lang]);
|
||
$("#payprinttxt").html(P_PAY_PRINT[lang]);
|
||
|
||
$("#payway").html(P_PAYWAY[lang]);
|
||
|
||
$("#choosepayway").html(P_CHOOSE_PAYWAY[lang]);
|
||
$("#canceltxt").html(P_CANCEL[lang]);
|
||
|
||
$("#cashtakeouttxt").html(P_CASHTAKEOUT[lang]);
|
||
$("#amounttxt").html(P_AMOUNT[lang]);
|
||
$("#amounttxt2").html(P_AMOUNT[lang]);
|
||
$("#cashtakeintxt").html(P_CASHTAKIN[lang]);
|
||
|
||
$("#cashoverviewtxt").html(P_OVERVIEW[lang]);
|
||
|
||
$("#putinact").html(P_PUT_IN[lang]);
|
||
$("#takeoutact").html(P_TAKE_OUT[lang]);
|
||
|
||
$("#overviewdetails").html(P_OVERV_DETAILS[lang]);
|
||
$("#cashsum").html(P_CASH_SUM[lang]);
|
||
$("#includeowncash").html(P_INCLUDE_OWN[lang]);
|
||
|
||
$("#noelementstxt").html(P_NO_ELEM[lang]);
|
||
$("#noelementsdetailstxt").html(P_NO_ELEM_DETAILS[lang]);
|
||
$("#topaytxt").html(P_TO_PAY[lang]);
|
||
$("#rettxt").html(P_PAY_RETURN[lang]);
|
||
$("#calcreturn").html(P_CALC_PAYBACK[lang]);
|
||
$("#haspaidtxt").html(P_HAS_PAID[lang]);
|
||
$("#tableselimmaptxt").html(P_TABLE_SEL[lang]);
|
||
}
|
||
|
||
function getButtonSizes() {
|
||
doAjax("GET","php/contenthandler.php?module=admin&command=getButtonSizes",null,fillButtonSizes,"Keine Buttongroesseninformation");
|
||
}
|
||
|
||
function fillButtonSizes(buttonsizes) {
|
||
osroombtnsize = buttonsizes.roombtnsize;
|
||
ostablebtnsize = buttonsizes.tablebtnsize;
|
||
osprodbtnsize = buttonsizes.prodbtnsize;
|
||
}
|
||
|
||
function getProdSizeClass() {
|
||
if (osprodbtnsize == 1) {
|
||
return("osprod-1");
|
||
} else if (osprodbtnsize == 2) {
|
||
return("osprod-2");
|
||
} else {
|
||
return "";
|
||
}
|
||
}
|
||
|
||
function getTableSizeClass() {
|
||
if (ostablebtnsize == 1) {
|
||
return("ostable-1");
|
||
} else if (ostablebtnsize == 2) {
|
||
return("ostable-2");
|
||
} else {
|
||
return "";
|
||
}
|
||
}
|
||
|
||
function getRoomSizeClass() {
|
||
if (osroombtnsize == 1) {
|
||
return("osroom-1");
|
||
} else if (osroombtnsize == 2) {
|
||
return("osroom-2");
|
||
} else {
|
||
return "";
|
||
}
|
||
}
|
||
|
||
function insertPayments(payments) {
|
||
var paymentList = "";
|
||
var max=20;
|
||
if (paymentconfig == 1) {
|
||
// small selection
|
||
max=2;
|
||
}
|
||
var sepAfterFirstPayment = false;
|
||
$.each(payments, function (i,payType) {
|
||
if (i<max) {
|
||
paymentList += '<a href="#" class="sure-do" data-role="button" data-theme="f" data-rel="back" id="paym_' + payType.id + '">' + payType.name + '</a>';
|
||
if (!sepAfterFirstPayment) {
|
||
paymentList += '<br><hr><br>';
|
||
sepAfterFirstPayment = true;
|
||
}
|
||
}
|
||
});
|
||
paymentList += '<a href="#" data-role="button" data-theme="d" data-rel="back" id="paym_cancel">' + P_CANCEL[lang] + '</a>';
|
||
$("#paymentlist").html(paymentList);
|
||
}
|
||
|
||
function hideReceiptPart() {
|
||
$("#payWithoutPrint").hide();
|
||
$("#payWithPrint").hide();
|
||
$("#hostbutton").hide();
|
||
$("#unten").hide();
|
||
}
|
||
function showReceiptPart() {
|
||
$("#payWithoutPrint").show();
|
||
$("#payWithPrint").show();
|
||
$("#hostbutton").show();
|
||
$("#unten").show();
|
||
$("#tablemapcontent").hide();
|
||
$("#togoarea").hide();
|
||
}
|
||
|
||
function getTableMapPreferences() {
|
||
doAjax("GET","php/tablemap.php?command=getTableMapPreferences",null,insertTMInfo,"Keine TM-Information");
|
||
}
|
||
function insertTMInfo(jsonTminfo) {
|
||
tminfo = jsonTminfo;
|
||
startDisplayProcess();
|
||
}
|
||
|
||
function shallDisplayRoom(roomid) {
|
||
for (var i=0;i<tminfo.length;i++) {
|
||
if (tminfo[i].roomid == roomid) {
|
||
return {show:tminfo[i].displaymap == 1 ? true : false,pos:tminfo[i].tablepositions};
|
||
}
|
||
}
|
||
return {show:false};
|
||
}
|
||
|
||
function handleClickInTablemap(data) {
|
||
checkForLogIn();
|
||
$("#info-page").data("roomid",null);
|
||
$("#info-page").data("tableviewactive",0);
|
||
$("#info-page").data("tid",data.tableid);
|
||
$("#info-page").data("tablename",data.tablename);
|
||
$("#oben").show();
|
||
getProdsToPayForTable(data.tableid,data.tablename);
|
||
}
|
||
|
||
function displayAllRooms() {
|
||
checkForLogIn();
|
||
$("#moneyToInsert").val("");
|
||
$("#moneyToTakeOut").val("");
|
||
$("#cashactions").show();
|
||
$("#navactions").show();
|
||
|
||
hideReceiptPart();
|
||
|
||
var lang = $("#info-page").data("billlanguage");
|
||
|
||
// first empty receipt
|
||
|
||
$("#prodlistinreceipt").empty().append('<td id="receiptprodheader" class="price">' + P_NO[lang] + '<td>' + P_DESCR[lang] + '<td class="price">' + P_PRICE[lang] + '<td class="price">' + P_TOTAL[lang]);
|
||
|
||
$.getJSON("php/contenthandler.php?module=roomtables&command=getRooms",function(allroomtables) {
|
||
var roomtableinfo = allroomtables.roomstables;
|
||
var takeAwayPrice = allroomtables.takeawayprice;
|
||
|
||
var noOfRooms = roomtableinfo.length;
|
||
|
||
if (noOfRooms == 1) {
|
||
$("#info-page").data("roomid",roomtableinfo[0]["id"]);
|
||
displayTablesOfRoom(roomtableinfo[0],false);
|
||
|
||
if (cameFromOrdering == 1) {
|
||
// REM* TODO: display back button! -> shall go back to waiter!
|
||
$("#startpaypage").show();
|
||
} else {
|
||
// REM* TODO hide back button
|
||
$("#startpaypage").hide();
|
||
}
|
||
} else {
|
||
|
||
var li = "";
|
||
var size = getRoomSizeClass();
|
||
$.each(roomtableinfo, function (i, name) {
|
||
li += '<li data-theme="f"><a href="#" id="' + i + '" class="info-go ' + size + '">' + name.name + '</a></li>';
|
||
});
|
||
|
||
if (takeAwayPrice != '0.00') {
|
||
li += '<li data-theme="c"><a href="#" class="togoorder ' + size + '">' + P_TOGO[lang] + ' (' + takeAwayPrice + ' ' + currency + ')</a></li>';
|
||
}
|
||
|
||
$("#startpaypage").hide();
|
||
|
||
$("#oben").append(li).promise().done(function () {
|
||
bindTogoOrdering();
|
||
$(this).off("click").on("click", "a", function (e) {
|
||
e.stopImmediatePropagation();
|
||
e.preventDefault();
|
||
var roomdetail = roomtableinfo[this.id];
|
||
$("#info-page").data("roomid",roomdetail["id"]);
|
||
|
||
// REM* TODO display back button
|
||
$("#startpaypage").show();
|
||
displayTablesOfRoom(roomdetail,true);
|
||
});
|
||
refreshList(this);
|
||
});
|
||
}
|
||
});
|
||
|
||
}
|
||
|
||
function bindTogoOrdering() {
|
||
$(".togoorder").off("click").on("click", function (e) {
|
||
e.stopImmediatePropagation();
|
||
e.preventDefault();
|
||
$("#info-page").data("roomid",null);
|
||
$("#info-page").data("tableviewactive",0);
|
||
$("#info-page").data("tid",0);
|
||
$("#info-page").data("tablename",P_TOGO[lang]);
|
||
$("#oben").show();
|
||
getProdsToPayForTable(0,"");
|
||
});
|
||
}
|
||
|
||
function displayTablesOfRoom (roomdetail,hasSomeRooms) {
|
||
checkForLogIn();
|
||
hasRooms = hasSomeRooms;
|
||
var roomid = $("#info-page").data("roomid");
|
||
hideReceiptPart();
|
||
displayUnpaidTables("Tischinfo nicht erhalten!");
|
||
}
|
||
|
||
$(document).ready(function() {
|
||
checkForLogIn();
|
||
var refreshId = setInterval(function() {
|
||
var roomid = $("#info-page").data("roomid");
|
||
if (roomid != null) {
|
||
displayUnpaidTables(null);
|
||
}
|
||
}, 10000);
|
||
$.ajaxSetup({ cache: false });
|
||
});
|
||
|
||
function displayUnpaidTables(errorMsg) {
|
||
doAjax("GET","php/contenthandler.php?module=roomtables&command=getUnpaidTables",{roomid:$("#info-page").data("roomid")},displayTables,errorMsg);
|
||
}
|
||
|
||
function displayTables(jsonInfo) {
|
||
var tables = jsonInfo.tables;
|
||
var takeAwayPrice = jsonInfo.takeawayprice;
|
||
|
||
$("#info-page").data("tableviewactive",1);
|
||
|
||
// REM* shall list or map for tables be shown?
|
||
var roomid = $("#info-page").data("roomid");
|
||
var displaymap = shallDisplayRoom(roomid);
|
||
if (displaymap.show) {
|
||
$("#oben").hide();
|
||
$("#tablemapcontent").show();
|
||
$("#togoarea").show();
|
||
d = new Date();
|
||
$("#mapimgpart").attr("src", "php/tablemap.php?command=getUnpaidTablesMapImgAsPng&showBubbles=0&roomid=" + roomid + "&"+d.getTime());
|
||
|
||
var tablemap = new Tablemap(roomid,null,"");
|
||
var overlay = tablemap.createOverlay("#mapimgpart", displaymap.pos,'',decpoint,currency,tables,ostablebtnsize);
|
||
$("#tableoverlay").html(overlay);
|
||
tablemap.bindingForOverlaySelection(handleClickInTablemap.bind(this),roomid,tables);
|
||
if (!hasRooms) {
|
||
if (takeAwayPrice != '0.00') {
|
||
// REM* graphical view, and no tables -> show TOGO under image
|
||
var li = '<li data-theme="d"><a href="#" class="togoorder ' + size + '">' + P_TOGO[lang] + '</a></li></ul>';
|
||
$("#tables-list-togo").html(li);
|
||
$("#togoarea").show();
|
||
}
|
||
|
||
refreshList("#tables-list-togo");
|
||
bindTogoOrdering();
|
||
}
|
||
} else {
|
||
$("#oben").show();
|
||
$("#tablemapcontent").hide();
|
||
$("#togoarea").hide();
|
||
|
||
var li = '<li data-role="list-divider" data-theme="b" data-role="heading">' + P_TABLE_SEL[lang] + '</li>';
|
||
var size = getTableSizeClass();
|
||
$.each(tables, function( index, value ) {
|
||
var sum = value["pricesum"].replace(".",decpoint);
|
||
var txt = value["name"] + " <small><i>(" + sum + " " + currency + ")</i></small>";
|
||
li += '<li data-theme="e"><a href="#" id="' + index + '" class="info-go ' + size + '">' + txt + '</a></li>';
|
||
});
|
||
if (!hasRooms) {
|
||
if (takeAwayPrice != '0.00') {
|
||
li += '<li data-theme="c"><a href="#" class="togoorder ' + size + '">' + P_TOGO[lang] + '</a></li>';
|
||
}
|
||
}
|
||
|
||
//append list to ul
|
||
$("#oben").empty().append(li).promise().done(function () {
|
||
bindTogoOrdering();
|
||
$(this).off("click").on("click", ".info-go", function (e) {
|
||
e.stopImmediatePropagation();
|
||
e.preventDefault();
|
||
// REM* this.id = Nummer des Eintrags in der Liste der Tische (d.h. 8. Eintrag k?nnte Tisch 10 sein)
|
||
// REM* var roomid = roomdetail["id"]; // hier ist roomdetail das alte, nicht das von oben!!!
|
||
$("#info-page").data("roomid",null);
|
||
$("#info-page").data("tableviewactive",0);
|
||
var tableid = tables[this.id]["id"];
|
||
var tablename = tables[this.id]["name"];
|
||
|
||
$("#info-page").data("tid",tableid);
|
||
$("#info-page").data("tablename",tablename);
|
||
|
||
// REM* var roomtable_array= new Array(roomid,tableid,tablename);
|
||
getProdsToPayForTable(tableid,tablename);
|
||
});
|
||
|
||
// REM* refresh list to enhance its styling.
|
||
refreshList(this);
|
||
});
|
||
}
|
||
};
|
||
|
||
|
||
function getProdsToPayForTable(tableid,tablename) {
|
||
$("#startpaypage").show();
|
||
if (tableid == 0) {
|
||
tablename = P_TOGO[lang];
|
||
$("#info-page").data("taxtype","togo");
|
||
} else {
|
||
$("#info-page").data("taxtype","normal");
|
||
}
|
||
$("#cashactions").hide();
|
||
$("#navactions").hide();
|
||
$.ajax({ type: "GET",
|
||
dataType: "json",
|
||
data : { tableid: tableid },
|
||
url: "php/contenthandler.php?module=queue&command=getJsonProductsOfTableToPay",
|
||
async: false,
|
||
success : function(jsonText)
|
||
{
|
||
var status = jsonText.status;
|
||
var msg = jsonText.msg;
|
||
if (status != "ERROR") {
|
||
showReceiptPart();
|
||
|
||
$("#info-page").data("tableprods",msg);
|
||
bindPayButton(msg,tableid,tablename);
|
||
initiatePayableView(msg,tablename);
|
||
} else {
|
||
alert("Fehler: " + msg);
|
||
}
|
||
},
|
||
error: function( text ) {
|
||
alert( "Sorry, there was a problem getting the products to pay for table!");
|
||
}
|
||
});
|
||
}
|
||
|
||
|
||
function initiatePayableView(jsonContent,tablename) {
|
||
$('#tableinreceipt').html(tablename + '<br> ');
|
||
clearUntenAndReceipt();
|
||
createAllEntriesInReceipt();
|
||
calcSum();
|
||
prodsToPayList = jsonContent;
|
||
payTable = tablename;
|
||
displayProdsToPayForTable();
|
||
}
|
||
|
||
|
||
function displayProdsToPayForTable() {
|
||
// REM* first group the items
|
||
prodsToPayListGrouping = new Grouping(prodsToPayList,createHashOfPayableItem);
|
||
prodsToPayListGrouping.group();
|
||
|
||
var size = getProdSizeClass();
|
||
|
||
var txt = '<li data-role="list-divider" data-theme="b" data-role="heading">' + P_NOT_PAID[lang] + payTable + '</li>'; // init a list
|
||
txt += '<li data-theme="f" data-icon="check"><a href="#" id="payall" class="' + size + '">' + P_ALL[lang] + '</a></li>';
|
||
|
||
var listContent = txt + prodsToPayListGrouping.outputList(createPayableItemListElement);
|
||
$("#oben").html(listContent);
|
||
refreshList("#oben");
|
||
|
||
$(".payable").off("click").on("click", function (e) {
|
||
e.stopImmediatePropagation();
|
||
e.preventDefault();
|
||
// REM* get rowIndex of item
|
||
var listItem = $(this).closest("li");
|
||
var rowIndex = $( "#oben li" ).index(listItem) - 2;
|
||
// REM* get an item from the payableList
|
||
var removedEntry = prodsToPayListGrouping.popSortedEntry(rowIndex);
|
||
prodsOnReceiptList[prodsOnReceiptList.length] = removedEntry;
|
||
displayProdsToPayForTable();
|
||
displayProdsOnReceipt();
|
||
});
|
||
|
||
$("#payall").off("click").on("click", function (e) {
|
||
e.stopImmediatePropagation();
|
||
e.preventDefault();
|
||
for (var i=0;i<prodsToPayList.length;i++) {
|
||
prodsOnReceiptList[prodsOnReceiptList.length] = prodsToPayList[i];
|
||
}
|
||
prodsToPayList = [];
|
||
displayProdsToPayForTable();
|
||
displayProdsOnReceipt();
|
||
});
|
||
|
||
window.scrollTo(0,0);
|
||
}
|
||
|
||
function displayProdsOnReceipt() {
|
||
// REM* first group the items
|
||
prodsOnReceiptListGrouping = new Grouping(prodsOnReceiptList,createHashOfPayableItem);
|
||
prodsOnReceiptListGrouping.group();
|
||
|
||
var size = getProdSizeClass();
|
||
|
||
var txt = '<li data-role="list-divider" data-theme="b" data-role="heading">';
|
||
txt += P_CONTENT_RECEIPT[lang] +': <p id="priceinreceipt">0,00 ' + currency + '</p></li>';
|
||
|
||
var listContent = txt + prodsOnReceiptListGrouping.outputList(createOnReceiptItemListElement);
|
||
$("#unten").html(listContent);
|
||
refreshList("#unten");
|
||
|
||
createAllEntriesInReceipt();
|
||
|
||
$(".onreceipt").off("click").on("click", function (e) {
|
||
e.stopImmediatePropagation();
|
||
e.preventDefault();
|
||
// REM* get rowIndex of item
|
||
var listItem = $(this).closest("li");
|
||
var rowIndex = $( "#unten li" ).index(listItem) - 1;
|
||
// REM* get an item from the payableList
|
||
var removedEntry = prodsOnReceiptListGrouping.popSortedEntry(rowIndex);
|
||
prodsToPayList[prodsToPayList.length] = removedEntry;
|
||
displayProdsToPayForTable();
|
||
displayProdsOnReceipt();
|
||
});
|
||
};
|
||
|
||
|
||
function generateListItem(theme,icon,id,content,classname) {
|
||
var size = getProdSizeClass();
|
||
var li = '<li data-theme="' + theme + '" data-icon="' + icon + '">';
|
||
li += '<a href="#" id="' + id + '" class="info-go ' + size + ' ' + classname + '">' + content + '</a></li>';
|
||
return li;
|
||
}
|
||
|
||
function addAllToUnten(jsonContent,tablename) {
|
||
$("#payall").off("click").on("click", function (e) {
|
||
e.stopImmediatePropagation();
|
||
e.preventDefault();
|
||
|
||
var entryListForReceipt = [];
|
||
$("#oben li a.info-go").each(function() {
|
||
|
||
var id_in_jsonText = $(this).attr('id');
|
||
var entry = {
|
||
idx : id_in_jsonText,
|
||
prodid: jsonContent[id_in_jsonText]["prodid"],
|
||
queueid: jsonContent[id_in_jsonText]["id"],
|
||
longname: jsonContent[id_in_jsonText]["longname"],
|
||
price: jsonContent[id_in_jsonText]["price"],
|
||
tax: jsonContent[id_in_jsonText]["tax"],
|
||
extras: jsonContent[id_in_jsonText]["extras"],
|
||
pricelevelname: jsonContent[id_in_jsonText]["pricelevelname"]
|
||
};
|
||
entryListForReceipt[entryListForReceipt.length] = entry;
|
||
});
|
||
|
||
$.each(entryListForReceipt, function (i, entry) {
|
||
addToUnten(entry.prodid,entry.longname,entry.price,entry.tax,entry.pricelevelname,entry.extras,entry.idx);
|
||
|
||
$("#oben li .info-go").each(function() {
|
||
$(this).closest('li').remove().promise();
|
||
});
|
||
|
||
refreshList("#oben");
|
||
});
|
||
});
|
||
|
||
}
|
||
|
||
function createHashOfPayableItem(aProd) {
|
||
var longname = aProd["longname"];
|
||
if (aProd["pricelevelname"] != "A") {
|
||
longname += " (" + aProd["pricelevelname"] + ")";
|
||
}
|
||
longname += " - " + (parseFloat(aProd["price"]).toFixed(2).replace(".",decpoint));
|
||
var extratxt = createExtraParagraph(aProd["extras"]);
|
||
return toHtml(longname) + extratxt;
|
||
}
|
||
|
||
function createPayableItemListElement(aProd) {
|
||
var count = "";
|
||
if("count" in aProd) {
|
||
if (aProd["count"] > 1) {
|
||
count = aProd["count"] + "x ";
|
||
}
|
||
}
|
||
var li_item = generateListItem("c","plus","payable_" + aProd["id"],count + createHashOfPayableItem(aProd),"payable");
|
||
return li_item;
|
||
}
|
||
|
||
function createOnReceiptItemListElement(aProd) {
|
||
var count = "";
|
||
if("count" in aProd) {
|
||
if (aProd["count"] > 1) {
|
||
count = aProd["count"] + "x ";
|
||
}
|
||
}
|
||
var li_item = generateListItem("c","plus","payable_" + aProd["id"],count + createHashOfPayableItem(aProd),"onreceipt");
|
||
return li_item;
|
||
}
|
||
|
||
|
||
// Make table empty...
|
||
function clearUntenAndReceipt() {
|
||
var untenHeader = '<li data-role="list-divider" data-theme="b" data-role="heading">';
|
||
untenHeader += P_CONTENT_RECEIPT[lang] +': <p id="priceinreceipt">0,00 ' + currency + '</p></li>';
|
||
|
||
$("#unten").empty().append(untenHeader).promise().done(function () {
|
||
refreshList("#unten");
|
||
});
|
||
|
||
$('#prodlistinreceipt tr').each(function() {
|
||
$(this).remove();
|
||
});
|
||
$("#thedate").html('<br><br> <br>');
|
||
}
|
||
|
||
|
||
// arrayToFill:
|
||
// [0]: count prodid prodid-pricelevelname queueid longname price pricelevelname
|
||
// [1]: count prodid prodid-pricelevelname queueid longname price pricelevelname
|
||
//
|
||
// entry:
|
||
// [0]: prodid queueid longname price pricelevelname
|
||
// REM* [2]: name, [3]: price, [4]: tax, [5] extras, [6]: pricelevel
|
||
function addEntryOrIncreaseCount(arrayToFill,entry) {
|
||
var index=0;
|
||
var found = false;
|
||
|
||
var combinedIdPricelevelPriceExtras = entry.prodid + "-" + entry.extras.join("_") + entry.price + "-" + entry.pricelevelname + "#" + entry.tax;
|
||
for (index=0;index<arrayToFill.length;index++) {
|
||
var anEntry = arrayToFill[index];
|
||
// REM* entry = prodid,queueid,longname,price,pricelevelname
|
||
// REM* anEntry = count,prodid,"prodid-pricelevel",queueid,longname,price
|
||
if (anEntry[2] == combinedIdPricelevelPriceExtras) {
|
||
// REM* prodid equal
|
||
anEntry[0] += 1;
|
||
found = true;
|
||
}
|
||
}
|
||
if (!found) {
|
||
arrayToFill.push(new Array(1,entry,combinedIdPricelevelPriceExtras));
|
||
}
|
||
return arrayToFill;
|
||
}
|
||
|
||
// REM* create an array of taxes that are present in the current bill
|
||
function listTaxes(collectionOfTaxes,decpointx) {
|
||
var taxes = [];
|
||
|
||
for (var i=0;i<collectionOfTaxes.length;i++) {
|
||
var tax = parseFloat(String(collectionOfTaxes[i]));
|
||
tax = tax.toFixed(2).replace(".",decpointx);
|
||
if (taxes.indexOf(tax) < 0) {
|
||
// REM* tax was not yet in the list
|
||
taxes[taxes.length] = tax;
|
||
}
|
||
}
|
||
return taxes;
|
||
}
|
||
|
||
function listTaxesBasedOnUntenList(decpointx) {
|
||
// REM* which different taxes do we have?
|
||
var mytaxes = [];
|
||
var count = 0;
|
||
|
||
for (var i=0;i<prodsOnReceiptList.length;i++) {
|
||
var prodEl = prodsOnReceiptList[i];
|
||
mytaxes.push(prodEl.tax);
|
||
}
|
||
|
||
return listTaxes(mytaxes,decpoint);
|
||
}
|
||
|
||
function calcSum() {
|
||
|
||
// REM* which different taxes do we have?
|
||
var taxes = listTaxesBasedOnUntenList(decpoint);
|
||
var jsonContent = $("#info-page").data("tableprods");
|
||
var sum = 0.0;
|
||
|
||
var nettosum = [];
|
||
var bruttosum = [];
|
||
var mwstsum = [];
|
||
|
||
// REM* initiate
|
||
for (var i=0;i<taxes.length;i++) {
|
||
nettosum[i] = 0.0;
|
||
bruttosum[i] = 0.0;
|
||
mwstsum[i] = 0.0;
|
||
}
|
||
|
||
var overallnetto = 0.0;
|
||
var overallbrutto = 0.0;
|
||
var overallmwst = 0.0;
|
||
|
||
for (var k=0;k<prodsOnReceiptList.length;k++) {
|
||
var item = prodsOnReceiptList[k];
|
||
var bruttoprice = parseFloat(item["price"]);
|
||
var taxStr = item["tax"];
|
||
var tax = parseFloat(taxStr);
|
||
taxStr = taxStr.replace(".",decpoint);
|
||
|
||
var nettoprice = bruttoprice/(1 + tax/100.0);
|
||
var mwst = bruttoprice - nettoprice;
|
||
|
||
// REM* find index of tax in array
|
||
var taxIndex = 0;
|
||
for (var i=0;i<taxes.length;i++) {
|
||
if (taxes[i] == taxStr) {
|
||
taxIndex = i;
|
||
}
|
||
}
|
||
|
||
nettosum[taxIndex] = nettosum[taxIndex] + nettoprice;
|
||
bruttosum[taxIndex] = bruttosum[taxIndex] + bruttoprice;
|
||
mwstsum[taxIndex] = mwstsum[taxIndex] + mwst;
|
||
|
||
overallnetto += nettoprice;
|
||
overallbrutto += bruttoprice;
|
||
overallmwst += mwst;
|
||
};
|
||
|
||
|
||
for (var j=0;j<taxes.length;j++) {
|
||
var tax = taxes[j];
|
||
var taxid = tax.replace(",","-");
|
||
// REM* comma in id is not good - replace by a line
|
||
$("#taxval" + taxid).html(tax + "%");
|
||
|
||
$("#mwst" + taxid).html(mwstsum[j].toFixed(2).replace(".",decpoint));
|
||
$("#netto" + taxid).html(nettosum[j].toFixed(2).replace(".",decpoint));
|
||
$("#brutto" + taxid).html(bruttosum[j].toFixed(2).replace(".",decpoint));
|
||
}
|
||
|
||
billbrutto = overallbrutto;
|
||
billnetto = overallnetto;
|
||
|
||
$("#priceinreceipt").html(overallbrutto.toFixed(2).replace(".",decpoint) + " " + currency);
|
||
$("#priceinreceipt2").html(overallbrutto.toFixed(2).replace(".",decpoint) + " " + currency);
|
||
}
|
||
|
||
// REM* use prodsOnReceiptListGrouping
|
||
function createAllEntriesInReceipt() {
|
||
var tablename = $("#info-page").data("tablename");
|
||
|
||
var entryListForReceipt=new Array();
|
||
// collect all entries in the list #unten
|
||
|
||
for (var i=0;i<prodsOnReceiptList.length;i++) {
|
||
var item = prodsOnReceiptList[i];
|
||
var entry = {
|
||
prodid: item["prodid"],
|
||
queueid: item["id"],
|
||
longname: item["longname"],
|
||
price: item["price"],
|
||
tax: item["tax"],
|
||
extras: item["extras"],
|
||
pricelevelname: item["pricelevelname"]
|
||
};
|
||
entryListForReceipt = addEntryOrIncreaseCount(entryListForReceipt,entry);
|
||
}
|
||
|
||
var tablecontent = createReceiptHeader();
|
||
|
||
// this preparation for the ESC/POS printers
|
||
var escPosList = new Array();
|
||
|
||
tablecontent += generateProdPart(decpoint,entryListForReceipt)
|
||
|
||
var taxGerFormat = $("#info-page").data("usstGerVal");
|
||
|
||
if ($("#info-page").data("taxtype") == "togo") {
|
||
taxGerFormat = $("#info-page").data("togoTaxGerVal");
|
||
}
|
||
|
||
var taxes = listTaxesBasedOnUntenList(decpoint);
|
||
// REM* taxes are now strings with country-specific decpoint
|
||
tablecontent += createReceiptFooter(taxGerFormat,lang,taxes);
|
||
|
||
// now calculate everything without hosting part for later export
|
||
$('#receiptpart').html(tablecontent);
|
||
calcSum(); // updates info:
|
||
var calculatedBill = $('#receiptpart').html();
|
||
$('#info-page').data("receipthtml",calculatedBill);
|
||
|
||
// again for pos/esc
|
||
var escposreceipt = new Array(taxGerFormat,escPosList);
|
||
// now put it to a DOM element
|
||
$("#info-page").data("escposprods",escposreceipt);
|
||
|
||
// shall the hosting be visible?
|
||
var visibilityHostPart = $("#info-page").data("hosting");
|
||
var hosttablepart = "";
|
||
if (visibilityHostPart == 1) {
|
||
// need to use .ajax instead of .get to set cache to false!
|
||
$.ajax({
|
||
url: "customer/bon-bewirtungsvorlage.html",
|
||
async: false,
|
||
success: function(hostdata){
|
||
$('#receiptpart').html(tablecontent + hostdata);
|
||
calcSum();
|
||
},
|
||
error: function( text ) {
|
||
alert( "Kommunikationsfehler zum Server: ");
|
||
},
|
||
cache: false
|
||
});
|
||
} else {
|
||
$('#receiptpart').html(tablecontent + hosttablepart);
|
||
calcSum();
|
||
}
|
||
}
|
||
|
||
function createReceiptHeader() {
|
||
var header = genCreateReceiptHeader($("#info-page").data("billlanguage"),
|
||
"",
|
||
$("#info-page").data("tablename"),
|
||
$("#loggedinuser").html(),
|
||
currency
|
||
);
|
||
return header;
|
||
}
|
||
|
||
function createReceiptFooter(taxGerFormat, lang, taxes) {
|
||
var footer = genCreateReceiptFooterNoSum(taxGerFormat,
|
||
$("#info-page").data("billlanguage"),
|
||
$("#info-page").data("companyinfo"),
|
||
taxes);
|
||
return footer;
|
||
}
|
||
|
||
function bindPayButton(jsonContent,tableid,tablename) {
|
||
$("#payWithoutPrint").off("click").on("click", function (e) {
|
||
e.stopImmediatePropagation();
|
||
e.preventDefault();
|
||
selectPayment(tableid,tablename,false);
|
||
});
|
||
$("#payWithPrint").off("click").on("click", function (e) {
|
||
e.stopImmediatePropagation();
|
||
e.preventDefault();
|
||
selectPayment(tableid,tablename,true);
|
||
});
|
||
}
|
||
|
||
function selectPayment(tableid,tablename,printoption) {
|
||
// first test if there are items to pay!
|
||
var itemsToPay = prodsOnReceiptList.length;
|
||
if (itemsToPay == 0) {
|
||
$.mobile.changePage("#nocashitems");
|
||
} else {
|
||
var topay = $("#priceinreceipt2").html().replace(".",decpoint);
|
||
$("#topayval").html(topay);
|
||
$("#haspaid").attr("placeholder", topay);
|
||
$("#haspaid").val("");
|
||
$("#topayback").html("0" + decpoint + "00");
|
||
|
||
// start pay process by selection of payment types
|
||
$.mobile.changePage("#paymentdialog");
|
||
bindCalcReturn();
|
||
$("#paymentdialog .sure-do").off("click").on("click", function() {
|
||
var paymentId = (($(this).attr("id")).split("_"))[1];
|
||
$(this).off("click");
|
||
$.mobile.changePage("#info-page");
|
||
|
||
var appliedTax = $("#info-page").data("usst");
|
||
if ($("#info-page").data("taxtype") == "togo") {
|
||
appliedTax = $("#info-page").data("togotax");
|
||
}
|
||
startPayProcess(printoption,tableid,tablename,paymentId,appliedTax);
|
||
});
|
||
}
|
||
}
|
||
|
||
function bindCalcReturn() {
|
||
$("#calcreturnbtn").off("click").on("click", function (e) {
|
||
e.stopImmediatePropagation();
|
||
e.preventDefault();
|
||
try {
|
||
var hasPaid = parseFloat($("#haspaid").val().replace(decpoint,"."));
|
||
var toPay = parseFloat($("#topayval").html().replace(decpoint,"."));
|
||
var toRet = hasPaid - toPay;
|
||
if ($.isNumeric(parseFloat(toRet))) {
|
||
var toReturn = toRet.toFixed(2).replace(".",decpoint);
|
||
$("#topayback").html(toReturn);
|
||
} else {
|
||
$("#topayback").html("?");
|
||
}
|
||
} catch (e) {
|
||
$("#topayback").html("?");
|
||
}
|
||
|
||
});
|
||
}
|
||
|
||
function startPayProcess(printoption,tableid,tablename,paymentid,tax) {
|
||
checkForLogIn();
|
||
var ids="";
|
||
|
||
for (var i=0;i<prodsOnReceiptList.length;i++) {
|
||
var item = prodsOnReceiptList[i];
|
||
var queueId = item["id"];
|
||
ids += queueId + ",";
|
||
}
|
||
|
||
// REM* declarePaidCreateBillReturnBillId
|
||
var style = ' style="table-layout: fixed; width: 70%; background-color: #cccccc;" ';
|
||
var htmlContentWithoutHosting = '<table ' + style + '>' + $('#info-page').data("receipthtml") + '</table>';
|
||
|
||
// for escpos
|
||
var escheader = $('#info-page').data("escposheader");
|
||
var escallprods = $("#info-page").data("escposprods");
|
||
var escfooter = $("#info-page").data("escposfooter");
|
||
var escpos = new Array(escheader,escallprods,escfooter,$("#info-page").data("hosting"));
|
||
|
||
$.ajax({ type: "POST",
|
||
dataType: "json",
|
||
data : { ids: ids,
|
||
// html : htmlContentWithoutHosting,
|
||
brutto: billbrutto,
|
||
netto: billnetto,
|
||
tableid : tableid,
|
||
paymentid : paymentid,
|
||
tax : tax,
|
||
decpoint : decpoint,
|
||
declareready: cameFromOrdering,
|
||
host: $("#info-page").data("hosting")
|
||
},
|
||
url: "php/contenthandler.php?module=queue&command=declarePaidCreateBillReturnBillId",
|
||
async: false,
|
||
success : function(jsonText)
|
||
{
|
||
var status = jsonText.status;
|
||
var billinfo = jsonText.msg;
|
||
|
||
if (status != "ERROR") {
|
||
billid = billinfo.billid;
|
||
billdate = billinfo.date;
|
||
|
||
if (billid < 0) {
|
||
alert("Error! Bitte erneut versuchen. Error code: " + billid);
|
||
window.location.reload(false);
|
||
} else {
|
||
var lang = $("#info-page").data("billlanguage");
|
||
$("#billid").html(P_ID[lang] + billid);
|
||
$("#billdate").html(billdate);
|
||
if (printoption) {
|
||
var htmlContent = '<table width=100% style="table-layout: fixed;font-size:' + receiptfontsize + 'px;">' + $("#receiptpart").html() + "</table>";
|
||
var payPrintType = $("#info-page").data("payPrintType");
|
||
if (payPrintType == 's') {
|
||
printBill(billid);
|
||
} else {
|
||
$("#oben").hide();
|
||
|
||
var receiptToPrint = "<table>" + $(".receipttable").html() + "</table>";
|
||
printContent(receiptToPrint);
|
||
}
|
||
}
|
||
// bug workaround. reload does not work after pdf-print-so getProd in all cases
|
||
prodsOnReceiptList = [];
|
||
getProdsToPayForTable(tableid,tablename);
|
||
var itemsLeft = $('#oben li').size() - 2;
|
||
if (itemsLeft > 0) {
|
||
//getProdsToPayForTable(tableid,tablename);
|
||
} else {
|
||
// so that reload also works for Chrome:
|
||
setTimeout(function(){document.location.href = "paydesk.html"},500);
|
||
}
|
||
}
|
||
} else {
|
||
alert("Fehler: " + billinfo);
|
||
}
|
||
},
|
||
error: function( text ) {
|
||
alert( "Sorry, there was a problem! " + text);
|
||
}
|
||
});
|
||
}
|
||
|
||
function printBill(billid) {
|
||
doAjax("POST","php/contenthandler.php?module=printqueue&command=queueReceiptPrintJob",
|
||
{billid : billid }, null, "Druckfehler");
|
||
}
|
||
|
||
function bindHostButton() {
|
||
$("#hostbutton").off("click").on("click", function (e) {
|
||
e.stopImmediatePropagation();
|
||
e.preventDefault();
|
||
|
||
var billlang = $("#info-page").data("billlanguage");
|
||
|
||
if (billlang == 0) {
|
||
var statusVisibility = $("#info-page").data("hosting");
|
||
if (statusVisibility == '0') {
|
||
$("#info-page").data("hosting",'1');
|
||
} else {
|
||
$("#info-page").data("hosting",'0');
|
||
}
|
||
createAllEntriesInReceipt();
|
||
} else {
|
||
if (lang == 0) {
|
||
alert("Bewirtungsbeleg steht nur f<>r deutsche Kassenbons zur Verf<72>gung.");
|
||
} else if (lang == 1) {
|
||
alert("Bewirtungsbeleg is only possible for German receipts.");
|
||
} else if (lang == 2) {
|
||
alert("Bewirtungsbeleg se puedo usar solo para tiques alemanes.");
|
||
}
|
||
}
|
||
});
|
||
}
|
||
|
||
function cashactions() {
|
||
$(".cashaction").off("click").on("click", function (e) {
|
||
var id = $(this).attr('id');
|
||
if (id == "cashtakeout") {
|
||
startCashTakeOutProcess();
|
||
} else if (id == "cashinsert") {
|
||
startCashInsertProcess();
|
||
} else if (id == "cashoverview") {
|
||
startCashOverviewProcess() ;
|
||
}
|
||
});
|
||
}
|
||
|
||
function startCashInsertProcess() {
|
||
$("#cashinsertdialog .sure-do").off("click").on("click", function() {
|
||
//$(this).off("click");
|
||
|
||
$.mobile.changePage("#info-page");
|
||
var money = $("#moneyToInsert").val().replace($("#info-page").data("decpoint"),".");
|
||
if (isNaN(money)) {
|
||
alert("Keine Zahl!");
|
||
} else {
|
||
if ((parseFloat(money) >= 0.0) && (parseFloat(money) <= 10000)) {
|
||
doCashInsert(money);
|
||
} else {
|
||
alert("Betrag muss positiv und kleiner als 10000 sein!");
|
||
}
|
||
}
|
||
});
|
||
$.mobile.changePage("#cashinsertdialog");
|
||
}
|
||
|
||
function startCashTakeOutProcess() {
|
||
$("#cashtakeoutdialog .sure-do").off("click").on("click", function() {
|
||
//$(this).off("click");
|
||
|
||
$.mobile.changePage("#info-page");
|
||
var money = $("#moneyToTakeOut").val().replace(decpoint,".");
|
||
if (isNaN(money)) {
|
||
alert("Keine Zahl!");
|
||
} else {
|
||
if ((parseFloat(money) >= 0.0) && (parseFloat(money) <= 10000)) {
|
||
doCashTakeOut(money);
|
||
} else {
|
||
alert("Betrag muss positiv und kleiner als 10000 sein!");
|
||
}
|
||
}
|
||
});
|
||
$.mobile.changePage("#cashtakeoutdialog");
|
||
}
|
||
|
||
function doCashInsert(money) {
|
||
doAjax("POST", "php/contenthandler.php?module=bill&command=doCashAction", {money: money}, handleCashActionResult, "Fehler Kassenaktion");
|
||
}
|
||
|
||
function doCashTakeOut(money) {
|
||
money = 0.0 - parseFloat(money);
|
||
doAjax("POST", "php/contenthandler.php?module=bill&command=doCashAction", {money: money}, handleCashActionResult, "Fehler Kassenaktion");
|
||
}
|
||
|
||
function startCashOverviewProcess() {
|
||
doAjax("POST", "php/contenthandler.php?module=bill&command=getCashOverviewOfUser", null, showCashOverview, "Fehler Kassenaktion");
|
||
}
|
||
|
||
function handleCashActionResult(jsonText) {
|
||
if (jsonText.status == "ERROR") {
|
||
alert("Fehler " + jsonText.code + ": " + jsonText.msg);
|
||
} else if (jsonText.status == "OK") {
|
||
alert(P_CASHACTION_OK[lang]);
|
||
}
|
||
}
|
||
|
||
function showCashOverview(jsonText) {
|
||
$("#cashbyguests").html((parseFloat(jsonText.guestmoney).toFixed(2)).replace(".",decpoint));
|
||
$("#cashtotal").html((parseFloat(jsonText.total).toFixed(2)).replace(".",decpoint));
|
||
$.mobile.changePage("#cashoverviewinfo");
|
||
}
|
||
|
||
function startDisplayProcess() {
|
||
var urlsuffix = location.search;
|
||
if (urlsuffix.length==0) {
|
||
displayAllRooms();
|
||
} else {
|
||
var urlstr=urlsuffix.slice(1);
|
||
var parts= urlstr.split("=");
|
||
if (parts.length != 2) {
|
||
// default
|
||
displayAllRooms();
|
||
}
|
||
|
||
var tid = parts[1];
|
||
// REM* this page was called from waiter view (important for: 1. back button, 2. remove from waiter view)
|
||
cameFromOrdering = 1;
|
||
|
||
// do not show cash actions if URL called by waiter module
|
||
$("#cashactions").hide();
|
||
$("#navactions").hide();
|
||
|
||
$.ajax({ type: "GET",
|
||
url: "php/contenthandler.php?module=queue&command=getJsonTableNameFromId",
|
||
dataType: "json",
|
||
data: {tableid : tid},
|
||
async: false,
|
||
success : function(jsonContent)
|
||
{
|
||
$("#info-page").data("tid",tid);
|
||
$("#info-page").data("tablename",jsonContent);
|
||
getProdsToPayForTable(tid,jsonContent);
|
||
},
|
||
error: function( text ) {
|
||
alert( "Kommunikationsfehler zum Server bei Tischnamenabfrage: " + errorMsg);
|
||
}
|
||
});
|
||
}
|
||
}
|
||
|
||
$(document).on("pageinit", "#info-page", function () {
|
||
initializeMainMenu("#modulemenu");
|
||
hideMenu();
|
||
getGeneralConfigItems();
|
||
$("#info-page").data("taxtype","normal");
|
||
|
||
getButtonSizes();
|
||
|
||
getPayments();
|
||
$("#hostingtablepart").hide();
|
||
$("#info-page").data("hosting",'0');
|
||
bindHostButton();
|
||
|
||
cashactions();
|
||
// button in header to start paydesk
|
||
$("#startpaypage").off("click").on("click", function (e) {
|
||
e.stopImmediatePropagation();
|
||
e.preventDefault();
|
||
if (cameFromOrdering == 1) {
|
||
setTimeout(function(){document.location.href = "waiter.html"},250);
|
||
} else {
|
||
// REM* should never be called cause if hidden back button
|
||
window.location.reload(false);
|
||
}
|
||
});
|
||
|
||
getTableMapPreferences();
|
||
// REM* starts startDisplayProcess later
|
||
});
|
||
|
||
</script>
|
||
|
||
<div data-role="page" id="info-page">
|
||
<div data-role="panel" id="modulepanel" data-position="right" data-display="overlay">
|
||
<ul data-role="listview" id="modulemenu" data-divider-theme="a" data-inset="true">
|
||
<li data-role="list-divider" data-theme="b" data-role="heading">Module</li>
|
||
</ul>
|
||
</div><!-- /panel -->
|
||
<div data-role="header" data-theme="b" data-position="fixed" id="theheader">
|
||
<h1><span id="paydesktitle">Kasse</span></h1>
|
||
<div data-type="horizontal" style="top:0px;position:absolute;float:right;z-index:10;display:inline;" align="right" class="ui-btn-right">
|
||
<a href="#" data-role="button" data-icon="arrow-d" data-ajax="false" id="menuswitch">Module</a>
|
||
</div>
|
||
<div data-type="horizontal" style="top:10px;position:absolute;float:right;z-index:10;display:inline;" align="left" class="ui-btn-left">
|
||
<a href="#" data-role="button" data-icon="arrow-l" data-ajax="false" id="startpaypage"></a>
|
||
</div>
|
||
</div>
|
||
<div data-role="content" id="contentpart">
|
||
<ul data-role="listview" id="oben" data-divider-theme="a" data-inset="true">
|
||
<li data-role="list-divider" data-theme="b" data-role="heading" id="roomsel">Raumauswahl</li>
|
||
</ul>
|
||
|
||
<div id="tablemapcontent" style="display:none;">
|
||
<div style="background-color:black;"><span id=tableselimmaptxt style="font-weight:bold;font-size:20px;color:white;">Tischauswahl</span>:</div>
|
||
<div id=tablemapcontent style="position: relative;width:100%;">
|
||
<img id="mapimgpart" style="width:100%;position: relative;left: 0;top: 0;" src=img/empty-room.png />
|
||
<div id=tableoverlay></div>
|
||
</div>
|
||
</div>
|
||
<div id=togoarea>
|
||
<ul data-role="listview" id="tables-list-togo" data-divider-theme="a" data-inset="true">
|
||
</ul>
|
||
</div>
|
||
|
||
<ul data-role="listview" id="cashactions" data-divider-theme="a" data-inset="true">
|
||
</ul>
|
||
|
||
<ul data-role="listview" id="navactions" data-divider-theme="a" data-inset="true">
|
||
<li data-role="list-divider" data-theme="b" data-role="heading"><span id="navtitle">Navigation</span></li>
|
||
<li data-theme="e"><a href="waiter.html" id="navtoorder" target="_top"><span id="nav2order">Bestellansicht</span></a></li>
|
||
</ul>
|
||
|
||
<div id="untenarea">
|
||
<ul data-role="listview" id="unten" data-divider-theme="a" data-inset="true">
|
||
<li data-role="list-divider" data-theme="b" data-role="heading">
|
||
Inhalt Kassenbon: <p id="priceinreceipt">0,00 Euro</p>
|
||
</li>
|
||
</ul>
|
||
</div>
|
||
|
||
<div data-role="controlgroup" data-type="horizontal" id="paybuttongroup">
|
||
<a href="#" data-role="button" data-theme="b" data-icon="check" id="payWithoutPrint"><span id="OnlyPayTxt">Nur Zahlung</span></a>
|
||
<a href="#" data-role="button" data-theme="b" data-icon="grid" id="payWithPrint"><span id="payprinttxt">Bondruck</span></a>
|
||
</div>
|
||
|
||
<div data-role="controlgroup" data-type="horizontal" id="hostbuttongroup">
|
||
<a href="#" data-role="button" data-theme="b" data-icon="check" id="hostbutton">Bewirtungsbeleg</a>
|
||
</div>
|
||
|
||
<div id="partForSaveInBill"> <!-- This part will be saved into bill in db -->
|
||
<div id=partToPrint>
|
||
<table id="receiptpart" class="receipttable" border=0 style="table-layout: fixed;"></table>
|
||
</div>
|
||
</div> <!-- end of partForSaveInBill -->
|
||
|
||
</div>
|
||
|
||
<div data-role="footer" data-theme="b" id="thefooter">
|
||
<div class="ui-grid-a">
|
||
<div class="ui-block-a userinfo" id="loggedinuser"></div>
|
||
<div class="ui-block-b grid_right" id="versioninfo"></div>
|
||
</div><!-- /grid-a -->
|
||
</div> <!-- footer -->
|
||
</div>
|
||
|
||
|
||
|
||
<!-- Dialog page -->
|
||
<div data-role="dialog" id="paymentdialog" data-title="Zahlungsart">
|
||
<div data-role="content">
|
||
<h3><span id="payway">Zahlungsart</span></h3>
|
||
<p>
|
||
<div>
|
||
<form>
|
||
<table>
|
||
<tr>
|
||
<td><span id=topaytxt>Zahlen: </span><td><i><b><span id=topayval>0,00</span></b></i><span id="curtopay"></span>
|
||
<td> <td><span id=haspaidtxt>Bezahlt: </span><td style="width:30px;color:yellow;"><input type="text" id="haspaid" value="" data-mini="true" placeholder="" />
|
||
</tr><tr>
|
||
<td><span id="rettxt">Zurück: </span><td><i><b><span id="topayback">0,00</span></b></i><span id=curtopay2></span></td>
|
||
<td> <td><td><button id="calcreturnbtn" type="submit" data-theme="b" style="width:200px;"><span id="calcreturn">Berechne</span></button>
|
||
</tr>
|
||
</table>
|
||
</form>
|
||
</div>
|
||
</p>
|
||
<p><span id="choosepayway">Auswahl der Zahlungsart</span></p>
|
||
<div id=paymentlist>
|
||
<a href="#" class="sure-do" data-role="button" data-theme="b" data-rel="back">Ja</a>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<!-- Dialog page -->
|
||
<div data-role="dialog" id="sure" data-title="Entfernen?">
|
||
<div data-role="content">
|
||
<h3>Zahlungsart</h3>
|
||
<a href="#" class="sure-do" data-role="button" data-theme="b" data-rel="back">Ja</a>
|
||
<a href="#" class="sure-do" data-role="button" data-theme="b" data-rel="back">Wert2</a>
|
||
<a href="#" data-role="button" data-theme="c" data-rel="back">Nein</a>
|
||
</div>
|
||
</div>
|
||
|
||
<!-- Dialog page for cash insert -->
|
||
<div data-role="dialog" id="cashinsertdialog" data-title="Kassenaktion">
|
||
<div data-role="content">
|
||
<h3><span id="cashtakeintxt">Bareinlage in die Kasse</span></h3>
|
||
<label for="moneyToInsert"><span id="amounttxt">Betrag:</span></label>
|
||
<input type="text" id="moneyToInsert" value="" data-mini="true">
|
||
<div id=paymentlistcash>
|
||
<a href="#" class="sure-do" data-role="button" data-theme="b" data-rel="back"><span id="putinact">Einlegen</span></a>
|
||
<a href="#" data-role="button" data-theme="d" data-rel="back" id="cash_insert_cancel"><span id="canceltxt">Abbruch</span></a>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<!-- Dialog page for cash insert -->
|
||
<div data-role="dialog" id="cashtakeoutdialog" data-title="Kassenaktion">
|
||
<div data-role="content">
|
||
<h3><span id="cashtakeouttxt">Barentnahme aus der Kasse</span></h3>
|
||
<label for="moneyToTakeOut"><span id="amounttxt2">Betrag:</span></label>
|
||
<input type="text" id="moneyToTakeOut" value="" data-mini="true">
|
||
<div id=paymentlist>
|
||
<a href="#" class="sure-do" data-role="button" data-theme="b" data-rel="back"><span id="takeoutact">Entnehmen</span></a>
|
||
<a href="#" data-role="button" data-theme="d" data-rel="back" id="cash_takeout_cancel">Abbruch</a>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<div data-role="dialog" id="cashoverviewinfo" name="cashoverviewinfo" data-overlay-theme="a" style="max-width:70%;" class="ui-corner-all">
|
||
<div data-role="content">
|
||
<h3><span id="cashoverviewtxt">Übersicht Kellnerkasse</span></h3>
|
||
|
||
<p><span id="overviewdetails">Diese Übersicht enthält die Bewirtungseinnahme durch den Kellner seit der letzten Tageslosung sowie
|
||
als weiteren Wert den Kassenstand unter Berücksichtigung der eigenen Eingaben und Entnahmen.</span><p>
|
||
<p><i><span id="cashsum">Bewirtungseinnahmen:</span></i> <b><span id=cashbyguests></span></b></p>
|
||
<p><i><span id="includeowncash">inkl. eigener Kassen-Eingaben/Entnahmen:</span></i> <b><span id=cashtotal></span></b><p>
|
||
<a href="#" data-role="button" data-theme="d" data-rel="back" id="cash_overview_ok">OK</a>
|
||
</div>
|
||
</div> <!-- popup -->
|
||
|
||
<div data-role="dialog" id="nocashitems" name="nocashitems" data-overlay-theme="a" style="max-width:70%;" class="ui-corner-all">
|
||
<div data-role="content">
|
||
<h3><span id="noelementstxt">Keine Rechnungselemente</span></h3>
|
||
|
||
<p><span id="noelementsdetailstxt">Es wurden keine abrechenbaren Produkte festgelegt (der Bon ist leer!).</span><p>
|
||
<a href="#" data-role="button" data-theme="d" data-rel="back" id="nocashitems_ok">OK</a>
|
||
</div>
|
||
</div> <!-- popup nocashitems -->
|
||
|
||
</body>
|
||
</html> |