diff --git a/printserver/OrderSprinterPrintserver.exe b/printserver/OrderSprinterPrintserver.exe index 5475577..3aa6d3c 100644 Binary files a/printserver/OrderSprinterPrintserver.exe and b/printserver/OrderSprinterPrintserver.exe differ diff --git a/scripts/Liesmich.txt b/scripts/Liesmich.txt new file mode 100644 index 0000000..3fe5a9b --- /dev/null +++ b/scripts/Liesmich.txt @@ -0,0 +1,32 @@ +Hinweise zum Inhalt dieses Verzeichnisses: + +Mit dem Backup-Skript "backup-db-linux.sh" ist es möglich, auf einem Linux-System + +- ein Backup der Datenbank +- das Kassenbuch (PDF-Zusammenfassung) vom Zeitraum des aktuellen Jahres + +auf einem USB-Stick anzulegen. Der USB-Stick wird vor dem Backup eingehängt, +und nachher wieder ausgehängt, so dass er anschließend vom Gerät abgezogen werden kann. + +Das Skript kann beispielsweise auf einem Raspberry Pi oder anderen Linux-System eingesetzt +werden. + +Das Ein- und Aushängen erfordert eigentlich Root-Berechtigungen. Entweder lässt man das Skript +als Root laufen, oder nutzt Möglichkeiten des setuid (wird hier nicht beschrieben). + +Es werden immer die letzten maximal drei Backups gespeichert bzw. aufbewahrt. + +Im Skript müssen am Anfang einige Variablen angepasst werden: +- der Gerätenamen des Sticks +- die Zugangsparameter der Datenbank (lassen sich aus der config.php) entnehmen, wenn nicht mehr bekannt. +- die Server-Baseadresse +- der Remoteaccess-Code, wie er zuvor in der Verwaltungsansicht eingestellt werden muss + +Es wird empfohlen, die Ausführung des Skripts über einen cron-Job regelmäßig und automatisisiert +zu starten: + +Um z.B. jeden Morgen um 4 Uhr eine Datensicherung zu starten, legt man den Cronjob wie folgt an: + +In der Datei /etc/crontab ans Ende folgenden Eintrag und anschließend eine Zeile freilassen: + +0 4 * * * root /usr/local/bin/backup-db-linux.sh > /dev/null 2>&1 diff --git a/scripts/backup-db-linux.sh b/scripts/backup-db-linux.sh new file mode 100755 index 0000000..2d3c318 --- /dev/null +++ b/scripts/backup-db-linux.sh @@ -0,0 +1,61 @@ +#!/bin/bash + +# Die folgenden Werte müssen je nach Installation angepasst werden: + +mount="/dev/sdc1" +database="ordersprinter" +user="Benutzer" +password="DasPasswort" +serverbase="http://localhost/ordersprinter" +remoteaccesscode="123" + +if grep -qs "$mount" /proc/mounts; then + echo "Der USB-Stick ist bereits eingehaengt" +else + echo "Der USB-Stick ist noch nicht eingehaengt." + mount "$mount" /mnt + if [ $? -eq 0 ]; then + echo "Der USB-Stick konnte eingehaengt werden." + + # Halte die letzten 3 Sicherungen der DB vor: + if [ -f /mnt/db-dump-1.json ] + then mv /mnt/db-dump-1.json /mnt/db-dump-2.json + fi + if [ -f /mnt/db-dump.json ] + then mv /mnt/db-dump.json /mnt/db-dump-1.json + fi + + # Halte die letzten 3 Sicherungen des Kassenbuchs vor + if [ -f /mnt/kassenbuch-1.pdf ] + then mv /mnt/kassenbuch-1.pdf /mnt/kassenbuch-2.pdf + fi + if [ -f /mnt/kassenbuch.pdf ] + then mv /mnt/kassenbuch.pdf /mnt/kassenbuch-1.pdf + fi + + # + # Sicherung der Datenbank über die OrderSprinter Backup-Funktion + # (das ist die bevorzugte Variante, weil die Ausgabe-Datei wieder über die Wiederherstellungsfunktion + # vom OrderSprinter eingelesen werden kann). + # + # + wget --post-data "remoteaccesscode=$remoteaccesscode" -O /mnt/db-dump.json 2>>/dev/null "$serverbase/php/contenthandler.php?module=admin&command=autobackup" + # + # + # Sicherung der Datenbank direkt über mysqldump: + # (wird diese Variante genutzt, ist das Umkopieren anzupassen, wenn mehrere Datensicherungen aufbewahrt + # werden sollen.) + # + #mysqldump --user=$user --password=$password --databases $database > /mnt/db-dump.sql + + # + # Sicherung des Kassenbuchs als PDF + wget --post-data "remoteaccesscode=$remoteaccesscode" -O /mnt/kassenbuch.pdf 2>>/dev/null "$serverbase/php/contenthandler.php?module=bill&command=autoBackupPdfSummary&lang=0" + # + + umount /mnt + echo "Das Datenbank-Backup ist erfolgt, der USB-Stick wurde wieder ausgehaengt." + else + echo "Der USB-Stick konnte nicht eingehaengt werden, das Backup ist nicht erfolgt!" + fi +fi diff --git a/webapp/OrderSprinterPrintserver.exe b/webapp/OrderSprinterPrintserver.exe index 5475577..3aa6d3c 100644 Binary files a/webapp/OrderSprinterPrintserver.exe and b/webapp/OrderSprinterPrintserver.exe differ diff --git a/webapp/bar.html b/webapp/bar.html index 7a6b615..f534652 100644 --- a/webapp/bar.html +++ b/webapp/bar.html @@ -5,7 +5,7 @@ - + diff --git a/webapp/bill.html b/webapp/bill.html index e4999fc..bf8b07d 100644 --- a/webapp/bill.html +++ b/webapp/bill.html @@ -5,7 +5,7 @@ - + diff --git a/webapp/elements/grouping.js b/webapp/elements/grouping.js new file mode 100644 index 0000000..eafe741 --- /dev/null +++ b/webapp/elements/grouping.js @@ -0,0 +1,97 @@ +function Grouping(set,hashFct) { + // initialization during construction of class + this.set = set; + + // setting by group() + this.sortedset = []; + + this.group = function() { + this.sortedset = []; + for (var i=0;i - + diff --git a/webapp/index.html b/webapp/index.html index 51512a8..6879c10 100644 --- a/webapp/index.html +++ b/webapp/index.html @@ -7,8 +7,8 @@ - - + + diff --git a/webapp/install.html b/webapp/install.html index 56deb8a..356daa6 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 ed2b864..eb100f9 100644 --- a/webapp/install/installer.php +++ b/webapp/install/installer.php @@ -778,6 +778,30 @@ $ret &= $this->setVersion($prefix, '1.1.11'); return $ret; } +function updateUserTable1111_1112($prefix,$version) { +$pdo = $this->pdo; +try { +if ($version != "1.1.11") { +$ret = $this->updateUserTable1110_1111($prefix,$version); +if (!$ret) { +return false; +} +} + +$adminCl = new Admin(); +DbUtils::overrulePrefix($prefix); + +$sql = "ALTER TABLE %room% ADD `abbreviation` VARCHAR (10) NULL AFTER roomname"; +$stmt = $pdo->prepare(DbUtils::substTableAlias($sql)); +$stmt->execute(); + +$this->updateVersion($pdo, '1.1.12'); +return true; +} catch (PDOException $e) { +return false; +} +} + function setVersion($prefix,$theVersion) { $pdo = $this->pdo; try { @@ -849,7 +873,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.11')"); +$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 , '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')"); @@ -1221,8 +1245,8 @@ 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.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.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" ); if (!in_array($version, $supportedVersions)) { @@ -1230,7 +1254,7 @@ echo json_encode("Quellversion nicht unterstützt"); return; } -$ret = $admin->updateUserTable1110_1111($_POST['prefix'], $version); +$ret = $admin->updateUserTable1111_1112($_POST['prefix'], $version); if(session_id() == '') { session_start(); diff --git a/webapp/kitchen.html b/webapp/kitchen.html index 16aac9c..3e668f4 100644 --- a/webapp/kitchen.html +++ b/webapp/kitchen.html @@ -5,7 +5,7 @@ - + diff --git a/webapp/manager.html b/webapp/manager.html index 31c7aff..0f6e1b3 100644 --- a/webapp/manager.html +++ b/webapp/manager.html @@ -5,7 +5,7 @@ - + @@ -229,6 +229,7 @@ var MAN_ROOM_PRINTER_NO = ["Kategorieeinstellung","Category setting","Configurac var MAN_ROOM_PRINTER_1 = ["Drucker 1","Printer 1","Imprimadora 1"]; var MAN_ROOM_PRINTER_2 = ["Drucker 2","Printer 2","Imprimadora 2"]; var MAN_ROOM_PRINTER_TXT = ["Arbeitsdrucker","Work printer","Imprimadora de trabajo"]; +var MAN_ROOM_ABBR_TXT = ["Kürzel","Abbr.","Abbr."]; var MAN_USERNAME = ["Benutzer","User","Usario"]; var MAN_BILLSUMALL = ["Gesamtbrutto","Total (brutto)","Todo (brutto)"]; @@ -889,17 +890,9 @@ function binding() { } else if (theId == "createdbexportxlsx") { window.location.href = "php/contenthandler.php?module=bill&command=exportXlsx&" + dateparams; } else if (theId == "createpdfexport") { - if (numberOfClosings == 0) { - alert(MAN_NO_CLOSINGS[lang]); - } else { - window.location.href = "php/contenthandler.php?module=bill&command=exportPdfReport&" + dateparams; - } + window.location.href = "php/contenthandler.php?module=bill&command=exportPdfReport&" + dateparams; } else if (theId == "createpdfsummary") { - if (numberOfClosings == 0) { - alert(MAN_NO_CLOSINGS[lang]); - } else { - window.location.href = "php/contenthandler.php?module=bill&command=exportPdfSummary&" + dateparams; - } + window.location.href = "php/contenthandler.php?module=bill&command=exportPdfSummary&" + dateparams; } }); @@ -1682,9 +1675,10 @@ function createRoomPrinterSelection(roomid,selectedPrinter) { function createEmptyRoomField(n,m) { var i=0; var text = ""; - text += ''; + text += ''; for (i=0;i'; + text += ''; - var id_in_jsonText = $(this).attr('id'); + + for (var i=0;i 0) { diff --git a/webapp/php/admin.php b/webapp/php/admin.php index 33dc53f..a548542 100644 --- a/webapp/php/admin.php +++ b/webapp/php/admin.php @@ -123,6 +123,8 @@ class Admin { $this->getPayPrintType(); } else if ($command == 'getPayments') { $this->getPayments(); + } else if ($command == 'autobackup') { + $this->backup('auto',$_POST['remoteaccesscode']); } else if (($command == 'new') || ($command == 'shutdown') || ($command == 'backup') || ($command == 'restore') || ($command == 'drop') || ($command == 'fill') || ($command == 'fillSampleProdType') || ($command == 'fillSpeisekarte') || ($command == 'assignTaxes')) { if ($this->isCurrentUserAdmin()) { if ($command == 'fill') { @@ -134,7 +136,7 @@ class Admin { } else if ($command == 'fillSpeisekarte') { $this->fillSpeisekarte($_POST['speisekarte']); } else if ($command == 'backup') { - $this->backup($_GET['type']); + $this->backup($_GET['type'],null); return; } else if ($command == 'restore') { $this->restore(); @@ -1104,19 +1106,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.11"); }; - if ($_SESSION['right_kitchen']) { $mainMenu[] = array("name" => $kitchentxt[$lang], "link" => "kitchen.html?v=1.1.11"); }; - if ($_SESSION['right_bar']) { $mainMenu[] = array("name" => "Bar", "link" => "bar.html?v=1.1.11"); }; - if ($_SESSION['right_supply']) { $mainMenu[] = array("name" => $supplytxt[$lang], "link" => "supplydesk.html?v=1.1.11"); }; + 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_paydesk']) { $mainMenu[] = array("name" => $paydesktxt[$lang], "link" => "paydesk.html"); }; - if ($_SESSION['right_statistics']) { $mainMenu[] = array("name" => $stattxt[$lang], "link" => "reports.html?v=1.1.11"); }; - if ($_SESSION['right_bill']) { $mainMenu[] = array("name" => $bontxt[$lang], "link" => "bill.html?v=1.1.11"); }; - if ($_SESSION['right_products']) { $mainMenu[] = array("name" => $prodtxt[$lang], "link" => "products.html?v=1.1.11"); }; - if ($_SESSION['right_reservation']) { $mainMenu[] = array("name" => $restxt[$lang], "link" => "reservation.html?v=1.1.11"); }; - if ($_SESSION['right_rating']) { $mainMenu[] = array("name" => $ratingtxt[$lang], "link" => "rating.html?v=1.1.11"); }; - if ($_SESSION['right_manager'] || $_SESSION['is_admin']) { $mainMenu[] = array("name" => $admintxt[$lang], "link" => "manager.html?v=1.1.11"); }; - $mainMenu[] = array("name" => $settingtxt[$lang], "link" => "preferences.html?v=1.1.11"); - $mainMenu[] = array("name" => "Feedback", "link" => "feedback.html?v=1.1.11"); + 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"); } $mainMenu[] = array("name" => $logout[$lang], "link" => "logout.php"); @@ -1125,7 +1127,7 @@ class Admin { $waiterMessage = $this->getMessage(null, "waitermessage"); } // CAUTION: change version also in config.txt!!! - $mainMenuAndVersion = array ("version" => "OrderSprinter 1.1.11", + $mainMenuAndVersion = array ("version" => "OrderSprinter 1.1.12", "user" => $currentUser, "menu" => $mainMenu, "waitermessage" => $waiterMessage, @@ -1724,13 +1726,33 @@ class Admin { "user","reservations","bill","queue","billproducts","comments","histprod","histconfig","histuser","histactions","hist","extras","extrasprods","queueextras"); } - public function backup($theType) { + public function backup($theType,$remoteaccesscode) { date_default_timezone_set(DbUtils::getTimeZone()); $nowtime = date('Y-m-d'); ini_set('memory_limit', '1000M'); - $pdo = DButils::openDbAndReturnPdoStatic(); + + if ($theType == "auto") { + $sql = "SELECT count(id) as number,setting FROM %config% WHERE name=?"; + $stmt = $pdo->prepare(DbUtils::substTableAlias($sql)); + $stmt->execute(array("remoteaccesscode")); + $row = $stmt->fetchObject(); + if ($row->number == 0) { + echo "No remote access code available - backup not allowed"; + return; + } + $code = $row->setting; + if (is_null($code) || (trim($code) == "")) { + echo "No remote access code set - backup not allowed"; + return; + } + if ($code != md5($remoteaccesscode)) { + echo "Wrong remote access code used - backup not allowed"; + return; + } + } + $pdo->beginTransaction(); $genInfo = $this->getGeneralConfigItems(false, $pdo); @@ -1801,18 +1823,24 @@ class Admin { } private function restore() { + ini_set('memory_limit', '1000M'); + set_time_limit(60*5); + if ($_FILES['userfile']['error'] != UPLOAD_ERR_OK //checks for errors && is_uploaded_file($_FILES['userfile']['tmp_name'])) { //checks that file is uploaded header("Location: ../infopage.html?e=manager.html=Kann_Datei_nicht_laden."); exit(); } - if(!file_exists($_FILES['userfile']['tmp_name']) || !is_uploaded_file($_FILES['userfile']['tmp_name'])) { - header("Location: ../infopage.html?e=manager.html=Datei_nicht_angegeben."); + if(!file_exists($_FILES['userfile']['tmp_name'])) { + header("Location: ../infopage.html?e=manager.html=Datei_existiert_nicht._Bitte_PHP-Variable_upload_max_filesize_checken."); exit(); } - ini_set('memory_limit', '1000M'); + if(!is_uploaded_file($_FILES['userfile']['tmp_name'])) { + header("Location: ../infopage.html?e=manager.html=Datei_konnte_nicht_hochgeladen_werden."); + exit(); + } $binaryFields = array("signature","img","setting","content"); @@ -1822,8 +1850,6 @@ class Admin { $basedb->setPrefix(TAB_PREFIX); $basedb->setTimeZone(DbUtils::getTimeZone()); - set_time_limit(60*5); - $pdo = DbUtils::openDbAndReturnPdoStatic(); $pdo->beginTransaction(); diff --git a/webapp/php/bill.php b/webapp/php/bill.php index 6a0f839..981ab79 100644 --- a/webapp/php/bill.php +++ b/webapp/php/bill.php @@ -54,7 +54,7 @@ class Bill { } if ($command == 'exportPdfReport') { if ($this->hasCurrentUserAdminOrManagerRights()) { - $this->exportPdfReport($_GET['lang'],$_GET['startMonth'],$_GET['startYear'],$_GET['endMonth'],$_GET['endYear']); + $this->exportPdfReport($_GET['startMonth'],$_GET['startYear'],$_GET['endMonth'],$_GET['endYear']); } else { echo "Benutzer nicht berechtigt"; } @@ -62,12 +62,16 @@ class Bill { } if ($command == 'exportPdfSummary') { if ($this->hasCurrentUserAdminOrManagerRights()) { - $this->exportPdfSummary($_GET['lang'],$_GET['startMonth'],$_GET['startYear'],$_GET['endMonth'],$_GET['endYear']); + $this->exportPdfSummary($_GET['startMonth'],$_GET['startYear'],$_GET['endMonth'],$_GET['endYear']); } else { echo "Benutzer nicht berechtigt"; } return; } + if ($command == 'autoBackupPdfSummary') { + $this->autoBackupPdfSummary($_POST['remoteaccesscode']); + return; + } if ($command == 'exportCsvOfClosing') { if ($this->hasCurrentUserAdminOrManagerRights()) { @@ -146,14 +150,26 @@ class Bill { } } + function billIsCancelled($pdo,$billid) { + $sql = "SELECT status FROM %bill% WHERE id=?"; + $stmt = $pdo->prepare(DbUtils::substTableAlias($sql)); + $stmt->execute(array($billid)); + $row = $stmt->fetchObject(); + $status = $row->status; + $ret = false; + if (($status == "x") || ($status == "s")) { + $ret = true; + } + return $ret; + } + /** * get the content of a bill (to be used for printserver etc.) * * @param unknown $billid */ - function getBillWithId($billid,$language,$printer) { + function getBillWithId($pdo,$billid,$language,$printer) { set_time_limit(120); - $pdo = $this->dbutils->openDbAndReturnPdo(); // is bill correct with signature? $commonUtils = new CommonUtils(); @@ -176,25 +192,43 @@ class Bill { $stmt->execute(array($billid)); $qrow = $stmt->fetchObject(); + $tableid = $row->tableid; if ($qrow->countid == 0) { - if ($row->tableid == 0) { + if ($tableid == 0) { // togo - $sql = "SELECT DISTINCT billdate,brutto,netto,'-' as tablename,username,host FROM %bill%,%user% WHERE %bill%.id=? AND userid=%user%.id AND tableid='0' "; + $sql = "SELECT DISTINCT billdate,brutto,netto,'-' as tablename,username,host,IFNULL(%bill%.status,'') as status FROM %bill%,%user% WHERE %bill%.id=? AND userid=%user%.id AND tableid='0' "; } else { - $sql = "SELECT DISTINCT billdate,brutto,netto,tableno as tablename,username,host FROM %bill%,%user%,%resttables% WHERE %bill%.id=? AND userid=%user%.id AND tableid=%resttables%.id "; + $sql = "SELECT DISTINCT billdate,brutto,netto,tableno as tablename,username,host,IFNULL(%bill%.status,'') as status FROM %bill%,%user%,%resttables% WHERE %bill%.id=? AND userid=%user%.id AND tableid=%resttables%.id "; } } else { - if ($row->tableid == 0) { + if ($tableid == 0) { // togo - $sql = "SELECT DISTINCT billdate,brutto,netto,'-' as tablename,username,host FROM %bill%,%user%,%queue% WHERE %bill%.id=? AND %bill%.id=%queue%.billid AND userid=%user%.id AND tableid='0' AND paidtime is not null "; + $sql = "SELECT DISTINCT billdate,brutto,netto,'-' as tablename,username,host,IFNULL(%bill%.status,'') as status FROM %bill%,%user%,%queue% WHERE %bill%.id=? AND %bill%.id=%queue%.billid AND userid=%user%.id AND tableid='0' AND paidtime is not null "; } else { - $sql = "SELECT DISTINCT billdate,brutto,netto,tableno as tablename,username,host FROM %bill%,%user%,%resttables%,%queue% WHERE %bill%.id=? AND %bill%.id=%queue%.billid AND userid=%user%.id AND tableid=%resttables%.id AND paidtime is not null "; + $sql = "SELECT DISTINCT billdate,brutto,netto,tableno as tablename,username,host,IFNULL(%bill%.status,'') as status FROM %bill%,%user%,%resttables%,%queue% WHERE %bill%.id=? AND %bill%.id=%queue%.billid AND userid=%user%.id AND tableid=%resttables%.id AND paidtime is not null "; } } $stmt = $pdo->prepare(DbUtils::substTableAlias($sql)); $stmt->execute(array($billid)); $row = $stmt->fetchObject(); + $status = $row->status; + $sign = ($status == "s" ? "-" : ""); + + if ($tableid != 0) { + $sql = "SELECT abbreviation FROM %room%,%resttables% WHERE %resttables%.id=? AND %resttables%.roomid=%room%.id"; + $stmt = $pdo->prepare(DbUtils::substTableAlias($sql)); + $stmt->execute(array($tableid)); + $trow = $stmt->fetchObject(); + if (is_null($trow->abbreviation)) { + $tablename = $row->tablename; + } else { + $tablename = $trow->abbreviation . "-" . $row->tablename; + } + } else { + $tablename = "-"; + } + if ($row == null) { // no rows found -> deliver no content echo json_encode(array("billoverallinfo" => array())); @@ -228,7 +262,7 @@ class Bill { "billmin" => $min, "brutto" => $row->brutto, "netto" => $row->netto, - "table" => $row->tablename, + "table" => $tablename, "username" => $row->username, "printer" => $printer, "host" => $host @@ -250,7 +284,7 @@ class Bill { } // now get all products of this bill - $sql = "select productname,price,%pricelevel%.name as pricelevelname,count(%queue%.productname) as count from %bill%,%queue%,%pricelevel% where %bill%.id=? and %queue%.billid=%bill%.id AND paidtime is not null AND %queue%.pricelevel = %pricelevel%.id group by productname,price,pricelevelname"; + $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"; $stmt = $pdo->prepare($this->dbutils->resolveTablenamesInSqlString($sql)); $stmt->execute(array($billid)); $result = $stmt->fetchAll(); @@ -260,16 +294,16 @@ class Bill { $prodarray[] = array("count" => $zeile['count'], "productname" => $zeile['productname'], "pricelevel" => $zeile['pricelevelname'], - "price" => $zeile['price'] + "price" => $sign . $zeile['price'] ); } - $sql = "select tax,round(sum(price) - sum(price / (1.0 + tax/100.0)),2) as mwst, round(sum(price / (1.0 + tax/100.0)),2) as netto, sum(price) as brutto FROM %queue% WHERE billid=? group by tax ORDER BY tax"; - $stmt = $pdo->prepare($this->dbutils->resolveTablenamesInSqlString($sql)); + $sql = "select tax,concat('$sign',round(sum(price) - sum(price / (1.0 + tax/100.0)),2)) as mwst, concat('$sign',round(sum(price / (1.0 + tax/100.0)),2)) as netto, concat('$sign',sum(price)) as brutto FROM %queue%,%billproducts% WHERE %billproducts%.billid=? AND %billproducts%.queueid=%queue%.id group by tax ORDER BY tax"; + $stmt = $pdo->prepare(DbUtils::substTableAlias($sql)); $stmt->execute(array($billid)); $result = $stmt->fetchAll(PDO::FETCH_OBJ); - + $out = array("billoverallinfo" => $billoverallinfo,"translations" => $billtranslations,"products" => $prodarray, "taxes" => $result); return $out; } @@ -376,7 +410,7 @@ class Bill { $commonUtils = new CommonUtils(); - $sql = "SELECT id,billdate,brutto,tableid,closingid,status FROM %bill% WHERE tableid >= '0' AND status is null AND $whenClause ORDER BY billdate DESC "; + $sql = "SELECT id,billdate,brutto,tableid,closingid,status FROM %bill% WHERE tableid >= '0' AND $whenClause ORDER BY billdate DESC "; $stmt = $pdo->prepare(DbUtils::substTableAlias($sql)); $stmt->execute(array($startDate,$endDate)); $result = $stmt->fetchAll(); @@ -393,13 +427,16 @@ class Bill { $shortdate = $date->format('H:i'); $closingID = $zeile['closingid']; $isClosed = (is_null($closingID) ? 0 : 1); + if ($this->billIsCancelled($pdo,$theId)) { + $isClosed = 1; + } $arr = array("id" => $theId, "longdate" => $zeile['billdate'], "shortdate" => $shortdate, "brutto" => $zeile['brutto'], "tablename" => $commonUtils->getTableNameFromId($pdo,$zeile['tableid']), - "billcontent" => $this->getBillWithId($theId,$l,0), + "billcontent" => $this->getBillWithId($pdo,$theId,$l,0), "isClosed" => $isClosed ); @@ -580,13 +617,50 @@ class Bill { return; } + private function autoBackupPdfSummary($remoteaccesscode) { + $pdo = DbUtils::openDbAndReturnPdoStatic(); + $sql = "SELECT count(id) as number,setting FROM %config% WHERE name=?"; + $stmt = $pdo->prepare(DbUtils::substTableAlias($sql)); + $stmt->execute(array("remoteaccesscode")); + $row = $stmt->fetchObject(); + if ($row->number == 0) { + echo "No remote access code available - backup not allowed"; + return; + } + $code = $row->setting; + if (is_null($code) || (trim($code) == "")) { + echo "No remote access code set - backup not allowed"; + return; + } + + if ($code != md5($remoteaccesscode)) { + echo "Wrong remote access code used - backup not allowed"; + return; + } + $pdo = null; + + date_default_timezone_set(DbUtils::getTimeZone()); + $currentYear = date('Y'); + $currentMonth = date('n'); + + $this->exportPdfSummary(1, $currentYear, $currentMonth, $currentYear); + } + private function exportPdfReport($startMonth,$startYear,$endMonth,$endYear) { $pdfExport = new PdfExport(); - $pdfExport->exportPdfReport($_GET['lang'],$_GET['startMonth'],$_GET['startYear'],$_GET['endMonth'],$_GET['endYear']); + $lang = 0; + if(isset($_GET["lang"])) { + $lang = $_GET['lang']; + } + $pdfExport->exportPdfReport($lang,$startMonth,$startYear,$endMonth,$endYear); } private function exportPdfSummary($startMonth,$startYear,$endMonth,$endYear) { $pdfExport = new PdfExport(); - $pdfExport->exportPdfSummary($_GET['lang'],$_GET['startMonth'],$_GET['startYear'],$_GET['endMonth'],$_GET['endYear']); + $lang = 0; + if(isset($_GET["lang"])) { + $lang = $_GET['lang']; + } + $pdfExport->exportPdfSummary($lang,$startMonth,$startYear,$endMonth,$endYear); } private function exportCsv($startMonth,$startYear,$endMonth,$endYear,$exportType) { diff --git a/webapp/php/closing.php b/webapp/php/closing.php index d57ebfc..771e4ac 100644 --- a/webapp/php/closing.php +++ b/webapp/php/closing.php @@ -501,7 +501,7 @@ $csv .= "$aBillId; \"$billdate\" ; \"" . $this->t['cashaction'][$l] . "\" ; \"$b } } else { -$sql = "SELECT DISTINCT productname,price,%queue%.tax as tax FROM %queue%,%billproducts% WHERE %billproducts%.billid=?' AND %billproducts%.queueid=%queue%.id"; +$sql = "SELECT DISTINCT productname,price,%queue%.tax as tax FROM %queue%,%billproducts% WHERE %billproducts%.billid=? AND %billproducts%.queueid=%queue%.id"; if ($status == 'x') { $statusTxt = $this->t["laterCancelled"][$l]; } else if ($status == 's') { diff --git a/webapp/php/printqueue.php b/webapp/php/printqueue.php index 1c25fc2..846aa2c 100644 --- a/webapp/php/printqueue.php +++ b/webapp/php/printqueue.php @@ -331,7 +331,7 @@ class PrintQueue { $printer = $aBill["printer"]; if (in_array($printer, $printersArr)) { - $receiptJob = array("id" => $printJobId,"bill" => $bill->getBillWithId($aBillId,$language,$printer)); + $receiptJob = array("id" => $printJobId,"bill" => $bill->getBillWithId($pdo,$aBillId,$language,$printer)); $billarray[] = $receiptJob; } } diff --git a/webapp/php/queuecontent.php b/webapp/php/queuecontent.php index 4416ccb..6be8848 100644 --- a/webapp/php/queuecontent.php +++ b/webapp/php/queuecontent.php @@ -474,12 +474,16 @@ class QueueContent { $takeAwayStr = array("Zum Mitnehmen","Take away","Para llevar"); $tablename = $takeAwayStr[$lang]; } else { - $sql = "SELECT tableno FROM %resttables% WHERE id=?"; + $sql = "SELECT tableno,%room%.abbreviation FROM %resttables%,%room% WHERE %resttables%.id=? AND %resttables%.roomid=%room%.id"; $stmt = $pdo->prepare(DbUtils::substTableAlias($sql)); $stmt->execute(array($theTableid)); $row = $stmt->fetchObject(); - $tablename = $row->tableno; + if (is_null($row->abbreviation)) { + $tablename = $row->tableno; + } else { + $tablename = $row->abbreviation . "-" . $row->tableno; + } } PrintQueue::queueWorkPrintJob($pdo, $tablename, $germanTime, $resultarray, $kind, $printer, $user); @@ -1025,7 +1029,7 @@ class QueueContent { $extras = $this->getExtrasOfQueueItem($pdo,$anId); $prodEntry = array( - "queueid" =>$anId, + "id" =>$anId, "longname" => $row->productname, "option" => $row->anoption, "extras" => $extras, @@ -1108,6 +1112,7 @@ class QueueContent { $stmt = $pdo->prepare(DbUtils::substTableAlias($sql)); $stmt->execute(); $result = $stmt->fetchAll(); + $prodsToPay = array(); foreach ($result as $zeile) { $thePrice = $zeile['price']; $theTax = $zeile['tax']; diff --git a/webapp/php/roomtables.php b/webapp/php/roomtables.php index 6fd468a..4f81ed7 100644 --- a/webapp/php/roomtables.php +++ b/webapp/php/roomtables.php @@ -275,17 +275,21 @@ class Roomtables { for ($roomindex = 0;$roomindex < $noOfRooms; $roomindex++) { $aRoom = $rooms[$roomindex]; $aRoomName = $aRoom[0]; - $roomPrinter = $aRoom[1]; + $aRoomAbbr = $aRoom[1]; + if ($aRoomAbbr == "") { + $aRoomAbbr = null; + } + $roomPrinter = $aRoom[2]; if ($roomPrinter == 0) { $roomPrinter = null; } - $sql = "INSERT INTO `%room%` (`id`, `roomname`, `printer`) VALUES (NULL,?,?)"; + $sql = "INSERT INTO `%room%` (`id`, `roomname`, `abbreviation`, `printer`) VALUES (NULL,?,?,?)"; $stmt = $pdo->prepare($this->dbutils->resolveTablenamesInSqlString($sql)); - $stmt->execute(array($aRoomName,$roomPrinter)); + $stmt->execute(array($aRoomName,$aRoomAbbr,$roomPrinter)); $roomId = $pdo->lastInsertId(); - $tablesArr = $aRoom[2]; + $tablesArr = $aRoom[3]; $noOfTables = count($tablesArr); for ($tableindex = 0; $tableindex < $noOfTables; $tableindex++) { @@ -302,7 +306,7 @@ class Roomtables { function getRoomfield() { $pdo = $this->dbutils->openDbAndReturnPdo(); - $sql = "SELECT id,roomname,IFNULL(printer,0) as printer FROM %room% WHERE removed is null ORDER BY 'sorting'"; + $sql = "SELECT id,roomname,IFNULL(abbreviation,'') as abbreviation,IFNULL(printer,0) as printer FROM %room% WHERE removed is null ORDER BY 'sorting'"; $stmt = $pdo->prepare($this->dbutils->resolveTablenamesInSqlString($sql)); $stmt->execute(); $result = $stmt->fetchAll(); @@ -315,6 +319,7 @@ class Roomtables { foreach($result as $row) { $roomid = $row['id']; $roomname = $row['roomname']; + $abbreviation = $row['abbreviation']; $printer = $row['printer']; // now get the tables of this room @@ -329,7 +334,7 @@ class Roomtables { foreach($tableresult as $aTable) { $tableArr[] = array("id" => $aTable['id'], "tablename" => $aTable['tableno']); } - $roomArr[] = array("roomid" => $roomid, "roomname" => $roomname, "printer" => $printer, "tables" => $tableArr, "noOfTables" => $numberOfTables); + $roomArr[] = array("roomid" => $roomid, "roomname" => $roomname, "abbreviation" => $abbreviation, "printer" => $printer, "tables" => $tableArr, "noOfTables" => $numberOfTables); } echo json_encode(array("status" => "OK", "noOfRooms" => $numberOfRooms, "maxTables" => $maxTables, "roomfield" => $roomArr)); diff --git a/webapp/php/utilities/basedb.php b/webapp/php/utilities/basedb.php index 2634e7b..4303722 100644 --- a/webapp/php/utilities/basedb.php +++ b/webapp/php/utilities/basedb.php @@ -243,6 +243,7 @@ class Basedb { CREATE TABLE `%room%` ( `id` INT (10) NOT NULL AUTO_INCREMENT PRIMARY KEY , `roomname` VARCHAR ( 150 ) NOT NULL, + `abbreviation` VARCHAR (10) NULL, `printer` INT(2) NULL, `removed` INT(2) NULL, `sorting` INT(2) NULL diff --git a/webapp/preferences.html b/webapp/preferences.html index 9e0b01a..ddd8315 100644 --- a/webapp/preferences.html +++ b/webapp/preferences.html @@ -5,7 +5,7 @@ - + diff --git a/webapp/products.html b/webapp/products.html index 4cb19a4..57721a9 100644 --- a/webapp/products.html +++ b/webapp/products.html @@ -7,7 +7,7 @@ - + diff --git a/webapp/rating.html b/webapp/rating.html index 637a46b..55b9ade 100644 --- a/webapp/rating.html +++ b/webapp/rating.html @@ -7,7 +7,7 @@ - + diff --git a/webapp/reports.html b/webapp/reports.html index 5445eb4..804d257 100644 --- a/webapp/reports.html +++ b/webapp/reports.html @@ -7,7 +7,7 @@ - + diff --git a/webapp/reservation.html b/webapp/reservation.html index a5d8b5a..c68ea89 100644 --- a/webapp/reservation.html +++ b/webapp/reservation.html @@ -5,7 +5,7 @@ - + diff --git a/webapp/supplydesk.html b/webapp/supplydesk.html index 2bb3f1d..f2ac6ce 100644 --- a/webapp/supplydesk.html +++ b/webapp/supplydesk.html @@ -5,7 +5,7 @@ - + diff --git a/webapp/waiter.html b/webapp/waiter.html index cc7b874..047eaff 100644 --- a/webapp/waiter.html +++ b/webapp/waiter.html @@ -4,7 +4,7 @@ - + @@ -81,6 +81,103 @@ 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!"]; +function Grouping(set,hashFct) { + // initialization during construction of class + this.set = set; + + // setting by group() + this.sortedset = []; + + this.group = function() { + this.sortedset = []; + for (var i=0;i" + createExtraParagraph(p.extras); +} -function fillNotDeliveredProductsOfATable(urlProdOfTableNotDelivered,prodListToFill) { - $.getJSON(urlProdOfTableNotDelivered,function(prodOfTable) { - - if (prodOfTable.length > 0) { - notDeliveredProdsAvailable = true; - } else { - notDeliveredProdsAvailable = false; - } - var li = "
  • " + W_KIT_BAR[lang] + "
  • "; - $.each(prodOfTable, function (i, name) { - var optiontext = ""; - if (name.option != '') { - optiontext = " (" + toHtml(name.option) + ")"; - } - if (name.isready == '0') { - li += '
  • ' + toHtml(name.longname) + optiontext + '
  • '; - } else { - li += '
  • ' + toHtml(name.longname) + optiontext + '
  • '; - } - }); - - $("#cancelcodefield").val(""); - if (cancelunpaidcode != "") { - if (prodOfTable.length > 0) { - $("#cancelcodearea").show(); - } else { - $("#cancelcodearea").hide(); - } - } else { - $("#cancelcodearea").hide(); - } - - $(prodListToFill).empty().append(li).promise().done(function () { - - $("#undeliveredheader").off("click").on("click", function (e) { - e.stopImmediatePropagation(); - e.preventDefault(); - alert(W_UNDELIV_INFO[lang]); - }); - - // now set as data the queueid - var index=0; - $(".notdelprod").each(function() { - $(this).data("queueid",prodOfTable[index].queueid); - index++; - }); - - $(this).off("click").on("click", "a", function (e) { - e.stopImmediatePropagation(); - e.preventDefault(); - - if (cancelunpaidcode != "") { - if ($("#cancelcodefield").val() != cancelunpaidcode) { - alert(W_WRONG_PIN[lang]); - return; - } - } - - var isReady = prodOfTable[this.id]["isready"]; - var isPaid = prodOfTable[this.id]["isPaid"]; - var isCooking = prodOfTable[this.id]["isCooking"]; - - if ((isPaid == "1") && (isReady=="1")) { - var dialogText = "Entfernen?"; - var this_elem = this; - areYouSure("Produkt wurde schon zubereitet und bezahlt", dialogText, "Ja", function() { - removeProductFromQueue(prodOfTable[this_elem.id]["queueid"],isPaid,isCooking,isReady); - fillNotDeliveredProductsOfATable(urlProdOfTableNotDelivered,prodListToFill); - }); - } else if (isReady=="1") { - var dialogText = "Entfernen?"; - var this_elem = this; - areYouSure("Produkt wurde schon zubereitet.", dialogText, "Ja", function() { - removeProductFromQueue(prodOfTable[this_elem.id]["queueid"],isPaid,isCooking,isReady); - fillNotDeliveredProductsOfATable(urlProdOfTableNotDelivered,prodListToFill); - }); - } else if (isPaid == "1") { - var dialogText = "Entfernen?"; - var this_elem = this; - areYouSure("Produkt wurde schon bezahlt.", dialogText, "Ja", function() { - removeProductFromQueue(prodOfTable[this_elem.id]["queueid"],isPaid,isCooking,isReady); - fillNotDeliveredProductsOfATable(urlProdOfTableNotDelivered,prodListToFill); - }); - } else if (isCooking == "1") { - var dialogText = "Entfernen?"; - var this_elem = this; - areYouSure("Produkt wird soeben zubereitet.", dialogText, "Ja", function() { - removeProductFromQueue(prodOfTable[this_elem.id]["queueid"],isPaid,isCooking,isReady); - fillNotDeliveredProductsOfATable(urlProdOfTableNotDelivered,prodListToFill); - }); - - } else { - removeProductFromQueue(prodOfTable[this.id]["queueid"],isPaid,isCooking,isReady); - fillNotDeliveredProductsOfATable(urlProdOfTableNotDelivered,prodListToFill); - } + +function createListElOfAssignedProd(aProd) { + var count = ""; + if("count" in aProd) { + if (aProd["count"] > 1) { + count = aProd["count"] + "x "; + } + } + if (aProd.isready == '0') { + return '
  • ' + count + createTxtAssignedProd(aProd) + '
  • '; + } else { + return '
  • ' + count + createTxtAssignedProd(aProd) + '
  • '; + } +} + +function fillAssignedProdList(assignedProds) { + if (assignedProds.length > 0) { + notDeliveredProdsAvailable = true; + } else { + notDeliveredProdsAvailable = false; + } + + $("#cancelcodefield").val(""); + if (cancelunpaidcode != "") { + if (assignedProds.length > 0) { + $("#cancelcodearea").show(); + } else { + $("#cancelcodearea").hide(); + } + } else { + $("#cancelcodearea").hide(); + } + + var assignedProdsGrouping = new Grouping(assignedProds,createTxtAssignedProd); + assignedProdsGrouping.group(); + + var listContent = "
  • " + W_KIT_BAR[lang] + "
  • "; + listContent += assignedProdsGrouping.outputList(createListElOfAssignedProd); + $("#orderedprod-list-0").html(listContent); + refreshList("#orderedprod-list-0"); + + $("#undeliveredheader").off("click").on("click", function (e) { + e.stopImmediatePropagation(); + e.preventDefault(); + alert(W_UNDELIV_INFO[lang]); + }); + + bindingOfAssignedProds(assignedProdsGrouping); +} + +function bindingOfAssignedProds(assignedProdsGrouping) { + $(".notdelprod").off("click").on("click", "a", function (e) { + e.stopImmediatePropagation(); + e.preventDefault(); + + if (cancelunpaidcode != "") { + if ($("#cancelcodefield").val() != cancelunpaidcode) { + alert(W_WRONG_PIN[lang]); + return; + } + } + + var listItem = $(this).closest("li"); + var rowIndex = $( "#orderedprod-list-0 li" ).index(listItem) - 1; + var rowEntries = assignedProdsGrouping.getItemsOfRow(rowIndex); + var anEntry = rowEntries[0]; + var queueid = anEntry.id; + + var isReady = anEntry.isready; + var isPaid = anEntry.isPaid; + var isCooking = anEntry.isCooking; + + if ((isPaid == "1") && (isReady=="1")) { + var dialogText = "Entfernen?"; + var this_elem = this; + areYouSure("Produkt wurde schon zubereitet und bezahlt", dialogText, "Ja", function() { + removeProductFromQueue(queueid,isPaid,isCooking,isReady); + }); + } else if (isReady=="1") { + var dialogText = "Entfernen?"; + var this_elem = this; + areYouSure("Produkt wurde schon zubereitet.", dialogText, "Ja", function() { + removeProductFromQueue(queueid,isPaid,isCooking,isReady); }); - refreshList(this); - }); - }); // ende json call + } else if (isPaid == "1") { + var dialogText = "Entfernen?"; + var this_elem = this; + areYouSure("Produkt wurde schon bezahlt.", dialogText, "Ja", function() { + removeProductFromQueue(queueid,isPaid,isCooking,isReady); + }); + } else if (isCooking == "1") { + var dialogText = "Entfernen?"; + var this_elem = this; + areYouSure("Produkt wird soeben zubereitet.", dialogText, "Ja", function() { + removeProductFromQueue(queueid,isPaid,isCooking,isReady); + }); + } else { + removeProductFromQueue(queueid,isPaid,isCooking,isReady); + } + }); + +} + +function fillNotDeliveredProductsOfATable(urlProdOfTableNotDelivered) { + doJsonAjaxAsync("GET", urlProdOfTableNotDelivered, null, fillAssignedProdList); } function fillOrderVolume(volume) { @@ -1669,11 +1788,9 @@ $(document).on("pagebeforeshow", "#typprodpage", function () { fillTypeProdList(0); // now the products that are assigned to table but yet not delivered - var urlProdOfTableNotDelivered = "php/contenthandler.php?module=queue&command=getJsonLongNamesOfProdsForTableNotDelivered&" - + "tableid=" + tableid; + var urlProdOfTableNotDelivered = "php/contenthandler.php?module=queue&command=getJsonLongNamesOfProdsForTableNotDelivered&tableid=" + tableid; - var prodListToFill = "#orderedprod-list-0"; - fillNotDeliveredProductsOfATable(urlProdOfTableNotDelivered,prodListToFill); + fillNotDeliveredProductsOfATable(urlProdOfTableNotDelivered); $("#workprint_btn").data("tableid",tableid); $("#gopaydesk_btn").data("tableid",tableid); @@ -1998,8 +2115,7 @@ function bindSendNewOrdersButton() { var urlProdOfTableNotDelivered = "php/contenthandler.php?module=queue&command=getJsonLongNamesOfProdsForTableNotDelivered&" + "tableid=" + tableid; var prodListToFill = "#orderedprod-list-0"; - fillNotDeliveredProductsOfATable(urlProdOfTableNotDelivered, - prodListToFill); + fillNotDeliveredProductsOfATable(urlProdOfTableNotDelivered); } function doJsonAjax(getOrPost, url, data, functionToCallIfSuccess, errorMsg) { $.ajax({
    ' + MAN_ROOM_LABEL[lang] + '' + MAN_ROOM_PRINTER_TXT[lang] + '' + MAN_TABLE_LABEL[lang] + '
    ' + MAN_ROOM_LABEL[lang] + '' + MAN_ROOM_ABBR_TXT[lang] + '' + MAN_ROOM_PRINTER_TXT[lang] + '' + MAN_TABLE_LABEL[lang] + '
    '; text += '' + createRoomPrinterSelection(i,0); text += tablelist(m,i); } @@ -1710,6 +1704,8 @@ function initroomfield(roomfield_json) { r_id = "#r_" + room_index.toString(); $(r_id).val(aRoom.roomname); + $("#rabbr_" + room_index).val(aRoom.abbreviation); + var noOfTables = aRoom.noOfTables; var roomPrinter = aRoom.printer; @@ -1744,6 +1740,7 @@ function roomfield_prefill() { var endNumber = startNumber + parseInt(m) - 1; $(id).val(MAN_TABLE_LABEL[lang] + " " + startNumber + "-" + endNumber); + $("#rabbr_" + i).val(''); for (j=0;j 0) { - roominfo[2] = tablesOfRoom; + roominfo[3] = tablesOfRoom; } else { continue; } diff --git a/webapp/paydesk.html b/webapp/paydesk.html index 9b5483f..394ce8f 100644 --- a/webapp/paydesk.html +++ b/webapp/paydesk.html @@ -5,7 +5,7 @@ - + @@ -16,6 +16,7 @@ + @@ -116,6 +117,18 @@ var cameFromOrdering = 0; var billbrutto = 0.0; var billnetto = 0.0; +// REM* info about items to pay and the table - after products are retrieved for table +// REM* this is the list of items, including double entries: +var prodsToPayList = []; +// REM* this is the list that is grouped of all items in the "oben" list, i.e. still not on the receipt +var prodsToPayListGrouping = []; +// REM* this is the tablename that shall appear on the receipt and on the lists +var payTable = ""; +//REM* this is the list of items, including double entries, of all entries already marked as being on the receipt +var prodsOnReceiptList = []; +// REM* this is the list that is grouped of all items in the "unten" list, i.e. on the receipt +var prodsOnReceiptListGrouping = []; + function getGeneralConfigItems() { doAjax("GET", "php/contenthandler.php?module=admin&command=getGeneralConfigItems", null, insertGeneralConfigItems, "Fehler Konfigurationsdaten"); } @@ -516,7 +529,7 @@ function getProdsToPayForTable(tableid,tablename) { $("#info-page").data("tableprods",msg); bindPayButton(msg,tableid,tablename); - displayProdsToPayForTable(msg,tablename); + initiatePayableView(msg,tablename); } else { alert("Fehler: " + msg); } @@ -527,32 +540,94 @@ function getProdsToPayForTable(tableid,tablename) { }); } -function displayProdsToPayForTable(jsonContent,tablename) { + +function initiatePayableView(jsonContent,tablename) { $('#tableinreceipt').html(tablename + '
     '); clearUntenAndReceipt(); createAllEntriesInReceipt(); calcSum(); + prodsToPayList = jsonContent; + payTable = tablename; + displayProdsToPayForTable(); +} + +function displayProdsToPayForTable() { + // REM* first group the items + prodsToPayListGrouping = new Grouping(prodsToPayList,createHashOfPayableItem); + prodsToPayListGrouping.group(); + var size = getProdSizeClass(); - $("#oben").empty().promise().done(function () { - var li = '
  • ' + P_NOT_PAID[lang] + tablename + '
  • '; // init a list - $("#oben").empty().append(li); - $("#oben").append('
  • ' + P_ALL[lang] + '
  • '); - $.each(jsonContent, function (index,aProd) { - // var queueid = jsonContent[this.id]["id"]; - addToOben(aProd["prodid"],toHtml(aProd["longname"]),aProd["price"],aProd["tax"],aProd["pricelevelname"],aProd["extras"],index); - }); - }); + + var txt = '
  • ' + P_NOT_PAID[lang] + payTable + '
  • '; // init a list + txt += '
  • ' + P_ALL[lang] + '
  • '; + + var listContent = txt + prodsToPayListGrouping.outputList(createPayableItemListElement); + $("#oben").html(listContent); refreshList("#oben"); - addAllToUnten(jsonContent,tablename); + $(".payable").off("click").on("click", function (e) { + e.stopImmediatePropagation(); + e.preventDefault(); + // REM* get rowIndex of item + var listItem = $(this).closest("li"); + var rowIndex = $( "#oben li" ).index(listItem) - 2; + // REM* get an item from the payableList + var removedEntry = prodsToPayListGrouping.popSortedEntry(rowIndex); + prodsOnReceiptList[prodsOnReceiptList.length] = removedEntry; + displayProdsToPayForTable(); + displayProdsOnReceipt(); + }); + + $("#payall").off("click").on("click", function (e) { + e.stopImmediatePropagation(); + e.preventDefault(); + for (var i=0;i0,00 ' + currency + '

    '; + + var listContent = txt + prodsOnReceiptListGrouping.outputList(createOnReceiptItemListElement); + $("#unten").html(listContent); + refreshList("#unten"); + + createAllEntriesInReceipt(); + + $(".onreceipt").off("click").on("click", function (e) { + e.stopImmediatePropagation(); + e.preventDefault(); + // REM* get rowIndex of item + var listItem = $(this).closest("li"); + var rowIndex = $( "#unten li" ).index(listItem) - 1; + // REM* get an item from the payableList + var removedEntry = prodsOnReceiptListGrouping.popSortedEntry(rowIndex); + prodsToPayList[prodsToPayList.length] = removedEntry; + displayProdsToPayForTable(); + displayProdsOnReceipt(); + }); +}; + + +function generateListItem(theme,icon,id,content,classname) { var size = getProdSizeClass(); var li = '
  • '; - li += '' + content + '
  • '; + li += '' + content + ''; return li; } @@ -591,39 +666,39 @@ function addAllToUnten(jsonContent,tablename) { } - - -function addToOben(prodid,longname,price,tax,pricelevelname,extras,index) { - var jsonContent = $("#info-page").data("tableprods"); - var tablename = $("#info-page").data("tablename"); - if (pricelevelname != "A") { - longname += " (" + pricelevelname + ")"; +function createHashOfPayableItem(aProd) { + var longname = aProd["longname"]; + if (aProd["pricelevelname"] != "A") { + longname += " (" + aProd["pricelevelname"] + ")"; } - longname += " - " + (parseFloat(price).toFixed(2).replace(".",decpoint)); - - var extratxt = createExtraParagraph(extras); - - var li_item = generateListItem("c","plus",index,toHtml(longname) + extratxt); - $("#oben").append(li_item).promise().done(function () { - createAllEntriesInReceipt(); - $(this).off("click").on("click", ".info-go", function (e) { - e.stopImmediatePropagation(); - e.preventDefault(); - var prodid = jsonContent[this.id]["prodid"]; - var price = jsonContent[this.id]["price"]; - var tax = jsonContent[this.id]["tax"]; - var pricelevelname = jsonContent[this.id]["pricelevelname"]; - var longname = jsonContent[this.id]["longname"]; - var extras = jsonContent[this.id]["extras"]; - addToUnten(prodid,longname,price,tax,pricelevelname,extras,this.id); - createAllEntriesInReceipt(); - $(this).closest("li").remove(); - refreshList("#oben"); - }); - }); - refreshList("#oben"); + longname += " - " + (parseFloat(aProd["price"]).toFixed(2).replace(".",decpoint)); + var extratxt = createExtraParagraph(aProd["extras"]); + return toHtml(longname) + extratxt; } +function createPayableItemListElement(aProd) { + var count = ""; + if("count" in aProd) { + if (aProd["count"] > 1) { + count = aProd["count"] + "x "; + } + } + var li_item = generateListItem("c","plus","payable_" + aProd["id"],count + createHashOfPayableItem(aProd),"payable"); + return li_item; +} + +function createOnReceiptItemListElement(aProd) { + var count = ""; + if("count" in aProd) { + if (aProd["count"] > 1) { + count = aProd["count"] + "x "; + } + } + var li_item = generateListItem("c","plus","payable_" + aProd["id"],count + createHashOfPayableItem(aProd),"onreceipt"); + return li_item; +} + + // Make table empty... function clearUntenAndReceipt() { var untenHeader = '
  • '; @@ -639,36 +714,6 @@ function clearUntenAndReceipt() { $("#thedate").html('

     
    '); } -function addToUnten(prodid,longname,price,tax,pricelevelname,extras,index) { - var jsonContent = $("#info-page").data("tableprods"); - var tablename = $("#info-page").data("tablename"); - if (pricelevelname != "A") { - longname += " (" + pricelevelname + ")"; - } - longname += " - " + (parseFloat(price).toFixed(2).replace(".",decpoint)); - - var extratxt = createExtraParagraph(extras); - - var li_item = generateListItem("f","minus",index,toHtml(longname) + extratxt); - $("#unten").append(li_item).promise().done(function () { - createAllEntriesInReceipt(); - $(this).off("click").on("click", ".info-go", function (e) { - e.stopImmediatePropagation(); - e.preventDefault(); - var prodid = jsonContent[this.id]["prodid"]; - var price = jsonContent[this.id]["price"]; - var tax = jsonContent[this.id]["tax"]; - var extras = jsonContent[this.id]["extras"]; - var pricelevelname = jsonContent[this.id]["pricelevelname"]; - var longname = jsonContent[this.id]["longname"]; - addToOben(prodid,longname,price,tax,pricelevelname,extras,this.id); - $(this).closest("li").remove(); - createAllEntriesInReceipt(); - refreshList("#unten"); - }); - }); - refreshList("#unten"); -} // arrayToFill: // [0]: count prodid prodid-pricelevelname queueid longname price pricelevelname @@ -714,18 +759,15 @@ function listTaxes(collectionOfTaxes,decpointx) { } function listTaxesBasedOnUntenList(decpointx) { - var jsonContent = $("#info-page").data("tableprods"); - // REM* which different taxes do we have? var mytaxes = []; var count = 0; - - $("#unten li a.info-go").each(function() { - var id_in_jsonText = this.id; - var prodEl = jsonContent[id_in_jsonText]; - mytaxes.push(prodEl.tax); - }); + for (var i=0;i' + (eval(price)).toFixed(2) + '
  • ' + (eval(price)).toFixed(2) + '