ordersprinter/paydesk.html

929 lines
32 KiB
HTML
Raw Blame History

<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=ISO-8859-1">
<link rel="stylesheet" type="text/css" href="css/bestformat.css">
<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>
</head>
<body>
<style>
@media screen
{
.receipttable {width: 30%; background-color: #cccccc;}
}
@media print
{
.receipttable {width: 100%;};
}
@media print
{
#thefooter,#theheader,#modulemenu,#oben,#untenarea,#payWithoutPrint,#paybuttongroup,#hostbuttongroup {display: none;}
}
</style>
<script>
function getTax() {
doAjax("GET", "php/contenthandler.php?module=admin&command=getTax", null, insertTax, "Fehler Umsatzsteuerdaten");
}
function getTogoTax() {
doAjax("GET", "php/contenthandler.php?module=admin&command=getTogoTax", null, insertTogoTax, "Fehler Umsatzsteuerdaten");
}
function getCompanyInfo() {
doAjax("GET", "php/contenthandler.php?module=admin&command=getCompanyInfo", null, insertCompanyInfo, "Fehler Betriebsinfo");
}
function getLogoUrl() {
doAjax("GET", "php/contenthandler.php?module=admin&command=getLogoUrl", null, insertLogoUrl, "Fehler Logo-URL");
}
function getPayPrintType() {
doAjax("GET", "php/contenthandler.php?module=admin&command=getPayPrintType", null, insertPayPrintType, "Fehler Druckkonfiguration");
}
function getPayments() {
doAjax("GET", "php/contenthandler.php?module=admin&command=getPayments", null, insertPayments, "Fehler Zahlungswege");
}
function insertTax(taxval) {
if (taxval == "FAILED") {
alert("Keine Umsatzsteuerinformation bekommen!");
} else {
var usstGerVal = taxval.replace(".", ",");
$("#info-page").data("usstGerVal",usstGerVal);
$("#info-page").data("usst",taxval);
}
}
function insertTogoTax(taxval) {
if (taxval == "FAILED") {
alert("Keine ToGo-Umsatzsteuerinformation bekommen!");
} else {
var usstGerVal = taxval.replace(".", ",");
$("#info-page").data("togoTaxGerVal",usstGerVal);
$("#info-page").data("togotax",taxval);
}
}
function insertCompanyInfo(companyInfo) {
$("#info-page").data("companyInfo",companyInfo);
}
function insertLogoUrl(logoUrl) {
$("#info-page").data("logoUrl",logoUrl);
}
function insertPayPrintType(payPrintType) {
$("#info-page").data("payPrintType",payPrintType);
}
function insertPayments(payments) {
var paymentList = "";
$.each(payments, function (i,payType) {
paymentList += '<a href="#" class="sure-do" data-role="button" data-theme="f" data-rel="back" id="paym_' + payType.id + '">' + payType.name + '</a>';
});
paymentList += '<a href="#" data-role="button" data-theme="d" data-rel="back" id="paym_cancel">Abbruch</a>';
$("#paymentlist").html(paymentList);
}
function hideReceiptPart() {
$("#payWithoutPrint").hide();
$("#payWithPrint").hide();
$("#hostbutton").hide();
$("#togobutton").hide();
$("#unten").hide();
}
function showReceiptPart() {
$("#payWithoutPrint").show();
$("#payWithPrint").show();
$("#hostbutton").show();
$("#togobutton").show();
$("#unten").show();
}
function displayAllRooms() {
$("#moneyToInsert").val("");
$("#moneyToTakeOut").val("");
$("#cashactions").show();
hideReceiptPart();
// first empty receipt
$("#prodlistinreceipt").empty().append('<td id="receiptprodheader" class="price">Anz<td>Beschreibung<td class="price">Preis<td class="price">Total');
$.getJSON("php/contenthandler.php?module=roomtables&command=getRooms",function(roomtableinfo) {
var noOfRooms = roomtableinfo.length;
if (noOfRooms == 1) {
$("#info-page").data("roomid",roomtableinfo[0]["id"]);
displayTablesOfRoom(roomtableinfo[0]);
} else {
var li = "";
$.each(roomtableinfo, function (i, name) {
li += '<li data-theme="f"><a href="#" id="' + i + '" class="info-go">' + name.name + '</a></li>';
});
$("#oben").append(li).promise().done(function () {
$(this).off("click").on("click", "a", function (e) {
e.stopImmediatePropagation();
e.preventDefault();
var roomdetail = roomtableinfo[this.id];
$("#info-page").data("roomid",roomdetail["id"]);
displayTablesOfRoom(roomdetail);
});
refreshList(this);
});
}
});
}
function displayTablesOfRoom (roomdetail) {
var roomid = $("#info-page").data("roomid");
hideReceiptPart();
displayUnpaidTables("Tischinfo nicht erhalten!");
}
$(document).ready(function() {
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(tables) {
$("#info-page").data("tableviewactive",1);
var li = '<li data-role="list-divider" data-theme="b" data-role="heading">Tischauswahl</li>';
$.each(tables, function( index, value ) {
var sum = value["sum"].replace(".",",");
var txt = value["name"] + "&nbsp;&nbsp;&nbsp;&nbsp;<small><i>(" + sum + " Euro)</i></small>";
li += '<li data-theme="e"><a href="#" id="' + index + '" class="info-go">' + txt + '</a></li>';
});
//append list to ul
$("#oben").empty().append(li).promise().done(function () {
$(this).off("click").on("click", ".info-go", function (e) {
e.stopImmediatePropagation();
e.preventDefault();
// this.id = Nummer des Eintrags in der Liste der Tische (d.h. 8. Eintrag k?nnte Tisch 10 sein)
//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);
//var roomtable_array= new Array(roomid,tableid,tablename);
getProdsToPayForTable(tableid,tablename);
});
//refresh list to enhance its styling.
refreshList(this);
});
};
function getProdsToPayForTable(tableid,tablename) {
$("#cashactions").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);
displayProdsToPayForTable(msg,tablename);
} else {
alert("Fehler: " + msg);
}
},
error: function( text ) {
alert( "Sorry, there was a problem getting the products to pay for table!");
}
});
}
function displayProdsToPayForTable(jsonContent,tablename) {
$('#tableinreceipt').html(tablename + '<br>&nbsp;');
clearUntenAndReceipt();
createAllEntriesInReceipt();
calcSum();
$("#oben").empty().promise().done(function () {
var li = '<li data-role="list-divider" data-theme="b" data-role="heading">Ausstehend f<>r Tisch ' + tablename + '</li>'; // init a list
$("#oben").empty().append(li);
$("#oben").append('<li data-theme="f" data-icon="check"><a href="#" id="payall">Alles</a></li>');
$.each(jsonContent, function (index,aProd) {
// var queueid = jsonContent[this.id]["id"];
addToOben(aProd["prodid"],aProd["longname"],aProd["price"],aProd["pricelevelname"],index);
});
});
refreshList("#oben");
addAllToUnten(jsonContent,tablename);
}
function generateListItem(theme,icon,id,content) {
var li = '<li data-theme="' + theme + '" data-icon="' + icon + '">';
li += '<a href="#" id="' + id + '" class="info-go">' + content + '</a></li>';
return li;
}
function addAllToUnten(jsonContent,tablename) {
$("#payall").off("click").on("click", function (e) {
e.stopImmediatePropagation();
e.preventDefault();
var entryListForReceipt=new Array();
$("#oben li a.info-go").each(function() {
var id_in_jsonText = $(this).attr('id');
var prodid = jsonContent[id_in_jsonText]["prodid"];
var longname = jsonContent[id_in_jsonText]["longname"];
var price = jsonContent[id_in_jsonText]["price"];
var pricelevelname = jsonContent[id_in_jsonText]["pricelevelname"];
var entry = new Array(id_in_jsonText,prodid,longname,price,pricelevelname);
entryListForReceipt.push(entry);
});
$.each(entryListForReceipt, function (i, entry) {
var indexInJson = entry[0];
var prodid = entry[1];
var longname = entry[2];
var price = entry[2];
var pricelevelname = entry[2];
addToUnten(prodid,longname,price,pricelevelname,indexInJson);
$("#oben li .info-go").each(function() {
$(this).closest('li').remove().promise();
});
refreshList("#oben");
});
});
}
function addToOben(prodid,longname,price,pricelevelname,index) {
var jsonContent = $("#info-page").data("tableprods");
var tablename = $("#info-page").data("tablename");
if (pricelevelname != "A") {
longname += " (" + pricelevelname + ")";
}
var li_item = generateListItem("c","plus",index,longname);
$("#oben").append(li_item).promise().done(function () {
createAllEntriesInReceipt();
$(this).off("click").on("click", ".info-go", function (e) {
e.stopImmediatePropagation();
e.preventDefault();
var prodid = jsonContent[this.id]["prodid"];
var price = jsonContent[this.id]["price"];
var pricelevelname = jsonContent[this.id]["pricelevelname"];
var longname = jsonContent[this.id]["longname"];
addToUnten(prodid,longname,price,pricelevelname,this.id);
createAllEntriesInReceipt();
$(this).closest("li").remove();
refreshList("#oben");
});
});
refreshList("#oben");
}
// Make table empty...
function clearUntenAndReceipt() {
var untenHeader = '<li data-role="list-divider" data-theme="b" data-role="heading">';
untenHeader += 'Inhalt Kassenbon: <p id="priceinreceipt">0,00 Euro</p></li>';
$("#unten").empty().append(untenHeader).promise().done(function () {
refreshList("#unten");
});
$('#prodlistinreceipt tr').each(function() {
$(this).remove();
});
$("#thedate").html('<br><br>&nbsp;<br>');
}
function addToUnten(prodid,longname,price,pricelevelname,index) {
var jsonContent = $("#info-page").data("tableprods");
var tablename = $("#info-page").data("tablename");
if (pricelevelname != "A") {
longname += " (" + pricelevelname + ")";
}
var li_item = generateListItem("f","minus",index,longname);
$("#unten").append(li_item).promise().done(function () {
createAllEntriesInReceipt();
$(this).off("click").on("click", ".info-go", function (e) {
e.stopImmediatePropagation();
e.preventDefault();
var prodid = jsonContent[this.id]["prodid"];
var price = jsonContent[this.id]["price"];
var pricelevelname = jsonContent[this.id]["pricelevelname"];
var longname = jsonContent[this.id]["longname"];
addToOben(prodid,longname,price,pricelevelname,this.id);
$(this).closest("li").remove();
createAllEntriesInReceipt();
refreshList("#unten");
});
});
refreshList("#unten");
}
// 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
function addEntryOrIncreaseCount(arrayToFill,entry) {
var index=0;
var found = false;
var combinedIdAndPricelevel = entry[0] + "-" + entry[4];
for (index=0;index<arrayToFill.length;index++) {
var anEntry = arrayToFill[index];
// entry = prodid,queueid,longname,price,pricelevelname
// anEntry = count,prodid,"prodid-pricelevel",queueid,longname,price
if (anEntry[2] == combinedIdAndPricelevel) {
// prodid equal
anEntry[0] += 1;
//alert("Duplikate: " + anEntry[0]);
found = true;
}
}
if (!found) {
//alert("Adde hinzu);
arrayToFill.push(new Array(1,entry[0],combinedIdAndPricelevel,entry[1],entry[2],entry[3],entry[4]));
}
return arrayToFill;
}
function calcSum() {
var jsonContent = $("#info-page").data("tableprods");
var sum = 0.0;
var tax = parseFloat($("#info-page").data("usst"));
if ($("#info-page").data("taxtype") == "togo") {
tax = parseFloat($("#info-page").data("togotax"));
}
$("#unten li a.info-go").each(function() {
var id_in_jsonText = $(this).attr('id');
var price = jsonContent[id_in_jsonText]["price"];
sum += parseFloat(price);
});
var netto = sum/(1 + tax/100.0);
var mwst_part = sum - netto;
$("#mwst").html(mwst_part.toFixed(2).replace(".",","));
$("#netto").html(netto.toFixed(2).replace(".",","));
$("#brutto").html(sum.toFixed(2).replace(".",","));
$("#priceinreceipt").html(sum.toFixed(2).replace(".",",") + " Euro");
$("#priceinreceipt2").html(sum.toFixed(2).replace(".",",") + " Euro");
}
function createAllEntriesInReceipt() {
var jsonContent = $("#info-page").data("tableprods");
var tablename = $("#info-page").data("tablename");
var priceStyle = 'style="border: solid black 0px;padding: 3px;text-align:right;vertical-align:bottom;"';
var entryListForReceipt=new Array();
// collect all entries in the list #unten
$("#unten li a.info-go").each(function() {
//tablecontent += '<tr class="prodlistinreceipt"><td id="count" class="price">1<td>' + longname + '<td id="price" class="price">' + (eval(price)).toFixed(2) + '<td id="total" class="price">' + (eval(price)).toFixed(2) + '</tr>';
var id_in_jsonText = $(this).attr('id');
var queueid = jsonContent[id_in_jsonText]["id"];
var prodid = jsonContent[id_in_jsonText]["prodid"];
var longname = jsonContent[id_in_jsonText]["longname"];
var price = jsonContent[id_in_jsonText]["price"];
var pricelevelname = jsonContent[id_in_jsonText]["pricelevelname"];
var entry = new Array(prodid,queueid,longname,price,pricelevelname);
entryListForReceipt = addEntryOrIncreaseCount(entryListForReceipt,entry);
});
var tablecontent = createReceiptHeader();
var index=0;
for (index=0;index<entryListForReceipt.length;index++) {
var anEntry = entryListForReceipt[index];
var count = parseInt(anEntry[0]);
var prodid = anEntry[1];
var queueid = anEntry[3];
var longname = anEntry[4];
var price = parseFloat(anEntry[5]);
var pricelevelname = anEntry[6];
if (pricelevelname != "A") {
longname += " (" + pricelevelname + ")";
}
var totalPrice = count * price;
var aProductLine = '<tr>';
//aProductLine += '<td class="price" id="prodid">' + prodid;
aProductLine += '<td ' + priceStyle + ' id="count">' + count + '<td>&nbsp;<td colspan=2>' + longname;
aProductLine = aProductLine + '<td ' + priceStyle + '>' + price.toFixed(2).replace(".",",");
aProductLine += '<td ' + priceStyle + '>' + totalPrice.toFixed(2).replace(".",",") + '</tr>';
tablecontent += aProductLine;
}
var taxGerFormat = $("#info-page").data("usstGerVal");
if ($("#info-page").data("taxtype") == "togo") {
taxGerFormat = $("#info-page").data("togoTaxGerVal");
}
tablecontent += createReceiptFooter(taxGerFormat);
// now calculate everything without hosting part for later export
$('#receiptpart').html(tablecontent);
calcSum(); // updates info:
var calculatedBill = $('#receiptpart').html();
$('#info-page').data("receipthtml",calculatedBill);
// 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 priceStyle = 'style="border: solid black 0px;padding: 3px;text-align:right;vertical-align:bottom;"';
var tablename = $("#info-page").data("tablename");
var logoUrl = $("#info-page").data("logoUrl");
var header = '';
if (logoUrl.length != 0) {
header += '<tr><td colspan=6><img src="' + logoUrl + '" width=100% /></td></tr>';
}
header += '<tr><td colspan=6>&nbsp;</tr>';
header += '<tr><td colspan=4>Tisch: ' + tablename + ' <td id="billid" colspan=2 ' + priceStyle + '></tr>';
header += '<tr><td colspan=4>&nbsp;<td id="billdate" colspan=2 ' + priceStyle + '></tr>';
header += '<tr><td colspan=4>Es bedient Sie: ' + $("#loggedinuser").html() + "</tr>";
header += '<tr><td colspan=6>&nbsp</tr>';
header += '<tr><td>Anz <td>&nbsp; <td colspan=2>Beschreibung <td ' + priceStyle + '>Preis <td ' + priceStyle + '>Total </tr>';
return header;
}
function createReceiptFooter(taxGerFormat) {
var priceStyle = 'style="border: solid black 0px;padding: 3px;text-align:right;vertical-align:bottom;"';
var infoStyle = 'style="text-align:center;vertical-align:bottom;"';
var emptyLine = '<tr><td colspan=6>&nbsp</tr>';
var footer = emptyLine;
footer += '<tr><td> &nbsp; <td colspan=3>Summe: <td id="priceinreceipt2" ' + priceStyle + ' colspan=2></td></tr>';
footer += emptyLine;
footer += '<tr><td colspan=2>MwSt% <td ' + priceStyle + '>MwST <td ' + priceStyle + '>Netto <td ' + priceStyle + ' colspan=2>Brutto </tr>';
footer += '<tr><td colspan=2>' + taxGerFormat + '% <td id="mwst" ' + priceStyle + '> <td id="netto" ' + priceStyle + '><td id="brutto" ' + priceStyle + ' colspan=2> </tr>';
footer += '<tr><td ' + infoStyle + ' colspan=6><center>&nbsp;<br>';
footer += $("#info-page").data("companyInfo").replace(/(?:\r\n|\r|\n)/g, '<br />');
footer += '</center></tr>';
return footer;
}
function bindPayButton(jsonContent,tableid,tablename) {
$("#payWithoutPrint").off("click").on("click", function (e) {
e.stopImmediatePropagation();
e.preventDefault();
selectPayment(jsonContent,tableid,tablename,false);
});
$("#payWithPrint").off("click").on("click", function (e) {
e.stopImmediatePropagation();
e.preventDefault();
selectPayment(jsonContent,tableid,tablename,true);
});
}
function selectPayment(jsonContent,tableid,tablename,printoption) {
// first test if there are items to pay!
var itemsToPay = $('#unten li').size() - 1;
if (itemsToPay == 0) {
$.mobile.changePage("#nocashitems");
} else {
// start pay process by selection of payment types
$.mobile.changePage("#paymentdialog");
$("#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(jsonContent,printoption,tableid,tablename,paymentId,appliedTax);
});
}
}
function startPayProcess(jsonContent,printoption,tableid,tablename,paymentid,tax) {
var ids="";
$('#unten li').each(function() {
var index = $(this).find("a").attr("id");
if (typeof index != 'undefined') {
var queueid = jsonContent[index]["id"];
ids += queueid + ",";
}
});
// declarePaidCreateBillReturnBillId
var style = ' style="width: 30%; background-color: #cccccc;" ';
var htmlContentWithoutHosting = '<table ' + style + '>' + $('#info-page').data("receipthtml") + '</table>';
$.ajax({ type: "POST",
dataType: "json",
data : { ids: ids,
html : htmlContentWithoutHosting,
brutto: $("#brutto").html().replace(",","."),
netto: $("#netto").html().replace(",","."),
tableid : tableid,
paymentid : paymentid,
tax : tax
},
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 {
$("#billid").html("Bon-Nr: " + billid);
$("#billdate").html(billdate);
if (printoption) {
var htmlContent = "<table width=100%>" + $("#receiptpart").html() + "</table>";
var payPrintType = $("#info-page").data("payPrintType");
if (payPrintType == 's') {
printBill(htmlContent);
} else {
window.print();
}
}
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: " + msg);
}
},
error: function( text ) {
alert( "Sorry, there was a problem! " + text);
}
});
}
function printBill(htmlText) {
doAjax("POST","php/contenthandler.php?module=printqueue&command=queuePrintJob",
{content : htmlText, type: 3 }, null, "Druckfehler");
}
function bindHostButton() {
$("#hostbutton").off("click").on("click", function (e) {
e.stopImmediatePropagation();
e.preventDefault();
var statusVisibility = $("#info-page").data("hosting");
if (statusVisibility == '0') {
$("#info-page").data("hosting",'1');
} else {
$("#info-page").data("hosting",'0');
}
createAllEntriesInReceipt();
});
}
function bindTogoButton() {
$("#togobutton").off("click").on("click", function (e) {
e.stopImmediatePropagation();
e.preventDefault();
if ($("#info-page").data("taxtype") == "normal") {
$("#info-page").data("taxtype","togo");
$("#togobutton").buttonMarkup({ icon: "check"});
} else {
$("#info-page").data("taxtype","normal");
$("#togobutton").buttonMarkup({ icon: "delete"});
}
createAllEntriesInReceipt();
});
}
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(",",".");
if (isNaN(money)) {
alert("Keine Zahl!");
} else {
if (parseFloat(money) >= 0.0) {
doCashInsert(money);
} else {
alert("Betrag muss positiv 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(",",".");
if (isNaN(money)) {
alert("Keine Zahl!");
} else {
if (parseFloat(money) >= 0.0) {
doCashTakeOut(money);
} else {
alert("Betrag muss positiv 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("Kassenaktion abgeschlossen");
}
}
function showCashOverview(jsonText) {
$("#cashbyguests").html((parseFloat(jsonText.guestmoney).toFixed(2)).replace(".",","));
$("#cashtotal").html((parseFloat(jsonText.total).toFixed(2)).replace(".",","));
$.mobile.changePage("#cashoverviewinfo");
}
$(document).on("pageinit", "#info-page", function () {
initializeMainMenu("#modulemenu");
hideMenu();
getTax(); // put tax info as data to page
$("#info-page").data("taxtype","normal");
getTogoTax();
getCompanyInfo(); // request the company info and put it as data to page for later use
getLogoUrl();
getPayPrintType();
getPayments();
$("#hostingtablepart").hide();
$("#info-page").data("hosting",'0');
bindHostButton();
bindTogoButton();
cashactions();
// button in header to start paydesk
$("#startpaypage").off("click").on("click", function (e) {
e.stopImmediatePropagation();
e.preventDefault();
window.location.reload(false);
});
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];
// do not show cash actions if URL called by waiter module
$("#cashactions").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);
}
});
}
});
</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>Kasse</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">
<ul data-role="listview" id="oben" data-divider-theme="a" data-inset="true">
<li data-role="list-divider" data-theme="b" data-role="heading">Raumauswahl</li>
</ul>
<ul data-role="listview" id="cashactions" data-divider-theme="a" data-inset="true">
<li data-role="list-divider" data-theme="b" data-role="heading">Kassenaktionen</li>
<li data-theme="e"><a href="#" id="cashinsert" class="info-go cashaction">Bareinlage</a></li>
<li data-theme="e"><a href="#" id="cashtakeout" class="info-go cashaction">Barentnahme</a></li>
<li data-theme="e"><a href="#" id="cashoverview" class="info-go cashaction">Einnahmen</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">Nur Zahlung</a>
<a href="#" data-role="button" data-theme="b" data-icon="grid" id="payWithPrint">Bondruck</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>
<a href="#" data-role="button" data-theme="b" data-icon="delete" id="togobutton">To Go</a>
</div>
<div id="partForSaveInBill"> <!-- This part will be saved into bill in db -->
<table id="receiptpart" class="receipttable" border=1>
</table>
</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>Zahlungsart</h3>
<p>Auswahl der Zahlungsart</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>Bareinlage in die Kasse</h3>
<label for="stornocode">Betrag: </label>
<input type="text" id="moneyToInsert" value="" data-mini="true">
<div id=paymentlist>
<a href="#" class="sure-do" data-role="button" data-theme="b" data-rel="back">Einlegen</a>
<a href="#" data-role="button" data-theme="d" data-rel="back" id="cash_insert_cancel">Abbruch</a>
</div>
</div>
</div>
<!-- Dialog page for cash insert -->
<div data-role="dialog" id="cashtakeoutdialog" data-title="Kassenaktion">
<div data-role="content">
<h3>Barentnahme aus der Kasse</h3>
<label for="stornocode">Betrag: </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">Entnehmen</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><EFBFBD>bersicht Kellnerkasse</h3>
<p>Diese <20>bersicht enth<74>lt die Bewirtungseinnahme durch den Kellner seit der letzten Tageslosung sowie
als weiteren Wert den Kassenstand unter Ber<65>cksichtigung der eigenen Eingaben und Entnahmen.<p>
<p><i>Bewirtungseinnahmen:</i> <b><span id=cashbyguests></span></b></p>
<p><i>inkl. eigener Kassen-Eingaben/Entnahmen:</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>Keine Rechnungselemente</h3>
<p>Es wurden keine abrechenbaren Produkte festgelegt (der Bon ist leer!).<p>
<a href="#" data-role="button" data-theme="d" data-rel="back" id="nocashitems_ok">OK</a>
</div>
</div> <!-- popup nocashitems -->
</body>
</html>