ordersprinter/webapp/products.html

1289 lines
47 KiB
HTML
Raw Normal View History

2020-11-19 22:47:44 +01:00
<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">
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 23:12:13 +01:00
<link rel="stylesheet" type="text/css" href="css/bestformat.css?v=1.5.16">
2020-11-19 23:02:42 +01:00
<link rel="stylesheet" href="php/contenthandler.php?module=admin&command=getmobilecss" />
2020-11-19 22:47:44 +01:00
<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>
2020-11-19 23:03:35 +01:00
<link href="php/3rdparty/hayageek_uploadfile.css" rel="stylesheet">
<script src="php/3rdparty/hayageek_jquery_uploadfile.js"></script>
2020-11-19 22:47:44 +01:00
</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"];
2020-11-19 23:02:49 +01:00
var PROD_UNIT = ["Einheit","Unit","Unidad"];
var PROD_DAYS = ["Tage","Days","Dias"];
2020-11-19 23:10:06 +01:00
var PROD_DISPLAY = ["Anzeige","Display","Publicar"];
2020-11-19 22:47:44 +01:00
var PROD_TAX = ["Steuersatz immer","Tax always","Impuesto siempre"];
2020-11-19 23:00:31 +01:00
var PROD_TAXAUSTRIA = ["Steuersatz Österreich","Tax Austria","Impuesto Austria"];
var PROD_AMOUNT = ["Verfügbare Menge","Available amount","Cuanto hay"];
2020-11-19 22:47:44 +01:00
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"];
2020-11-19 23:03:10 +01:00
var PROD_SORT_ALPHA = ["Produkte alphabetisch sortieren","Sort products alphabetical","Especie productos alfabéticamente"];
2020-11-19 22:47:44 +01:00
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!"];
2020-11-19 22:58:23 +01:00
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!"];
2020-11-19 22:47:44 +01:00
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"];
2020-11-19 23:03:35 +01:00
var PROD_PRODIMAGES = ["Bildzuweisung","Image assignment","Asignar imagenes"];
2020-11-19 22:47:44 +01:00
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"];
2020-11-19 23:12:05 +01:00
var PROD_PRINTER_3 = ["Drucker 3","Printer 3","Imprimadora 3"];
var PROD_PRINTER_4 = ["Drucker 4","Printer 4","Imprimadora 4"];
var PROD_PRINTER_PRIO = ["Druckerpriorität","Priority of printer","Prioridad de la impresora"];
var PROD_PRINTER_FIXB0 = ["Raumdrucker","Room printer","Impresora de la habitación"];
var PROD_PRINTER_FIXB1 = ["Kategoriedrucker","Category printer","Impresora de la categoría"];
2020-11-19 22:53:50 +01:00
var PROD_PLACEHOLDER_NEW_PRODTYPE = ["Name der neuen Kategorie", "Name of the new category","Nombre de la categoría nueva"];
2020-11-19 23:03:10 +01:00
var PROD_APPLIED = ["Aktion wurde durchgeführt.","Action was performed.","Acción completa."];
2020-11-19 23:03:20 +01:00
var PROD_TYPEPROPS = ["Kategorieeigenschaften ein-/ausblenden","Show/hide properties of type","Mostrar o ocultar characterística de typo"];
var PROD_CATS_LIST = ["Unterkategorien","Sub Categories","Categorias contenidas"];
var PROD_PRODUCTS_LIST = ["Produkte","Products","Productos"];
2020-11-19 23:11:27 +01:00
var PROD_SET_TITLE = ["Gesamtes Bildmaterial","Full image set","Todos los imagenes"];
var PROD_CLEAN_PRODIMAGES = ["Entferne nicht zugewiesene Bilder in der DB","Remove unassigned images from database","Removar imagenes non usados"];
var PROD_DOWNLOAD_PRODIMAGES = ["Download gesamtes Bildmaterial","Download complete Image Set","Download todos los imagenes"];
2020-11-19 22:47:44 +01:00
2020-11-19 23:00:05 +01:00
// this is the maximal price that a product may cost
var MAX_PRICE = 999.99;
2020-11-19 22:47:44 +01:00
var decpoint = ".";
2020-11-19 23:00:31 +01:00
var austria = 0;
2020-11-19 22:47:44 +01:00
var lang = 0;
var p_allprods = [];
var menu;
var prodtypes = [];
var prodleafs = [];
var audiofiles;
var p_allextras = [];
var p_currenttypeid = null;
2020-11-19 23:11:27 +01:00
var keynames = [];
2020-11-19 22:47:44 +01:00
function setLanguage(language) {
lang = language;
$("#prodtitletxt").html(PROD_TITLE[lang]);
$("#assignheader").html(PROD_ASSIGN[lang]);
$("#extrasheader").html(PROD_EXTRAS[lang]);
2020-11-19 23:03:35 +01:00
$("#prodimagesheader").html(PROD_PRODIMAGES[lang]);
2020-11-19 22:47:44 +01:00
$("#menuheader").html(PROD_MENU[lang]);
2020-11-19 23:11:27 +01:00
$("#headeroffullprodset").html(PROD_SET_TITLE[lang]);
$("#cleantxt").html(PROD_CLEAN_PRODIMAGES[lang]);
$("#downloadprodimagestxt").html(PROD_DOWNLOAD_PRODIMAGES[lang]);
2020-11-19 22:47:44 +01:00
}
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");
2020-11-19 23:03:35 +01:00
cmdBinding();
getProdsForProdsImageArea();
2020-11-19 23:12:05 +01:00
bindExpandProdEntry();
2020-11-19 22:47:44 +01:00
}
2020-11-19 23:03:35 +01:00
function getProdsForProdsImageArea() {
2020-11-19 23:11:27 +01:00
doAjax("GET","php/contenthandler.php?module=products&command=getkeynames",null,insertkeynamesAndContinue,null);
}
function insertkeynamesAndContinue(answer) {
if (answer.status == "OK") {
keynames = answer.msg;
getAllIndividualProdsForProdsImageArea();
} else {
alert("Fehler: " + answer.msg);
}
}
function getAllIndividualProdsForProdsImageArea() {
2020-11-19 23:03:35 +01:00
doAjax("GET","php/contenthandler.php?module=products&command=getOnlyAllProds",null,fillProdImagesArea,null);
}
function fillProdImagesArea(answer) {
if (answer.status != "OK") {
return;
}
var prodlist = answer.msg;
var txt = "";
for (var i=0;i<prodlist.length;i++) {
var aProd = prodlist[i];
txt += createProdImageEntry(aProd.longname,aProd.id,aProd.chain);
}
$("#prodimageslist").html(txt);
$("#prodimageslist").trigger("create");
bindProdImageEntryClick();
}
function createProdImageEntry(longname,prodid,chain) {
var txt = '<div data-role="collapsible" data-content-theme="f" data-theme="c" id="prodimageentry_' + prodid+ '" class="prodimageentry" >';
txt += '<h3>' + toHtml(longname) + '</h3>';
txt += '<p>' + toHtml(chain) + '<p>';
txt += '<span class="imagepart"><img src="php/contenthandler.php?module=products&command=getprodimage&prodid=' + prodid + '" /></span>';
txt += '<div class="uploadarea"></div>';
txt += '<a href="#" data-role="button" data-icon="delete" data-theme="d" data-ajax="false" id="prodimagedelete_' + prodid + '" class="deleteprodimage" >Bildzuordnung entfernen</a> '
2020-11-19 23:11:27 +01:00
txt += '<select id="prodimageassignbox_' + prodid +'" data-theme="e" class="prodimageassbox">';
txt += '<option value="0">&nbsp;</option>';
keynames.forEach(function(aKey,index) {
txt += '<option value="' + aKey.id + '">' + aKey.keyname + '</option>';
});
txt += '</select>';
2020-11-19 23:03:35 +01:00
txt += "</div>";
return txt;
}
function bindProdImageEntryClick() {
$(".prodimageentry").off("collapsibleexpand").on("collapsibleexpand", function (e) {
e.stopImmediatePropagation();
e.preventDefault();
var id = this.id;
var prodid = id.split('_')[1];
createProdEntryArea(prodid);
});
$(".deleteprodimage").off("click").on("click", function (e) {
e.stopImmediatePropagation();
e.preventDefault();
var prodid = this.id.split('_')[1];
2020-11-19 23:11:27 +01:00
doAjax("POST","php/contenthandler.php?module=products&command=deleteImageProdAssignment",{prodid:prodid},createProdEntryArea,"Aufhebung der Zuordnung ist fehlgeschlagen");
});
$(".prodimageassbox").off("change").on("change", function (e) {
e.stopImmediatePropagation();
e.preventDefault();
var id = this.id;
var prodid = id.split('_')[1];
var prodimageid = $("#" + id).val();
if (prodimageid != 0) {
var data = {
prodid: prodid,
prodimageid: prodimageid
};
doAjax("POST","php/contenthandler.php?module=products&command=assignProdImageToKey",data,createProdEntryAreaOfId,"Zuordnung ist fehlgeschlagen");
}
2020-11-19 23:03:35 +01:00
});
}
2020-11-19 23:11:27 +01:00
function createProdEntryAreaOfId(answer) {
if (answer.status == "OK") {
createProdEntryArea(answer.prodid);
} else {
alert("Fehler: " + answer.msg);
}
}
2020-11-19 23:03:35 +01:00
function createProdEntryArea(prodid) {
2020-11-19 23:11:27 +01:00
updateProdImagePart(prodid);
2020-11-19 23:03:35 +01:00
var txt = "";
txt = '&nbsp;&nbsp;<div id="restorefilearea_' + prodid + '" >Upload</div>';
txt += '<div id="restorestatus_' + prodid + '" ></div>';
$("#prodimageentry_" + prodid + " .uploadarea").html(txt);
$("#restorefilearea_" + prodid).trigger("create");
initRestoreFileUpload(prodid);
}
function updateProdImagePart(prodid) {
var millis = getMillis();
var src = 'php/contenthandler.php?module=products&command=getprodimage&prodid=' + prodid + "&millis=" + millis;
$("#prodimageentry_" + prodid + " .imagepart img").attr("src", src);
}
2020-11-19 23:11:27 +01:00
function initFullProdimageSetFileUpload() {
var settings = {
url: "php/contenthandler.php?module=products&command=loadfullprodimageset",
method: "POST",
allowedTypes:"ocs,txt",
fileName: "textfile",
multiple: false,
uploadQueueOrder: 'replace',
showFileCounter: false,
dragDropStr: "<span>Datei</span>",
extErrorStr: " ist nicht erlaubt. Erlaubte Dateiendung: ",
onSuccess:function(files,data,xhr)
{
var answer = jQuery.parseJSON(data);
if (answer.status != "OK") {
alert("Upload war nicht erfolgreich: " + answer.msg);
} else {
alert("Import war erfolgreich.");
getProdsForProdsImageArea();
}
},
onError: function(files,status,errMsg)
{
$("#uploadprodsetstatus").html("<font color='red'>Upload fehlgeschlagen</font>");
}
};
$("#uploadprodsetfilearea").uploadFile(settings);
$("#uploadprodsetfilearea").trigger("create");
}
2020-11-19 23:03:35 +01:00
function initRestoreFileUpload(prodid) {
var settings = {
url: "php/contenthandler.php?module=products&command=loadprodimage&prodid=" + prodid,
method: "POST",
allowedTypes:"jpg,png,gif",
fileName: "imagefile",
multiple: false,
uploadQueueOrder: 'replace',
showFileCounter: false,
dragDropStr: "<span>Bilddatei</span>",
extErrorStr: " ist nicht erlaubt. Erlaubte Dateiendung: ",
onSuccess:function(files,data,xhr)
{
var answer = jQuery.parseJSON(data);
if (answer.status != "OK") {
alert("Upload war nicht erfolgreich: " + answer.msg);
} else {
//alert("Import war erfolgreich.");
updateProdImagePart(prodid)
2020-11-19 23:11:27 +01:00
};
2020-11-19 23:03:35 +01:00
},
onError: function(files,status,errMsg)
{
$("#restorestatus_" + prodid).html("<font color='red'>Upload fehlgeschlagen</font>");
}
2020-11-19 23:11:27 +01:00
};
2020-11-19 23:03:35 +01:00
$("#restorefilearea_" + prodid).uploadFile(settings);
$("#restorefilearea_" + prodid).trigger("create");
}
2020-11-19 22:47:44 +01:00
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;
2020-11-19 23:12:05 +01:00
var prodtype = createProdType(ct.id,ct.name,ct.kind,ct.usekitchen,ct.usesupplydesk,ct.printer,ct.fixbind);
2020-11-19 22:47:44 +01:00
prodtypes[prodtypes.length] = prodtype;
txt += prodtype.createUpperMenuTypeStructure();
} else {
$("#goupimg_0").hide();
p_currenttypeid = null;
}
2020-11-19 23:03:20 +01:00
var cats = "";
2020-11-19 22:47:44 +01:00
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;
2020-11-19 23:03:20 +01:00
cats += '<button id="gotoprodtype_' + id + '" type="submit" data-theme="e" class="oscmd">' + name + ' &rArr;</button>';
2020-11-19 22:47:44 +01:00
}
}
2020-11-19 23:03:20 +01:00
if (cats != "") {
txt += PROD_CATS_LIST[lang] + ":<br>" + cats;
}
2020-11-19 23:10:21 +01:00
if (ct == null) {
// on highest levels show fields to create types on highest level
2020-11-19 23:11:29 +01:00
txt += '<br><input id="topleveltypefield" placeholder="' + PROD_PLACEHOLDER_NEW_PRODTYPE[lang] + '" style="background:white;color:black;" />';
2020-11-19 23:10:21 +01:00
txt += '<div class="ui-grid-a">';
txt += '<div class="ui-block-a"><button id="createtoptypebtn_food" class="oscmd" type="submit" data-theme="c">' + PROD_NEW_CAT[lang] + " (" + PROD_FOOD[lang] + ") </button></div>";
txt += '<div class="ui-block-b"><button id="createtoptypebtn_drink" class="oscmd" type="submit" data-theme="c">' + PROD_NEW_CAT[lang] + " (" + PROD_DRINKS[lang] + ") </button></div>";
txt += '</div>';
}
2020-11-19 23:03:20 +01:00
var prodsListPrinted = false;
2020-11-19 22:47:44 +01:00
var pt = content.containedProds;
if (pt != null) {
var i=0;
for (i=0;i<pt.length;i++) {
var prod = pt[i];
2020-11-19 23:02:49 +01:00
var unit = 0;
if ((prod.unit !== undefined) && (prod.unit != null)) {
unit = prod.unit;
}
2020-11-19 23:10:06 +01:00
var display = 'KG';
if ((prod.display !== undefined) && (prod.display != null)) {
display = prod.display;
}
2020-11-19 23:02:49 +01:00
var days = '';
if (days != '0123456') {
days = prod.days;
}
2020-11-19 23:10:06 +01:00
var aProduct = newProduct(prod.id,prod.longname,prod.shortname,prod.priceA,prod.priceB,prod.priceC,unit,display,days,prod.tax,prod.taxaustria,prod.amount,prod.available,prod.audio,prod.favorite);
2020-11-19 22:47:44 +01:00
prodleafs[prodleafs.length] = aProduct;
2020-11-19 23:03:20 +01:00
if (!prodsListPrinted) {
prodsListPrinted = true;
txt += PROD_PRODUCTS_LIST[lang] + ":<br>";
}
2020-11-19 22:47:44 +01:00
txt += aProduct.createListStructureLine(audiofiles);
}
if (ct != null) {
var dummyPrice = "0.00".replace(".",decpoint);
2020-11-19 23:10:06 +01:00
var aProduct = newProduct("n" + ct.id,"","",dummyPrice,dummyPrice,dummyPrice,0,'KG',"0123456","null",0,"null",1,"",0);
2020-11-19 22:47:44 +01:00
prodleafs[prodleafs.length] = aProduct;
txt += aProduct.createListStructureLine(audiofiles);
}
}
if (ct != null) {
txt += prodtype.createLowerMenuTypeStructure();
}
return txt;
}
2020-11-19 23:12:05 +01:00
function bindExpandProdEntry() {
$(".prodcollapsible").off("collapsibleexpand").on("collapsibleexpand", function (e) {
e.stopImmediatePropagation();
e.preventDefault();
var id = (this.id.split("_"))[1];
for (var i=0;i<prodleafs.length;i++) {
var prod = prodleafs[i];
if (prod.id == id) {
prod.createProdContentStructure(audiofiles);
prodcancel(id);
cmdBinding();
}
}
});
}
2020-11-19 22:47:44 +01:00
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);
2020-11-19 23:02:57 +01:00
} else if (cmd == 'upextra') {
upExtra(objid);
}
2020-11-19 22:47:44 +01:00
});
}
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);
2020-11-19 23:10:21 +01:00
} else if (cmd == "createtoptypebtn") {
newtoptype(objid);
2020-11-19 22:47:44 +01:00
} 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();
2020-11-19 23:03:10 +01:00
} else if (cmd == 'sortalphaprod') {
sortAlpha(objid);
2020-11-19 22:47:44 +01:00
} else if (cmd == 'prodextrainput') {
doAjax("GET","php/contenthandler.php?module=products&command=getAssignedExtrasOfProd&prodid=" + objid,null,handleAssignedExtras,"Zugewiesene Optionen");
2020-11-19 23:03:20 +01:00
} else if (cmd == 'toggleprodtype') {
toggleProdType(objid);
2020-11-19 23:10:21 +01:00
} else if (cmd == 'createtoptypebtn') {
2020-11-19 23:03:20 +01:00
}
2020-11-19 22:47:44 +01:00
});
}
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);
});
}
2020-11-19 23:03:10 +01:00
function sortAlpha(typeid) {
var data = {
refid: typeid
};
doAjax("POST","php/contenthandler.php?module=products&command=sortProdAlpha",data,reloadPageWithTimeout,"Sortierung ist fehlgeschlagen");
}
2020-11-19 22:47:44 +01:00
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");
2020-11-19 23:03:10 +01:00
actionOnProd(url,prodid,null,false);
2020-11-19 22:47:44 +01:00
}
2020-11-19 23:03:20 +01:00
function toggleProdType(typeid) {
var currentDisplayState = $("#toggleprodtype_" + typeid).data("display");
if ((currentDisplayState == undefined) || (currentDisplayState == 0)) {
$("#toggleprodtype_" + typeid).data("display",1);
$("#typepropertiespart_" + typeid).show();
} else {
$("#toggleprodtype_" + typeid).data("display",0);
$("#typepropertiespart_" + typeid).hide();
}
}
2020-11-19 23:10:26 +01:00
var prodproperties = [
{ prop: "longname", field: "prodlong_input", fieldtype: "v", default: '', isnum: false, allowempty: false},
{ prop: "shortname", field: "prodshort_input", fieldtype: "v", default: '', isnum: false, allowempty: "longname"},
{ prop: "priceA", field: "prodpriceA_input", fieldtype: "v", default: '', isnum: true, allowempty: false},
{ prop: "priceB", field: "prodpriceB_input", fieldtype: "v", default: '', isnum: true, allowempty: "priceA"},
{ prop: "priceC", field: "prodpriceC_input", fieldtype: "v", default: '', isnum: true, allowempty: "priceA"},
{ prop: "unit", field: "produnit_input", fieldtype: "v", default: '', isnum: false, allowempty: true},
{ prop: "display", field: "proddisplay_input", fieldtype: "v", default: '', isnum: false, allowempty: true},
{ prop: "days", field: "proddays_input", fieldtype: "v", default: '0123456', isnum: false, allowempty: true},
{ prop: "tax", field: "prodtax_input", fieldtype: "v", default: 'null', isnum: true, allowempty: true},
{ prop: "amount", field: "prodamount_input", fieldtype: "v", default: 'null', isnum: false, allowempty: true},
{ prop: "taxaustria", field: "taxaustriasel", fieldtype: "sval", default: '', isnum: false, allowempty: true},
{ prop: "selectedAudioFile", field: "audiosel", fieldtype: "stext", default: '', isnum: false, allowempty: true},
2020-11-19 23:10:43 +01:00
{ prop: "available", field: "prodavail", fieldtype: "sval", default: '1', isnum: false, allowempty: true},
{ prop: "favorite", field: "prodfav", fieldtype: "sval", default: '1', isnum: false, allowempty: true}
2020-11-19 23:10:26 +01:00
];
2020-11-19 22:47:44 +01:00
function parsePricesAndProperties(prodid) {
2020-11-19 23:10:26 +01:00
var retValue = {};
for (var i=0;i<prodproperties.length;i++) {
var aProperty = prodproperties[i];
var aVal = '';
if (aProperty.fieldtype == 'v') {
var untrimmedVal = $("#" + aProperty.field + "_" + prodid).val();
if (untrimmedVal != null) {
aVal = untrimmedVal.trim();
}
if (aVal == '') {
if (aProperty.allowempty === false) {
return { status:false };
} else if (aProperty.allowempty === true) {
aVal = aProperty.default;
} else {
aVal = retValue[aProperty.allowempty];
}
}
} else if (aProperty.fieldtype == 'sval') {
aVal = $("#" + aProperty.field + "_" + prodid + " option:selected").val();
} else if (aProperty.fieldtype == 'stext') {
aVal = $("#" + aProperty.field + "_" + prodid + " option:selected").text();
};
if (aProperty.isnum) {
aVal = aVal.toString().replace(decpoint,".");
2020-11-19 23:10:28 +01:00
if ((aVal != '') && (aVal != 'null') && (!$.isNumeric(aVal))) {
2020-11-19 23:10:26 +01:00
return { status:false };
};
2020-11-19 22:47:44 +01:00
}
2020-11-19 23:10:26 +01:00
retValue[aProperty.prop] = aVal;
2020-11-19 22:47:44 +01:00
}
2020-11-19 23:10:26 +01:00
if (retValue["selectedAudioFile"] == 'Kein Ton') {
retValue["selectedAudioFile"] = '';
2020-11-19 23:02:49 +01:00
}
2020-11-19 23:10:28 +01:00
if (austria != 1) {
retValue["taxaustria"] = 'null';
}
2020-11-19 23:10:26 +01:00
retValue["status"] = true;
return retValue;
2020-11-19 22:47:44 +01:00
}
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) {
2020-11-19 23:00:05 +01:00
if ((props.priceA > MAX_PRICE) || (props.priceB > MAX_PRICE) || (props.priceC > MAX_PRICE)) {
2020-11-19 22:58:23 +01:00
alert(PROD_MAX_PRICE_EXCEEDED[lang]);
return;
}
2020-11-19 23:10:26 +01:00
2020-11-19 22:47:44 +01:00
var origAssignedExtras = $("#prodextra_" + prodid).data("orig_assignedextras");
var doChangeExtras = 0;
var assignedExtras = null;
if (origAssignedExtras != null) {
var assignedExtras = $("#prodextra_" + prodid).data("assignedextras");
var doChangeExtras = 0;
if (!areEqual(origAssignedExtras, assignedExtras)) {
doChangeExtras = 1;
if (assignedExtras.length == 0) {
assignedExtras = null;
}
}
}
2020-11-19 23:10:26 +01:00
props["id"] = prodid;
props["changeExtras"] = doChangeExtras;
props["extras"] = assignedExtras;
props["assignextrastotype"] = isAssignAllExtrasChecked;
2020-11-19 22:47:44 +01:00
2020-11-19 23:10:26 +01:00
actionOnProd("php/contenthandler.php?module=products&command=applySingleProdData",prodid,props,true);
2020-11-19 22:47:44 +01:00
if (isAssignAllExtrasChecked == 1) {
$(".assextralist").html("");
$(".assextralist").trigger("create");
}
} else {
alert(PROD_WRONG_FORMAT[lang]);
}
}
2020-11-19 23:03:10 +01:00
function actionOnProd(url,prodid,postdata,confirmation) {
if (confirmation) {
if (postdata == null) {
doAjax("GET", url, null, refreshProductAndConfirm, "Fehler Produktdaten");
} else {
doAjax("POST", url, postdata, refreshProductAndConfirm, "Fehler Produktdaten");
}
} else {
if (postdata == null) {
doAjax("GET", url, null, refreshProduct, "Fehler Produktdaten");
} else {
doAjax("POST", url, postdata, refreshProduct, "Fehler Produktdaten");
}
}
2020-11-19 22:47:44 +01:00
}
2020-11-19 23:03:10 +01:00
function refreshProductAndConfirm(prodData) {
alert(PROD_APPLIED[lang]);
refreshProduct(prodData);
}
2020-11-19 22:47:44 +01:00
function refreshProduct(prodData) {
2020-11-19 23:10:06 +01:00
var aProduct = newProduct(prodData.id,prodData.longname,prodData.shortname,prodData.priceA,prodData.priceB,prodData.priceC,prodData.unit,prodData.display,prodData.days,prodData.tax,prodData.taxaustria,prodData.amount,prodData.available,prodData.audio,prodData.favorite);
2020-11-19 22:47:44 +01:00
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];
2020-11-19 23:10:26 +01:00
var data = parsePricesAndProperties(typeid);
if (data.status == false) {
alert(PROD_WRONG_FORMAT[lang]);
} else {
data["category"] = tid;
doAjax("POST","php/contenthandler.php?module=products&command=createProduct",data,location.reload(),"Neues Produkt nicht anlegbar");
2020-11-19 23:02:49 +01:00
}
2020-11-19 22:47:44 +01:00
}
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.");
}
2020-11-19 23:10:21 +01:00
function createNewTypeOnServer(refid,name,kind) {
if (name == "") {
alert(PROD_ENTER_CAT_NAME[lang]);
} else {
var data = {
refid: refid,
name: name,
kind: kind
};
2020-11-19 22:47:44 +01:00
doAjax("POST","php/contenthandler.php?module=products&command=createProdType",data,reloadPageWithTimeout,"Neue Kategorie nicht anlegbar");
2020-11-19 23:10:21 +01:00
}
}
function newtoptype(kind) {
var name = $("#topleveltypefield").val().trim();
createNewTypeOnServer("top",name,(kind == "food" ? 0 : 1));
}
function typenew(typeid) {
var name = $("#newtypename_" + typeid).val().trim();
createNewTypeOnServer(typeid,name,0);
2020-11-19 22:47:44 +01:00
}
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;
2020-11-19 23:12:05 +01:00
var fixbind = parseInt($("#fixbind_" + typeid + " option:selected").val());
2020-11-19 22:47:44 +01:00
var data = {
id: typeid,
name: name,
kind: kind,
usekitchen: useKit,
usesupply: useSupply,
2020-11-19 23:12:05 +01:00
printer: printer,
fixbind: fixbind
2020-11-19 23:11:27 +01:00
};
2020-11-19 22:47:44 +01:00
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;
2020-11-19 23:12:05 +01:00
var prodtype = createProdType(theType.id,theType.name,theType.kind,theType.usekitchen,theType.usesupplydesk,theType.printer,theType.fixbind);
2020-11-19 22:47:44 +01:00
prodtype.insertValuesIntoMenuList();
$("#menulist").trigger("create");
} else {
alert("Fehler " + answer.code + ": " + answer.msg);
}
}
function reloadPageWithTimeout(result) {
if (result.status != "OK") {
alert("Fehler aufgetreten - bitte Aktion wiederholen!");
} else {
2020-11-19 23:11:27 +01:00
setTimeout(function(){document.location.href = "products.html";},250);
2020-11-19 22:47:44 +01:00
}
}
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);
}
2020-11-19 23:02:57 +01:00
function upExtra(extraid) {
doAjax("POST","php/contenthandler.php?module=products&command=upExtra",{id:extraid},handleExtraCreation,"Extras");
}
2020-11-19 22:47:44 +01:00
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);
});
2020-11-19 23:11:27 +01:00
$("#cleanprodimageindb").off("click").on("click", function (e) {
e.stopImmediatePropagation();
e.preventDefault();
// cleanprodimagestable
doAjax("POST","php/contenthandler.php?module=products&command=cleanprodimagestable",null,handleCleanProcess,"Extras");
});
$("#downloadprodimages").off("click").on("click", function (e) {
e.stopImmediatePropagation();
e.preventDefault();
window.location.href = "php/contenthandler.php?module=products&command=prodimghmlexport";
});
2020-11-19 22:47:44 +01:00
}
2020-11-19 23:11:27 +01:00
function handleCleanProcess(answer) {
if (answer.status == "OK") {
alert("OK");
getProdsForProdsImageArea();
} else {
alert("Fehler: " + answer.msg);
}
}
2020-11-19 22:47:44 +01:00
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;
2020-11-19 23:00:31 +01:00
austria = values.austria;
2020-11-19 22:47:44 +01:00
$("#info-page").data("decpoint",values.decpoint);
setLanguage(values.userlanguage);
getAudioFiles();
showPriceLevels();
createCommentsArea();
createExtrasArea();
binding();
2020-11-19 23:11:27 +01:00
initFullProdimageSetFileUpload();
2020-11-19 22:47:44 +01:00
} else {
setTimeout(function(){document.location.href = "index.html"},250); // not logged in
}
}
$(document).on("pageinit", "#info-page", function () {
initializeMainMenu("#modulemenu");
getGeneralConfigItems();
hideMenu();
});
</script>
2020-11-19 23:11:29 +01:00
<div data-role="page" id="info-page" data-theme="c">
2020-11-19 22:47:44 +01:00
<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 23:02:16 +01:00
<li data-role="list-divider" data-theme="b" data-role="heading">Hauptmenü</li>
2020-11-19 22:47:44 +01:00
</ul>
</div><!-- /panel -->
2020-11-19 23:11:29 +01:00
<div data-role="header" data-theme="b" data-position="fixed" id="theheader" style="background-color:black;">
2020-11-19 23:11:33 +01:00
<h1><span id="prodtitletxt">Angebot</span> <img src="img/connection.png" class="connectionstatus" style="display:none;" /> <img src="img/printerstatus.png" class="printerstatus" style="display:none;" /> <img src="img/tasksstatus.png" class="tasksstatus" style="display:none;" /></h1>
2020-11-19 22:47:44 +01:00
<div data-type="horizontal" style="top:0px;position:absolute;float:right;z-index:10;display:inline;" align="right" class="ui-btn-right">
2020-11-19 23:02:16 +01:00
<a href="#" data-role="button" data-icon="arrow-d" data-ajax="false" id="menuswitch">Hauptmenü</a>
2020-11-19 22:47:44 +01:00
</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>
2020-11-19 23:11:27 +01:00
<p><div id=extraslist></div>
2020-11-19 22:47:44 +01:00
</div>
</div>
2020-11-19 23:03:35 +01:00
<div id="prodimagesarea">
2020-11-19 23:11:27 +01:00
<div data-role="collapsible" data-content-theme="f" data-theme="c">
<h3><span id="prodimagesheader">Bildzuweisung</span></h3>
<p><div id="prodsetimageuploadarea">
<div class="roundedborderarea">
2020-11-19 23:11:29 +01:00
<h3><span id="headeroffullprodset" style="color:black;">Setmanipulation</span></h3>
2020-11-19 23:11:27 +01:00
<div id="uploadprodsetfilearea">Bildset-Upload</div>
<div id="uploadprodsetstatus"></div>
<p><button id="cleanprodimageindb" type="submit" data-theme="e"><span id="cleantxt">Bereinigen</span></button>
<p><button id="downloadprodimages" type="submit" data-theme="e"><span id="downloadprodimagestxt">Download</span></button>
</div>
</div>
<p><div id=prodimageslist></div>
</div>
2020-11-19 23:03:35 +01:00
</div>
2020-11-19 22:47:44 +01:00
</div>
2020-11-19 23:11:29 +01:00
<div data-role="footer" data-theme="b" id="thefooterr" style="background-color:black;" >
2020-11-19 22:47:44 +01:00
<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>
2020-11-19 23:11:27 +01:00
2020-11-19 22:47:44 +01:00
<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>