diff --git a/gastsystem/index.php b/gastsystem/index.php index 350c56c..773bc72 100644 --- a/gastsystem/index.php +++ b/gastsystem/index.php @@ -9,8 +9,8 @@ - - + + @@ -97,10 +97,16 @@

Bestellvorgang

Sollen noch weitere Speisen oder Getränke bestellt werden? -

-
-
-
+ + +

@@ -109,11 +115,10 @@
-
  OrderSprinter
-
1.5.33  
+
1.6.1  
diff --git a/gastsystem/install.php b/gastsystem/install.php index 146679c..c74c168 100644 --- a/gastsystem/install.php +++ b/gastsystem/install.php @@ -114,10 +114,10 @@ if (isset($_POST['code'])) { } else { echo ""; echo "Installation Gastsystem"; - echo ''; + echo ''; echo ""; echo "
"; - echo "Installation OrderSprinter-Gastsystem 1.5.33

"; + echo "Installation OrderSprinter-Gastsystem 1.6.1

"; echo "
"; echo "
"; echo "
"; diff --git a/gastsystem/js/ordering.js b/gastsystem/js/ordering.js index 811a4c5..5b31d4b 100644 --- a/gastsystem/js/ordering.js +++ b/gastsystem/js/ordering.js @@ -1 +1 @@ -$(document).on("pageinit","#guest-page",function(){var a=Date.now();$("#logoarea").html('');intervalCheckLastOsSystemAccess(5);getTables()});var selectedTableid=null;var syncisWorking=false;var dailycode=null;var tablecode=null;var products=null;var types=null;var currency="";var decpoint=".";var selectedproduct=null;var selectedtable=null;var timeout=0;var timecounter=0;var askdaycode=1;var asktablecode=1;var fetchTimer=null;var orders=[];var tablevalues=[];function intervalCheckLastOsSystemAccess(b){doAjax("GET","php/ossystem.php?command=getsystemstatus",null,insertSyncIsWorking,true);var a=setInterval(function(){doAjax("GET","php/ossystem.php?command=getsystemstatus",null,insertSyncIsWorking,true)},b*1000)}function timeouting(){if(fetchTimer!=null){clearTimeout(fetchTimer)}if(timeout!=0){timecounter=0;fetchTimer=setInterval(function(){updateTimer()},1000)}}function createReadableTimeValue(c){var b=Math.floor(c/60);var a=c%60;if(a<10){a="0"+a.toString()}return"Verbleibende Zeit bis Neuanmeldung: "+b+":"+a+"  "}function updateTimer(){if(timecounter>0){$("#timecounter").show();$("#timecounter").html(createReadableTimeValue(timecounter))}else{$("#timecounter").hide()}if(timecounter>0){timecounter--;if(timecounter==0){var a=$("#tableselection").is(":visible");if(!a){$(".notcollapsible").hide();getTables()}}}}function insertSyncIsWorking(c){if(c.status=="OK"){if(c.msg.lastaccessok==1){syncisWorking=true}else{syncisWorking=false}if(syncisWorking){$("#warningdiv").hide()}else{$("#warningdiv").show()}var a=c.msg.dbwritestatus;var d=a.writeable;if(d==0){var b=a.file;if(a.reason!=""){b+=" (Zusatzinfo: "+a.reason+")"}$("#writeprotectedfile").html(b);$("#warningdiv2").show()}else{$("#warningdiv2").hide()}}}function getTables(){orders=[];doAjax("GET","php/tables.php?command=gettables",null,insertTables,"Fehler beim Abruf der Tische",true)}function preventCollapsible(){$(".notcollapsible").off("collapsiblecollapse").on("collapsiblecollapse",function(a){a.stopImmediatePropagation();a.preventDefault();var b=this.id;$("#"+b).collapsible("expand")})}function insertTables(b){if(b.status!="OK"){alert("Es ist ein Fehler aufgetreten: "+b.msg)}else{currency=b.currency;decpoint=b.decpoint;timeout=b.timeout;askdaycode=b.askdaycode;asktablecode=b.asktablecode;var a="";a+=fillSelectionBox("tableselect",b.msg,"Tischauswahl");$("#tableselectionbox").html(a);$("#tableselection").show();$("#tableselection").trigger("create");preventCollapsible();$("#tableselectionbox").off("change").on("change",function(c){c.stopImmediatePropagation();c.preventDefault();selectedTableid=$("#tableselect").val();if(selectedTableid!=(-1)){$("#tableselection").hide();handleCodeInput()}});timeouting()}}function handleCodeInput(){if((askdaycode==0)&&(asktablecode==0)){tablecode="empty";dailycode="empty";timecounter=timeout;initProductsView();return}$("#tablecodediv").show();preventCollapsible();if(askdaycode==1){tablecode="empty";$("#daycodearea").show()}if(asktablecode==1){dailycode="empty";$("#tablecodearea").show()}$("#tablecodefield").val("");$("#dailycodefield").val("");$("#codebackbtn").off("click").on("click",function(a){a.stopImmediatePropagation();a.preventDefault();hideCodeAreas();$("#tablecodediv").hide();getTables()});$("#submitcodesbtn").off("click").on("click",function(b){b.stopImmediatePropagation();b.preventDefault();tablecode=$("#tablecodefield").val().trim();dailycode=$("#dailycodefield").val().trim();var a={tableid:selectedTableid,tablecode:tablecode,dailycode:dailycode};doAjax("POST","php/tables.php?command=checkcodes",a,handleCodeCheck,"Fehler bei der Abfrage der Codes",true)})}function hideCodeAreas(){$("#daycodearea").hide();$("#tablecodearea").hide()}function handleCodeCheck(a){if(a.status!="OK"){alert(a.msg)}else{hideCodeAreas();timecounter=timeout;initProductsView()}}function fillSelectionBox(f,b,d){tablevalues=b;var e='
';e+='";return e}function toHtml(a){return(a.replace(/"/g,""").replace(//g,">"))}function initProductsView(){doAjax("POST","php/menu.php?command=getmenu",null,showProductsView,"Fehler bei der Abfrage der Speisekarte",true)}function showProductsView(a){timecounter=timeout;preventCollapsible();if(a.status!="OK"){alert("Fehler: "+a.msg);$("#productsdiv").hide();getTables()}else{products=a.msg.products;types=a.msg.types;showProdTypes(0);$("#tablecodediv").hide();$("#productsdiv").show();$("#prodbackbtn").off("click").on("click",function(b){b.stopImmediatePropagation();b.preventDefault();$("#productsdiv").hide();getTables()})}}function showProdTypes(c){timecounter=timeout;var a=createTypesHtml(c);if(a!=null){$("#typesdiv").html(a);$("#typesdiv").trigger("create")}bindProdTypes();var b=createProdsHtml(c);if(b!=null){$("#prodsdiv").show();$("#prodsdiv").html(b);$("#prodsdiv").trigger("create");bindProducts()}else{$("#prodsdiv").hide()}preventCollapsible()}function bindProducts(){$(".product").off("click").on("click",function(c){c.stopImmediatePropagation();c.preventDefault();var b=this.id.split("_")[1];selectedproduct=b;$("#productsdiv").hide();$("#prodconfirmdiv").show();timecounter=timeout;var a=getProductName(selectedproduct);$("#selectedprod").html(toHtml(a));bindProdConfirm()})}function bindProdTypes(){$(".prodtype").off("click").on("click",function(b){b.stopImmediatePropagation();b.preventDefault();var a=this.id.split("_")[1];showProdTypes(a)});$(".up").off("click").on("click",function(b){b.stopImmediatePropagation();b.preventDefault();var a=this.id.split("_")[1];showProdTypes(a)})}function createTypesHtml(d){if(types==null){return null}var c='";return c}function getParentOfReference(c){for(var b=0;b";if(f){return g}else{return null}}function getProdDetails(e){for(var d=0;d';if(c){b+=''}b+=toHtml(a.prodname);b+=" ("+a.price+")";return b}function bindProdConfirm(){$("#prodconfirmbackbtn").off("click").on("click",function(a){a.stopImmediatePropagation();a.preventDefault();$("#prodconfirmdiv").hide();initProductsView()});$("#prodconfirmbtn").off("click").on("click",function(b){b.stopImmediatePropagation();b.preventDefault();var a={prodid:selectedproduct,tableid:selectedTableid,dailycode:dailycode,tablecode:tablecode};doAjax("POST","php/queue.php?command=putintoqueue",a,askForMore,"Fehler beim Senden der Produktdaten",true)})}function askForMore(a){if(a.status!="OK"){alert("Fehler: "+a.msg)}else{var b=Date.now();orders[orders.length]={prodid:selectedproduct,ordertime:b};createOrdersList("#orderslist");$("#prodconfirmdiv").hide();$("#askformorediv").show();timecounter=timeout;preventCollapsible();$("#askformorenobtn").off("click").on("click",function(c){c.stopImmediatePropagation();c.preventDefault();$("#askformorediv").hide();getTables()});$("#askformoreyesbtn").off("click").on("click",function(c){c.stopImmediatePropagation();c.preventDefault();$("#askformorediv").hide();initProductsView()})}}function createOrdersList(a){var d='
    ';d+='
  • Bestellte Produkte für den Tisch "'+toHtml(getNameOfSelectedTable())+'"
  • ';for(var c=0;c";$(a).html(d);$(a).trigger("create")}function getNameOfSelectedTable(){for(var a=0;a');intervalCheckLastOsSystemAccess(5);tablesPreselected=false;var c=location.search;if(c.length!=0){var a=c.slice(1);var f=a.split("=");if((f.length>=2)&&(f[0]=="code")){var b=f[1];var e=b.split("_");if(e.length>=2){tablecode=e[0];selectedTableid=e[1];tablesPreselected=true}}}getTables()});var tablesPreselected=false;var selectedTableid=null;var syncisWorking=false;var dailycode=null;var tablecode=null;var products=null;var types=null;var currency="";var decpoint=".";var selectedproduct=null;var selectedtable=null;var timeout=0;var timecounter=0;var askdaycode=1;var asktablecode=1;var fetchTimer=null;var orders=[];var tablevalues=[];function intervalCheckLastOsSystemAccess(b){doAjax("GET","php/ossystem.php?command=getsystemstatus",null,insertSyncIsWorking,true);var a=setInterval(function(){doAjax("GET","php/ossystem.php?command=getsystemstatus",null,insertSyncIsWorking,true)},b*1000)}function timeouting(){if(fetchTimer!=null){clearTimeout(fetchTimer)}if(timeout!=0){timecounter=0;fetchTimer=setInterval(function(){updateTimer()},1000)}}function createReadableTimeValue(c){var b=Math.floor(c/60);var a=c%60;if(a<10){a="0"+a.toString()}return"Verbleibende Zeit bis Neuanmeldung: "+b+":"+a+"  "}function updateTimer(){if(timecounter>0){$("#timecounter").show();$("#timecounter").html(createReadableTimeValue(timecounter))}else{$("#timecounter").hide()}if(timecounter>0){timecounter--;if(timecounter==0){var a=$("#tableselection").is(":visible");if(!a){$(".notcollapsible").hide();getTables()}}}}function insertSyncIsWorking(c){if(c.status=="OK"){if(c.msg.lastaccessok==1){syncisWorking=true}else{syncisWorking=false}if(syncisWorking){$("#warningdiv").hide()}else{$("#warningdiv").show()}var a=c.msg.dbwritestatus;var d=a.writeable;if(d==0){var b=a.file;if(a.reason!=""){b+=" (Zusatzinfo: "+a.reason+")"}$("#writeprotectedfile").html(b);$("#warningdiv2").show()}else{$("#warningdiv2").hide()}}}function requestTableInfoWithoutGUI(){doAjax("GET","php/tables.php?command=gettables",null,insertTablesNoGui,"Fehler beim Abruf der Tische",true)}function requestTableInfoWithGUI(){orders=[];doAjax("GET","php/tables.php?command=gettables",null,insertTables,"Fehler beim Abruf der Tische",true)}function getTables(){if(tablesPreselected){requestTableInfoWithoutGUI()}else{requestTableInfoWithGUI()}}function preventCollapsible(){$(".notcollapsible").off("collapsiblecollapse").on("collapsiblecollapse",function(a){a.stopImmediatePropagation();a.preventDefault();var b=this.id;$("#"+b).collapsible("expand")})}function insertTablesNoGui(a){if(a.status!="OK"){alert("Es ist ein Fehler aufgetreten: "+a.msg)}else{currency=a.currency;decpoint=a.decpoint;timeout=a.timeout;askdaycode=a.askdaycode;asktablecode=a.asktablecode;tablevalues=a.msg;timeouting();handleCodeInput()}}function insertTables(b){if(b.status!="OK"){alert("Es ist ein Fehler aufgetreten: "+b.msg)}else{currency=b.currency;decpoint=b.decpoint;timeout=b.timeout;askdaycode=b.askdaycode;asktablecode=b.asktablecode;var a="";a+=fillSelectionBox("tableselect",b.msg,"Tischauswahl");$("#tableselectionbox").html(a);$("#tableselection").show();$("#tableselection").trigger("create");preventCollapsible();$("#tableselectionbox").off("change").on("change",function(c){c.stopImmediatePropagation();c.preventDefault();selectedTableid=$("#tableselect").val();if(selectedTableid!=(-1)){$("#tableselection").hide();handleCodeInput()}});timeouting()}}function handleCodeInput(){if((askdaycode==0)&&tablesPreselected){startCodeCheck(selectedTableid,tablecode,"empty");return}if((askdaycode==0)&&(asktablecode==0)){if(!tablesPreselected){tablecode="empty"}dailycode="empty";timecounter=timeout;initProductsView();return}$("#tablecodediv").show();preventCollapsible();if(askdaycode==1){if(!tablesPreselected){tablecode="empty"}$("#daycodearea").show()}if((asktablecode==1)&&!tablesPreselected){dailycode="empty";$("#tablecodearea").show()}$("#tablecodefield").val("");$("#dailycodefield").val("");$("#codebackbtn").off("click").on("click",function(a){a.stopImmediatePropagation();a.preventDefault();hideCodeAreas();$("#tablecodediv").hide();getTables()});$("#submitcodesbtn").off("click").on("click",function(a){a.stopImmediatePropagation();a.preventDefault();if(!tablesPreselected){tablecode=$("#tablecodefield").val().trim()}dailycode=$("#dailycodefield").val().trim();startCodeCheck(selectedTableid,tablecode,dailycode)})}function startCodeCheck(a,d,b){var c={tableid:a,tablecode:d,dailycode:b};doAjax("POST","php/tables.php?command=checkcodes",c,handleCodeCheck,"Fehler bei der Abfrage der Codes",true)}function hideCodeAreas(){$("#daycodearea").hide();$("#tablecodearea").hide()}function handleCodeCheck(a){if(a.status!="OK"){alert(a.msg)}else{hideCodeAreas();timecounter=timeout;initProductsView()}}function fillSelectionBox(f,b,d){tablevalues=b;var e='
    ';e+='";return e}function toHtml(a){return(a.replace(/"/g,""").replace(//g,">"))}function initProductsView(){doAjax("POST","php/menu.php?command=getmenu",null,showProductsView,"Fehler bei der Abfrage der Speisekarte",true)}function showProductsView(a){timecounter=timeout;preventCollapsible();if(a.status!="OK"){alert("Fehler: "+a.msg);$("#productsdiv").hide();getTables()}else{products=a.msg.products;types=a.msg.types;showProdTypes(0);$("#tablecodediv").hide();$("#productsdiv").show();$("#prodbackbtn").off("click").on("click",function(b){b.stopImmediatePropagation();b.preventDefault();$("#productsdiv").hide();getTables()})}}function showProdTypes(c){timecounter=timeout;var a=createTypesHtml(c);if(a!=null){$("#typesdiv").html(a);$("#typesdiv").trigger("create")}bindProdTypes();var b=createProdsHtml(c);if(b!=null){$("#prodsdiv").show();$("#prodsdiv").html(b);$("#prodsdiv").trigger("create");bindProducts()}else{$("#prodsdiv").hide()}preventCollapsible()}function bindProducts(){$(".product").off("click").on("click",function(c){c.stopImmediatePropagation();c.preventDefault();var b=this.id.split("_")[1];selectedproduct=b;$("#productsdiv").hide();$("#prodconfirmdiv").show();timecounter=timeout;var a=getProductName(selectedproduct);$("#selectedprod").html(toHtml(a));bindProdConfirm()})}function bindProdTypes(){$(".prodtype").off("click").on("click",function(b){b.stopImmediatePropagation();b.preventDefault();var a=this.id.split("_")[1];showProdTypes(a)});$(".up").off("click").on("click",function(b){b.stopImmediatePropagation();b.preventDefault();var a=this.id.split("_")[1];showProdTypes(a)})}function createTypesHtml(d){if(types==null){return null}var c='";return c}function getParentOfReference(c){for(var b=0;b";if(f){return g}else{return null}}function getProdDetails(e){for(var d=0;d';if(c){b+=''}b+=toHtml(a.prodname);b+=" ("+a.price+")";return b}function bindProdConfirm(){$("#prodconfirmbackbtn").off("click").on("click",function(a){a.stopImmediatePropagation();a.preventDefault();$("#prodconfirmdiv").hide();initProductsView()});$("#prodconfirmbtn").off("click").on("click",function(b){b.stopImmediatePropagation();b.preventDefault();var a={prodid:selectedproduct,tableid:selectedTableid,dailycode:dailycode,tablecode:tablecode};doAjax("POST","php/queue.php?command=putintoqueue",a,askForMore,"Fehler beim Senden der Produktdaten",true)})}function askForMore(a){if(a.status!="OK"){alert("Fehler: "+a.msg)}else{var b=Date.now();orders[orders.length]={prodid:selectedproduct,ordertime:b};createOrdersList("#orderslist");$("#prodconfirmdiv").hide();$("#askformorediv").show();if(tablesPreselected){$("#askformoreyesno").hide();$("#askformoreonlyyes").show()}else{$("#askformoreyesno").show();$("#askformoreonlyyes").hide()}timecounter=timeout;preventCollapsible();$("#askformorenobtn").off("click").on("click",function(c){c.stopImmediatePropagation();c.preventDefault();$("#askformorediv").hide();getTables()});$("#askformoreyesbtn").off("click").on("click",function(c){c.stopImmediatePropagation();c.preventDefault();$("#askformorediv").hide();initProductsView()});$("#askformoreyesbtn2").off("click").on("click",function(c){c.stopImmediatePropagation();c.preventDefault();$("#askformorediv").hide();initProductsView()})}}function createOrdersList(a){var d='
      ';d+='
    • Bestellte Produkte für den Tisch "'+toHtml(getNameOfSelectedTable())+'"
    • ';for(var c=0;c";$(a).html(d);$(a).trigger("create")}function getNameOfSelectedTable(){for(var a=0;a "OK","msg" => "Installation successful"); diff --git a/webapp/OrderSprinterPrintserver.exe b/webapp/OrderSprinterPrintserver.exe old mode 100644 new mode 100755 index a6838bc..bff5d93 Binary files a/webapp/OrderSprinterPrintserver.exe and b/webapp/OrderSprinterPrintserver.exe differ diff --git a/webapp/bar.html b/webapp/bar.html index e6414a0..de31156 100644 --- a/webapp/bar.html +++ b/webapp/bar.html @@ -5,7 +5,7 @@ - + @@ -13,8 +13,8 @@ - - + + +


              '; + echo join("
              ", $frame); + echo '






      '; + + } else { + + foreach ($frame as &$frameLine) { + $frameLine = join(' ', explode("\xc0", $frameLine)); + $frameLine = join('', explode("\xc1", $frameLine)); + $frameLine = join(' ', explode("\xa0", $frameLine)); + $frameLine = join('', explode("\xa1", $frameLine)); + $frameLine = join('', explode("\x84", $frameLine)); //format 0 + $frameLine = join('', explode("\x85", $frameLine)); //format 1 + $frameLine = join('', explode("\x81", $frameLine)); //special bit + $frameLine = join(' ', explode("\x90", $frameLine)); //clock 0 + $frameLine = join('', explode("\x91", $frameLine)); //clock 1 + $frameLine = join(' ', explode("\x88", $frameLine)); //version + $frameLine = join('', explode("\x89", $frameLine)); //version + $frameLine = join('♦', explode("\x01", $frameLine)); + $frameLine = join('⋅', explode("\0", $frameLine)); + } + + ?> + + "; + echo join("
      ", $frame); + echo "
      "; + + } + } + + //---------------------------------------------------------------------- + public static function serial($frame) + { + return gzcompress(join("\n", $frame), 9); + } + + //---------------------------------------------------------------------- + public static function unserial($code) + { + return explode("\n", gzuncompress($code)); + } + + //---------------------------------------------------------------------- + public static function newFrame($version) + { + if($version < 1 || $version > QRSPEC_VERSION_MAX) + return null; + + if(!isset(self::$frames[$version])) { + + $fileName = QR_CACHE_DIR.'frame_'.$version.'.dat'; + + if (QR_CACHEABLE) { + if (file_exists($fileName)) { + self::$frames[$version] = self::unserial(file_get_contents($fileName)); + } else { + self::$frames[$version] = self::createFrame($version); + file_put_contents($fileName, self::serial(self::$frames[$version])); + } + } else { + self::$frames[$version] = self::createFrame($version); + } + } + + if(is_null(self::$frames[$version])) + return null; + + return self::$frames[$version]; + } + + //---------------------------------------------------------------------- + public static function rsBlockNum($spec) { return $spec[0] + $spec[3]; } + public static function rsBlockNum1($spec) { return $spec[0]; } + public static function rsDataCodes1($spec) { return $spec[1]; } + public static function rsEccCodes1($spec) { return $spec[2]; } + public static function rsBlockNum2($spec) { return $spec[3]; } + public static function rsDataCodes2($spec) { return $spec[4]; } + public static function rsEccCodes2($spec) { return $spec[2]; } + public static function rsDataLength($spec) { return ($spec[0] * $spec[1]) + ($spec[3] * $spec[4]); } + public static function rsEccLength($spec) { return ($spec[0] + $spec[3]) * $spec[2]; } + + } + + + +//---- qrimage.php ----------------------------- + + + + +/* + * PHP QR Code encoder + * + * Image output of code using GD2 + * + * PHP QR Code is distributed under LGPL 3 + * Copyright (C) 2010 Dominik Dzienia + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + + define('QR_IMAGE', true); + + class QRimage { + + //---------------------------------------------------------------------- + public static function png($frame, $filename = false, $pixelPerPoint = 4, $outerFrame = 4,$saveandprint=FALSE) + { + $image = self::image($frame, $pixelPerPoint, $outerFrame); + + if ($filename === false) { + Header("Content-type: image/png"); + ImagePng($image); + } else { + if($saveandprint===TRUE){ + ImagePng($image, $filename); + header("Content-type: image/png"); + ImagePng($image); + }else{ + ImagePng($image, $filename); + } + } + + ImageDestroy($image); + } + + //---------------------------------------------------------------------- + public static function jpg($frame, $filename = false, $pixelPerPoint = 8, $outerFrame = 4, $q = 85) + { + $image = self::image($frame, $pixelPerPoint, $outerFrame); + + if ($filename === false) { + Header("Content-type: image/jpeg"); + ImageJpeg($image, null, $q); + } else { + ImageJpeg($image, $filename, $q); + } + + ImageDestroy($image); + } + + //---------------------------------------------------------------------- + private static function image($frame, $pixelPerPoint = 4, $outerFrame = 4) + { + $h = count($frame); + $w = strlen($frame[0]); + + $imgW = $w + 2*$outerFrame; + $imgH = $h + 2*$outerFrame; + + $base_image =ImageCreate($imgW, $imgH); + + $col[0] = ImageColorAllocate($base_image,255,255,255); + $col[1] = ImageColorAllocate($base_image,0,0,0); + + imagefill($base_image, 0, 0, $col[0]); + + for($y=0; $y<$h; $y++) { + for($x=0; $x<$w; $x++) { + if ($frame[$y][$x] == '1') { + ImageSetPixel($base_image,$x+$outerFrame,$y+$outerFrame,$col[1]); + } + } + } + + $target_image =ImageCreate($imgW * $pixelPerPoint, $imgH * $pixelPerPoint); + ImageCopyResized($target_image, $base_image, 0, 0, 0, 0, $imgW * $pixelPerPoint, $imgH * $pixelPerPoint, $imgW, $imgH); + ImageDestroy($base_image); + + return $target_image; + } + } + + + +//---- qrinput.php ----------------------------- + + + + +/* + * PHP QR Code encoder + * + * Input encoding class + * + * Based on libqrencode C library distributed under LGPL 2.1 + * Copyright (C) 2006, 2007, 2008, 2009 Kentaro Fukuchi + * + * PHP QR Code is distributed under LGPL 3 + * Copyright (C) 2010 Dominik Dzienia + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + + define('STRUCTURE_HEADER_BITS', 20); + define('MAX_STRUCTURED_SYMBOLS', 16); + + class QRinputItem { + + public $mode; + public $size; + public $data; + public $bstream; + + public function __construct($mode, $size, $data, $bstream = null) + { + $setData = array_slice($data, 0, $size); + + if (count($setData) < $size) { + $setData = array_merge($setData, array_fill(0,$size-count($setData),0)); + } + + if(!QRinput::check($mode, $size, $setData)) { + throw new Exception('Error m:'.$mode.',s:'.$size.',d:'.join(',',$setData)); + return null; + } + + $this->mode = $mode; + $this->size = $size; + $this->data = $setData; + $this->bstream = $bstream; + } + + //---------------------------------------------------------------------- + public function encodeModeNum($version) + { + try { + + $words = (int)($this->size / 3); + $bs = new QRbitstream(); + + $val = 0x1; + $bs->appendNum(4, $val); + $bs->appendNum(QRspec::lengthIndicator(QR_MODE_NUM, $version), $this->size); + + for($i=0; $i<$words; $i++) { + $val = (ord($this->data[$i*3 ]) - ord('0')) * 100; + $val += (ord($this->data[$i*3+1]) - ord('0')) * 10; + $val += (ord($this->data[$i*3+2]) - ord('0')); + $bs->appendNum(10, $val); + } + + if($this->size - $words * 3 == 1) { + $val = ord($this->data[$words*3]) - ord('0'); + $bs->appendNum(4, $val); + } else if($this->size - $words * 3 == 2) { + $val = (ord($this->data[$words*3 ]) - ord('0')) * 10; + $val += (ord($this->data[$words*3+1]) - ord('0')); + $bs->appendNum(7, $val); + } + + $this->bstream = $bs; + return 0; + + } catch (Exception $e) { + return -1; + } + } + + //---------------------------------------------------------------------- + public function encodeModeAn($version) + { + try { + $words = (int)($this->size / 2); + $bs = new QRbitstream(); + + $bs->appendNum(4, 0x02); + $bs->appendNum(QRspec::lengthIndicator(QR_MODE_AN, $version), $this->size); + + for($i=0; $i<$words; $i++) { + $val = (int)QRinput::lookAnTable(ord($this->data[$i*2 ])) * 45; + $val += (int)QRinput::lookAnTable(ord($this->data[$i*2+1])); + + $bs->appendNum(11, $val); + } + + if($this->size & 1) { + $val = QRinput::lookAnTable(ord($this->data[$words * 2])); + $bs->appendNum(6, $val); + } + + $this->bstream = $bs; + return 0; + + } catch (Exception $e) { + return -1; + } + } + + //---------------------------------------------------------------------- + public function encodeMode8($version) + { + try { + $bs = new QRbitstream(); + + $bs->appendNum(4, 0x4); + $bs->appendNum(QRspec::lengthIndicator(QR_MODE_8, $version), $this->size); + + for($i=0; $i<$this->size; $i++) { + $bs->appendNum(8, ord($this->data[$i])); + } + + $this->bstream = $bs; + return 0; + + } catch (Exception $e) { + return -1; + } + } + + //---------------------------------------------------------------------- + public function encodeModeKanji($version) + { + try { + + $bs = new QRbitrtream(); + + $bs->appendNum(4, 0x8); + $bs->appendNum(QRspec::lengthIndicator(QR_MODE_KANJI, $version), (int)($this->size / 2)); + + for($i=0; $i<$this->size; $i+=2) { + $val = (ord($this->data[$i]) << 8) | ord($this->data[$i+1]); + if($val <= 0x9ffc) { + $val -= 0x8140; + } else { + $val -= 0xc140; + } + + $h = ($val >> 8) * 0xc0; + $val = ($val & 0xff) + $h; + + $bs->appendNum(13, $val); + } + + $this->bstream = $bs; + return 0; + + } catch (Exception $e) { + return -1; + } + } + + //---------------------------------------------------------------------- + public function encodeModeStructure() + { + try { + $bs = new QRbitstream(); + + $bs->appendNum(4, 0x03); + $bs->appendNum(4, ord($this->data[1]) - 1); + $bs->appendNum(4, ord($this->data[0]) - 1); + $bs->appendNum(8, ord($this->data[2])); + + $this->bstream = $bs; + return 0; + + } catch (Exception $e) { + return -1; + } + } + + //---------------------------------------------------------------------- + public function estimateBitStreamSizeOfEntry($version) + { + $bits = 0; + + if($version == 0) + $version = 1; + + switch($this->mode) { + case QR_MODE_NUM: $bits = QRinput::estimateBitsModeNum($this->size); break; + case QR_MODE_AN: $bits = QRinput::estimateBitsModeAn($this->size); break; + case QR_MODE_8: $bits = QRinput::estimateBitsMode8($this->size); break; + case QR_MODE_KANJI: $bits = QRinput::estimateBitsModeKanji($this->size);break; + case QR_MODE_STRUCTURE: return STRUCTURE_HEADER_BITS; + default: + return 0; + } + + $l = QRspec::lengthIndicator($this->mode, $version); + $m = 1 << $l; + $num = (int)(($this->size + $m - 1) / $m); + + $bits += $num * (4 + $l); + + return $bits; + } + + //---------------------------------------------------------------------- + public function encodeBitStream($version) + { + try { + + unset($this->bstream); + $words = QRspec::maximumWords($this->mode, $version); + + if($this->size > $words) { + + $st1 = new QRinputItem($this->mode, $words, $this->data); + $st2 = new QRinputItem($this->mode, $this->size - $words, array_slice($this->data, $words)); + + $st1->encodeBitStream($version); + $st2->encodeBitStream($version); + + $this->bstream = new QRbitstream(); + $this->bstream->append($st1->bstream); + $this->bstream->append($st2->bstream); + + unset($st1); + unset($st2); + + } else { + + $ret = 0; + + switch($this->mode) { + case QR_MODE_NUM: $ret = $this->encodeModeNum($version); break; + case QR_MODE_AN: $ret = $this->encodeModeAn($version); break; + case QR_MODE_8: $ret = $this->encodeMode8($version); break; + case QR_MODE_KANJI: $ret = $this->encodeModeKanji($version);break; + case QR_MODE_STRUCTURE: $ret = $this->encodeModeStructure(); break; + + default: + break; + } + + if($ret < 0) + return -1; + } + + return $this->bstream->size(); + + } catch (Exception $e) { + return -1; + } + } + }; + + //########################################################################## + + class QRinput { + + public $items; + + private $version; + private $level; + + //---------------------------------------------------------------------- + public function __construct($version = 0, $level = QR_ECLEVEL_L) + { + if ($version < 0 || $version > QRSPEC_VERSION_MAX || $level > QR_ECLEVEL_H) { + throw new Exception('Invalid version no'); + return NULL; + } + + $this->version = $version; + $this->level = $level; + } + + //---------------------------------------------------------------------- + public function getVersion() + { + return $this->version; + } + + //---------------------------------------------------------------------- + public function setVersion($version) + { + if($version < 0 || $version > QRSPEC_VERSION_MAX) { + throw new Exception('Invalid version no'); + return -1; + } + + $this->version = $version; + + return 0; + } + + //---------------------------------------------------------------------- + public function getErrorCorrectionLevel() + { + return $this->level; + } + + //---------------------------------------------------------------------- + public function setErrorCorrectionLevel($level) + { + if($level > QR_ECLEVEL_H) { + throw new Exception('Invalid ECLEVEL'); + return -1; + } + + $this->level = $level; + + return 0; + } + + //---------------------------------------------------------------------- + public function appendEntry(QRinputItem $entry) + { + $this->items[] = $entry; + } + + //---------------------------------------------------------------------- + public function append($mode, $size, $data) + { + try { + $entry = new QRinputItem($mode, $size, $data); + $this->items[] = $entry; + return 0; + } catch (Exception $e) { + return -1; + } + } + + //---------------------------------------------------------------------- + + public function insertStructuredAppendHeader($size, $index, $parity) + { + if( $size > MAX_STRUCTURED_SYMBOLS ) { + throw new Exception('insertStructuredAppendHeader wrong size'); + } + + if( $index <= 0 || $index > MAX_STRUCTURED_SYMBOLS ) { + throw new Exception('insertStructuredAppendHeader wrong index'); + } + + $buf = array($size, $index, $parity); + + try { + $entry = new QRinputItem(QR_MODE_STRUCTURE, 3, buf); + array_unshift($this->items, $entry); + return 0; + } catch (Exception $e) { + return -1; + } + } + + //---------------------------------------------------------------------- + public function calcParity() + { + $parity = 0; + + foreach($this->items as $item) { + if($item->mode != QR_MODE_STRUCTURE) { + for($i=$item->size-1; $i>=0; $i--) { + $parity ^= $item->data[$i]; + } + } + } + + return $parity; + } + + //---------------------------------------------------------------------- + public static function checkModeNum($size, $data) + { + for($i=0; $i<$size; $i++) { + if((ord($data[$i]) < ord('0')) || (ord($data[$i]) > ord('9'))){ + return false; + } + } + + return true; + } + + //---------------------------------------------------------------------- + public static function estimateBitsModeNum($size) + { + $w = (int)$size / 3; + $bits = $w * 10; + + switch($size - $w * 3) { + case 1: + $bits += 4; + break; + case 2: + $bits += 7; + break; + default: + break; + } + + return $bits; + } + + //---------------------------------------------------------------------- + public static $anTable = array( + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 36, -1, -1, -1, 37, 38, -1, -1, -1, -1, 39, 40, -1, 41, 42, 43, + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 44, -1, -1, -1, -1, -1, + -1, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, + 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 + ); + + //---------------------------------------------------------------------- + public static function lookAnTable($c) + { + return (($c > 127)?-1:self::$anTable[$c]); + } + + //---------------------------------------------------------------------- + public static function checkModeAn($size, $data) + { + for($i=0; $i<$size; $i++) { + if (self::lookAnTable(ord($data[$i])) == -1) { + return false; + } + } + + return true; + } + + //---------------------------------------------------------------------- + public static function estimateBitsModeAn($size) + { + $w = (int)($size / 2); + $bits = $w * 11; + + if($size & 1) { + $bits += 6; + } + + return $bits; + } + + //---------------------------------------------------------------------- + public static function estimateBitsMode8($size) + { + return $size * 8; + } + + //---------------------------------------------------------------------- + public function estimateBitsModeKanji($size) + { + return (int)(($size / 2) * 13); + } + + //---------------------------------------------------------------------- + public static function checkModeKanji($size, $data) + { + if($size & 1) + return false; + + for($i=0; $i<$size; $i+=2) { + $val = (ord($data[$i]) << 8) | ord($data[$i+1]); + if( $val < 0x8140 + || ($val > 0x9ffc && $val < 0xe040) + || $val > 0xebbf) { + return false; + } + } + + return true; + } + + /*********************************************************************** + * Validation + **********************************************************************/ + + public static function check($mode, $size, $data) + { + if($size <= 0) + return false; + + switch($mode) { + case QR_MODE_NUM: return self::checkModeNum($size, $data); break; + case QR_MODE_AN: return self::checkModeAn($size, $data); break; + case QR_MODE_KANJI: return self::checkModeKanji($size, $data); break; + case QR_MODE_8: return true; break; + case QR_MODE_STRUCTURE: return true; break; + + default: + break; + } + + return false; + } + + + //---------------------------------------------------------------------- + public function estimateBitStreamSize($version) + { + $bits = 0; + + foreach($this->items as $item) { + $bits += $item->estimateBitStreamSizeOfEntry($version); + } + + return $bits; + } + + //---------------------------------------------------------------------- + public function estimateVersion() + { + $version = 0; + $prev = 0; + do { + $prev = $version; + $bits = $this->estimateBitStreamSize($prev); + $version = QRspec::getMinimumVersion((int)(($bits + 7) / 8), $this->level); + if ($version < 0) { + return -1; + } + } while ($version > $prev); + + return $version; + } + + //---------------------------------------------------------------------- + public static function lengthOfCode($mode, $version, $bits) + { + $payload = $bits - 4 - QRspec::lengthIndicator($mode, $version); + switch($mode) { + case QR_MODE_NUM: + $chunks = (int)($payload / 10); + $remain = $payload - $chunks * 10; + $size = $chunks * 3; + if($remain >= 7) { + $size += 2; + } else if($remain >= 4) { + $size += 1; + } + break; + case QR_MODE_AN: + $chunks = (int)($payload / 11); + $remain = $payload - $chunks * 11; + $size = $chunks * 2; + if($remain >= 6) + $size++; + break; + case QR_MODE_8: + $size = (int)($payload / 8); + break; + case QR_MODE_KANJI: + $size = (int)(($payload / 13) * 2); + break; + case QR_MODE_STRUCTURE: + $size = (int)($payload / 8); + break; + default: + $size = 0; + break; + } + + $maxsize = QRspec::maximumWords($mode, $version); + if($size < 0) $size = 0; + if($size > $maxsize) $size = $maxsize; + + return $size; + } + + //---------------------------------------------------------------------- + public function createBitStream() + { + $total = 0; + + foreach($this->items as $item) { + $bits = $item->encodeBitStream($this->version); + + if($bits < 0) + return -1; + + $total += $bits; + } + + return $total; + } + + //---------------------------------------------------------------------- + public function convertData() + { + $ver = $this->estimateVersion(); + if($ver > $this->getVersion()) { + $this->setVersion($ver); + } + + for(;;) { + $bits = $this->createBitStream(); + + if($bits < 0) + return -1; + + $ver = QRspec::getMinimumVersion((int)(($bits + 7) / 8), $this->level); + if($ver < 0) { + throw new Exception('WRONG VERSION'); + return -1; + } else if($ver > $this->getVersion()) { + $this->setVersion($ver); + } else { + break; + } + } + + return 0; + } + + //---------------------------------------------------------------------- + public function appendPaddingBit(&$bstream) + { + $bits = $bstream->size(); + $maxwords = QRspec::getDataLength($this->version, $this->level); + $maxbits = $maxwords * 8; + + if ($maxbits == $bits) { + return 0; + } + + if ($maxbits - $bits < 5) { + return $bstream->appendNum($maxbits - $bits, 0); + } + + $bits += 4; + $words = (int)(($bits + 7) / 8); + + $padding = new QRbitstream(); + $ret = $padding->appendNum($words * 8 - $bits + 4, 0); + + if($ret < 0) + return $ret; + + $padlen = $maxwords - $words; + + if($padlen > 0) { + + $padbuf = array(); + for($i=0; $i<$padlen; $i++) { + $padbuf[$i] = ($i&1)?0x11:0xec; + } + + $ret = $padding->appendBytes($padlen, $padbuf); + + if($ret < 0) + return $ret; + + } + + $ret = $bstream->append($padding); + + return $ret; + } + + //---------------------------------------------------------------------- + public function mergeBitStream() + { + if($this->convertData() < 0) { + return null; + } + + $bstream = new QRbitstream(); + + foreach($this->items as $item) { + $ret = $bstream->append($item->bstream); + if($ret < 0) { + return null; + } + } + + return $bstream; + } + + //---------------------------------------------------------------------- + public function getBitStream() + { + + $bstream = $this->mergeBitStream(); + + if($bstream == null) { + return null; + } + + $ret = $this->appendPaddingBit($bstream); + if($ret < 0) { + return null; + } + + return $bstream; + } + + //---------------------------------------------------------------------- + public function getByteStream() + { + $bstream = $this->getBitStream(); + if($bstream == null) { + return null; + } + + return $bstream->toByte(); + } + } + + + + + + +//---- qrbitstream.php ----------------------------- + + + + +/* + * PHP QR Code encoder + * + * Bitstream class + * + * Based on libqrencode C library distributed under LGPL 2.1 + * Copyright (C) 2006, 2007, 2008, 2009 Kentaro Fukuchi + * + * PHP QR Code is distributed under LGPL 3 + * Copyright (C) 2010 Dominik Dzienia + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + + class QRbitstream { + + public $data = array(); + + //---------------------------------------------------------------------- + public function size() + { + return count($this->data); + } + + //---------------------------------------------------------------------- + public function allocate($setLength) + { + $this->data = array_fill(0, $setLength, 0); + return 0; + } + + //---------------------------------------------------------------------- + public static function newFromNum($bits, $num) + { + $bstream = new QRbitstream(); + $bstream->allocate($bits); + + $mask = 1 << ($bits - 1); + for($i=0; $i<$bits; $i++) { + if($num & $mask) { + $bstream->data[$i] = 1; + } else { + $bstream->data[$i] = 0; + } + $mask = $mask >> 1; + } + + return $bstream; + } + + //---------------------------------------------------------------------- + public static function newFromBytes($size, $data) + { + $bstream = new QRbitstream(); + $bstream->allocate($size * 8); + $p=0; + + for($i=0; $i<$size; $i++) { + $mask = 0x80; + for($j=0; $j<8; $j++) { + if($data[$i] & $mask) { + $bstream->data[$p] = 1; + } else { + $bstream->data[$p] = 0; + } + $p++; + $mask = $mask >> 1; + } + } + + return $bstream; + } + + //---------------------------------------------------------------------- + public function append(QRbitstream $arg) + { + if (is_null($arg)) { + return -1; + } + + if($arg->size() == 0) { + return 0; + } + + if($this->size() == 0) { + $this->data = $arg->data; + return 0; + } + + $this->data = array_values(array_merge($this->data, $arg->data)); + + return 0; + } + + //---------------------------------------------------------------------- + public function appendNum($bits, $num) + { + if ($bits == 0) + return 0; + + $b = QRbitstream::newFromNum($bits, $num); + + if(is_null($b)) + return -1; + + $ret = $this->append($b); + unset($b); + + return $ret; + } + + //---------------------------------------------------------------------- + public function appendBytes($size, $data) + { + if ($size == 0) + return 0; + + $b = QRbitstream::newFromBytes($size, $data); + + if(is_null($b)) + return -1; + + $ret = $this->append($b); + unset($b); + + return $ret; + } + + //---------------------------------------------------------------------- + public function toByte() + { + + $size = $this->size(); + + if($size == 0) { + return array(); + } + + $data = array_fill(0, (int)(($size + 7) / 8), 0); + $bytes = (int)($size / 8); + + $p = 0; + + for($i=0; $i<$bytes; $i++) { + $v = 0; + for($j=0; $j<8; $j++) { + $v = $v << 1; + $v |= $this->data[$p]; + $p++; + } + $data[$i] = $v; + } + + if($size & 7) { + $v = 0; + for($j=0; $j<($size & 7); $j++) { + $v = $v << 1; + $v |= $this->data[$p]; + $p++; + } + $data[$bytes] = $v; + } + + return $data; + } + + } + + + + +//---- qrsplit.php ----------------------------- + + + + +/* + * PHP QR Code encoder + * + * Input splitting classes + * + * Based on libqrencode C library distributed under LGPL 2.1 + * Copyright (C) 2006, 2007, 2008, 2009 Kentaro Fukuchi + * + * PHP QR Code is distributed under LGPL 3 + * Copyright (C) 2010 Dominik Dzienia + * + * The following data / specifications are taken from + * "Two dimensional symbol -- QR-code -- Basic Specification" (JIS X0510:2004) + * or + * "Automatic identification and data capture techniques -- + * QR Code 2005 bar code symbology specification" (ISO/IEC 18004:2006) + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + class QRsplit { + + public $dataStr = ''; + public $input; + public $modeHint; + + //---------------------------------------------------------------------- + public function __construct($dataStr, $input, $modeHint) + { + $this->dataStr = $dataStr; + $this->input = $input; + $this->modeHint = $modeHint; + } + + //---------------------------------------------------------------------- + public static function isdigitat($str, $pos) + { + if ($pos >= strlen($str)) + return false; + + return ((ord($str[$pos]) >= ord('0'))&&(ord($str[$pos]) <= ord('9'))); + } + + //---------------------------------------------------------------------- + public static function isalnumat($str, $pos) + { + if ($pos >= strlen($str)) + return false; + + return (QRinput::lookAnTable(ord($str[$pos])) >= 0); + } + + //---------------------------------------------------------------------- + public function identifyMode($pos) + { + if ($pos >= strlen($this->dataStr)) + return QR_MODE_NUL; + + $c = $this->dataStr[$pos]; + + if(self::isdigitat($this->dataStr, $pos)) { + return QR_MODE_NUM; + } else if(self::isalnumat($this->dataStr, $pos)) { + return QR_MODE_AN; + } else if($this->modeHint == QR_MODE_KANJI) { + + if ($pos+1 < strlen($this->dataStr)) + { + $d = $this->dataStr[$pos+1]; + $word = (ord($c) << 8) | ord($d); + if(($word >= 0x8140 && $word <= 0x9ffc) || ($word >= 0xe040 && $word <= 0xebbf)) { + return QR_MODE_KANJI; + } + } + } + + return QR_MODE_8; + } + + //---------------------------------------------------------------------- + public function eatNum() + { + $ln = QRspec::lengthIndicator(QR_MODE_NUM, $this->input->getVersion()); + + $p = 0; + while(self::isdigitat($this->dataStr, $p)) { + $p++; + } + + $run = $p; + $mode = $this->identifyMode($p); + + if($mode == QR_MODE_8) { + $dif = QRinput::estimateBitsModeNum($run) + 4 + $ln + + QRinput::estimateBitsMode8(1) // + 4 + l8 + - QRinput::estimateBitsMode8($run + 1); // - 4 - l8 + if($dif > 0) { + return $this->eat8(); + } + } + if($mode == QR_MODE_AN) { + $dif = QRinput::estimateBitsModeNum($run) + 4 + $ln + + QRinput::estimateBitsModeAn(1) // + 4 + la + - QRinput::estimateBitsModeAn($run + 1);// - 4 - la + if($dif > 0) { + return $this->eatAn(); + } + } + + $ret = $this->input->append(QR_MODE_NUM, $run, str_split($this->dataStr)); + if($ret < 0) + return -1; + + return $run; + } + + //---------------------------------------------------------------------- + public function eatAn() + { + $la = QRspec::lengthIndicator(QR_MODE_AN, $this->input->getVersion()); + $ln = QRspec::lengthIndicator(QR_MODE_NUM, $this->input->getVersion()); + + $p = 0; + + while(self::isalnumat($this->dataStr, $p)) { + if(self::isdigitat($this->dataStr, $p)) { + $q = $p; + while(self::isdigitat($this->dataStr, $q)) { + $q++; + } + + $dif = QRinput::estimateBitsModeAn($p) // + 4 + la + + QRinput::estimateBitsModeNum($q - $p) + 4 + $ln + - QRinput::estimateBitsModeAn($q); // - 4 - la + + if($dif < 0) { + break; + } else { + $p = $q; + } + } else { + $p++; + } + } + + $run = $p; + + if(!self::isalnumat($this->dataStr, $p)) { + $dif = QRinput::estimateBitsModeAn($run) + 4 + $la + + QRinput::estimateBitsMode8(1) // + 4 + l8 + - QRinput::estimateBitsMode8($run + 1); // - 4 - l8 + if($dif > 0) { + return $this->eat8(); + } + } + + $ret = $this->input->append(QR_MODE_AN, $run, str_split($this->dataStr)); + if($ret < 0) + return -1; + + return $run; + } + + //---------------------------------------------------------------------- + public function eatKanji() + { + $p = 0; + + while($this->identifyMode($p) == QR_MODE_KANJI) { + $p += 2; + } + + $ret = $this->input->append(QR_MODE_KANJI, $p, str_split($this->dataStr)); + if($ret < 0) + return -1; + + return $run; + } + + //---------------------------------------------------------------------- + public function eat8() + { + $la = QRspec::lengthIndicator(QR_MODE_AN, $this->input->getVersion()); + $ln = QRspec::lengthIndicator(QR_MODE_NUM, $this->input->getVersion()); + + $p = 1; + $dataStrLen = strlen($this->dataStr); + + while($p < $dataStrLen) { + + $mode = $this->identifyMode($p); + if($mode == QR_MODE_KANJI) { + break; + } + if($mode == QR_MODE_NUM) { + $q = $p; + while(self::isdigitat($this->dataStr, $q)) { + $q++; + } + $dif = QRinput::estimateBitsMode8($p) // + 4 + l8 + + QRinput::estimateBitsModeNum($q - $p) + 4 + $ln + - QRinput::estimateBitsMode8($q); // - 4 - l8 + if($dif < 0) { + break; + } else { + $p = $q; + } + } else if($mode == QR_MODE_AN) { + $q = $p; + while(self::isalnumat($this->dataStr, $q)) { + $q++; + } + $dif = QRinput::estimateBitsMode8($p) // + 4 + l8 + + QRinput::estimateBitsModeAn($q - $p) + 4 + $la + - QRinput::estimateBitsMode8($q); // - 4 - l8 + if($dif < 0) { + break; + } else { + $p = $q; + } + } else { + $p++; + } + } + + $run = $p; + $ret = $this->input->append(QR_MODE_8, $run, str_split($this->dataStr)); + + if($ret < 0) + return -1; + + return $run; + } + + //---------------------------------------------------------------------- + public function splitString() + { + while (strlen($this->dataStr) > 0) + { + if($this->dataStr == '') + return 0; + + $mode = $this->identifyMode(0); + + switch ($mode) { + case QR_MODE_NUM: $length = $this->eatNum(); break; + case QR_MODE_AN: $length = $this->eatAn(); break; + case QR_MODE_KANJI: + if ($hint == QR_MODE_KANJI) + $length = $this->eatKanji(); + else $length = $this->eat8(); + break; + default: $length = $this->eat8(); break; + + } + + if($length == 0) return 0; + if($length < 0) return -1; + + $this->dataStr = substr($this->dataStr, $length); + } + } + + //---------------------------------------------------------------------- + public function toUpper() + { + $stringLen = strlen($this->dataStr); + $p = 0; + + while ($p<$stringLen) { + $mode = self::identifyMode(substr($this->dataStr, $p), $this->modeHint); + if($mode == QR_MODE_KANJI) { + $p += 2; + } else { + if (ord($this->dataStr[$p]) >= ord('a') && ord($this->dataStr[$p]) <= ord('z')) { + $this->dataStr[$p] = chr(ord($this->dataStr[$p]) - 32); + } + $p++; + } + } + + return $this->dataStr; + } + + //---------------------------------------------------------------------- + public static function splitStringToQRinput($string, QRinput $input, $modeHint, $casesensitive = true) + { + if(is_null($string) || $string == '\0' || $string == '') { + throw new Exception('empty string!!!'); + } + + $split = new QRsplit($string, $input, $modeHint); + + if(!$casesensitive) + $split->toUpper(); + + return $split->splitString(); + } + } + + + +//---- qrrscode.php ----------------------------- + + + + +/* + * PHP QR Code encoder + * + * Reed-Solomon error correction support + * + * Copyright (C) 2002, 2003, 2004, 2006 Phil Karn, KA9Q + * (libfec is released under the GNU Lesser General Public License.) + * + * Based on libqrencode C library distributed under LGPL 2.1 + * Copyright (C) 2006, 2007, 2008, 2009 Kentaro Fukuchi + * + * PHP QR Code is distributed under LGPL 3 + * Copyright (C) 2010 Dominik Dzienia + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + + class QRrsItem { + + public $mm; // Bits per symbol + public $nn; // Symbols per block (= (1<= $this->nn) { + $x -= $this->nn; + $x = ($x >> $this->mm) + ($x & $this->nn); + } + + return $x; + } + + //---------------------------------------------------------------------- + public static function init_rs_char($symsize, $gfpoly, $fcr, $prim, $nroots, $pad) + { + // Common code for intializing a Reed-Solomon control block (char or int symbols) + // Copyright 2004 Phil Karn, KA9Q + // May be used under the terms of the GNU Lesser General Public License (LGPL) + + $rs = null; + + // Check parameter ranges + if($symsize < 0 || $symsize > 8) return $rs; + if($fcr < 0 || $fcr >= (1<<$symsize)) return $rs; + if($prim <= 0 || $prim >= (1<<$symsize)) return $rs; + if($nroots < 0 || $nroots >= (1<<$symsize)) return $rs; // Can't have more roots than symbol values! + if($pad < 0 || $pad >= ((1<<$symsize) -1 - $nroots)) return $rs; // Too much padding + + $rs = new QRrsItem(); + $rs->mm = $symsize; + $rs->nn = (1<<$symsize)-1; + $rs->pad = $pad; + + $rs->alpha_to = array_fill(0, $rs->nn+1, 0); + $rs->index_of = array_fill(0, $rs->nn+1, 0); + + // PHP style macro replacement ;) + $NN =& $rs->nn; + $A0 =& $NN; + + // Generate Galois field lookup tables + $rs->index_of[0] = $A0; // log(zero) = -inf + $rs->alpha_to[$A0] = 0; // alpha**-inf = 0 + $sr = 1; + + for($i=0; $i<$rs->nn; $i++) { + $rs->index_of[$sr] = $i; + $rs->alpha_to[$i] = $sr; + $sr <<= 1; + if($sr & (1<<$symsize)) { + $sr ^= $gfpoly; + } + $sr &= $rs->nn; + } + + if($sr != 1){ + // field generator polynomial is not primitive! + $rs = NULL; + return $rs; + } + + /* Form RS code generator polynomial from its roots */ + $rs->genpoly = array_fill(0, $nroots+1, 0); + + $rs->fcr = $fcr; + $rs->prim = $prim; + $rs->nroots = $nroots; + $rs->gfpoly = $gfpoly; + + /* Find prim-th root of 1, used in decoding */ + for($iprim=1;($iprim % $prim) != 0;$iprim += $rs->nn) + ; // intentional empty-body loop! + + $rs->iprim = (int)($iprim / $prim); + $rs->genpoly[0] = 1; + + for ($i = 0,$root=$fcr*$prim; $i < $nroots; $i++, $root += $prim) { + $rs->genpoly[$i+1] = 1; + + // Multiply rs->genpoly[] by @**(root + x) + for ($j = $i; $j > 0; $j--) { + if ($rs->genpoly[$j] != 0) { + $rs->genpoly[$j] = $rs->genpoly[$j-1] ^ $rs->alpha_to[$rs->modnn($rs->index_of[$rs->genpoly[$j]] + $root)]; + } else { + $rs->genpoly[$j] = $rs->genpoly[$j-1]; + } + } + // rs->genpoly[0] can never be zero + $rs->genpoly[0] = $rs->alpha_to[$rs->modnn($rs->index_of[$rs->genpoly[0]] + $root)]; + } + + // convert rs->genpoly[] to index form for quicker encoding + for ($i = 0; $i <= $nroots; $i++) + $rs->genpoly[$i] = $rs->index_of[$rs->genpoly[$i]]; + + return $rs; + } + + //---------------------------------------------------------------------- + public function encode_rs_char($data, &$parity) + { + $MM =& $this->mm; + $NN =& $this->nn; + $ALPHA_TO =& $this->alpha_to; + $INDEX_OF =& $this->index_of; + $GENPOLY =& $this->genpoly; + $NROOTS =& $this->nroots; + $FCR =& $this->fcr; + $PRIM =& $this->prim; + $IPRIM =& $this->iprim; + $PAD =& $this->pad; + $A0 =& $NN; + + $parity = array_fill(0, $NROOTS, 0); + + for($i=0; $i< ($NN-$NROOTS-$PAD); $i++) { + + $feedback = $INDEX_OF[$data[$i] ^ $parity[0]]; + if($feedback != $A0) { + // feedback term is non-zero + + // This line is unnecessary when GENPOLY[NROOTS] is unity, as it must + // always be for the polynomials constructed by init_rs() + $feedback = $this->modnn($NN - $GENPOLY[$NROOTS] + $feedback); + + for($j=1;$j<$NROOTS;$j++) { + $parity[$j] ^= $ALPHA_TO[$this->modnn($feedback + $GENPOLY[$NROOTS-$j])]; + } + } + + // Shift + array_shift($parity); + if($feedback != $A0) { + array_push($parity, $ALPHA_TO[$this->modnn($feedback + $GENPOLY[0])]); + } else { + array_push($parity, 0); + } + } + } + } + + //########################################################################## + + class QRrs { + + public static $items = array(); + + //---------------------------------------------------------------------- + public static function init_rs($symsize, $gfpoly, $fcr, $prim, $nroots, $pad) + { + foreach(self::$items as $rs) { + if($rs->pad != $pad) continue; + if($rs->nroots != $nroots) continue; + if($rs->mm != $symsize) continue; + if($rs->gfpoly != $gfpoly) continue; + if($rs->fcr != $fcr) continue; + if($rs->prim != $prim) continue; + + return $rs; + } + + $rs = QRrsItem::init_rs_char($symsize, $gfpoly, $fcr, $prim, $nroots, $pad); + array_unshift(self::$items, $rs); + + return $rs; + } + } + + + +//---- qrmask.php ----------------------------- + + + + +/* + * PHP QR Code encoder + * + * Masking + * + * Based on libqrencode C library distributed under LGPL 2.1 + * Copyright (C) 2006, 2007, 2008, 2009 Kentaro Fukuchi + * + * PHP QR Code is distributed under LGPL 3 + * Copyright (C) 2010 Dominik Dzienia + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + + define('N1', 3); + define('N2', 3); + define('N3', 40); + define('N4', 10); + + class QRmask { + + public $runLength = array(); + + //---------------------------------------------------------------------- + public function __construct() + { + $this->runLength = array_fill(0, QRSPEC_WIDTH_MAX + 1, 0); + } + + //---------------------------------------------------------------------- + public function writeFormatInformation($width, &$frame, $mask, $level) + { + $blacks = 0; + $format = QRspec::getFormatInfo($mask, $level); + + for($i=0; $i<8; $i++) { + if($format & 1) { + $blacks += 2; + $v = 0x85; + } else { + $v = 0x84; + } + + $frame[8][$width - 1 - $i] = chr($v); + if($i < 6) { + $frame[$i][8] = chr($v); + } else { + $frame[$i + 1][8] = chr($v); + } + $format = $format >> 1; + } + + for($i=0; $i<7; $i++) { + if($format & 1) { + $blacks += 2; + $v = 0x85; + } else { + $v = 0x84; + } + + $frame[$width - 7 + $i][8] = chr($v); + if($i == 0) { + $frame[8][7] = chr($v); + } else { + $frame[8][6 - $i] = chr($v); + } + + $format = $format >> 1; + } + + return $blacks; + } + + //---------------------------------------------------------------------- + public function mask0($x, $y) { return ($x+$y)&1; } + public function mask1($x, $y) { return ($y&1); } + public function mask2($x, $y) { return ($x%3); } + public function mask3($x, $y) { return ($x+$y)%3; } + public function mask4($x, $y) { return (((int)($y/2))+((int)($x/3)))&1; } + public function mask5($x, $y) { return (($x*$y)&1)+($x*$y)%3; } + public function mask6($x, $y) { return ((($x*$y)&1)+($x*$y)%3)&1; } + public function mask7($x, $y) { return ((($x*$y)%3)+(($x+$y)&1))&1; } + + //---------------------------------------------------------------------- + private function generateMaskNo($maskNo, $width, $frame) + { + $bitMask = array_fill(0, $width, array_fill(0, $width, 0)); + + for($y=0; $y<$width; $y++) { + for($x=0; $x<$width; $x++) { + if(ord($frame[$y][$x]) & 0x80) { + $bitMask[$y][$x] = 0; + } else { + $maskFunc = call_user_func(array($this, 'mask'.$maskNo), $x, $y); + $bitMask[$y][$x] = ($maskFunc == 0)?1:0; + } + + } + } + + return $bitMask; + } + + //---------------------------------------------------------------------- + public static function serial($bitFrame) + { + $codeArr = array(); + + foreach ($bitFrame as $line) + $codeArr[] = join('', $line); + + return gzcompress(join("\n", $codeArr), 9); + } + + //---------------------------------------------------------------------- + public static function unserial($code) + { + $codeArr = array(); + + $codeLines = explode("\n", gzuncompress($code)); + foreach ($codeLines as $line) + $codeArr[] = str_split($line); + + return $codeArr; + } + + //---------------------------------------------------------------------- + public function makeMaskNo($maskNo, $width, $s, &$d, $maskGenOnly = false) + { + $b = 0; + $bitMask = array(); + + $fileName = QR_CACHE_DIR.'mask_'.$maskNo.DIRECTORY_SEPARATOR.'mask_'.$width.'_'.$maskNo.'.dat'; + + if (QR_CACHEABLE) { + if (file_exists($fileName)) { + $bitMask = self::unserial(file_get_contents($fileName)); + } else { + $bitMask = $this->generateMaskNo($maskNo, $width, $s, $d); + if (!file_exists(QR_CACHE_DIR.'mask_'.$maskNo)) + mkdir(QR_CACHE_DIR.'mask_'.$maskNo); + file_put_contents($fileName, self::serial($bitMask)); + } + } else { + $bitMask = $this->generateMaskNo($maskNo, $width, $s, $d); + } + + if ($maskGenOnly) + return; + + $d = $s; + + for($y=0; $y<$width; $y++) { + for($x=0; $x<$width; $x++) { + if($bitMask[$y][$x] == 1) { + $d[$y][$x] = chr(ord($s[$y][$x]) ^ (int)$bitMask[$y][$x]); + } + $b += (int)(ord($d[$y][$x]) & 1); + } + } + + return $b; + } + + //---------------------------------------------------------------------- + public function makeMask($width, $frame, $maskNo, $level) + { + $masked = array_fill(0, $width, str_repeat("\0", $width)); + $this->makeMaskNo($maskNo, $width, $frame, $masked); + $this->writeFormatInformation($width, $masked, $maskNo, $level); + + return $masked; + } + + //---------------------------------------------------------------------- + public function calcN1N3($length) + { + $demerit = 0; + + for($i=0; $i<$length; $i++) { + + if($this->runLength[$i] >= 5) { + $demerit += (N1 + ($this->runLength[$i] - 5)); + } + if($i & 1) { + if(($i >= 3) && ($i < ($length-2)) && ($this->runLength[$i] % 3 == 0)) { + $fact = (int)($this->runLength[$i] / 3); + if(($this->runLength[$i-2] == $fact) && + ($this->runLength[$i-1] == $fact) && + ($this->runLength[$i+1] == $fact) && + ($this->runLength[$i+2] == $fact)) { + if(($this->runLength[$i-3] < 0) || ($this->runLength[$i-3] >= (4 * $fact))) { + $demerit += N3; + } else if((($i+3) >= $length) || ($this->runLength[$i+3] >= (4 * $fact))) { + $demerit += N3; + } + } + } + } + } + return $demerit; + } + + //---------------------------------------------------------------------- + public function evaluateSymbol($width, $frame) + { + $head = 0; + $demerit = 0; + + for($y=0; $y<$width; $y++) { + $head = 0; + $this->runLength[0] = 1; + + $frameY = $frame[$y]; + + if ($y>0) + $frameYM = $frame[$y-1]; + + for($x=0; $x<$width; $x++) { + if(($x > 0) && ($y > 0)) { + $b22 = ord($frameY[$x]) & ord($frameY[$x-1]) & ord($frameYM[$x]) & ord($frameYM[$x-1]); + $w22 = ord($frameY[$x]) | ord($frameY[$x-1]) | ord($frameYM[$x]) | ord($frameYM[$x-1]); + + if(($b22 | ($w22 ^ 1))&1) { + $demerit += N2; + } + } + if(($x == 0) && (ord($frameY[$x]) & 1)) { + $this->runLength[0] = -1; + $head = 1; + $this->runLength[$head] = 1; + } else if($x > 0) { + if((ord($frameY[$x]) ^ ord($frameY[$x-1])) & 1) { + $head++; + $this->runLength[$head] = 1; + } else { + $this->runLength[$head]++; + } + } + } + + $demerit += $this->calcN1N3($head+1); + } + + for($x=0; $x<$width; $x++) { + $head = 0; + $this->runLength[0] = 1; + + for($y=0; $y<$width; $y++) { + if($y == 0 && (ord($frame[$y][$x]) & 1)) { + $this->runLength[0] = -1; + $head = 1; + $this->runLength[$head] = 1; + } else if($y > 0) { + if((ord($frame[$y][$x]) ^ ord($frame[$y-1][$x])) & 1) { + $head++; + $this->runLength[$head] = 1; + } else { + $this->runLength[$head]++; + } + } + } + + $demerit += $this->calcN1N3($head+1); + } + + return $demerit; + } + + + //---------------------------------------------------------------------- + public function mask($width, $frame, $level) + { + $minDemerit = PHP_INT_MAX; + $bestMaskNum = 0; + $bestMask = array(); + + $checked_masks = array(0,1,2,3,4,5,6,7); + + if (QR_FIND_FROM_RANDOM !== false) { + + $howManuOut = 8-(QR_FIND_FROM_RANDOM % 9); + for ($i = 0; $i < $howManuOut; $i++) { + $remPos = rand (0, count($checked_masks)-1); + unset($checked_masks[$remPos]); + $checked_masks = array_values($checked_masks); + } + + } + + $bestMask = $frame; + + foreach($checked_masks as $i) { + $mask = array_fill(0, $width, str_repeat("\0", $width)); + + $demerit = 0; + $blacks = 0; + $blacks = $this->makeMaskNo($i, $width, $frame, $mask); + $blacks += $this->writeFormatInformation($width, $mask, $i, $level); + $blacks = (int)(100 * $blacks / ($width * $width)); + $demerit = (int)((int)(abs($blacks - 50) / 5) * N4); + $demerit += $this->evaluateSymbol($width, $mask); + + if($demerit < $minDemerit) { + $minDemerit = $demerit; + $bestMask = $mask; + $bestMaskNum = $i; + } + } + + return $bestMask; + } + + //---------------------------------------------------------------------- + } + + + + +//---- qrencode.php ----------------------------- + + + + +/* + * PHP QR Code encoder + * + * Main encoder classes. + * + * Based on libqrencode C library distributed under LGPL 2.1 + * Copyright (C) 2006, 2007, 2008, 2009 Kentaro Fukuchi + * + * PHP QR Code is distributed under LGPL 3 + * Copyright (C) 2010 Dominik Dzienia + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + + class QRrsblock { + public $dataLength; + public $data = array(); + public $eccLength; + public $ecc = array(); + + public function __construct($dl, $data, $el, &$ecc, QRrsItem $rs) + { + $rs->encode_rs_char($data, $ecc); + + $this->dataLength = $dl; + $this->data = $data; + $this->eccLength = $el; + $this->ecc = $ecc; + } + }; + + //########################################################################## + + class QRrawcode { + public $version; + public $datacode = array(); + public $ecccode = array(); + public $blocks; + public $rsblocks = array(); //of RSblock + public $count; + public $dataLength; + public $eccLength; + public $b1; + + //---------------------------------------------------------------------- + public function __construct(QRinput $input) + { + $spec = array(0,0,0,0,0); + + $this->datacode = $input->getByteStream(); + if(is_null($this->datacode)) { + throw new Exception('null imput string'); + } + + QRspec::getEccSpec($input->getVersion(), $input->getErrorCorrectionLevel(), $spec); + + $this->version = $input->getVersion(); + $this->b1 = QRspec::rsBlockNum1($spec); + $this->dataLength = QRspec::rsDataLength($spec); + $this->eccLength = QRspec::rsEccLength($spec); + $this->ecccode = array_fill(0, $this->eccLength, 0); + $this->blocks = QRspec::rsBlockNum($spec); + + $ret = $this->init($spec); + if($ret < 0) { + throw new Exception('block alloc error'); + return null; + } + + $this->count = 0; + } + + //---------------------------------------------------------------------- + public function init(array $spec) + { + $dl = QRspec::rsDataCodes1($spec); + $el = QRspec::rsEccCodes1($spec); + $rs = QRrs::init_rs(8, 0x11d, 0, 1, $el, 255 - $dl - $el); + + + $blockNo = 0; + $dataPos = 0; + $eccPos = 0; + for($i=0; $iecccode,$eccPos); + $this->rsblocks[$blockNo] = new QRrsblock($dl, array_slice($this->datacode, $dataPos), $el, $ecc, $rs); + $this->ecccode = array_merge(array_slice($this->ecccode,0, $eccPos), $ecc); + + $dataPos += $dl; + $eccPos += $el; + $blockNo++; + } + + if(QRspec::rsBlockNum2($spec) == 0) + return 0; + + $dl = QRspec::rsDataCodes2($spec); + $el = QRspec::rsEccCodes2($spec); + $rs = QRrs::init_rs(8, 0x11d, 0, 1, $el, 255 - $dl - $el); + + if($rs == NULL) return -1; + + for($i=0; $iecccode,$eccPos); + $this->rsblocks[$blockNo] = new QRrsblock($dl, array_slice($this->datacode, $dataPos), $el, $ecc, $rs); + $this->ecccode = array_merge(array_slice($this->ecccode,0, $eccPos), $ecc); + + $dataPos += $dl; + $eccPos += $el; + $blockNo++; + } + + return 0; + } + + //---------------------------------------------------------------------- + public function getCode() + { + $ret; + + if($this->count < $this->dataLength) { + $row = $this->count % $this->blocks; + $col = $this->count / $this->blocks; + if($col >= $this->rsblocks[0]->dataLength) { + $row += $this->b1; + } + $ret = $this->rsblocks[$row]->data[$col]; + } else if($this->count < $this->dataLength + $this->eccLength) { + $row = ($this->count - $this->dataLength) % $this->blocks; + $col = ($this->count - $this->dataLength) / $this->blocks; + $ret = $this->rsblocks[$row]->ecc[$col]; + } else { + return 0; + } + $this->count++; + + return $ret; + } + } + + //########################################################################## + + class QRcode { + + public $version; + public $width; + public $data; + + //---------------------------------------------------------------------- + public function encodeMask(QRinput $input, $mask) + { + if($input->getVersion() < 0 || $input->getVersion() > QRSPEC_VERSION_MAX) { + throw new Exception('wrong version'); + } + if($input->getErrorCorrectionLevel() > QR_ECLEVEL_H) { + throw new Exception('wrong level'); + } + + $raw = new QRrawcode($input); + + QRtools::markTime('after_raw'); + + $version = $raw->version; + $width = QRspec::getWidth($version); + $frame = QRspec::newFrame($version); + + $filler = new FrameFiller($width, $frame); + if(is_null($filler)) { + return NULL; + } + + // inteleaved data and ecc codes + for($i=0; $i<$raw->dataLength + $raw->eccLength; $i++) { + $code = $raw->getCode(); + $bit = 0x80; + for($j=0; $j<8; $j++) { + $addr = $filler->next(); + $filler->setFrameAt($addr, 0x02 | (($bit & $code) != 0)); + $bit = $bit >> 1; + } + } + + QRtools::markTime('after_filler'); + + unset($raw); + + // remainder bits + $j = QRspec::getRemainder($version); + for($i=0; $i<$j; $i++) { + $addr = $filler->next(); + $filler->setFrameAt($addr, 0x02); + } + + $frame = $filler->frame; + unset($filler); + + + // masking + $maskObj = new QRmask(); + if($mask < 0) { + + if (QR_FIND_BEST_MASK) { + $masked = $maskObj->mask($width, $frame, $input->getErrorCorrectionLevel()); + } else { + $masked = $maskObj->makeMask($width, $frame, (intval(QR_DEFAULT_MASK) % 8), $input->getErrorCorrectionLevel()); + } + } else { + $masked = $maskObj->makeMask($width, $frame, $mask, $input->getErrorCorrectionLevel()); + } + + if($masked == NULL) { + return NULL; + } + + QRtools::markTime('after_mask'); + + $this->version = $version; + $this->width = $width; + $this->data = $masked; + + return $this; + } + + //---------------------------------------------------------------------- + public function encodeInput(QRinput $input) + { + return $this->encodeMask($input, -1); + } + + //---------------------------------------------------------------------- + public function encodeString8bit($string, $version, $level) + { + if(string == NULL) { + throw new Exception('empty string!'); + return NULL; + } + + $input = new QRinput($version, $level); + if($input == NULL) return NULL; + + $ret = $input->append($input, QR_MODE_8, strlen($string), str_split($string)); + if($ret < 0) { + unset($input); + return NULL; + } + return $this->encodeInput($input); + } + + //---------------------------------------------------------------------- + public function encodeString($string, $version, $level, $hint, $casesensitive) + { + + if($hint != QR_MODE_8 && $hint != QR_MODE_KANJI) { + throw new Exception('bad hint'); + return NULL; + } + + $input = new QRinput($version, $level); + if($input == NULL) return NULL; + + $ret = QRsplit::splitStringToQRinput($string, $input, $hint, $casesensitive); + if($ret < 0) { + return NULL; + } + + return $this->encodeInput($input); + } + + //---------------------------------------------------------------------- + public static function png($text, $outfile = false, $level = QR_ECLEVEL_L, $size = 3, $margin = 4, $saveandprint=false) + { + $enc = QRencode::factory($level, $size, $margin); + return $enc->encodePNG($text, $outfile, $saveandprint=false); + } + + //---------------------------------------------------------------------- + public static function text($text, $outfile = false, $level = QR_ECLEVEL_L, $size = 3, $margin = 4) + { + $enc = QRencode::factory($level, $size, $margin); + return $enc->encode($text, $outfile); + } + + //---------------------------------------------------------------------- + public static function raw($text, $outfile = false, $level = QR_ECLEVEL_L, $size = 3, $margin = 4) + { + $enc = QRencode::factory($level, $size, $margin); + return $enc->encodeRAW($text, $outfile); + } + } + + //########################################################################## + + class FrameFiller { + + public $width; + public $frame; + public $x; + public $y; + public $dir; + public $bit; + + //---------------------------------------------------------------------- + public function __construct($width, &$frame) + { + $this->width = $width; + $this->frame = $frame; + $this->x = $width - 1; + $this->y = $width - 1; + $this->dir = -1; + $this->bit = -1; + } + + //---------------------------------------------------------------------- + public function setFrameAt($at, $val) + { + $this->frame[$at['y']][$at['x']] = chr($val); + } + + //---------------------------------------------------------------------- + public function getFrameAt($at) + { + return ord($this->frame[$at['y']][$at['x']]); + } + + //---------------------------------------------------------------------- + public function next() + { + do { + + if($this->bit == -1) { + $this->bit = 0; + return array('x'=>$this->x, 'y'=>$this->y); + } + + $x = $this->x; + $y = $this->y; + $w = $this->width; + + if($this->bit == 0) { + $x--; + $this->bit++; + } else { + $x++; + $y += $this->dir; + $this->bit--; + } + + if($this->dir < 0) { + if($y < 0) { + $y = 0; + $x -= 2; + $this->dir = 1; + if($x == 6) { + $x--; + $y = 9; + } + } + } else { + if($y == $w) { + $y = $w - 1; + $x -= 2; + $this->dir = -1; + if($x == 6) { + $x--; + $y -= 8; + } + } + } + if($x < 0 || $y < 0) return null; + + $this->x = $x; + $this->y = $y; + + } while(ord($this->frame[$y][$x]) & 0x80); + + return array('x'=>$x, 'y'=>$y); + } + + } ; + + //########################################################################## + + class QRencode { + + public $casesensitive = true; + public $eightbit = false; + + public $version = 0; + public $size = 3; + public $margin = 4; + + public $structured = 0; // not supported yet + + public $level = QR_ECLEVEL_L; + public $hint = QR_MODE_8; + + //---------------------------------------------------------------------- + public static function factory($level = QR_ECLEVEL_L, $size = 3, $margin = 4) + { + $enc = new QRencode(); + $enc->size = $size; + $enc->margin = $margin; + + switch ($level.'') { + case '0': + case '1': + case '2': + case '3': + $enc->level = $level; + break; + case 'l': + case 'L': + $enc->level = QR_ECLEVEL_L; + break; + case 'm': + case 'M': + $enc->level = QR_ECLEVEL_M; + break; + case 'q': + case 'Q': + $enc->level = QR_ECLEVEL_Q; + break; + case 'h': + case 'H': + $enc->level = QR_ECLEVEL_H; + break; + } + + return $enc; + } + + //---------------------------------------------------------------------- + public function encodeRAW($intext, $outfile = false) + { + $code = new QRcode(); + + if($this->eightbit) { + $code->encodeString8bit($intext, $this->version, $this->level); + } else { + $code->encodeString($intext, $this->version, $this->level, $this->hint, $this->casesensitive); + } + + return $code->data; + } + + //---------------------------------------------------------------------- + public function encode($intext, $outfile = false) + { + $code = new QRcode(); + + if($this->eightbit) { + $code->encodeString8bit($intext, $this->version, $this->level); + } else { + $code->encodeString($intext, $this->version, $this->level, $this->hint, $this->casesensitive); + } + + QRtools::markTime('after_encode'); + + if ($outfile!== false) { + file_put_contents($outfile, join("\n", QRtools::binarize($code->data))); + } else { + return QRtools::binarize($code->data); + } + } + + //---------------------------------------------------------------------- + public function encodePNG($intext, $outfile = false,$saveandprint=false) + { + try { + + ob_start(); + $tab = $this->encode($intext); + $err = ob_get_contents(); + ob_end_clean(); + + if ($err != '') + QRtools::log($outfile, $err); + + $maxSize = (int)(QR_PNG_MAXIMUM_SIZE / (count($tab)+2*$this->margin)); + + QRimage::png($tab, $outfile, min(max(1, $this->size), $maxSize), $this->margin,$saveandprint); + + } catch (Exception $e) { + + QRtools::log($outfile, $e->getMessage()); + + } + } + } + + diff --git a/webapp/php/admin.php b/webapp/php/admin.php index 4125a46..07376ea 100644 --- a/webapp/php/admin.php +++ b/webapp/php/admin.php @@ -1228,7 +1228,11 @@ class Admin { array("austriabind",0,false), array("doublereceipt",0,false), array("printextraprice",1,false), - array("turbo",5,false) + array("turbo",5,false), + array("guestqrtext",null,false), + array("guestqrsize",null,false), + array("guestqrfontsize",null,false), + array("reservationitem",null,false) ); if (is_null($pdo)) { @@ -1423,7 +1427,7 @@ class Admin { $view = "preferences.html"; } - echo json_encode($view . "?v=1.5.33"); + echo json_encode($view . "?v=1.6.1"); } } @@ -1644,31 +1648,31 @@ 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.5.33"); } + if ($_SESSION['right_waiter']) { $mainMenu[] = array("name" => $waitertxt[$lang], "link" => "waiter.html?v=1.6.1"); } } else { - if ($_SESSION['right_waiter']) { $mainMenu[] = array("name" => $waiterdesktxt[$lang], "link" => "waiterdesktop.php?v=1.5.33"); } + if ($_SESSION['right_waiter']) { $mainMenu[] = array("name" => $waiterdesktxt[$lang], "link" => "waiterdesktop.php?v=1.6.1"); } } - if ($_SESSION['right_kitchen']) { $mainMenu[] = array("name" => $kitchentxt[$lang], "link" => "kitchen.html?v=1.5.33"); } - if ($_SESSION['right_bar']) { $mainMenu[] = array("name" => "Bar", "link" => "bar.html?v=1.5.33"); } - if ($_SESSION['right_supply']) { $mainMenu[] = array("name" => $supplytxt[$lang], "link" => "supplydesk.html?v=1.5.33"); } + if ($_SESSION['right_kitchen']) { $mainMenu[] = array("name" => $kitchentxt[$lang], "link" => "kitchen.html?v=1.6.1"); } + if ($_SESSION['right_bar']) { $mainMenu[] = array("name" => "Bar", "link" => "bar.html?v=1.6.1"); } + if ($_SESSION['right_supply']) { $mainMenu[] = array("name" => $supplytxt[$lang], "link" => "supplydesk.html?v=1.6.1"); } if ($_SESSION['modus'] == 0) { - if ($_SESSION['right_paydesk']) { $mainMenu[] = array("name" => $paydesktxt[$lang], "link" => "paydesk.html?v=1.5.33"); } + if ($_SESSION['right_paydesk']) { $mainMenu[] = array("name" => $paydesktxt[$lang], "link" => "paydesk.html?v=1.6.1"); } } - if ($_SESSION['right_statistics']) { $mainMenu[] = array("name" => $stattxt[$lang], "link" => "reports.html?v=1.5.33"); } - if ($_SESSION['right_bill']) { $mainMenu[] = array("name" => $bontxt[$lang], "link" => "bill.html?v=1.5.33"); } - if ($_SESSION['right_products']) { $mainMenu[] = array("name" => $prodtxt[$lang], "link" => "products.html?v=1.5.33"); } - if ($_SESSION['right_reservation']) { $mainMenu[] = array("name" => $restxt[$lang], "link" => "reservation.html?v=1.5.33"); } - if ($_SESSION['right_tasks'] || $_SESSION['right_tasksmanagement']) { $mainMenu[] = array("name" => $taskstxt[$lang], "link" => "tasks.html?v=1.5.33"); } - if ($_SESSION['right_rating']) { $mainMenu[] = array("name" => $ratingtxt[$lang], "link" => "rating.html?v=1.5.33"); } - if ($_SESSION['right_customers']) { $mainMenu[] = array("name" => $customerstxt[$lang], "link" => "customers.html?v=1.5.33"); } - if ($_SESSION['right_pickups']) { $mainMenu[] = array("name" => $pickupstxt[$lang], "link" => "pickups.html?v=1.5.33"); } - if ($_SESSION['right_dash']) { $mainMenu[] = array("name" => $dashtxt[$lang], "link" => "dash.php?v=1.5.33"); } - if ($_SESSION['right_manager'] || $_SESSION['is_admin'] || $_SESSION['right_closing']) { $mainMenu[] = array("name" => $admintxt[$lang], "link" => "manager.html?v=1.5.33"); } - $mainMenu[] = array("name" => $settingtxt[$lang], "link" => "preferences.html?v=1.5.33"); - if ($_SESSION['right_timetracking'] || $_SESSION['right_timemanager']) { $mainMenu[] = array("name" => $timetrackingtxt[$lang], "link" => "timetracking.html?v=1.5.33"); } + if ($_SESSION['right_statistics']) { $mainMenu[] = array("name" => $stattxt[$lang], "link" => "reports.html?v=1.6.1"); } + if ($_SESSION['right_bill']) { $mainMenu[] = array("name" => $bontxt[$lang], "link" => "bill.html?v=1.6.1"); } + if ($_SESSION['right_products']) { $mainMenu[] = array("name" => $prodtxt[$lang], "link" => "products.html?v=1.6.1"); } + if ($_SESSION['right_reservation']) { $mainMenu[] = array("name" => $restxt[$lang], "link" => "reservation.html?v=1.6.1"); } + if ($_SESSION['right_tasks'] || $_SESSION['right_tasksmanagement']) { $mainMenu[] = array("name" => $taskstxt[$lang], "link" => "tasks.html?v=1.6.1"); } + if ($_SESSION['right_rating']) { $mainMenu[] = array("name" => $ratingtxt[$lang], "link" => "rating.html?v=1.6.1"); } + if ($_SESSION['right_customers']) { $mainMenu[] = array("name" => $customerstxt[$lang], "link" => "customers.html?v=1.6.1"); } + if ($_SESSION['right_pickups']) { $mainMenu[] = array("name" => $pickupstxt[$lang], "link" => "pickups.html?v=1.6.1"); } + if ($_SESSION['right_dash']) { $mainMenu[] = array("name" => $dashtxt[$lang], "link" => "dash.php?v=1.6.1"); } + if ($_SESSION['right_manager'] || $_SESSION['is_admin'] || $_SESSION['right_closing']) { $mainMenu[] = array("name" => $admintxt[$lang], "link" => "manager.html?v=1.6.1"); } + $mainMenu[] = array("name" => $settingtxt[$lang], "link" => "preferences.html?v=1.6.1"); + if ($_SESSION['right_timetracking'] || $_SESSION['right_timemanager']) { $mainMenu[] = array("name" => $timetrackingtxt[$lang], "link" => "timetracking.html?v=1.6.1"); } - $mainMenu[] = array("name" => "Hilfe", "link" => "help.php?v=1.5.33"); - $mainMenu[] = array("name" => "Feedback", "link" => "feedback.html?v=1.5.33"); + $mainMenu[] = array("name" => "Hilfe", "link" => "help.php?v=1.6.1"); + $mainMenu[] = array("name" => "Feedback", "link" => "feedback.html?v=1.6.1"); } $mainMenu[] = array("name" => $logout[$lang], "link" => "logout.php"); @@ -2288,7 +2292,11 @@ class Admin { "logolocation" => array("dbcol" => "logolocation","checknum" => 1), "austriabind" => array("dbcol" => "austriabind","checknum" => 0), "doublereceipt" => array("dbcol" => "doublereceipt","checknum" => 0), - "printextraprice" => array("dbcol" => "printextraprice","checknum" => 0) + "printextraprice" => array("dbcol" => "printextraprice","checknum" => 0), + "guestqrtext" => array("dbcol" => "guestqrtext","checknum" => 0), + "guestqrsize" => array("dbcol" => "guestqrsize","checknum" => 1), + "guestqrfontsize" => array("dbcol" => "guestqrfontsize","checknum" => 1), + "reservationitem" => array("dbcol" => "reservationitem","checknum" => 0) ); $problem = false; foreach ($changedValues as $aChangeSet) { diff --git a/webapp/php/closing.php b/webapp/php/closing.php index 088145b..7a11f24 100644 --- a/webapp/php/closing.php +++ b/webapp/php/closing.php @@ -189,6 +189,7 @@ $newClosingId = $maxIdVal + 1; $closingEntrySql = "INSERT INTO `%closing%` (`id`,`closingdate`,`remark`,`billcount`,`billsum`,`signature`) VALUES (?,?,?,?,?,?)"; CommonUtils::execSql($pdo, $closingEntrySql, array($newClosingId,$closingTime,$remark,0,0.0,null)); +set_time_limit(60*60); $sql = "SELECT id FROM %bill% WHERE closingid is null AND (tableid >= '0' OR status='c') "; $stmt = $pdo->prepare($this->dbutils->resolveTablenamesInSqlString($sql)); $stmt->execute(); @@ -207,9 +208,11 @@ if (!$ok) { return(array("status" => "ERROR", "code" => ERROR_INCONSISTENT_DB, "msg" => ERROR_INCONSISTENT_DB_MSG)); } +set_time_limit(60*60); $sql = "UPDATE %bill% SET closingid='$newClosingId' WHERE closingid is null AND (tableid >= '0' OR status='c') AND (paymentid <> ?)"; CommonUtils::execSql($pdo, $sql, array(8)); +set_time_limit(60*60); $sql = "SELECT count(id) as billstotake FROM %bill% WHERE closingid=? AND (tableid >= '0' OR status='c')"; $stmt = $pdo->prepare($this->dbutils->resolveTablenamesInSqlString($sql)); $stmt->execute(array($newClosingId)); @@ -238,9 +241,11 @@ $pricesumstr = number_format($pricesum, 2, ".", ''); $data = "I($newClosingId)-S($prevClosingDate)-E($closingTime)-D($billsToTake)-S($pricesumstr)"; $signature = md5($data); +set_time_limit(60*60); $sql = "UPDATE %closing% SET billcount=?, billsum=?,signature=? WHERE id=?"; CommonUtils::execSql($pdo, $sql, array($billsToTake,$pricesum,$signature,$newClosingId)); +set_time_limit(60*60); $sql = "SELECT value as val FROM %work% WHERE item=?"; $indexunclosedqueue = 0; $r = CommonUtils::fetchSqlAll($pdo, $sql, array('indexunclosedqueue')); @@ -250,15 +255,18 @@ if (!is_null($rval)) { $indexunclosedqueue = intval($rval); } } +set_time_limit(60*60); $sql = "UPDATE %queue% Q,%work% W SET Q.clsid=? WHERE Q.id > ? AND Q.clsid is null"; CommonUtils::execSql($pdo, $sql, array($newClosingId,$indexunclosedqueue)); +set_time_limit(60*60); $sql = "UPDATE %queue% SET toremove='1' WHERE billid is null AND clsid=?"; CommonUtils::execSql($pdo, $sql, array($newClosingId)); +set_time_limit(60*60); $sql = "UPDATE %queue% set paidtime=?,delivertime=? WHERE billid is not null AND paidtime is null"; CommonUtils::execSql($pdo, $sql, array($closingTime,$closingTime)); @@ -272,6 +280,7 @@ CommonUtils::execSql($pdo, "OPTIMIZE TABLE %printjobs%", null); $sql = "DELETE FROM %work% WHERE item=?"; CommonUtils::execSql($pdo, $sql, array("sumuphash")); +set_time_limit(60*60); $sql = "UPDATE %queue% SET isclosed=?"; CommonUtils::execSql($pdo, $sql, array(1)); diff --git a/webapp/php/customers.php b/webapp/php/customers.php index f9585c3..f1e176e 100644 --- a/webapp/php/customers.php +++ b/webapp/php/customers.php @@ -878,7 +878,7 @@ class Customers { $txt = ""; $txt .= "" . self::$CUS_OVERVIEW[$lang] . ""; $txt .= ''; - $txt .= ''; + $txt .= ''; $txt .= ""; return $txt; } diff --git a/webapp/php/debug.php b/webapp/php/debug.php index cea4b58..2a73bb4 100644 --- a/webapp/php/debug.php +++ b/webapp/php/debug.php @@ -27,7 +27,7 @@ if (isset($_POST["cmd"])) { if (strlen($status) > 150) { $status = substr($status, 0,149); } - $version = "1.5.33"; + $version = "1.6.1"; $arr = array("cmd" => $cmd,"fct" => $fct, "xhr" => $xhr,"errormsg" => $errormsg,"status" => $status,"version" => $version,"phpversion" => $phpversion); } else { diff --git a/webapp/php/reports.php b/webapp/php/reports.php index 772ee71..6f6259f 100644 --- a/webapp/php/reports.php +++ b/webapp/php/reports.php @@ -84,7 +84,11 @@ class Reports { echo json_encode(array("status" => "OK","msg" => $values)); break; case 'getProds': - $values = $this->sumSortedByProducts($pdo, $allDates['last30days'][0], $allDates['currentTimeStr']); + $days = null; + if (isset($_GET['days'])) { + $days = intval($_GET['days']); + } + $values = $this->sumSortedByProducts($pdo, $allDates['last30days'][0], $allDates['currentTimeStr'],null,null,$days); echo json_encode(array("status" => "OK","msg" => $values)); break; case 'getRatings': @@ -204,7 +208,7 @@ class Reports { $retArrayLastMonth = $this->iterateForDays($pdo, $allDates['monthAndYearOfLastMonth'],intval($allDates['lastDayOfLastMonth']),true); // products in the last 30 days: - $retArrayProds = $this->sumSortedByProducts($pdo, $allDates['last30days'][0], $allDates['currentTimeStr']); + $retArrayProds = $this->sumSortedByProducts($pdo, $allDates['last30days'][0], $allDates['currentTimeStr'],null,null,null); $retRatings = $this->getRatings($pdo,$allDates['last30days'],$allDates['lastMonthComplete'], $allDates['currentTimeStr']); @@ -305,16 +309,15 @@ class Reports { } return ($asum < $bsum) ? 1 : -1; } - - /* - * returns a sorted by prices list: - * array("prodid" => $aProdId,"prodname" => $aProd['prodname'], "sum" => $sumprice); - * array("prodid" => $aProdId,"prodname" => $aProd['prodname'], "sum" => $sumprice); - * (...) - */ - public function sumSortedByProducts($pdo,$startDateTime,$endDateTime,$closidstart=null,$closidend=null) { + + public function sumSortedByProducts($pdo,$startDateTime,$endDateTime,$closidstart=null,$closidend=null,$days=null) { // first get all products and with their id and name + if (!is_null($days)) { + date_default_timezone_set(DbUtils::getTimeZone()); + $startDateTime = date("Y-m-d", strtotime('-' . ($days - 1) . ' day') ); + } + if (is_null($closidstart)) { $sql = "SELECT DISTINCT productid from %queue%,%bill%,%products% "; $sql .= "WHERE %queue%.productid=%products%.id "; diff --git a/webapp/php/reservation.php b/webapp/php/reservation.php index 7fa9cd1..9c525a4 100644 --- a/webapp/php/reservation.php +++ b/webapp/php/reservation.php @@ -13,11 +13,11 @@ class Reservation { echo json_encode(array("status" => "ERROR", "code" => ERROR_RES_NOT_AUTHOTRIZED, "msg" => ERROR_RES_NOT_AUTHOTRIZED_MSG)); } else { if ($command == 'createReservation') { - $this->createReservation($_POST['day'],$_POST['month'],$_POST['year'],$_POST['start'],$_POST['name'],$_POST['email'],$_POST['persons'],$_POST['duration'],$_POST['phone'],$_POST['remark'],$_POST["tableid"]); + $this->createReservation($_POST['day'],$_POST['month'],$_POST['year'],$_POST['starthour'],$_POST['startmin'],$_POST['name'],$_POST['email'],$_POST['persons'],$_POST['durationhours'],$_POST['durationmins'],$_POST['phone'],$_POST['remark'],$_POST["tableid"]); } else if ($command == 'getReservations') { $this->getReservations($_GET['day'],$_GET['month'],$_GET['year']); } else if ($command == 'changeReservation') { - $this->changeReservation($_POST['id'],$_POST['day'],$_POST['month'],$_POST['year'],$_POST['start'],$_POST['name'],$_POST['email'],$_POST['persons'],$_POST['duration'],$_POST['phone'],$_POST['remark'],$_POST["tableid"]); + $this->changeReservation($_POST['id'],$_POST['day'],$_POST['month'],$_POST['year'],$_POST['starthour'],$_POST['startmin'],$_POST['name'],$_POST['email'],$_POST['persons'],$_POST['durationhours'],$_POST['durationmins'],$_POST['phone'],$_POST['remark'],$_POST["tableid"]); } else if ($command == 'delReservation') { $this->delReservation($_POST['id']); } else if ($command == 'emailConfirmReservation') { @@ -42,7 +42,7 @@ class Reservation { } } - private function createReservation($day,$month,$year,$start,$name,$email,$persons,$duration,$phone,$remark,$tableid) { + private function createReservation($day,$month,$year,$start,$startmin,$name,$email,$persons,$durationhours,$durationmins,$phone,$remark,$tableid) { $userid = $_SESSION['userid']; date_default_timezone_set(DbUtils::getTimeZone()); $currentTime = date('Y-m-d H:i:s'); @@ -56,11 +56,11 @@ class Reservation { $pdo->beginTransaction(); $sql = "INSERT INTO `%reservations%` ( - `id` , `creator`,`creationdate`,`scheduledate`,`name`,`email`,`starttime`,`duration`,`persons`,`phone`,`remark`,`tableid`) + `id` , `creator`,`creationdate`,`scheduledate`,`name`,`email`,`starttime`,`starttimemin`,`duration`,`durationmins`,`persons`,`phone`,`remark`,`tableid`) VALUES ( - NULL , ?,?,?,?,?,?,?,?,?,?,?)"; + NULL , ?,?,?,?,?,?,?,?,?,?,?,?,?)"; $stmt = $pdo->prepare($this->dbutils->resolveTablenamesInSqlString($sql)); - $stmt->execute(array($userid,$currentTime,$scheduledDate,$name,$email,$start,$duration,$persons,$phone,$remark,$tableid)); + $stmt->execute(array($userid,$currentTime,$scheduledDate,$name,$email,$start,$startmin,$durationhours,$durationmins,$persons,$phone,$remark,$tableid)); $pdo->commit(); echo json_encode(array("status" => "OK")); } @@ -70,7 +70,7 @@ class Reservation { } } - private function changeReservation($id,$day,$month,$year,$start,$name,$email,$persons,$duration,$phone,$remark,$tableid) { + private function changeReservation($id,$day,$month,$year,$startHour,$startMin,$name,$email,$persons,$durationHours,$durationMins,$phone,$remark,$tableid) { $userid = $_SESSION['userid']; date_default_timezone_set(DbUtils::getTimeZone()); $currentTime = date('Y-m-d H:i:s'); @@ -80,8 +80,8 @@ class Reservation { try { $pdo->beginTransaction(); - $sql = "UPDATE `%reservations%` SET creator=?,creationdate=?,scheduledate=?,name=?,email=?,starttime=?,duration=?,persons=?,phone=?,remark=?,tableid=? WHERE id=?"; - CommonUtils::execSql($pdo, $sql, array($userid,$currentTime,$scheduledDate,$name,$email,$start,$duration,$persons,$phone,$remark,$tableid,$id)); + $sql = "UPDATE `%reservations%` SET creator=?,creationdate=?,scheduledate=?,name=?,email=?,starttime=?,starttimemin=?,duration=?,durationmins=?,persons=?,phone=?,remark=?,tableid=? WHERE id=?"; + CommonUtils::execSql($pdo, $sql, array($userid,$currentTime,$scheduledDate,$name,$email,$startHour,$startMin,$durationHours,$durationMins,$persons,$phone,$remark,$tableid,$id)); $pdo->commit(); echo json_encode(array("status" => "OK")); } @@ -144,7 +144,7 @@ class Reservation { $txt = ""; $txt .= "Reservierungsübersicht"; $txt .= ''; - $txt .= ''; + $txt .= ''; $txt .= ""; $txt .= ""; $txt .= "

      Reservierungsübersicht für $day.$month.$year

      "; @@ -170,7 +170,8 @@ class Reservation { } private static function getSqlForResByTime() { // REM* roomname and tablename only for the html output - $sql = "SELECT R.id,U.username as username,creationdate,scheduledate,starttime,name,email,persons,duration,phone,remark,tableid, "; + $sqlEndTime = self::sqlForEndTime(); + $sql = "SELECT R.id,U.username as username,creationdate,scheduledate,starttime as starthour,starttimemin as startmin,$sqlEndTime,name,email,persons,duration,durationmins,phone,remark,tableid, "; $sql .= "IF(tableid is null,'-1',(SELECT RO.id as roomid FROM %room% RO,%resttables% T WHERE T.id=tableid AND T.roomid=RO.id)) as roomid, "; $sql .= "IF(tableid is null,'-1',(SELECT RO.sorting as roomsorting FROM %room% RO,%resttables% T WHERE T.id=tableid AND T.roomid=RO.id)) as roomsorting, "; $sql .= "IF(tableid is null,'',(SELECT RO.roomname as roomname FROM %room% RO,%resttables% T WHERE T.id=tableid AND T.roomid=RO.id)) as roomname, "; @@ -180,14 +181,25 @@ class Reservation { $sql .= "WHERE DATE(scheduledate)=? AND R.creator=U.id "; return $sql; } + // REM* the end time may be in next day, and the minutes may also need an hiour to be increased + private static function sqlForEndTime() { + $sqlEndTimeStamp = 'ADDTIME(CONCAT(starttime,":",starttimemin,":00"),CONCAT(duration,":",durationmins,":00"))'; + // REM* will return something like 26:15:00 in case endtime is on next day + $sqlEndHour = 'HOUR(' . $sqlEndTimeStamp . ') as endhour'; + $sqlEndMin = 'MINUTE(' . $sqlEndTimeStamp . ') as endmin'; + $sqlEndTime = "$sqlEndHour,$sqlEndMin"; + return $sqlEndTime; + } private function getReservations($day,$month,$year) { $pdo = DbUtils::openDbAndReturnPdoStatic(); + $sqlEndTime = self::sqlForEndTime(); + // REM* the many sortings in the sql allow the sorting by time, room-sort and table-sort $sql = self::getSqlForResByTime(); $timeSortedReservations = $this->getReservationsCore($pdo,$day,$month,$year,$sql . " ORDER BY starttime,roomsorting,tablesorting"); // REM* and now by table - $sql = "SELECT DISTINCT R.tableid as tableid,ROOM.id as roomid,ROOM.sorting as roomsorting,T.sorting as tablesorting FROM %reservations% R,%room% ROOM,%resttables% T "; + $sql = "SELECT DISTINCT R.tableid as tableid,T.tableno as tablename,ROOM.id as roomid,ROOM.sorting as roomsorting,T.sorting as tablesorting FROM %reservations% R,%room% ROOM,%resttables% T "; $sql .= " WHERE DATE(scheduledate)=? AND tableid is not null AND tableid >= '0' "; $sql .= " AND R.tableid = T.id AND T.roomid=ROOM.id "; $sql .= " ORDER BY ROOM.sorting,T.sorting "; @@ -198,23 +210,23 @@ class Reservation { $byTables = array(); foreach($allTablesOfResAtThatDate as $tableRes) { - $sql = "SELECT R.id,U.username as creator,creationdate,scheduledate,starttime as start,name as guest,email,persons,duration,(starttime + duration) as endhour,"; + $sql = "SELECT R.id,U.username as creator,creationdate,scheduledate,YEAR(scheduledate) as year,MONTH(scheduledate) as month, DAY(scheduledate) as day,starttime as starthour,starttimemin as startmin,name as guest,email,persons,duration as durationhours,durationmins,$sqlEndTime,"; $sql .= " phone,remark,tableid,'" . $tableRes["roomid"] . "' as roomid "; $sql .= "FROM %reservations% R,%user% U "; $sql .= "WHERE DATE(scheduledate)=? AND R.creator=U.id AND tableid=? "; $sql .= "ORDER BY starttime"; $allResOfThatTable = CommonUtils::fetchSqlAll($pdo, $sql, array($scheduledDate,$tableRes["tableid"])); - $byTables[] = array("tableid" => $tableRes["tableid"],"roomid" => $tableRes["roomid"], "reservations" => $allResOfThatTable); + $byTables[] = array("tableid" => $tableRes["tableid"],"tablename" => $tableRes["tablename"],"roomid" => $tableRes["roomid"], "reservations" => $allResOfThatTable); } // REM* these were all reservations by table at the given date. Let's add all reservations without a table assignment - $sql = "SELECT R.id,U.username as creator,creationdate,scheduledate,starttime as start,name as guest,email,persons,duration,(starttime + duration) as endhour,"; + $sql = "SELECT R.id,U.username as creator,creationdate,scheduledate,YEAR(scheduledate) as year,MONTH(scheduledate) as month, DAY(scheduledate) as day,starttime as starthour,starttimemin as startmin,name as guest,email,persons,duration as durationhours,durationmins,$sqlEndTime,"; $sql .= " phone,remark,'-1' as tableid,'-1' as roomid "; $sql .= "FROM %reservations% R,%user% U "; $sql .= "WHERE DATE(scheduledate)=? AND R.creator=U.id AND (tableid is null OR tableid='-1') "; $sql .= "ORDER BY starttime"; $allResOfUndefinedTable = CommonUtils::fetchSqlAll($pdo, $sql, array($scheduledDate)); if (count($allResOfUndefinedTable) > 0) { - $byTables[] = array("tableid" => '-1',"roomid" => '-1', "reservations" => $allResOfUndefinedTable); + $byTables[] = array("tableid" => '-1',"tablename" => "?","roomid" => '-1', "reservations" => $allResOfUndefinedTable); } $msg = array("bytimes" => $timeSortedReservations,"bytables" => $byTables); @@ -239,21 +251,22 @@ class Reservation { $resArray = array(); foreach($result as $row) { - $datetimeparts = explode(" ",$row['scheduledate']); - $thedate = $datetimeparts[0]; - $thedateparts = explode("-",$thedate); $resArray[] = array( "id" => $row['id'], "creator" => $row['username'], "creationdate" => $row['creationdate'], - "day" => $thedateparts[2], - "month" => $thedateparts[1], - "year" => $thedateparts[0], - "start" => $row['starttime'], + "day" => $row['day'], + "month" => $row['month'], + "year" => $row['year'], + "starthour" => $row['starthour'], + "startmin" => $row['startmin'], + "endhour" => $row['endhour'], + "endmin" => $row['endmin'], "guest" => $row['name'], "email" => $row['email'], "persons" => $row['persons'], - "duration" => $row['duration'], + "durationhours" => $row['duration'], + "durationmins" => $row['durationmins'], "phone" => $row['phone'], "remark" => $row['remark'], "roomid" => $row['roomid'], @@ -286,4 +299,4 @@ class Reservation { return array(); } } -} +} \ No newline at end of file diff --git a/webapp/php/roomtables.php b/webapp/php/roomtables.php index 8ef798e..021a38f 100644 --- a/webapp/php/roomtables.php +++ b/webapp/php/roomtables.php @@ -38,13 +38,17 @@ class Roomtables { } else if ($command == 'getRoomfieldAlsoInactive') { $this->getRoomfieldAlsoInactive(); } else if ($command == 'setRoomInfo') { - if ($this->hasCurrentUserAdminRights()) { + if (self::hasCurrentUserAdminRights()) { $this->setRoomInfo($_POST['rooms'],$_POST['togoworkprinter']); } + } else if ($command == 'createTableCodes') { + self::createTableCodes(); + } else if ($command == 'tableqrcodes') { + self::tableqrcodes(); } } - private function hasCurrentUserAdminRights() { + private static function hasCurrentUserAdminRights() { if(session_id() == '') { session_start(); } @@ -55,6 +59,27 @@ class Roomtables { } } + private static function createTableCodes() { + if (!self::hasCurrentUserAdminRights()) { + echo json_encode(array("status" => "ERROR","msg" => "Benutzerrechte nicht ausreichend")); + return; + } + try { + $pdo = DbUtils::openDbAndReturnPdoStatic(); + $sql = "SELECT id FROM %resttables% WHERE removed is null AND (code is NULL OR code='')"; + $activeTables = CommonUtils::fetchSqlAll($pdo, $sql); + $updateSql = "UPDATE %resttables% SET code=? WHERE id=?"; + foreach($activeTables as $table) { + $tableid = $table["id"]; + $uniqid = md5(uniqid()); + CommonUtils::execSql($pdo, $updateSql, array($uniqid,$tableid)); + } + echo json_encode(array("status" => "OK")); + } catch (Exception $ex) { + echo json_encode(array("status" => "ERROR","msg" => "Datenbank nicht erreichbar")); + } + } + function showAllRooms() { $pdo = DbUtils::openDbAndReturnPdoStatic(); $roomtables = $this->getAllTablesAndRooms($pdo); @@ -220,9 +245,22 @@ class Roomtables { return ''; } + private static function sqlForEndTime() { + $sqlEndTimeStamp = 'ADDTIME(CONCAT(starttime,":",starttimemin,":00"),CONCAT(duration,":",durationmins,":00"))'; + $sqlEndHour = 'HOUR(' . $sqlEndTimeStamp . ') as endhour'; + $sqlEndMin = 'MINUTE(' . $sqlEndTimeStamp . ') as endmin'; + $sqlEndTime = "$sqlEndHour,$sqlEndMin"; + return $sqlEndTime; + } + private function getAllTablesAndRooms($pdo) { - $sql = "SELECT tableid,GROUP_CONCAT(DISTINCT CONCAT(starttime,':00-',(starttime+duration),':00') ORDER BY starttime) as times from %reservations% R "; + $sqlEndTimeStamp = 'ADDTIME(CONCAT(starttime,":",starttimemin,":00"),CONCAT(duration,":",durationmins,":00"))'; + $sqlEndHour = 'HOUR(' . $sqlEndTimeStamp . ') '; + $sqlEndMin = 'LPAD(MINUTE(' . $sqlEndTimeStamp . '),2,0)'; + + $sql = "SELECT tableid,GROUP_CONCAT(DISTINCT CONCAT(starttime,':',LPAD(starttimemin,2,0),'-',($sqlEndHour),':',($sqlEndMin)) ORDER BY starttime) as times from %reservations% R "; + //$sql = "SELECT tableid,GROUP_CONCAT(DISTINCT CONCAT(starttime,':00-',(starttime+duration),':00') ORDER BY starttime) as times from %reservations% R "; $sql .= "WHERE DATE(scheduledate)=CURDATE() AND (HOUR(NOW())-1) <= starttime GROUP BY tableid"; $reservations = CommonUtils::fetchSqlAll($pdo, $sql); @@ -484,4 +522,85 @@ class Roomtables { $result = CommonUtils::fetchSqlAll($pdo, $sql, array(1,1)); return $result; } + + private static function createSingleQRCode($guesturl,$tablename,$tableid,$code,$addOnText,$guestqrsize,$guestqrfontsize) { + $arg = $guesturl . '/index.php?code=' . $code . "_" . $tableid; + $txt = '

      '; + $txt .= 'Tisch: ' . $tablename . '
      '; + if (!is_null($code) && ($code != '')) { + $txt .= '
      '; + } else { + $txt .= '

      Tischcode wurde noch nicht zugewiesen
      '; + } + $txt .= '

      ' . $addOnText . ''; + $txt .= '

      '; + return $txt; + } + + private static function createQrCodeForTables($pdo,$guesturl,$addOnText,$guestqrsize,$guestqrfontsize) { + $maxCols = round(500.0/($guestqrsize + 20)); + $allTables = self::getTablesForGuestsystem($pdo); + $txt = ''; + $col = 0; + foreach($allTables as $aTable) { + $code = $aTable['code']; + $tableid = $aTable['id']; + $tablename = $aTable['name']; + if ($col == 0) { + $txt .= ""; + } + $txt .= '"; + } + } + $txt .= "
      ' . self::createSingleQRCode($guesturl, $tablename, $tableid, $code, $addOnText, $guestqrsize, $guestqrfontsize); + $col++; + if ($col == $maxCols) { + $col = 0; + $txt .= "
      "; + return $txt; + } + + private static function tableqrcodes() { + header( "Expires: Mon, 20 Dec 1998 01:00:00 GMT" ); + header( "Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT" ); + header( "Cache-Control: no-cache, must-revalidate" ); + header( "Content-Type: text/html; charset=utf8" ); + + $pdo = DbUtils::openDbAndReturnPdoStatic(); + $guestUrl = CommonUtils::getConfigValue($pdo, 'guesturl', ''); + + if (CommonUtils::strEndsWith($guestUrl, "/")) { + $guestUrl = substr($guestUrl, 0, strlen($guestUrl) - 1); + } + + if (CommonUtils::strEndsWith($guestUrl, "/index.php")) { + $guestUrl = substr($guestUrl, 0, strlen($guestUrl) - strlen("/index.php")); + } + + $guestqrtext = CommonUtils::getConfigValue($pdo, 'guestqrtext', ''); + $guestqrsize = CommonUtils::getConfigValue($pdo, 'guestqrsize', ''); + if (($guestqrsize < 20) || ($guestqrsize > 500)) { + $guestqrsize = 150; + } + $guestqrfontsize = CommonUtils::getConfigValue($pdo, 'guestqrfontsize', ''); + if (($guestqrfontsize < 5) || ($guestqrfontsize > 50)) { + $guestqrfontsize = 15; + } + if (is_null($guestUrl) || ($guestUrl == '')) { + echo "Gastbestell-URL noch nicht konfiguriert"; + return; + } + + $txt = ""; + $txt .= "Tisch QR-Codes für die Gastbestellung"; + $txt .= ''; + $txt .= ''; + $txt .= ""; + $txt .= ""; + $txt .= "

      Tisch QR-Codes für die Gastbestellung

      "; + + $txt .= self::createQrCodeForTables($pdo,$guestUrl,$guestqrtext,$guestqrsize,$guestqrfontsize); + $txt .= ""; + echo $txt; + } } diff --git a/webapp/php/utilities/osqrcode.php b/webapp/php/utilities/osqrcode.php new file mode 100644 index 0000000..f119af1 --- /dev/null +++ b/webapp/php/utilities/osqrcode.php @@ -0,0 +1,23 @@ +calcStartDate($startMonth, $startYear); $endDate = $this->calcEndDate($endMonth, $endYear); - $prodStat = $reports->sumSortedByProducts($pdo, $startDate, $endDate,null,null); + $prodStat = $reports->sumSortedByProducts($pdo, $startDate, $endDate,null,null,null); } else { - $prodStat = $reports->sumSortedByProducts($pdo, 0,0,$closidstart,$closidend); + $prodStat = $reports->sumSortedByProducts($pdo, 0,0,$closidstart,$closidend,null); } $this->setProdsTableHeader(); diff --git a/webapp/php/utilities/version.php b/webapp/php/utilities/version.php index ff6f57d..787c82a 100644 --- a/webapp/php/utilities/version.php +++ b/webapp/php/utilities/version.php @@ -1287,6 +1287,26 @@ class Version { return array(true); } + public static function upd_1533_1600($pdo, $prefix, $dbname) { + try { + self::execSql($pdo, "ALTER TABLE %reservations% ADD starttimemin INT(3) NULL AFTER `starttime`"); + self::execSql($pdo, "UPDATE %reservations% SET starttimemin='0'"); + self::execSql($pdo, "ALTER TABLE %reservations% ADD durationmins INT(3) NULL AFTER `duration`"); + self::execSql($pdo, "UPDATE %reservations% SET durationmins='0'"); + self::insertOrUpdateConfigItem($pdo, 'guestqrtext', 'Gastbestellung'); + self::insertOrUpdateConfigItem($pdo, 'guestqrfontsize', '15'); + self::insertOrUpdateConfigItem($pdo, 'guestqrsize', '150'); + self::insertOrUpdateConfigItem($pdo, 'reservationitem', "{Name}\n{Start-Stunde}:{Start-Minute}-{Ende-Stunde}:{Ende-Minute}\nDauer: {Dauer-Stunden}:{Dauer-Minuten}\n{Personen} Personen\n{Bemerkung}"); + return array(true); + } catch (PDOException $e) { + return array(false,$e); + } + } + + public static function upd_1600_1601($pdo, $prefix, $dbname) { + return array(true); + } + public static $updateOrder = array( "1.3.0" => array("upd_1300_1301","1.3.1"), "1.3.1" => array("upd_1301_1302","1.3.2"), @@ -1367,7 +1387,9 @@ class Version { "1.5.29" => array("upd_1529_1530","1.5.30"), "1.5.30" => array("upd_1530_1531","1.5.31"), "1.5.31" => array("upd_1531_1532","1.5.32"), - "1.5.32" => array("upd_1532_1533","1.5.33") + "1.5.32" => array("upd_1532_1533","1.5.33"), + "1.5.33" => array("upd_1533_1600","1.6.0"), + "1.6.0" => array("upd_1600_1601","1.6.1") ); public static function runUpdateProcess($pdo,$prefix, $dbname, $untilVersion,$checkValidVersion) { diff --git a/webapp/pickups.html b/webapp/pickups.html index a3a40d9..8e3eff2 100644 --- a/webapp/pickups.html +++ b/webapp/pickups.html @@ -5,7 +5,7 @@ - + @@ -13,7 +13,7 @@ - + diff --git a/webapp/preferences.html b/webapp/preferences.html index 92b0701..9239af7 100644 --- a/webapp/preferences.html +++ b/webapp/preferences.html @@ -5,7 +5,7 @@ - + @@ -13,7 +13,7 @@ - + diff --git a/webapp/products.html b/webapp/products.html index b6572fc..f9f363e 100644 --- a/webapp/products.html +++ b/webapp/products.html @@ -7,16 +7,16 @@ - + - - - + + + diff --git a/webapp/productsdesktop.php b/webapp/productsdesktop.php index da2a712..c080146 100644 --- a/webapp/productsdesktop.php +++ b/webapp/productsdesktop.php @@ -4,7 +4,7 @@ - + @@ -15,7 +15,7 @@ - + - + diff --git a/webapp/reports.html b/webapp/reports.html index 6cb0431..0410b6f 100644 --- a/webapp/reports.html +++ b/webapp/reports.html @@ -7,14 +7,14 @@ - + - + @@ -51,9 +51,9 @@ var REP_THIS_MONTH_TXT = ["Diese Übersicht umfasst alle Einnahmen dieses Monats var REP_LAST_MONTH_TXT = ["Diese Übersicht umfasst Einnahmen des letzten Monats.", "This overview shows all revenues of the last month.", "Este parte muestra todo el cobro del mes pasado."]; -var REP_PROD_LAST30_TXT = ["Diese Übersicht zeigt die Einnahmen, die mit den in den letzten 30 Tagen verkauften Produkten erzielt wurden.", - "This overview displays the revenue that could be achieved with all sold products in the last 30 days.", - "Este parte muestra el cobro con el productos vendido en los últimos 30 días."]; +var REP_PROD_LAST30_TXT = ["Diese Übersicht zeigt die Einnahmen, die mit den in den letzten Tagen verkauften Produkten erzielt wurden.", + "This overview displays the revenue that could be achieved with all sold products in the last days.", + "Este parte muestra el cobro con el productos vendido en los últimos días."]; var REP_NO_DATA = ["Es liegen keine Daten vor.", "There is no data.", "No hay ningún datos."]; var REP_PRODREP = ["Produktstatistik","Product report","Estadistica de productos"]; var REP_TITLE = ["Statistik","Statistics","Estadisticas"]; @@ -76,6 +76,7 @@ var REP_RECORD_ACTION = [ ["Tischwechsel Produktbuchung","Received moved products","Recibo productos de otra mesa"] ]; var REP_NO_ENTRIES = ["Keine Einträge","No entries","Ningún data"]; +var REP_PRODSLIDER_LABEL = ["Seit wievielen Tagen","Since how many days","Desce hace cuantos dias"]; var lang = 0; var allorders = []; @@ -193,6 +194,27 @@ function setLanguage(language) { }); } + function getProdsSlider() { + var txt = '

      '; + txt += ''; + txt += '
      '; + txt += '

      '; + return txt; + } + + function bindProdsSlider() { + $("#prodsslider").off("slidestop").on("slidestop", function (e) { + e.stopImmediatePropagation(); + e.preventDefault(); + requestNewProdStat(); + }); + } + + function requestNewProdStat() { + var days = $("#prodsslider").val(); + $("#content_prods_section .divaroundtable").html(''); + doAjax("GET", "php/contenthandler.php?module=reports&command=getProds&days=" + days, null, updateProdsStat, "Fehler keine Daten für Produktverkäufe",true); + } function fillUsersums(answer) { if (answer.status == "OK") { var htmlTable = createTableWithData(answer.msg,REP_USER[lang],"center",15,10,75); @@ -230,10 +252,18 @@ function setLanguage(language) { function fillProds(answer) { if (answer.status == "OK") { var htmlTable = createTableWithData(answer.msg,REP_PROD[lang],"left",30,10,60); - $("#content_prods_section").html(htmlTable); + var prodsSlider = getProdsSlider(); + $("#content_prods_section").html(prodsSlider + htmlTable); + $("#prodsliderarea").trigger("create"); + bindProdsSlider(); + } + } + function updateProdsStat(answer) { + if (answer.status == "OK") { + var htmlTable = createTableWithData(answer.msg,REP_PROD[lang],"left",30,10,60); + $("#content_prods_section .divaroundtable").html(htmlTable); } } - function fillRatings(answer) { if (answer.status == "OK") { var htmlPart = createRatingsPartCore(answer.msg,REP_DAY[lang],10,10,40,40); @@ -459,10 +489,11 @@ function setLanguage(language) { function createTableWithData(values,iterObjName,iterAlignment,width1,width2,width3) { var maxValue = values.max; - var content = REP_NO_DATA[lang]; + var content = "

      " + REP_NO_DATA[lang] + "
      "; if (maxValue != 0.0) { - var content = ""; + var content = "
      "; + content += "
      "; content += aTableHeader(iterObjName,REP_SUM[lang],"Graph",width1,width2,width3); var contentValues = values.content; @@ -475,7 +506,7 @@ function setLanguage(language) { width1,width2,width3); }); - content += "
      "; + content += "
    "; } return content; } diff --git a/webapp/reservation.html b/webapp/reservation.html index 143c527..dda0984 100644 --- a/webapp/reservation.html +++ b/webapp/reservation.html @@ -5,7 +5,7 @@ - + @@ -13,8 +13,9 @@ + - + @@ -29,6 +30,11 @@ +var W_TABLES=["Tische","Tables","Mesas"];var W_ATABLE=["Tisch","Table","Mesa"];var W_ROOMS=["Räume","Rooms","Espacios"];var W_SELECTION=["Auswahl","Selection","Selección"];var W_LAST_SELECTED=["zuletzt","last","seleccionado"];var W_FAVS=["Favoriten","Favorites","Favoritos"];var W_NEW_ORDER=["Neue Order","New Orders","Ordenes nuevas"];var W_KIT_BAR=["nicht serviert/unbezahlt","unserved/unpaid","no servido/impagado"];var W_OTHER_PROD=["Auswahl Produktkategorie","Select product categroy","Categoría diferente"];var W_WORK_TICKET=["Arbeitsbon","Work ticket","Tique de trabajar"];var W_NOTE=["Bemerkung","Comment","Comentario"];var W_NUMBER=["Anzahl","Number","Número"];var W_SEND_ORDERS=["Bestellung senden","Send orders","Enviar Ordenes"];var W_TO_PAYDESK=["-> Kasse","-> Paydesk","-> Caja"];var W_TABLECHANGE=["Tischwechsel","Change table","Cambiar mesa"];var W_ROOMTABLE=["Raum-Tisch","Room-Table","Espacio-Mesa"];var W_TABLE_SEL=["Tischauswahl","Select table","Qué mesa?"];var W_UNDELIV_INFO=["Liste enthält die Produkte die noch in der Küchen-/Baransicht sind, sowie unbezahlte Produkte, die die Bereitstellungsansicht nicht durchlaufen.","List contains the products which are still in kitchen or bar view, as well as unpaid products that do not pass the supplydesk view.","La lista contiene los productos que estan todavía en modulo de cocina/bar, también productos impagados que no pasan vista de productos preparados."];var W_REMOVE_ERROR=["Ansicht nicht mehr aktuell - Liste wird neu geladen.","View is obsolete - List will be reloaded.","Vista no esta actual - vamos a actualisar la lista."];var W_FOOD_FOR=["Speisen für","Food for","Comidas para"];var W_DRINKS_FOR=["Getränke für","Beverage for","Bebidas para"];var W_ACT_NEW_ORD_EL=["Aktion auswählen","Select action","Que acción?"];var W_ACT_CHANGE=["Ändern","Modify","Modificar"];var W_ACT_CHANGE_ALL=["Alle Ändern","Modify all","Modificar todo"];var W_ACT_CHANGE_ONE=["Einen Artikel ändern","Modify one item","Modificar un artículo"];var W_APPLY=["Anwenden","Apply","Aplicar"];var W_CANCEL=["Abbrechen","Cancel","Cancelar"];var W_STILL_UNSENT_ORDERS=["Es sind noch ungesendete Orders vorhanden!","There are unsent orders in the list","Hay elementos in la liste que no han enviados"];var W_EXTRAS=["Extras/Optionen","Add-ons/Options","Opciones"];var W_OPEN_PANEL=["Extras-Auswahl noch offen","Add-ons selection still open","Selección de opciones todavía abierta"];var W_DEL=["Löschen","Delete","Removar"];var W_MSG=["Nachricht","Message","Mensaje"];var W_CHANGE_PRICE=["Neuer Preis: ","New price: ","Cambiar precio: "];var W_PRICE=["Preis","Price","Precio"];var W_WRONG_FORMAT=["Falsches Zahlenformat","Wrong number format","Formato de precio incorecto"];var W_TOGO=["Außer-Haus-Verkauf","Sale with Tax No 2","Venta IVA 2"];var W_YES=["Ja","Yes","Si"];var W_NO=["Nein","No","No"];var W_DISCARD_NO_ASK=["Es sind noch ungesendete Orders vorhanden! Sollen diese verworfen werden?","There are still unsent orders. Do you want to discard them?","Hay todavía ordenes non-enviados. Removarlos?"];var W_DISCARD_HEADER=["Neue Orders verwerfen?","Discard new orders?","Removar ordenes nuevos?"];var W_SEARCH=["Produktsuche","Product search","Buscar producto"];var W_BARCODE=["Barcode","Barcode","Código de barras"];var W_SEARCHRESULTS=["Suchergebnis","Search Result","Encontrado"];var W_WRONG_PIN=["Falscher Stornocode","Wrong cancel code","Codigo falso"];var W_NO_ORDERS=["Keine neuen Orders zum Versand vorhanden!","No new orders available!","No hay ningún orden nuevo!"];var W_TO_PAY=["offen","to pay","a pagar"];var W_MOVE_PRODS=["Produkte verschieben","Move products","Productos a otra mesa"];var W_NO_PRODS_SELECTED=["Es wurden keine Produkte ausgewählt!","You have not chosen any products!","No ha seleccionado ningún producto!"];var W_MAX_PRICE_EXCEEDED=["Der Maximalwert für den Preis wurde überschritten!","The max. value for the price is exceeded!","El valor del precio es más que el maximum!"];var W_REORDER=["Nachbestellen","Reorder","Order una vez mas"];var W_REMOVE=["Entfernen","Remove","Removar"];var W_SELALL=["Alles auswählen","Select all","Elegir todo"];var W_UNSELALL=["Alles abwählen","Unselect all","No elegir nada"];var W_ONLY=["noch","only","sólo"];var W_DEL_ALL_UNDELIVERED=["Entferne alles","Remove all","Borrar todo"];var W_DEL_ALL_ASSIGNED_PRODS=["Alle Produkte löschen?","Delete all products?","Removar todos los productos?"];var W_NO_VALID_PRICE=["Keine gültige Zahl","No valid value","No es un número valido"];var W_NO_REORDER_VAR_PRICE=["Nur Produkte mit der Einheit 'Stück' könne auf diese Weise nachbestellt werden.","Only products of unit 'Piece' can be reordered this way.","Un producto de esta unidad no se puede reordenado asi."];var W_INVALID_NO_ENTERING=["Fehler bei der Eingabe","Input contains errors","Número invalido"];var w_INVALID_NO_RANGE=["Ungültiger Zahlenbereich (1-1000)","Invalid number range (1-1000)","Número no es entre 1 y 1000"];var W_DAYCODETXT=["Tageslosung","Day code","Código del día"];var W_RECORDS_HEADER=["Tischprotokoll","Records of table","Historia de la mesa"];var W_RECORDS_INIT=["Tischprotokoll (Anklicken zum Öffnen)","Records of table (click to open)","Historia de la mesa (click para abrir)"];var W_RECORD_ACTION=[["Bestellung","Ordering","Ordenar"],["Rechnung","Bill","Pagar"],["Produktstorno","Discard product","Descartar producto"],["Rechnungsstorno","Discard bill","Descartar pago"],["Rechnungs- und Produktstorno","Discard bill and product","Descrtar pago y producto"],["Tischwechsel Produktentfernung","Move products to other table","Productos a otra mesa"],["Tischwechsel Produktbuchung","Received moved products","Recibo productos de otra mesa"]];var W_NO_ENTRIES=["Keine Einträge","No entries","Ningún data"];var W_NOT_SUPPORTED=["Nicht unterstützt für dieses Produkt","Not supported for this product","No posible para este producto"];var CHANGE_ALL=0;var CHANGE_ONE=1;var WORKFLOW_DIGI_WORK=0;var WORKFLOW_DIGI=1;var WORKFLOW_WORK=2;var WORKFLOW_WORK_SEND=3;function Grouping(b,a){this.set=b;this.sortedset=[];this.group=function(){this.sortedset=[];for(var g=0;g/g,">"))}function setLanguage(c){lang=c;$("#roomtableheader2").html(W_ROOMTABLE[lang]);$("#tableselection").html(W_TABLE_SEL[lang]);$("#actiontxt").html(W_ACT_NEW_ORD_EL[lang]);$("#actdeltxt").html(W_DEL[lang]);$("#discard_new_orders_yes").html(W_YES[lang]);$("#discard_new_orders_no").html(W_NO[lang]);$("#discardnewordersask").html(W_DISCARD_NO_ASK[lang]);$("#discardnoheader").html(W_DISCARD_HEADER[lang]);$("#moveprods").html(W_MOVE_PRODS[lang]);$(".daycodetxt").html(W_DAYCODETXT[lang]);var k="";if(prominentsearch==0){k+='
    ';if(usebarcode==1){k+=''}}else{if(usebarcode==0){k+='
    ';k+="
    "}else{k+='
    ';k+='';k+="
    "}}k+="
    ";var a='
    ';if(prominentsearch==0){$("#searchposition-normal").html(k)}else{$("#searchposition-prominent").html(k)}if(usebarcode==1){$("#barcode").focus()}var g=a;var f="";if((workflowconfig==WORKFLOW_DIGI_WORK)||(workflowconfig==WORKFLOW_DIGI)||(workflowconfig==WORKFLOW_WORK_SEND)){f=" osbigbtn ";if(preferfixbtns==1){f=" ossmallbtn fixedsendorderbtn "}if(showtransferbtns==1){g+=''+W_SEND_ORDERS[lang]+""}}if((workflowconfig==WORKFLOW_DIGI_WORK)||(workflowconfig==WORKFLOW_WORK)||(workflowconfig==WORKFLOW_WORK_SEND)){f=" osbigbtn ";if(preferfixbtns==1){f=" ossmallbtn fixedworkprintbtn "}if(showtransferbtns==1){g+=''+W_WORK_TICKET[lang]+""}}if(cashenabled==1){f=" osbigbtn ";if(preferfixbtns==1){f=" ossmallbtn fixedgopaydeskbtn "}g+=''+W_TO_PAYDESK[lang]+""}g+='';$("#commandbuttons").html(g);if(preferfixbtns==1){$("#waiterui").addClass("fixedwaiterui")}$("#waiterui").trigger("create");var i="
    "+W_NUMBER[lang]+':
    ';var b='
    ';$("#actremark").html(i+b);if(rightchangeprice==1){var e='';$("#actchangepricesection").html(e);var h='
    ';h+=getDiscountButton("discount1","a",discount1,discountname1);h+=getDiscountButton("discount2","b",discount2,discountname2);h+=getDiscountButton("discount3","c",discount3,discountname3);h+="
    ";$("#actdiscount").html(h)}$("#actionneworderconfirm_all").html(W_ACT_CHANGE_ALL[lang]);$("#actionneworderconfirm_one").html(W_ACT_CHANGE_ONE[lang]);$("#actionnewordercancel").html(W_CANCEL[lang]);$("#select-comment").off("change").on("change",function(m){var l=$("#select-comment").find(":selected").val();$("#optionfield").val(l)});$("#act-select-comment").off("change").on("change",function(m){var l=$("#act-select-comment").find(":selected").val();$("#act-optionfield").val(l)});$("#discard_new_orders_no").off("click").on("click",function(l){l.stopImmediatePropagation();l.preventDefault();parent.history.back()});$("#discard_priceenter").off("click").on("click",function(l){l.stopImmediatePropagation();l.preventDefault();$("#enterpricedlg").dialog("close")});$("#discard_numberenter").off("click").on("click",function(l){l.stopImmediatePropagation();l.preventDefault();$("#enternumberdlg").dialog("close")});$("#discard_new_orders_yes").off("click").on("click",function(l){l.stopImmediatePropagation();l.preventDefault();neworders=[];gotoOtherPage($("#discardnewordersdlg").data("link"))});$("#prodbackbtn").off("click").on("click",function(l){if(neworders.length!=0){l.stopImmediatePropagation();l.preventDefault();hideMenuProd();$("#discardnewordersdlg").data("link","back_table");$.mobile.changePage("#discardnewordersdlg")}else{parent.history.back()}});$("#searchField").off("keyup").on("keyup",function(l){generateSearchResults()});if(usebarcode==1){$("#barcode").focus()}$("#barcode").off("keyup").on("keyup",function(l){handleBarcodeInput()})}function getDiscountButton(f,e,c,a){var b='";if(a.trim()!=""){b='"}return b}function generateSearchResults(){var i=$("#searchField").val().trim().toLowerCase();if(i.length";var h=$("#typprodpage").data("types_prods_sorted");var a=false;var g=null;for(var f=0;f=0){g=e.prodimageid;if(g!=0){a=true;break}}}$.each(h,function(n,o){var m=o.longname;if(m.toLowerCase().indexOf(i)>=0){c+='
  • ';if(a&&(preferimgmobile==1)){var l="php/contenthandler.php?module=products&command=getprodimage&prodid="+o.id+"&size=l";c+=''}c+=toHtml(m);c+=createSearchProdInfoTxt(o.id,o.unit);c+="
  • "}});c+="
";$("#searchResult").html(c);$("#searchResult").trigger("create");$(".srinfo").off("click").on("click",function(q){q.stopImmediatePropagation();q.preventDefault();var m=this.id.split("_")[1];var p=getProdEntry(m);var o=p.price;var n=p.unit;var l=W_PRICE[lang]+": "+o+" "+currency;if(n>2){l+="/"+g_units_arr[n].text}alert(l)});$(".srplus").off("click").on("click",function(n){n.stopImmediatePropagation();n.preventDefault();var m=this.id.split("_")[1];var l=getSearchProdCount(m);$("#srprodcount_"+m).html(l+1)});$(".srminus").off("click").on("click",function(n){n.stopImmediatePropagation();n.preventDefault();var m=this.id.split("_")[1];var l=getSearchProdCount(m);if(l==2){$("#srprodcount_"+m).html(1);selectedProdCount=1}else{if(l>2){$("#srprodcount_"+m).html(l-1)}}});$(".srprodcount").off("click").on("click",function(o){o.stopImmediatePropagation();o.preventDefault();var n=this.id.split("_")[1];var m=getProdEntry(n);var l=m.unit;if(l>1){alert(W_NOT_SUPPORTED[lang]);return}$("#enternumberdlg").data("prodid",n);enternumberdlgshown=true;$("#enternumberfield").val("");$.mobile.changePage("#enternumberdlg");var p=$(this).parent().attr("id");bindEnterSearchNumberNumbers(p)});$(".searchresult").off("click").on("click",function(m){m.stopImmediatePropagation();m.preventDefault();var l=this.id.split("_")[1];handleClickOnSearchResult(l)})}}function handleBarcodeInput(){var c=$("#barcode").val();c=c.split("-").join("");c=c.split(" ").join("");if(c!=""){var a=findProdWithBarcode(c);if(a!=null){$("#barcode").val("");var b=a.id;beep();handleClickOnProd(b)}}}function findProdWithBarcode(b){var e=$("#typprodpage").data("types_prods_sorted");for(var c=0;c'+a+""}htmlComments=b;predefinedComments=b;$("#select-comment").html(b);$("#select-comment").selectmenu("refresh")}function initializeMainMenu(a,h,e,i,g){$("#"+e).html(" "+a.user);$("#"+i).html(a.version+" ");var k='
  • Module
  • ';$.each(a.menu,function(n,m){var l=m.name;var o=m.link;if(g){k+='
  • '+l+"
  • "}else{k+='
  • '+l+"
  • "}});$(h).empty().append(k).promise().done(function(){refreshList(h)});if(h=="#modulemenu-room"){var c=a.waitermessage;if(c!=""){$("#waitermessage").show();var b='
  • '+W_MSG[lang]+"
  • ";var f='
  • '+toHtml(c)+"
  • ";$("#waitermessage").html(b+f);refreshList("#waitermessage")}else{$("#waitermessage").hide()}}$(".modulebutton").off("click").on("click",function(m){var l=$(this).attr("href");doJsonAjaxAsync("POST","php/contenthandler.php?module=admin&command=setLastModuleOfUser",{view:l},null,"Problem Benutzerdatenpflege",false)})}function intervalCheckConnection(b){checkConnection();var a=setInterval(function(){checkConnection()},b*1000)}function checkConnection(){var a=new Image();a.onerror=function(){$(".connectionstatus").show()};a.onload=function(){$(".connectionstatus").hide()};a.src="img/gray.png?t="+(+new Date)}function refreshList(a){if($(a).hasClass("ui-listview")){$(a).listview("refresh")}else{$(a).trigger("create")}}function gotoOtherPage(a){var b=a.split("_");if(b[0]=="menu"){doJsonAjax("POST","php/contenthandler.php?module=admin&command=setLastModuleOfUser",{view:b[1]},null,null);setTimeout(function(){document.location.href=b[1]},250)}else{if(b[0]=="back"){$("#discardnewordersdlg").dialog("close");parent.history.back()}}}function moduleForward(a){if(neworders.length==0){gotoOtherPage(a)}else{hideMenuProd();$("#discardnewordersdlg").data("link",a);$.mobile.changePage("#discardnewordersdlg")}}function getPayPrintType(){doJsonAjax("GET","php/contenthandler.php?module=admin&command=getPayPrintType",null,insertPayPrintType,"Fehler Druckkonfiguration")}function insertPayPrintType(a){$("#workprintarea").data("payPrintType",a)}function getUserHasRightForPaydesk(){doJsonAjax("GET","php/contenthandler.php?module=admin&command=hasUserPaydeskRight",null,hasUserPaydeskRight,"Fehler Kassenberechtigung")}function hasUserPaydeskRight(a){$("#gopaydesk_btn").data("allowed",a)}function hideMenuRoom(){$("#modulepanel-room").panel("close");$("#menuswitch").off("click").on("click",function(a){a.stopImmediatePropagation();a.preventDefault();$("#modulepanel-room").panel("open")})}function hideMenuTable(){$("#modulepanel-table").panel("close");$("#menuswitchtable").off("click").on("click",function(a){a.stopImmediatePropagation();a.preventDefault();$("#modulepanel-table").panel("open")})}function hideMenuProd(){$("#modulepanel-prod").panel("close");$("#menuswitchprod").off("click").on("click",function(a){a.stopImmediatePropagation();a.preventDefault();$("#modulepanel-prod").panel("open")})}function calcTotalPriceOfProdAndExtras(b,c){var e=parseFloat(b);var a=extrasManagement.calcPriceOfAssignedExtras(c);totalPrice=(parseFloat(e+a)).toFixed(2);return totalPrice}function addProductToQueueNoGuiUpdate(f,m,h,c,e,o,g){var b=getProdProperties(f);var a=b.name;var k=calcTotalPriceOfProdAndExtras(b.price,h);var n={name:a,option:m,extras:h,prodid:f,price:k,changedPrice:c,togo:e,unit:o,unitamount:g};for(var l=0;l";var f=groupedNewOrders.count.length;for(s=0;s1){t=n+g_units_arr[o].text+" "}var q=toHtml(groupedNewOrders.name[s]);var u=groupedNewOrders.option[s];var h=groupedNewOrders.count[s];if(h>1){q=""+h.toString()+"x "+t+q}else{q=t+q}var p=groupedNewOrders.prodids[s];if(u!=""){u="

    "+toHtml(u)+"

    "}var e=groupedNewOrders.changedPrices[s];var k=groupedNewOrders.togos[s];var a="";var g=groupedNewOrders.extras[s];if((g!=null)&&(g!="")){a=""+g+""}var r='
  • ';var b=q+u+a;if(e!="NO"){e=e.replace(".",decpoint)+" "+currency;if(o>1){e+="/"+g_units_arr[o].text}if(k!=0){m+=r+''+b+" ("+e+" - To-Go)
  • "}else{m+=r+''+b+" ("+e+")"}}else{if(k!=0){m+=r+''+b+" - To-Go"}else{m+=r+''+b+""}}}$("#neworders").html(m);refreshList("#neworders");binding_neworderelem()}function getProdSizeClass(){if(osprodbtnsize==1){return("osprod-1")}else{if(osprodbtnsize==2){return("osprod-2")}}return""}function binding_neworderelem(){$(".neworder_el").off("click").on("click",function(c){c.stopImmediatePropagation();c.preventDefault();var b=$("#neworders li").index($(this).closest("li"))-1;var a={count:groupedNewOrders.count[b],name:groupedNewOrders.name[b],price:groupedNewOrders.price[b],option:groupedNewOrders.option[b],extras:groupedNewOrders.extras[b],prodid:groupedNewOrders.prodids[b],origidxs:groupedNewOrders.origidxs[b],changedPrices:groupedNewOrders.changedPrices[b],togos:groupedNewOrders.togos[b],unit:groupedNewOrders.units[b],unitamount:groupedNewOrders.unitamounts[b]};$("#actiononneworderel").data("entry",a);$("#actiononneworderel").data("newcount",a.count);$("#actiononneworderel").data("groupedListIndex",b);$("#actiononneworderel").data("countatdialogstart",a.count);$("#act-optionfield").val(a.option);$("#act-numberfield").val(a.count);$("#togocheckbox").prop("checked",a.togos==1?true:false);actionSelOnNewOrderElem()})}function calcTotalPriceOfNewOrders(){var a=0;if(neworders.length!=0){neworders.forEach(function(c,b){if(c.changedPrice.toLowerCase()=="no"){a+=parseFloat(c.price)}else{a+=parseFloat(c.changedPrice)}})}a=a.toFixed(2).replace(".",decpoint);return a+" "+currency}function sendNewOrders(c,f,a){var g=$("#typprodpage").data("table-info");var b=g[1];if(neworders.length!=0){var e={tableid:b,prods:neworders,print:(c?1:0),payprinttype:f};$("#typprodpage").data("neworders",[]);if(f=="s"){doJsonAjax("POST","php/contenthandler.php?module=queue&command=addProductListToQueue",e,a,"Fehler bei Produktversand")}else{doJsonAjax("POST","php/contenthandler.php?module=queue&command=addProductListToQueue",e,fillPrintAreaAndPrint,"Fehler bei Produktversand")}}else{if(c&¬DeliveredProdsAvailable){}}}function reloadPage(){tableListActive=false;setTimeout(function(){document.location.href="waiter.html"},250)}function removeCurrentOrders(){groupedNewOrders={count:[],joinedvals:[],name:[],prodids:[],extras:[],origidxs:[],changedPrices:[],togos:[]};neworders=[]}function gotoTablePage(){removeCurrentOrders();var a=$("#tables-page").data("allroomtables");var b=a.length;if(!isTogoOrderSelected||(b==1)){if(tablesAfterSend==1){$.mobile.changePage("#tables-page")}else{reloadPage()}}else{reloadPage()}}function removeProductFromQueue(a,c,f,e,b,g){if(typeof g==="undefined"){g=true}if(!b){alert(W_WRONG_PIN[lang]);return}$.ajax({type:"POST",dataType:"json",url:"php/contenthandler.php?module=queue&command=removeProductFromQueue",data:{queueid:a,isPaid:c,isCooking:f,isReady:e},async:false,success:function(l){if(l.status!="OK"){alert(W_REMOVE_ERROR[lang])}var k=$("#typprodpage").data("table-info");var h=k[1];var i="php/contenthandler.php?module=queue&command=getJsonLongNamesOfProdsForTableNotDelivered&tableid="+h;if(g){fillNotDeliveredProductsOfATable(i)}},error:function(h){alert("Sorry, Fehler bei Produktentfernung!")}})}function reorderProduct(f,b,h,g){var a=getProdProperties(f);if((a.unit!=0)&&(a.unit!="null")){alert(W_NO_REORDER_VAR_PRICE[lang]);return}var e=[];for(var c=0;c'+k.name+""});if(showtogo==1){a+='
  • '+W_TOGO[lang]}var f=h.takeawayprice;var c=f.replace(".",decpoint)+" "+currency;if(f!=0){a+=" ("+W_TO_PAY[lang]+": "+c+")"}a+=createServeInfo(null,h.takeawayprodcount,h.takeawayprodready);a+="
  • ";$("#room-list").append(a).promise().done(function(){bindTogoOrdering();bindServeClick();$(this).off("click").on("click","a",function(l){l.stopImmediatePropagation();l.preventDefault();var k=b[this.id];currentRoomIndex=this.id;isTogoOrderSelected=false;$("#tables-page").data("roomdetail",k);nextPage="tables-page";$.mobile.changePage("#tables-page")});refreshList(this)})}}})}function handleClickInTablemap(a){forwardDisplayToProductView.call(this,a.roomid,a.tableid,a.tablename)}$(document).on("pagebeforeshow","#tables-page",function(){lastSelectedProduct="";tableListActive=true;if(nextPage==""){reloadPage()}hideMenuTable();checkForLogIn();$("#searchField").val("");$("#barcode").val("");generateSearchResults();$("#tableselbackbtn").off("click").on("click",function(a){a.stopImmediatePropagation();a.preventDefault();tableListActive=false;$.mobile.changePage("#info-page")});updateTableList()});$(document).on("pagebeforeshow","#changetablewhatdialog",function(){var a=$("#changetablewhatdialog").data("fromtableid");doJsonAjax("GET","php/contenthandler.php?module=queue&command=getProdsForTableChange",{tableId:a},insertProductsToChangeTableDlg,"Tischartikel")});function insertProductsToChangeTableDlg(a){if(a.status!="OK"){alert("Fehler");return}prodsToMove=a.msg;allselected=1;updateProdToMoveList();$("#selectallnothing").off("click").on("click",function(f){f.stopImmediatePropagation();f.preventDefault();allselected=1-allselected;for(var c=0;c"+c.productname+b+"";a+="
  • "+g+"
  • "}$("#productsToMoveList").html(a);refreshList("#productsToMoveList");handleClickOnMoveableProd()}function handleClickOnMoveableProd(){$(".prodToMoveEl").off("click").on("click",function(f){f.stopImmediatePropagation();f.preventDefault();var b=this.id.split("_")[1];var a=prodsToMove[b];var c=a["class"];if(c=="unselecteditem"){a["class"]="selecteditem"}else{a["class"]="unselecteditem"}updateProdToMoveList()});$("#moveprods").off("click").on("click",function(k){k.stopImmediatePropagation();k.preventDefault();var g=[];for(var f=0;f'+W_TOGO[lang]+""}k+="";$("#tables-list-togo").html(k);$("#togoarea").show();refreshList("#tables-list-togo");bindTogoOrdering();bindServeClick()}}else{$(h).show();$("#togoarea").hide();$("#tablemapcontent").hide();var k='
  • '+W_TABLES[lang]+"
  • ";var f="";if(ostablebtnsize==1){f="ostable-1"}else{if(ostablebtnsize==2){f="ostable-2"}}$.each(l,function(s,u){var r=u.pricesum;var q=r.replace(".",decpoint)+" "+currency;var o=u.prodcount;var t=u.prodready;var n=u.readyQueueIds;var m=u.reservations;var p=u.name;if(m!=""){p+=" (Res.: "+m+")"}if(r!=0){k+='
  • '+p+" ("+W_TO_PAY[lang]+": "+q+")"+createServeInfo(u.id,o,t)+"
  • "}else{k+='
  • '+p+createServeInfo(u.id,o,t)+"
  • "}});if(c=="t"){if(showtogo==1){k+='
  • '+W_TOGO[lang]+"
  • "}}$(h).empty().append(k).promise().done(function(){bindTogoOrdering();bindServeClick();$(this).off("click").on("click",".info-go",function(p){p.stopImmediatePropagation();p.preventDefault();var o=g;var m=l[this.id]["id"];var n=l[this.id]["name"];forwardDisplayToProductView.call(this,a,m,n)});refreshList(this)})}}function bindServeClick(){$(".prodreadyicon").off("click").on("click",function(l){l.stopImmediatePropagation();l.preventDefault();var f=this.id.split("_")[1];var h=queueIdsOfTakeAway;if((f!=null)&&(f!="n")){var a=$("#tables-page").data("roomdetail");var c=a.tables;for(var b=0;b0){var k=h.join();doJsonAjax("POST","php/contenthandler.php?module=queue&command=declareMultipleProductsDelivered",{queueids:k},updateAfterDelivery,"Bereitstellung")}})}function updateAfterDelivery(a){if(tableListActive){updateTableList()}else{reloadPage()}}function bindTogoOrdering(){$(".togoorder").off("click").on("click",function(a){a.stopImmediatePropagation();a.preventDefault();isTogoOrderSelected=true;forwardDisplayToProductView.call(this,0,0,W_TOGO[lang])})}function forwardDisplayToProductView(b,a,c){neworders=[];updateNewOrdersGui();var e=new Array(b,a,c);$("#typprodpage").data("table-info",e);nextPage="typprodpage";$.mobile.changePage("#typprodpage");neworders=[];updateNewOrdersGui()}function attachAndDisplayFirstRefTypes(e){$("#typprodpage").data("types_prods",e);var a=e.prods;var c=[];for(var b=0;b";if(applyExtraBtnPos!=1){a+='
  • '+W_APPLY[lang]+"
  • "}a+=extrasManagement.renderExtras(c,b,true);if(requestPriceInExtras!=false){a+='
  •  '+currency+"
  • "}if(applyExtraBtnPos!=2){a+='
  • '+W_APPLY[lang]+"
  • "}a+=createHigherLine(b);return a}function bindExtrasSel(){$(".extrasel").off("click").on("click",function(i){i.stopImmediatePropagation();i.preventDefault();var a=this.id.split("_");var b=a[1];var f=a[2];if((b=="abottom")||(b=="atop")){var g=getProdEntry(f);var c=g.extras;var k=extrasManagement.getAssignedExtras();if(requestPriceInExtras){var h=$("#enterpriceextrasfield").val();h=h.trim();h=h.replace(decpoint,".");if((h!="")&&($.isNumeric(h))){requestPriceInExtras=false;presetPriceInExtras="";addProductToNewOrdersList(f,k,h,0,1)}else{alert(W_NO_VALID_PRICE[lang])}}else{addProductToNewOrdersList(f,k,null,0,1)}}else{extrasManagement.extraClicked(b);if(requestPriceInExtras!==false){presetPriceInExtras=$("#enterpriceextrasfield").val()}var l=listOfExtras(f);$("#typeproducts-list").html(l);refreshList("#typeproducts-list");bindExtrasSel();bindHigherButtons()}})}function lastSelectedProdToStr(){return" ("+W_LAST_SELECTED[lang]+": "+lastSelectedProduct+")"}function listOfTypesProds(g){var a='
  • '+W_SELECTION[lang]+"";if(lastSelectedProduct!=""){a+=lastSelectedProdToStr()}a+="
  • ";var b=$("#typprodpage").data("types_prods");var f=getProdSizeClass();$.each(b.types,function(l,k){if(parseInt(k.ref)==g){a+='
  • '+toHtml(k.name)+"
  • "}});var i=false;if(preferimgmobile==1){var e=null;for(var c=0;c';if(i&&(preferimgmobile==1)){var k="php/contenthandler.php?module=products&command=getprodimage&prodid="+m.id+"&size=l";a+=''}a+=toHtml(m.name);if((m.amount!="null")&&(m.amount<11)){a+=" ("+W_ONLY[lang]+" "+m.amount+")"}a+=createProdInfoTxt(m.id,m.unit);a+=""}});if(g!=0){a+=createHigherLine(f)}return a}function createHigherLine(e){var f="f";if(preferfixbtns==1){f="a"}var a='
  • ';a+='
    ';var c="";var b="";if(preferfixbtns==1){c="fixedtypetopimg";b="fixedtypehigherimg"}a+='
    ';a+='
    ';a+="
    ";a+="
  • ";return a}function createProdEntryWithTextPrice(a,f,g){var e=getProdEntry(a);var c=e.unit;if(e!=null){var b=e.price.replace(".",decpoint);if(c>1){b+="
    /"+g_units_arr[c].text}return"
    "+b+"
    "}return""}function createProdInfoTxt(b,c){var a="";if(showplusminus==1){a+="1";7}if(priceinlist==0){a+="
    "}else{a+=createProdEntryWithTextPrice(b,"prodtextinfo","pinfo")}if(showplusminus==1){a+="
    ";a+="
    "}return a}function createSearchProdInfoTxt(b,c){var a="";if(showplusminus==1){a+="1"}if(priceinlist==0){a+="
    "}else{a+=createProdEntryWithTextPrice(b,"srtextinfo","srinfo")}if(showplusminus==1){a+="
    ";a+="
    "}return a}function createServeInfo(e,c,b){if(supplyright==0){return""}if(e==null){e="n"}if(b>0){var a=""+b+"("+c+")";if(b>=c){a+="
    "}else{a+="
    "}return a}else{return""}}function getProdEntry(e){var b=$("#typprodpage").data("types_prods");var c=0;var a=b.prods;for(c=0;c";var b=$("#typprodpage").data("types_prods");var e=getProdSizeClass();var a=false;var c=[];$.each(b.prods,function(g,h){if(parseInt(h.favorite)==1){a=true;c[c.length]={id:h.id,longname:h.longname,unit:h.unit}}});c.sort(prodcompare);$.each(c,function(g,h){f+='
  • '+toHtml(h.longname);f+=createProdInfoTxt(h.id,h.unit);f+="
  • "});f+="";if(a){$("#favarea").html(f);$("#favarea").trigger("create")}else{$("#favarea").html("");$("#favarea").trigger("create")}}function bindFavEvent(){$(".fav").off("click").on("click",function(b){b.stopImmediatePropagation();b.preventDefault();favOrSearchWasClicked=true;levelOneType=0;var a=this.id.split("_")[1];if(showplusminus==1){selectedProdCount=getProdCount(a)}else{selectedProdCount=1}handleClickOnProd(a)})}function displayTypesProds(c,b){if(preferfixbtns!=1){window.scrollTo(0,0)}if(c==0){fillFavArea();bindFavEvent()}else{$("#favarea").html("")}var a=null;if(b==null){idOfHigherType=c;a=listOfTypesProds(parseInt(c));extrasMenuOpen=false}else{a=listOfExtras(parseInt(c));extrasMenuOpen=true}$("#typeproducts-list").empty().append(a).promise().done(function(){refreshList("#typeproducts-list");$(this).off("click").on("click","a",function(f){f.stopImmediatePropagation();f.preventDefault();productInListClicked(this.id,c)});bindHigherButtons()});$(".prodinfo").off("click").on("click",function(l){l.stopImmediatePropagation();l.preventDefault();var g=this.id.split("_")[1];var k=getProdEntry(g);var i=k.price;var h=k.unit;var f=W_PRICE[lang]+": "+i+" "+currency;if(h>2){f+="/"+g_units_arr[h].text}alert(f)});$(".prodplus").off("click").on("click",function(h){h.stopImmediatePropagation();h.preventDefault();var g=this.id.split("_")[1];var f=getProdCount(g);$("#prodcount_"+g).html(f+1)});$(".prodminus").off("click").on("click",function(h){h.stopImmediatePropagation();h.preventDefault();var g=this.id.split("_")[1];var f=getProdCount(g);if(f==2){$("#prodcount_"+g).html(1);selectedProdCount=1}else{if(f>2){$("#prodcount_"+g).html(f-1)}}});$(".prodcount").off("click").on("click",function(i){i.stopImmediatePropagation();i.preventDefault();var h=this.id.split("_")[1];var g=getProdEntry(h);var f=g.unit;if(f>1){alert(W_NOT_SUPPORTED[lang]);return}$("#enternumberdlg").data("prodid",h);enternumberdlgshown=true;$("#enternumberfield").val("");$.mobile.changePage("#enternumberdlg");var k=$(this).parent().attr("id");bindEnterNumberNumbers(k,c)})}function productInListClicked(b,e){favOrSearchWasClicked=false;$("#searchField").val("");$("#barcode").val("");generateSearchResults();var a=b.split("_");if(a[0]=="t"){if(e==0){levelOneType=a[1];e=a[1]}displayTypesProds(a[1],null)}else{var c=a[1];if(showplusminus==1){selectedProdCount=getProdCount(c)}else{selectedProdCount=1}$("#prodcount_"+c).html(1);handleClickOnProd(c)}}function getHigherType(){var c=$("#typprodpage").data("types_prods");var b=c.types;var f=0;if(!extrasMenuOpen){for(var e=0;e0)&&(e<2)){idOfHigherType=f.ref;if(f.unit==1){requestPriceInExtras=true;presetPriceInExtras=""}else{requestPriceInExtras=false}displayTypesProds(c,b);bindExtrasSel()}else{if(f.unit!=0){var a=g_units_arr[f.unit].longtext;$("#enterpriceheader").html(a);$("#enterpricedlg").data("unit",f.unit);hideMenuProd();enterpricedlgshown=true;$("#enterpricedlg").data("prodid",c);$("#enterpricefield").val("");$.mobile.changePage("#enterpricedlg");bindEnterPriceNumbers()}else{addProductToNewOrdersList(c,null,null,0,1)}}}function bindEnterPriceNumbers(){$(".numfield td").off("click").on("click",function(b){b.stopImmediatePropagation();b.preventDefault();var f=$(this).html();var a=$(this).attr("class");if(a!="keyboardapply"){var c=String($("#enterpricefield").val());$("#enterpricefield").val(c+f)}});$("#apply_priceenter").off("click").on("click",function(f){f.stopImmediatePropagation();f.preventDefault();var a=$("#enterpricedlg").data("prodid");var c=$("#enterpricefield").val();c=c.trim();c=c.replace(decpoint,".");var b=$("#enterpricedlg").data("unit");if((c!="")&&($.isNumeric(c))){$("#enterpricedlg").dialog("close");if(b==1){addProductToNewOrdersList(a,null,c,0,1)}else{addProductToNewOrdersList(a,null,null,b,c)}}else{alert(W_NO_VALID_PRICE[lang])}})}function bindPartNumberEntry(){$(".numfield td").off("click").on("click",function(f){f.stopImmediatePropagation();f.preventDefault();var g=$(this).html();var c=$(this).attr("class");if(c!="keyboardapply"){var a=String($("#enternumberfield").val());if(c=="dellastkey"){var h=a.length;if(h>0){var b=a.substring(0,h-1);$("#enternumberfield").val(b)}}else{$("#enternumberfield").val(a+g)}}})}function bindEnterNumberNumbers(b,a){bindPartNumberEntry();$("#apply_numberenter").off("click").on("click",function(g){g.stopImmediatePropagation();g.preventDefault();var f=$("#enternumberdlg").data("prodid");var c=$("#enternumberfield").val().trim();if(c==""){c=1}if($.isNumeric(c)){if((c<1)||(c>1000)){alert(w_INVALID_NO_RANGE[lang])}else{if(c>1){$("#enternumberdlg").dialog("close");$("#prodcount_"+f).html(c);productInListClicked(b,a)}else{$("#enternumberdlg").dialog("close");$("#prodcount_"+f).html("");productInListClicked(b,a)}}}else{alert(W_INVALID_NO_ENTERING[lang])}})}function bindEnterSearchNumberNumbers(a){bindPartNumberEntry();$("#apply_numberenter").off("click").on("click",function(f){f.stopImmediatePropagation();f.preventDefault();var c=$("#enternumberdlg").data("prodid");var b=$("#enternumberfield").val().trim();if(b==""){b=1}if($.isNumeric(b)){if((b<1)||(b>1000)){alert(w_INVALID_NO_RANGE[lang])}else{if(b>1){$("#enternumberdlg").dialog("close");$("#srprodcount_"+c).html(b);handleClickOnSearchResult(c)}else{$("#enternumberdlg").dialog("close");$("#srprodcount_"+c).html(1);handleClickOnSearchResult(c)}}}else{alert(W_INVALID_NO_ENTERING[lang])}})}function addProductToNewOrdersList(e,f,g,m,b){if(g==undefined){g=null}if(m==undefined){m=0}if(b==undefined){b=1}var h=$("#typprodpage").data("table-info");var a=h[1];addProductToQueue(e,f,"NO",0,g,m,b);var i=getProdAudio(parseInt(e));var c=parseInt($("#typprodpage").data("ordervolume"))/10;if(i!=""){var l="customer/"+i;if(i.match(/mp3$/)){$("#audiofile").html('')}else{if(i.match(/ogg$/)){$("#audiofile").html('')}else{if(i.match(/wav$/)){$("#audiofile").html('')}}}document.getElementById("audiofile").load();document.getElementById("audiofile").volume=c;document.getElementById("audiofile").play()}else{if(c>0.5){beep()}}var k="php/contenthandler.php?module=queue&command=getJsonLongNamesOfProdsForTableNotDelivered&tableid="+a;fillNotDeliveredProductsOfATable(k);if((keeptypelevel==0)||(favOrSearchWasClicked)){displayTypesProds(levelOneType,null)}else{if(extrasMenuOpen){displayTypesProds(idOfHigherType,null)}}allowPrintAndOrderBtn=true;refreshList("#typeproducts-list")}function beep(){var a=new Audio("data:audio/wav;base64,//uQRAAAAWMSLwUIYAAsYkXgoQwAEaYLWfkWgAI0wWs/ItAAAGDgYtAgAyN+QWaAAihwMWm4G8QQRDiMcCBcH3Cc+CDv/7xA4Tvh9Rz/y8QADBwMWgQAZG/ILNAARQ4GLTcDeIIIhxGOBAuD7hOfBB3/94gcJ3w+o5/5eIAIAAAVwWgQAVQ2ORaIQwEMAJiDg95G4nQL7mQVWI6GwRcfsZAcsKkJvxgxEjzFUgfHoSQ9Qq7KNwqHwuB13MA4a1q/DmBrHgPcmjiGoh//EwC5nGPEmS4RcfkVKOhJf+WOgoxJclFz3kgn//dBA+ya1GhurNn8zb//9NNutNuhz31f////9vt///z+IdAEAAAK4LQIAKobHItEIYCGAExBwe8jcToF9zIKrEdDYIuP2MgOWFSE34wYiR5iqQPj0JIeoVdlG4VD4XA67mAcNa1fhzA1jwHuTRxDUQ//iYBczjHiTJcIuPyKlHQkv/LHQUYkuSi57yQT//uggfZNajQ3Vmz+Zt//+mm3Wm3Q576v////+32///5/EOgAAADVghQAAAAA//uQZAUAB1WI0PZugAAAAAoQwAAAEk3nRd2qAAAAACiDgAAAAAAABCqEEQRLCgwpBGMlJkIz8jKhGvj4k6jzRnqasNKIeoh5gI7BJaC1A1AoNBjJgbyApVS4IDlZgDU5WUAxEKDNmmALHzZp0Fkz1FMTmGFl1FMEyodIavcCAUHDWrKAIA4aa2oCgILEBupZgHvAhEBcZ6joQBxS76AgccrFlczBvKLC0QI2cBoCFvfTDAo7eoOQInqDPBtvrDEZBNYN5xwNwxQRfw8ZQ5wQVLvO8OYU+mHvFLlDh05Mdg7BT6YrRPpCBznMB2r//xKJjyyOh+cImr2/4doscwD6neZjuZR4AgAABYAAAABy1xcdQtxYBYYZdifkUDgzzXaXn98Z0oi9ILU5mBjFANmRwlVJ3/6jYDAmxaiDG3/6xjQQCCKkRb/6kg/wW+kSJ5//rLobkLSiKmqP/0ikJuDaSaSf/6JiLYLEYnW/+kXg1WRVJL/9EmQ1YZIsv/6Qzwy5qk7/+tEU0nkls3/zIUMPKNX/6yZLf+kFgAfgGyLFAUwY//uQZAUABcd5UiNPVXAAAApAAAAAE0VZQKw9ISAAACgAAAAAVQIygIElVrFkBS+Jhi+EAuu+lKAkYUEIsmEAEoMeDmCETMvfSHTGkF5RWH7kz/ESHWPAq/kcCRhqBtMdokPdM7vil7RG98A2sc7zO6ZvTdM7pmOUAZTnJW+NXxqmd41dqJ6mLTXxrPpnV8avaIf5SvL7pndPvPpndJR9Kuu8fePvuiuhorgWjp7Mf/PRjxcFCPDkW31srioCExivv9lcwKEaHsf/7ow2Fl1T/9RkXgEhYElAoCLFtMArxwivDJJ+bR1HTKJdlEoTELCIqgEwVGSQ+hIm0NbK8WXcTEI0UPoa2NbG4y2K00JEWbZavJXkYaqo9CRHS55FcZTjKEk3NKoCYUnSQ0rWxrZbFKbKIhOKPZe1cJKzZSaQrIyULHDZmV5K4xySsDRKWOruanGtjLJXFEmwaIbDLX0hIPBUQPVFVkQkDoUNfSoDgQGKPekoxeGzA4DUvnn4bxzcZrtJyipKfPNy5w+9lnXwgqsiyHNeSVpemw4bWb9psYeq//uQZBoABQt4yMVxYAIAAAkQoAAAHvYpL5m6AAgAACXDAAAAD59jblTirQe9upFsmZbpMudy7Lz1X1DYsxOOSWpfPqNX2WqktK0DMvuGwlbNj44TleLPQ+Gsfb+GOWOKJoIrWb3cIMeeON6lz2umTqMXV8Mj30yWPpjoSa9ujK8SyeJP5y5mOW1D6hvLepeveEAEDo0mgCRClOEgANv3B9a6fikgUSu/DmAMATrGx7nng5p5iimPNZsfQLYB2sDLIkzRKZOHGAaUyDcpFBSLG9MCQALgAIgQs2YunOszLSAyQYPVC2YdGGeHD2dTdJk1pAHGAWDjnkcLKFymS3RQZTInzySoBwMG0QueC3gMsCEYxUqlrcxK6k1LQQcsmyYeQPdC2YfuGPASCBkcVMQQqpVJshui1tkXQJQV0OXGAZMXSOEEBRirXbVRQW7ugq7IM7rPWSZyDlM3IuNEkxzCOJ0ny2ThNkyRai1b6ev//3dzNGzNb//4uAvHT5sURcZCFcuKLhOFs8mLAAEAt4UWAAIABAAAAAB4qbHo0tIjVkUU//uQZAwABfSFz3ZqQAAAAAngwAAAE1HjMp2qAAAAACZDgAAAD5UkTE1UgZEUExqYynN1qZvqIOREEFmBcJQkwdxiFtw0qEOkGYfRDifBui9MQg4QAHAqWtAWHoCxu1Yf4VfWLPIM2mHDFsbQEVGwyqQoQcwnfHeIkNt9YnkiaS1oizycqJrx4KOQjahZxWbcZgztj2c49nKmkId44S71j0c8eV9yDK6uPRzx5X18eDvjvQ6yKo9ZSS6l//8elePK/Lf//IInrOF/FvDoADYAGBMGb7FtErm5MXMlmPAJQVgWta7Zx2go+8xJ0UiCb8LHHdftWyLJE0QIAIsI+UbXu67dZMjmgDGCGl1H+vpF4NSDckSIkk7Vd+sxEhBQMRU8j/12UIRhzSaUdQ+rQU5kGeFxm+hb1oh6pWWmv3uvmReDl0UnvtapVaIzo1jZbf/pD6ElLqSX+rUmOQNpJFa/r+sa4e/pBlAABoAAAAA3CUgShLdGIxsY7AUABPRrgCABdDuQ5GC7DqPQCgbbJUAoRSUj+NIEig0YfyWUho1VBBBA//uQZB4ABZx5zfMakeAAAAmwAAAAF5F3P0w9GtAAACfAAAAAwLhMDmAYWMgVEG1U0FIGCBgXBXAtfMH10000EEEEEECUBYln03TTTdNBDZopopYvrTTdNa325mImNg3TTPV9q3pmY0xoO6bv3r00y+IDGid/9aaaZTGMuj9mpu9Mpio1dXrr5HERTZSmqU36A3CumzN/9Robv/Xx4v9ijkSRSNLQhAWumap82WRSBUqXStV/YcS+XVLnSS+WLDroqArFkMEsAS+eWmrUzrO0oEmE40RlMZ5+ODIkAyKAGUwZ3mVKmcamcJnMW26MRPgUw6j+LkhyHGVGYjSUUKNpuJUQoOIAyDvEyG8S5yfK6dhZc0Tx1KI/gviKL6qvvFs1+bWtaz58uUNnryq6kt5RzOCkPWlVqVX2a/EEBUdU1KrXLf40GoiiFXK///qpoiDXrOgqDR38JB0bw7SoL+ZB9o1RCkQjQ2CBYZKd/+VJxZRRZlqSkKiws0WFxUyCwsKiMy7hUVFhIaCrNQsKkTIsLivwKKigsj8XYlwt/WKi2N4d//uQRCSAAjURNIHpMZBGYiaQPSYyAAABLAAAAAAAACWAAAAApUF/Mg+0aohSIRobBAsMlO//Kk4soosy1JSFRYWaLC4qZBYWFRGZdwqKiwkNBVmoWFSJkWFxX4FFRQWR+LsS4W/rFRb/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////VEFHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAU291bmRib3kuZGUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMjAwNGh0dHA6Ly93d3cuc291bmRib3kuZGUAAAAAAAAAACU=");a.play()}function fetchTypeProdsFromServer(){doJsonAjaxAsync("GET","php/contenthandler.php?module=products&command=getAllTypesAndAvailProds",null,attachAndDisplayFirstRefTypes,true)}var waitProdTimer=null;function fillTypeProdList(b){var a=$("#typprodpage").data("types_prods");if(a!=undefined){displayTypesProds(b,null)}else{waitProdTimer=setInterval(function(){var c=$("#typprodpage").data("types_prods");if(c!=undefined){clearInterval(waitProdTimer);displayTypesProds(b,null)}},200)}}function fillTypeProdList_(a){displayTypesProds(a,null)}function createTxtAssignedProd(f){var b="";if(f.option!=""){b=" ("+toHtml(f.option)+")"}var c=f.longname;if(f.togo==1){c="To-Go: "+c}if(f.pricechanged==1){c+=" - "+f.price.replace(".",decpoint)+" "+currency}if(f.unit>1){var g=g_units_arr[f.unit].text;var e=f.unitamount.replace(".",decpoint);c+=" ("+e+" "+g+")"}var a="";if(f.isready=="1"){a+=" ☞"}if(f.isCooking=="1"){a+=" ♨"}if(f.isPaid=="1"){a+=" ☑"}return toHtml(c)+b+a+"
    "+createExtraParagraph(f.extras,f.extrasamounts)}function createListElOfAssignedProd(b){var a="";if("count" in b){if(b.count>1){a=b.count+"x "}}if(b.isready=="0"){return'
  • '+a+createTxtAssignedProd(b)+"
  • "}else{return'
  • '+a+createTxtAssignedProd(b)+"
  • "}}function fillAssignedProdList(b){if(b.length>0){notDeliveredProdsAvailable=true}else{notDeliveredProdsAvailable=false}$("#cancelcodefield").val("");if(cancelunpaidcode!=""){if(b.length>0){$("#cancelcodearea").show()}else{$("#cancelcodearea").hide()}}else{$("#cancelcodearea").hide()}var c=new Grouping(b,createTxtAssignedProd);c.group();var a='
  • '+W_KIT_BAR[lang]+"
  • ";a+=c.outputList(createListElOfAssignedProd);if(notDeliveredProdsAvailable){a+='
  • '+W_DEL_ALL_UNDELIVERED[lang]+"
  • "}$("#orderedprod-list-0").html(a);refreshList("#orderedprod-list-0");$("#undeliveredheader").off("click").on("click",function(f){f.stopImmediatePropagation();f.preventDefault();alert(W_UNDELIV_INFO[lang])});bindingOfAssignedProds(c);bindDelAllUndeliveredProds(b);$("#cancelcodeform").off("submit").on("submit",function(f){f.stopImmediatePropagation();f.preventDefault()})}function bindDelAllUndeliveredProds(a){$("#delallundelivered").off("click").on("click",function(b){b.stopImmediatePropagation();b.preventDefault();areYouSure("Produkte löschen.",W_DEL_ALL_ASSIGNED_PRODS[lang],W_REMOVE[lang],function(){removeAllAssignedProds(a)})})}function removeAllAssignedProds(h){var c=true;if(cancelunpaidcode!=""){if($("#cancelcodefield").val()!=cancelunpaidcode){c=false;alert(W_WRONG_PIN[lang]);return}}for(var f=0;f