diff --git a/printserver/OrderSprinterPrintserver.exe b/printserver/OrderSprinterPrintserver.exe index e0e2579..4e05680 100644 Binary files a/printserver/OrderSprinterPrintserver.exe and b/printserver/OrderSprinterPrintserver.exe differ diff --git a/spider/install/installer.php b/spider/install/installer.php index d1cc907..d5aa3ab 100644 --- a/spider/install/installer.php +++ b/spider/install/installer.php @@ -85,7 +85,7 @@ class Installer { } Database::dropTables($pdo); Database::createEmptyTables($pdo, $prefix); - Database::setVersion($pdo,$prefix,"1.3.0"); + Database::setVersion($pdo,$prefix,"1.3.1"); Database::setAccessPassword($pdo,$prefix,$adminpass); Database::setRefreshRate($pdo,$prefix,"5"); // default: 5 times per hour return array("status" => "OK","msg" => "Installation successful"); diff --git a/webapp/OrderSprinterPrintserver.exe b/webapp/OrderSprinterPrintserver.exe index e0e2579..4e05680 100644 Binary files a/webapp/OrderSprinterPrintserver.exe and b/webapp/OrderSprinterPrintserver.exe differ diff --git a/webapp/bar.html b/webapp/bar.html index c81f066..0b018c6 100644 --- a/webapp/bar.html +++ b/webapp/bar.html @@ -5,7 +5,7 @@ - + diff --git a/webapp/bill.html b/webapp/bill.html index 914a9f8..595a7a9 100644 --- a/webapp/bill.html +++ b/webapp/bill.html @@ -5,7 +5,7 @@ - + diff --git a/webapp/customers.html b/webapp/customers.html index 223d223..2052fb7 100644 --- a/webapp/customers.html +++ b/webapp/customers.html @@ -74,8 +74,12 @@ var CUS_PRINTBILL = ["Drucken","Print","Imprimir"]; var CUS_DECLARE_ALL_PAY = ["Alle als bezahlt deklarieren","Declare all as paid","Declarar todo pagado"]; var CUS_PRINT_ALL = ["Alle Bons drucken","Print all receipts","Imprimir todos los tiquetes"]; var CUS_FILTER_OPEN_BILLS = ["Filter Gäste mit offenen Rechnungen","Filter on customers with ooen bills","Filtrar clientes con tiquets non-pagados"]; +var CUS_LOGBTN = ["Rechnungslog (csv)","Log of payments (csv)","Protocolo de los pagos (csv)"]; var CUS_SEND_EMAIL = ["Email an alle Gruppenmitglieder senden","Send email to all group members","Enviar email a todos los miembros"]; var CUS_EMAIL_WARNING = ["Emails lassen sich nur versenden, wenn die Email-Konfiguration vorgenommen wurde","Emails can only be sent if the email configuration was done","Sólo puede enviar emails si la configuración es completada"]; +var CUS_STORNO_QUEST_TITLE = ["Storno?","Cancel?","Contrapartida?"]; +var CUS_STORNO_QUEST_TEXT = ["Bon als vom Gast unbezahlt deklarieren?","Cancel the payment of the guest?","Contrapartida del tique por el cliente?"]; +var CUS_YES = ["Ja","Yes","Si"]; var l = 0; @@ -95,6 +99,7 @@ function setLanguage(language) { $("#newguestheader").html(CUS_NEW_CUS_HEADER[l]); $("#customerdatetxt").html(CUS_DATE[l]); $("#customeropenbillstxt").html(CUS_FILTER_OPEN_BILLS[l]); + $("#customerlog").html(CUS_LOGBTN[l]); } $(document).on("pageinit", "#info-page", function () { @@ -159,12 +164,12 @@ $(document).on("pageinit", "#info-page", function () {
- +
- +
@@ -174,7 +179,7 @@ $(document).on("pageinit", "#info-page", function () {
- +
@@ -202,6 +207,10 @@ $(document).on("pageinit", "#info-page", function () {
+ +
+ +
+ + +
+
+

?

+

?

+
+ + + + + Ja + Nein +
+
+
+ diff --git a/webapp/elements/customers.js b/webapp/elements/customers.js index 3c7fb62..ffa9872 100644 --- a/webapp/elements/customers.js +++ b/webapp/elements/customers.js @@ -1 +1 @@ -var allgroups=[];var customers=[];var decpoint=".";var currency="";function getGeneralConfigItemsCus(){$("#customersearch").val("");$("#groupsearch").val("");clearNewCustomerFields();clearNewGroupFields();doAjax("GET","php/contenthandler.php?module=admin&command=getGeneralConfigItems",null,insertConfigDoRest,"Fehler Konfigurationsdaten");customizeDatePicker("#newcustomercheckin",null);customizeDatePicker("#newcustomercheckout",null);customizeDatePicker("#customerdate","")}function insertConfigDoRest(b){if(b.status==="OK"){var a=b.msg;$("#customersearch").val("");setLanguage(a.userlanguage);decpoint=a.decpoint;currency=a.currency;bindGroupsOrCustomerBtns();showCustomersArea();startSearch()}else{setTimeout(function(){document.location.href="index.html"},250)}}function showCustomersArea(){$("#customersarea").show();$("#groupsarea").hide();$("#customersbtn").buttonMarkup({theme:"f"});$("#customersbtn").buttonMarkup({icon:"arrow-d"});$("#groupsbtn").buttonMarkup({theme:"c"});$("#groupsbtn").buttonMarkup({icon:"arrow-r"})}function showGroupsArea(){$("#customersarea").hide();$("#groupsarea").show();$("#customersbtn").buttonMarkup({theme:"c"});$("#customersbtn").buttonMarkup({icon:"arrow-r"});$("#groupsbtn").buttonMarkup({theme:"f"});$("#groupsbtn").buttonMarkup({icon:"arrow-d"})}function bindGroupsOrCustomerBtns(){$("#customersbtn").off("click").on("click",function(a){a.stopImmediatePropagation();a.preventDefault();showCustomersArea()});$("#groupsbtn").off("click").on("click",function(a){a.stopImmediatePropagation();a.preventDefault();showGroupsArea()});$("#newcustomerbtn").off("click").on("click",function(h){h.stopImmediatePropagation();h.preventDefault();var b=$("#newcustomername").val().trim();var k=$("#newcustomeremail").val().trim();var m=$("#newcustomeraddress").val().trim();var g=$("#newcustomerremark").val().trim();var i=$("#newcustomerphone").val().trim();var j=$("#newcustomermobil").val().trim();var c=$("#newcustomerwww").val().trim();var a=$("#newcustomerroom").val().trim();if(b===""){alert(CUS_EMPTY_NAME[l])}else{var f=getCheckinouts("#newcustomercheckin","#newcustomercheckout");if(!f.valid){alert(CUS_CHECKIN_AFTER_OUT[l]);return}var d={name:b,email:k,addr:m,remark:g,phone:i,mobil:j,www:c,checkin:f.checkin,checkout:f.checkout,room:a};if(!cusCheckTextLengths(d)){return}doAjax("POST","php/contenthandler.php?module=customers&command=createNewCustomer",d,handleCreateCustomerResult,"Gast anlegen unmöglich",true)}});$("#customersearch").off("keyup").on("keyup",function(a){startSearch()});$("#groupsearch").off("keyup").on("keyup",function(a){startSearch()});$("#newgroupbtn").off("click").on("click",function(c){c.stopImmediatePropagation();c.preventDefault();var a=$("#newgroupname").val().trim();var d=$("#newgroupremark").val().trim();if(a===""){alert(GROUP_EMPTY_NAME[l])}else{var b={name:a,remark:d};doAjax("POST","php/contenthandler.php?module=customers&command=createNewGroup",b,handleCreateGroupResult,"Gruppe anlegen unmöglich",true)}})}function bindOnDynamicCustomersBtn(){$(".applycustomer").off("click").on("click",function(g){g.stopImmediatePropagation();g.preventDefault();var j=this.id.split("_")[1];var a=[];for(var b=0;b200){cusAlertTextLength("Bemerkung");return false}var c=$("#cusfield_cusfield_newroom_"+a).val();if(c.length>50){cusAlertTextLength("Zimmer");return false}var b={id:a,checkin:g.checkin,checkout:g.checkout,room:c,remark:f};doAjax("POST","php/contenthandler.php?module=customers&command=newVacation",b,handleChangeVacationResult,"Aufenthalt anlegen unmöglich",true)});$(".delvacation").off("click").on("click",function(a){a.stopImmediatePropagation();a.preventDefault();var b=this.id.split("_")[1];doAjax("POST","php/contenthandler.php?module=customers&command=delVacation",{id:b},handleChangeVacationResult,"Aufenthalt löschen unmöglich",true)});$(".paybill").off("click").on("click",function(b){b.stopImmediatePropagation();b.preventDefault();var a=this.id.split("_")[1];doAjax("POST","php/contenthandler.php?module=customers&command=pay",{id:a},handleChangeBillResult,"Deklaration als bezahlt unmöglich",true)});$(".unpaybill").off("click").on("click",function(b){b.stopImmediatePropagation();b.preventDefault();var a=this.id.split("_")[1];doAjax("POST","php/contenthandler.php?module=customers&command=unpay",{id:a},handleChangeBillResult,"Deklaration als unbezahlt unmöglich",true)});$(".printbill").off("click").on("click",function(b){b.stopImmediatePropagation();b.preventDefault();var a=this.id.split("_")[1];doAjax("POST","php/contenthandler.php?module=customers&command=printbill",{id:a},null,"Drucken unmöglich",true)});$(".payallbills").off("click").on("click",function(b){b.stopImmediatePropagation();b.preventDefault();var a=this.id.split("_")[1];doAjax("POST","php/contenthandler.php?module=customers&command=payallbills",{id:a},handleChangeBillResult,"Deklaration alle unmöglich",true)});$(".printallbills").off("click").on("click",function(b){b.stopImmediatePropagation();b.preventDefault();var a=this.id.split("_")[1];doAjax("POST","php/contenthandler.php?module=customers&command=printallbills",{id:a},null,"Drucken alle unmöglich",true)})}function updateVacationsOfCustomer(a){doAjax("GET","php/contenthandler.php?module=customers&command=getVacations",{cusid:a},handleVacationsResult,null,true)}function updateBillsOfCustomer(a){doAjax("GET","php/contenthandler.php?module=customers&command=getBills",{cusid:a},handleBillsResult,null,true)}function handleVacationsResult(e){if(e.status==="OK"){var f=e.msg.vacations;var b=e.msg.cusid;var a="";for(var d=0;dCheck-in: "+d;a+="

Check-out: "+c;a+="

"+CUS_ROOM_LABEL[l]+": "+f;a+="

"+CUS_REMARK_LABEL[l]+g;a+=createDeleteButton(h+"_delvacation",CUS_DEL[l],"d","delvacation");a+="";return a}function renderABill(h,b,c,f,g,i){var a=f.replace(".",decpoint)+" "+currency;var e="c";if(i==1){e="f"}var d=createCollapsibleStartGeneral("billentry_"+h,c+" - "+a,e,"billentry",true);d+="

"+CUS_BILLID[l]+": "+b;d+="

"+CUS_BILLDATE[l]+": "+c;d+="

"+CUS_BILLBRUTTO[l]+": "+c;if(i==0){d+=createApplyButton(b+"_paybill",CUS_DECLAREPAY[l],"f","paybill")}else{d+=createApplyButton(b+"_unpaybill",CUS_DECLAREUNPAY[l],"d","unpaybill")}d+=createApplyButton(b+"_printbill",CUS_PRINTBILL[l],"f","printbill");d+="";return d}function handleEmailResult(a){if(a.status==="OK"){alert("Aktion abgeschlossen")}else{alert("Error: "+a.msg)}}function handleChangeVacationResult(b){if(b.status==="OK"){var a=b.cusid;$("#cusfield_newcheckin_"+a).val("");$("#cusfield_newcheckout_"+a).val("");$("#cusfield_cusfield_newroom_"+a).val("");$("#cusfield_vacremark_"+a).val("");updateVacationsOfCustomer(a)}else{alert("Error: "+b.msg)}}function handleChangeBillResult(b){if(b.status==="OK"){var a=b.cusid;updateBillsOfCustomer(a)}else{alert("Error: "+b.msg)}}function deleteCustomerCore(b){var a={id:b};doAjax("POST","php/contenthandler.php?module=customers&command=deleteCustomer",a,handleDeleteCustomerResult,"Gast löschen unmöglich",true)}function deleteGroupCore(b){var a={id:b};doAjax("POST","php/contenthandler.php?module=customers&command=deleteGroup",a,handleDeleteGroupResult,"Gruppe löschen unmöglich",true)}function areYouSureCus(c,b,a,d){$("#sure .sure-1").text(c);$("#sure .sure-2").text(b);$("#sure .sure-do").text(a).off("click.sure").on("click.sure",function(){d()});$(this).off("click.sure");$.mobile.changePage("#sure")}function startSearch(){var a={search:$("#groupsearch").val().trim()};doAjax("POST","php/contenthandler.php?module=customers&command=getGroups",a,handleGetGroupsResult,"Gästeabfrage unmöglich",true)}function startCustomerSearch(){var c=$("#customersearch").val().trim();var a=getDate("#customerdate");var d="";if((a!=null)&&(a!="")){d=a.year+"-"+a.month+"-"+a.day}var b=0;if($("#customeropenbills").is(":checked")){b=1}var e={search:c,date:d,onlyopenbills:b};doAjax("POST","php/contenthandler.php?module=customers&command=getCustomers",e,handleGetCustomerResult,"Gästeabfrage unmöglich",true)}function clearNewCustomerFields(){$("#newcustomername").val("");$("#newcustomeremail").val("");$("#newcustomeraddress").val("");$("#newcustomerremark").val("");$("#newcustomerphone").val("");$("#newcustomermobil").val("");$("#newcustomerwww").val("");$("#newcustomercheckin").val("");$("#newcustomercheckout").val("");$("#newcustomerroom").val("")}function handleCreateCustomerResult(a){if(a.status==="OK"){clearNewCustomerFields();if(a.code==1){var b=CUS_ALREADY_CUS_NAME[l];b=b.replace("%number%",a.value);alert(b)}startSearch()}else{alert(CUS_ACTION_FAILED[l]+": "+a.msg)}}function clearNewGroupFields(){$("#newgroupname").val("");$("#newgroupremark").val("")}function handleCreateGroupResult(a){if(a.status==="OK"){clearNewGroupFields();startSearch()}else{if(a.code==1){alert(CUS_GROUP_EXISTS[l])}else{alert(CUS_ACTION_FAILED[l]+": "+a.msg)}}}function handleChangeCustomerResult(a){if(a.status==="OK"){startSearch()}else{alert(CUS_ACTION_FAILED[l]+": "+a.msg)}}function handleDeleteCustomerResult(a){if(a.status==="OK"){startSearch()}else{alert(CUS_ACTION_FAILED[l]+": "+a.msg)}}function handleDeleteGroupResult(a){if(a.status==="OK"){startSearch()}else{alert(CUS_ACTION_FAILED[l]+": "+a.msg)}}function handleChangeGroupResult(a){if(a.status==="OK"){startSearch()}else{alert(CUS_ACTION_FAILED[l]+": "+a.msg)}}function createInputTextField(f,d,e,b,c){var a='

';a+=' ";a+=' ';a+="
";return a}function createTextAreaField(f,d,e,b,c){var a='
';a+=' ";a+=' ";a+="
";return a}function createDateTimePicker(d,b,c){var a='
';a+=' ";a+=' ';a+="
";return a}function createCollapsibleStartNew(d,b,c){var a='
';a+="

"+toHtml(b)+"

";return a}function createCollapsibleStartGeneral(g,c,e,f,b){var d=" ";if(b===false){d=' style="display:none;" '}var a='
";a+="

"+toHtml(c)+"

";return a}function createApplyButton(e,b,d,c){var a='";return a}function createDeleteButton(e,b,d,c){var a='";return a}function createApplyDeleteButtons(d,c,b){var a='
';a+='
'+createApplyButton(d,CUS_APPLY[l],"f",c)+"
";a+='
'+createDeleteButton(d,CUS_DEL[l],"d",b)+"
";a+="
";return a}function renderACustomer(d){var b=d.id;var c="";if((d.openbillsum!=null)&&(d.openbillsum!="")){c=" ("+d.openbillsum;c=c.replace(".",decpoint)+" "+currency+")"}var a=createCollapsibleStartNew(b,d.name+c,"c");a+="

";a+=createInputTextField(b,"cus","name","Name",d.name);a+=createTextAreaField(b,"cus","address",CUS_ADR_LABEL[l],d.address);a+=createInputTextField(b,"cus","phone",CUS_PHONE_LABEL[l],d.phone);a+=createInputTextField(b,"cus","mobil",CUS_MOBIL_LABEL[l],d.mobil);a+=createInputTextField(b,"cus","email","E-Mail",d.email);a+=createInputTextField(b,"cus","www",CUS_WWW_LABEL[l],d.www);a+=createTextAreaField(b,"cus","remark",CUS_REMARK_LABEL[l],d.remark);a+=createGroupList(d);a+="

";a+=CUS_CREATED[l]+": "+d.created+"
";a+=CUS_LAST_MODIFIED[l]+": "+d.lastmodified;a+="
";a+=createApplyDeleteButtons(b,"applycustomer","deletecustomer");a+="

";a+=createCollapsibleStartGeneral("allbills_"+b,CUS_BILLS[l],"e","billscollapsible",true);a+='

';a+="
";a+=createCollapsibleStartGeneral("allvacations_"+b,CUS_VACATIONS[l],"e","vacationcollapsible",true);a+='

';a+=createCollapsibleStartGeneral("newvacations_"+b,CUS_NEWVACATIONS[l],"c","newvacationscollapsible",true);a+=createDateTimePicker("cusfield_newcheckin_"+b,"Check-in","a");a+=createDateTimePicker("cusfield_newcheckout_"+b,"Check-out","a");a+=createInputTextField(b,"cus","cusfield_newroom",CUS_ROOM_LABEL[l],"");a+=createInputTextField(b,"cus","vacremark",CUS_REMARK_LABEL[l],"");a+=createApplyButton(b+"_newvacation",CUS_APPLY[l],"f","newvacation");a+="
";a+="";return a}function renderCustomers(b){var a="";for(var c=0;c
";a+=createInputTextField(b,"grp","name","Name",e.name);a+=createTextAreaField(b,"grp","remark",CUS_REMARK_LABEL[l],e.remark);var c=e.customers;if(c.length>0){a+="

";a+=CUS_CONTAINED_IN_GRP[l]+":
";for(var d=0;d"}a+="
"}a+="

";a+=CUS_CREATED[l]+": "+e.created+"
";a+="
";a+=createApplyDeleteButtons(b,"applygroup","deletegroup");a+=createCollapsibleStartGeneral("groupemail_"+b,"Email","e","groupemailentry",true);a+=createInputTextField(b,"grpemailsubject","grpemailsubject","Subject","");a+=createTextAreaField(b,"grpemailtext","grpemailtext","Text","");a+=createApplyButton(b+"_groupsendemail",CUS_SEND_EMAIL[l],"f","groupsendemail");a+="

"+CUS_EMAIL_WARNING[l]+"";a+="";a+="

";a+="";return a}function renderGroups(b){var a="";for(var c=0;c';e+='
  • '+CUS_GRP_ASS_LIST[l]+"
  • ";for(var d=0;d'+toHtml(c.name)+""}e+="";return e}function cusAlertTextLength(a){alert(CUS_ALERT_TEXT_LEN[l]+a)}function cusCheckTextLengths(a){if(a.name.length>50){cusAlertTextLength("Name");return false}if(a.addr.length>200){cusAlertTextLength(CUS_ADR_LABEL[l]);return false}if(a.phone.length>30){cusAlertTextLength(CUS_PHONE_LABEL[l]);return false}if(a.mobil.length>30){cusAlertTextLength(CUS_MOBIL_LABEL[l]);return false}if(a.email.length>50){cusAlertTextLength("Email");return false}if(a.www.length>50){cusAlertTextLength(CUS_WWW_LABEL[l]);return false}if(a.remark.length>500){cusAlertTextLength(CUS_REMARK_LABEL[l]);return false}return true}function customizeDatePicker(e,b){var d="de";if(l==1){d="en"}else{if(l==2){d="es"}}var a=new Date().getFullYear();var c=(a-10)+":"+(a+3);$(e).datepicker($.datepicker.regional[d]).datepicker("option",{changeMonth:true,changeYear:true,yearRange:c});if((b!=null)&&(b!="")){$(e).datepicker("setDate",new Date(b))}else{$(e).val("")}}function getDate(d){var c=$(d).val();if((c==undefined)||(c.trim()=="")){return null}var a=$(d).datepicker("getDate");var b={day:("0"+a.getDate()).slice(-2),month:("0"+(a.getMonth()+1)).slice(-2),year:a.getFullYear(),date:a};return b}function getCheckinouts(b,h){var d=getDate(b);var c=getDate(h);var a="";if((d!=null)&&(d!="")){a=d.year+"-"+d.month+"-"+d.day}var f="";if((c!=null)&&(c!="")){f=c.year+"-"+c.month+"-"+c.day}var e=true;if((d!=null)&&(d!="")&&(c!=null)&&(c!="")){if(d.date>c.date){e=false}}var g={checkin:a,checkout:f,valid:e};return g}; \ No newline at end of file +var allgroups=[];var customers=[];var decpoint=".";var currency="";var payments=[];function getGeneralConfigItemsCus(){$("#customersearch").val("");$("#groupsearch").val("");clearNewCustomerFields();clearNewGroupFields();doAjax("GET","php/contenthandler.php?module=admin&command=getGeneralConfigItems",null,insertConfigDoRest,"Fehler Konfigurationsdaten");doAjax("GET","php/contenthandler.php?module=customers&command=getPaymentsForGuest",null,insertPayments,"Fehler Zahlungswege",true);customizeDatePicker("#newcustomercheckin",null);customizeDatePicker("#newcustomercheckout",null);customizeDatePicker("#customerdate","")}function insertConfigDoRest(b){if(b.status==="OK"){var a=b.msg;$("#customersearch").val("");setLanguage(a.userlanguage);decpoint=a.decpoint;currency=a.currency;bindGroupsOrCustomerBtns();showCustomersArea();startSearch()}else{setTimeout(function(){document.location.href="index.html"},250)}}function insertPayments(d){if(d.status=="OK"){var c=d.msg;payments=[];for(var b=0;b";return a}function showCustomersArea(){$("#customersarea").show();$("#groupsarea").hide();$("#customersbtn").buttonMarkup({theme:"f"});$("#customersbtn").buttonMarkup({icon:"arrow-d"});$("#groupsbtn").buttonMarkup({theme:"c"});$("#groupsbtn").buttonMarkup({icon:"arrow-r"})}function showGroupsArea(){$("#customersarea").hide();$("#groupsarea").show();$("#customersbtn").buttonMarkup({theme:"c"});$("#customersbtn").buttonMarkup({icon:"arrow-r"});$("#groupsbtn").buttonMarkup({theme:"f"});$("#groupsbtn").buttonMarkup({icon:"arrow-d"})}function bindGroupsOrCustomerBtns(){$("#customersbtn").off("click").on("click",function(a){a.stopImmediatePropagation();a.preventDefault();showCustomersArea()});$("#groupsbtn").off("click").on("click",function(a){a.stopImmediatePropagation();a.preventDefault();showGroupsArea()});$("#newcustomerbtn").off("click").on("click",function(h){h.stopImmediatePropagation();h.preventDefault();var b=$("#newcustomername").val().trim();var k=$("#newcustomeremail").val().trim();var m=$("#newcustomeraddress").val().trim();var g=$("#newcustomerremark").val().trim();var i=$("#newcustomerphone").val().trim();var j=$("#newcustomermobil").val().trim();var c=$("#newcustomerwww").val().trim();var a=$("#newcustomerroom").val().trim();if(b===""){alert(CUS_EMPTY_NAME[l])}else{var f=getCheckinouts("#newcustomercheckin","#newcustomercheckout");if(!f.valid){alert(CUS_CHECKIN_AFTER_OUT[l]);return}var d={name:b,email:k,addr:m,remark:g,phone:i,mobil:j,www:c,checkin:f.checkin,checkout:f.checkout,room:a};if(!cusCheckTextLengths(d)){return}doAjax("POST","php/contenthandler.php?module=customers&command=createNewCustomer",d,handleCreateCustomerResult,"Gast anlegen unmöglich",true)}});$("#customersearch").off("keyup").on("keyup",function(a){startSearch()});$("#groupsearch").off("keyup").on("keyup",function(a){startSearch()});$("#newgroupbtn").off("click").on("click",function(c){c.stopImmediatePropagation();c.preventDefault();var a=$("#newgroupname").val().trim();var d=$("#newgroupremark").val().trim();if(a===""){alert(GROUP_EMPTY_NAME[l])}else{var b={name:a,remark:d};doAjax("POST","php/contenthandler.php?module=customers&command=createNewGroup",b,handleCreateGroupResult,"Gruppe anlegen unmöglich",true)}});$("#customerlog").off("click").on("click",function(a){a.stopImmediatePropagation();a.preventDefault();window.open("php/contenthandler.php?module=customers&command=exportLog","_blank")})}function bindOnDynamicCustomersBtn(){$(".applycustomer").off("click").on("click",function(g){g.stopImmediatePropagation();g.preventDefault();var j=this.id.split("_")[1];var a=[];for(var b=0;b200){cusAlertTextLength("Bemerkung");return false}var c=$("#cusfield_cusfield_newroom_"+a).val();if(c.length>50){cusAlertTextLength("Zimmer");return false}var b={id:a,checkin:g.checkin,checkout:g.checkout,room:c,remark:f};doAjax("POST","php/contenthandler.php?module=customers&command=newVacation",b,handleChangeVacationResult,"Aufenthalt anlegen unmöglich",true)});$(".delvacation").off("click").on("click",function(a){a.stopImmediatePropagation();a.preventDefault();var b=this.id.split("_")[1];doAjax("POST","php/contenthandler.php?module=customers&command=delVacation",{id:b},handleChangeVacationResult,"Aufenthalt löschen unmöglich",true)});$(".unpaybill").off("click").on("click",function(b){b.stopImmediatePropagation();b.preventDefault();var a=this.id.split("_")[1];$("#stornocode").val("");$("#stornoreason").val("");areYouSureCancel(CUS_STORNO_QUEST_TITLE[l],CUS_STORNO_QUEST_TEXT[l],CUS_YES[l],function(){var c={id:a,code:$("#stornocode").val(),remark:$("#stornoreason").val()};doAjax("POST","php/contenthandler.php?module=customers&command=unpay",c,handleChangeBillResult,"Deklaration als unbezahlt unmöglich",true)})});$(".paymentpay").off("click").on("click",function(d){d.stopImmediatePropagation();d.preventDefault();var g=this.id;var c=g.split("_");var a=c[2];var f=c[3];var b=c[4];if(b!="all"){doAjax("POST","php/contenthandler.php?module=customers&command=pay",{id:b,paymentid:f},handleChangeBillResult,"Deklaration als bezahlt unmöglich",true)}else{doAjax("POST","php/contenthandler.php?module=customers&command=payallbills",{id:a,paymentid:f},handleChangeBillResult,"Deklaration alle unmöglich",true)}});$(".printbill").off("click").on("click",function(b){b.stopImmediatePropagation();b.preventDefault();var a=this.id.split("_")[1];doAjax("POST","php/contenthandler.php?module=customers&command=printbill",{id:a},null,"Drucken unmöglich",true)});$(".printallbills").off("click").on("click",function(b){b.stopImmediatePropagation();b.preventDefault();var a=this.id.split("_")[1];doAjax("POST","php/contenthandler.php?module=customers&command=printallbills",{id:a},null,"Drucken alle unmöglich",true)})}function updateVacationsOfCustomer(a){doAjax("GET","php/contenthandler.php?module=customers&command=getVacations",{cusid:a},handleVacationsResult,null,true)}function updateBillsOfCustomer(a){doAjax("GET","php/contenthandler.php?module=customers&command=getBills",{cusid:a},handleBillsResult,null,true)}function handleVacationsResult(e){if(e.status==="OK"){var f=e.msg.vacations;var b=e.msg.cusid;var a="";for(var d=0;d0){if(d){a+="
    "+CUS_DECLARE_ALL_PAY[l]+":
    ";for(var c=0;cCheck-in: "+d;a+="

    Check-out: "+c;a+="

    "+CUS_ROOM_LABEL[l]+": "+f;a+="

    "+CUS_REMARK_LABEL[l]+g;a+=createDeleteButton(h+"_delvacation",CUS_DEL[l],"d","delvacation");a+="";return a}function renderABill(h,b,c,f,g,i){var a=f.replace(".",decpoint)+" "+currency;var e="c";if(i==1){e="f"}var d=createCollapsibleStartGeneral("billentry_"+h,c+" - "+a,e,"billentry",true);d+="

    "+CUS_BILLID[l]+": "+b;d+="

    "+CUS_BILLDATE[l]+": "+c;d+="

    "+CUS_BILLBRUTTO[l]+": "+c;if(i==0){d+=createPaymentsArea(h,b,CUS_DECLAREPAY[l])}else{d+=createApplyButton(b+"_unpaybill",CUS_DECLAREUNPAY[l],"d","unpaybill")}d+=createApplyButton(b+"_printbill",CUS_PRINTBILL[l],"f","printbill");d+="";return d}function handleEmailResult(a){if(a.status==="OK"){alert("Aktion abgeschlossen")}else{alert("Error: "+a.msg)}}function handleChangeVacationResult(b){if(b.status==="OK"){var a=b.cusid;$("#cusfield_newcheckin_"+a).val("");$("#cusfield_newcheckout_"+a).val("");$("#cusfield_cusfield_newroom_"+a).val("");$("#cusfield_vacremark_"+a).val("");updateVacationsOfCustomer(a)}else{alert("Error: "+b.msg)}}function handleChangeBillResult(b){if(b.status==="OK"){var a=b.cusid;updateBillsOfCustomer(a)}else{alert("Error: "+b.msg)}}function deleteCustomerCore(b){var a={id:b};doAjax("POST","php/contenthandler.php?module=customers&command=deleteCustomer",a,handleDeleteCustomerResult,"Gast löschen unmöglich",true)}function deleteGroupCore(b){var a={id:b};doAjax("POST","php/contenthandler.php?module=customers&command=deleteGroup",a,handleDeleteGroupResult,"Gruppe löschen unmöglich",true)}function areYouSureCus(c,b,a,d){$("#sure .sure-1").text(c);$("#sure .sure-2").text(b);$("#sure .sure-do").text(a).off("click.sure").on("click.sure",function(){d()});$(this).off("click.sure");$.mobile.changePage("#sure")}function startSearch(){var a={search:$("#groupsearch").val().trim()};doAjax("POST","php/contenthandler.php?module=customers&command=getGroups",a,handleGetGroupsResult,"Gästeabfrage unmöglich",true)}function startCustomerSearch(){var c=$("#customersearch").val().trim();var a=getDate("#customerdate");var d="";if((a!=null)&&(a!="")){d=a.year+"-"+a.month+"-"+a.day}var b=0;if($("#customeropenbills").is(":checked")){b=1}var e={search:c,date:d,onlyopenbills:b};doAjax("POST","php/contenthandler.php?module=customers&command=getCustomers",e,handleGetCustomerResult,"Gästeabfrage unmöglich",true)}function clearNewCustomerFields(){$("#newcustomername").val("");$("#newcustomeremail").val("");$("#newcustomeraddress").val("");$("#newcustomerremark").val("");$("#newcustomerphone").val("");$("#newcustomermobil").val("");$("#newcustomerwww").val("");$("#newcustomercheckin").val("");$("#newcustomercheckout").val("");$("#newcustomerroom").val("")}function handleCreateCustomerResult(a){if(a.status==="OK"){clearNewCustomerFields();if(a.code==1){var b=CUS_ALREADY_CUS_NAME[l];b=b.replace("%number%",a.value);alert(b)}startSearch()}else{alert(CUS_ACTION_FAILED[l]+": "+a.msg)}}function clearNewGroupFields(){$("#newgroupname").val("");$("#newgroupremark").val("")}function handleCreateGroupResult(a){if(a.status==="OK"){clearNewGroupFields();startSearch()}else{if(a.code==1){alert(CUS_GROUP_EXISTS[l])}else{alert(CUS_ACTION_FAILED[l]+": "+a.msg)}}}function handleChangeCustomerResult(a){if(a.status==="OK"){startSearch()}else{alert(CUS_ACTION_FAILED[l]+": "+a.msg)}}function handleDeleteCustomerResult(a){if(a.status==="OK"){startSearch()}else{alert(CUS_ACTION_FAILED[l]+": "+a.msg)}}function handleDeleteGroupResult(a){if(a.status==="OK"){startSearch()}else{alert(CUS_ACTION_FAILED[l]+": "+a.msg)}}function handleChangeGroupResult(a){if(a.status==="OK"){startSearch()}else{alert(CUS_ACTION_FAILED[l]+": "+a.msg)}}function createInputTextField(f,d,e,b,c){var a='

    ';a+=' ";a+=' ';a+="
    ";return a}function createTextAreaField(f,d,e,b,c){var a='
    ';a+=' ";a+=' ";a+="
    ";return a}function createDateTimePicker(d,b,c){var a='
    ';a+=' ";a+=' ';a+="
    ";return a}function createCollapsibleStartNew(d,b,c){var a='
    ';a+="

    "+toHtml(b)+"

    ";return a}function createCollapsibleStartGeneral(g,c,e,f,b){var d=" ";if(b===false){d=' style="display:none;" '}var a='
    ";a+="

    "+toHtml(c)+"

    ";return a}function createApplyButton(e,b,d,c){var a='";return a}function createDeleteButton(e,b,d,c){var a='";return a}function createApplyDeleteButtons(d,c,b){var a='
    ';a+='
    '+createApplyButton(d,CUS_APPLY[l],"f",c)+"
    ";a+='
    '+createDeleteButton(d,CUS_DEL[l],"d",b)+"
    ";a+="
    ";return a}function renderACustomer(d){var b=d.id;var c="";if((d.openbillsum!=null)&&(d.openbillsum!="")){c=" ("+d.openbillsum;c=c.replace(".",decpoint)+" "+currency+")"}var a=createCollapsibleStartNew(b,d.name+c,"c");a+="

    ";a+=createInputTextField(b,"cus","name","Name",d.name);a+=createTextAreaField(b,"cus","address",CUS_ADR_LABEL[l],d.address);a+=createInputTextField(b,"cus","phone",CUS_PHONE_LABEL[l],d.phone);a+=createInputTextField(b,"cus","mobil",CUS_MOBIL_LABEL[l],d.mobil);a+=createInputTextField(b,"cus","email","E-Mail",d.email);a+=createInputTextField(b,"cus","www",CUS_WWW_LABEL[l],d.www);a+=createTextAreaField(b,"cus","remark",CUS_REMARK_LABEL[l],d.remark);a+=createGroupList(d);a+="

    ";a+=CUS_CREATED[l]+": "+d.created+"
    ";a+=CUS_LAST_MODIFIED[l]+": "+d.lastmodified;a+="
    ";a+=createApplyDeleteButtons(b,"applycustomer","deletecustomer");a+="

    ";a+=createCollapsibleStartGeneral("allbills_"+b,CUS_BILLS[l],"e","billscollapsible",true);a+='

    ';a+="
    ";a+=createCollapsibleStartGeneral("allvacations_"+b,CUS_VACATIONS[l],"e","vacationcollapsible",true);a+='

    ';a+=createCollapsibleStartGeneral("newvacations_"+b,CUS_NEWVACATIONS[l],"c","newvacationscollapsible",true);a+=createDateTimePicker("cusfield_newcheckin_"+b,"Check-in","a");a+=createDateTimePicker("cusfield_newcheckout_"+b,"Check-out","a");a+=createInputTextField(b,"cus","cusfield_newroom",CUS_ROOM_LABEL[l],"");a+=createInputTextField(b,"cus","vacremark",CUS_REMARK_LABEL[l],"");a+=createApplyButton(b+"_newvacation",CUS_APPLY[l],"f","newvacation");a+="
    ";a+="";return a}function renderCustomers(b){var a="";for(var c=0;c
    ";a+=createInputTextField(b,"grp","name","Name",e.name);a+=createTextAreaField(b,"grp","remark",CUS_REMARK_LABEL[l],e.remark);var c=e.customers;if(c.length>0){a+="

    ";a+=CUS_CONTAINED_IN_GRP[l]+":
    ";for(var d=0;d"}a+="
    "}a+="

    ";a+=CUS_CREATED[l]+": "+e.created+"
    ";a+="
    ";a+=createApplyDeleteButtons(b,"applygroup","deletegroup");a+=createCollapsibleStartGeneral("groupemail_"+b,"Email","e","groupemailentry",true);a+=createInputTextField(b,"grpemailsubject","grpemailsubject","Subject","");a+=createTextAreaField(b,"grpemailtext","grpemailtext","Text","");a+=createApplyButton(b+"_groupsendemail",CUS_SEND_EMAIL[l],"f","groupsendemail");a+="

    "+CUS_EMAIL_WARNING[l]+"";a+="";a+="

    ";a+="";return a}function renderGroups(b){var a="";for(var c=0;c';e+='
  • '+CUS_GRP_ASS_LIST[l]+"
  • ";for(var d=0;d'+toHtml(c.name)+""}e+="";return e}function cusAlertTextLength(a){alert(CUS_ALERT_TEXT_LEN[l]+a)}function cusCheckTextLengths(a){if(a.name.length>50){cusAlertTextLength("Name");return false}if(a.addr.length>200){cusAlertTextLength(CUS_ADR_LABEL[l]);return false}if(a.phone.length>30){cusAlertTextLength(CUS_PHONE_LABEL[l]);return false}if(a.mobil.length>30){cusAlertTextLength(CUS_MOBIL_LABEL[l]);return false}if(a.email.length>50){cusAlertTextLength("Email");return false}if(a.www.length>50){cusAlertTextLength(CUS_WWW_LABEL[l]);return false}if(a.remark.length>500){cusAlertTextLength(CUS_REMARK_LABEL[l]);return false}return true}function customizeDatePicker(e,b){var d="de";if(l==1){d="en"}else{if(l==2){d="es"}}var a=new Date().getFullYear();var c=(a-10)+":"+(a+3);$(e).datepicker($.datepicker.regional[d]).datepicker("option",{changeMonth:true,changeYear:true,yearRange:c});if((b!=null)&&(b!="")){$(e).datepicker("setDate",new Date(b))}else{$(e).val("")}}function getDate(d){var c=$(d).val();if((c==undefined)||(c.trim()=="")){return null}var a=$(d).datepicker("getDate");var b={day:("0"+a.getDate()).slice(-2),month:("0"+(a.getMonth()+1)).slice(-2),year:a.getFullYear(),date:a};return b}function getCheckinouts(b,h){var d=getDate(b);var c=getDate(h);var a="";if((d!=null)&&(d!="")){a=d.year+"-"+d.month+"-"+d.day}var f="";if((c!=null)&&(c!="")){f=c.year+"-"+c.month+"-"+c.day}var e=true;if((d!=null)&&(d!="")&&(c!=null)&&(c!="")){if(d.date>c.date){e=false}}var g={checkin:a,checkout:f,valid:e};return g}function areYouSureCancel(c,b,a,d){$("#cancelsure .sure-1").text(c);$("#cancelsure .sure-2").text(b);$("#cancelsure .sure-do").text(a).off("click.cancelsure").on("click.cancelsure",function(f){f.stopImmediatePropagation();f.preventDefault();$("#nocancelbtn").off("click");$("#cancelsure").dialog("close");$.mobile.changePage("#info-page");d();$(this).off("click.cancelsure")});$("#nocancelbtn").off("click").on("click",function(f){f.stopImmediatePropagation();f.preventDefault();$("#cancelsure .sure-do").text(a).off("click.cancelsure");$("#cancelsure").dialog("close");$.mobile.changePage("#info-page")});$.mobile.changePage("#cancelsure");setTimeout(function(){$("#stornocode").val("");$("#stornoreason").val("")},1000)}; \ No newline at end of file diff --git a/webapp/feedback.html b/webapp/feedback.html index 38c4694..b85139c 100644 --- a/webapp/feedback.html +++ b/webapp/feedback.html @@ -4,7 +4,7 @@ - + diff --git a/webapp/index.html b/webapp/index.html index c9d6a45..f84201b 100644 --- a/webapp/index.html +++ b/webapp/index.html @@ -9,8 +9,8 @@ - - + + @@ -203,7 +203,7 @@ function handleResultOfInstallCheck(is_installed) { if (is_installed == "Yes") { useInstallation(); } else { - setTimeout(function(){document.location.href = "install.html?v=1.3.0"},500); + setTimeout(function(){document.location.href = "install.html?v=1.3.1"},500); } } diff --git a/webapp/install.html b/webapp/install.html index ed15c7a..dfa7d81 100644 --- a/webapp/install.html +++ b/webapp/install.html @@ -679,7 +679,7 @@ $(document).ready(function() {   - +   diff --git a/webapp/install/installer.php b/webapp/install/installer.php index 564c6fd..534a3ce 100644 --- a/webapp/install/installer.php +++ b/webapp/install/installer.php @@ -1780,6 +1780,34 @@ return false; } } +function updateUserTable1300_1301($prefix, $version, $dbname) { +$pdo = $this->pdo; +try { +if ($version != "1.3.0") { +$ret = $this->updateUserTable1222_1300($prefix, $version, $dbname); +if (!$ret) { +echo "Version update v1.2.22 to 1.3.0 not successful."; +return false; +} +} + +DbUtils::overrulePrefix($prefix); + +$this->basedb->createCustomerLogTable($pdo); + +$sql = "INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL,?,?)"; +$stmt = $pdo->prepare($this->basedb->resolveTablenamesInSqlString($sql)); +$stmt->execute(array('cancelguestcode','')); + + +$this->updateVersion($pdo, '1.3.1'); +return true; +} catch (PDOException $e) { +echo "Error in v1.3.0 to 1.3.1: $e"; +return false; +} +} + function setVersion($prefix,$theVersion) { $pdo = $this->pdo; @@ -1857,6 +1885,7 @@ $this->basedb->createGroupsTable($pdo); $this->basedb->createGroupCustomerTable($pdo); $this->basedb->createVacationsTable($pdo); $this->basedb->createBillTable($pdo); +$this->basedb->createCustomerLogTable($pdo); $this->basedb->createQueueTable($pdo); $this->basedb->createBillProductsTable($pdo); $this->basedb->createHistTables($pdo); @@ -1905,7 +1934,7 @@ $this->basedb->doSQL($pdo,"INSERT INTO `%config%` (`id` , `name`, `setting`) VAL $this->basedb->doSQL($pdo,"INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'billlanguage', $billlanguage)"); $this->basedb->doSQL($pdo,"INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'currency', '$currency')"); $this->basedb->doSQL($pdo,"INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'receiptfontsize', '12')"); -$this->basedb->doSQL($pdo,"INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'version', '1.3.0')"); +$this->basedb->doSQL($pdo,"INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'version', '1.3.1')"); $this->basedb->doSQL($pdo,"INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'paymentconfig', '0')"); $this->basedb->doSQL($pdo,"INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'remoteaccesscode', null)"); $this->basedb->doSQL($pdo,"INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'decpoint', '$decpoint')"); @@ -2286,7 +2315,7 @@ $zones[] = $timezone_identifiers[$i]; } echo json_encode($zones); } else if ($command == 'update') { -$installerVersion = "1.3.0"; +$installerVersion = "1.3.1"; $admin = new InstallAdmin(); $pdo = $admin->openDbAndReturnPdo($_POST['host'],$_POST['db'],$_POST['user'],$_POST['password']); @@ -2317,7 +2346,7 @@ $supportedVersions = array("1.0.22","1.0.23","1.0.24","1.0.25","1.0.26","1.0.27" "1.1.0","1.1.1","1.1.2","1.1.3","1.1.4","1.1.5","1.1.6","1.1.7","1.1.8", "1.1.9","1.1.10","1.1.11","1.1.12","1.1.13","1.1.14","1.1.15","1.1.16","1.1.17", "1.1.18","1.1.19","1.1.20","1.1.21","1.1.22","1.1.23","1.1.24","1.1.25","1.1.26","1.1.27","1.1.28","1.1.29","1.1.30", "1.2.0","1.2.1","1.2.2", "1.2.3", "1.2.4","1.2.5","1.2.6","1.2.7","1.2.8","1.2.9","1.2.10","1.2.11","1.2.12","1.2.13","1.2.14","1.2.15","1.2.16","1.2.17", -"1.2.18","1.2.19","1.2.20","1.2.21","1.2.22" +"1.2.18","1.2.19","1.2.20","1.2.21","1.2.22","1.3.0" ); if (!in_array($version, $supportedVersions)) { @@ -2325,7 +2354,7 @@ echo json_encode("Quellversion nicht unterstützt"); return; } -$ret = $admin->updateUserTable1222_1300($_POST['prefix'], $version, $_POST['db']); +$ret = $admin->updateUserTable1300_1301($_POST['prefix'], $version, $_POST['db']); if(session_id() == '') { session_start(); diff --git a/webapp/kitchen.html b/webapp/kitchen.html index 3785008..f343220 100644 --- a/webapp/kitchen.html +++ b/webapp/kitchen.html @@ -5,7 +5,7 @@ - + diff --git a/webapp/manager.html b/webapp/manager.html index c67e27d..265aa50 100644 --- a/webapp/manager.html +++ b/webapp/manager.html @@ -5,7 +5,7 @@ - + @@ -102,6 +102,7 @@ var MAN_XLSX_EXP_RECEIPTS = ["... Excel","... Excel","... Excel"]; var MAN_CSV_EXP_ALL = ["CSV-Export komplett","CSV export all","Grabar todo en CSV"]; var MAN_PRINT_ALL = ["Drucken Komplettbericht","Print all","Imprimir todo"]; var MAN_PRINT_RECEIPT = ["Drucken Zusammenfassung auf Bon","Print summary on receipt","Imprimir resumen en tique"]; +var MAN_CSV_EXP_GUEST = ["CSV-Export Gastbezahlprotokoll","CSV Export Guest payments log","CSV Export Pagos del cliente"]; var MAN_OF = [" vom "," of "," de "]; var MAN_PERIOD = ["Zeitraum: ","Period: ","Período: "]; var MAN_1ST_CLOSING = ["Erste Erstellung einer Tageslosung","First creation of a closing","Primer acción de cerrar"]; @@ -275,6 +276,7 @@ var MAN_TAX_USE = ["Wenn kein Steuersatz beim Produkt angegeben ist: MwSt/Tax/IV "If no tax is specified for a product, these tax settings are used. For Austria other tax settings are relevant, see above!", "Si no un producto no tiene un IVA asignado, se usa estas IVAs"]; var MAN_CANCEL_UNPAID_CODE = ["Stornierungscode unbez. Best.", "Cancel code unpaid items","Codigo para cancelor productos impagados"]; +var MAN_CANCEL_GUEST_CODE = ["Stornierungscode Bezahlung (Modul Gast)","Cancel code for payment (module guest)","Codigo para cancelar pagado por cliente"]; var MAN_ROOM_PRINTER_NO = ["Kategorieeinstellung","Category setting","Configuración/categoria"]; var MAN_ROOM_PRINTER_1 = ["Drucker 1","Printer 1","Imprimadora 1"]; @@ -371,6 +373,7 @@ var generalValuesSettings = [ ["reservationnote",MAN_RES_NOTE[lang],"i",0], ["remoteaccesscode",MAN_REMOTE_ACCESS[lang],"i",0,""], ["cancelunpaidcode",MAN_CANCEL_UNPAID_CODE[lang],"i",0,""], + ["cancelguestcode",MAN_CANCEL_GUEST_CODE[lang],"i",0,""], // REM SMTP settings ["smtphost",MAN_SMTPHOST[lang],"i",0,""], ["smtpauth",MAN_SMTPAUTH[lang],"s",5], @@ -635,6 +638,7 @@ function insertGeneralConfigItems(configResult) { $("#webimpressum").val(values.webimpressum); $("#cancelunpaidcode").val(values.cancelunpaidcode); + $("#cancelguestcode").val(values.cancelguestcode); $("#hsinfile").val(values.hsinfile); $("#hsoutfile").val(values.hsoutfile); @@ -1045,6 +1049,13 @@ function binding() { window.location.href = "php/contenthandler.php?module=closing&command=exportCsv&closingid=" + closingid; }); + $(".csvExportGuestButton").off("click").on("click", function (e) { + var button_id = this.id; + var pos_underscore = button_id.indexOf("_"); + var closingid = button_id.substr(pos_underscore+1,button_id.length-1); + window.location.href = "php/contenthandler.php?module=closing&command=exportGuestCsv&closingid=" + closingid; + }); + $(".csvEmailAllButton").off("click").on("click", function (e) { var button_id = this.id; var pos_underscore = button_id.indexOf("_"); @@ -2079,6 +2090,8 @@ function createClosingPart (aText,id,totalsum,cashsum,usersums,taxessums,cashops closingPart += ''; + closingPart += ''; + closingPart += '

    '; closingPart += ''; @@ -2500,6 +2513,10 @@ $(document).on("pageinit", "#admin-page", function () { +
    + + +
    diff --git a/webapp/paydesk.html b/webapp/paydesk.html index cabb3da..585321c 100644 --- a/webapp/paydesk.html +++ b/webapp/paydesk.html @@ -5,7 +5,7 @@ - + diff --git a/webapp/php/admin.php b/webapp/php/admin.php index d7c5e90..573d05a 100644 --- a/webapp/php/admin.php +++ b/webapp/php/admin.php @@ -777,6 +777,7 @@ class Admin { $version = CommonUtils::getConfigValue($pdo,"version",null); $payprinttype = CommonUtils::getConfigValue($pdo,"payprinttype",null); $cancelunpaidcode = CommonUtils::getConfigValue($pdo,"cancelunpaidcode",null); + $cancelguestcode = CommonUtils::getConfigValue($pdo,"cancelguestcode",null); $tax = CommonUtils::getConfigValue($pdo,"tax",null); $togotax = CommonUtils::getConfigValue($pdo,"togotax",null); $taxaustrianormal = CommonUtils::getConfigValue($pdo,"taxaustrianormal",null); @@ -863,7 +864,7 @@ class Admin { "rightchangeprice" => $right_changeprice, "bigfontworkreceipt" => $bigfontworkreceipt, "prominentsearch" => $prominentsearch,"groupworkitems" => $groupworkitems, "sday" => $now["mday"],"smonth" => $now["mon"], "syear" => $now["year"], "shour" => $now["hours"], "smin" => $now["minutes"], "smtphost" => $smtphost,"smtpauth" => $smtpauth,"smtpuser" => $smtpuser,"smtppass" => $smtppass,"smtpsecure" => $smtpsecure,"smtpport" => $smtpport, - "webimpressum" => $webimpressum, "cancelunpaidcode" => $cancelunpaidcode, "discount1" => $discount1,"discount2" => $discount2,"discount3" => $discount3, + "webimpressum" => $webimpressum, "cancelunpaidcode" => $cancelunpaidcode, "cancelguestcode" => $cancelguestcode, "discount1" => $discount1,"discount2" => $discount2,"discount3" => $discount3, "austria" => $austria, "digigopaysetready" => $digigopaysetready, "waitergopayprint" => $waitergopayprint, "oneprodworkreceipts" => $oneprodworkreceipts, "digiprintwork" => $digiprintwork, "memorylimit" => $memorylimit, "hs3refresh" => $hs3refresh, "paydeskid" => $paydeskid, "aeskey" => $aeskey, "certificatesn" => $certificatesn, "addreceipttoprinter" => $addreceipttoprinter, @@ -960,7 +961,7 @@ class Admin { $view = "preferences.html"; } - echo json_encode($view . "?v=1.3.0"); + echo json_encode($view . "?v=1.3.1"); } } @@ -1167,25 +1168,25 @@ class Admin { if (!self::isOnlyRatingUser($rights, $right_rating, true)) { if ($_SESSION['modus'] == 0) { - if ($_SESSION['right_waiter']) { $mainMenu[] = array("name" => $waitertxt[$lang], "link" => "waiter.html?v=1.3.0"); }; + if ($_SESSION['right_waiter']) { $mainMenu[] = array("name" => $waitertxt[$lang], "link" => "waiter.html?v=1.3.1"); }; } else { - if ($_SESSION['right_waiter']) { $mainMenu[] = array("name" => $waiterdesktxt[$lang], "link" => "waiterdesktop.php?v=1.3.0"); }; + if ($_SESSION['right_waiter']) { $mainMenu[] = array("name" => $waiterdesktxt[$lang], "link" => "waiterdesktop.php?v=1.3.1"); }; } - if ($_SESSION['right_kitchen']) { $mainMenu[] = array("name" => $kitchentxt[$lang], "link" => "kitchen.html?v=1.3.0"); }; - if ($_SESSION['right_bar']) { $mainMenu[] = array("name" => "Bar", "link" => "bar.html?v=1.3.0"); }; - if ($_SESSION['right_supply']) { $mainMenu[] = array("name" => $supplytxt[$lang], "link" => "supplydesk.html?v=1.3.0"); }; + if ($_SESSION['right_kitchen']) { $mainMenu[] = array("name" => $kitchentxt[$lang], "link" => "kitchen.html?v=1.3.1"); }; + if ($_SESSION['right_bar']) { $mainMenu[] = array("name" => "Bar", "link" => "bar.html?v=1.3.1"); }; + if ($_SESSION['right_supply']) { $mainMenu[] = array("name" => $supplytxt[$lang], "link" => "supplydesk.html?v=1.3.1"); }; if ($_SESSION['modus'] == 0) { - if ($_SESSION['right_paydesk']) { $mainMenu[] = array("name" => $paydesktxt[$lang], "link" => "paydesk.html?v=1.3.0"); }; + if ($_SESSION['right_paydesk']) { $mainMenu[] = array("name" => $paydesktxt[$lang], "link" => "paydesk.html?v=1.3.1"); }; } - if ($_SESSION['right_statistics']) { $mainMenu[] = array("name" => $stattxt[$lang], "link" => "reports.html?v=1.3.0"); }; - if ($_SESSION['right_bill']) { $mainMenu[] = array("name" => $bontxt[$lang], "link" => "bill.html?v=1.3.0"); }; - if ($_SESSION['right_products']) { $mainMenu[] = array("name" => $prodtxt[$lang], "link" => "products.html?v=1.3.0"); }; - if ($_SESSION['right_reservation']) { $mainMenu[] = array("name" => $restxt[$lang], "link" => "reservation.html?v=1.3.0"); }; - if ($_SESSION['right_rating']) { $mainMenu[] = array("name" => $ratingtxt[$lang], "link" => "rating.html?v=1.3.0"); }; - if ($_SESSION['right_customers']) { $mainMenu[] = array("name" => $customerstxt[$lang], "link" => "customers.html?v=1.3.0"); }; - if ($_SESSION['right_manager'] || $_SESSION['is_admin'] || $_SESSION['right_closing']) { $mainMenu[] = array("name" => $admintxt[$lang], "link" => "manager.html?v=1.3.0"); }; - $mainMenu[] = array("name" => $settingtxt[$lang], "link" => "preferences.html?v=1.3.0"); - $mainMenu[] = array("name" => "Feedback", "link" => "feedback.html?v=1.3.0"); + if ($_SESSION['right_statistics']) { $mainMenu[] = array("name" => $stattxt[$lang], "link" => "reports.html?v=1.3.1"); }; + if ($_SESSION['right_bill']) { $mainMenu[] = array("name" => $bontxt[$lang], "link" => "bill.html?v=1.3.1"); }; + if ($_SESSION['right_products']) { $mainMenu[] = array("name" => $prodtxt[$lang], "link" => "products.html?v=1.3.1"); }; + if ($_SESSION['right_reservation']) { $mainMenu[] = array("name" => $restxt[$lang], "link" => "reservation.html?v=1.3.1"); }; + if ($_SESSION['right_rating']) { $mainMenu[] = array("name" => $ratingtxt[$lang], "link" => "rating.html?v=1.3.1"); }; + if ($_SESSION['right_customers']) { $mainMenu[] = array("name" => $customerstxt[$lang], "link" => "customers.html?v=1.3.1"); }; + if ($_SESSION['right_manager'] || $_SESSION['is_admin'] || $_SESSION['right_closing']) { $mainMenu[] = array("name" => $admintxt[$lang], "link" => "manager.html?v=1.3.1"); }; + $mainMenu[] = array("name" => $settingtxt[$lang], "link" => "preferences.html?v=1.3.1"); + $mainMenu[] = array("name" => "Feedback", "link" => "feedback.html?v=1.3.1"); } $mainMenu[] = array("name" => $logout[$lang], "link" => "logout.php"); @@ -1194,7 +1195,7 @@ class Admin { $waiterMessage = $this->getMessage(null, "waitermessage"); } // CAUTION: change version also in config.txt!!! - $mainMenuAndVersion = array ("version" => "OrderSprinter 1.3.0", + $mainMenuAndVersion = array ("version" => "OrderSprinter 1.3.1", "user" => $currentUser, "menu" => $mainMenu, "waitermessage" => $waiterMessage, @@ -1469,6 +1470,7 @@ class Admin { "remoteaccesscode" => array("dbcol" => "remoteaccesscode","checknum" => 0), "webimpressum" => array("dbcol" => "webimpressum","checknum" => 0), "cancelunpaidcode" => array("dbcol" => "cancelunpaidcode","checknum" => 0), + "cancelguestcode" => array("dbcol" => "cancelguestcode","checknum" => 0), "printandqueuejobs" => array("dbcol" => "printandqueuejobs","checknum" => 0), "cashenabled" => array("dbcol" => "cashenabled","checknum" => 0), "beepcooked" => array("dbcol" => "beepcooked","checknum" => 0), @@ -1932,13 +1934,13 @@ class Admin { private function getAllTablesToBackupRestore() { return array("closing","logo","printjobs","ratings","work","payment","room","resttables","tablepos","tablemaps","pricelevel","prodtype","products","config", - "user","reservations","customers","groups","groupcustomer","vacations","bill","queue","billproducts","hsin","hsout","comments","histprod","histconfig","histuser","histactions","hist", + "user","reservations","customers","groups","groupcustomer","vacations","bill","customerlog","queue","billproducts","hsin","hsout","comments","histprod","histconfig","histuser","histactions","hist", "extras","extrasprods","queueextras"); } private function getAllWithLogsTablesToBackupRestore() { return array("log","closing","logo","printjobs","ratings","work","payment","room","resttables","tablepos","tablemaps","pricelevel","prodtype","products","config", - "user","reservations","customers","groups","groupcustomer","vacations","bill","queue","billproducts","hsin","hsout","comments","histprod","histconfig","histuser","histactions","hist", + "user","reservations","customers","groups","groupcustomer","vacations","bill","customerlog","queue","billproducts","hsin","hsout","comments","histprod","histconfig","histuser","histactions","hist", "extras","extrasprods","queueextras"); } diff --git a/webapp/php/closing.php b/webapp/php/closing.php index b5a4268..e6db29d 100644 --- a/webapp/php/closing.php +++ b/webapp/php/closing.php @@ -4,6 +4,7 @@ require_once ('dbutils.php'); require_once ('commonutils.php'); require_once ('globals.php'); require_once ('admin.php'); +require_once ('customers.php'); require_once ('utilities/Emailer.php'); class Closing { @@ -34,6 +35,8 @@ $this->createClosing($_POST['remark']); $this->getClosings($_GET['month'], $_GET['year']); } else if ($command == 'exportCsv') { $this->exportCsv($_GET['closingid']); +} else if ($command == 'exportGuestCsv') { +$this->exportGuestCsv($_GET['closingid']); } else if ($command == 'emailCsv') { $this->emailCsv($_GET['closingid'],$_GET['emailaddress'],$_GET['topic']); } else if ($command == 'getClosing') { @@ -324,6 +327,14 @@ $pdo = DbUtils::openDbAndReturnPdoStatic(); $this->retrieveClosingFromDb($pdo,$closingid, true, false); } +private function exportGuestCsv($closingid) { +$pdo = DbUtils::openDbAndReturnPdoStatic(); +$prevClosingDate = self::getDateOfPreviousClosing($pdo,$closingid); +$sql = "SELECT closingdate FROM %closing% WHERE id=?"; +$curClosingDateRow = CommonUtils::getRowSqlObject($pdo, $sql, array($closingid)); +$curClosingDate = $curClosingDateRow->closingdate; +Customers::exportLog($pdo, $prevClosingDate, $curClosingDate); +} private function emailCsvCore($pdo,$closingid,$toEmail,$topic,$startdate,$enddate,$billsum,$billcount) { $msg = $this->retrieveClosingFromDb($pdo,$closingid, false, true); diff --git a/webapp/php/customers.php b/webapp/php/customers.php index be82f39..ab6a16b 100644 --- a/webapp/php/customers.php +++ b/webapp/php/customers.php @@ -29,9 +29,14 @@ class Customers { "printbill" => array("loggedin" => 1, "isadmin" => 0, "rights" => array("customers")), "payallbills" => array("loggedin" => 1, "isadmin" => 0, "rights" => array("customers")), "printallbills" => array("loggedin" => 1, "isadmin" => 0, "rights" => array("customers")), - "emailGroup" => array("loggedin" => 1, "isadmin" => 0, "rights" => array("customers")) + "emailGroup" => array("loggedin" => 1, "isadmin" => 0, "rights" => array("customers")), + "exportLog" => array("loggedin" => 1, "isadmin" => 0, "rights" => array("customers")), + "getPaymentsForGuest" => array("loggedin" => 1, "isadmin" => 0, "rights" => array("customers")) ); + public static $CANCEL = 0; + public static $PAY = 1; + private static function checkRights($command) { if(session_id() == '') { session_start(); @@ -114,17 +119,21 @@ class Customers { } else if ($command == 'getBills') { echo json_encode($this->getBills($pdo,$_GET['cusid'])); } else if ($command == 'pay') { - echo json_encode($this->pay($pdo,$_POST['id'])); + echo json_encode($this->pay($pdo,$_POST['id'],$_POST['paymentid'])); } else if ($command == 'unpay') { - echo json_encode($this->unpay($pdo,$_POST['id'])); + echo json_encode($this->unpay($pdo,$_POST['id'],$_POST["code"],$_POST["remark"])); } else if ($command == 'printbill') { echo json_encode($this->printBill($pdo,$_POST['id'])); } else if ($command == 'payallbills') { - echo json_encode($this->payallbills($pdo,$_POST['id'])); + echo json_encode($this->payallbills($pdo,$_POST['id'],$_POST['paymentid'])); } else if ($command == 'printallbills') { echo json_encode($this->printallbills($pdo,$_POST['id'])); } else if ($command == 'emailGroup') { echo json_encode($this->emailGroup($pdo,$_POST['groupid'],$_POST["subject"],$_POST["text"])); + } else if ($command == 'getPaymentsForGuest') { + echo json_encode($this->getPaymentsForGuest($pdo)); + } else if ($command == 'exportLog') { + self::exportLog($pdo); } else { echo "Command not supported."; } @@ -172,7 +181,7 @@ class Customers { $cusid = $pdo->lastInsertId(); self::addVacationsCore($pdo,$cusid,$checkin,$checkout,$room,null); - $pdo->commit();; + $pdo->commit(); return array("status" => "OK","code" => $code, "value" => $number); } catch (Exception $e) { $pdo->rollBack(); @@ -267,14 +276,18 @@ class Customers { } } - private static function payOrUnpay($pdo,$id,$value) { + private static function payOrUnpay($pdo,$id,$value,$doTransaction,$remark=null) { try { - $pdo->beginTransaction(); + if ($doTransaction) { + $pdo->beginTransaction(); + } $sql = "SELECT count(id) as countid FROM %bill% WHERE id=?"; $row = CommonUtils::getRowSqlObject($pdo, $sql, array($id)); if ($row->countid != 1) { - $pdo->rollBack(); - return array("status" => "ERROR","msg" => "Bill entry not found"); + if ($doTransaction) { + $pdo->rollBack(); + } + return array("status" => "ERROR","msg" => "Bill with id=$id not found"); } else { $sql = "SELECT intguestid FROM %bill% WHERE id=?"; $row = CommonUtils::getRowSqlObject($pdo, $sql, array($id)); @@ -282,20 +295,43 @@ class Customers { $sql = "UPDATE %bill% SET intguestpaid=? WHERE id=?"; CommonUtils::execSql($pdo, $sql, array($value,$id)); - $pdo->commit(); + + date_default_timezone_set(DbUtils::getTimeZone()); + $currentTime = date('Y-m-d H:i:s'); + if(session_id() == '') { + session_start(); + } + $userid = $_SESSION['userid']; + $sql = "INSERT INTO %customerlog% (date,action,customerid,userid,billid,remark) VALUES(?,?,?,?,?,?)"; + $action = (is_null($value) ? self::$CANCEL : self::$PAY); + CommonUtils::execSql($pdo, $sql, array($currentTime,$action,$cusid,$userid,$id,$remark)); + + if ($doTransaction) { + $pdo->commit(); + } return array("status" => "OK","cusid" => $cusid); } } catch (Exception $ex) { - $pdo->rollBack(); + if ($doTransaction) { + $pdo->rollBack(); + } return array("status" => "ERROR","msg" => $ex->getMessage()); } } - private function pay($pdo,$id) { - return (self::payOrUnpay($pdo, $id, 1)); + private function pay($pdo,$id,$paymentid) { + $paymentname = self::getPaymentName($pdo,$paymentid); + return (self::payOrUnpay($pdo, $id, 1,true,$paymentname)); } - private function unpay($pdo,$id) { - return (self::payOrUnpay($pdo, $id, null)); + private function unpay($pdo,$id,$code,$remark) { + $stornocode = CommonUtils::getConfigValue($pdo, 'cancelguestcode', null); + if (is_null($stornocode)) { + return array("status" => "ERROR","msg" => "Es wurde noch kein Stornocode in der Verwaltung festgelegt"); + } + if ($stornocode != $code) { + return array("status" => "ERROR","msg" => "Falscher Stornocode"); + } + return (self::payOrUnpay($pdo, $id, null,true,$remark)); } private function printBill($pdo,$billid) { @@ -321,11 +357,19 @@ class Customers { return array("status" => "OK"); } - private function payallbills($pdo,$cusid) { + private function payallbills($pdo,$cusid,$paymentid) { try { $pdo->beginTransaction(); - $sql = "UPDATE %bill% SET intguestpaid=? WHERE intguestid=?"; - CommonUtils::execSql($pdo, $sql, array(1,$cusid)); + $paymentname = self::getPaymentName($pdo,$paymentid); + $sql = "SELECT id FROM %bill% WHERE intguestpaid is null AND intguestid=?"; + $result = CommonUtils::fetchSqlAll($pdo, $sql, array($cusid)); + foreach($result as $aBill) { + $ok = self::payOrUnpay($pdo, $aBill["id"], 1,false,$paymentname); + if ($ok["status"] != "OK") { + $pdo->rollBack(); + return $ok; + } + } $pdo->commit(); return array("status" => "OK","cusid" => $cusid); } catch (Exception $ex) { @@ -557,4 +601,85 @@ class Customers { return array("status" => "ERROR","msg" => 'Not all emails could be sent'); } } -} \ No newline at end of file + + public static function exportLog($pdo,$startDate = null, $endDate = null) { + header("Content-type: text/x-csv"); + header("Content-Disposition: attachment; filename=Gastbezahlungen.csv"); + header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); + header("Pragma: no-cache"); + header("Expires: 0"); + + echo("Datum; Gast-ID; Gastname; Bon-ID; Aktion; Benutzer-ID; Benutzername; Stornobemerkung oder Zahlungsweg\n"); + + $sql = "SELECT %customerlog%.date as date,CASE WHEN action=0 THEN 'Bezahlung storniert' WHEN action=1 THEN 'bezahlt' ELSE 'undefiniert' END as action,"; + $sql .= " %customerlog%.billid as billid,%customerlog%.remark as remark, userid, username, customerid, %user%.username as username, %customers%.name as customername "; + $sql .= " FROM %customerlog%,%user%,%customers% "; + $sql .= " WHERE (userid=%user%.id AND customerid=%customers%.id) "; + + $where = ''; + + if (is_null($startDate) && (!is_null($endDate))) { + $where = " AND (date <= '$endDate') "; + } else if (!is_null($startDate) && (!is_null($endDate))) { + $where = " AND (date <= '$endDate') AND (date >= '$startDate') "; + } + $sql .= $where; + + $result = CommonUtils::fetchSqlAll($pdo, $sql, null); + + foreach($result as $aLog) { + echo $aLog["date"] . ";"; + echo $aLog["customerid"] . ";"; + echo self::quoteForCsv($aLog["customername"]) . ";"; + echo $aLog["billid"] . ";"; + echo $aLog["action"] . ";"; + echo $aLog["userid"] . ";"; + echo self::quoteForCsv($aLog["username"]) . ";"; + echo self::quoteForCsv($aLog["remark"]) . ";"; + echo "\r\n"; + } + } + + public static function quoteForCsv($txt) { + $txt = str_replace("\"","\"\"",$txt); + return '"' . $txt . '"'; + } + + + private function getPaymentsForGuest($pdo) { + if(session_id() == '') { + session_start(); + } + + $where = " WHERE (id <> 7) AND (id <> 8)"; + + $lang = $_SESSION['language']; + $sql = "SELECT id,name FROM %payment% $where"; + if ($lang == 1) { + $sql = "SELECT id,name_en as name FROM %payment% $where"; + } else if ($lang == 2) { + $sql = "SELECT id,name_esp as name FROM %payment% $where"; + } + + $result = CommonUtils::fetchSqlAll($pdo, $sql, null); + + return array("status" => "OK","msg" => $result); + } + + private static function getPaymentName ($pdo,$paymentid) { + if(session_id() == '') { + session_start(); + } + + $lang = $_SESSION['language']; + $sql = "SELECT id,name FROM %payment% WHERE id=?"; + if ($lang == 1) { + $sql = "SELECT id,name_en as name FROM %payment% WHERE id=?"; + } else if ($lang == 2) { + $sql = "SELECT id,name_esp as name FROM %payment% WHERE id=?"; + } + + $row = CommonUtils::getRowSqlObject($pdo, $sql, array($paymentid)); + return $row->name; + } +} diff --git a/webapp/php/dbutils.php b/webapp/php/dbutils.php index b9abf8a..dcb33f4 100644 --- a/webapp/php/dbutils.php +++ b/webapp/php/dbutils.php @@ -2,43 +2,6 @@ // Datenbank-Verbindungsparameter require_once ('config.php'); -define ('DB_QUEUE_TABLE', TAB_PREFIX . 'queue'); -define ('DB_PRODUCTS_TABLE', TAB_PREFIX . 'products'); -define ('DB_USER_TABLE', TAB_PREFIX . 'user'); -define ('DB_ROOM_TABLE', TAB_PREFIX . 'room'); -define ('DB_RESTTABLES_TABLE', TAB_PREFIX . 'resttables'); -define ('DB_PRODTYPE_TABLE', TAB_PREFIX . 'prodtype'); -define ('DB_TABLEMAPS_TABLE', TAB_PREFIX . 'tablemaps'); -define ('DB_TABLEPOS_TABLE', TAB_PREFIX . 'tablepos'); -define ('DB_BILL_TABLE', TAB_PREFIX . 'bill'); -define ('DB_CUSTOMERS_TABLE', TAB_PREFIX . 'customers'); -define ('DB_GROUPS_TABLE', TAB_PREFIX . 'groups'); -define ('DB_GROUPCUSTOMER_TABLE', TAB_PREFIX . 'groupcustomer'); -define ('DB_VACATIONS_TABLE', TAB_PREFIX . 'vacations'); -define ('DB_PRICELEVEL_TABLE', TAB_PREFIX . 'pricelevel'); -define ('DB_CONFIG_TABLE', TAB_PREFIX . 'config'); -define ('DB_CLOSING_TABLE', TAB_PREFIX . 'closing'); -define ('DB_PRINTJOB_TABLE', TAB_PREFIX . 'printjob'); -define ('DB_WORK_TABLE', TAB_PREFIX . 'work'); -define ('DB_COMMENTS_TABLE', TAB_PREFIX . 'comments'); -define ('DB_HSIN_TABLE', TAB_PREFIX . 'hsin'); -define ('DB_HSOUT_TABLE', TAB_PREFIX . 'hsout'); -define ('DB_LOGO_TABLE', TAB_PREFIX . 'logo'); -define ('DB_EXTRAS_TABLE', TAB_PREFIX . 'extras'); -define ('DB_EXTRASPRODS_TABLE', TAB_PREFIX . 'extrasprods'); - -define ('DB_HIST_TABLE', TAB_PREFIX . 'hist'); -define ('DB_HIST_PROD_TABLE', TAB_PREFIX . 'histprod'); -define ('DB_HIST_CONFIG_TABLE', TAB_PREFIX . 'histconfig'); -define ('DB_HIST_USER_TABLE', TAB_PREFIX . 'histuser'); -define ('DB_HIST_ACTIONS_TABLE', TAB_PREFIX . 'histactions'); - -define ('DB_HIST_PAYMENT_TABLE', TAB_PREFIX . 'payment'); -define ('DB_BILLPRODUCTS_TABLE', TAB_PREFIX . 'billproducts'); -define ('DB_RESERVATIONS_TABLE', TAB_PREFIX . 'reservations'); -define ('DB_QUEUEEXTRAS_TABLE', TAB_PREFIX . 'queueextras'); -define ('DB_RATINGS_TABLE', TAB_PREFIX . 'ratings'); - class DbUtils { private static $timezone = null; private static $prefix = null; @@ -81,7 +44,6 @@ class DbUtils { function testDbAccess($host,$dbname,$user,$pass) { $dsn = 'mysql:host=' . $host . ';dbname=' . $dbname; - $user = $user; $password = $pass; $pdo = null; try { @@ -109,13 +71,17 @@ class DbUtils { if (!is_null(self::$prefix)) { $prefix = self::$prefix; } - + return self::substTableAliasCore($sqlString, $prefix); + } + + public static function substTableAliasCore($sqlString,$prefix) { $out = str_replace("%queue%",$prefix . 'queue',$sqlString); $out = str_replace("%products%",$prefix . 'products',$out); $out = str_replace("%user%",$prefix . 'user',$out); $out = str_replace("%room%",$prefix . 'room',$out); $out = str_replace("%resttables%",$prefix . 'resttables',$out); $out = str_replace("%bill%",$prefix . 'bill',$out); + $out = str_replace("%customerlog%", $prefix . 'customerlog', $out); $out = str_replace("%customers%",$prefix . 'customers',$out); $out = str_replace("%groups%",$prefix . 'groups',$out); $out = str_replace("%groupcustomer%",$prefix . 'groupcustomer',$out); @@ -219,5 +185,4 @@ class DbUtils { array("col" => 'audio', "hist" => 1, "property" => "audio"), array("col" => 'removed', "hist" => 0) ); -} -?> \ No newline at end of file +} \ No newline at end of file diff --git a/webapp/php/products.php b/webapp/php/products.php index 225a611..f221e9e 100644 --- a/webapp/php/products.php +++ b/webapp/php/products.php @@ -142,6 +142,22 @@ class Products { } } + private static $proddefs = array( + array("id" => "id","get" => "%products%.id as id","histid" => "prodid","histget" => "prodid","histexportname" => "Produktid","isnumber" => "0"), + array("id" => "shortname", "get" => "shortname","histid" => "shortname","histget" => "shortname","histexportname" => "Kurzname","isnumber" => "0"), + array("id" => "longname", "get" => "longname","histid" => "longname","histget" => "longname","histexportname" => "Langname","isnumber" => "0"), + array("id" => "available", "get" => "available","histid" => "available","histget" => "available","histexportname" => "","histexportname" => "Verfügbarkeit","isnumber" => "0"), + array("id" => "priceA", "get" => "priceA","histid" => "priceA","histget" => "priceA","histexportname" => "Preis (Stufe A)","isnumber" => "1"), + array("id" => "priceB", "get" => "priceB","histid" => "priceB","histget" => "priceB","histexportname" => "Preis (Stufe B)","isnumber" => "1"), + array("id" => "priceC", "get" => "priceC","histid" => "priceC","histget" => "priceC","histexportname" => "Preis (Stufe C)","isnumber" => "1"), + array("id" => "tax", "get" => "IF(tax is not null, tax, 'null') as tax","histid" => "tax","histget" => "tax","histexportname" => "Steuer","isnumber" => "1"), + array("id" => "taxaustria", "get" => "IF(taxaustria is not null, taxaustria, 'null') as taxaustria","histid" => "","histget" => "","histexportname" => "","isnumber" => "0"), + array("id" => "amount", "get" => "IF(amount is not null, amount, 'null') as amount","histid" => "","histget" => "","histexportname" => "","isnumber" => "0"), + array("id" => "audio", "get" => "IF(audio is not null, audio, '') as audio","histid" => "","histget" => "","histexportname" => "","isnumber" => "0"), + array("id" => "favorite", "get" => "IF(favorite is not null, favorite, '') as favorite","histid" => "prodid","histget" => "favorite","histexportname" => "Favorit","isnumber" => "0"), + array("id" => "type", "get" => "'p' as type","histid" => "","histget" => "","histexportname" => "","isnumber" => "0"), + ); + function getDateValueAsBoolInterpretatedIcon($aValue) { if ($aValue != '0' ) { $imgFile = "ok.png"; @@ -254,28 +270,22 @@ class Products { */ private function getProductsWithReferenz($pdo,$ref) { $prods = array(); - $sql = "SELECT id,shortname,longname,priceA,priceB,priceC,IF(tax is not null, tax, 'null') as tax,IF(taxaustria is not null, taxaustria, 'null') as taxaustria,available,IF(amount is not null, amount, 'null') as amount,audio from %products% where removed is null AND category is null ORDER BY sorting"; + + $sqlselecttxt = self::getSqlSearchForProducts(); + + $sql = "SELECT $sqlselecttxt from %products% where removed is null AND category is null ORDER BY sorting"; if ($ref > 0) { - $sql = "SELECT id,shortname,longname,priceA,priceB,priceC,IF(tax is not null, tax, 'null') as tax,IF(taxaustria is not null, taxaustria, 'null') as taxaustria,available,IF(amount is not null, amount, 'null') as amount,audio from %products% where removed is null AND category=$ref ORDER BY sorting"; + $sql = "SELECT $sqlselecttxt from %products% where removed is null AND category=$ref ORDER BY sorting"; } $stmt = $pdo->prepare(DbUtils::substTableAlias($sql)); $stmt->execute(); $result = $stmt->fetchAll(); foreach($result as $zeile) { - $prod_entry = array( - "id" => $zeile['id'], - "shortname" => $zeile['shortname'], - "longname" => $zeile['longname'], - "available" => $zeile['available'], - "priceA" => $zeile['priceA'], - "priceB" => $zeile['priceB'], - "priceC" => $zeile['priceC'], - "tax" => $zeile['tax'], - "taxaustria" => $zeile['taxaustria'], - "amount" => $zeile['amount'], - "audio" => ($zeile['audio'] == null ? '' : $zeile['audio']), - "type" => "p"); + $prod_entry = array("type" => "p"); + foreach(self::$proddefs as $aProdDef) { + $prod_entry[$aProdDef["id"]] = $zeile[$aProdDef["id"]]; + } $prods[] = $prod_entry; } @@ -378,12 +388,13 @@ class Products { } $containedTypes = $stmt->fetchAll(PDO::FETCH_OBJ); + $sqlselecttxt = self::getSqlSearchForProducts(); if (!is_null($ref) && ($ref>0)) { - $sql = "SELECT id,shortname,longname,priceA,priceB,priceC,IF(tax is not null, tax, 'null') as tax,IF(taxaustria is not null, taxaustria, 'null') as taxaustria,available,IF(amount is not null, amount, 'null') as amount,favorite,audio,'p' as type from %products% where removed is null AND category=? ORDER BY sorting"; + $sql = "SELECT $sqlselecttxt from %products% where removed is null AND category=? ORDER BY sorting"; $stmt = $pdo->prepare($this->dbutils->resolveTablenamesInSqlString($sql)); $stmt->execute(array($ref)); } else { - $sql = "SELECT id,shortname,longname,priceA,priceB,priceC,IF(tax is not null, tax, 'null') as tax,IF(taxaustria is not null, taxaustria, 'null') as taxaustria,available,IF(amount is not null, amount, 'null') as amount,favorite,audio,'p' as type from %products% where removed is null AND category is null ORDER BY sorting"; + $sql = "SELECT $sqlselecttxt from %products% where removed is null AND category is null ORDER BY sorting"; $stmt = $pdo->prepare($this->dbutils->resolveTablenamesInSqlString($sql)); $stmt->execute(); } @@ -437,6 +448,35 @@ class Products { return($row->setting); } + public static function getSqlSearchForProducts() { + $sqlselect = array(); + foreach(self::$proddefs as $aProdDef) { + $sqlselect[] = $aProdDef["get"]; + } + return (join(",",$sqlselect)); + } + + public static function getSqlSearchForHistProducts() { + $sqlselect = array(); + foreach(self::$proddefs as $aProdDef) { + $theHistId = $aProdDef["histget"]; + if ($theHistId != '') { + $sqlselect[] = $aProdDef["histget"]; + } + } + return (join(",",$sqlselect)); + } + + public static function getHistProdExportNames() { + $sqlselect = array(); + foreach(self::$proddefs as $aProdDef) { + $theHistId = $aProdDef["histexportname"]; + if ($theHistId != '') { + $sqlselect[] = $aProdDef["histexportname"]; + } + } + return (join(";",$sqlselect)); + } private function exportCsv() { $pdo = DbUtils::openDbAndReturnPdoStatic(); @@ -447,12 +487,14 @@ class Products { header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Pragma: no-cache"); header("Expires: 0"); - echo("Eintragsid; Datum ; Produktid; Kurzname; Langname; Preis (Stufe A); Preis (Stufe B);"); - echo("Preis (Stufe C); Steuer; Verfügbarkeit; Favorit; Extras/Optionen; Beschreibung"); + echo("Eintragsid; Datum ;"); + echo self::getHistProdExportNames(); + echo("; Extras/Optionen; Beschreibung"); echo("\n"); $sql = "SELECT DISTINCT %hist%.id as id,date,"; - $sql .= "prodid,shortname,longname,priceA,priceB,priceC,IF(tax is not null, tax, '-') as tax,available,favorite,extras,description "; + $sql .= self::getSqlSearchForHistProducts(); + $sql .= ",extras,description "; $sql .= " FROM %hist%, %histprod%, %histactions% "; $sql .= " WHERE (refid=%histprod%.id) "; $sql .= " AND (action='1' OR action='4' OR action='5') "; @@ -463,21 +505,35 @@ class Products { $stmt->execute(); $result = $stmt->fetchAll(); foreach($result as $zeile) { - $val1 = $zeile['id']; - $val2 = $zeile['date']; - $val3 = $zeile['prodid']; - $val4 = str_replace('"','""',$zeile['shortname']); - $val5 = str_replace('"','""',$zeile['longname']); - $val6 = str_replace(".",$decpoint,$zeile['priceA']); - $val7 = str_replace(".",$decpoint,$zeile['priceB']); - $val8 = str_replace(".",$decpoint,$zeile['priceC']); - $val9 = str_replace(".",$decpoint,$zeile['tax']); - $val10 = ($zeile['available'] == '1' ? "Ja" : "Nein"); - $val11 = ($zeile['favorite'] == '1' ? "Ja" : "Nein"); - $val12 = $zeile['extras']; - $val13 = $zeile['description']; - - echo "$val1; $val2; $val3; \"$val4\"; \"$val5\"; $val6; $val7; $val8; $val9; $val10; $val11; $val12; $val13\n"; + echo $zeile['id'] . ";" . $zeile['date'] . ";"; + foreach(self::$proddefs as $aProdDef) { + $item = $aProdDef["histexportname"]; + $itemsql = $aProdDef["histget"]; + if ($item != "") { + if ($itemsql == 'tax') { + // IF(tax is not null, tax, '-') as tax + $value = ($zeile['tax']); + if ($value == null) { + $value = '-'; + } + $value = str_replace(".",$decpoint,$value); + } else if ($itemsql == 'available') { + $value = ($zeile['available'] == '1' ? "Ja" : "Nein"); + } else if ($itemsql == 'favorite') { + $value = ($zeile['favorite'] == '1' ? "Ja" : "Nein"); + } else { + $isNumber = $aProdDef["isnumber"]; + $value = $zeile[$aProdDef["histget"]]; + if ($isNumber == '1') { + $value = str_replace(".",$decpoint,$value); + } else { + $value = str_replace('"','""',$value); + } + } + echo $value . ";"; + } + } + echo $zeile['extras'] . ";" . $zeile['description'] . "\n"; } } @@ -654,8 +710,6 @@ class Products { } private function delExtra($id) { - // TODO: hist! - // TODO: extrasprods cleanen try { $pdo = $this->dbutils->openDbAndReturnPdo(); $sql = "UPDATE %extras% SET removed='1' WHERE id=?"; @@ -995,17 +1049,6 @@ class Products { function createProduct(ProductEntry $prodEntry) { $typeId = $prodEntry->getCategory(); - $available = $prodEntry->getAvailable(); - $favorite = $prodEntry->getFavorite(); - $priceA = $prodEntry->getPriceA(); - $priceB = $prodEntry->getPriceB(); - $priceC = $prodEntry->getPriceC(); - $tax = $prodEntry->getTax(); - $taxaustria = $prodEntry->getTaxAustria(); - $audioFile = $prodEntry->getAudio(); - $shortname = $prodEntry->getShortName(); - $longname = $prodEntry->getLongName(); - $amount = $prodEntry->getAmount(); if (!is_numeric($typeId)) { return; diff --git a/webapp/php/utilities/basedb.php b/webapp/php/utilities/basedb.php index 8a219b8..f70ad71 100644 --- a/webapp/php/utilities/basedb.php +++ b/webapp/php/utilities/basedb.php @@ -91,43 +91,7 @@ class Basedb { } function resolveTablenamesInSqlString($sqlString) { - $out = str_replace("%queue%",$this->prefix . "queue",$sqlString); - $out = str_replace("%products%",$this->prefix . "products",$out); - $out = str_replace("%user%",$this->prefix . "user",$out); - $out = str_replace("%room%",$this->prefix . "room",$out); - $out = str_replace("%resttables%",$this->prefix . "resttables",$out); - $out = str_replace("%tablemaps%",$this->prefix . "tablemaps",$out); - $out = str_replace("%tablepos%",$this->prefix . "tablepos",$out); - $out = str_replace("%bill%",$this->prefix . "bill",$out); - $out = str_replace("%customers%",$this->prefix . "customers",$out); - $out = str_replace("%groups%",$this->prefix . "groups",$out); - $out = str_replace("%groupcustomer%",$this->prefix . "groupcustomer",$out); - $out = str_replace("%vacations%",$this->prefix . "vacations",$out); - $out = str_replace("%pricelevel%",$this->prefix . "pricelevel",$out); - $out = str_replace("%config%",$this->prefix . "config",$out); - $out = str_replace("%closing%",$this->prefix . "closing",$out); - $out = str_replace("%printjobs%",$this->prefix . "printjob",$out); - $out = str_replace("%hist%",$this->prefix . "hist",$out); - $out = str_replace("%histprod%",$this->prefix . "histprod",$out); - $out = str_replace("%histconfig%",$this->prefix . "histconfig",$out); - $out = str_replace("%histuser%",$this->prefix . "histuser",$out); - $out = str_replace("%histactions%",$this->prefix . "histactions",$out); - $out = str_replace("%payment%",$this->prefix . "payment",$out); - $out = str_replace("%billproducts%",$this->prefix . "billproducts",$out); - $out = str_replace("%work%",$this->prefix . "work",$out); - $out = str_replace("%comments%",$this->prefix . "comments",$out); - $out = str_replace("%hsin%",$this->prefix . "hsin",$out); - $out = str_replace("%hsout%",$this->prefix . "hsout",$out); - $out = str_replace("%reservations%",$this->prefix . "reservations",$out); - $out = str_replace("%logo%",$this->prefix . "logo",$out); - $out = str_replace("%log%",$this->prefix . "log",$out); - $out = str_replace("%extras%",$this->prefix . "extras",$out); - $out = str_replace("%extrasprods%",$this->prefix . "extrasprods", $out); - $out = str_replace("%queueextras%",$this->prefix . "queueextras", $out); - $out = str_replace("%ratings%",$this->prefix . "ratings", $out); - $out = str_replace("%hsin%",$this->prefix . "hsin", $out); - $out = str_replace("%hsout%",$this->prefix . "hsout", $out); - return (str_replace("%prodtype%",$this->prefix . "prodtype",$out)); + return DbUtils::substTableAliasCore($sqlString, $this->prefix); } function dropTables($pdo) { @@ -149,6 +113,7 @@ class Basedb { $this->doSQLcatch($pdo, "drop TABLE `%billproducts%`"); $this->doSQLcatch($pdo, "drop TABLE `%queue%`"); $this->doSQLcatch($pdo, "drop TABLE `%printjobs%`"); + $this->doSQLcatch($pdo, "drop TABLE `%customerlog%`"); $this->doSQLcatch($pdo, "drop TABLE `%bill%`"); $this->doSQLcatch($pdo, "drop TABLE `%ratings%`"); $this->doSQLcatch($pdo, "drop TABLE `%user%`"); @@ -171,46 +136,25 @@ class Basedb { $this->doSQLcatch($pdo, "drop TABLE `%logo%`"); $this->doSQLcatch($pdo, "drop TABLE `%log%`"); } + - function dropTablesNoCatch($pdo) { - $this->doSQL($pdo, "DROP TABLE `%hsin%`"); - $this->doSQL($pdo, "DROP TABLE `%hsout%`"); - $this->doSQL($pdo, "DROP TABLE `%comments%`"); - $this->doSQL($pdo, "DROP TABLE `%reservations%`"); - $this->doSQL($pdo, "DROP TABLE `%work%`"); - $this->doSQL($pdo, "DROP TABLE `%hist%`"); - $this->doSQL($pdo, "DROP TABLE `%histprod%`"); - $this->doSQL($pdo, "DROP TABLE `%histconfig%`"); - $this->doSQL($pdo, "DROP TABLE `%histuser%`"); - $this->doSQL($pdo, "DROP TABLE `%histactions%`"); - - $this->doSQL($pdo, "drop TABLE `%queueextras%`"); - $this->doSQL($pdo, "drop TABLE `%extrasprods%`"); - $this->doSQL($pdo, "drop TABLE `%extras%`"); - - $this->doSQL($pdo, "drop TABLE `%billproducts%`"); - $this->doSQL($pdo, "drop TABLE `%queue%`"); - $this->doSQL($pdo, "drop TABLE `%printjobs%`"); - $this->doSQL($pdo, "drop TABLE `%bill%`"); - $this->doSQL($pdo, "drop TABLE `%ratings%`"); - $this->doSQL($pdo, "drop TABLE `%user%`"); - $this->doSQL($pdo, "drop TABLE `%closing%`"); - $this->doSQL($pdo, "drop TABLE `%config%`"); - $this->doSQL($pdo, "drop TABLE `%products%`"); - $this->doSQL($pdo, "drop TABLE `%prodtype%`"); - $this->doSQL($pdo, "drop TABLE `%pricelevel%`"); - $this->doSQL($pdo, "drop TABLE `%tablepos%`"); - $this->doSQL($pdo, "drop TABLE `%tablemaps%`"); - $this->doSQL($pdo, "drop TABLE `%resttables%`"); - $this->doSQL($pdo, "drop TABLE `%room%`"); - $this->doSQL($pdo, "drop TABLE `%payment%`"); - $this->doSQL($pdo, "drop TABLE `%logo%`"); - $this->doSQL($pdo, "drop TABLE `%log%`"); - - $this->doSQL($pdo, "drop TABLE `%groupcustomer%`"); - $this->doSQL($pdo, "drop TABLE `%vacations%`"); - $this->doSQL($pdo, "drop TABLE `%groups%`"); - $this->doSQL($pdo, "drop TABLE `%customers%`"); + function createCustomerLogTable($pdo) { + $sql = " + CREATE TABLE `%customerlog%` ( + `id` INT (3) NOT NULL AUTO_INCREMENT PRIMARY KEY, + `date` DATETIME NULL, + `customerid` INT(10) NULL, + `billid` INT(10) NULL, + `action` INT(2) NULL, + `userid` INT(3) NULL, + `remark` VARCHAR ( 500 ) NULL, + FOREIGN KEY (billid) REFERENCES %bill%(id), + FOREIGN KEY (customerid) REFERENCES %customers%(id), + FOREIGN KEY (userid) REFERENCES %user%(id) + ) CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE = InnoDb + "; + $stmt = $pdo->prepare($this->resolveTablenamesInSqlString($sql)); + $stmt->execute(); } function createLogTable($pdo) { @@ -875,6 +819,7 @@ class Basedb { $this->createGroupCustomerTable($pdo); $this->createVacationsTable($pdo); $this->createBillTable($pdo); + $this->createCustomerLogTable($pdo); $this->createQueueTable($pdo); $this->createBillProductsTable($pdo); $this->createHistTables($pdo); diff --git a/webapp/preferences.html b/webapp/preferences.html index 3331cb8..e8f0f93 100644 --- a/webapp/preferences.html +++ b/webapp/preferences.html @@ -5,7 +5,7 @@ - + diff --git a/webapp/products.html b/webapp/products.html index 9f90152..001a292 100644 --- a/webapp/products.html +++ b/webapp/products.html @@ -7,7 +7,7 @@ - + diff --git a/webapp/rating.html b/webapp/rating.html index ecbab2f..59f59c1 100644 --- a/webapp/rating.html +++ b/webapp/rating.html @@ -7,7 +7,7 @@ - + diff --git a/webapp/reports.html b/webapp/reports.html index 8ffbaa9..1ba10c1 100644 --- a/webapp/reports.html +++ b/webapp/reports.html @@ -7,7 +7,7 @@ - + diff --git a/webapp/reservation.html b/webapp/reservation.html index 5b5547c..ac41387 100644 --- a/webapp/reservation.html +++ b/webapp/reservation.html @@ -5,7 +5,7 @@ - + diff --git a/webapp/supplydesk.html b/webapp/supplydesk.html index 9a1d2fe..5943232 100644 --- a/webapp/supplydesk.html +++ b/webapp/supplydesk.html @@ -5,7 +5,7 @@ - + diff --git a/webapp/waiter.html b/webapp/waiter.html index 477c069..1fa5624 100644 --- a/webapp/waiter.html +++ b/webapp/waiter.html @@ -4,7 +4,7 @@ - +