ordersprinter/webapp/products.html

957 lines
33 KiB
HTML

<html>
<head>
<title>Ansicht Produkte</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.29">
<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="elements/product.js"></script>
<script src="elements/extra.js"></script>
</head>
<body>
<script>
var PROD_YES = ["Ja","Yes","Si"];
var PROD_NO = ["Nein","No","No"];
var PROD_NEW_PROD = ["Neues Produkt","New product","Nuevo producto"];
var PROD_NO_TONE = ["Kein Ton","No audio","Ningún sonido"];
var PROD_PRICE = ["Preis","Price","Precio"];
var PROD_TAX = ["Steuersatz immer","Tax always","Impuesto siempre"];
var PROD_SHORTNAME = ["Kurzname:","Short name:","Nombre corto"];
var PROD_LONG_NAME = ["Langname:","Long name:","Nombre largo"];
var PROD_AVAILABLE = ["Verfügbar","Available","Disponible"];
var PROD_FAVORITE = ["Favorit","Favorite","Favorito"];
var PROD_APPLY = ["Anwenden","Apply","Aplicar"];
var PROD_CANCEL = ["Abbrechen","Cancel","Cancelar"];
var PROD_PRICELEVEL = ["Preisstufe: ","Price level: ","Nivel de precio: "];
var PROD_TYPE = ["Art","Type","Typo"];
var PROD_KITCHEN_BAR = ["Küche/Bar","Kitchen/Bar","Cocina/Bar"];
var PROD_SUPPLY = ["Bereitstellung","Provision","Preparados"];
var PROD_NAME = ["Name:","Name:","Nombre:"];
var PROD_FOOD = ["Speisen","Food","Comidas"];
var PROD_DRINKS = ["Getränke","Beverage","Bebidas"];
var PROD_PASS_KITCHEN = ["Durchlaufe Küche/Bar","Pass kitchen/bar","Pasar cocina/bar"];
var PROD_NO_PASS_KITCHEN = ["Küche/Bar nicht durchlaufen","Do not pass kitchen/bar","No pasar cocina/bar"];
var PROD_PASS_SUPPLY = ["Durchlaufe Bereitstellung","Pass supplydesk","Pasar punto >preparado<"];
var PROD_NO_PASS_SUPPLY = ["Bereitstellung nicht durchlaufen","Do not pass supplydesk","No pasar punto >preparado<"];
var PROD_NEW_CAT = ["Neue Kategorie","New category","Nueva categoría"];
var PROD_ASSIGN = ["Produkt zuweisen","Assign product","Asignar producto"];
var PROD_TITLE = ["Angebot","Products","Productos"];
var PROD_ENTER_CAT_NAME = ["Name der neuen Produktkategorie eingeben!","Enter name of new category!","Ningún nombre de la categoría nueva insertado!"];
var PROD_WRONG_FORMAT = ["Falsches Zahlenformat oder fehlender Eintrag!","Wrong number format or missing entry!","Formato falso o ningún dato!"];
var PROD_MAX_PRICE_EXCEEDED = ["Der Maximalwert für einen Preis wurde überschritten!","The max. value for a price is exceeded!","El valor de un precio es más que el maximum!"];
var PROD_COMMENTS = ["Diese Bemerkungen können bei einer Bestellung zu jedem Produkt hinzugefügt werden.","These remarks can be added to each product during ordering.","Durante ordenar estos commentarios se puede añadido a cada producto."];
var PROD_COMMENT = ["Bemerkungen","Remarks","Comentarios"];
var PROD_DEL = ["Löschen","Delete","Removar"];
var PROD_EXTRAS = ["Extras/Optionen","Add-ons/Options","Opciones"];
var PROD_ASS_EXTRAS = ["Zuweisung Extras/Optionen","Assign Add-ons/Options","Asignar opciones"];
var PROD_ENTER_VALUES = ["Leere Datenfelder sind nicht erlaubt","Empty fields not allowed","Necesitamos valores"];
var PROD_MENU = ["Speisekarte","Menu","Menú"];
var PROD_DO_ASS = ["Zuweisung","Assignment","Asignar"];
var PROD_ASSIGN_EXTRAS_ALL = ["Extras allen Produkten dieser Kategorie zuweisen:","Assign extras to all products of this type:","Asignar extra a todos los productos en este grupo:"];
var PROD_PRINTER = ["Drucker","Printer","Imrpimadora"];
var PROD_PRINTER_1 = ["Drucker 1","Printer 1","Imprimadora 1"];
var PROD_PRINTER_2 = ["Drucker 2","Printer 2","Imprimadora 2"];
var PROD_PLACEHOLDER_NEW_PRODTYPE = ["Name der neuen Kategorie", "Name of the new category","Nombre de la categoría nueva"];
var decpoint = ".";
var lang = 0;
var p_allprods = [];
var menu;
var prodtypes = [];
var prodleafs = [];
var audiofiles;
var p_allextras = [];
var p_currenttypeid = null;
function setLanguage(language) {
lang = language;
$("#prodtitletxt").html(PROD_TITLE[lang]);
$("#assignheader").html(PROD_ASSIGN[lang]);
$("#extrasheader").html(PROD_EXTRAS[lang]);
$("#menuheader").html(PROD_MENU[lang]);
}
function getAudioFiles() {
doAjax("GET","php/contenthandler.php?module=products&command=getAudioFiles",null,setAvailableAudioFiles,"keine Audiofiles-Info bekommen");
}
function setAvailableAudioFiles(audioFiles) {
this.audiofiles = audioFiles;
$("#info-page").data("audioFiles",audioFiles);
showDbProducts();
}
function showDbProducts() {
doAjax("GET","php/contenthandler.php?module=products&command=getAllAvailProdsAlphaSorted",null,saveProdsGetHierarchy,"keine Produktinformation bekommen");
}
function saveProdsGetHierarchy(prods) {
p_allprods = prods;
doAjax("GET","php/contenthandler.php?module=products&command=getMenu&ref=0",null,saveMenu,"keine Produkthierarchyinformation bekommen");
}
function saveMenu(jsonMenu) {
menu = jsonMenu;
var tablestructure = createMenuTableStructure(menu);
$("#menulist").html(tablestructure);
fillListTableWithContent();
$("#menulist").trigger("create");
cmdBinding();
}
function createMenuTableStructure(menu) {
if (menu.status != "OK") {
return;
}
var content = menu.msg;
prodleafs = [];
prodtypes = [];
var txt = "";
var ct = content.currentType;
if (ct != null) {
$("#goupimg_0").show();
p_currenttypeid = ct.id;
var prodtype = createProdType(ct.id,ct.name,ct.kind,ct.usekitchen,ct.usesupplydesk,ct.printer);
prodtypes[prodtypes.length] = prodtype;
txt += prodtype.createUpperMenuTypeStructure();
} else {
$("#goupimg_0").hide();
p_currenttypeid = null;
}
var it = content.containedTypes;
if (it != null) {
var i=0;
for (i=0;i<it.length;i++) {
var aType = it[i];
var name = aType.name;
var id = aType.id;
txt += '<button id="gotoprodtype_' + id + '" type="submit" data-theme="e" class="oscmd">' + name + ' &rArr;</button>';
}
}
var pt = content.containedProds;
if (pt != null) {
var i=0;
for (i=0;i<pt.length;i++) {
var prod = pt[i];
var aProduct = newProduct(prod.id,prod.longname,prod.shortname,prod.priceA,prod.priceB,prod.priceC,prod.tax,prod.available,prod.audio,prod.favorite);
prodleafs[prodleafs.length] = aProduct;
txt += aProduct.createListStructureLine(audiofiles);
}
if (ct != null) {
var dummyPrice = "0.00".replace(".",decpoint);
var aProduct = newProduct("n" + ct.id,"","",dummyPrice,dummyPrice,dummyPrice,"null",1,"",0);
prodleafs[prodleafs.length] = aProduct;
txt += aProduct.createListStructureLine(audiofiles);
}
}
if (ct != null) {
txt += prodtype.createLowerMenuTypeStructure();
}
return txt;
}
function fillListTableWithContent() {
var i=0;
for (i=0;i<prodtypes.length;i++) {
var aProdType = prodtypes[i];
aProdType.insertValuesIntoMenuList();
}
for (i=0;i<prodleafs.length;i++) {
var aProd = prodleafs[i];
aProd.insertValuesIntoMenuList();
}
$("#shortnameheader").data("text",$("#shortnameheader").html());
$(".prodheader").data("visi",1);
}
function extraBinding() {
$(".extracmd").off("click").on("click", function (e) {
e.stopImmediatePropagation();
e.preventDefault();
var cmd = (this.id.split("_"))[0];
var objid = (this.id.split("_"))[1];
if (cmd == 'newextra') {
createNewExtra();
} else if (cmd == 'delextra') {
delExtra(objid);
} else if (cmd == 'applyextra') {
applyExtra(objid);
}
});
}
function cmdBinding() {
$(".oscmd").off("click").on("click", function (e) {
e.stopImmediatePropagation();
e.preventDefault();
var cmd = (this.id.split("_"))[0];
var objid = (this.id.split("_"))[1];
if (cmd == "prodcancel") {
prodcancel(objid);
} else if (cmd == "prodapply") {
prodapply(objid);
} else if (cmd == "prodnew") {
prodnew(objid);
} else if (cmd == "produp") {
produp(objid);
} else if (cmd == "proddown") {
proddown(objid);
} else if (cmd == "proddel") {
proddel(objid);
} else if (cmd == "newtype") {
typenew(objid);
} else if (cmd == "typeapply") {
typeapply(objid);
} else if (cmd == "typecancel") {
typecancel(objid);
} else if (cmd == "typedel") {
typedelete(objid);
} else if (cmd == 'assignprod') {
assignStart(objid);
} else if (cmd == 'gotoprodtype') {
gotoprodtype(objid);
} else if (cmd == 'goupimg') {
goupprodtype();
} else if (cmd == 'prodextrainput') {
doAjax("GET","php/contenthandler.php?module=products&command=getAssignedExtrasOfProd&prodid=" + objid,null,handleAssignedExtras,"Zugewiesene Optionen");
}
});
}
function areEqual(arr1,arr2) {
if (arr1.length != arr2.length) {
return false;
}
for (var i=0;i<arr1;i++) {
if (arr2.indexOf(arr1[i]) < 0) {
return false;
}
}
return true;
}
function handleAssignedExtras(res) {
if (res.status != "OK") {
return;
}
var msg = res.msg;
var prodid = res.prodid;
$("#prodextra_" + prodid).data("orig_assignedextras",msg.slice(0));
handleAssignedExtrasCore(msg.slice(0),res.prodid);
}
function handleAssignedExtrasCore(msg,prodid) {
$("#prodextra_" + prodid).data("assignedextras",msg);
var aList = '<ul data-role="listview" data-divider-theme="a" data-inset="true">';
aList += '<li data-role="list-divider" data-theme="b" data-role="heading">' + PROD_EXTRAS[lang] + '</li>';
var i=0;
for (i=0;i<p_allextras.length;i++) {
var anExtra = p_allextras[i];
var extraid = anExtra.id;
var name = toHtml(anExtra.name);
if (msg.indexOf(extraid) >= 0) {
aList += '<li data-theme="f" data-icon="check"><a href="#" class="extradlgitem" id="prodextra_'+ extraid + '_' + prodid + '">' + name + '</a></li>';
} else {
aList += '<li data-theme="e" data-icon="plus"><a href="#" class="extradlgitem" id="prodextra_'+ extraid + '_' + prodid + '">' + name + '</a></li>';
}
}
aList += "</ul>";
aList += '<div data-role="fieldcontain">';
aList += '<fieldset data-role="controlgroup">';
aList += '<legend>' + PROD_ASSIGN_EXTRAS_ALL[lang] + '</legend>';
aList += '<input type="checkbox" name="extrassignall_' + prodid + '" id="extrassignall_' + prodid + '"/>';
aList += '<label for="extrassignall_' + prodid + '">' + PROD_YES[lang] + '</label>';
aList += '</fieldset></div>';
$("#assextralist_" + prodid).html(aList);
$("#assextralist_" + prodid).trigger("create");
$(".extradlgitem").off("click").on("click", function (e) {
e.stopImmediatePropagation();
e.preventDefault();
var splits = this.id.split("_");
var extraid = splits[1];
var prodid = splits[2];
var msg = $("#prodextra_" + prodid).data("assignedextras");
if (msg.indexOf(extraid) >= 0) {
msg.splice(msg.indexOf(extraid),1);
} else {
msg[msg.length] = extraid;
}
handleAssignedExtrasCore(msg,prodid);
});
}
function goupprodtype() {
doAjax("GET","php/contenthandler.php?module=products&command=getMenuLevelUp&ref=" + p_currenttypeid,null,saveMenu,"keine Produkthierarchyinformation bekommen");
}
function gotoprodtype(id) {
doAjax("GET","php/contenthandler.php?module=products&command=getMenu&ref=" + id,null,saveMenu,"keine Produkthierarchyinformation bekommen");
}
function assignStart(typeid) {
var txt = "<select>";
var i=0;
for (i=0;i<p_allprods.length;i++) {
var aProd = p_allprods[i];
var id = aProd.id;
var longname = aProd.longname;
var cat = aProd.category;
if (cat != typeid) {
txt += "<option value=" + id + ">" + toHtml(longname) + "</option>";
}
}
txt += "</select>";
$("#assprodlist").html(txt);
$("#assigndialog").trigger("create");
$("#assprodlist").data("typeid",typeid);
$.mobile.changePage("#assigndialog");
$("#assignprodbtnaftersel").off("click").on("click", function (e) {
e.stopImmediatePropagation();
e.preventDefault();
var theType = $("#assprodlist").data("typeid");
var prodid = $( "#assprodlist option:selected").val();
var data = {
productid : prodid,
typeid : theType
};
doAjax("POST","php/contenthandler.php?module=products&command=reassign",data,reloadPageWithTimeout,"Produkt nicht zuweisbar");
});
}
function prodcancel(prodid) {
var url = "php/contenthandler.php?module=products&command=getSingleProdData&id=" + prodid;
$("#assextralist_" + prodid).html("");
$("#assextralist_" + prodid).trigger("create");
actionOnProd(url,prodid,null);
}
function parsePricesAndProperties(prodid) {
var longname = $("#prodlong_input_" + prodid).val();
var shortname = $("#prodshort_input_" + prodid).val();
var priceA = $("#prodpriceA_input_" + prodid).val().trim();
var priceB = $("#prodpriceB_input_" + prodid).val().trim();
var priceC = $("#prodpriceC_input_" + prodid).val().trim();
var tax = $("#prodtax_input_" + prodid).val().trim();
if (tax == "") {
tax = "null";
} else {
tax = tax.toString().replace(decpoint,".");
}
var selectedAudioFile = $("#audiosel_" + prodid + " option:selected").text();
if (selectedAudioFile == 'Kein Ton') {
selectedAudioFile = '';
}
var available = $( "#prodavail_" + prodid + " option:selected").val();
var favorite = $( "#prodfav_" + prodid + " option:selected").val();
var priceA_Arr = convertToDecimalPoint(priceA);
if (priceB.length != 0) {
var priceB_Arr = convertToDecimalPoint(priceB);
} else {
var priceB_Arr = convertToDecimalPoint(priceA);
}
if (priceC.length != 0) {
var priceC_Arr = convertToDecimalPoint(priceC);
} else {
var priceC_Arr = convertToDecimalPoint(priceA);
}
var taxTxt = tax.toString().replace(decpoint,".");
if (taxTxt != "null") {
if (!$.isNumeric(taxTxt)) {
return false;
}
}
if (priceA_Arr[0] && priceB_Arr[0] && priceC_Arr[0]) {
return {
status:true,
longname:longname,
shortname:shortname,
priceA:priceA_Arr[1],
priceB:priceB_Arr[1],
priceC:priceC_Arr[1],
tax:taxTxt,
selectedAudioFile:selectedAudioFile,
available:available,
favorite:favorite
}
} else {
return {
status:false
}
}
}
function prodapply(prodid) {
var props = parsePricesAndProperties(prodid);
var extrasAssignAllEl = '#extrassignall_' + prodid;
var isAssignAllExtrasChecked = 0;
if ( $(extrasAssignAllEl).length ) {
isAssignAllExtrasChecked = ($(extrasAssignAllEl).prop("checked") ? 1:0);
}
if (props.status) {
if ((props.priceA > 999.99) || (props.priceB > 999.99) || (props.priceC > 999.99)) {
alert(PROD_MAX_PRICE_EXCEEDED[lang]);
return;
}
var origAssignedExtras = $("#prodextra_" + prodid).data("orig_assignedextras");
var doChangeExtras = 0;
var assignedExtras = null;
if (origAssignedExtras != null) {
// the button to assign extras was pressed
var assignedExtras = $("#prodextra_" + prodid).data("assignedextras");
var doChangeExtras = 0;
if (!areEqual(origAssignedExtras, assignedExtras)) {
doChangeExtras = 1;
if (assignedExtras.length == 0) {
assignedExtras = null;
}
}
}
var data = {
id: prodid,
longname: props.longname,
shortname: props.shortname,
priceA: props.priceA,
priceB: props.priceB,
priceC: props.priceC,
tax: props.tax,
available: props.available,
audioFile: props.selectedAudioFile,
changeExtras: doChangeExtras,
favorite:props.favorite,
extras: assignedExtras,
assignextrastotype: isAssignAllExtrasChecked
};
actionOnProd("php/contenthandler.php?module=products&command=applySingleProdData",prodid,data);
if (isAssignAllExtrasChecked == 1) {
$(".assextralist").html("");
$(".assextralist").trigger("create");
}
} else {
alert(PROD_WRONG_FORMAT[lang]);
}
}
function actionOnProd(url,prodid,postdata) {
if (postdata == null) {
doAjax("GET", url, null, refreshProduct, "Fehler Produktdaten");
} else {
doAjax("POST", url, postdata, refreshProduct, "Fehler Produktdaten");
}
}
function refreshProduct(prodData) {
var aProduct = newProduct(prodData.id,prodData.longname,prodData.shortname,prodData.priceA,prodData.priceB,prodData.priceC,prodData.tax,prodData.available,prodData.audio,prodData.favorite);
aProduct.insertValuesIntoMenuList();
$("#assextralist_" + prodData.id).html("");
$("#assextralist_" + prodData.id).trigger("create");
$("#cont_" + prodData.id).trigger("create");
}
function prodnew(typeid) {
var tid = (typeid.split("n"))[1];
var props = parsePricesAndProperties(typeid);
var tax = props.tax;
if (tax.trim() == "") {
tax = "null";
}
var data = {
longname: props.longname,
shortname: props.shortname,
priceA: props.priceA,
priceB: props.priceB,
priceC: props.priceC,
tax: props.tax,
available: props.available,
prodTypeId: tid,
audioFile: props.selectedAudioFile,
favorite: props.favorite
};
doAjax("POST","php/contenthandler.php?module=products&command=createProduct",data,location.reload(),"Neues Produkt nicht anlegbar");
}
function reloadCurrentType() {
doAjax("GET","php/contenthandler.php?module=products&command=getMenu&ref=" + p_currenttypeid,null,saveMenu,"keine Produkthierarchyinformation bekommen");
}
function produp(prodid) {
doAjax("POST","php/contenthandler.php?module=products&command=sortup",{prodid:prodid},reloadCurrentType,"Produktsort./entf.");
}
function proddown(prodid) {
doAjax("POST","php/contenthandler.php?module=products&command=sortdown",{prodid:prodid},reloadCurrentType,"Produktsort./entf.");
}
function proddel(prodid) {
doAjax("POST","php/contenthandler.php?module=products&command=delproduct",{prodid:prodid},reloadCurrentType,"Produktsort./entf.");
}
function typenew(typeid) {
var newTypeName = $("#newtypename_" + typeid).val();
if (newTypeName.trim() == "") {
alert(PROD_ENTER_CAT_NAME[lang]);
} else {
var data = {
refid: typeid,
name: newTypeName
};
doAjax("POST","php/contenthandler.php?module=products&command=createProdType",data,reloadPageWithTimeout,"Neue Kategorie nicht anlegbar");
}
}
function typeapply(typeid) {
var name = $("#typename_input_" + typeid).val();
if (name.trim() == "") {
alert(PROD_ENTER_CAT_NAME[lang]);
} else {
var kind = $("#kind_" + typeid + " option:selected").val();
var useKit = $("#usekitchen_" + typeid + " option:selected").val();
var useSupply = $("#usesupply_" + typeid + " option:selected").val();
var printer = parseInt($("#printer_" + typeid + " option:selected").val()) + 1;
var data = {
id: typeid,
name: name,
kind: kind,
usekitchen: useKit,
usesupply: useSupply,
printer: printer
}
doAjax("POST","php/contenthandler.php?module=products&command=applyType",data,null,"Fehler Kategorieänderung");
}
}
function typecancel(typeid) {
doAjax("GET","php/contenthandler.php?module=products&command=getSingleTypeData&id=" + typeid,null,handleTypeCancelAnswer,"Fehler Kategorieänderung");
}
function typedelete(typeid) {
doAjax("POST","php/contenthandler.php?module=products&command=delType",{id:typeid},reloadPageWithTimeout,"Fehler Kategorieänderung");
}
function handleTypeCancelAnswer(answer) {
if (answer.status == "OK") {
var theType = answer.msg;
var prodtype = createProdType(theType.id,theType.name,theType.kind,theType.usekitchen,theType.usesupplydesk);
prodtype.insertValuesIntoMenuList();
$("#menulist").trigger("create");
} else {
alert("Fehler " + answer.code + ": " + answer.msg);
}
}
// reload, also for Chrome working
function reloadPageWithTimeout(result) {
if (result.status != "OK") {
alert("Fehler aufgetreten - bitte Aktion wiederholen!");
} else {
setTimeout(function(){document.location.href = "products.html"},250);
}
}
function cb_showPriceLevels(jsonContent) {
var selectedLevel = jsonContent.currentId;
var selectedLevelName = jsonContent.currentName;
var levels = jsonContent.levels;
var aText = '<div data-role="collapsible" id="pricelevelcollapsible" data-theme="c" data-collapsed="false"><h3>' + PROD_PRICELEVEL[lang] + selectedLevelName + '</h3><p>';
aText += '<fieldset data-role="controlgroup" id="pricelevelfieldset" >';
var htmlTextA = getPriceLevelRadio("radio-pricelevel-a",levels[0]["name"] + ": " + levels[0]["info"],levels[0]["selected"]);
var htmlTextB = getPriceLevelRadio("radio-pricelevel-b",levels[1]["name"] + ": " + levels[1]["info"],levels[1]["selected"]);
var htmlTextC = getPriceLevelRadio("radio-pricelevel-c",levels[2]["name"] + ": " + levels[2]["info"],levels[2]["selected"]);
aText += htmlTextA + htmlTextB + htmlTextC;
aText += '</fieldset></p></div>';
$("#pricelevelswitch").html(aText);
$("#pricelevelcollapsible").trigger('create');
$("#pricelevelswitch").trigger('create');
}
function showPriceLevels() {
var jsonContent = '';
doAjax("POST","php/contenthandler.php?module=products&command=getPriceLevelInfo",null,cb_showPriceLevels,"Preislevel");
}
function setPriceLevel(priceLevelId) {
$.ajax({ type: "POST",
dataType: "json",
url: "php/contenthandler.php?module=products&command=setPriceLevelInfo",
data : {
priceLevelId: priceLevelId
},
async: false,
success : function(jsonContent)
{
showPriceLevels();
binding();
},
error: function( text ) {
alert( "Sorry, there was a problem setting price level: " + text);
}
});
}
function getPriceLevelRadio (idname, priceinfo, checked) {
var aText = '<input type="radio" name="radio-pricelevel" id="' + idname + '" value="choice-level" data-theme="f" />';
if (checked == "1") {
aText = '<input type="radio" name="radio-pricelevel" id="' + idname + '" value="choice-level" checked="checked" data-theme="f"/>';
}
aText += '<label for="' + idname + '">' + priceinfo + '</label>';
return aText;
}
function createCommentsAreaWithComments(comments) {
if (comments.status != "OK") {
alert("Fehler " + comments.code + ": " + comments.msg);
return;
}
var commentsAreaTop = ' \
<div id="commentslist" data-role="collapsible" data-collapsed="false" data-theme="c" data-content-theme="e" class="noprint"> \
<h3><span id="comments_section">' + PROD_COMMENT[lang] + '</span></h3> \
<p><span id="comments_info">' + PROD_COMMENTS[lang] + '</span></p> \
<table width=100%>';
var commentsList = "";
var genComments = comments.msg;
var i=0;
for (i=0;i<genComments.length;i++) {
var aComment = genComments[i].comment;
aComment = toHtml(aComment);
var commentId = genComments[i].id;
var commentText = '<input type="text" value="'+ aComment + '" data-mini="true" id="genComComField_' + commentId + '"/>';
var buttonChange = '<td><a href="#" data-role="button" class="changeGenComment" id="genComChangeBtn_' + commentId + '">&radic;</a>';
var buttonUp = '<td><a href="#" data-role="button" class="upgencomment" id="genComUpBtn_' + commentId + '">&uarr;</a>';
if (i==0) {
buttonUp = '<td>&nbsp;';
}
var buttonDown = '<td><a href="#" data-role="button" class="downgencomment" id="genComDownBtn_' + commentId + '">&darr;</a>';
if (i==(genComments.length-1)) {
buttonDown = '<td>&nbsp;';
}
var buttonDelete = '<td><a href="#" data-role="button" class="delgencomment" id="genComDelField_' + commentId + '">&otimes;</a>';
commentsList += "<tr><td>" + commentText + buttonChange + buttonUp + buttonDown + buttonDelete + "</tr>";
}
var commentsBottom = ' \
<tr> \
<td><input type="text" id="newgencommentfield" value="" data-mini="true" placeholder="..." /> \
<td><a href="#" data-role="button" data-ajax="false" id="addgeneralcomment">+</a> \
</tr></table></div>';
$("#commentsarea").html(commentsAreaTop + commentsList + commentsBottom);
$("#commentsarea").trigger("create");
addGeneralCommentListener();
addGenChangeListener();
addGenComDelListener();
addGenComUpListener();
addGenComDownListener();
}
function createCommentsArea() {
doAjax("GET","php/contenthandler.php?module=products&command=getAllGeneralComments",null,createCommentsAreaWithComments,"Bemerkungen");
}
function addGeneralCommentListener() {
$("#addgeneralcomment").off("click").on("click", function (e) {
var comment = $("#newgencommentfield").val();
doAjax("POST","php/contenthandler.php?module=products&command=addGeneralComment",{comment: comment},handleResultOfGenCommentsChange,"Bemerkungen");
});
}
function handleResultOfGenCommentsChange(jsonText) {
if (jsonText.status == "OK") {
createCommentsArea();
} else {
alert("Fehler " + jsonText.code + ": " + jsonText.msg);
}
}
function addGenChangeListener() {
$(".changeGenComment").off("click").on("click", function (e) {
var commentId = (this.id.split("_"))[1];
var changedComment = $("#genComComField_" + commentId).val();
doAjax("POST","php/contenthandler.php?module=products&command=changeGeneralComment",{id:commentId,comment: changedComment},handleResultOfGenCommentsChange,"Bemerkungen");
});
}
function addGenComDelListener() {
$(".delgencomment").off("click").on("click", function (e) {
var commentId = (this.id.split("_"))[1];
doAjax("POST","php/contenthandler.php?module=products&command=delGeneralComment",{id:commentId},handleResultOfGenCommentsChange,"Bemerkungen");
});
}
function addGenComUpListener() {
$(".upgencomment").off("click").on("click", function (e) {
var commentId = (this.id.split("_"))[1];
doAjax("POST","php/contenthandler.php?module=products&command=upGeneralComment",{id:commentId},handleResultOfGenCommentsChange,"Bemerkungen");
});
}
function addGenComDownListener() {
$(".downgencomment").off("click").on("click", function (e) {
var commentId = (this.id.split("_"))[1];
doAjax("POST","php/contenthandler.php?module=products&command=downGeneralComment",{id:commentId},handleResultOfGenCommentsChange,"Bemerkungen");
});
}
function convertToDecimalPoint(aVal) {
if (aVal != null) {
var strVal = aVal.toString().replace(decpoint,".");
if ($.isNumeric(strVal)) {
return [true, strVal];
}
}
return [false];
}
function createExtrasArea() {
p_allextras = [];
doAjax("GET","php/contenthandler.php?module=products&command=getAllExtrasAlphaSorted",null,createExtrasAreaNow,"Optionen erstellen");
}
function createExtrasAreaNow(query) {
if (query.status == "OK") {
var extras = query.msg;
var txt = "<table>";
var i=0;
for (i=0;i<extras.length;i++) {
var anExtraDb = extras[i];
var anExtra = newExtra(anExtraDb.id, anExtraDb.name, anExtraDb.price);
p_allextras[p_allextras.length] = anExtra;
txt += anExtra.createTableStructureLine();
}
var anExtra = newExtra(null,"",null);
txt += anExtra.createTableStructureLine();
txt += "</table>";
$("#extraslist").html(txt);
for (i=0;i<p_allextras.length;i++) {
var anExtra = p_allextras[i];
anExtra.insertValuesIntoMenuTable();
}
}
extraBinding();
}
function createNewExtra() {
var name = $("#newextraname").val();
var price = $("#newextraprice").val();
createOrApplyExtra(name,price,"createExtra",null);
}
function applyExtra(extraid) {
var name = $("#extraname_" + extraid).val();
var price = $("#extraprice_" + extraid).val();
createOrApplyExtra(name,price,"applyExtra",extraid);
}
function createOrApplyExtra(name,price,fct,id) {
price = price.replace(",",".");
if(isNaN(Number(price))) {
alert(PROD_WRONG_FORMAT[lang]);
return;
}
if ((name.trim() == "") || (price.trim() == "") ) {
alert(PROD_ENTER_VALUES[lang]);
} else {
if (fct == "applyExtra") {
doAjax("POST","php/contenthandler.php?module=products&command=" + fct,{name:name,price:price,id:id},handleExtraChange,"Extras");
} else {
doAjax("POST","php/contenthandler.php?module=products&command=" + fct,{name:name,price:price,id:id},handleExtraCreation,"Extras");
}
}
}
function delExtra(extraid) {
doAjax("POST","php/contenthandler.php?module=products&command=delExtra",{id:extraid},handleExtraCreation,"Extras");
}
var lastRed = null;
function handleExtraMalfunction(answer) {
var extraid = answer.id;
if (extraid != null) {
$("#extraname_" + extraid).css("color","red");
lastRed = "#extraname_" + extraid;
} else {
$("#newextraname").css("color","red");
lastRed = "#newextraname";
}
alert("Fehler " + answer.code + ": " + answer.msg);
}
function handleExtraCreation(answer) {
$(lastRed).css("color","black");
if (answer.status == "OK") {
createExtrasArea();
} else {
handleExtraMalfunction(answer);
}
}
function handleExtraChange(answer) {
$(lastRed).css("color","black");
if (answer.status != "OK") {
handleExtraMalfunction(answer);
}
}
function binding() {
$("#radio-pricelevel-a").off("click").on("click", function (e) {
setPriceLevel(1);
});
$("#radio-pricelevel-b").off("click").on("click", function (e) {
setPriceLevel(2);
});
$("#radio-pricelevel-c").off("click").on("click", function (e) {
setPriceLevel(3);
});
}
function getGeneralConfigItems() {
doAjax("GET", "php/contenthandler.php?module=admin&command=getGeneralConfigItems", null, insertDecPointStartRest, "Fehler Konfigurationsdaten");
}
function insertDecPointStartRest(configResult) {
if (configResult.status == "OK") {
var values = configResult.msg;
decpoint = values.decpoint;
$("#info-page").data("decpoint",values.decpoint);
setLanguage(values.userlanguage);
getAudioFiles();
showPriceLevels();
createCommentsArea();
createExtrasArea();
binding();
} else {
setTimeout(function(){document.location.href = "index.html"},250); // not logged in
}
}
$(document).on("pageinit", "#info-page", function () {
initializeMainMenu("#modulemenu");
getGeneralConfigItems();
hideMenu();
});
</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="prodtitletxt">Angebot</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>
<div data-role="content" id="Content">
<div id="pricelevelswitch"></div>
<br>
<div id="commentsarea"></div>
<br>
<div id="menuarea" >
<div data-role="collapsible" data-content-theme="f" data-theme="c" data-collapsed="false">
<h3><span id="menuheader">Speisekarte</span><img id="goupimg_0" src='img/goup.png' class='goup oscmd' /></h3>
<p>
<div id=menulist></div>
</p>
</div>
</div>
<br>
<div id="extrasarea">
<div data-role="collapsible" data-content-theme="f" data-theme="c">
<h3><span id="extrasheader">Extras/Optionen</span></h3>
<p>
<div id=extraslist></div>
</p>
</div>
</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 -->
</div> <!-- page -->
<!-- Dialog page assign products -->
<div data-role="dialog" id="assigndialog" data-title="Zuweisung">
<div data-role="content">
<h3 id="assignheader">?</h3>
<div id=assprodlist></div>
<button id="assignprodbtnaftersel" type="submit" data-theme="b" class="oscmd" data-icon="check">Ja</button>
<a href="#" data-role="button" data-theme="c" data-rel="back">Nein</a>
</div>
</div>
</body>
</html>