2020-11-19 23:10:26 +01:00
< ? php
class Version {
public static function updateVersion ( $pdo , $version ) {
self :: insertOrUpdateConfigItem ( $pdo , 'version' , $version );
}
public static function insertOrUpdateConfigItem ( $pdo , $item , $value ) {
$hist = new HistFiller ();
$hist -> 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; \n t:llllllllllllllllllll; f: ; a_ID:rrrrrrrrrrr \n ;f: ;d:w \n \n g:v; c:v \n \n k:rrr; s: ; m:v; s: ; n:rrrrrr; o:rrrrrrr \n f:- \n " ;
$rect .= " START_PRODUCTS \n a:rrr; s: ; c:v; s: ; b:rrrrrr; d:rrrrrrr \n END_PRODUCTS \n \n " ;
$rect .= " p:rrrrr; q:rrrrrr; r:rrrrrrrr; n:rrrrrrrr \n START_TAXES \n t:rrrrr; m:rrrrrr; n:rrrrrrrr; b:rrrrrrrr \n END_TAXES \n \n " ;
$rect .= " f: ; E_Summe:llllllllllllllllllll; \n \n j:l; " ;
return $rect ;
}
public static function getDefaultWorkTemplateFood () {
$rect = " SS:Speisen \n \n i_ID:v \n t:v \n z:v \n " ;
$rect .= " \n " ;
$rect .= " START_WORK \n " ;
$rect .= " f:-; \n " ;
$rect .= " N:v; \n s: ;b:v; \n " ;
$rect .= " e:v \n " ;
$rect .= " END_WORK \n " ;
$rect .= " f:- " ;
return $rect ;
}
public static function getDefaultWorkTemplateDrinks () {
$rect = " SS:Getränke \n \n i_ID:v \n t:v \n z:v \n " ;
$rect .= " \n " ;
$rect .= " START_WORK \n " ;
$rect .= " f:-; \n " ;
$rect .= " N:v; \n s: ;b:v; \n " ;
$rect .= " e:v \n " ;
$rect .= " END_WORK \n " ;
$rect .= " f:- " ;
return $rect ;
}
2020-11-19 23:11:52 +01:00
public static function getDefaultPickupTemplate () {
$rect = " S:Abholbon \n \n II_ID:v \n " ;
$rect .= " START_WORK \n " ;
$rect .= " f:-; \n " ;
$rect .= " N:v; \n s: ;b:v; \n " ;
$rect .= " e:v \n " ;
$rect .= " END_WORK \n " ;
$rect .= " f:- " ;
return $rect ;
}
2020-11-19 23:10:26 +01:00
public static function genSampleHostText () {
$hosttext = " \n \n Angaben zum Nachweis der Höhe \n und der betrieblichen \n Veranlassung von \n Bewirtungsaufwendungen \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 ;
}
2020-11-19 23:11:49 +01:00
public static function getDefaultClosTemplate ( $pdo ) {
$r = Basedb :: loadSampleCusHtmlTemplate ( $pdo );
return $r ;
}
2020-11-19 23:10:26 +01:00
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 ) {
2020-11-19 23:10:28 +01:00
return array ( true );
2020-11-19 23:10:26 +01:00
}
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 ) {
2020-11-19 23:10:28 +01:00
return array ( true );
2020-11-19 23:10:26 +01:00
}
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 ) {
2020-11-19 23:12:35 +01:00
return array ( true );
2020-11-19 23:10:26 +01:00
}
public static function upd_1404_1405 ( $pdo , $prefix , $dbname ) {
2020-11-19 23:10:28 +01:00
return array ( true );
2020-11-19 23:10:26 +01:00
}
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 ();
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 );
}
}
2020-11-19 23:10:28 +01:00
public static function upd_1408_1409 ( $pdo , $prefix , $dbname ) {
return array ( true );
}
2020-11-19 23:10:30 +01:00
public static function upd_1409_1410 ( $pdo , $prefix , $dbname ) {
return array ( true );
2020-11-19 23:10:33 +01:00
}
public static function upd_1410_1411 ( $pdo , $prefix , $dbname ) {
2020-11-19 23:10:35 +01:00
return array ( true );
}
public static function upd_1411_1412 ( $pdo , $prefix , $dbname ) {
return array ( true );
2020-11-19 23:10:30 +01:00
}
2020-11-19 23:10:37 +01:00
public static function upd_1412_1413 ( $pdo , $prefix , $dbname ) {
return array ( true );
}
2020-11-19 23:10:39 +01:00
public static function upd_1413_1414 ( $pdo , $prefix , $dbname ) {
return array ( true );
}
2020-11-19 23:10:41 +01:00
public static function upd_1414_1415 ( $pdo , $prefix , $dbname ) {
return array ( true );
}
2020-11-19 23:10:43 +01:00
public static function upd_1415_1416 ( $pdo , $prefix , $dbname ) {
return array ( true );
}
2020-11-19 23:10:46 +01:00
public static function upd_1416_1417 ( $pdo , $prefix , $dbname ) {
try {
self :: insertOrUpdateConfigItem ( $pdo , 'forceprint' , '0' );
self :: insertOrUpdateConfigItem ( $pdo , 'printextras' , '0' );
$sql = " ALTER TABLE %queueextras% ADD INDEX tqueueextras (queueid) " ;
$stmt = $pdo -> prepare ( DbUtils :: substTableAlias ( $sql ));
$stmt -> execute ();
$sql = " ALTER TABLE %bill% ADD printextras INT(1) NULL AFTER intguestpaid " ;
$stmt = $pdo -> prepare ( DbUtils :: substTableAlias ( $sql ));
$stmt -> execute ();
return array ( true );
} catch ( PDOException $e ) {
return array ( false , $e );
}
}
2020-11-19 23:10:48 +01:00
public static function upd_1417_1418 ( $pdo , $prefix , $dbname ) {
try {
self :: insertOrUpdateConfigItem ( $pdo , 'beepordered' , '0' );
return array ( true );
} catch ( PDOException $e ) {
return array ( false , $e );
}
}
2020-11-19 23:10:30 +01:00
2020-11-19 23:11:27 +01:00
public static function upd_1418_1500 ( $pdo , $prefix , $dbname ) {
try {
self :: execSql ( $pdo , " ALTER TABLE %roles% ADD right_timetracking INT(1) NULL AFTER right_dash " );
self :: execSql ( $pdo , " ALTER TABLE %roles% ADD right_timemanager INT(1) NULL AFTER right_timetracking " );
self :: execSql ( $pdo , " ALTER TABLE %histuser% ADD right_timetracking INT(1) NULL AFTER right_dash " );
self :: execSql ( $pdo , " ALTER TABLE %histuser% ADD right_timemanager INT(1) NULL AFTER right_timetracking " );
self :: execSqlWithParam ( $pdo , " UPDATE %roles% SET right_timetracking=?,right_timemanager=? " , array ( 1 , 0 ));
self :: execSqlWithParam ( $pdo , " UPDATE %histuser% SET right_timetracking=?,right_timemanager=? " , array ( 1 , 0 ));
self :: execSqlWithParam ( $pdo , " UPDATE %roles% SET right_timemanager=? WHERE right_manager=? OR is_admin=? " , array ( 1 , 1 , 1 ));
self :: execSqlWithParam ( $pdo , " UPDATE %histuser% SET right_timemanager=? WHERE right_manager=? OR is_admin=? " , array ( 1 , 1 , 1 ));
self :: execSql ( $pdo , " OPTIMIZE TABLE %roles% " );
self :: execSql ( $pdo , " OPTIMIZE TABLE %histuser% " );
$basedb = new BaseDb (); $basedb -> createTimesTable ( $pdo );
self :: insertOrUpdateConfigItem ( $pdo , 'minbeforecome' , '0' );
self :: insertOrUpdateConfigItem ( $pdo , 'minaftergo' , '0' );
self :: execSql ( $pdo , " ALTER TABLE %config% MODIFY name VARCHAR(30) NULL " );
$sql = " ALTER TABLE %config% ADD INDEX tconfig (name) " ;
$stmt = $pdo -> prepare ( DbUtils :: substTableAlias ( $sql ));
$stmt -> execute ();
self :: execSql ( $pdo , " ALTER TABLE %prodimages% ADD keyname VARCHAR(30) NULL AFTER id " );
self :: execSql ( $pdo , " UPDATE %prodimages% set keyname=CONCAT('Bild_',id) " );
return array ( true );
} catch ( PDOException $e ) {
return array ( false , $e );
}
}
2020-11-19 23:11:29 +01:00
public static function upd_1500_1501 ( $pdo , $prefix , $dbname ) {
try {
self :: insertOrUpdateConfigItem ( $pdo , 'defaultview' , '0' );
return array ( true );
} catch ( PDOException $e ) {
return array ( false , $e );
}
}
2020-11-19 23:11:33 +01:00
public static function upd_1501_1502 ( $pdo , $prefix , $dbname ) {
try {
self :: execSql ( $pdo , " ALTER TABLE %roles% ADD right_tasks INT(1) NULL AFTER right_timetracking " );
self :: execSql ( $pdo , " ALTER TABLE %roles% ADD right_tasksmanagement INT(1) NULL AFTER right_tasks " );
self :: execSql ( $pdo , " ALTER TABLE %histuser% ADD right_tasks INT(1) NULL AFTER right_timetracking " );
self :: execSql ( $pdo , " ALTER TABLE %histuser% ADD right_tasksmanagement INT(1) NULL AFTER right_tasks " );
self :: execSqlWithParam ( $pdo , " UPDATE %roles% SET right_tasks=?,right_tasksmanagement=? " , array ( 0 , 0 ));
self :: execSqlWithParam ( $pdo , " UPDATE %histuser% SET right_tasks=?,right_tasksmanagement=? " , array ( 0 , 0 ));
self :: execSqlWithParam ( $pdo , " UPDATE %roles% SET right_tasksmanagement=? WHERE right_manager=? OR is_admin=? " , array ( 1 , 1 , 1 ));
self :: execSqlWithParam ( $pdo , " UPDATE %histuser% SET right_tasksmanagement=? WHERE right_manager=? OR is_admin=? " , array ( 1 , 1 , 1 ));
self :: execSql ( $pdo , " OPTIMIZE TABLE %roles% " );
self :: execSql ( $pdo , " OPTIMIZE TABLE %histuser% " );
$basedb = new BaseDb (); $basedb -> createTasksTable ( $pdo );
$basedb = new BaseDb (); $basedb -> createTaskHistTable ( $pdo );
self :: execSql ( $pdo , " ALTER TABLE %resttables% ADD area INT(1) NULL AFTER name " );
self :: execSql ( $pdo , " OPTIMIZE TABLE %resttables% " );
self :: execSql ( $pdo , " ALTER TABLE %user% ADD area INT(1) NULL AFTER roleid " );
self :: execSql ( $pdo , " OPTIMIZE TABLE %user% " );
self :: execSql ( $pdo , " ALTER TABLE %histuser% ADD area INT(1) NULL AFTER right_customers " );
self :: execSql ( $pdo , " OPTIMIZE TABLE %histuser% " );
self :: insertOrUpdateConfigItem ( $pdo , 'taskallassign' , '0' );
self :: insertOrUpdateConfigItem ( $pdo , 'taskifempty' , 0 );
self :: insertOrUpdateConfigItem ( $pdo , 'taskownerempty' , 0 );
return array ( true );
} catch ( PDOException $e ) {
return array ( false , $e );
}
}
2020-11-19 23:11:36 +01:00
public static function upd_1502_1503 ( $pdo , $prefix , $dbname ) {
try {
self :: insertOrUpdateConfigItem ( $pdo , 'showtogo' , '1' );
return array ( true );
} catch ( PDOException $e ) {
return array ( false , $e );
}
}
2020-11-19 23:11:42 +01:00
public static function upd_1503_1504 ( $pdo , $prefix , $dbname ) {
try {
$sql = " ALTER TABLE %printjobs% ADD INDEX tprintjobs (type,removed,printer) " ;
$stmt = $pdo -> prepare ( DbUtils :: substTableAlias ( $sql ));
$stmt -> execute ();
self :: insertOrUpdateConfigItem ( $pdo , 'showprepinwaiter' , '1' );
return array ( true );
} catch ( PDOException $e ) {
return array ( false , $e );
}
}
2020-11-19 23:11:44 +01:00
public static function upd_1504_1505 ( $pdo , $prefix , $dbname ) {
2020-11-19 23:12:16 +01:00
return array ( true );
2020-11-19 23:11:44 +01:00
}
2020-11-19 23:11:47 +01:00
public static function upd_1505_1506 ( $pdo , $prefix , $dbname ) {
try {
self :: insertOrUpdateConfigItem ( $pdo , 'pollbills' , '2' );
self :: insertOrUpdateConfigItem ( $pdo , 'pollworksf' , '2' );
self :: insertOrUpdateConfigItem ( $pdo , 'pollworksd' , '2' );
self :: insertOrUpdateConfigItem ( $pdo , 'pollclosings' , '2' );
return array ( true );
} catch ( PDOException $e ) {
return array ( false , $e );
}
}
2020-11-19 23:11:49 +01:00
public static function upd_1506_1507 ( $pdo , $prefix , $dbname ) {
try {
$closTemplate = self :: getDefaultClosTemplate ( $pdo );
self :: insertOrUpdateConfigItem ( $pdo , 'clostemplate' , $closTemplate );
return array ( true );
} catch ( PDOException $e ) {
return array ( false , $e );
}
}
2020-11-19 23:11:52 +01:00
public static function upd_1507_1508 ( $pdo , $prefix , $dbname ) {
try {
self :: insertOrUpdateConfigItem ( $pdo , 'printpickups' , 0 );
self :: insertOrUpdateConfigItem ( $pdo , 'pollpickups' , 2 );
$pickuptemplate = self :: getDefaultPickupTemplate ();
self :: insertOrUpdateConfigItem ( $pdo , 'pickuptemplate' , $pickuptemplate );
self :: insertOrUpdateConfigItem ( $pdo , 'p1prinstance' , 1 );
self :: insertOrUpdateConfigItem ( $pdo , 'showpickupsno' , 20 );
self :: execSql ( $pdo , " ALTER TABLE %roles% ADD right_pickups INT(1) NULL AFTER right_customers " );
self :: execSql ( $pdo , " ALTER TABLE %histuser% ADD right_pickups INT(1) NULL AFTER right_customers " );
2020-11-19 23:11:54 +01:00
self :: execSqlWithParam ( $pdo , " UPDATE %roles% SET right_pickups=? " , array ( 0 ));
2020-11-19 23:11:52 +01:00
self :: execSqlWithParam ( $pdo , " UPDATE %histuser% SET right_pickups=? " , array ( 0 ));
self :: execSql ( $pdo , " OPTIMIZE TABLE %roles% " );
self :: execSql ( $pdo , " OPTIMIZE TABLE %histuser% " );
self :: execSql ( $pdo , " ALTER TABLE %printjobs% ADD pickready INT(1) NULL AFTER removed " );
return array ( true );
} catch ( PDOException $e ) {
return array ( false , $e );
}
}
2020-11-19 23:11:54 +01:00
public static function upd_1508_1509 ( $pdo , $prefix , $dbname ) {
2020-11-19 23:12:16 +01:00
return array ( true );
2020-11-19 23:11:54 +01:00
}
2020-11-19 23:11:57 +01:00
public static function upd_1509_1510 ( $pdo , $prefix , $dbname ) {
try {
self :: insertOrUpdateConfigItem ( $pdo , 'togoworkprinter' , 0 );
return array ( true );
} catch ( PDOException $e ) {
return array ( false , $e );
}
}
2020-11-19 23:12:00 +01:00
public static function upd_1510_1511 ( $pdo , $prefix , $dbname ) {
try {
self :: insertOrUpdateConfigItem ( $pdo , 'showhostprint' , 1 );
self :: insertOrUpdateConfigItem ( $pdo , 'oneclickcooked' , 0 );
self :: insertOrUpdateConfigItem ( $pdo , 'showpickupdelbtn' , 1 );
self :: insertOrUpdateConfigItem ( $pdo , 'showpickhelp' , 1 );
self :: insertOrUpdateConfigItem ( $pdo , 'showpayments' , 1 );
return array ( true );
} catch ( PDOException $e ) {
return array ( false , $e );
}
}
2020-11-19 23:12:02 +01:00
public static function upd_1511_1512 ( $pdo , $prefix , $dbname ) {
try {
self :: insertOrUpdateConfigItem ( $pdo , 'cbirdfolder' , '' );
self :: execSql ( $pdo , " ALTER TABLE %user% ADD calcpref INT(2) NULL AFTER extrasapplybtnpos " );
return array ( true );
} catch ( PDOException $e ) {
return array ( false , $e );
}
}
2020-11-19 23:12:05 +01:00
public static function upd_1512_1513 ( $pdo , $prefix , $dbname ) {
try {
self :: execSql ( $pdo , " ALTER TABLE %prodtype% ADD fixbind INT(1) NULL AFTER printer " );
self :: execSql ( $pdo , " UPDATE %prodtype% SET fixbind='0' " );
self :: insertOrUpdateConfigItem ( $pdo , 'd3prinstance' , '1' );
self :: insertOrUpdateConfigItem ( $pdo , 'd4prinstance' , '1' );
self :: insertOrUpdateConfigItem ( $pdo , 'f3prinstance' , '1' );
self :: insertOrUpdateConfigItem ( $pdo , 'f4prinstance' , '1' );
return array ( true );
} catch ( PDOException $e ) {
return array ( false , $e );
}
}
2020-11-19 23:12:07 +01:00
public static function upd_1513_1514 ( $pdo , $prefix , $dbname ) {
try {
$sql = " UPDATE %work% SET signature=? WHERE item=? " ;
self :: execSqlWithParam ( $pdo , $sql , array ( " " , " privkey " ));
self :: execSqlWithParam ( $pdo , $sql , array ( " " , " cert " ));
self :: execSqlWithParam ( $pdo , $sql , array ( " " , " lastbillid " ));
2020-11-19 23:12:10 +01:00
self :: execSql ( $pdo , " UPDATE %work% SET signature='' " );
2020-11-19 23:12:07 +01:00
self :: execSql ( $pdo , " ALTER TABLE %work% MODIFY signature VARCHAR(50) NULL " );
CommonUtils :: setMd5OfLastBillidInWorkTable ( $pdo );
2020-11-19 23:12:10 +01:00
self :: execSql ( $pdo , " UPDATE %bill% SET signature='' " );
2020-11-19 23:12:07 +01:00
self :: execSql ( $pdo , " ALTER TABLE %bill% MODIFY signature VARCHAR(50) NULL " );
CommonUtils :: calcSignaturesForAllBills ( $pdo );
2020-11-19 23:12:10 +01:00
self :: execSql ( $pdo , " UPDATE %closing% SET signature='' " );
2020-11-19 23:12:07 +01:00
self :: execSql ( $pdo , " ALTER TABLE %closing% MODIFY signature VARCHAR(50) NULL " );
Closing :: signAllClosings ( $pdo );
self :: insertOrUpdateConfigItem ( $pdo , 'billprintjobs' , '2' );
return array ( true );
} catch ( PDOException $e ) {
return array ( false , $e );
}
}
2020-11-19 23:12:10 +01:00
public static function upd_1514_1515 ( $pdo , $prefix , $dbname ) {
2020-11-19 23:12:16 +01:00
return array ( true );
2020-11-19 23:12:10 +01:00
}
2020-11-19 23:12:13 +01:00
public static function upd_1515_1516 ( $pdo , $prefix , $dbname ) {
2020-11-19 23:12:16 +01:00
return array ( true );
}
public static function upd_1516_1517 ( $pdo , $prefix , $dbname ) {
return array ( true );
2020-11-19 23:12:13 +01:00
}
2020-11-19 23:12:18 +01:00
public static function upd_1517_1518 ( $pdo , $prefix , $dbname ) {
try {
self :: insertOrUpdateConfigItem ( $pdo , 'payprinttype' , 's' );
self :: execSql ( $pdo , " ALTER TABLE %products% ADD barcode VARCHAR(25) NULL AFTER priceC " );
self :: execSql ( $pdo , " ALTER TABLE %histprod% ADD barcode VARCHAR(25) NULL AFTER priceC " );
self :: insertOrUpdateConfigItem ( $pdo , 'usebarcode' , '0' );
return array ( true );
} catch ( PDOException $e ) {
return array ( false , $e );
}
}
2020-11-19 23:12:22 +01:00
public static function upd_1518_1519 ( $pdo , $prefix , $dbname ) {
try {
self :: insertOrUpdateConfigItem ( $pdo , 'sumupforcard' , '0' );
self :: insertOrUpdateConfigItem ( $pdo , 'affiliatekey' , '' );
self :: insertOrUpdateConfigItem ( $pdo , 'appid' , '' );
self :: insertOrUpdateConfigItem ( $pdo , 'sumupfailuretext' , 'Fehlgeschlagene Kartenzahlung' );
$sql = " UPDATE `%payment%` SET name=?, name_en=?, name_esp=? WHERE id=? " ;
self :: execSqlWithParam ( $pdo , $sql , array ( " Kartenzahlung " , " Card Payment " , " Pago con tarjeta " , 2 ));
$sql = " UPDATE `%bill%` SET paymentid=? WHERE paymentid=? " ;
self :: execSqlWithParam ( $pdo , $sql , array ( 2 , 3 ));
return array ( true );
} catch ( PDOException $e ) {
return array ( false , $e );
}
}
2020-11-19 23:12:24 +01:00
public static function upd_1519_1520 ( $pdo , $prefix , $dbname ) {
try {
self :: insertOrUpdateConfigItem ( $pdo , 'printcash' , '0' );
return array ( true );
} catch ( PDOException $e ) {
return array ( false , $e );
}
}
2020-11-19 23:12:27 +01:00
public static function upd_1520_1521 ( $pdo , $prefix , $dbname ) {
try {
$sql = " UPDATE %queue% SET toremove=? " ;
self :: execSqlWithParam ( $pdo , $sql , array ( 0 ));
return array ( true );
} catch ( PDOException $e ) {
return array ( false , $e );
}
}
2020-11-19 23:12:30 +01:00
public static function upd_1521_1522 ( $pdo , $prefix , $dbname ) {
try {
self :: insertOrUpdateConfigItem ( $pdo , 'showerrorlog' , '1' );
return array ( true );
} catch ( PDOException $e ) {
return array ( false , $e );
}
}
2020-11-19 23:12:32 +01:00
public static function upd_1522_1523 ( $pdo , $prefix , $dbname ) {
try {
self :: execSql ( $pdo , " ALTER TABLE %queue% ADD clsid INT(1) NULL AFTER isclosed " );
self :: execSql ( $pdo , " ALTER TABLE %queue% ADD FOREIGN KEY(clsid) REFERENCES %closing% (id) " );
$sql = " SELECT max(id) as maxid FROM %queue% " ;
$stmt = $pdo -> prepare ( DbUtils :: substTableAliasCore ( $sql , $prefix ));
$stmt -> execute ();
$r = $stmt -> fetchAll ( PDO :: FETCH_ASSOC );
$maxid = 0 ;
if ( count ( $r ) > 0 ) {
$maxid = $r [ 0 ][ " maxid " ];
if ( is_null ( $maxid )) {
$maxid = 0 ;
}
}
$sql = " INSERT INTO %work% (item,value) VALUES(?,?) " ;
$stmt = $pdo -> prepare ( DbUtils :: substTableAliasCore ( $sql , $prefix ));
$stmt -> execute ( array ( " indexunclosedqueue " , $maxid ));
self :: execSql ( $pdo , " ALTER TABLE %work% MODIFY value VARCHAR(100) NULL " );
return array ( true );
} catch ( PDOException $e ) {
return array ( false , $e );
}
}
2020-11-19 23:12:35 +01:00
public static function upd_1523_1524 ( $pdo , $prefix , $dbname ) {
try {
self :: execSql ( $pdo , " ALTER TABLE %queue% ADD unit INT(1) NULL AFTER price " );
self :: execSql ( $pdo , " ALTER TABLE %queue% ADD unitamount decimal(15,2) NULL AFTER unit " );
self :: execSql ( $pdo , " UPDATE %queue% SET unitamount='1' " );
$sql = " UPDATE %queue% SET unit=(SELECT IFNULL(unit,0) FROM %products% P WHERE productid=P.id) " ;
self :: execSql ( $pdo , $sql );
self :: execSql ( $pdo , " OPTIMIZE TABLE %queue% " );
return array ( true );
} catch ( PDOException $e ) {
return array ( false , $e );
}
}
2020-11-19 23:12:37 +01:00
public static function upd_1524_1525 ( $pdo , $prefix , $dbname ) {
try {
self :: insertOrUpdateConfigItem ( $pdo , 'showtransferbtns' , '1' );
self :: execSql ( $pdo , " ALTER TABLE %reservations% ADD tableid INT(10) NULL AFTER phone " );
$sql = " ALTER TABLE %reservations% ADD INDEX tresdate (scheduledate) " ;
$stmt = $pdo -> prepare ( DbUtils :: substTableAlias ( $sql ));
$stmt -> execute ();
$sql = " ALTER TABLE %logo% MODIFY setting MEDIUMBLOB NULL " ;
$stmt = $pdo -> prepare ( DbUtils :: substTableAlias ( $sql ));
$stmt -> execute ();
return array ( true );
} catch ( PDOException $e ) {
return array ( false , $e );
}
}
2020-11-19 23:12:39 +01:00
public static function upd_1525_1526 ( $pdo , $prefix , $dbname ) {
try {
self :: insertOrUpdateConfigItem ( $pdo , 'logolocation' , '1' );
self :: execSql ( $pdo , " ALTER TABLE %queueextras% ADD amount INT(3) NULL AFTER extraid " );
self :: execSql ( $pdo , " ALTER TABLE %extras% ADD maxamount INT(3) NULL AFTER price " );
self :: execSql ( $pdo , " UPDATE %extras% SET maxamount='1' " );
return array ( true );
} catch ( PDOException $e ) {
return array ( false , $e );
}
}
2020-11-19 23:10:26 +01:00
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 " ),
2020-11-19 23:10:28 +01:00
" 1.4.7 " => array ( " upd_1407_1408 " , " 1.4.8 " ),
2020-11-19 23:10:30 +01:00
" 1.4.8 " => array ( " upd_1408_1409 " , " 1.4.9 " ),
2020-11-19 23:10:33 +01:00
" 1.4.9 " => array ( " upd_1409_1410 " , " 1.4.10 " ),
2020-11-19 23:10:35 +01:00
" 1.4.10 " => array ( " upd_1410_1411 " , " 1.4.11 " ),
2020-11-19 23:10:37 +01:00
" 1.4.11 " => array ( " upd_1411_1412 " , " 1.4.12 " ),
2020-11-19 23:10:39 +01:00
" 1.4.12 " => array ( " upd_1412_1413 " , " 1.4.13 " ),
2020-11-19 23:10:41 +01:00
" 1.4.13 " => array ( " upd_1413_1414 " , " 1.4.14 " ),
2020-11-19 23:10:43 +01:00
" 1.4.14 " => array ( " upd_1414_1415 " , " 1.4.15 " ),
2020-11-19 23:10:46 +01:00
" 1.4.15 " => array ( " upd_1415_1416 " , " 1.4.16 " ),
2020-11-19 23:10:48 +01:00
" 1.4.16 " => array ( " upd_1416_1417 " , " 1.4.17 " ),
2020-11-19 23:11:27 +01:00
" 1.4.17 " => array ( " upd_1417_1418 " , " 1.4.18 " ),
2020-11-19 23:11:29 +01:00
" 1.4.18 " => array ( " upd_1418_1500 " , " 1.5.0 " ),
2020-11-19 23:11:33 +01:00
" 1.5.0 " => array ( " upd_1500_1501 " , " 1.5.1 " ),
2020-11-19 23:11:36 +01:00
" 1.5.1 " => array ( " upd_1501_1502 " , " 1.5.2 " ),
2020-11-19 23:11:42 +01:00
" 1.5.2 " => array ( " upd_1502_1503 " , " 1.5.3 " ),
2020-11-19 23:11:44 +01:00
" 1.5.3 " => array ( " upd_1503_1504 " , " 1.5.4 " ),
2020-11-19 23:11:47 +01:00
" 1.5.4 " => array ( " upd_1504_1505 " , " 1.5.5 " ),
2020-11-19 23:11:49 +01:00
" 1.5.5 " => array ( " upd_1505_1506 " , " 1.5.6 " ),
2020-11-19 23:11:52 +01:00
" 1.5.6 " => array ( " upd_1506_1507 " , " 1.5.7 " ),
2020-11-19 23:11:54 +01:00
" 1.5.7 " => array ( " upd_1507_1508 " , " 1.5.8 " ),
2020-11-19 23:11:57 +01:00
" 1.5.8 " => array ( " upd_1508_1509 " , " 1.5.9 " ),
2020-11-19 23:12:00 +01:00
" 1.5.9 " => array ( " upd_1509_1510 " , " 1.5.10 " ),
2020-11-19 23:12:02 +01:00
" 1.5.10 " => array ( " upd_1510_1511 " , " 1.5.11 " ),
2020-11-19 23:12:05 +01:00
" 1.5.11 " => array ( " upd_1511_1512 " , " 1.5.12 " ),
2020-11-19 23:12:07 +01:00
" 1.5.12 " => array ( " upd_1512_1513 " , " 1.5.13 " ),
2020-11-19 23:12:10 +01:00
" 1.5.13 " => array ( " upd_1513_1514 " , " 1.5.14 " ),
2020-11-19 23:12:13 +01:00
" 1.5.14 " => array ( " upd_1514_1515 " , " 1.5.15 " ),
2020-11-19 23:12:16 +01:00
" 1.5.15 " => array ( " upd_1515_1516 " , " 1.5.16 " ),
2020-11-19 23:12:18 +01:00
" 1.5.16 " => array ( " upd_1516_1517 " , " 1.5.17 " ),
2020-11-19 23:12:22 +01:00
" 1.5.17 " => array ( " upd_1517_1518 " , " 1.5.18 " ),
2020-11-19 23:12:24 +01:00
" 1.5.18 " => array ( " upd_1518_1519 " , " 1.5.19 " ),
2020-11-19 23:12:27 +01:00
" 1.5.19 " => array ( " upd_1519_1520 " , " 1.5.20 " ),
2020-11-19 23:12:30 +01:00
" 1.5.20 " => array ( " upd_1520_1521 " , " 1.5.21 " ),
2020-11-19 23:12:32 +01:00
" 1.5.21 " => array ( " upd_1521_1522 " , " 1.5.22 " ),
2020-11-19 23:12:35 +01:00
" 1.5.22 " => array ( " upd_1522_1523 " , " 1.5.23 " ),
2020-11-19 23:12:37 +01:00
" 1.5.23 " => array ( " upd_1523_1524 " , " 1.5.24 " ),
2020-11-19 23:12:39 +01:00
" 1.5.24 " => array ( " upd_1524_1525 " , " 1.5.25 " ),
" 1.5.25 " => array ( " upd_1525_1526 " , " 1.5.26 " )
2020-11-19 23:10:26 +01:00
);
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 " );
}
}