$this->checkwriteaccessconfigfolder(), "configfile" => $this->checkwriteaccessconfigfile(), "customerfolder" => $this->checkwritecustomerfolder(), "speisekarte" => $this->checkwritespeisekarte() ); echo json_encode($retArray); } function checkWriteAccessNoJson() { return(array( "configfolder" => $this->checkwriteaccessconfigfolder(), "configfile" => $this->checkwriteaccessconfigfile(), "customerfolder" => $this->checkwritecustomerfolder(), "speisekarte" => $this->checkwritespeisekarte(), "privkey" => $this->checkwriteaccessprivkey(), "pubkey" => $this->checkwriteaccesspubkey() )); } } class Basedb { var $prefix = ""; var $timezone = "Europe/Berlin"; function setPrefix($pre) { $this->prefix = $pre; } function setTimeZone($zone) { $this->timezone = $zone; } function doSQL($pdo,$sql) { $stmt = $pdo->prepare($this->resolveTablenamesInSqlString($sql)); $stmt->execute(); } function doSQLcatch($pdo,$sql) { try { $stmt = $pdo->prepare($this->resolveTablenamesInSqlString($sql)); $stmt->execute(); } catch (Exception $e) { // nothing - table not present or whatever... } } function resolveTablenamesInSqlString($sqlString) { $out = str_replace("%queue%",$this->prefix . "queue",$sqlString); $out = str_replace("%products%",$this->prefix . "products",$out); $out = str_replace("%user%",$this->prefix . "user",$out); $out = str_replace("%room%",$this->prefix . "room",$out); $out = str_replace("%resttables%",$this->prefix . "resttables",$out); $out = str_replace("%tablemaps%",$this->prefix . "tablemaps",$out); $out = str_replace("%tablepos%",$this->prefix . "tablepos",$out); $out = str_replace("%bill%",$this->prefix . "bill",$out); $out = str_replace("%pricelevel%",$this->prefix . "pricelevel",$out); $out = str_replace("%config%",$this->prefix . "config",$out); $out = str_replace("%closing%",$this->prefix . "closing",$out); $out = str_replace("%printjobs%",$this->prefix . "printjob",$out); $out = str_replace("%hist%",$this->prefix . "hist",$out); $out = str_replace("%histprod%",$this->prefix . "histprod",$out); $out = str_replace("%histconfig%",$this->prefix . "histconfig",$out); $out = str_replace("%histuser%",$this->prefix . "histuser",$out); $out = str_replace("%histactions%",$this->prefix . "histactions",$out); $out = str_replace("%payment%",$this->prefix . "payment",$out); $out = str_replace("%billproducts%",$this->prefix . "billproducts",$out); $out = str_replace("%work%",$this->prefix . "work",$out); $out = str_replace("%comments%",$this->prefix . "comments",$out); $out = str_replace("%reservations%",$this->prefix . "reservations",$out); $out = str_replace("%logo%",$this->prefix . "logo",$out); $out = str_replace("%extras%",$this->prefix . "extras",$out); $out = str_replace("%extrasprods%",$this->prefix . "extrasprods", $out); $out = str_replace("%queueextras%",$this->prefix . "queueextras", $out); $out = str_replace("%ratings%",$this->prefix . "ratings", $out); return (str_replace("%prodtype%",$this->prefix . "prodtype",$out)); } function dropTables($pdo) { $this->doSQLcatch($pdo, "DROP TABLE `%comments%`"); $this->doSQLcatch($pdo, "DROP TABLE `%reservations%`"); $this->doSQLcatch($pdo, "DROP TABLE `%work%`"); $this->doSQLcatch($pdo, "DROP TABLE `%hist%`"); $this->doSQLcatch($pdo, "DROP TABLE `%histprod%`"); $this->doSQLcatch($pdo, "DROP TABLE `%histconfig%`"); $this->doSQLcatch($pdo, "DROP TABLE `%histuser%`"); $this->doSQLcatch($pdo, "DROP TABLE `%histactions%`"); $this->doSQLcatch($pdo, "drop TABLE `%queueextras%`"); $this->doSQLcatch($pdo, "drop TABLE `%extrasprods%`"); $this->doSQLcatch($pdo, "drop TABLE `%extras%`"); $this->doSQLcatch($pdo, "drop TABLE `%billproducts%`"); $this->doSQLcatch($pdo, "drop TABLE `%queue%`"); $this->doSQLcatch($pdo, "drop TABLE `%printjobs%`"); $this->doSQLcatch($pdo, "drop TABLE `%bill%`"); $this->doSQLcatch($pdo, "drop TABLE `%ratings%`"); $this->doSQLcatch($pdo, "drop TABLE `%user%`"); $this->doSQLcatch($pdo, "drop TABLE `%closing%`"); $this->doSQLcatch($pdo, "drop TABLE `%config%`"); $this->doSQLcatch($pdo, "drop TABLE `%products%`"); $this->doSQLcatch($pdo, "drop TABLE `%prodtype%`"); $this->doSQLcatch($pdo, "drop TABLE `%pricelevel%`"); $this->doSQLcatch($pdo, "drop TABLE `%tablepos%`"); $this->doSQLcatch($pdo, "drop TABLE `%tablemaps%`"); $this->doSQLcatch($pdo, "drop TABLE `%resttables%`"); $this->doSQLcatch($pdo, "drop TABLE `%room%`"); $this->doSQLcatch($pdo, "drop TABLE `%payment%`"); $this->doSQLcatch($pdo, "drop TABLE `%logo%`"); } function dropTablesNoCatch($pdo) { $this->doSQL($pdo, "DROP TABLE `%comments%`"); $this->doSQL($pdo, "DROP TABLE `%reservations%`"); $this->doSQL($pdo, "DROP TABLE `%work%`"); $this->doSQL($pdo, "DROP TABLE `%hist%`"); $this->doSQL($pdo, "DROP TABLE `%histprod%`"); $this->doSQL($pdo, "DROP TABLE `%histconfig%`"); $this->doSQL($pdo, "DROP TABLE `%histuser%`"); $this->doSQL($pdo, "DROP TABLE `%histactions%`"); $this->doSQL($pdo, "drop TABLE `%queueextras%`"); $this->doSQL($pdo, "drop TABLE `%extrasprods%`"); $this->doSQL($pdo, "drop TABLE `%extras%`"); $this->doSQL($pdo, "drop TABLE `%billproducts%`"); $this->doSQL($pdo, "drop TABLE `%queue%`"); $this->doSQL($pdo, "drop TABLE `%printjobs%`"); $this->doSQL($pdo, "drop TABLE `%bill%`"); $this->doSQL($pdo, "drop TABLE `%ratings%`"); $this->doSQL($pdo, "drop TABLE `%user%`"); $this->doSQL($pdo, "drop TABLE `%closing%`"); $this->doSQL($pdo, "drop TABLE `%config%`"); $this->doSQL($pdo, "drop TABLE `%products%`"); $this->doSQL($pdo, "drop TABLE `%prodtype%`"); $this->doSQL($pdo, "drop TABLE `%pricelevel%`"); $this->doSQL($pdo, "drop TABLE `%tablepos%`"); $this->doSQL($pdo, "drop TABLE `%tablemaps%`"); $this->doSQL($pdo, "drop TABLE `%resttables%`"); $this->doSQL($pdo, "drop TABLE `%room%`"); $this->doSQL($pdo, "drop TABLE `%payment%`"); $this->doSQL($pdo, "drop TABLE `%logo%`"); } function createPaymentTable($pdo) { $sql = " CREATE TABLE `%payment%` ( `id` INT (3) NOT NULL UNIQUE, `name` VARCHAR ( 20 ) NOT NULL, `name_en` VARCHAR ( 20 ) NOT NULL, `name_esp` VARCHAR ( 20 ) NOT NULL ) CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE = InnoDb "; $stmt = $pdo->prepare($this->resolveTablenamesInSqlString($sql)); $stmt->execute(); } function createUserTable($pdo) { $sql = " CREATE TABLE `%user%` ( `id` INT (10) NOT NULL AUTO_INCREMENT PRIMARY KEY , `username` VARCHAR ( 150 ) NOT NULL, `userpassword` VARCHAR ( 150 ) NOT NULL, `is_admin` INT (1) NOT NULL, `right_waiter` INT (1) NOT NULL, `right_kitchen` INT (1) NOT NULL, `right_bar` INT (1) NOT NULL, `right_supply` INT (1) NOT NULL, `right_paydesk` INT (1) NOT NULL, `right_statistics` INT (1) NOT NULL, `right_bill` INT (1) NOT NULL, `right_products` INT (1) NOT NULL, `right_manager` INT (1) NOT NULL, `right_reservation` INT (1) NOT NULL, `right_rating` INT (1) NOT NULL, `right_changeprice` INT (1) NOT NULL, `lastmodule` VARCHAR ( 30 ) NULL, `ordervolume` INT (2) NULL, `language` INT (2) NULL, `receiptprinter` INT (1) NULL, `roombtnsize` INT(1) NULL, `tablebtnsize` INT(1) NULL, `prodbtnsize` INT(1) NULL, `prefertablemap` INT(1) NULL, `active` INT (2) NOT NULL ) CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE = InnoDb ; "; $this->doSQL($pdo,$sql); } function createRoomTable($pdo) { $sql = " CREATE TABLE `%room%` ( `id` INT (10) NOT NULL AUTO_INCREMENT PRIMARY KEY , `roomname` VARCHAR ( 150 ) NOT NULL, `printer` INT(2) NULL, `removed` INT(2) NULL, `sorting` INT(2) NULL ) CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE = InnoDb ; "; $stmt = $pdo->prepare($this->resolveTablenamesInSqlString($sql)); $stmt->execute(); } function createTableMapsTable($pdo) { $sql = " CREATE TABLE `%tablemaps%` ( `id` INT (10) NOT NULL AUTO_INCREMENT PRIMARY KEY , `roomid` INT (10) NOT NULL, `img` MEDIUMBLOB, `sizex` INT(4) NULL, `sizey` INT(4) NULL, FOREIGN KEY (roomid) REFERENCES %room%(id) ) CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE = InnoDb ; "; $stmt = $pdo->prepare(DbUtils::substTableAlias($sql)); $stmt->execute(); } function createTablePosTable($pdo) { $sql = " CREATE TABLE `%tablepos%` ( `id` INT (10) NOT NULL AUTO_INCREMENT PRIMARY KEY , `tableid` INT (10) NOT NULL, `x` INT(4) NULL, `y` INT(4) NULL, FOREIGN KEY (tableid) REFERENCES %resttables%(id) ) CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE = InnoDb ; "; $stmt = $pdo->prepare(DbUtils::substTableAlias($sql)); $stmt->execute(); } function createRestTables($pdo) { $sql = " CREATE TABLE `%resttables%` ( `id` INT (10) NOT NULL AUTO_INCREMENT PRIMARY KEY , `tableno` VARCHAR ( 150 ) NOT NULL, `roomid` INT ( 10 ) NOT NULL, `removed` INT(2) NULL, `sorting` INT(2) NULL, FOREIGN KEY (roomid) REFERENCES %room%(id) ) CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE = InnoDb ; "; $stmt = $pdo->prepare($this->resolveTablenamesInSqlString($sql)); $stmt->execute(); } function createConfigTable($pdo) { $sql = " CREATE TABLE `%config%` ( `id` INT (10) NOT NULL AUTO_INCREMENT PRIMARY KEY , `name` VARCHAR ( 1000 ) , `setting` VARCHAR ( 10000 ) ) CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE = InnoDb ; "; $stmt = $pdo->prepare($this->resolveTablenamesInSqlString($sql)); $stmt->execute(); } function createLogoTable($pdo) { $sql = " CREATE TABLE `%logo%` ( `id` INT (2) NOT NULL AUTO_INCREMENT PRIMARY KEY , `name` VARCHAR ( 100 ) , `setting` BLOB ) CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE = InnoDb ; "; $stmt = $pdo->prepare($this->resolveTablenamesInSqlString($sql)); $stmt->execute(); } function createProdTypeTable($pdo) { $sql = " CREATE TABLE `%prodtype%` ( `id` INT (10) NOT NULL AUTO_INCREMENT PRIMARY KEY , `name` VARCHAR ( 150 ) NOT NULL, `usekitchen` INT(1) NOT NULL, `usesupplydesk` INT(1) NOT NULL, `kind` INT(2) NOT NULL, `printer` INT(2) NULL, `sorting` INT(2) NULL, `reference` INT (10) NULL, `removed` INT(1) NULL, FOREIGN KEY (reference) REFERENCES %prodtype%(id) ) CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE = InnoDb ; "; $this->doSQL($pdo,$sql); } function createExtrasTable($pdo) { $sql = " CREATE TABLE `%extras%` ( `id` INT (10) NOT NULL AUTO_INCREMENT PRIMARY KEY , `name` VARCHAR ( 150 ) NOT NULL, `price` DECIMAL (5,2) NOT NULL, `removed` INT(1) NULL ) CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE = InnoDb ; "; $this->doSQL($pdo,$sql); } function createExtrasprodsTable($pdo) { $sql = " CREATE TABLE `%extrasprods%` ( `id` INT (10) NOT NULL AUTO_INCREMENT PRIMARY KEY , `extraid` INT (10) NOT NULL, `prodid` INT (10) NOT NULL, FOREIGN KEY (extraid) REFERENCES %extras%(id), FOREIGN KEY (prodid) REFERENCES %products%(id) ) CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE = InnoDb ; "; $this->doSQL($pdo,$sql); } function createQueueExtrasTable($pdo) { $sql = " CREATE TABLE `%queueextras%` ( `id` INT (10) NOT NULL AUTO_INCREMENT PRIMARY KEY , `queueid` INT (10) NOT NULL, `extraid` INT (10) NOT NULL, `name` VARCHAR (200) NOT NULL, FOREIGN KEY (extraid) REFERENCES %extras%(id), FOREIGN KEY (queueid) REFERENCES %queue%(id) ) CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE = InnoDb ; "; $this->doSQL($pdo,$sql); } function createProductTable($pdo) { $sql = " CREATE TABLE `%products%` ( `id` INT (10) NOT NULL AUTO_INCREMENT PRIMARY KEY , `shortname` VARCHAR ( 150 ) NOT NULL, `longname` VARCHAR ( 150 ) NOT NULL, `priceA` DECIMAL (5,2) NULL, `priceB` DECIMAL (5,2) NULL, `priceC` DECIMAL (5,2) NULL, `tax` DECIMAL (5,2) NULL, `category` INT(3) NULL, `favorite` INT(1) NULL, `sorting` INT(2) NULL, `available` INT(2) NOT NULL, `audio` VARCHAR ( 150 ) NULL, `removed` INT(1) NULL, FOREIGN KEY (category) REFERENCES %prodtype%(id) ) CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE = InnoDb ; "; $this->doSQL($pdo,$sql); } function createPriceLevelTable($pdo) { $sql = " CREATE TABLE `%pricelevel%` ( `id` INT (10) NOT NULL AUTO_INCREMENT PRIMARY KEY , `name` VARCHAR ( 1000 ) , `info` VARCHAR ( 1000 ), `info_en` VARCHAR ( 1000 ) , `info_esp` VARCHAR ( 1000 ) ) CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE = InnoDb ; "; $stmt = $pdo->prepare($this->resolveTablenamesInSqlString($sql)); $stmt->execute(); } function createClosingTable($pdo) { $sql = " CREATE TABLE `%closing%` ( `id` INT (10) NOT NULL AUTO_INCREMENT PRIMARY KEY , `closingdate` DATETIME NOT NULL , `billcount` INT(5) NOT NULL , `billsum` DECIMAL (9,2) NOT NULL , `signature` VARBINARY ( 520 ) NULL, `remark` VARCHAR ( 1000 ) ) CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE = InnoDb ; "; $stmt = $pdo->prepare($this->resolveTablenamesInSqlString($sql)); $stmt->execute(); } function createRatingsTable($pdo) { $sql = " CREATE TABLE `%ratings%` ( `id` INT (10) NOT NULL AUTO_INCREMENT PRIMARY KEY , `date` DATETIME NOT NULL , `service` INT(2) NULL, `kitchen` INT(2) NULL, `remark` VARCHAR ( 200 ) NULL ) CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE = InnoDb ; "; $stmt = $pdo->prepare($this->resolveTablenamesInSqlString($sql)); $stmt->execute(); } function createBillTable($pdo) { $sql = " CREATE TABLE `%bill%` ( `id` INT (10) NOT NULL AUTO_INCREMENT PRIMARY KEY , `billdate` DATETIME NOT NULL , `brutto` DECIMAL (7,2) NULL, `netto` DECIMAL (7,2) NULL, `tableid` VARCHAR ( 150 ) NOT NULL, `closingid` INT(4) NULL, `status` VARCHAR(2) NULL, `paymentid` INT(2) NULL, `userid` INT(3) NULL, `ref` INT(10) NULL, `tax` DECIMAL (5,2) NULL, `host` INT(2) NULL, `signature` VARBINARY ( 520 ) NULL, FOREIGN KEY (closingid) REFERENCES %closing%(id), FOREIGN KEY (paymentid) REFERENCES %payment%(id), FOREIGN KEY (userid) REFERENCES %user%(id), FOREIGN KEY (ref) REFERENCES %bill%(id) ) CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE = InnoDb ; "; $stmt = $pdo->prepare($this->resolveTablenamesInSqlString($sql)); $stmt->execute(); } /* * Create the queue table: * action: P=Pay, S=Storno */ function createQueueTable($pdo) { $sql = " CREATE TABLE `%queue%` ( `id` INT( 10 ) NOT NULL AUTO_INCREMENT PRIMARY KEY , `tablenr` INT( 3 ) NULL , `productid` INT( 10 ) NULL , `pricelevel` INT( 3 ) NOT NULL , `price` DECIMAL (5,2) NOT NULL, `tax` DECIMAL (5,2) NOT NULL, `productname` VARCHAR( 150 ) NULL, `ordertime` DATETIME NULL , `orderuser` INT(10) NOT NULL , `anoption` VARCHAR( 150 ) NULL , `readytime` DATETIME NOT NULL, `delivertime` DATETIME NULL, `paidtime` DATETIME NULL, `billid` INT(10), `toremove` INT(3) NOT NULL, `cooking` INT(10) NULL, `workprinted` INT(2) NOT NULL, FOREIGN KEY (tablenr) REFERENCES %resttables%(id), FOREIGN KEY (pricelevel) REFERENCES %pricelevel%(id), FOREIGN KEY (productid) REFERENCES %products%(id), FOREIGN KEY (billid) REFERENCES %bill%(id), FOREIGN KEY (cooking) REFERENCES %user%(id), FOREIGN KEY (orderuser) REFERENCES %user%(id) ) CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE = InnoDb ; "; $this->doSQL($pdo,$sql); } function createBillProductsTable($pdo) { $sql = " CREATE TABLE `%billproducts%` ( `queueid` INT( 10 ) NOT NULL, `billid` INT(10) NOT NULL, FOREIGN KEY (queueid) REFERENCES %queue%(id), FOREIGN KEY (billid) REFERENCES %bill%(id) ) CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE = InnoDb ; "; $this->doSQL($pdo,$sql); } function createHistTables($pdo) { $sql = " CREATE TABLE `%hist%` ( `id` INT (10) NOT NULL AUTO_INCREMENT PRIMARY KEY , `date` DATETIME NOT NULL , `action` INT ( 2 ) NOT NULL, `refid` INT (10) NULL ) CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE = InnoDb "; $this->doSQL($pdo,$sql); $sql = " CREATE TABLE `%histprod%` ( `id` INT (10) NOT NULL AUTO_INCREMENT PRIMARY KEY , `prodid` INT (10) NOT NULL, `shortname` VARCHAR ( 150 ) NOT NULL, `longname` VARCHAR ( 150 ) NOT NULL, `priceA` DECIMAL (5,2) NULL, `priceB` DECIMAL (5,2) NULL, `priceC` DECIMAL (5,2) NULL, `tax` DECIMAL (5,2) NULL, `sorting` INT(2) NULL, `available` INT(2) NOT NULL, `favorite` INT(1) NULL, `audio` VARCHAR ( 150 ) NULL, `extras` VARCHAR ( 250 ) NULL, FOREIGN KEY (prodid) REFERENCES %products%(id) ) CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE = InnoDb "; $this->doSQL($pdo,$sql); $sql = " CREATE TABLE `%histconfig%` ( `id` INT (10) NOT NULL AUTO_INCREMENT PRIMARY KEY , `configid` INT (10) , `setting` VARCHAR ( 10000 ), FOREIGN KEY (configid) REFERENCES %config%(id) ) CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE = InnoDb "; $this->doSQL($pdo,$sql); $sql = " CREATE TABLE `%histuser%` ( `id` INT (10) NOT NULL AUTO_INCREMENT PRIMARY KEY , `userid` INT (10) , `username` VARCHAR ( 150 ) NOT NULL, `is_admin` INT (1) NOT NULL, `right_waiter` INT (1) NOT NULL, `right_kitchen` INT (1) NOT NULL, `right_bar` INT (1) NOT NULL, `right_supply` INT (1) NOT NULL, `right_paydesk` INT (1) NOT NULL, `right_statistics` INT (1) NOT NULL, `right_bill` INT (1) NOT NULL, `right_products` INT (1) NOT NULL, `right_manager` INT (1) NOT NULL, `right_reservation` INT (1) NOT NULL, `right_rating` INT (1) NOT NULL, `right_changeprice` INT (1) NOT NULL, `active` INT (2) NOT NULL, FOREIGN KEY (userid) REFERENCES %user%(id) ) CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE = InnoDb "; $this->doSQL($pdo,$sql); $sql = " CREATE TABLE `%histactions%` ( `id` INT (3) NOT NULL, `name` VARCHAR ( 20 ) NOT NULL, `description` VARCHAR ( 150 ) NULL ) CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE = InnoDb "; $this->doSQL($pdo,$sql); } function createPrintJobsTable($pdo) { $sql = " CREATE TABLE `%printjobs%` ( `id` INT (10) NOT NULL AUTO_INCREMENT PRIMARY KEY , `content` TEXT NOT NULL , `type` INT (2) NOT NULL , `printer` INT(2) NULL ) CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE = InnoDb ; "; $stmt = $pdo->prepare($this->resolveTablenamesInSqlString($sql)); $stmt->execute(); } function createWorkTable($pdo) { $sql = " CREATE TABLE `%work%` ( `id` INT (10) NOT NULL AUTO_INCREMENT PRIMARY KEY , `item` VARCHAR ( 20 ) NOT NULL , `value` VARCHAR ( 20 ) NOT NULL , `signature` VARBINARY(4000) NULL ) CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE = InnoDb ; "; $stmt = $pdo->prepare($this->resolveTablenamesInSqlString($sql)); $stmt->execute(); } function getPrivkey($pdo) { $sql = "SELECT signature FROM %work% WHERE item=?"; $stmt = $pdo->prepare($this->resolveTablenamesInSqlString($sql)); $stmt->execute(array("privkey")); $row = $stmt->fetchObject(); $privkey = $row->signature; return(openssl_get_privatekey($privkey)); } function signLastBillid($pdo) { $sql = "SELECT MAX(id) as maxbillid FROM %bill%"; $stmt = $pdo->prepare($this->resolveTablenamesInSqlString($sql)); $stmt->execute(); $row =$stmt->fetchObject(); if ($row != null) { $lastBillId = $row->maxbillid; } else { $lastBillId = 0; } $pkeyid = $this->getPrivkey($pdo); $lastBillId = intval($lastBillId); openssl_sign("B($lastBillId)", $signature, $pkeyid); openssl_free_key($pkeyid); $signature = base64_encode($signature); $sql = "SELECT id FROM %work% WHERE item=?"; $stmt = $pdo->prepare($this->resolveTablenamesInSqlString($sql)); $stmt->execute(array("lastbillid")); if ($stmt->rowCount() > 0) { $sql = "UPDATE %work% SET value=?, signature=? WHERE item=?"; $stmt = $pdo->prepare($this->resolveTablenamesInSqlString($sql)); $stmt->execute(array($lastBillId,$signature,"lastbillid")); } else { $sql = "INSERT INTO `%work%` (`id` , `item`,`value`,`signature`) VALUES ( NULL,?,?,?)"; $stmt = $pdo->prepare($this->resolveTablenamesInSqlString($sql)); $stmt->execute(array("lastbillid",$lastBillId,$signature)); } } function createCommentsTable($pdo) { $sql = " CREATE TABLE `%comments%` ( `id` INT( 10 ) NOT NULL AUTO_INCREMENT PRIMARY KEY , `comment` VARCHAR( 150 ) NULL , `prodid` INT (10) NULL , `sorting` INT(2) NULL, `active` INT (2) NOT NULL, FOREIGN KEY (prodid) REFERENCES %products%(id) ) CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE = InnoDb ; "; $this->doSQL($pdo,$sql); } function createReservationsTable($pdo) { $sql = " CREATE TABLE `%reservations%` ( `id` INT( 10 ) NOT NULL AUTO_INCREMENT PRIMARY KEY, `creator` INT (10) NOT NULL, `creationdate` DATETIME NOT NULL, `scheduledate` DATETIME NOT NULL, `name` VARCHAR( 100 ) NULL, `email` VARCHAR( 100 ) NULL, `starttime` INT (3) NOT NULL, `duration` INT (3) NOT NULL, `persons` INT (10) NULL, `phone` VARCHAR( 40 ) NULL, `remark` VARCHAR( 400 ) NULL, FOREIGN KEY (creator) REFERENCES %user%(id) ) CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE = InnoDb ; "; $this->doSQL($pdo,$sql); } function createEmptyTables($pdo) { $this->createPaymentTable($pdo); $this->createUserTable($pdo); $this->createRoomTable($pdo); $this->createRestTables($pdo); $this->createTableMapsTable($pdo); $this->createTablePosTable($pdo); $this->createConfigTable($pdo); $this->createProdTypeTable($pdo); $this->createProductTable($pdo); $this->createPriceLevelTable($pdo); $this->createClosingTable($pdo); $this->createRatingsTable($pdo); $this->createBillTable($pdo); $this->createQueueTable($pdo); $this->createBillProductsTable($pdo); $this->createHistTables($pdo); $this->createPrintJobsTable($pdo); $this->createWorkTable($pdo); $this->createCommentsTable($pdo); $this->createReservationsTable($pdo); $this->createLogoTable($pdo); $this->createExtrasTable($pdo); $this->createExtrasprodsTable($pdo); $this->createQueueExtrasTable($pdo); } } ?>