diff --git a/printserver/OrderSprinterPrintserver.exe b/printserver/OrderSprinterPrintserver.exe index 3aa6d3c..878381d 100644 Binary files a/printserver/OrderSprinterPrintserver.exe and b/printserver/OrderSprinterPrintserver.exe differ diff --git a/webapp/OrderSprinterPrintserver.exe b/webapp/OrderSprinterPrintserver.exe index 3aa6d3c..878381d 100644 Binary files a/webapp/OrderSprinterPrintserver.exe and b/webapp/OrderSprinterPrintserver.exe differ diff --git a/webapp/bar.html b/webapp/bar.html index f534652..2f92989 100644 --- a/webapp/bar.html +++ b/webapp/bar.html @@ -5,7 +5,7 @@ - + diff --git a/webapp/bill.html b/webapp/bill.html index bf8b07d..60bb076 100644 --- a/webapp/bill.html +++ b/webapp/bill.html @@ -5,7 +5,7 @@ - + @@ -67,6 +67,8 @@ var BILL_UPDATE = ["Aktualisieren","Update","Actualizar"]; var BILL_PRINT = ["Drucken","Print","Imprimir"]; var BILL_STORNO = ["Storno","Cancel","Contrapartida"]; var BILL_CLOSED = ["abgeschlossen","closed","cerrado"]; +var BILL_DO_HOST = ["Bewirtungsbeleg","Guest receipt","Tique de invitados"]; +var BILL_UNDO_HOST = ["Rückgängig Bewirtungsbeleg","Undo guest receipt","No tique de invitados"]; var BILL_TITLE = ["Kassenbons","Receipts","Tiques"]; var BILL_YES = ["Ja","Yes","Si"]; var BILL_NO = ["Nein","No","No"]; @@ -77,6 +79,9 @@ var BILL_NO_CANCEL_POSS = ["Der Stornovorgang ist fehlgeschlagen. Die wahrschein "Contrapartida no fue posible. Probablemente el tique esta ya cerrado."]; var BILL_DATE = ["Datum","Date","Fecha"]; var BILL_STORNO_REASON = ["Stornogrund","Reason","Razón"]; +var BILL_TOGGLE_HOST = ["Der ursprüngliche Bon wurde storniert und mit geänderter Bewirtungseigenschaft neu angelegt. Er befindet sich an erster Stelle in der Bonliste.", + "Der original receipt was discarded and recreated with the changed guest receipt property. The new receipt is on top of the list", + "El tique original esta descartado y iniciado de nuevo en la forma modificada"];; var lang = 0; @@ -151,6 +156,14 @@ function cancelBill(jsonText) { setTimeout(function(){location.reload()},1000); } +function changeHostBill(jsonText) { + if (jsonText.status != "OK") { + alert("Fehler " + jsonText.code + ": " + jsonText.msg); + return; + } + alert(BILL_TOGGLE_HOST[lang]); + setTimeout(function(){location.reload()},1000); +} function displayBillsWithContent (jsonContent) { if (jsonContent.status != "OK") { @@ -233,6 +246,19 @@ function displayBillsWithContent (jsonContent) { doAjaxCancelBill(billid,$("#stornocode").val(),$("#stornoreason").val()); }); }); + + $(".changehostbuttons").off("click").on("click", function (e) { + var billid = this.id.split("_")[1]; + var isNowHost = this.id.split("_")[2]; + $("#stornocode").val(""); + $("#stornoreason").val(""); + + var data = { + billid: billid, + isNowHost: isNowHost + }; + doAjax("POST","php/contenthandler.php?module=bill&command=changeBillHost",data,changeHostBill,"Bonänderung abgebrochen"); + }); }); } @@ -262,10 +288,16 @@ function getBillWithId(id) { var printbuttonid = 'print_' + id; var cancelbuttonid = 'cancel_' + id; + var changehostbuttonid = 'changehost_' + id + "_" + entry.host; var collapse_elem_id = 'collapse_' + id; var printbutton = '' + BILL_PRINT[lang] + ''; var cancelButton = '' + BILL_STORNO[lang] + ''; + var toggleHostTxt = BILL_DO_HOST[lang]; + if (entry.host == 1) { + toggleHostTxt = BILL_UNDO_HOST[lang]; + } + var changehostbutton = '' + toggleHostTxt + ''; var bi = entry.billcontent.billoverallinfo; var date_time = bi.billday + "." + bi.billmonth + "." + bi.billyear + " " + bi.billhour + ":" + bi.billmin; @@ -273,7 +305,7 @@ function getBillWithId(id) { var txt = '
' + printbutton; if (entry.isClosed == 0) { // REM* bill is not closed - so can be printed AND cancelled - txt += cancelButton + '
' + content + '
'; + txt += cancelButton + changehostbutton + '
' + content + ''; } else { // REM* bill is closed - only printing possible, no cancelling txt += '

' + '
' + content + '
'; diff --git a/webapp/customer/menulegend.txt b/webapp/customer/menulegend.txt index 8b2e18b..0dafdff 100755 --- a/webapp/customer/menulegend.txt +++ b/webapp/customer/menulegend.txt @@ -51,7 +51,7 @@ # !Extraname (ID:8) # 12,34 ; (45),Langname eines Produkts,(49),(50) # - Die ID-Angabe ist optional (kann weggelassen werden) # - Der Wert 12,34 ist der Aufpreis -# - Hinter dem Semikolo können Komma-getrennt Produte angegebenen werden, die +# - Hinter dem Semikolon können Komma-getrennt Produkte angegebenen werden, die # dieses Extra haben dürfen. Angabe entweder ID des Produkts in Klammern oder # der Langname eines Produkts. (Gibt es den Langnamen mehrfach, wird das Extra # auch mehrfach zugewiesen.) diff --git a/webapp/customer/speisekarte.txt b/webapp/customer/speisekarte.txt index 5a6c614..4b16936 100755 --- a/webapp/customer/speisekarte.txt +++ b/webapp/customer/speisekarte.txt @@ -33,7 +33,7 @@ # !Extraname (ID:8) # 12,34 ; (45),Langname eines Produkts,(49),(50) # - Die ID-Angabe ist optional (kann weggelassen werden) # - Der Wert 12,34 ist der Aufpreis -# - Hinter dem Semikolo können Komma-getrennt Produte angegebenen werden, die +# - Hinter dem Semikolon können Komma-getrennt Produkte angegebenen werden, die # dieses Extra haben dürfen. Angabe entweder ID des Produkts in Klammern oder # der Langname eines Produkts. (Gibt es den Langnamen mehrfach, wird das Extra # auch mehrfach zugewiesen.) diff --git a/webapp/feedback.html b/webapp/feedback.html index e00b7c7..ed99f07 100644 --- a/webapp/feedback.html +++ b/webapp/feedback.html @@ -4,7 +4,7 @@ - + diff --git a/webapp/index.html b/webapp/index.html index 6879c10..12fbee2 100644 --- a/webapp/index.html +++ b/webapp/index.html @@ -7,8 +7,8 @@ - - + + diff --git a/webapp/install.html b/webapp/install.html index 356daa6..6f53eae 100644 --- a/webapp/install.html +++ b/webapp/install.html @@ -679,7 +679,7 @@ $(document).ready(function() {   - +   diff --git a/webapp/install/installer.php b/webapp/install/installer.php index eb100f9..8570447 100644 --- a/webapp/install/installer.php +++ b/webapp/install/installer.php @@ -579,7 +579,7 @@ $stmt->execute(); $sql = "UPDATE %user% SET keeptypelevel=?"; $stmt = $pdo->prepare(DbUtils::substTableAlias($sql)); -$stmt->execute(array(1)); +$stmt->execute(array(0)); $sql = "ALTER TABLE %user% MODIFY keeptypelevel INT(1) NOT NULL"; $stmt = $pdo->prepare(DbUtils::substTableAlias($sql)); @@ -802,6 +802,36 @@ return false; } } +function updateUserTable1112_1113($prefix,$version) { +$pdo = $this->pdo; +try { +if ($version != "1.1.12") { +$ret = $this->updateUserTable1111_1112($prefix,$version); +if (!$ret) { +return false; +} +} + +$adminCl = new Admin(); +DbUtils::overrulePrefix($prefix); + +$sql = "ALTER TABLE %queue% ADD pricechanged INT(1) NULL AFTER anoption"; +$stmt = $pdo->prepare(DbUtils::substTableAlias($sql)); +$stmt->execute(); +$sql = "ALTER TABLE %queue% ADD togo INT(1) NULL AFTER pricechanged"; +$stmt = $pdo->prepare(DbUtils::substTableAlias($sql)); +$stmt->execute(); +$sql = "UPDATE %queue% SET pricechanged=?,togo=?"; +$stmt = $pdo->prepare(DbUtils::substTableAlias($sql)); +$stmt->execute(array(0,0)); + +$this->updateVersion($pdo, '1.1.13'); +return true; +} catch (PDOException $e) { +return false; +} +} + function setVersion($prefix,$theVersion) { $pdo = $this->pdo; try { @@ -873,7 +903,7 @@ $this->basedb->doSQL($pdo,"INSERT INTO `%config%` (`id` , `name`, `setting`) VAL $this->basedb->doSQL($pdo,"INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'billlanguage', $billlanguage)"); $this->basedb->doSQL($pdo,"INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'currency', '$currency')"); $this->basedb->doSQL($pdo,"INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'receiptfontsize', '12')"); -$this->basedb->doSQL($pdo,"INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'version', '1.1.12')"); +$this->basedb->doSQL($pdo,"INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'version', '1.1.13')"); $this->basedb->doSQL($pdo,"INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'paymentconfig', '0')"); $this->basedb->doSQL($pdo,"INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'remoteaccesscode', null)"); $this->basedb->doSQL($pdo,"INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'decpoint', '$decpoint')"); @@ -965,7 +995,7 @@ $pdo = $this->pdo; $userInsertSql = "INSERT INTO `%user%` (`id` , `username` , `userpassword`, `is_admin`, `right_waiter`,`right_kitchen`,`right_bar`,`right_supply`,`right_paydesk`,`right_statistics`,`right_bill`,`right_products`,`right_changeprice`,`right_manager`,`right_reservation`,`right_rating`,`language`,`prefertablemap`,`keeptypelevel`,`extrasapplybtnpos`,`active`) VALUES (NULL,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,'1','1')"; $stmt = $pdo->prepare(DbUtils::substTableAlias($userInsertSql)); -$stmt->execute(array($username,$md5adminpass,$is_admin,$right_waiter,$right_kitchen,$right_bar,$right_supply,$right_paydesk,$right_statistics,$right_bill,$right_products,$right_changeprice,$right_manager,$right_reservation,$right_rating,$lang,$prefertablemap,1)); +$stmt->execute(array($username,$md5adminpass,$is_admin,$right_waiter,$right_kitchen,$right_bar,$right_supply,$right_paydesk,$right_statistics,$right_bill,$right_products,$right_changeprice,$right_manager,$right_reservation,$right_rating,$lang,$prefertablemap,0)); $newUserIdForHist = $pdo->lastInsertId(); @@ -1246,7 +1276,7 @@ return; $supportedVersions = array("1.0.22","1.0.23","1.0.24","1.0.25","1.0.26","1.0.27","1.0.28","1.0.29", "1.0.30","1.0.31","1.0.32","1.0.33","1.0.34","1.0.35","1.0.36","1.0.37","1.0.38","1.0.39", "1.0.40","1.0.41","1.0.42","1.0.43", -"1.1.0","1.1.1","1.1.2","1.1.3","1.1.4","1.1.5","1.1.6","1.1.7","1.1.8", "1.1.9","1.1.10","1.1.11" +"1.1.0","1.1.1","1.1.2","1.1.3","1.1.4","1.1.5","1.1.6","1.1.7","1.1.8", "1.1.9","1.1.10","1.1.11","1.1.12" ); if (!in_array($version, $supportedVersions)) { @@ -1254,7 +1284,7 @@ echo json_encode("Quellversion nicht unterstützt"); return; } -$ret = $admin->updateUserTable1111_1112($_POST['prefix'], $version); +$ret = $admin->updateUserTable1112_1113($_POST['prefix'], $version); if(session_id() == '') { session_start(); diff --git a/webapp/kitchen.html b/webapp/kitchen.html index 3e668f4..eb5bc1f 100644 --- a/webapp/kitchen.html +++ b/webapp/kitchen.html @@ -5,7 +5,7 @@ - + diff --git a/webapp/manager.html b/webapp/manager.html index 0f6e1b3..a2708bf 100644 --- a/webapp/manager.html +++ b/webapp/manager.html @@ -5,7 +5,7 @@ - + diff --git a/webapp/paydesk.html b/webapp/paydesk.html index 394ce8f..d2dd84f 100644 --- a/webapp/paydesk.html +++ b/webapp/paydesk.html @@ -5,7 +5,7 @@ - + @@ -631,47 +631,15 @@ function generateListItem(theme,icon,id,content,classname) { return li; } -function addAllToUnten(jsonContent,tablename) { - $("#payall").off("click").on("click", function (e) { - e.stopImmediatePropagation(); - e.preventDefault(); - - var entryListForReceipt = []; - $("#oben li a.info-go").each(function() { - - var id_in_jsonText = $(this).attr('id'); - var entry = { - idx : id_in_jsonText, - prodid: jsonContent[id_in_jsonText]["prodid"], - queueid: jsonContent[id_in_jsonText]["id"], - longname: jsonContent[id_in_jsonText]["longname"], - price: jsonContent[id_in_jsonText]["price"], - tax: jsonContent[id_in_jsonText]["tax"], - extras: jsonContent[id_in_jsonText]["extras"], - pricelevelname: jsonContent[id_in_jsonText]["pricelevelname"] - }; - entryListForReceipt[entryListForReceipt.length] = entry; - }); - - $.each(entryListForReceipt, function (i, entry) { - addToUnten(entry.prodid,entry.longname,entry.price,entry.tax,entry.pricelevelname,entry.extras,entry.idx); - - $("#oben li .info-go").each(function() { - $(this).closest('li').remove().promise(); - }); - - refreshList("#oben"); - }); - }); - -} - function createHashOfPayableItem(aProd) { var longname = aProd["longname"]; if (aProd["pricelevelname"] != "A") { longname += " (" + aProd["pricelevelname"] + ")"; } longname += " - " + (parseFloat(aProd["price"]).toFixed(2).replace(".",decpoint)); + if (aProd["togo"] == 1) { + longname = "To-Go: " + longname; + } var extratxt = createExtraParagraph(aProd["extras"]); return toHtml(longname) + extratxt; } @@ -721,12 +689,12 @@ function clearUntenAndReceipt() { // // entry: // [0]: prodid queueid longname price pricelevelname -// REM* [2]: name, [3]: price, [4]: tax, [5] extras, [6]: pricelevel +// REM* [2]: name, [3]: price, [4]: tax, [5]: togo, [6] extras, [7]: pricelevel function addEntryOrIncreaseCount(arrayToFill,entry) { var index=0; var found = false; - var combinedIdPricelevelPriceExtras = entry.prodid + "-" + entry.extras.join("_") + entry.price + "-" + entry.pricelevelname + "#" + entry.tax; + var combinedIdPricelevelPriceExtras = entry.prodid + "-" + entry.extras.join("_") + entry.price + "-" + entry.pricelevelname + "#" + entry.tax + "_" + entry.togo; for (index=0;indexexecute(array($view,$userid)); } echo json_encode(array("status" => "OK")); + } else { + echo json_encode(array("status" => "Error","msg" => "Benutzer nicht eingeloggt")); } } @@ -1106,19 +1108,19 @@ class Admin { $right_rating = $_SESSION['right_rating']; if (!self::isOnlyRatingUser($rights, $right_rating, true)) { - if ($_SESSION['right_waiter']) { $mainMenu[] = array("name" => $waitertxt[$lang], "link" => "waiter.html?v=1.1.12"); }; - if ($_SESSION['right_kitchen']) { $mainMenu[] = array("name" => $kitchentxt[$lang], "link" => "kitchen.html?v=1.1.12"); }; - if ($_SESSION['right_bar']) { $mainMenu[] = array("name" => "Bar", "link" => "bar.html?v=1.1.12"); }; - if ($_SESSION['right_supply']) { $mainMenu[] = array("name" => $supplytxt[$lang], "link" => "supplydesk.html?v=1.1.12"); }; + if ($_SESSION['right_waiter']) { $mainMenu[] = array("name" => $waitertxt[$lang], "link" => "waiter.html?v=1.1.13"); }; + if ($_SESSION['right_kitchen']) { $mainMenu[] = array("name" => $kitchentxt[$lang], "link" => "kitchen.html?v=1.1.13"); }; + if ($_SESSION['right_bar']) { $mainMenu[] = array("name" => "Bar", "link" => "bar.html?v=1.1.13"); }; + if ($_SESSION['right_supply']) { $mainMenu[] = array("name" => $supplytxt[$lang], "link" => "supplydesk.html?v=1.1.13"); }; if ($_SESSION['right_paydesk']) { $mainMenu[] = array("name" => $paydesktxt[$lang], "link" => "paydesk.html"); }; - if ($_SESSION['right_statistics']) { $mainMenu[] = array("name" => $stattxt[$lang], "link" => "reports.html?v=1.1.12"); }; - if ($_SESSION['right_bill']) { $mainMenu[] = array("name" => $bontxt[$lang], "link" => "bill.html?v=1.1.12"); }; - if ($_SESSION['right_products']) { $mainMenu[] = array("name" => $prodtxt[$lang], "link" => "products.html?v=1.1.12"); }; - if ($_SESSION['right_reservation']) { $mainMenu[] = array("name" => $restxt[$lang], "link" => "reservation.html?v=1.1.12"); }; - if ($_SESSION['right_rating']) { $mainMenu[] = array("name" => $ratingtxt[$lang], "link" => "rating.html?v=1.1.12"); }; - if ($_SESSION['right_manager'] || $_SESSION['is_admin']) { $mainMenu[] = array("name" => $admintxt[$lang], "link" => "manager.html?v=1.1.12"); }; - $mainMenu[] = array("name" => $settingtxt[$lang], "link" => "preferences.html?v=1.1.12"); - $mainMenu[] = array("name" => "Feedback", "link" => "feedback.html?v=1.1.12"); + if ($_SESSION['right_statistics']) { $mainMenu[] = array("name" => $stattxt[$lang], "link" => "reports.html?v=1.1.13"); }; + if ($_SESSION['right_bill']) { $mainMenu[] = array("name" => $bontxt[$lang], "link" => "bill.html?v=1.1.13"); }; + if ($_SESSION['right_products']) { $mainMenu[] = array("name" => $prodtxt[$lang], "link" => "products.html?v=1.1.13"); }; + if ($_SESSION['right_reservation']) { $mainMenu[] = array("name" => $restxt[$lang], "link" => "reservation.html?v=1.1.13"); }; + if ($_SESSION['right_rating']) { $mainMenu[] = array("name" => $ratingtxt[$lang], "link" => "rating.html?v=1.1.13"); }; + if ($_SESSION['right_manager'] || $_SESSION['is_admin']) { $mainMenu[] = array("name" => $admintxt[$lang], "link" => "manager.html?v=1.1.13"); }; + $mainMenu[] = array("name" => $settingtxt[$lang], "link" => "preferences.html?v=1.1.13"); + $mainMenu[] = array("name" => "Feedback", "link" => "feedback.html?v=1.1.13"); } $mainMenu[] = array("name" => $logout[$lang], "link" => "logout.php"); @@ -1127,7 +1129,7 @@ class Admin { $waiterMessage = $this->getMessage(null, "waitermessage"); } // CAUTION: change version also in config.txt!!! - $mainMenuAndVersion = array ("version" => "OrderSprinter 1.1.12", + $mainMenuAndVersion = array ("version" => "OrderSprinter 1.1.13", "user" => $currentUser, "menu" => $mainMenu, "waitermessage" => $waiterMessage, @@ -1199,7 +1201,7 @@ class Admin { $userInsertSql = "INSERT INTO `%user%` (`id` , `username` , `userpassword`, `is_admin`, `right_waiter`,`right_kitchen`,`right_bar`,`right_supply`,`right_paydesk`,`right_statistics`,`right_bill`,`right_products`,`right_reservation`,`right_rating`,`right_changeprice`,`right_manager`,`language`,`receiptprinter`,`prefertablemap`,`keeptypelevel`,`extrasapplybtnpos`,`active`) VALUES ("; $userInsertSql .= " NULL, ?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; $stmt = $pdo->prepare(DbUtils::substTableAlias($userInsertSql)); - $stmt->execute(array($username,$password_hash,$isAdmin,$rWaiter,$rKitchen,$rBar,$rSupply,$rPayDesk,$rStat,$rBill,$rProducts,$rReservation,$rRating,$rChangeprice,$rManager,$lang,1,1,1,1,1)); + $stmt->execute(array($username,$password_hash,$isAdmin,$rWaiter,$rKitchen,$rBar,$rSupply,$rPayDesk,$rStat,$rBill,$rProducts,$rReservation,$rRating,$rChangeprice,$rManager,$lang,1,1,0,1,1)); $lastId = $pdo->lastInsertId(); diff --git a/webapp/php/bill.php b/webapp/php/bill.php index 981ab79..01c5f16 100644 --- a/webapp/php/bill.php +++ b/webapp/php/bill.php @@ -107,11 +107,22 @@ class Bill { return; } + if ($command == 'changeBillHost') { + if ($this->hasCurrentUserPaydeskRights()) { + $pdo = DbUtils::openDbAndReturnPdoStatic(); + $this->changeBillHost($pdo,$_POST['billid'],$_POST['isNowHost']); + } else { + echo json_encode(array("status" => "ERROR", "code" => ERROR_PAYDESK_NOT_AUTHOTRIZED, "msg" => ERROR_PAYDESK_NOT_AUTHOTRIZED_MSG)); + } + return; + } + if ($this->hasCurrentUserBillRights()) { if ($command == 'getLastBillsWithContent') { $this->getLastBillsWithContent($_GET['day'],$_GET['month'],$_GET['year']); } else if ($command == 'cancelBill') { - $this->cancelBill($_POST['billid'],$_POST['stornocode'],$_POST['reason']); + $pdo = DbUtils::openDbAndReturnPdoStatic(); + $this->cancelBill($pdo,$_POST['billid'],$_POST['stornocode'],$_POST['reason'],true,true,true); } } else { echo json_encode(array("status" => "ERROR", "code" => ERROR_BILL_NOT_AUTHOTRIZED, "msg" => ERROR_BILL_NOT_AUTHOTRIZED_MSG)); @@ -284,15 +295,19 @@ class Bill { } // now get all products of this bill - $sql = "select productname,price,%pricelevel%.name as pricelevelname,count(%queue%.productname) as count from %queue%,%pricelevel%,%billproducts% where %billproducts%.billid=? AND %billproducts%.queueid=%queue%.id AND %queue%.pricelevel = %pricelevel%.id group by productname,price,pricelevelname"; + $sql = "select productname,price,%pricelevel%.name as pricelevelname,togo,count(%queue%.productname) as count from %queue%,%pricelevel%,%billproducts% where %billproducts%.billid=? AND %billproducts%.queueid=%queue%.id AND %queue%.pricelevel = %pricelevel%.id group by productname,price,pricelevelname,togo"; $stmt = $pdo->prepare($this->dbutils->resolveTablenamesInSqlString($sql)); $stmt->execute(array($billid)); $result = $stmt->fetchAll(); $prodarray = array(); foreach($result as $zeile) { + $productname = $zeile['productname']; + if ($zeile["togo"] == 1) { + $productname = "To-Go: " . $productname; + } $prodarray[] = array("count" => $zeile['count'], - "productname" => $zeile['productname'], + "productname" => $productname, "pricelevel" => $zeile['pricelevelname'], "price" => $sign . $zeile['price'] ); @@ -410,7 +425,7 @@ class Bill { $commonUtils = new CommonUtils(); - $sql = "SELECT id,billdate,brutto,tableid,closingid,status FROM %bill% WHERE tableid >= '0' AND $whenClause ORDER BY billdate DESC "; + $sql = "SELECT id,billdate,brutto,tableid,closingid,status,host FROM %bill% WHERE tableid >= '0' AND $whenClause ORDER BY id DESC,billdate DESC "; $stmt = $pdo->prepare(DbUtils::substTableAlias($sql)); $stmt->execute(array($startDate,$endDate)); $result = $stmt->fetchAll(); @@ -437,7 +452,8 @@ class Bill { "brutto" => $zeile['brutto'], "tablename" => $commonUtils->getTableNameFromId($pdo,$zeile['tableid']), "billcontent" => $this->getBillWithId($pdo,$theId,$l,0), - "isClosed" => $isClosed + "isClosed" => $isClosed, + "host" => $zeile['host'] ); $resultarray[] = $arr; @@ -479,11 +495,99 @@ class Bill { } } + private function changeBillHost($pdo,$billid,$isNowHost) { + $sql = "SELECT host,closingid FROM %bill% WHERE id=?"; + $stmt = $pdo->prepare(DbUtils::substTableAlias($sql)); + $stmt->execute(array($billid)); + $row = $stmt->fetchObject(); + if ($row->host != $isNowHost) { + echo json_encode(array("status" => "ERROR", "code" => ERROR_BILL_NOT_WO_HOST, "msg" => ERROR_BILL_NOT_WO_HOST_MSG)); + return; + } + if (!is_null($row->closingid)) { + echo json_encode(array("status" => "ERROR", "code" => ERROR_BILL_ALREADY_CLOSED, "msg" => ERROR_BILL_ALREADY_CLOSED_MSG)); + return; + } + + $pdo->beginTransaction(); + + $sql = "SELECT queueid FROM %billproducts% WHERE billid=?"; + $stmt = $pdo->prepare(DbUtils::substTableAlias($sql)); + $stmt->execute(array($billid)); + $idsOfBill = $stmt->fetchAll(); + $ids = array(); + foreach($idsOfBill as $anId) { + $ids[] = $anId["queueid"]; + } + + $sql = "SELECT brutto,netto,tableid,paymentid,tax FROM %bill% WHERE id=?"; + $stmt = $pdo->prepare(DbUtils::substTableAlias($sql)); + $stmt->execute(array($billid)); + $row = $stmt->fetchObject(); + + $ok = $this->cancelBill($pdo, $billid, "", "OrderSprinter-Bewirtungseigenschaft", false, false, false); + if (!$ok) { + $pdo->rollBack(); + echo json_encode(array("status" => "ERROR", "code" => ERROR_BILL_CANCEL_IMOSSIBLE, "msg" => ERROR_BILL_CANCEL_IMOSSIBLE_MSG)); + return; + } + + $this->recreateBill($pdo, $ids, $row->brutto, $row->netto, $row->tableid, $row->paymentid, $row->tax, 1-$isNowHost); + + $pdo->commit(); + + echo json_encode(array("status" => "OK", "code" => OK)); + } + + function recreateBill($pdo,$ids_array,$brutto,$netto,$tableid,$paymentId,$tax,$host) { + + $userid = $this->getUserId(); + + // current time + date_default_timezone_set(DbUtils::getTimeZone()); + $currentTime = date('Y-m-d H:i:s'); + + $billid = (-1); + + // find highest bill id + $sql = "SELECT id from %bill% ORDER BY id DESC"; + $stmt = $pdo->prepare(DbUtils::substTableAlias($sql)); + $stmt->execute(); + $numberOfIds = $stmt->rowCount(); + $row =$stmt->fetchObject(); + $billid = intval($row->id)+1; + $commonUtils = new CommonUtils(); + $commonUtils->setLastBillIdInWorkTable($pdo, $billid); + + if (is_null($tableid)) { + $tableid = 0; + } + + // now calculate the signature for the bill entry + $signature = $commonUtils->calcSignatureForBill($pdo,$currentTime, $brutto, $netto, '0.00', $userid); + + $billInsertSql = "INSERT INTO `%bill%` (`id` , `billdate`,`brutto`,`netto`,`tableid`,`paymentid`,`userid`,`ref`,`tax`,`host`,`signature`) VALUES (?,?,?,?,?,?,?,NULL,NULL,?,?)"; + $stmt = $pdo->prepare($this->dbutils->resolveTablenamesInSqlString($billInsertSql)); + $stmt->execute(array($billid,$currentTime,$brutto,$netto,$tableid,$paymentId,$userid,$host,$signature)); + + // now declare them all to be paid: + for ($i=0;$iprepare(DbUtils::substTableAlias($updateSql)); + $stmt->execute(array($currentTime,$billid,$queueid)); + + $billProdsSql = "INSERT INTO `%billproducts%` (`queueid`,`billid`) VALUES ( ?,?)"; + $stmt = $pdo->prepare($this->dbutils->resolveTablenamesInSqlString($billProdsSql)); + $stmt->execute(array($queueid,$billid)); + } + } + /* * Cancel a bill - set all queue items to not paid and drop the bill entry */ - private function cancelBill($billid,$stornocode,$reason) { - $pdo = DbUtils::openDbAndReturnPdoStatic(); + private function cancelBill($pdo,$billid,$stornocode,$reason,$doOwnTransaction,$doEcho,$checkStornoCode) { // current time date_default_timezone_set(DbUtils::getTimeZone()); $currentTime = date('Y-m-d H:i:s'); @@ -496,25 +600,35 @@ class Bill { $numberOfVals = $row->countid; if ($numberOfVals != 1) { // stornocode not fixed - echo json_encode(array("status" => "ERROR", "code" => ERROR_BILL_NOT_STORNO_CODE, "msg" => ERROR_BILL_NOT_STORNO_CODE_MSG)); - return; + if ($doEcho) { + echo json_encode(array("status" => "ERROR", "code" => ERROR_BILL_NOT_STORNO_CODE, "msg" => ERROR_BILL_NOT_STORNO_CODE_MSG)); + } + return false; } $stornocodeInDb = $row->setting; - if ($stornocode != $stornocodeInDb) { - echo json_encode(array("status" => "ERROR", "code" => ERROR_BILL_WRONG_STORNO_CODE, "msg" => ERROR_BILL_WRONG_STORNO_CODE_MSG)); - return; + if ($checkStornoCode) { + if ($stornocode != $stornocodeInDb) { + if ($doEcho) { + echo json_encode(array("status" => "ERROR", "code" => ERROR_BILL_WRONG_STORNO_CODE, "msg" => ERROR_BILL_WRONG_STORNO_CODE_MSG)); + } + return false; + } } if (!is_numeric($billid)) { // this may be an attack... - echo json_encode(array("status" => "ERROR", "code" => ERROR_BILL_WRONG_NUMERIC_VALUE, "msg" => ERROR_BILL_WRONG_NUMERIC_VALUE_MSG)); - return; + if ($doEcho) { + echo json_encode(array("status" => "ERROR", "code" => ERROR_BILL_WRONG_NUMERIC_VALUE, "msg" => ERROR_BILL_WRONG_NUMERIC_VALUE_MSG)); + } + return false; } - // Do transactional cancel - $pdo->beginTransaction(); + // Do transactional cancel + if ($doOwnTransaction) { + $pdo->beginTransaction(); + } // is the bill already closed? In this case no cancel is allowed! $sql = "SELECT brutto,netto,tax,tableid,closingid,status,paymentid FROM %bill% WHERE id=?"; @@ -536,31 +650,42 @@ class Bill { if (!is_null($closingId) || ($status == 's') || ($status == 'x')) { // no cancel possible anymore! - $pdo->rollBack(); - if (($status == 's') || ($status == 'x')) { - echo json_encode(array("status" => "ERROR", "code" => ERROR_BILL_ALREADY_CANCELLED, "msg" => ERROR_BILL_ALREADY_CANCELLED_MSG)); - } else { - echo json_encode(array("status" => "ERROR", "code" => ERROR_BILL_ALREADY_CLOSED, "msg" => ERROR_BILL_ALREADY_CLOSED_MSG)); + if ($doOwnTransaction) { + $pdo->rollBack(); } - - return; + if ($doEcho) { + if (($status == 's') || ($status == 'x')) { + echo json_encode(array("status" => "ERROR", "code" => ERROR_BILL_ALREADY_CANCELLED, "msg" => ERROR_BILL_ALREADY_CANCELLED_MSG)); + } else { + echo json_encode(array("status" => "ERROR", "code" => ERROR_BILL_ALREADY_CLOSED, "msg" => ERROR_BILL_ALREADY_CLOSED_MSG)); + } + } + return false; } // is bill correct with signature? $commonUtils = new CommonUtils(); $correct = $commonUtils->verifyBill($pdo, $billid); if (!$correct) { - $pdo->rollBack(); - echo json_encode(array("status" => "ERROR", "code" => ERROR_INCONSISTENT_DB, "msg" => ERROR_INCONSISTENT_DB_MSG)); - return; + if ($doOwnTransaction) { + $pdo->rollBack(); + } + if ($doEcho) { + echo json_encode(array("status" => "ERROR", "code" => ERROR_INCONSISTENT_DB, "msg" => ERROR_INCONSISTENT_DB_MSG)); + } + return false; } // Test if it is allowed to insert new bill as storno bill or if manipulation has happened $nextbillid = $this->testForNewBillIdAndUpdateWorkTable($pdo); if ($nextbillid < 0) { - echo json_encode(array("status" => "ERROR", "code" => ERROR_INCONSISTENT_DB, "msg" => ERROR_INCONSISTENT_DB_MSG)); - $pdo->rollBack(); - return; + if ($doEcho) { + echo json_encode(array("status" => "ERROR", "code" => ERROR_INCONSISTENT_DB, "msg" => ERROR_INCONSISTENT_DB_MSG)); + } + if ($doOwnTransaction) { + $pdo->rollBack(); + } + return false; } // 0. find the queueitems that are related to that bill @@ -610,11 +735,15 @@ class Bill { $stmt->execute(array($aQueueid,$refIdOfStornoEntry)); } - $pdo->commit(); + if ($doOwnTransaction) { + $pdo->commit(); + } // end of transactional cancel - echo json_encode(array("status" => "OK", "code" => OK)); - return; + if ($doEcho) { + echo json_encode(array("status" => "OK", "code" => OK)); + } + return true; } private function autoBackupPdfSummary($remoteaccesscode) { @@ -780,6 +909,7 @@ class Bill { } $sql .= " AND %bill%.userid = %user%.id "; $sql .= "ORDER BY billdate"; + $stmt = $pdo->prepare(DbUtils::substTableAlias($sql)); if ($onlyClosingId == null) { diff --git a/webapp/php/globals.php b/webapp/php/globals.php index ae7781b..0205c5b 100644 --- a/webapp/php/globals.php +++ b/webapp/php/globals.php @@ -80,6 +80,11 @@ define ( 'PARSE_ERROR_MSG', 'Fehler beim Parsen'); define ( 'NUMBERFORMAT_ERROR', 27); define ( 'NUMBERFORMAT_ERROR_MSG', 'Falsches Zahlenformat'); +define ( 'ERROR_BILL_NOT_WO_HOST', '28'); +define ( 'ERROR_BILL_NOT_WO_HOST_MSG', 'Bewirtungseigenschaft falsch'); +define ( 'ERROR_BILL_CANCEL_IMOSSIBLE', '7'); +define ( 'ERROR_BILL_CANCEL_IMOSSIBLE_MSG', 'Stornierung unmöglich'); + define ( 'FOOD_PRINT_TYPE', 1); define ( 'DRINK_PRINT_TYPE', 2); define ( 'PAY_PRINT_TYPE', 3); diff --git a/webapp/php/queuecontent.php b/webapp/php/queuecontent.php index 6be8848..3ddeead 100644 --- a/webapp/php/queuecontent.php +++ b/webapp/php/queuecontent.php @@ -811,10 +811,17 @@ class QueueContent { } else { $price = $theChangedPrice; } + + // now check if the product is a togo article that might have been booked on a table + $togo = $aProd["togo"]; + $tax = $normaltax; if (is_null($theTableid)) { $tax = $togotax; } + if ($togo == 1) { + $tax = $togotax; + } if (!is_null($row->tax)) { $tax = $row->tax; } @@ -845,14 +852,14 @@ class QueueContent { $ordertime = date('Y-m-d H:i:s'); $insertSql = "INSERT INTO `%queue%` ( - `id` , `tablenr`,`productid`,`pricelevel`,`price`,`tax`,`productname`,`ordertime`,`orderuser`,`anoption`,`readytime`,`delivertime`,`paidtime`,`billid`,`toremove`,`cooking`,`workprinted`) + `id` , `tablenr`,`productid`,`pricelevel`,`price`,`tax`,`productname`,`ordertime`,`orderuser`,`anoption`,`pricechanged`,`togo`,`readytime`,`delivertime`,`paidtime`,`billid`,`toremove`,`cooking`,`workprinted`) VALUES ( - NULL , ?,?,?,?,?,?,?,?,?, '0000-00-00 00:00:00', '0000-00-00 00:00:00', NULL,NULL,'0',NULL,'0');"; + NULL , ?,?,?,?,?,?,?,?,?,?,?, '0000-00-00 00:00:00', '0000-00-00 00:00:00', NULL,NULL,'0',NULL,'0');"; - $stmt = $pdo->prepare($this->dbutils->resolveTablenamesInSqlString($insertSql)); - $stmt->execute(array($theTableid,$productid,$currentPriceLevelId,$price,$tax,$productname,$ordertime,$_SESSION['userid'],$theOption)); + $stmt = $pdo->prepare(DbUtils::substTableAlias($insertSql)); + $stmt->execute(array($theTableid,$productid,$currentPriceLevelId,$price,$tax,$productname,$ordertime,$_SESSION['userid'],$theOption,($theChangedPrice == "NO" ? 0 : 1),$togo)); $queueid = $pdo->lastInsertId(); - + if (!is_null($extras) && ($extras != "")) { for ($j=0;$jprepare(DbUtils::substTableAlias($sql)); foreach ($resultids as $anId) { $stmt->execute(array($anId)); @@ -1032,6 +1039,9 @@ class QueueContent { "id" =>$anId, "longname" => $row->productname, "option" => $row->anoption, + "pricechanged" => $row->pricechanged, + "togo" => $row->togo, + "price" => $row->price, "extras" => $extras, "isready" => $isReady, "isPaid" => $isPaid, @@ -1098,7 +1108,7 @@ class QueueContent { function getJsonProductsOfTableToPay($tableid) { $pdo = DbUtils::openDbAndReturnPdoStatic(); - $sql = "SELECT %queue%.id as id,longname,%queue%.price as price,%queue%.tax,%pricelevel%.name as pricelevelname,%products%.id as prodid + $sql = "SELECT %queue%.id as id,longname,%queue%.price as price,%queue%.tax,%pricelevel%.name as pricelevelname,%products%.id as prodid,%queue%.togo as togo FROM %queue% INNER JOIN %products% ON %queue%.productid = %products%.id INNER JOIN %pricelevel% ON %queue%.pricelevel = %pricelevel%.id "; @@ -1118,12 +1128,13 @@ class QueueContent { $theTax = $zeile['tax']; $thePriceLevelName = $zeile['pricelevelname']; $longName = $zeile['longname']; + $togo = $zeile["togo"]; $queueid = $zeile['id']; $extras = $this->getExtrasOfQueueItem($pdo,$queueid); $prodId = $zeile['prodid']; - $prodsToPay[] = array("id" => $queueid, "prodid" => $prodId, "longname" => $longName, "pricelevelname" => $thePriceLevelName, "price" => $thePrice, "tax" => $theTax, "extras" => $extras); + $prodsToPay[] = array("id" => $queueid, "prodid" => $prodId, "longname" => $longName, "pricelevelname" => $thePriceLevelName, "price" => $thePrice, "tax" => $theTax, "togo" => $togo, "extras" => $extras); } echo json_encode(array("status" => "OK", "msg" => $prodsToPay)); } diff --git a/webapp/php/utilities/basedb.php b/webapp/php/utilities/basedb.php index 4303722..565207a 100644 --- a/webapp/php/utilities/basedb.php +++ b/webapp/php/utilities/basedb.php @@ -495,6 +495,8 @@ class Basedb { `ordertime` DATETIME NULL , `orderuser` INT(10) NOT NULL , `anoption` VARCHAR( 150 ) NULL , + `pricechanged` INT(1) NULL , + `togo` INT(1) NULL , `readytime` DATETIME NOT NULL, `delivertime` DATETIME NULL, `paidtime` DATETIME NULL, diff --git a/webapp/preferences.html b/webapp/preferences.html index ddd8315..b532020 100644 --- a/webapp/preferences.html +++ b/webapp/preferences.html @@ -5,7 +5,7 @@ - + diff --git a/webapp/products.html b/webapp/products.html index 57721a9..c521416 100644 --- a/webapp/products.html +++ b/webapp/products.html @@ -7,7 +7,7 @@ - + diff --git a/webapp/rating.html b/webapp/rating.html index 55b9ade..01d10c9 100644 --- a/webapp/rating.html +++ b/webapp/rating.html @@ -7,7 +7,7 @@ - + diff --git a/webapp/receiptutils.js b/webapp/receiptutils.js index 04bb4f9..49c0015 100644 --- a/webapp/receiptutils.js +++ b/webapp/receiptutils.js @@ -92,7 +92,7 @@ function createReceiptFooterFromDbTaxes(lang, companyInfo,sum,taxes,decPoint) { return footer; } -function generateOneProdLine(count,productname,price,pricelevelname,decPoint) { +function generateOneProdLine(count,productname,price,pricelevelname,decPoint,togo) { var priceStyle = 'style="border: solid black 0px;padding: 3px;text-align:right;vertical-align:bottom;"'; var noStyle = 'style="border: solid black 0px;padding: 3px;text-align:center;vertical-align:bottom;"'; @@ -101,6 +101,10 @@ function generateOneProdLine(count,productname,price,pricelevelname,decPoint) { if (pricelevelname != "A") { productname += " (" + pricelevelname + ")"; } + if (togo == 1) { + productname = "To-Go: " + productname; + } + var totalPrice = count * price; var formattedTotal = totalPrice.toFixed(2).replace(".",decPoint); @@ -134,10 +138,10 @@ function generateProdPart(decPoint,entryListForReceipt) { var prodEntry = anEntry[1]; var productname = prodEntry.longname; var price = prodEntry.price; - var tax = prodEntry.tax; + var togo = prodEntry.togo; var pricelevelname = prodEntry.pricelevelname; - tablecontent += generateOneProdLine(count,productname,price,pricelevelname,decPoint); + tablecontent += generateOneProdLine(count,productname,price,pricelevelname,decPoint,togo); } return tablecontent; } diff --git a/webapp/reports.html b/webapp/reports.html index 804d257..2792b2c 100644 --- a/webapp/reports.html +++ b/webapp/reports.html @@ -7,7 +7,7 @@ - + diff --git a/webapp/reservation.html b/webapp/reservation.html index c68ea89..b591699 100644 --- a/webapp/reservation.html +++ b/webapp/reservation.html @@ -5,7 +5,7 @@ - + diff --git a/webapp/supplydesk.html b/webapp/supplydesk.html index f2ac6ce..c9adc25 100644 --- a/webapp/supplydesk.html +++ b/webapp/supplydesk.html @@ -5,7 +5,7 @@ - + diff --git a/webapp/waiter.html b/webapp/waiter.html index 047eaff..106d685 100644 --- a/webapp/waiter.html +++ b/webapp/waiter.html @@ -4,7 +4,7 @@ - + @@ -54,6 +54,8 @@ 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"]; @@ -81,6 +83,9 @@ var W_UNDELIVERED = ["nicht serviert (+ unbezahlt)","not served (and unpaid)","n 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 CHANGE_ALL = 0; +var CHANGE_ONE = 1 + function Grouping(set,hashFct) { // initialization during construction of class this.set = set; @@ -208,7 +213,8 @@ var groupedNewOrders = { prodids: [], extras: [], origidxs: [], - changedPrices: [] + changedPrices: [], + togos: [] }; var levelOneType = 0; // first selectedtype under 0 @@ -313,7 +319,8 @@ function setLanguage(language) { $("#actdiscount").html(discounttxt); } - $("#actionneworderconfirm").html(W_ACT_CHANGE[lang]); + $("#actionneworderconfirm_all").html(W_ACT_CHANGE_ALL[lang]); + $("#actionneworderconfirm_one").html(W_ACT_CHANGE_ONE[lang]); $("#actionnewordercancel").html(W_CANCEL[lang]); $("#select-comment").off("click").on("click", function (e) { @@ -429,8 +436,7 @@ function generateSearchResults() { e.preventDefault(); var prodid = this.id.split("_")[1]; selectedProdCount = getSearchProdCount(prodid); - $("#searchField").val(""); - generateSearchResults(); + clearSearchAndGoToHigherTypeIfExtrasOpen(); levelOneType = 0; handleClickOnProd(prodid); }); @@ -487,8 +493,7 @@ function initializeMainMenu(moduleEntries,menuid,user,version,forward) { }; $(".modulebutton").off("click").on("click", function (e) { var view = $(this).attr("href"); - doJsonAjax("POST","php/contenthandler.php?module=admin&command=setLastModuleOfUser", - { view: view}, null, "Problem Benutzerdatenpflege"); + doJsonAjaxAsync("POST","php/contenthandler.php?module=admin&command=setLastModuleOfUser",{ view: view}, null, "Problem Benutzerdatenpflege",false); }); } @@ -562,7 +567,7 @@ function hideMenuProd() { }); } -function addProductToQueueNoGuiUpdate(productid,option,extras,changedPrice) { +function addProductToQueueNoGuiUpdate(productid,option,extras,changedPrice,togo) { var prodprop = getProdProperties(productid); var prodname = prodprop.name; var prodprice = prodprop.price; @@ -572,7 +577,8 @@ function addProductToQueueNoGuiUpdate(productid,option,extras,changedPrice) { extras: extras, prodid: productid, price: prodprice, - changedPrice : changedPrice + changedPrice : changedPrice, + togo: togo }; for (var i=0;i"; } var changedPrice = groupedNewOrders.changedPrices[i]; + var togo = groupedNewOrders.togos[i]; var extrastxt = ""; var extras = groupedNewOrders.extras[i]; if ((extras != null ) && (extras != "")) { @@ -644,10 +652,18 @@ function updateNewOrdersList() { if (changedPrice != "NO") { changedPrice = changedPrice.replace(".",decpoint); - li += '
  • ' + lname + optiontext + extrastxt + ' (' + changedPrice + ')' + '
  • '; + if (togo != 0) { + li += '
  • ' + lname + optiontext + extrastxt + ' (' + changedPrice + ' - To-Go)' + '
  • '; + } else { + li += '
  • ' + lname + optiontext + extrastxt + ' (' + changedPrice + ')' + '
  • '; + } } else { - li += '
  • ' + lname + optiontext + extrastxt + '
  • '; + if (togo != 0) { + li += '
  • ' + lname + optiontext + extrastxt + ' - To-Go
  • '; + } else { + li += '
  • ' + lname + optiontext + extrastxt + '
  • '; + } } } $("#neworders").html(li); @@ -679,13 +695,15 @@ function binding_neworderelem() { extras: groupedNewOrders.extras[index], prodid: groupedNewOrders.prodids[index], origidxs: groupedNewOrders.origidxs[index], - changedPrices: groupedNewOrders.changedPrices[index] + changedPrices: groupedNewOrders.changedPrices[index], + togos: groupedNewOrders.togos[index] }; $("#actiononneworderel").data("entry",selectedEntry); $("#actiononneworderel").data("newcount",selectedEntry.count); $("#actiononneworderel").data("groupedListIndex",index); $("#act-optionfield").val(selectedEntry.option); + $("#togocheckbox").prop('checked',selectedEntry.togos == 1 ? true : false); actionSelOnNewOrderElem(); }); } @@ -807,7 +825,7 @@ $(document).on("pageinit", "#info-page", function () { function intervalFetchRoomTableInfoFromServer(seconds) { var fetchTimer = setInterval(function() { if (tableListActive) { - doJsonAjaxAsync("GET","php/contenthandler.php?module=products&command=getAllTypesAndAvailProds",null,updateTableViewIfListStillOpen); + doJsonAjaxAsync("GET","php/contenthandler.php?module=products&command=getAllTypesAndAvailProds",null,updateTableViewIfListStillOpen,true); } }, seconds * 1000); } @@ -956,6 +974,9 @@ $(document).on("pagebeforeshow", "#tables-page", function () { hideMenuTable(); checkForLogIn(); + $("#searchField").val(""); + generateSearchResults(); + $("#tableselbackbtn").off("click").on("click", function (e) { e.stopImmediatePropagation(); e.preventDefault(); @@ -1443,6 +1464,8 @@ function displayTypesProds(ref,extras) { $(this).off("click").on("click", "a", function (e) { e.stopImmediatePropagation(); e.preventDefault(); + $("#searchField").val(""); + generateSearchResults(); var theId = this.id; var idParts = theId.split("_"); if (idParts[0] == 't') { @@ -1493,31 +1516,42 @@ function displayTypesProds(ref,extras) { }); } +function getHigherType() { + var prodtypes = $("#typprodpage").data("types_prods"); + var thetypes = prodtypes.types; + var higherType = 0; + if (!extrasMenuOpen) { + for (var i=0;i'); } - var vol = parseInt($("#typprodpage").data("ordervolume")) / 10.0; + document.getElementById('audiofile').load(); document.getElementById('audiofile').volume=vol; document.getElementById('audiofile').play(); + } else { + if (vol > 0.5) { + beep(); + } } var urlProdOfTableNotDelivered = "php/contenthandler.php?module=queue&command=getJsonLongNamesOfProdsForTableNotDelivered&tableid=" + tableid; @@ -1588,8 +1627,13 @@ function addProductToNewOrdersList(prodid,extras) { refreshList("#typeproducts-list"); } +function beep() { + var snd = new Audio("data:audio/wav;base64,//uQRAAAAWMSLwUIYAAsYkXgoQwAEaYLWfkWgAI0wWs/ItAAAGDgYtAgAyN+QWaAAihwMWm4G8QQRDiMcCBcH3Cc+CDv/7xA4Tvh9Rz/y8QADBwMWgQAZG/ILNAARQ4GLTcDeIIIhxGOBAuD7hOfBB3/94gcJ3w+o5/5eIAIAAAVw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LC4qZBYWFRGZdwqKiwkNBVmoWFSJkWFxX4FFRQWR+LsS4W/rFRb/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////VEFHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAU291bmRib3kuZGUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMjAwNGh0dHA6Ly93d3cuc291bmRib3kuZGUAAAAAAAAAACU="); + snd.play(); +} + function fetchTypeProdsFromServer() { - doJsonAjaxAsync("GET","php/contenthandler.php?module=products&command=getAllTypesAndAvailProds",null,attachAndDisplayFirstRefTypes); + doJsonAjaxAsync("GET","php/contenthandler.php?module=products&command=getAllTypesAndAvailProds",null,attachAndDisplayFirstRefTypes,true); } @@ -1621,6 +1665,15 @@ function createTxtAssignedProd(p) { optiontext = " (" + toHtml(p.option) + ")"; } + var prodname = p.longname; + if (p.togo == 1) { + prodname = "To-Go: " + prodname; + } + + if (p.pricechanged == 1) { + prodname += " - " + p.price.replace(".", decpoint); + } + var status = ""; if (p.isready == '1') { status += " ☞"; @@ -1632,7 +1685,7 @@ function createTxtAssignedProd(p) { status += " ☑"; } - return toHtml(p.longname) + optiontext + status + "
    " + createExtraParagraph(p.extras); + return toHtml(prodname) + optiontext + status + "
    " + createExtraParagraph(p.extras); } @@ -1739,7 +1792,7 @@ function bindingOfAssignedProds(assignedProdsGrouping) { } function fillNotDeliveredProductsOfATable(urlProdOfTableNotDelivered) { - doJsonAjaxAsync("GET", urlProdOfTableNotDelivered, null, fillAssignedProdList); + doJsonAjaxAsync("GET", urlProdOfTableNotDelivered, null, fillAssignedProdList,true); } function fillOrderVolume(volume) { @@ -2123,7 +2176,7 @@ function bindSendNewOrdersButton() { url : url, dataType : "json", data : data, - async : false, + async : true, success : function(jsonContent) { if (functionToCallIfSuccess != null) { functionToCallIfSuccess(jsonContent); @@ -2140,13 +2193,13 @@ function bindSendNewOrdersButton() { }); } - function doJsonAjaxAsync(getOrPost, url, data, functionToCallIfSuccess) { + function doJsonAjaxAsync(getOrPost, url, data, functionToCallIfSuccess,doAsync) { $.ajax({ type : getOrPost, url : url, dataType : "json", data : data, - async : true, + async : doAsync, success : function(jsonContent) { if (functionToCallIfSuccess != null) { functionToCallIfSuccess(jsonContent); @@ -2192,7 +2245,18 @@ function bindSendNewOrdersButton() { $("#act-select-comment").html(predefinedComments); $.mobile.changePage("#actiononneworderel"); + + if (count == 1) { + $("#actionneworderconfirm_all").html(W_ACT_CHANGE[lang]); + $("#actionneworderconfirm_one").hide(); + } else { + $("#actionneworderconfirm_all").html(W_ACT_CHANGE_ALL[lang]); + $("#actionneworderconfirm_one").html(W_ACT_CHANGE_ONE[lang]); + $("#actionneworderconfirm_one").show(); + } + $('#act-select-comment').selectmenu('refresh'); + $("#togocheckbox").checkboxradio('refresh'); // start binding $("#actminusone").off("click").on( @@ -2224,14 +2288,21 @@ function bindSendNewOrdersButton() { actionSelOnNewOrderElem($("#actiononneworderel").data( "entry"), $("#actiononneworderel").data( "groupedListIndex")); - actionNewOrderConfirm(); + actionNewOrderConfirm(CHANGE_ONE); }); - $("#actionneworderconfirm").off("click").on("click", function(e) { + $("#actionneworderconfirm_all").off("click").on("click", function(e) { e.stopImmediatePropagation(); e.preventDefault(); $("#actiononneworderel").dialog("close"); - actionNewOrderConfirm(); + actionNewOrderConfirm(CHANGE_ALL); + }); + + $("#actionneworderconfirm_one").off("click").on("click", function(e) { + e.stopImmediatePropagation(); + e.preventDefault(); + $("#actiononneworderel").dialog("close"); + actionNewOrderConfirm(CHANGE_ONE); }); $("#actionnewordercancel").off("click").on("click", function(e) { @@ -2258,7 +2329,8 @@ function bindSendNewOrdersButton() { }); } - function actionNewOrderConfirm() { + + function actionNewOrderConfirm(howmany) { // which entry was modified? var groupEntry = $("#actiononneworderel").data("entry"); @@ -2266,7 +2338,7 @@ function bindSendNewOrdersButton() { var option = $("#act-optionfield").val(); if (rightchangeprice == 1) { - changedPrice = $("#act-changepricefield").val().trim(); + var changedPrice = $("#act-changepricefield").val().trim(); changedPrice = changedPrice.replace(",", "."); if (changedPrice == "") { changedPrice = "NO"; @@ -2282,11 +2354,27 @@ function bindSendNewOrdersButton() { changedPrice = "NO"; } - var allIdx = groupEntry.origidxs; - for (i = 0; i < allIdx.length; i++) { - var idx = allIdx[i]; - neworders[idx].option = option; - neworders[idx].changedPrice = changedPrice; + var togo = $("#togocheckbox").prop('checked'); + if (togo) { + togo = 1; + } else { + togo = 0; + } + + + if (howmany == CHANGE_ONE) { + var allIdx = groupEntry.origidxs; + neworders[allIdx[0]].option = option; + neworders[allIdx[0]].changedPrice = changedPrice; + neworders[allIdx[0]].togo = togo; + } else { + var allIdx = groupEntry.origidxs; + for (i = 0; i < allIdx.length; i++) { + var idx = allIdx[i]; + neworders[idx].option = option; + neworders[idx].changedPrice = changedPrice; + neworders[idx].togo = togo; + } } $("#act-optionfield").val(""); @@ -2311,11 +2399,11 @@ function bindSendNewOrdersButton() { var sampleIdx = allIdx[0]; // take for copy var prodid = neworders[sampleIdx].prodid; var changedPrice = neworders[sampleIdx].changedPrice; + var togo = neworders[sampleIdx].togo; var option = neworders[sampleIdx].option; var extras = neworders[sampleIdx].extras; for (i = 0; i < diff; i++) { - addProductToQueueNoGuiUpdate(prodid, option, extras, - changedPrice); + addProductToQueueNoGuiUpdate(prodid, option, extras,changedPrice,togo); } } @@ -2356,6 +2444,7 @@ function bindSendNewOrdersButton() { var prodids = []; var origidxs = []; var changedPrices = []; + var togos = []; var grouped = { count : counts, @@ -2366,7 +2455,8 @@ function bindSendNewOrdersButton() { extras : extras, prodids : prodids, origidxs : origidxs, - changedPrices : changedPrices + changedPrices : changedPrices, + togos : togos }; var i = 0; @@ -2377,6 +2467,7 @@ function bindSendNewOrdersButton() { var option = anEntry.option; var prodid = anEntry.prodid; var changedPrice = anEntry.changedPrice; + var togo = anEntry.togo; var extra = anEntry.extras; var extrastxt = ""; @@ -2389,8 +2480,10 @@ function bindSendNewOrdersButton() { var joinedNeedle = name + "-" + option + "-" + extrastxt; if (changedPrice != "NO") { - joinedNeedle = name + "-" + option + "-" + extrastxt - + changedPrice; + joinedNeedle = name + "-" + option + "-" + extrastxt + changedPrice; + } + if (togo == 1) { + joinedNeedle += " - To-Go"; } var index = grouped.joinedvals.indexOf(joinedNeedle); if (index >= 0) { @@ -2412,6 +2505,7 @@ function bindSendNewOrdersButton() { grouped.extras[gLength] = extrastxt; grouped.prodids[gLength] = prodid; grouped.changedPrices[gLength] = changedPrice; + grouped.togos[gLength] = togo; grouped.origidxs[gLength] = [ i ]; } } @@ -2548,6 +2642,14 @@ function bindSendNewOrdersButton() { -1 +1 + +
    +
    + + +
    +
    + x
    @@ -2557,7 +2659,8 @@ function bindSendNewOrdersButton() {

    - Ja + Ja + Ja Nein