updateConfigInHist($pdo, $item, $value); } public static function execSql($pdo,$sql) { $stmt = $pdo->prepare(DbUtils::substTableAlias($sql)); $stmt->execute(); } public static function execSqlWithParam($pdo,$sql,$param) { $stmt = $pdo->prepare(DbUtils::substTableAlias($sql)); $stmt->execute($param); } public static function insertIntRow($pdo,$table,$rowToInsert,$afterRow) { self::insertTypeRow($pdo, $table, $rowToInsert, $afterRow, 'INT(1) NULL'); } public static function insertTypeRow($pdo,$table,$rowToInsert,$afterRow,$type) { $sql = "SHOW COLUMNS FROM $table LIKE '$rowToInsert'"; $stmt = $pdo->prepare(DbUtils::substTableAlias($sql)); $stmt->execute(); $result = $stmt->fetchAll(); if (count($result) == 0) { $sql = "ALTER TABLE $table ADD $rowToInsert $type AFTER $afterRow"; $stmt = $pdo->prepare(DbUtils::substTableAlias($sql)); $stmt->execute(); } } public static function getDefaultCustomRecTemplate() { $rect = "l;\nt:llllllllllllllllllll; f: ; a_ID:rrrrrrrrrrr\n;f: ;d:w\n\ng:v; c:v\n\nk:rrr; s: ; m:v; s: ; n:rrrrrr; o:rrrrrrr\nf:-\n"; $rect .= "START_PRODUCTS\na:rrr; s: ; c:v; s: ; b:rrrrrr; d:rrrrrrr\nEND_PRODUCTS\n\n"; $rect .= "p:rrrrr; q:rrrrrr; r:rrrrrrrr; n:rrrrrrrr\nSTART_TAXES\nt:rrrrr; m:rrrrrr; n:rrrrrrrr; b:rrrrrrrr\nEND_TAXES\n\n"; $rect .= "f: ; E_Summe:llllllllllllllllllll;\n\nj:l;"; return $rect; } public static function getDefaultWorkTemplateFood() { $rect = "SS:Speisen\n\ni_ID:v\nt:v\nz:v\n"; $rect .= "\n"; $rect .= "START_WORK\n"; $rect .= "f:-;\n"; $rect .= "N:v;\ns: ;b:v;\n"; $rect .= "e:v\n"; $rect .= "END_WORK\n"; $rect .= "f:-"; return $rect; } public static function getDefaultWorkTemplateDrinks() { $rect = "SS:Getränke\n\ni_ID:v\nt:v\nz:v\n"; $rect .= "\n"; $rect .= "START_WORK\n"; $rect .= "f:-;\n"; $rect .= "N:v;\ns: ;b:v;\n"; $rect .= "e:v\n"; $rect .= "END_WORK\n"; $rect .= "f:-"; return $rect; } public static function genSampleHostText() { $hosttext = "\n\nAngaben zum Nachweis der Höhe\nund der betrieblichen\nVeranlassung von\nBewirtungsaufwendungen\n(Par. 4 Abs. 5 Ziff. 2 EStG)\n\n"; $hosttext .= "Tag der Bewirtung:\n\n\n"; $hosttext .= "Ort der Bewirtung:\n\n\n"; $hosttext .= "Bewirtete Person(en):\n\n\n\n\n\n"; $hosttext .= "Anlass der Bewirtung:\n\n\n\n\n\n\n"; $hosttext .= "Ort, Datum Unterschrift\n\n"; return $hosttext; } public static function getDefaultCancelWorkTemplate() { $rect = "SS: Stornierung\n\n"; $rect .= "s:zu stornieren ;n:v\n"; $rect .= "s: ID: ;i:v\n"; $rect .= "s: Tisch: ;t:v\n"; $rect .= "s: Zeit: ;z:v\n"; $rect .= "s: Extras: ;e:v\n"; $rect .= "s: Preis: ;p:v\n"; $rect .= "s: Typ: ;k:v\n"; $rect .= "s: zu storn. Arb.bon: ;q:v\n"; return $rect; } private static function updateNettoValuesOfBill($pdo) { $sql = "SELECT %bill%.id as billid,IF(status='s',-1,1)*ROUND(SUM(price/(1 + %queue%.tax/100.0)),6) as netto FROM %queue%,%billproducts%,%bill% WHERE %billproducts%.billid=%bill%.id AND %billproducts%.queueid=%queue%.id AND (status is null OR status=? OR status=?) GROUP by billid"; $stmt = $pdo->prepare(DbUtils::substTableAlias($sql)); $stmt->execute(array('x','s')); $result = $stmt->fetchAll(PDO::FETCH_ASSOC); $sql = "UPDATE %bill% SET netto=? WHERE id=?"; $stmt = $pdo->prepare(DbUtils::substTableAlias($sql)); foreach($result as $r) { $stmt->execute(array($r["netto"],$r["billid"])); } } public static function upd_1300_1301($pdo, $prefix, $dbname) { try { $basedb = new BaseDb(); $basedb->createCustomerLogTable($pdo); self::insertOrUpdateConfigItem($pdo, 'cancelguestcode', ''); return array(true); } catch (PDOException $e) { return array(false,$e); } } public static function upd_1301_1302($pdo, $prefix, $dbname) { try { self::insertOrUpdateConfigItem($pdo, 'returntoorder', '1'); return array(true); } catch (PDOException $e) { return array(false,$e); } } public static function upd_1302_1303($pdo, $prefix, $dbname) { try { $sql = "SHOW COLUMNS FROM %customers% LIKE 'hello'"; $stmt = $pdo->prepare(DbUtils::substTableAlias($sql)); $stmt->execute(); $result = $stmt->fetchAll(); if (count($result) == 0) { self::execSql($pdo, "ALTER TABLE %customers% ADD hello VARCHAR(100) NULL AFTER www"); self::execSql($pdo, "ALTER TABLE %customers% ADD regards VARCHAR(100) NULL AFTER hello"); self::execSql($pdo, "OPTIMIZE TABLE %customers%"); } self::insertOrUpdateConfigItem($pdo, 'rksvserver', ''); return array(true); } catch (PDOException $e) { return array(false,$e); } } public static function upd_1303_1304($pdo, $prefix, $dbname) { try { return array(true); } catch (PDOException $e) { return array(false,$e); } } public static function upd_1304_1305($pdo, $prefix, $dbname) { try { return array(true); } catch (PDOException $e) { return array(false,$e); } } public static function upd_1305_1306($pdo, $prefix, $dbname) { try { return array(true); } catch (PDOException $e) { return array(false,$e); } } public static function upd_1306_1307($pdo, $prefix, $dbname) { try { self::insertOrUpdateConfigItem($pdo, 'updateurl', 'http://www.ordersprinter.de/update'); return array(true); } catch (PDOException $e) { return array(false,$e); } } public static function upd_1307_1308($pdo, $prefix, $dbname) { try { $sql = "SHOW COLUMNS FROM %user% LIKE 'mobiletheme'"; $stmt = $pdo->prepare(DbUtils::substTableAlias($sql)); $stmt->execute(); $result = $stmt->fetchAll(); if (count($result) == 0) { $sql = "ALTER TABLE %user% ADD mobiletheme INT(2) NULL AFTER language"; $stmt = $pdo->prepare(DbUtils::substTableAlias($sql)); $stmt->execute(); } self::insertOrUpdateConfigItem($pdo, 'discountname1', ''); self::insertOrUpdateConfigItem($pdo, 'discountname2', ''); self::insertOrUpdateConfigItem($pdo, 'discountname3', ''); return array(true); } catch (PDOException $e) { return array(false,$e); } } public static function upd_1308_1309($pdo, $prefix, $dbname) { try { self::execSql($pdo, "ALTER TABLE %products% ADD unit INT(2) NULL AFTER priceC"); self::execSql($pdo, "ALTER TABLE %histprod% ADD unit INT(2) NULL AFTER priceC"); self::execSql($pdo, "ALTER TABLE %products% ADD days VARCHAR(20) NULL AFTER unit"); self::execSql($pdo, "ALTER TABLE %histprod% ADD days VARCHAR(20) NULL AFTER unit"); self::execSql($pdo, "ALTER TABLE %user% ADD failedlogins VARCHAR(20) NULL AFTER extrasapplybtnpos"); return array(true); } catch (PDOException $e) { return array(false,$e); } } public static function upd_1309_1310($pdo, $prefix, $dbname) { try { $sql = "INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL,?,?)"; $stmt = $pdo->prepare(DbUtils::substTableAliasCore($sql, $prefix)); $stmt->execute(array('closshowci', '1')); $stmt->execute(array('closshowpaytaxes', '1')); $stmt->execute(array('closshowprods', '1')); $sql = "SELECT setting FROM %config% WHERE name=?"; $stmt = $pdo->prepare(DbUtils::substTableAliasCore($sql, $prefix)); $stmt->execute(array("paymentconfig")); $row = $stmt->fetchObject(); $paymentconfig = $row->setting; $sql = "INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL,?,?)"; $stmt = $pdo->prepare(DbUtils::substTableAliasCore($sql, $prefix)); if ($paymentconfig == 0) { $stmt->execute(array('showpayment2', '1')); $stmt->execute(array('showpayment3', '1')); $stmt->execute(array('showpayment4', '1')); $stmt->execute(array('showpayment5', '1')); $stmt->execute(array('showpayment6', '1')); $stmt->execute(array('showpayment7', '1')); $stmt->execute(array('showpayment8', '1')); } else { $stmt->execute(array('showpayment2', '1')); $stmt->execute(array('showpayment3', '0')); $stmt->execute(array('showpayment4', '0')); $stmt->execute(array('showpayment5', '0')); $stmt->execute(array('showpayment6', '0')); $stmt->execute(array('showpayment7', '0')); $stmt->execute(array('showpayment8', '0')); } self::execSql($pdo, "ALTER TABLE %extras% ADD sorting INT(2) NULL AFTER price"); $sql = "SELECT id FROM %extras% WHERE removed is null"; $stmt = $pdo->prepare(DbUtils::substTableAlias($sql)); $stmt->execute(); $result = $stmt->fetchAll(); $pos = 1; $sql = "UPDATE %extras% SET sorting=? WHERE id=?"; $stmt = $pdo->prepare(DbUtils::substTableAlias($sql)); foreach ($result as $extraid) { $stmt->execute(array($pos, $extraid["id"])); $pos++; } return array(true); } catch (PDOException $e) { return array(false,$e); } } public static function upd_1310_1311($pdo, $prefix, $dbname) { try { $hosttext = self::genSampleHostText(); self::insertOrUpdateConfigItem($pdo, 'hosttext', $hosttext); return array(true); } catch (PDOException $e) { return array(false,$e); } } public static function upd_1311_1312($pdo, $prefix, $dbname) { try { return array(true); } catch (PDOException $e) { return array(false,$e); } } public static function upd_1312_1313($pdo, $prefix, $dbname) { try { return array(true); } catch (PDOException $e) { return array(false,$e); } } public static function upd_1313_1314($pdo, $prefix, $dbname) { try { self::insertOrUpdateConfigItem($pdo, 'k1prinstance', '1'); self::insertOrUpdateConfigItem($pdo, 'k2prinstance', '1'); self::insertOrUpdateConfigItem($pdo, 'k3prinstance', '1'); self::insertOrUpdateConfigItem($pdo, 'k4prinstance', '1'); self::insertOrUpdateConfigItem($pdo, 'k5prinstance', '1'); self::insertOrUpdateConfigItem($pdo, 'k6prinstance', '1'); self::insertOrUpdateConfigItem($pdo, 'd1prinstance', '1'); self::insertOrUpdateConfigItem($pdo, 'd2prinstance', '1'); self::insertOrUpdateConfigItem($pdo, 'f1prinstance', '1'); self::insertOrUpdateConfigItem($pdo, 'f2prinstance', '1'); self::insertOrUpdateConfigItem($pdo, 'dashslot1', '1'); self::insertOrUpdateConfigItem($pdo, 'dashslot2', '2'); self::insertOrUpdateConfigItem($pdo, 'dashslot3', '3'); $sql = "SHOW COLUMNS FROM %user% LIKE 'right_dash'"; $stmt = $pdo->prepare(DbUtils::substTableAlias($sql)); $stmt->execute(); $result = $stmt->fetchAll(); if (count($result) == 0) { self::execSql($pdo, "ALTER TABLE %user% ADD right_dash INT(2) NULL AFTER right_closing"); self::execSql($pdo, "ALTER TABLE %histuser% ADD right_dash INT(2) NULL AFTER right_closing"); self::execSqlWithParam($pdo, "UPDATE %user% SET right_dash=?", array(0)); self::execSqlWithParam($pdo, "UPDATE %histuser% SET right_dash=?", array(0)); self::execSqlWithParam($pdo, "UPDATE %user% SET right_dash=? WHERE right_manager=? OR is_admin=?", array(1, 1, 1)); self::execSqlWithParam($pdo, "UPDATE %histuser% SET right_dash=? WHERE right_manager=? OR is_admin=?", array(1, 1, 1)); self::execSql($pdo, "OPTIMIZE TABLE %user%"); self::execSql($pdo, "OPTIMIZE TABLE %histuser%"); } return array(true); } catch (PDOException $e) { return array(false,$e); } } public static function upd_1314_1315($pdo, $prefix, $dbname) { try { return array(true); } catch (PDOException $e) { return array(false,$e); } } public static function upd_1315_1316($pdo, $prefix, $dbname) { try { $sql = "UPDATE %config% SET name=? WHERE name=?"; $stmt = $pdo->prepare(DbUtils::substTableAliasCore($sql, $prefix)); $stmt->execute(array('groupworkitemsf', 'groupworkitems')); $sql = "SELECT setting FROM %config% WHERE name=?"; $stmt = $pdo->prepare(DbUtils::substTableAliasCore($sql, $prefix)); $stmt->execute(array('groupworkitemsf')); $row = $stmt->fetchObject(); $groupworkitemsf = $row->setting; $sql = "INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL,?,?)"; $stmt = $pdo->prepare(DbUtils::substTableAliasCore($sql, $prefix)); $stmt->execute(array('groupworkitemsd', $groupworkitemsf)); $sql = "UPDATE %config% SET name=? WHERE name=?"; $stmt = $pdo->prepare(DbUtils::substTableAliasCore($sql, $prefix)); $stmt->execute(array('oneprodworkrecf', 'oneprodworkreceipts')); $sql = "SELECT setting FROM %config% WHERE name=?"; $stmt = $pdo->prepare(DbUtils::substTableAliasCore($sql, $prefix)); $stmt->execute(array('oneprodworkrecf')); $row = $stmt->fetchObject(); $oneprodworkrecf = $row->setting; $sql = "INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL,?,?)"; $stmt = $pdo->prepare(DbUtils::substTableAliasCore($sql, $prefix)); $stmt->execute(array('oneprodworkrecd', $oneprodworkrecf)); return array(true); } catch (PDOException $e) { return array(false,$e); } } public static function upd_1316_1317($pdo, $prefix, $dbname) { try { self::insertOrUpdateConfigItem($pdo, 'dblog', '1'); return array(true); } catch (PDOException $e) { return array(false,$e); } } public static function upd_1317_1318($pdo, $prefix, $dbname) { try { self::insertOrUpdateConfigItem($pdo, 'startprodsearch', '3'); return array(true); } catch (PDOException $e) { return array(false,$e); } } public static function upd_1318_1319($pdo, $prefix, $dbname) { try { self::insertOrUpdateConfigItem($pdo, 'priceinlist', '0'); $basedb = new BaseDb(); $basedb->createProdimagesTable($pdo); $sql = "SHOW COLUMNS FROM %products% LIKE 'prodimageid'"; $stmt = $pdo->prepare(DbUtils::substTableAlias($sql)); $stmt->execute(); $result = $stmt->fetchAll(); if (count($result) == 0) { self::execSql($pdo, "ALTER TABLE %products% ADD prodimageid INT(10) NULL AFTER audio"); self::execSql($pdo, "OPTIMIZE TABLE %products%"); self::execSql($pdo, "ALTER TABLE %histprod% ADD prodimageid INT(10) NULL AFTER audio"); self::execSql($pdo, "OPTIMIZE TABLE %histprod%"); } $sql = "SHOW COLUMNS FROM %user% LIKE 'preferimgdesk'"; $stmt = $pdo->prepare(DbUtils::substTableAlias($sql)); $stmt->execute(); $result = $stmt->fetchAll(); if (count($result) == 0) { $sql = "ALTER TABLE %user% ADD preferimgdesk INT(1) NULL AFTER prefertablemap"; $stmt = $pdo->prepare(DbUtils::substTableAlias($sql)); $stmt->execute(); $sql = "ALTER TABLE %user% ADD preferimgmobile INT(1) NULL AFTER preferimgdesk"; $stmt = $pdo->prepare(DbUtils::substTableAlias($sql)); $stmt->execute(); } return array(true); } catch (PDOException $e) { return array(false,$e); } } public static function upd_1319_1320($pdo, $prefix, $dbname) { try { $sql = "SHOW COLUMNS FROM %user% LIKE 'showplusminus'"; $stmt = $pdo->prepare(DbUtils::substTableAlias($sql)); $stmt->execute(); $result = $stmt->fetchAll(); if (count($result) == 0) { $sql = "ALTER TABLE %user% ADD showplusminus INT(1) NULL AFTER preferimgmobile"; $stmt = $pdo->prepare(DbUtils::substTableAlias($sql)); $stmt->execute(); $sql = "UPDATE %user% SET showplusminus=?"; $stmt = $pdo->prepare(DbUtils::substTableAlias($sql)); $stmt->execute(array(1)); } return array(true); } catch (PDOException $e) { return array(false,$e); } } public static function upd_1320_1321($pdo, $prefix, $dbname) { try { return array(true); } catch (PDOException $e) { return array(false,$e); } } public static function upd_1321_1322($pdo, $prefix, $dbname) { try { self::insertOrUpdateConfigItem($pdo, 'tmpdir', ''); self::insertOrUpdateConfigItem($pdo, 'ftphost', ''); self::insertOrUpdateConfigItem($pdo, 'ftpuser', ''); self::insertOrUpdateConfigItem($pdo, 'ftppass', ''); return array(true); } catch (PDOException $e) { return array(false,$e); } } public static function upd_1322_1323($pdo, $prefix, $dbname) { try { self::insertIntRow($pdo, "%printjobs%", "removed", "printer"); self::insertIntRow($pdo, "%queue%", "printjobid", "workprinted"); $cancelTemplate = self::getDefaultCancelWorkTemplate(); self::insertOrUpdateConfigItem($pdo, 'canceltemplate', $cancelTemplate); $sql = "SHOW COLUMNS FROM %user% LIKE 'right_waiter'"; $stmt = $pdo->prepare(DbUtils::substTableAlias($sql)); $stmt->execute(); $result = $stmt->fetchAll(); if (count($result) > 0) { $basedb = new BaseDb(); $basedb->createRolesTable($pdo); try { $sql = "DELETE FROM %roles%"; $stmt = $pdo->prepare(DbUtils::substTableAlias($sql)); $stmt->execute(); } catch (Exception $ex) { } $sql = "ALTER TABLE %user% ADD roleid INT (10) NULL AFTER active"; $stmt = $pdo->prepare(DbUtils::substTableAlias($sql)); $stmt->execute(); $existingRights = array( "is_admin", "right_waiter", "right_kitchen", "right_bar", "right_supply", "right_paydesk", "right_statistics", "right_bill", "right_products", "right_manager", "right_closing", "right_dash", "right_reservation", "right_rating", "right_changeprice", "right_customers" ); $rightInStr = implode(",", $existingRights); $sql = "SELECT DISTINCT $rightInStr FROM %user% WHERE active='1'"; $stmt = $pdo->prepare(DbUtils::substTableAliasCore($sql, $prefix)); $stmt->execute(); $allDistinctPermutations = $stmt->fetchAll(PDO::FETCH_ASSOC); $i = 1; foreach ($allDistinctPermutations as $aPerm) { $addOnToName = ""; if ($aPerm["is_admin"] == 1) { $addOnToName = " (Admin)"; } else if ($aPerm["right_manager"] == 1) { $addOnToName = " (Verwaltung)"; } $sql = "INSERT INTO %roles% (name,$rightInStr) VALUES('Rolle $i $addOnToName',?,?,?,?,? ,?,?,?,?,? , ?,?,?,?,?, ?)"; $params = array( $aPerm["is_admin"], $aPerm["right_waiter"], $aPerm["right_kitchen"], $aPerm["right_bar"], $aPerm["right_supply"], $aPerm["right_paydesk"], $aPerm["right_statistics"], $aPerm["right_bill"], $aPerm["right_products"], $aPerm["right_manager"], $aPerm["right_closing"], $aPerm["right_dash"], $aPerm["right_reservation"], $aPerm["right_rating"], $aPerm["right_changeprice"], $aPerm["right_customers"] ); $stmt = $pdo->prepare(DbUtils::substTableAlias($sql)); $stmt->execute($params); $newroleid = $pdo->lastInsertId(); $where = "is_admin=? AND "; $where .= "right_waiter=? AND "; $where .= "right_kitchen=? AND "; $where .= "right_bar=? AND "; $where .= "right_supply=? AND "; $where .= "right_paydesk=? AND "; $where .= "right_statistics=? AND "; $where .= "right_bill=? AND "; $where .= "right_products=? AND "; $where .= "right_manager=? AND "; $where .= "right_closing=? AND "; $where .= "right_dash=? AND "; $where .= "right_reservation=? AND "; $where .= "right_rating=? AND "; $where .= "right_changeprice=? AND "; $where .= "right_customers=?"; $sql = "SELECT id FROM %user% WHERE $where AND active=1"; $stmt = $pdo->prepare(DbUtils::substTableAliasCore($sql, $prefix)); $stmt->execute($params); $allUserIdsOfThatRole = $stmt->fetchAll(PDO::FETCH_ASSOC); foreach ($allUserIdsOfThatRole as $u) { $sql = "UPDATE %user% SET roleid=? WHERE id=?"; $stmt = $pdo->prepare(DbUtils::substTableAliasCore($sql, $prefix)); $stmt->execute(array($newroleid, $u["id"])); } $i++; } foreach ($existingRights as $r) { $sql = "ALTER TABLE %user% DROP COLUMN " . $r; $stmt = $pdo->prepare(DbUtils::substTableAliasCore($sql, $prefix)); $stmt->execute(); } $sql = "UPDATE %user% SET roleid=? WHERE active='0'"; $stmt = $pdo->prepare(DbUtils::substTableAliasCore($sql, $prefix)); $stmt->execute(array(null)); $sql = "OPTIMIZE TABLE %user%"; $stmt = $pdo->prepare(DbUtils::substTableAliasCore($sql, $prefix)); $stmt->execute(); } return array(true); } catch (PDOException $e) { return array(false,$e); } } public static function upd_1323_1324($pdo, $prefix, $dbname) { try { return array(true); } catch (PDOException $e) { return array(false,$e); } } public static function upd_1324_1325($pdo, $prefix, $dbname) { try { return array(true); } catch (PDOException $e) { return array(false,$e); } } public static function upd_1325_1326($pdo, $prefix, $dbname) { return array(true); } public static function upd_1326_1400($pdo, $prefix, $dbname) { try { self::insertOrUpdateConfigItem($pdo, 'guestjobprint', '1'); $sql = "SHOW COLUMNS FROM %products% LIKE 'display'"; $stmt = $pdo->prepare(DbUtils::substTableAlias($sql)); $stmt->execute(); $result = $stmt->fetchAll(); if (count($result) == 0) { self::execSql($pdo, "ALTER TABLE %products% ADD display VARCHAR(3) NULL AFTER prodimageid"); self::execSql($pdo, "OPTIMIZE TABLE %products%"); self::execSql($pdo, "ALTER TABLE %histprod% ADD display VARCHAR(3) NULL AFTER prodimageid"); self::execSql($pdo, "OPTIMIZE TABLE %histprod%"); } self::insertOrUpdateConfigItem($pdo, 'guesturl', ''); self::insertOrUpdateConfigItem($pdo, 'guestcode', ''); self::insertOrUpdateConfigItem($pdo, 'dailycode', ''); self::insertIntRow($pdo, "%user%", "preferfixbtns", "preferimgmobile"); $sql = "ALTER TABLE %queue% MODIFY orderuser INT(10) NULL"; $stmt = $pdo->prepare(DbUtils::substTableAlias($sql)); $stmt->execute(); self::insertTypeRow($pdo, '%resttables%', 'code', 'roomid', 'VARCHAR ( 200 ) NULL'); self::insertTypeRow($pdo, '%resttables%', 'name', 'code', 'VARCHAR ( 50 ) NULL'); self::insertTypeRow($pdo, '%resttables%', 'active', 'name', 'INT(1) NULL'); self::insertTypeRow($pdo, '%resttables%', 'allowoutorder', 'active', 'INT(1) NULL'); $sql = "UPDATE %resttables% SET name=tableno"; $stmt = $pdo->prepare(DbUtils::substTableAlias($sql)); $stmt->execute(); $basedb = new BaseDb(); $basedb->initTableOrder($pdo); $basedb = new BaseDb(); $basedb->initRoomOrder($pdo); return array(true); } catch (PDOException $e) { return array(false,$e); } } public static function upd_1400_1401($pdo, $prefix, $dbname) { try { $sql = "ALTER TABLE %bill% MODIFY netto DECIMAL (17,6) NULL"; $stmt = $pdo->prepare(DbUtils::substTableAlias($sql)); $stmt->execute(); self::updateNettoValuesOfBill($pdo); $sql = "OPTIMIZE TABLE %bill%"; $stmt = $pdo->prepare(DbUtils::substTableAliasCore($sql, $prefix)); $stmt->execute(); return array(true); } catch (PDOException $e) { return array(false,$e); } } public static function upd_1401_1402($pdo, $prefix, $dbname) { return array(true); } public static function upd_1402_1403($pdo, $prefix, $dbname) { try { $sql = "ALTER TABLE %queue% ADD INDEX tqueue (tablenr)"; $stmt = $pdo->prepare(DbUtils::substTableAlias($sql)); $stmt->execute(); $sql = "ALTER TABLE %queue% ADD INDEX pqueue (productid)"; $stmt = $pdo->prepare(DbUtils::substTableAlias($sql)); $stmt->execute(); $sql = "ALTER TABLE %queue% ADD INDEX bqueue (billid)"; $stmt = $pdo->prepare(DbUtils::substTableAlias($sql)); $stmt->execute(); return array(true); } catch (PDOException $e) { return array(false,$e); } } public static function upd_1403_1404($pdo, $prefix, $dbname) { try { $sql = "OPTIMIZE TABLE %queue%"; $stmt = $pdo->prepare(DbUtils::substTableAliasCore($sql, $prefix)); $stmt->execute(); return array(true); } catch (PDOException $e) { return array(false,$e); } } public static function upd_1404_1405($pdo, $prefix, $dbname) { return array(true); } public static function upd_1405_1406($pdo, $prefix, $dbname) { try { self::insertOrUpdateConfigItem($pdo, 'askdaycode', '1'); self::insertOrUpdateConfigItem($pdo, 'asktablecode', '1'); self::insertOrUpdateConfigItem($pdo, 'guesttimeout', '5'); self::insertOrUpdateConfigItem($pdo, 'showdaycode', '0'); $sql = "ALTER TABLE %products% ADD INDEX pcatindex (category)"; $stmt = $pdo->prepare(DbUtils::substTableAlias($sql)); $stmt->execute(); $sql = "OPTIMIZE TABLE %products%"; $stmt = $pdo->prepare(DbUtils::substTableAliasCore($sql, $prefix)); $stmt->execute(); $sql = "OPTIMIZE TABLE %queue%"; $stmt = $pdo->prepare(DbUtils::substTableAliasCore($sql, $prefix)); $stmt->execute(); return array(true); } catch (PDOException $e) { return array(false,$e); } } public static function upd_1406_1407($pdo, $prefix, $dbname) { try { $basedb = new BaseDb(); $basedb->sortProdTypes($pdo); return array(true); } catch (PDOException $e) { return array(false,$e); } } public static function upd_1407_1408($pdo, $prefix, $dbname) { try { $basedb = new BaseDb(); $basedb->sortProdTypes($pdo); $basedb->createRecordsTable($pdo); $basedb->createRecordsQueueTable($pdo); $sql = "ALTER TABLE %user% ADD tablesaftersend INT(1) NULL AFTER keeptypelevel"; $stmt = $pdo->prepare(DbUtils::substTableAlias($sql)); $stmt->execute(); $sql = "UPDATE %user% SET tablesaftersend=?"; $stmt = $pdo->prepare(DbUtils::substTableAlias($sql)); $stmt->execute(array(1)); return array(true); } catch (PDOException $e) { return array(false,$e); } } public static function upd_1408_1409($pdo, $prefix, $dbname) { return array(true); } public static function upd_1409_1410($pdo, $prefix, $dbname) { return array(true); } public static function upd_1410_1411($pdo, $prefix, $dbname) { return array(true); } public static function upd_1411_1412($pdo, $prefix, $dbname) { return array(true); } public static function upd_1412_1413($pdo, $prefix, $dbname) { return array(true); } public static $updateOrder = array( "1.3.0" => array("upd_1300_1301","1.3.1"), "1.3.1" => array("upd_1301_1302","1.3.2"), "1.3.2" => array("upd_1302_1303","1.3.3"), "1.3.3" => array("upd_1303_1304","1.3.4"), "1.3.4" => array("upd_1304_1305","1.3.5"), "1.3.5" => array("upd_1305_1306","1.3.6"), "1.3.6" => array("upd_1306_1307","1.3.7"), "1.3.7" => array("upd_1307_1308","1.3.8"), "1.3.8" => array("upd_1308_1309","1.3.9"), "1.3.9" => array("upd_1309_1310","1.3.10"), "1.3.10" => array("upd_1310_1311","1.3.11"), "1.3.11" => array("upd_1311_1312","1.3.12"), "1.3.12" => array("upd_1312_1313","1.3.13"), "1.3.13" => array("upd_1313_1314","1.3.14"), "1.3.14" => array("upd_1314_1315","1.3.15"), "1.3.15" => array("upd_1315_1316","1.3.16"), "1.3.16" => array("upd_1316_1317","1.3.17"), "1.3.17" => array("upd_1317_1318","1.3.18"), "1.3.18" => array("upd_1318_1319","1.3.19"), "1.3.19" => array("upd_1319_1320","1.3.20"), "1.3.20" => array("upd_1320_1321","1.3.21"), "1.3.21" => array("upd_1321_1322","1.3.22"), "1.3.22" => array("upd_1322_1323","1.3.23"), "1.3.23" => array("upd_1323_1324","1.3.24"), "1.3.24" => array("upd_1324_1325","1.3.25"), "1.3.25" => array("upd_1325_1326","1.3.26"), "1.3.26" => array("upd_1326_1400","1.4.0"), "1.4.0" => array("upd_1400_1401","1.4.1"), "1.4.1" => array("upd_1401_1402","1.4.2"), "1.4.2" => array("upd_1402_1403","1.4.3"), "1.4.3" => array("upd_1403_1404","1.4.4"), "1.4.4" => array("upd_1404_1405","1.4.5"), "1.4.5" => array("upd_1405_1406","1.4.6"), "1.4.6" => array("upd_1406_1407","1.4.7"), "1.4.7" => array("upd_1407_1408","1.4.8"), "1.4.8" => array("upd_1408_1409","1.4.9"), "1.4.9" => array("upd_1409_1410","1.4.10"), "1.4.10" => array("upd_1410_1411","1.4.11"), "1.4.11" => array("upd_1411_1412","1.4.12"), "1.4.12" => array("upd_1412_1413","1.4.13") ); // RE;* also for install process no check is required public static function runUpdateProcess($pdo,$prefix, $dbname, $untilVersion,$checkValidVersion) { $curversion = CommonUtils::getConfigValue($pdo, "version", "0"); if ($checkValidVersion && !array_key_exists($curversion, self::$updateOrder) && ($curversion != "{VERSION}")) { return array("status" => "ERROR","msg" => "Versionsupdate von Quellversion $curversion nicht möglich."); } $params = [$pdo, $prefix, $dbname]; $updateCompleted = false; while (!$updateCompleted) { $curversion = CommonUtils::getConfigValue($pdo, "version", "0"); if ($curversion == $untilVersion) { // final version reached break; } if (!array_key_exists($curversion, self::$updateOrder)) { $updateCompleted = true; break; } $updContext = self::$updateOrder[$curversion]; $updFct = $updContext[0]; $ret = call_user_func_array(["Version", $updFct], $params); if (!$ret[0]) { return array("status" => "ERROR","msg" => $ret[1]); } self::updateVersion($pdo, $updContext[1]); } return array("status" => "OK"); } }