102 lines
3.3 KiB
JavaScript
102 lines
3.3 KiB
JavaScript
var P_SUM = ["Summe:","Sum:","Todo:"];
|
|
var P_TOTAL = ["Total","Total","Total"];
|
|
var P_MWST = ["MwSt","Tax","IVA"];
|
|
var P_NETTO = ["Netto","Net","Neto"];
|
|
var P_BRUTTO = ["Brutto","Gross","Bruto"];
|
|
var P_ID = ["Id:","Id:","Id:"];
|
|
var P_TABLE = ["Tisch:","Table:","Mesa:"];
|
|
var P_WAITER = ["Es bediente Sie:", "Waiter:", "Camarero:"];
|
|
var P_NO = ["Anz.", "No.", "Nú."];
|
|
var P_DESCR = ["Beschreibung","Description","Descripción"];
|
|
var P_PRICE = ["Preis","Price","Precio"];
|
|
|
|
|
|
|
|
function createReceiptFooterFromDbTaxes(lang, companyInfo,sum,taxes,decPoint) {
|
|
|
|
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> </tr>';
|
|
var footer = emptyLine;
|
|
|
|
footer += '<tr><td colspan=2>' + P_MWST[lang] + '% <td ' + priceStyle + '>' + P_MWST[lang] + '<td ' + priceStyle + '>' + P_NETTO[lang] + '<td ' + priceStyle + ' colspan=2>' + P_BRUTTO[lang] + '</tr>';
|
|
|
|
for (var i=0;i<taxes.length;i++) {
|
|
var tax = taxes[i];
|
|
footer += "<tr><td colspan=2>" + tax.tax;
|
|
footer += "<td " + priceStyle + ">" + tax.mwst.replace(".",decPoint);
|
|
footer += "<td " + priceStyle + ">" + tax.netto.replace(".",decPoint);
|
|
footer += "<td colspan=2 " + priceStyle + ">" + tax.brutto.replace(".",decPoint);
|
|
footer += "</tr>";
|
|
}
|
|
|
|
footer += emptyLine;
|
|
footer += '<tr><td> <td colspan=3>' + P_SUM[lang] + '<td id="priceinreceipt2" ' + priceStyle + ' colspan=2>' + sum.toFixed(2).replace(".",decPoint) + '</td></tr>';
|
|
footer += emptyLine;
|
|
|
|
footer += '<tr><td ' + infoStyle + ' colspan=6><center> <br>';
|
|
footer += toHtml(companyInfo).replace(/(?:\r\n|\r|\n)/g, '<br />');
|
|
footer += '</center></tr>';
|
|
|
|
return footer;
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
* Generate the product part of a receipt on base of html table array elements
|
|
*
|
|
* @param decPoint
|
|
* @param entryListForReceipt
|
|
* @returns {String}
|
|
*/
|
|
function generateProdPart(decPoint,entryListForReceipt) {
|
|
var index=0;
|
|
tablecontent = '';
|
|
for (index=0;index<entryListForReceipt.length;index++) {
|
|
var anEntry = entryListForReceipt[index];
|
|
|
|
var count = parseInt(anEntry[0]);
|
|
var prodEntry = anEntry[1];
|
|
var productname = prodEntry.longname;
|
|
var price = prodEntry.price;
|
|
var togo = prodEntry.togo;
|
|
var pricelevelname = prodEntry.pricelevelname;
|
|
|
|
tablecontent += generateOneProdLine(count,productname,price,pricelevelname,decPoint,togo);
|
|
}
|
|
return tablecontent;
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
* Generate HTML output on base of db content
|
|
*/
|
|
function generateHtmlBillFromScratch(lang,billid,billcontent,currency,decPoint,companyInfo,hosthtml,guestinfo) {
|
|
var table = '<table id="receiptpart" class="receipttable" border=1 style="table-layout: fixed;">';
|
|
|
|
var overallinfo = billcontent.billoverallinfo;
|
|
var prods = billcontent.products;
|
|
|
|
var username = overallinfo.username;
|
|
var tablename = overallinfo.table;
|
|
|
|
var header = genCreateReceiptHeader(lang,billid,tablename,username,currency,guestinfo);
|
|
|
|
var products = generateProdPartByDbContent(decPoint,prods);
|
|
|
|
var sum = parseFloat(overallinfo.brutto);
|
|
|
|
var footer = createReceiptFooterFromDbTaxes(lang, companyInfo,sum,billcontent.taxes,decPoint);
|
|
|
|
var receipt = table + header + products + footer;
|
|
if (overallinfo.host == 1) {
|
|
receipt += hosthtml;
|
|
}
|
|
|
|
receipt += "</table>";
|
|
return receipt;
|
|
}
|