ordersprinter/webapp/bill.html

502 lines
18 KiB
HTML
Raw Normal View History

2020-11-19 22:47:44 +01:00
<html>
<head>
<title>Ansicht Kassenbons</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="content-type" content="text/html; charset=utf-8">
2020-11-19 22:48:24 +01:00
<meta name="author" content="Stefan Pichel">
2020-11-19 22:47:44 +01:00
2020-11-19 22:59:54 +01:00
<link rel="stylesheet" type="text/css" href="css/bestformat.css?v=1.2.2">
2020-11-19 22:47:44 +01:00
<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" />
<link rel="stylesheet" href="php/3rdparty/jquerymobiledatepicker/jquery.mobile.datepicker.css" />
<script src="php/3rdparty/jquerymobiledatepicker/jquery.mobile.datepicker.js"></script>
2020-11-19 22:52:25 +01:00
<script src="php/3rdparty/jquery-1.11.3.min.js"></script>
<script src="php/3rdparty/jquery.mobile-1.4.5.min.js"></script>
<link rel="stylesheet" href="php/3rdparty/jqueryui1-11-4/jquery-ui.min.css" />
<script src="php/3rdparty/jqueryui1-11-4/jquery-ui.min.js"></script>
<script src="php/3rdparty/jqueryui1-11-4/jquery-ui-i18n.min.js"></script>
2020-11-19 22:47:44 +01:00
<script src="utilities.js"></script>
<script src="receiptutils.js"></script>
<style>
@media handheld
{
.receipttable {width: 100%; background-color: #cccccc;}
}
@media all
{
.receipttable {width: 100%; background-color: #cccccc;}
}
@media all
{
#colWithBillOverview { vertical-align:top;}
}
@media all
{
#receiptbill {display: none;}
}
@media print
{
.receipttable {width: 100%;};
}
@media print
{
#receiptbill {width: 100%; display: block;};
}
@media print
{
#theheader,#modulemenu,#billlist,#thefooterr,#updatebtn,#datepickerarea {display: none;}
}
</style>
</head>
<body>
<script>
var BILL_TABLE = ["Tisch","Table","Mesa"];
var BILL_UPDATE = ["Aktualisieren","Update","Actualizar"];
var BILL_PRINT = ["Drucken","Print","Imprimir"];
var BILL_STORNO = ["Storno","Cancel","Contrapartida"];
var BILL_CLOSED = ["abgeschlossen","closed","cerrado"];
2020-11-19 22:55:20 +01:00
var BILL_DO_HOST = ["Bewirtungsbeleg","Guest receipt","Tique de invitados"];
var BILL_UNDO_HOST = ["Rückgängig Bewirtungsbeleg","Undo guest receipt","No tique de invitados"];
2020-11-19 22:47:44 +01:00
var BILL_TITLE = ["Kassenbons","Receipts","Tiques"];
var BILL_YES = ["Ja","Yes","Si"];
var BILL_NO = ["Nein","No","No"];
var BILL_STORNO_QUEST_TITLE = ["Storno?","Cancel?","Contrapartida?"];
var BILL_STORNO_QUEST_TEXT = ["Bon stornieren?","Cancel the receipt?","Contrapartida del tique"];
var BILL_NO_CANCEL_POSS = ["Der Stornovorgang ist fehlgeschlagen. Die wahrscheinlichste Ursache ist ein Tagesabschluss, der den zu stornierenden Bon einschließt. In diesem Fall darf der Bon rückwirkend nicht mehr annuliert werden.",
"Cancelling was not possible. Probably the receipt to cancel is already part of a closing. In this case the receipt cannot be cancelled.",
"Contrapartida no fue posible. Probablemente el tique esta ya cerrado."];
var BILL_DATE = ["Datum","Date","Fecha"];
2020-11-19 22:52:25 +01:00
var BILL_STORNO_REASON = ["Stornogrund","Reason","Razón"];
2020-11-19 22:55:20 +01:00
var BILL_TOGGLE_HOST = ["Der ursprüngliche Bon wurde storniert und mit geänderter Bewirtungseigenschaft neu angelegt. Er befindet sich an erster Stelle in der Bonliste.",
"Der original receipt was discarded and recreated with the changed guest receipt property. The new receipt is on top of the list",
"El tique original esta descartado y iniciado de nuevo en la forma modificada"];;
2020-11-19 22:59:47 +01:00
var BILL_WRONG_FORMAT = ["Falsches Zahlenformat","Wrong number format","Formato de precio incorecto"];
var BILL_FIRST_JOB = ["Erste Bon-ID","First job id","Id primero"];
var BILL_LAST_JOB = ["Letzte Bon-ID","Last job id","Id último"];
var BILL_BATCH = ["Stapelverarbeitung","Batch processing","Accion con muchos elementos"];
2020-11-19 22:47:44 +01:00
var lang = 0;
var when = 0;
var decpoint = ".";
// REM* contains the bill information from server
var jsonBills = "";
function setLanguage(language) {
lang = language;
$("#updatebtntxt").html(BILL_UPDATE[lang]);
$("#billtitletxt").html(BILL_TITLE[lang]);
$("#stornoyes").html(BILL_YES[lang]);
$("#stornono").html(BILL_NO[lang]);
$("#billnocancelposs").html(BILL_NO_CANCEL_POSS[lang]);
$("#datetxt").html(BILL_DATE[lang]);
2020-11-19 22:52:25 +01:00
$("#stornoreasontxt").html(BILL_STORNO_REASON[lang]);
2020-11-19 22:59:47 +01:00
$("#printjobstxt").html(BILL_PRINT[lang]);
$("#fromjobidtxt").html(BILL_FIRST_JOB[lang]);
$("#tojobidtxt").html(BILL_LAST_JOB[lang]);
$("#batchheadertxt").html(BILL_BATCH[lang]);
2020-11-19 22:47:44 +01:00
var langtxt = "de";
if (lang == 1) {
langtxt = "en";
} else if (lang == 2) {
langtxt = "es";
}
var currentYear = new Date().getFullYear();
var yearRangeTxt = (currentYear-5) + ":" + (currentYear);
$("#datepicker").datepicker($.datepicker.regional[langtxt]).datepicker("option", {
changeMonth: true,
changeYear: true,
yearRange: yearRangeTxt,
});
$('#datepicker').datepicker('setDate', new Date());
}
function updatelistener() {
$("#updatebtn").off("click").on("click", function (e) {
e.stopImmediatePropagation();
e.preventDefault();
getLastBills();
});
}
2020-11-19 22:59:47 +01:00
function batchjoblistener() {
$("#printjobsbtn").off("click").on("click", function (e) {
e.stopImmediatePropagation();
e.preventDefault();
var start = $("#fromjobidfield").val();
var end = $("#tojobidfield").val();
if (!isInt(start) || !isInt(end)) {
alert(BILL_WRONG_FORMAT[lang]);
return;
}
doAjax("POST","php/contenthandler.php?module=printqueue&command=batchReceiptPrintJob",{start : start, end:end }, handleBatchResult, null);
});
}
function handleBatchResult(answer) {
if (answer.status != "OK") {
alert("Fehler " + answer.code + ": " + answer.msg);
} else {
$("#fromjobidfield").val("");
$("#tojobidfield").val("");
}
}
2020-11-19 22:47:44 +01:00
function getLastBills() {
var date = $("#datepicker").datepicker("getDate");
var data = {
day: date.getDate(),
month: (date.getMonth() + 1),
year: date.getFullYear(),
};
doAjax("GET","php/contenthandler.php?module=bill&command=getLastBillsWithContent",data,displayBillsWithContent,"letzte Bons");
}
2020-11-19 22:52:25 +01:00
function doAjaxCancelBill(billid,stornocode,reason) {
2020-11-19 22:47:44 +01:00
var data = {
billid: billid,
2020-11-19 22:52:25 +01:00
stornocode: stornocode,
reason:reason.trim()
2020-11-19 22:47:44 +01:00
};
doAjax("POST","php/contenthandler.php?module=bill&command=cancelBill",data,cancelBill,"Bonstorno abgebrochen");
}
function cancelBill(jsonText) {
if (jsonText.status != "OK") {
alert("Fehler " + jsonText.code + ": " + jsonText.msg);
2020-11-19 22:52:25 +01:00
return;
2020-11-19 22:47:44 +01:00
}
setTimeout(function(){location.reload()},1000);
}
2020-11-19 22:55:20 +01:00
function changeHostBill(jsonText) {
if (jsonText.status != "OK") {
alert("Fehler " + jsonText.code + ": " + jsonText.msg);
return;
}
alert(BILL_TOGGLE_HOST[lang]);
setTimeout(function(){location.reload()},1000);
}
2020-11-19 22:47:44 +01:00
function displayBillsWithContent (jsonContent) {
if (jsonContent.status != "OK") {
$("#billlist").html("");
$('#billlist').trigger('create');
alert("Fehler " + jsonContent.code + ": " + jsonContent.msg);
return;
}
jsonBills = jsonContent;
$("#billlist").html("");
var currency = $("#bill-page").data("currency");
var txt = "";
jsonContent = jsonContent.msg;
for (var i=0;i<jsonContent.length;i++) {
var entry = jsonContent[i];
var id = entry.id;
var shortdate = entry.shortdate;
var longdate = entry.longdate;
var tablename = entry.tablename;
var brutto = (entry.brutto).replace(".",decpoint);
var collapse_elem_id = 'collapse_' + id;
var collapse_elem = '<div data-role="collapsible" data-content-theme="e" id="'+collapse_elem_id+'" data-collapsed="true" data-theme="c" class="billcollapsible">';
var header = '<h3>'+shortdate + ": " + BILL_TABLE[lang] + " &lt;" + tablename + "&gt; " + brutto + ' ' + currency + '</h3>';
if (entry.isClosed == 1) {
header = '<h3>'+shortdate + ": " + BILL_TABLE[lang] + " &lt;" + tablename + "&gt; " + brutto + ' ' + currency + ' -' + BILL_CLOSED[lang] + '-</h3>';
}
var waitTxt = '<p><img src=php/3rdparty/images/ajax-loader.gif /></p>';
txt += collapse_elem + header + waitTxt + "</div>";
}
$("#billlist").html(txt);
$('#billlist').trigger('create');
$(".billcollapsible").off("collapsibleexpand").on("collapsibleexpand", function (e) {
e.stopImmediatePropagation();
e.preventDefault();
var billid = this.id.split("_")[1];
var bill = getBillWithId(billid);
// REM* insert now the bill into collapsible_billid
$("#collapse_" + billid + " p").html(bill[0]);
var entry = bill[2];
var date_time = bill[1];
var longdate = entry.longdate;
var printbuttonid = 'print_' + billid;
var cancelbuttonid = 'cancel_' + billid;
$("#collapse_" + billid).find("#billdate").html(date_time);
var contentToPrint = new Array(id,longdate,bill[0]);
$("#" + printbuttonid).data("entrydata", contentToPrint);
if (entry.isClosed == 0) {
$("#" + cancelbuttonid).data("billid", id);
}
$("#collapse_" + billid).trigger("create");
$(".printbuttons").off("click").on("click", function (e) {
var billid = this.id.split("_")[1];
var contentToPrint = $("#print_" + billid).data("entrydata");
$("#receiptbill").html(contentToPrint[2]);
$("#receiptbill table").css('width', '100%');
$("#receiptbill").find("#billdate").html(contentToPrint[1]);
$("#receiptbill").find("#billid").html(contentToPrint[0]);
var payPrintType = $("#bill-page").data("payPrintType");
if (payPrintType == 's') {
printBill(billid);
} else {
window.print();
}
});
$(".cancelbuttons").off("click").on("click", function (e) {
var billid = this.id.split("_")[1];
2020-11-19 22:52:25 +01:00
$("#stornocode").val("");
$("#stornoreason").val("");
2020-11-19 22:47:44 +01:00
areYouSure(BILL_STORNO_QUEST_TITLE[lang], BILL_STORNO_QUEST_TEXT[lang], BILL_YES[lang], function() {
2020-11-19 22:52:25 +01:00
doAjaxCancelBill(billid,$("#stornocode").val(),$("#stornoreason").val());
2020-11-19 22:47:44 +01:00
});
});
2020-11-19 22:55:20 +01:00
$(".changehostbuttons").off("click").on("click", function (e) {
var billid = this.id.split("_")[1];
var isNowHost = this.id.split("_")[2];
$("#stornocode").val("");
$("#stornoreason").val("");
var data = {
billid: billid,
isNowHost: isNowHost
};
doAjax("POST","php/contenthandler.php?module=bill&command=changeBillHost",data,changeHostBill,"Bonänderung abgebrochen");
});
2020-11-19 22:47:44 +01:00
});
}
function getBillWithId(id) {
var logoUrl = $("#bill-page").data("logourl");
var companyInfo = $("#bill-page").data("companyinfo");
var currency = $("#bill-page").data("currency");
var hosthtml = jsonBills.hosthtml;
var bills = jsonBills.msg;
// get entry with that billid
var entry = null;
for (var i=0;i<bills.length;i++) {
if (bills[i].id == id) {
entry = bills[i];
break
}
}
if (entry == null) {
alert("ERROR - Rechnung mit ID " + id + " konnte nicht gefunden werden");
return;
}
var content = generateHtmlBillFromScratch(lang,id,entry.billcontent,currency,decpoint,companyInfo,hosthtml);
var printbuttonid = 'print_' + id;
var cancelbuttonid = 'cancel_' + id;
2020-11-19 22:55:20 +01:00
var changehostbuttonid = 'changehost_' + id + "_" + entry.host;
2020-11-19 22:47:44 +01:00
var collapse_elem_id = 'collapse_' + id;
var printbutton = '<a href="#" data-role="button" id="' + printbuttonid + '" data-theme="f" class="printbuttons">' + BILL_PRINT[lang] + '</a>';
var cancelButton = '<a href="#" data-role="button" id="' + cancelbuttonid + '" data-theme="f" class="cancelbuttons">' + BILL_STORNO[lang] + '</a>';
2020-11-19 22:55:20 +01:00
var toggleHostTxt = BILL_DO_HOST[lang];
if (entry.host == 1) {
toggleHostTxt = BILL_UNDO_HOST[lang];
}
var changehostbutton = '<a href="#" data-role="button" id="' + changehostbuttonid + '" data-theme="f" class="changehostbuttons">' + toggleHostTxt + '</a>';
2020-11-19 22:47:44 +01:00
var bi = entry.billcontent.billoverallinfo;
var date_time = bi.billday + "." + bi.billmonth + "." + bi.billyear + " " + bi.billhour + ":" + bi.billmin;
var txt = '<center>' + printbutton;
if (entry.isClosed == 0) {
// REM* bill is not closed - so can be printed AND cancelled
2020-11-19 22:55:20 +01:00
txt += cancelButton + changehostbutton + '<br>' + content + '</center>';
2020-11-19 22:47:44 +01:00
} else {
// REM* bill is closed - only printing possible, no cancelling
txt += '<p><center>' + '<br>' + content + '</center>';
}
return [txt,date_time,entry];
}
function printBill(billid) {
doAjax("POST","php/contenthandler.php?module=printqueue&command=queueReceiptPrintJob",
2020-11-19 22:59:50 +01:00
{billid : billid , useaddrecprinter: 0}, null, "Druckfehler");
2020-11-19 22:47:44 +01:00
}
function areYouSure(text1, text2, button, callback) {
$("#sure .sure-1").text(text1);
$("#sure .sure-2").text(text2);
2020-11-19 22:52:25 +01:00
$("#sure .sure-do").text(button).off("click.sure").on("click.sure", function(e) {
e.stopImmediatePropagation();
e.preventDefault();
$("#nocancelbtn").off("click");
$( "#sure" ).dialog( "close" );
$.mobile.changePage("#bill-page");
2020-11-19 22:47:44 +01:00
callback();
$(this).off("click.sure");
});
2020-11-19 22:52:25 +01:00
$("#nocancelbtn").off("click").on("click", function (e) {
e.stopImmediatePropagation();
e.preventDefault();
$("#sure .sure-do").text(button).off("click.sure");
$( "#sure" ).dialog( "close" );
$.mobile.changePage("#bill-page");
});
2020-11-19 22:47:44 +01:00
$.mobile.changePage("#sure");
}
function getGeneralConfigItems() {
doAjax("GET", "php/contenthandler.php?module=admin&command=getGeneralConfigItems", null, insertGenConfigStartRest, "Fehler Konfigurationsdaten");
}
function insertGenConfigStartRest(configResult) {
if (configResult.status == "OK") {
var values = configResult.msg;
$("#bill-page").data("payPrintType",values.payprinttype);
$("#bill-page").data("currency",values.currency);
$("#bill-page").data("billanguage",values.billlanguage);
$("#bill-page").data("logourl",values.logourl);
$("#bill-page").data("companyinfo",values.companyinfo);
decpoint = values.decpoint;
setLanguage(values.userlanguage);
getLastBills();
updatelistener();
2020-11-19 22:59:47 +01:00
batchjoblistener();
2020-11-19 22:47:44 +01:00
bindWhenSelection();
2020-11-19 22:59:47 +01:00
if (values.payprinttype == "s") {
// REM* only then allow batch processing
$("#batchpanel").show();
}
2020-11-19 22:47:44 +01:00
} else {
setTimeout(function(){document.location.href = "index.html"},250); // not logged in
}
}
function bindWhenSelection() {
$("#datepicker").off("change").on("change", function (e) {
var date = $("#datepicker").datepicker("getDate");
getLastBills();
updatelistener();
bindWhenSelection();
});
}
//pageinit event for first page
//triggers only once
//write all your on-load functions and event handlers pertaining to page1
$(document).on("pageinit", "#bill-page", function () {
initializeMainMenu("#modulemenu");
hideMenu();
$.ajaxSetup({ cache: false });
getGeneralConfigItems();
2020-11-19 22:59:47 +01:00
$("#fromjobidfield").val("");
$("#tojobidfield").val("");
2020-11-19 22:47:44 +01:00
});
</script>
<div data-role="page" id="bill-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">
2020-11-19 22:59:47 +01:00
<li data-role="list-divider" data-theme="b">Module</li>
2020-11-19 22:47:44 +01:00
</ul>
</div><!-- /panel -->
<div data-role="header" data-theme="b" data-position="fixed" id="theheader">
<h1><span id="billtitletxt">Kassenbons</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"><span id="modulstxt2">Module</span></a>
</div>
</div>
<div data-role="content">
<div data-role="fieldcontain" id="datepickerarea">
<label for="datepicker"><span id=datetxt>Datum</span>: </label>
<input data-role="date" data-inline="true" type="text" id="datepicker" data-theme="d">
</div>
<a href="#" data-role="button" data-theme="f" id="updatebtn"><span id="updatebtntxt">Aktualisieren</span></a>
<br><br>
<div id=billlist></div>
2020-11-19 22:59:47 +01:00
<div id="batchpanel" data-role="collapsible" data-collapsed="false" data-theme="e" data-content-theme="c" style="display:none;">
<h3><span id="batchheadertxt">Stapelverarbeitung</span></h3>
<p>
<form>
<span id="fromjobidtxt">Erste Bon-ID:</span><input type="text" id="fromjobidfield" style="background-color:white;"/><br>
<span id="tojobidtxt">Letzte Bon-ID:</span><input type="text" id="tojobidfield" style="background-color:white;" /><br>
<a href="#" data-role="button" data-icon="check" id="printjobsbtn" data-theme="f"><span id="printjobstxt">Drucken</span></a>
</form>
</div>
2020-11-19 22:47:44 +01:00
<div id=receiptbill></div>
</div>
<div data-role="footer" data-theme="b" id="thefooterr">
<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 -->
2020-11-19 22:59:47 +01:00
<div data-role="popup" id="cancelfailed" data-overlay-theme="a" style="max-width:70%;" class="ui-corner-all">
2020-11-19 22:47:44 +01:00
<div data-role="header" class="ui-corner-top">
<h1>Storno fehlgeschlagen</h1>
</div>
<a href="#" data-rel="back" data-role="button" data-theme="a" data-icon="delete" data-iconpos="notext" class="ui-btn-right"></a>
<div data-role="content" class="ui-corner-bottom ui-content">
<p><span id="billnocancelposs">Der Stornovorgang ist fehlgeschlagen. Die wahrscheinlichste Ursache ist ein Tagesabschluss, der den zu
stornierenden Bon einschließt. In diesem Fall darf der Bon rückwirkend nicht mehr annuliert werden.</span></p>
</div>
</div> <!-- popup for reading sample queue data -->
</div>
<!-- Dialog page -->
<div data-role="dialog" id="sure" data-title="Entfernen?">
<div data-role="content">
<h3 class="sure-1">?</h3>
<p class="sure-2">?</p>
<form>
2020-11-19 22:52:25 +01:00
<label for="stornoreason"><span id="stornoreasontxt">Stornogrund:</span></label>
<input type="text" id="stornoreason" value="" data-mini="true /">
<label for="stornocode">Stornocode: </label>
<input type="password" id="stornocode" value="" data-mini="true">
<a href="#" class="sure-do" data-role="button" data-theme="b" data-rel="back"><span id="stornoyes">Ja</span></a>
<a href="#" data-role="button" data-theme="c" id="nocancelbtn"><span id="stornono">Nein</span></a>
2020-11-19 22:47:44 +01:00
</form>
</div>
</div>
</body>
</html>