$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) { return DbUtils::substTableAliasCore($sqlString, $this->prefix); } function dropTables($pdo) { $this->doSQLcatch($pdo, "DROP TABLE `%hsout%`"); $this->doSQLcatch($pdo, "DROP TABLE `%hsin%`"); $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 `%customerlog%`"); $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 `%prodimages%`"); $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 `%groupcustomer%`"); $this->doSQLcatch($pdo, "drop TABLE `%vacations%`"); $this->doSQLcatch($pdo, "drop TABLE `%groups%`"); $this->doSQLcatch($pdo, "drop TABLE `%customers%`"); $this->doSQLcatch($pdo, "drop TABLE `%logo%`"); $this->doSQLcatch($pdo, "drop TABLE `%log%`"); } function createCustomerLogTable($pdo) { $sql = " CREATE TABLE `%customerlog%` ( `id` INT (3) NOT NULL AUTO_INCREMENT PRIMARY KEY, `date` DATETIME NULL, `customerid` INT(10) NULL, `billid` INT(10) NULL, `action` INT(2) NULL, `userid` INT(3) NULL, `remark` VARCHAR ( 500 ) NULL, FOREIGN KEY (billid) REFERENCES %bill%(id), FOREIGN KEY (customerid) REFERENCES %customers%(id), FOREIGN KEY (userid) REFERENCES %user%(id) ) CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE = InnoDb "; $stmt = $pdo->prepare($this->resolveTablenamesInSqlString($sql)); $stmt->execute(); } function createLogTable($pdo) { $sql = " CREATE TABLE `%log%` ( `id` INT (3) NOT NULL AUTO_INCREMENT PRIMARY KEY, `date` DATETIME NULL, `component` VARCHAR ( 20 ) NULL, `message` VARCHAR ( 500 ) NULL ) CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE = InnoDb "; $stmt = $pdo->prepare($this->resolveTablenamesInSqlString($sql)); $stmt->execute(); } 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_closing` INT (1) NOT NULL, `right_dash` INT (1) NOT NULL, `right_reservation` INT (1) NOT NULL, `right_rating` INT (1) NOT NULL, `right_changeprice` INT (1) NOT NULL, `right_customers` INT (1) NOT NULL, `lastmodule` VARCHAR ( 30 ) NULL, `ordervolume` INT (2) NULL, `language` INT (2) NULL, `mobiletheme` INT(2) NULL, `receiptprinter` INT (1) NULL, `roombtnsize` INT(1) NULL, `tablebtnsize` INT(1) NULL, `prodbtnsize` INT(1) NULL, `prefertablemap` INT(1) NULL, `preferimgdesk` INT(1) NULL, `preferimgmobile` INT(1), `keeptypelevel` INT(1) NOT NULL, `extrasapplybtnpos` INT(1) NOT NULL, `failedlogins` VARCHAR(20) 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, `abbreviation` VARCHAR (10) 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` " . DECIMALSMALL . " NOT NULL, `sorting` INT(2) 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` " . DECIMALSMALL . " NULL, `priceB` " . DECIMALSMALL . " NULL, `priceC` " .DECIMALSMALL . " NULL, `unit` INT(2) NULL, `days` VARCHAR(20) NULL, `tax` " . DECIMALSMALL . " NULL, `taxaustria` INT(1) NULL, `amount` INT(5) NULL, `category` INT(3) NULL, `favorite` INT(1) NULL, `sorting` INT(2) NULL, `available` INT(2) NOT NULL, `audio` VARCHAR ( 150 ) NULL, `prodimageid` INT(10) NULL, `removed` INT(1) NULL, FOREIGN KEY (category) REFERENCES %prodtype%(id), FOREIGN KEY (prodimageid) REFERENCES %prodimages%(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` " . DECIMALBIG . " NOT NULL , `signature` blob 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` " . DECIMALMIDDLE . " NULL, `netto` " . DECIMALMIDDLE . " NULL, `prevbrutto` " . DECIMALBIG . " NULL, `prevnetto` " . DECIMALBIG . " 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` " . DECIMALSMALL . " NULL, `host` INT(2) NULL, `reason` VARCHAR ( 150 ) NULL, `reservationid` VARCHAR( 30 ) NULL, `guestinfo` VARCHAR( 30 ) NULL, `intguestid` INT(10) NULL, `intguestpaid` INT(2) NULL, `signature`blob 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), FOREIGN KEY (intguestid) REFERENCES %customers%(id) ) CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE = InnoDb ; "; $stmt = $pdo->prepare($this->resolveTablenamesInSqlString($sql)); $stmt->execute(); } function createCustomersTable($pdo) { $sql = " CREATE TABLE `%customers%` ( `id` INT (10) NOT NULL AUTO_INCREMENT PRIMARY KEY , `name` VARCHAR(50) NULL, `address` VARCHAR(200) NULL, `email` VARCHAR(50) NULL, `phone` VARCHAR(30) NULL, `mobil` VARCHAR(30) NULL, `www` VARCHAR(50) NULL, `hello` VARCHAR(100) NULL, `regards` VARCHAR(100) NULL, `remark` VARCHAR(500) NULL, `created` DATETIME NULL, `lastmodified` DATETIME NULL ) CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE = InnoDb ; "; $stmt = $pdo->prepare($this->resolveTablenamesInSqlString($sql)); $stmt->execute(); } function createGroupsTable($pdo) { $sql = " CREATE TABLE `%groups%` ( `id` INT (10) NOT NULL AUTO_INCREMENT PRIMARY KEY , `name` VARCHAR(50) NULL, `remark` VARCHAR(200) NULL, `created` DATETIME NULL ) CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE = InnoDb ; "; $stmt = $pdo->prepare($this->resolveTablenamesInSqlString($sql)); $stmt->execute(); } function createGroupCustomerTable($pdo) { $sql = " CREATE TABLE `%groupcustomer%` ( `id` INT (10) NOT NULL AUTO_INCREMENT PRIMARY KEY , `groupid` INT(10) NOT NULL, `customerid` INT(10) NOT NULL, FOREIGN KEY (groupid) REFERENCES %groups%(id), FOREIGN KEY (customerid) REFERENCES %customers%(id) ) CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE = InnoDb ; "; $stmt = $pdo->prepare($this->resolveTablenamesInSqlString($sql)); $stmt->execute(); } function createVacationsTable($pdo) { $sql = " CREATE TABLE `%vacations%` ( `id` INT (10) NOT NULL AUTO_INCREMENT PRIMARY KEY , `customerid` INT(10) NOT NULL, `checkin` DATE NULL, `checkout` DATE NULL, `room` VARCHAR(50) NULL, `remark` VARCHAR(200) NULL, FOREIGN KEY (customerid) REFERENCES %customers%(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` " . DECIMALSMALL . " NOT NULL, `tax` " . DECIMALSMALL . " NOT NULL, `taxaustria` INT(1) NULL, `productname` VARCHAR( 150 ) NULL, `ordertime` DATETIME NULL , `orderuser` INT(10) NOT NULL , `anoption` VARCHAR( 150 ) NULL , `pricechanged` INT(1) NULL , `togo` INT(1) NULL , `readytime` DATETIME NULL, `delivertime` DATETIME NULL, `paidtime` DATETIME NULL, `billid` INT(10), `toremove` INT(3) NOT NULL, `cooking` INT(10) NULL, `workprinted` INT(2) NOT NULL, `isclosed` INT(1) 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 createProdimagesTable($pdo) { $sql = " CREATE TABLE `%prodimages%` ( `id` INT (10) NOT NULL AUTO_INCREMENT PRIMARY KEY , `imgh` MEDIUMBLOB, `imgm` MEDIUMBLOB, `imgl` MEDIUMBLOB ) CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE = InnoDb ; "; try { $this->doSQL($pdo,$sql); } catch (Exception $ex) { // do nothing - the table may already exist (previous installation etc. } } 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` " . DECIMALSMALL . " NULL, `priceB` " . DECIMALSMALL . " NULL, `priceC` " . DECIMALSMALL . " NULL, `unit` INT(2) NULL, `days` VARCHAR(20) NULL, `tax` " . DECIMALSMALL . " NULL, `taxaustria` INT(1) NULL, `sorting` INT(2) NULL, `available` INT(2) NOT NULL, `favorite` INT(1) NULL, `audio` VARCHAR ( 150 ) NULL, `prodimageid` INT(10) NULL, `extras` VARCHAR ( 300 ) 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_closing` INT (1) NOT NULL, `right_dash` INT (1) NOT NULL, `right_reservation` INT (1) NOT NULL, `right_rating` INT (1) NOT NULL, `right_changeprice` INT (1) NOT NULL, `right_customers` 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` blob 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 createHsinTable($pdo) { $sql = " CREATE TABLE `%hsin%` ( `id` INT( 10 ) NOT NULL AUTO_INCREMENT PRIMARY KEY , `reservationid` VARCHAR( 30 ) NULL , `billid` INT(10) NULL, `date` VARCHAR( 10 ) NULL, `time` VARCHAR( 5 ) NULL, `number` INT(10) NULL, `prodid` INT(10) NULL, `prodname` VARCHAR( 100 ) NULL, `tax` VARCHAR( 50 ) NULL, `brutto` " . DECIMALSMALL . " NOT NULL, `total` " . DECIMALSMALL . " NOT NULL, `currency` VARCHAR( 5 ) NULL, `waiterid` VARCHAR( 20 ) NULL, `waitername` VARCHAR( 20 ) NULL ) CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE = InnoDb ; "; $this->doSQL($pdo,$sql); } function createHsoutTable($pdo) { $sql = " CREATE TABLE `%hsout%` ( `id` INT( 10 ) NOT NULL AUTO_INCREMENT PRIMARY KEY , `reservationid` VARCHAR( 50 ) NULL , `object` VARCHAR( 50 ) NULL , `guest` VARCHAR( 100 ) NULL ) CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE = InnoDb ; "; $this->doSQL($pdo,$sql); } 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->createLogTable($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->createProdimagesTable($pdo); $this->createProductTable($pdo); $this->createPriceLevelTable($pdo); $this->createClosingTable($pdo); $this->createRatingsTable($pdo); $this->createCustomersTable($pdo); $this->createGroupsTable($pdo); $this->createGroupCustomerTable($pdo); $this->createVacationsTable($pdo); $this->createBillTable($pdo); $this->createCustomerLogTable($pdo); $this->createQueueTable($pdo); $this->createBillProductsTable($pdo); $this->createHistTables($pdo); $this->createPrintJobsTable($pdo); $this->createWorkTable($pdo); $this->createCommentsTable($pdo); $this->createHsinTable($pdo); $this->createHsoutTable($pdo); $this->createReservationsTable($pdo); $this->createLogoTable($pdo); $this->createExtrasTable($pdo); $this->createExtrasprodsTable($pdo); $this->createQueueExtrasTable($pdo); } } ?>