2020-11-19 22:47:44 +01:00
< ? php
error_reporting ( E_ALL );
if ( is_readable ( " ../php/config1.php " )) {
require_once ( " ../php/config1.php " );
} else {
require_once ( " ../php/config.php " );
}
require_once ( '../php/utilities/basedb.php' );
2020-11-19 23:00:05 +01:00
require_once ( '../php/utilities/decimaldefs.php' );
2020-11-19 22:47:44 +01:00
require_once ( '../php/admin.php' );
class ConfigWriter {
function getConfigVals () {
if ( ! is_readable ( " ../php/config.php " ) && ( ! is_readable ( " ../php/config1.php " ))) {
echo json_encode ( array ( " status " => " Failed " ));
}
$retArray = array (
" host " => MYSQL_HOST ,
" db " => MYSQL_DB ,
" user " => MYSQL_USER ,
" password " => MYSQL_PASSWORD ,
" tabprefix " => TAB_PREFIX );
echo json_encode ( array ( " status " => " OK " , " result " => $retArray ));
}
}
class InstallAdmin {
var $pdo ;
var $basedb ;
var $timezone ;
function __construct () {
$this -> basedb = new Basedb ();
}
function setPrefix ( $pre ) {
$this -> basedb -> setPrefix ( $pre );
}
function setPdo ( $pdo ) {
$this -> pdo = $pdo ;
}
function setTimeZone ( $zone ) {
$this -> timezone = $zone ;
}
2020-11-19 22:59:47 +01:00
function openDbAndReturnPdo ( $host , $db , $user , $password ) {
$dsn = 'mysql:host=' . $host . ';dbname=' . $db ;
$pdo = null ;
2020-11-19 22:47:44 +01:00
try {
$pdo = new PDO ( $dsn , $user , $password );
$pdo -> setAttribute ( PDO :: ATTR_ERRMODE , PDO :: ERRMODE_EXCEPTION );
}
catch ( PDOException $e ) {
echo 'Verbindungsproblem: ' . $e -> getMessage ();
$pdo = null ;
2020-11-19 22:59:47 +01:00
}
return $pdo ;
2020-11-19 22:47:44 +01:00
}
function checkPhpStatus () {
$extensions = array ( " gd " , " mysqli " , " openssl " , " pdo_mysql " , " PDO " , " session " , " zlib " );
$missing = array ();
$extensions_status = 1 ;
foreach ( $extensions as $anExtension ) {
if ( ! extension_loaded ( $anExtension )) {
$missing [] = $anExtension ;
$extensions_status = 0 ;
}
}
set_time_limit ( 60 * 5 + 1 );
ini_set ( 'session.gc_maxlifetime' , 65535 );
session_set_cookie_params ( 65535 );
$max_execution_status = 1 ;
// 5 minutes = 5*60
if ( ini_get ( 'max_execution_time' ) < ( 5 * 60 )) {
$max_execution_status = 0 ;
}
$session_lifetime_status = 1 ;
if ( ini_get ( 'session.gc_maxlifetime' ) < ( 10 * 60 * 60 )) {
$session_lifetime_status = 0 ;
}
$ret = array ( " extensions_status " => $extensions_status , " missing_extensions " => join ( " , " , $missing ),
" max_execution_status " => $max_execution_status , " max_execution_time " => ini_get ( 'max_execution_time' ),
" session_lifetime_status " => $session_lifetime_status , " session_gc_maxlifetime " => ini_get ( 'session.gc_maxlifetime' )
);
echo json_encode ( $ret );
}
2020-11-19 22:59:47 +01:00
private function getForeignKeyName ( $pdo , $fromtable , $totable , $dbname ) {
$foreignKey = null ;
try {
$sql = " SELECT constraint_name as foreignkey FROM information_schema.REFERENTIAL_CONSTRAINTS WHERE constraint_schema = ' $dbname ' AND table_name = '% $fromtable %' AND REFERENCED_TABLE_NAME='% $totable %' " ;
$stmt = $pdo -> prepare ( $this -> basedb -> resolveTablenamesInSqlString ( $sql ));
$stmt -> execute ();
$result = $stmt -> fetchAll ();
if ( count ( $result ) != 1 ) {
return null ;
}
$foreignKey = $result [ 0 ][ " foreignkey " ];
} catch ( Exception $e ) {
return null ;
}
return $foreignKey ;
}
private function replaceForeignIdKey ( $pdo , $fromtable , $totable , $dbname , $foreignkeyname , $colname ) {
$foreignkeyorig = $this -> getForeignKeyName ( $pdo , $fromtable , $totable , $dbname );
if ( ! is_null ( $foreignkeyorig )) {
$this -> execSql ( $pdo , " alter table % $fromtable % drop foreign key $foreignkeyorig " );
$this -> execSql ( $pdo , " ALTER TABLE % $fromtable % ADD CONSTRAINT $foreignkeyname FOREIGN KEY ( $colname ) REFERENCES % $totable %(id) " );
}
}
private function replaceForeignKeysToBillAndClosing ( $pdo , $dbname ) {
$this -> replaceForeignIdKey ( $pdo , 'billproducts' , 'bill' , $dbname , 'billprodref' , 'billid' );
$this -> replaceForeignIdKey ( $pdo , 'queue' , 'bill' , $dbname , 'queuebillref' , 'billid' );
$this -> replaceForeignIdKey ( $pdo , 'bill' , 'closing' , $dbname , 'billclosingref' , 'closingid' );
$this -> replaceForeignIdKey ( $pdo , 'bill' , 'bill' , $dbname , 'billbillref' , 'ref' );
}
2020-11-19 22:47:44 +01:00
function updateVersion ( $pdo , $version ) {
$setVersion = " update %config% set setting=? where name='version' " ;
$stmt = $pdo -> prepare ( $this -> basedb -> resolveTablenamesInSqlString ( $setVersion ));
$stmt -> execute ( array ( $version ));
$sql = " SELECT id FROM %config% WHERE name=? " ;
$stmt = $pdo -> prepare ( $this -> basedb -> resolveTablenamesInSqlString ( $sql ));
$stmt -> execute ( array ( 'version' ));
$row = $stmt -> fetchObject ();
$sql_insert_histconfig = " INSERT INTO %histconfig% (id,configid,setting) VALUES (NULL,?,?) " ;
$stmt = $pdo -> prepare ( $this -> basedb -> resolveTablenamesInSqlString ( $sql_insert_histconfig ));
$stmt -> execute ( array ( $row -> id , $version ));
$newRefIdForHist = $pdo -> lastInsertId ();
$sql = " SELECT setting FROM %config% WHERE name=? " ;
$stmt = $pdo -> prepare ( $this -> basedb -> resolveTablenamesInSqlString ( $sql ));
$stmt -> execute ( array ( 'timezone' ));
$row = $stmt -> fetchObject ();
date_default_timezone_set ( $row -> setting );
$currentTime = date ( 'Y-m-d H:i:s' );
$sql_insert_hist = " INSERT INTO %hist% (id,date,action,refid) VALUES (NULL,?,?,?) " ;
$stmt_insert_hist = $pdo -> prepare ( $this -> basedb -> resolveTablenamesInSqlString ( $sql_insert_hist ));
$stmt_insert_hist -> execute ( array ( $currentTime , '6' , $newRefIdForHist ));
}
2020-11-19 22:52:55 +01:00
function updateUserTable1022_1023 ( $prefix , $version ) {
2020-11-19 22:47:44 +01:00
$pdo = $this -> pdo ;
2020-11-19 22:52:55 +01:00
try {
if ( $version != " 1.0.22 " ) {
2020-11-19 22:47:44 +01:00
return false ;
}
$adminCl = new Admin ();
DbUtils :: overrulePrefix ( $prefix );
$adminCl -> changeOneConfigDbItem ( $pdo , " timezone " , " Europe/Berlin " , " %config% " , true );
$this -> updateVersion ( $pdo , '1.0.23' );
return true ;
} catch ( PDOException $e ) {
return false ;
}
}
2020-11-19 22:52:55 +01:00
function updateUserTable1023_1024 ( $prefix , $version ) {
2020-11-19 22:47:44 +01:00
$pdo = $this -> pdo ;
try {
2020-11-19 22:52:55 +01:00
if ( $version != " 1.0.23 " ) {
$ret = $this -> updateUserTable1022_1023 ( $prefix , $version );
if ( ! $ret ) { return false ; }
}
2020-11-19 22:47:44 +01:00
$adminCl = new Admin ();
DbUtils :: overrulePrefix ( $prefix );
$sql = " ALTER TABLE %user% ADD right_changeprice INT (1) NULL AFTER right_rating " ;
$stmt = $pdo -> prepare ( DbUtils :: substTableAlias ( $sql ));
$stmt -> execute ();
$sql = " UPDATE %user% SET right_changeprice=? " ;
$stmt = $pdo -> prepare ( DbUtils :: substTableAlias ( $sql ));
$stmt -> execute ( array ( 1 ));
$sql = " ALTER TABLE %user% MODIFY right_changeprice INT (1) NOT NULL " ;
$stmt = $pdo -> prepare ( DbUtils :: substTableAlias ( $sql ));
$stmt -> execute ();
$sql = " ALTER TABLE %histuser% ADD right_changeprice INT (1) NULL AFTER right_rating " ;
$stmt = $pdo -> prepare ( DbUtils :: substTableAlias ( $sql ));
$stmt -> execute ();
$sql = " UPDATE %histuser% SET right_changeprice=? " ;
$stmt = $pdo -> prepare ( DbUtils :: substTableAlias ( $sql ));
$stmt -> execute ( array ( 1 ));
$sql = " ALTER TABLE %histuser% MODIFY right_changeprice INT (1) NOT NULL " ;
$stmt = $pdo -> prepare ( DbUtils :: substTableAlias ( $sql ));
$stmt -> execute ();
$sql = " ALTER TABLE %user% ADD prefertablemap INT(1) NULL AFTER prodbtnsize " ;
$stmt = $pdo -> prepare ( DbUtils :: substTableAlias ( $sql ));
$stmt -> execute ();
$sql = " UPDATE %user% SET prefertablemap=? " ;
$stmt = $pdo -> prepare ( DbUtils :: substTableAlias ( $sql ));
$stmt -> execute ( array ( 1 ));
$this -> basedb -> createTableMapsTable ( $pdo );
$this -> basedb -> createTablePosTable ( $pdo );
$this -> updateVersion ( $pdo , '1.0.24' );
return true ;
} catch ( PDOException $e ) {
return false ;
}
}
2020-11-19 22:52:55 +01:00
function updateUserTable1024_1025 ( $prefix , $version ) {
$ret = true ;
if ( $version != " 1.0.24 " ) {
$ret = $this -> updateUserTable1023_1024 ( $prefix , $version );
if ( ! $ret ) { return false ; }
}
$ret &= $this -> setVersion ( $prefix , '1.0.25' );
return $ret ;
2020-11-19 22:47:44 +01:00
}
2020-11-19 22:52:55 +01:00
function updateUserTable1025_1026 ( $prefix , $version ) {
2020-11-19 22:47:44 +01:00
$pdo = $this -> pdo ;
try {
2020-11-19 22:52:55 +01:00
if ( $version != " 1.0.25 " ) {
$ret = $this -> updateUserTable1024_1025 ( $prefix , $version );
if ( ! $ret ) { return false ; }
}
2020-11-19 22:47:44 +01:00
$adminCl = new Admin ();
DbUtils :: overrulePrefix ( $prefix );
$sql = " ALTER TABLE %queue% DROP payinprogress " ;
$stmt = $pdo -> prepare ( DbUtils :: substTableAlias ( $sql ));
$stmt -> execute ();
$this -> updateVersion ( $pdo , '1.0.26' );
return true ;
} catch ( PDOException $e ) {
return false ;
}
}
2020-11-19 22:52:55 +01:00
function updateUserTable1026_1027 ( $prefix , $version ) {
$ret = true ;
if ( $version != " 1.0.26 " ) {
$ret = $this -> updateUserTable1025_1026 ( $prefix , $version );
if ( ! $ret ) { return false ; }
}
$ret &= $this -> setVersion ( $prefix , '1.0.27' );
return $ret ;
2020-11-19 22:47:44 +01:00
}
2020-11-19 22:52:55 +01:00
function updateUserTable1027_1028 ( $prefix , $version ) {
2020-11-19 22:47:44 +01:00
$pdo = $this -> pdo ;
try {
2020-11-19 22:52:55 +01:00
if ( $version != " 1.0.27 " ) {
$ret = $this -> updateUserTable1026_1027 ( $prefix , $version );
if ( ! $ret ) { return false ; }
}
2020-11-19 22:47:44 +01:00
$adminCl = new Admin ();
DbUtils :: overrulePrefix ( $prefix );
$sql = " ALTER TABLE %queue% MODIFY tablenr INT( 3 ) NULL " ;
$stmt = $pdo -> prepare ( DbUtils :: substTableAlias ( $sql ));
$stmt -> execute ();
$this -> updateVersion ( $pdo , '1.0.28' );
return true ;
} catch ( PDOException $e ) {
return false ;
}
}
2020-11-19 22:52:55 +01:00
function updateUserTable1028_1029 ( $prefix , $version ) {
$ret = true ;
if ( $version != " 1.0.28 " ) {
$ret = $this -> updateUserTable1027_1028 ( $prefix , $version );
if ( ! $ret ) { return false ; }
}
$ret &= $this -> setVersion ( $prefix , '1.0.29' );
return $ret ;
2020-11-19 22:47:44 +01:00
}
2020-11-19 22:52:55 +01:00
function updateUserTable1029_1030 ( $prefix , $version ) {
$ret = true ;
if ( $version != " 1.0.29 " ) {
$ret = $this -> updateUserTable1028_1029 ( $prefix , $version );
if ( ! $ret ) { return false ; }
}
$ret &= $this -> setVersion ( $prefix , '1.0.30' );
return $ret ;
2020-11-19 22:47:44 +01:00
}
2020-11-19 22:52:55 +01:00
function updateUserTable1030_1031 ( $prefix , $version ) {
$ret = true ;
if ( $version != " 1.0.30 " ) {
$ret = $this -> updateUserTable1029_1030 ( $prefix , $version );
if ( ! $ret ) { return false ; }
}
$ret &= $this -> setVersion ( $prefix , '1.0.31' );
return $ret ;
2020-11-19 22:47:44 +01:00
}
2020-11-19 22:52:55 +01:00
function updateUserTable1031_1032 ( $prefix , $version ) {
$ret = true ;
if ( $version != " 1.0.31 " ) {
$ret = $this -> updateUserTable1030_1031 ( $prefix , $version );
if ( ! $ret ) {
return false ;
}
}
$ret &= $this -> setVersion ( $prefix , '1.0.32' );
return $ret ;
2020-11-19 22:47:44 +01:00
}
2020-11-19 22:52:55 +01:00
function updateUserTable1032_1033 ( $prefix , $version ) {
$ret = true ;
if ( $version != " 1.0.32 " ) {
$ret = $this -> updateUserTable1031_1032 ( $prefix , $version );
if ( ! $ret ) {
return false ;
}
}
$ret &= $this -> setVersion ( $prefix , '1.0.33' );
return $ret ;
2020-11-19 22:47:44 +01:00
}
2020-11-19 22:52:55 +01:00
function updateUserTable1033_1034 ( $prefix , $version ) {
$ret = true ;
if ( $version != " 1.0.33 " ) {
$ret = $this -> updateUserTable1032_1033 ( $prefix , $version );
if ( ! $ret ) {
return false ;
}
}
$ret &= $this -> setVersion ( $prefix , '1.0.34' );
return $ret ;
2020-11-19 22:47:44 +01:00
}
2020-11-19 22:52:55 +01:00
function updateUserTable1034_1035 ( $prefix , $version ) {
$ret = true ;
if ( $version != " 1.0.34 " ) {
$ret = $this -> updateUserTable1033_1034 ( $prefix , $version );
if ( ! $ret ) {
return false ;
}
}
$ret &= $this -> setVersion ( $prefix , '1.0.35' );
return $ret ;
2020-11-19 22:47:44 +01:00
}
2020-11-19 22:52:55 +01:00
function updateUserTable1035_1036 ( $prefix , $version ) {
$ret = true ;
if ( $version != " 1.0.35 " ) {
$ret = $this -> updateUserTable1034_1035 ( $prefix , $version );
if ( ! $ret ) {
return false ;
}
}
$ret &= $this -> setVersion ( $prefix , '1.0.36' );
return $ret ;
2020-11-19 22:47:44 +01:00
}
2020-11-19 22:52:55 +01:00
function updateUserTable1036_1037 ( $prefix , $version ) {
$ret = true ;
if ( $version != " 1.0.36 " ) {
$ret = $this -> updateUserTable1035_1036 ( $prefix , $version );
if ( ! $ret ) {
return false ;
}
}
$ret &= $this -> setVersion ( $prefix , '1.0.37' );
return $ret ;
2020-11-19 22:47:44 +01:00
}
2020-11-19 22:52:55 +01:00
function updateUserTable1037_1038 ( $prefix , $version ) {
2020-11-19 22:47:44 +01:00
$pdo = $this -> pdo ;
try {
2020-11-19 22:52:55 +01:00
if ( $version != " 1.0.37 " ) {
$ret = $this -> updateUserTable1036_1037 ( $prefix , $version );
if ( ! $ret ) {
return false ;
}
}
2020-11-19 22:47:44 +01:00
$adminCl = new Admin ();
DbUtils :: overrulePrefix ( $prefix );
$sql = " ALTER TABLE %queue% DROP action " ;
$stmt = $pdo -> prepare ( $this -> basedb -> resolveTablenamesInSqlString ( $sql ));
$stmt -> execute ();
2020-11-19 23:00:05 +01:00
$sql = " ALTER TABLE %queue% ADD tax " . DECIMALSMALL . " NULL AFTER price " ;
2020-11-19 22:47:44 +01:00
$stmt = $pdo -> prepare ( $this -> basedb -> resolveTablenamesInSqlString ( $sql ));
$stmt -> execute ();
$sql = " UPDATE %queue%,%bill% SET %queue%.tax = %bill%.tax WHERE %queue%.billid=%bill%.id " ;
$stmt = $pdo -> prepare ( $this -> basedb -> resolveTablenamesInSqlString ( $sql ));
$stmt -> execute ();
// at this point all queue items have the tax from the bill, if their billid was set - otherwise they keep being NULL
$sql = " UPDATE %queue%,%config% SET %queue%.tax = %config%.setting WHERE %queue%.billid is NULL AND %config%.name='tax' AND %queue%.tablenr is not null; " ;
$stmt = $pdo -> prepare ( $this -> basedb -> resolveTablenamesInSqlString ( $sql ));
$stmt -> execute ();
$sql = " UPDATE %queue%,%config% SET %queue%.tax = %config%.setting WHERE %queue%.billid is NULL AND %config%.name='togotax' AND %queue%.tablenr is null; " ;
$stmt = $pdo -> prepare ( $this -> basedb -> resolveTablenamesInSqlString ( $sql ));
$stmt -> execute ();
// at this point all unpaid products have the normal tax
// allow bill table to have no taxes (tax column is needed for signature of old bills (verifyBill)
$sql = " ALTER TABLE %bill% MODIFY tax decimal(5,2) NULL " ;
$stmt = $pdo -> prepare ( $this -> basedb -> resolveTablenamesInSqlString ( $sql ));
$stmt -> execute ();
2020-11-19 23:00:05 +01:00
$sql = " ALTER TABLE %queue% MODIFY tax " . DECIMALSMALL . " NOT NULL " ;
2020-11-19 22:47:44 +01:00
$stmt = $pdo -> prepare ( $this -> basedb -> resolveTablenamesInSqlString ( $sql ));
$stmt -> execute ();
2020-11-19 23:00:05 +01:00
$sql = " ALTER TABLE %products% ADD tax " . DECIMALSMALL . " NULL AFTER priceC " ;
2020-11-19 22:47:44 +01:00
$stmt = $pdo -> prepare ( $this -> basedb -> resolveTablenamesInSqlString ( $sql ));
$stmt -> execute ();
2020-11-19 23:00:05 +01:00
$sql = " ALTER TABLE %histprod% ADD tax " . DECIMALSMALL . " NULL AFTER priceC " ;
2020-11-19 22:47:44 +01:00
$stmt = $pdo -> prepare ( $this -> basedb -> resolveTablenamesInSqlString ( $sql ));
$stmt -> execute ();
$this -> updateVersion ( $pdo , " 1.0.38 " );
return true ;
} catch ( PDOException $e ) {
return false ;
}
}
2020-11-19 22:52:55 +01:00
function updateUserTable1038_1039 ( $prefix , $version ) {
$ret = true ;
if ( $version != " 1.0.38 " ) {
$ret = $this -> updateUserTable1037_1038 ( $prefix , $version );
if ( ! $ret ) {
return false ;
}
}
$ret &= $this -> setVersion ( $prefix , '1.0.39' );
return $ret ;
2020-11-19 22:47:44 +01:00
}
2020-11-19 22:52:55 +01:00
function updateUserTable1039_1040 ( $prefix , $version ) {
2020-11-19 22:47:44 +01:00
$pdo = $this -> pdo ;
try {
2020-11-19 22:52:55 +01:00
if ( $version != " 1.0.39 " ) {
$ret = $this -> updateUserTable1038_1039 ( $prefix , $version );
if ( ! $ret ) {
return false ;
}
}
2020-11-19 22:47:44 +01:00
$adminCl = new Admin ();
DbUtils :: overrulePrefix ( $prefix );
$sql = " INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL,?,?) " ;
$stmt = $pdo -> prepare ( $this -> basedb -> resolveTablenamesInSqlString ( $sql ));
$stmt -> execute ( array ( 'cancelunpaidcode' , '' ));
$sql = " ALTER TABLE %hist% MODIFY refid INT (10) NULL " ;
$stmt = $pdo -> prepare ( $this -> basedb -> resolveTablenamesInSqlString ( $sql ));
$stmt -> execute ();
$this -> updateVersion ( $pdo , '1.0.40' );
return true ;
} catch ( PDOException $e ) {
return false ;
}
}
2020-11-19 22:52:55 +01:00
function updateUserTable1040_1041 ( $prefix , $version ) {
2020-11-19 22:47:44 +01:00
$pdo = $this -> pdo ;
try {
2020-11-19 22:52:55 +01:00
if ( $version != " 1.0.40 " ) {
$ret = $this -> updateUserTable1039_1040 ( $prefix , $version );
if ( ! $ret ) {
return false ;
}
}
2020-11-19 22:47:44 +01:00
$adminCl = new Admin ();
DbUtils :: overrulePrefix ( $prefix );
$sql = " ALTER TABLE %prodtype% ADD printer INT(2) NULL AFTER kind " ;
$stmt = $pdo -> prepare ( DbUtils :: substTableAlias ( $sql ));
$stmt -> execute ();
$sql = " UPDATE %prodtype% SET printer=? " ;
$stmt = $pdo -> prepare ( DbUtils :: substTableAlias ( $sql ));
$stmt -> execute ( array ( 1 ));
$sql = " UPDATE %printjobs% SET printer=? WHERE (type=1 OR type=2) AND printer is null " ;
$stmt = $pdo -> prepare ( DbUtils :: substTableAlias ( $sql ));
$stmt -> execute ( array ( 1 ));
$this -> updateVersion ( $pdo , '1.0.41' );
return true ;
} catch ( PDOException $e ) {
return false ;
}
}
2020-11-19 22:52:55 +01:00
function updateUserTable1041_1042 ( $prefix , $version ) {
2020-11-19 22:47:44 +01:00
$pdo = $this -> pdo ;
try {
2020-11-19 22:52:55 +01:00
if ( $version != " 1.0.41 " ) {
$ret = $this -> updateUserTable1040_1041 ( $prefix , $version );
if ( ! $ret ) {
return false ;
}
}
2020-11-19 22:47:44 +01:00
$adminCl = new Admin ();
DbUtils :: overrulePrefix ( $prefix );
$this -> updateVersion ( $pdo , '1.0.42' );
return true ;
} catch ( PDOException $e ) {
return false ;
}
}
2020-11-19 22:52:55 +01:00
function updateUserTable1042_1043 ( $prefix , $version ) {
2020-11-19 22:47:44 +01:00
$pdo = $this -> pdo ;
try {
2020-11-19 22:52:55 +01:00
if ( $version != " 1.0.42 " ) {
$ret = $this -> updateUserTable1041_1042 ( $prefix , $version );
if ( ! $ret ) {
return false ;
}
}
2020-11-19 22:47:44 +01:00
$adminCl = new Admin ();
DbUtils :: overrulePrefix ( $prefix );
$sql = " ALTER TABLE %queue% ADD orderuser INT(10) NULL AFTER ordertime " ;
$stmt = $pdo -> prepare ( DbUtils :: substTableAlias ( $sql ));
$stmt -> execute ();
// get the first user - at least the admin should be aways there
$sql = " SELECT id FROM %user% WHERE active=? ORDER BY id LIMIT 1 " ;
$stmt = $pdo -> prepare ( DbUtils :: substTableAlias ( $sql ));
$stmt -> execute ( array ( 1 ));
$row = $stmt -> fetchObject ();
$userid = $row -> id ;
$sql = " UPDATE %queue% SET orderuser=? " ;
$stmt = $pdo -> prepare ( DbUtils :: substTableAlias ( $sql ));
$stmt -> execute ( array ( $userid ));
$sql = " ALTER TABLE %queue% MODIFY orderuser INT(10) NOT NULL " ;
$stmt = $pdo -> prepare ( DbUtils :: substTableAlias ( $sql ));
$stmt -> execute ();
$sql = " ALTER TABLE %room% ADD printer INT(2) NULL AFTER roomname " ;
$stmt = $pdo -> prepare ( DbUtils :: substTableAlias ( $sql ));
$stmt -> execute ();
$this -> updateVersion ( $pdo , '1.0.43' );
return true ;
} catch ( PDOException $e ) {
return false ;
}
}
2020-11-19 22:52:55 +01:00
function updateUserTable1043_1100 ( $prefix , $version ) {
$ret = true ;
if ( $version != " 1.0.43 " ) {
$ret = $this -> updateUserTable1042_1043 ( $prefix , $version );
if ( ! $ret ) {
return false ;
}
}
$ret &= $this -> setVersion ( $prefix , '1.1.0' );
return $ret ;
2020-11-19 22:47:44 +01:00
}
2020-11-19 22:52:55 +01:00
function updateUserTable1100_1101 ( $prefix , $version ) {
2020-11-19 22:48:24 +01:00
$pdo = $this -> pdo ;
try {
2020-11-19 22:52:55 +01:00
if ( $version != " 1.1.0 " ) {
$ret = $this -> updateUserTable1043_1100 ( $prefix , $version );
if ( ! $ret ) {
return false ;
}
}
2020-11-19 22:48:24 +01:00
$adminCl = new Admin ();
DbUtils :: overrulePrefix ( $prefix );
$sql = " ALTER TABLE %user% ADD keeptypelevel INT(1) NULL AFTER prefertablemap " ;
$stmt = $pdo -> prepare ( DbUtils :: substTableAlias ( $sql ));
$stmt -> execute ();
$sql = " UPDATE %user% SET keeptypelevel=? " ;
$stmt = $pdo -> prepare ( DbUtils :: substTableAlias ( $sql ));
2020-11-19 22:55:20 +01:00
$stmt -> execute ( array ( 0 ));
2020-11-19 22:48:24 +01:00
$sql = " ALTER TABLE %user% MODIFY keeptypelevel INT(1) NOT NULL " ;
$stmt = $pdo -> prepare ( DbUtils :: substTableAlias ( $sql ));
$stmt -> execute ();
$sql = " INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL,?,?) " ;
$stmt = $pdo -> prepare ( $this -> basedb -> resolveTablenamesInSqlString ( $sql ));
$stmt -> execute ( array ( 'bigfontworkreceipt' , '0' ));
$this -> updateVersion ( $pdo , '1.1.1' );
return true ;
} catch ( PDOException $e ) {
return false ;
}
}
2020-11-19 22:52:55 +01:00
function updateUserTable1101_1102 ( $prefix , $version ) {
2020-11-19 22:50:09 +01:00
$pdo = $this -> pdo ;
try {
2020-11-19 22:52:55 +01:00
if ( $version != " 1.1.1 " ) {
$ret = $this -> updateUserTable1100_1101 ( $prefix , $version );
if ( ! $ret ) {
return false ;
}
}
2020-11-19 22:50:09 +01:00
$adminCl = new Admin ();
DbUtils :: overrulePrefix ( $prefix );
$sql = " ALTER TABLE %queue% ADD isclosed INT(1) NULL AFTER workprinted " ;
$stmt = $pdo -> prepare ( DbUtils :: substTableAlias ( $sql ));
$stmt -> execute ();
$sql = " select max(closingdate) as lastdate from %closing% " ;
$stmt = $pdo -> prepare ( DbUtils :: substTableAlias ( $sql ));
$stmt -> execute ();
$row = $stmt -> fetchObject ();
$lastclosingdate = $row -> lastdate ;
if ( ! is_null ( $lastclosingdate )) {
$sql = " UPDATE %queue% SET isclosed=? WHERE ordertime <= ? " ;
$stmt = $pdo -> prepare ( DbUtils :: substTableAlias ( $sql ));
$stmt -> execute ( array ( 1 , $lastclosingdate ));
}
$this -> updateVersion ( $pdo , '1.1.2' );
return true ;
} catch ( PDOException $e ) {
return false ;
}
}
2020-11-19 22:52:55 +01:00
function updateUserTable1102_1103 ( $prefix , $version ) {
$ret = true ;
if ( $version != " 1.1.2 " ) {
$ret = $this -> updateUserTable1101_1102 ( $prefix , $version );
if ( ! $ret ) {
return false ;
}
}
$ret &= $this -> setVersion ( $prefix , '1.1.3' );
return $ret ;
2020-11-19 22:51:21 +01:00
}
2020-11-19 22:52:55 +01:00
function updateUserTable1103_1104 ( $prefix , $version ) {
$ret = true ;
if ( $version != " 1.1.3 " ) {
$ret = $this -> updateUserTable1102_1103 ( $prefix , $version );
if ( ! $ret ) {
return false ;
}
}
$ret &= $this -> setVersion ( $prefix , '1.1.4' );
return $ret ;
2020-11-19 22:51:46 +01:00
}
2020-11-19 22:52:55 +01:00
function updateUserTable1104_1105 ( $prefix , $version ) {
2020-11-19 22:52:25 +01:00
$pdo = $this -> pdo ;
try {
2020-11-19 22:52:55 +01:00
if ( $version != " 1.1.4 " ) {
$ret = $this -> updateUserTable1103_1104 ( $prefix , $version );
if ( ! $ret ) {
return false ;
}
}
2020-11-19 22:52:25 +01:00
$adminCl = new Admin ();
DbUtils :: overrulePrefix ( $prefix );
$sql = " ALTER TABLE %bill% ADD reason VARCHAR ( 150 ) NULL AFTER host " ;
$stmt = $pdo -> prepare ( DbUtils :: substTableAlias ( $sql ));
$stmt -> execute ();
$sql = " INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL,?,?) " ;
$stmt = $pdo -> prepare ( DbUtils :: substTableAlias ( $sql ));
$stmt -> execute ( array ( 'prominentsearch' , '0' ));
$this -> updateVersion ( $pdo , '1.1.5' );
return true ;
} catch ( PDOException $e ) {
return false ;
}
}
2020-11-19 22:52:55 +01:00
function updateUserTable1105_1106 ( $prefix , $version ) {
$ret = true ;
if ( $version != " 1.1.5 " ) {
$ret = $this -> updateUserTable1104_1105 ( $prefix , $version );
if ( ! $ret ) {
return false ;
}
}
$ret &= $this -> setVersion ( $prefix , '1.1.6' );
return $ret ;
}
function updateUserTable1106_1107 ( $prefix , $version ) {
$ret = true ;
if ( $version != " 1.1.6 " ) {
$ret = $this -> updateUserTable1105_1106 ( $prefix , $version );
if ( ! $ret ) {
return false ;
}
}
$ret &= $this -> setVersion ( $prefix , '1.1.7' );
return $ret ;
2020-11-19 22:52:43 +01:00
}
2020-11-19 22:53:18 +01:00
function updateUserTable1107_1108 ( $prefix , $version ) {
$ret = true ;
if ( $version != " 1.1.7 " ) {
$ret = $this -> updateUserTable1106_1107 ( $prefix , $version );
if ( ! $ret ) {
return false ;
}
}
$ret &= $this -> setVersion ( $prefix , '1.1.8' );
return $ret ;
}
2020-11-19 22:53:50 +01:00
function updateUserTable1108_1109 ( $prefix , $version ) {
$pdo = $this -> pdo ;
try {
if ( $version != " 1.1.8 " ) {
$ret = $this -> updateUserTable1107_1108 ( $prefix , $version );
if ( ! $ret ) {
return false ;
}
}
$adminCl = new Admin ();
DbUtils :: overrulePrefix ( $prefix );
$sql = " INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL,?,?) " ;
$stmt = $pdo -> prepare ( DbUtils :: substTableAlias ( $sql ));
$stmt -> execute ( array ( 'groupworkitems' , '1' ));
$sql = " ALTER TABLE %user% ADD extrasapplybtnpos INT(1) NULL AFTER keeptypelevel " ;
$stmt = $pdo -> prepare ( DbUtils :: substTableAlias ( $sql ));
$stmt -> execute ();
$sql = " UPDATE %user% SET extrasapplybtnpos=? " ;
$stmt = $pdo -> prepare ( DbUtils :: substTableAlias ( $sql ));
$stmt -> execute ( array ( 1 ));
$sql = " ALTER TABLE %user% MODIFY extrasapplybtnpos INT(1) NOT NULL " ;
$stmt = $pdo -> prepare ( DbUtils :: substTableAlias ( $sql ));
$stmt -> execute ();
$this -> updateVersion ( $pdo , '1.1.9' );
return true ;
} catch ( PDOException $e ) {
return false ;
}
}
2020-11-19 22:54:12 +01:00
function updateUserTable1109_1110 ( $prefix , $version ) {
$ret = true ;
if ( $version != " 1.1.9 " ) {
$ret = $this -> updateUserTable1108_1109 ( $prefix , $version );
if ( ! $ret ) {
return false ;
}
}
$ret &= $this -> setVersion ( $prefix , '1.1.10' );
return $ret ;
}
2020-11-19 22:54:51 +01:00
function updateUserTable1110_1111 ( $prefix , $version ) {
$ret = true ;
if ( $version != " 1.1.10 " ) {
$ret = $this -> updateUserTable1109_1110 ( $prefix , $version );
if ( ! $ret ) {
return false ;
}
}
$ret &= $this -> setVersion ( $prefix , '1.1.11' );
return $ret ;
}
2020-11-19 22:55:09 +01:00
function updateUserTable1111_1112 ( $prefix , $version ) {
$pdo = $this -> pdo ;
try {
if ( $version != " 1.1.11 " ) {
$ret = $this -> updateUserTable1110_1111 ( $prefix , $version );
if ( ! $ret ) {
return false ;
}
}
$adminCl = new Admin ();
DbUtils :: overrulePrefix ( $prefix );
$sql = " ALTER TABLE %room% ADD `abbreviation` VARCHAR (10) NULL AFTER roomname " ;
$stmt = $pdo -> prepare ( DbUtils :: substTableAlias ( $sql ));
$stmt -> execute ();
$this -> updateVersion ( $pdo , '1.1.12' );
return true ;
} catch ( PDOException $e ) {
return false ;
}
}
2020-11-19 22:55:20 +01:00
function updateUserTable1112_1113 ( $prefix , $version ) {
$pdo = $this -> pdo ;
try {
if ( $version != " 1.1.12 " ) {
$ret = $this -> updateUserTable1111_1112 ( $prefix , $version );
if ( ! $ret ) {
return false ;
}
}
$adminCl = new Admin ();
DbUtils :: overrulePrefix ( $prefix );
$sql = " ALTER TABLE %queue% ADD pricechanged INT(1) NULL AFTER anoption " ;
$stmt = $pdo -> prepare ( DbUtils :: substTableAlias ( $sql ));
$stmt -> execute ();
$sql = " ALTER TABLE %queue% ADD togo INT(1) NULL AFTER pricechanged " ;
$stmt = $pdo -> prepare ( DbUtils :: substTableAlias ( $sql ));
$stmt -> execute ();
$sql = " UPDATE %queue% SET pricechanged=?,togo=? " ;
$stmt = $pdo -> prepare ( DbUtils :: substTableAlias ( $sql ));
$stmt -> execute ( array ( 0 , 0 ));
$this -> updateVersion ( $pdo , '1.1.13' );
return true ;
} catch ( PDOException $e ) {
return false ;
}
}
2020-11-19 22:55:30 +01:00
function updateUserTable1113_1114 ( $prefix , $version ) {
$ret = true ;
if ( $version != " 1.1.13 " ) {
$ret = $this -> updateUserTable1112_1113 ( $prefix , $version );
if ( ! $ret ) {
return false ;
}
}
$ret &= $this -> setVersion ( $prefix , '1.1.14' );
return $ret ;
}
2020-11-19 22:55:43 +01:00
function updateUserTable1114_1115 ( $prefix , $version ) {
$ret = true ;
if ( $version != " 1.1.14 " ) {
$ret = $this -> updateUserTable1113_1114 ( $prefix , $version );
if ( ! $ret ) {
return false ;
}
}
$ret &= $this -> setVersion ( $prefix , '1.1.15' );
return $ret ;
}
2020-11-19 22:55:55 +01:00
function updateUserTable1115_1116 ( $prefix , $version ) {
$ret = true ;
if ( $version != " 1.1.15 " ) {
$ret = $this -> updateUserTable1114_1115 ( $prefix , $version );
if ( ! $ret ) {
return false ;
}
}
$ret &= $this -> setVersion ( $prefix , '1.1.16' );
return $ret ;
}
2020-11-19 22:56:12 +01:00
function updateUserTable1116_1117 ( $prefix , $version ) {
$ret = true ;
if ( $version != " 1.1.16 " ) {
$ret = $this -> updateUserTable1115_1116 ( $prefix , $version );
if ( ! $ret ) {
return false ;
}
}
$ret &= $this -> setVersion ( $prefix , '1.1.17' );
return $ret ;
}
2020-11-19 22:56:23 +01:00
function updateUserTable1117_1118 ( $prefix , $version ) {
$ret = true ;
if ( $version != " 1.1.17 " ) {
$ret = $this -> updateUserTable1116_1117 ( $prefix , $version );
if ( ! $ret ) {
return false ;
}
}
$ret &= $this -> setVersion ( $prefix , '1.1.18' );
return $ret ;
}
2020-11-19 22:56:38 +01:00
function updateUserTable1118_1119 ( $prefix , $version ) {
$ret = true ;
if ( $version != " 1.1.18 " ) {
$ret = $this -> updateUserTable1117_1118 ( $prefix , $version );
if ( ! $ret ) {
return false ;
}
}
$ret &= $this -> setVersion ( $prefix , '1.1.19' );
return $ret ;
}
2020-11-19 22:58:12 +01:00
function updateUserTable1119_1120 ( $prefix , $version ) {
$ret = true ;
if ( $version != " 1.1.19 " ) {
$ret = $this -> updateUserTable1118_1119 ( $prefix , $version );
if ( ! $ret ) {
return false ;
}
}
$ret &= $this -> setVersion ( $prefix , '1.1.20' );
return $ret ;
}
2020-11-19 22:58:17 +01:00
function updateUserTable1120_1121 ( $prefix , $version ) {
$pdo = $this -> pdo ;
try {
if ( $version != " 1.1.20 " ) {
$ret = $this -> updateUserTable1119_1120 ( $prefix , $version );
if ( ! $ret ) {
return false ;
}
}
$adminCl = new Admin ();
DbUtils :: overrulePrefix ( $prefix );
$sql = " INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL,?,?) " ;
$stmt = $pdo -> prepare ( $this -> basedb -> resolveTablenamesInSqlString ( $sql ));
$stmt -> execute ( array ( 'discount1' , '50' ));
$stmt -> execute ( array ( 'discount2' , '20' ));
$stmt -> execute ( array ( 'discount3' , '10' ));
$stmt -> execute ( array ( 'austria' , '0' ));
$this -> updateVersion ( $pdo , '1.1.21' );
return true ;
} catch ( PDOException $e ) {
return false ;
}
}
2020-11-19 22:58:20 +01:00
function updateUserTable1121_1122 ( $prefix , $version ) {
$pdo = $this -> pdo ;
try {
if ( $version != " 1.1.21 " ) {
$ret = $this -> updateUserTable1120_1121 ( $prefix , $version );
if ( ! $ret ) {
return false ;
}
}
$adminCl = new Admin ();
DbUtils :: overrulePrefix ( $prefix );
$sql = " INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL,?,?) " ;
$stmt = $pdo -> prepare ( $this -> basedb -> resolveTablenamesInSqlString ( $sql ));
$stmt -> execute ( array ( 'paydeskid' , 'OrderSprinter-1' ));
$stmt -> execute ( array ( 'aeskey' , '0102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f20' ));
$stmt -> execute ( array ( 'certificatesn' , '1234567' ));
2020-11-19 23:00:05 +01:00
$sql = " ALTER TABLE %bill% ADD prevbrutto " . DECIMALBIG . " NULL AFTER netto " ;
2020-11-19 22:58:20 +01:00
$stmt = $pdo -> prepare ( DbUtils :: substTableAlias ( $sql ));
$stmt -> execute ();
2020-11-19 23:00:05 +01:00
$sql = " ALTER TABLE %bill% ADD prevnetto " . DECIMALBIG . " NULL AFTER prevbrutto " ;
2020-11-19 22:58:20 +01:00
$stmt = $pdo -> prepare ( DbUtils :: substTableAlias ( $sql ));
$stmt -> execute ();
$sql = " SELECT IFNULL(MAX(id), 0) as maxid FROM %bill% " ;
$stmt = $pdo -> prepare ( DbUtils :: substTableAlias ( $sql ));
$stmt -> execute ();
$row = $stmt -> fetchObject ();
$maxid = $row -> maxid ;
$sql = " UPDATE %bill% SET prevbrutto=?, prevnetto=? WHERE id=? " ;
$stmt = $pdo -> prepare ( DbUtils :: substTableAlias ( $sql ));
$stmt -> execute ( array ( 0 , 0 , 1 ));
for ( $i = 2 ; $i <= $maxid ; $i ++ ) {
$sql = " SELECT SUM(brutto) as sumbrutto, SUM(netto) as sumnetto FROM %bill% WHERE id<? " ;
$stmt = $pdo -> prepare ( DbUtils :: substTableAlias ( $sql ));
$stmt -> execute ( array ( $i ));
$row = $stmt -> fetchObject ();
$sql = " UPDATE %bill% SET prevbrutto=?, prevnetto=? WHERE id=? " ;
$stmt = $pdo -> prepare ( DbUtils :: substTableAlias ( $sql ));
$stmt -> execute ( array ( $row -> sumbrutto , $row -> sumnetto , $i ));
}
$this -> updateVersion ( $pdo , '1.1.22' );
return true ;
} catch ( PDOException $e ) {
return false ;
}
}
2020-11-19 22:58:23 +01:00
function updateUserTable1122_1123 ( $prefix , $version ) {
$pdo = $this -> pdo ;
try {
if ( $version != " 1.1.22 " ) {
$ret = $this -> updateUserTable1121_1122 ( $prefix , $version );
if ( ! $ret ) {
return false ;
}
}
$adminCl = new Admin ();
DbUtils :: overrulePrefix ( $prefix );
$sql = " ALTER TABLE %work% MODIFY signature blob NULL " ;
$stmt = $pdo -> prepare ( DbUtils :: substTableAlias ( $sql ));
$stmt -> execute ();
$sql = " ALTER TABLE %bill% MODIFY signature blob NULL " ;
$stmt = $pdo -> prepare ( DbUtils :: substTableAlias ( $sql ));
$stmt -> execute ();
$sql = " ALTER TABLE %closing% MODIFY signature blob NULL " ;
$stmt = $pdo -> prepare ( DbUtils :: substTableAlias ( $sql ));
$stmt -> execute ();
$this -> updateVersion ( $pdo , '1.1.23' );
return true ;
} catch ( PDOException $e ) {
return false ;
}
}
2020-11-19 22:58:27 +01:00
function updateUserTable1123_1124 ( $prefix , $version ) {
$ret = true ;
if ( $version != " 1.1.23 " ) {
$ret = $this -> updateUserTable1122_1123 ( $prefix , $version );
if ( ! $ret ) {
return false ;
}
}
$ret &= $this -> setVersion ( $prefix , '1.1.24' );
return $ret ;
}
2020-11-19 22:58:30 +01:00
function updateUserTable1124_1125 ( $prefix , $version ) {
$ret = true ;
if ( $version != " 1.1.24 " ) {
$ret = $this -> updateUserTable1123_1124 ( $prefix , $version );
if ( ! $ret ) {
return false ;
}
}
$ret &= $this -> setVersion ( $prefix , '1.1.25' );
return $ret ;
}
2020-11-19 22:58:33 +01:00
function updateUserTable1125_1126 ( $prefix , $version ) {
$ret = true ;
if ( $version != " 1.1.25 " ) {
$ret = $this -> updateUserTable1124_1125 ( $prefix , $version );
if ( ! $ret ) {
return false ;
}
}
$ret &= $this -> setVersion ( $prefix , '1.1.26' );
return $ret ;
}
2020-11-19 22:58:36 +01:00
function updateUserTable1126_1127 ( $prefix , $version ) {
$pdo = $this -> pdo ;
try {
if ( $version != " 1.1.26 " ) {
$ret = $this -> updateUserTable1125_1126 ( $prefix , $version );
if ( ! $ret ) {
return false ;
}
}
$adminCl = new Admin ();
DbUtils :: overrulePrefix ( $prefix );
$sql = " INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL,?,?) " ;
$stmt = $pdo -> prepare ( $this -> basedb -> resolveTablenamesInSqlString ( $sql ));
$stmt -> execute ( array ( 'digigopaysetready' , '1' ));
$this -> updateVersion ( $pdo , '1.1.27' );
return true ;
} catch ( PDOException $e ) {
return false ;
}
}
2020-11-19 22:58:39 +01:00
function updateUserTable1127_1128 ( $prefix , $version ) {
$pdo = $this -> pdo ;
try {
if ( $version != " 1.1.27 " ) {
$ret = $this -> updateUserTable1126_1127 ( $prefix , $version );
if ( ! $ret ) {
return false ;
}
}
$adminCl = new Admin ();
DbUtils :: overrulePrefix ( $prefix );
2020-11-19 22:59:54 +01:00
$rect = $this -> getDefaultCustomRecTemplate ();
2020-11-19 22:58:39 +01:00
$sql = " INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL,?,?) " ;
$stmt = $pdo -> prepare ( $this -> basedb -> resolveTablenamesInSqlString ( $sql ));
$stmt -> execute ( array ( 'rectemplate' , $rect ));
$this -> updateVersion ( $pdo , '1.1.28' );
return true ;
} catch ( PDOException $e ) {
return false ;
}
}
2020-11-19 22:58:42 +01:00
function updateUserTable1128_1129 ( $prefix , $version ) {
$pdo = $this -> pdo ;
try {
if ( $version != " 1.1.28 " ) {
2020-11-19 22:58:45 +01:00
$ret = $this -> updateUserTable1127_1128 ( $prefix , $version );
2020-11-19 22:58:42 +01:00
if ( ! $ret ) {
return false ;
}
}
$adminCl = new Admin ();
DbUtils :: overrulePrefix ( $prefix );
$sql = " INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL,?,?) " ;
$stmt = $pdo -> prepare ( $this -> basedb -> resolveTablenamesInSqlString ( $sql ));
$stmt -> execute ( array ( 'waitergopayprint' , 0 ));
$this -> updateVersion ( $pdo , '1.1.29' );
return true ;
} catch ( PDOException $e ) {
return false ;
}
}
2020-11-19 22:58:45 +01:00
function updateUserTable1129_1130 ( $prefix , $version ) {
$pdo = $this -> pdo ;
try {
if ( $version != " 1.1.29 " ) {
$ret = $this -> updateUserTable1128_1129 ( $prefix , $version );
if ( ! $ret ) {
return false ;
}
}
$adminCl = new Admin ();
DbUtils :: overrulePrefix ( $prefix );
// Bugfix - the update chain was ignoring the step to 1.1.27
$sql = " select count(id) as reccount from %config% where name='rectemplate' " ;
$stmt = $pdo -> prepare ( $this -> basedb -> resolveTablenamesInSqlString ( $sql ));
$stmt -> execute ();
$row = $stmt -> fetchObject ();
if ( intval ( $row -> reccount ) == 0 ) {
$rect = $this -> getDefaultCustomRecTemplate ();
$sql = " INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL,?,?) " ;
$stmt = $pdo -> prepare ( $this -> basedb -> resolveTablenamesInSqlString ( $sql ));
$stmt -> execute ( array ( 'rectemplate' , $rect ));
}
$this -> updateVersion ( $pdo , '1.1.30' );
return true ;
} catch ( PDOException $e ) {
return false ;
}
}
2020-11-19 22:59:47 +01:00
private function execSql ( $pdo , $sql ) {
$stmt = $pdo -> prepare ( $this -> basedb -> resolveTablenamesInSqlString ( $sql ));
$stmt -> execute ();
}
function updateUserTable1130_1200 ( $prefix , $version , $dbname ) {
$pdo = $this -> pdo ;
try {
if ( $version != " 1.1.30 " ) {
$ret = $this -> updateUserTable1129_1130 ( $prefix , $version );
if ( ! $ret ) {
return false ;
}
}
DbUtils :: overrulePrefix ( $prefix );
$this -> replaceForeignKeysToBillAndClosing ( $pdo , $dbname );
$this -> execSql ( $pdo , " ALTER TABLE %user% ADD right_closing INT (1) NULL AFTER right_products " );
$this -> execSql ( $pdo , " ALTER TABLE %histuser% ADD right_closing INT (1) NULL AFTER right_products " );
$this -> execSql ( $pdo , " UPDATE %user% SET right_closing=right_manager " );
$this -> execSql ( $pdo , " UPDATE %histuser% SET right_closing=right_manager " );
$this -> execSql ( $pdo , " ALTER TABLE %user% MODIFY right_closing INT(1) NOT NULL " );
$this -> execSql ( $pdo , " ALTER TABLE %histuser% MODIFY right_closing INT(1) NOT NULL " );
$this -> updateVersion ( $pdo , '1.2.0' );
return true ;
} catch ( PDOException $e ) {
return false ;
}
2020-11-19 22:59:50 +01:00
}
function updateUserTable1200_1201 ( $prefix , $version , $dbname ) {
$pdo = $this -> pdo ;
try {
if ( $version != " 1.2.0 " ) {
$ret = $this -> updateUserTable1130_1200 ( $prefix , $version , $dbname );
if ( ! $ret ) {
return false ;
}
}
DbUtils :: overrulePrefix ( $prefix );
$sql = " INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL,?,?) " ;
$stmt = $pdo -> prepare ( $this -> basedb -> resolveTablenamesInSqlString ( $sql ));
$stmt -> execute ( array ( 'addreceipttoprinter' , null ));
$this -> updateVersion ( $pdo , '1.2.1' );
return true ;
} catch ( PDOException $e ) {
return false ;
}
2020-11-19 22:59:54 +01:00
}
function updateUserTable1201_1202 ( $prefix , $version , $dbname ) {
$pdo = $this -> pdo ;
try {
if ( $version != " 1.2.1 " ) {
$ret = $this -> updateUserTable1200_1201 ( $prefix , $version , $dbname );
if ( ! $ret ) {
return false ;
}
}
DbUtils :: overrulePrefix ( $prefix );
$foodTemplate = $this -> getDefaultWorkTemplateFood ();
$sql = " INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL,?,?) " ;
$stmt = $pdo -> prepare ( $this -> basedb -> resolveTablenamesInSqlString ( $sql ));
$stmt -> execute ( array ( 'foodtemplate' , $foodTemplate ));
$drinkTemplate = $this -> getDefaultWorkTemplateDrinks ();
$sql = " INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL,?,?) " ;
$stmt = $pdo -> prepare ( $this -> basedb -> resolveTablenamesInSqlString ( $sql ));
$stmt -> execute ( array ( 'drinktemplate' , $drinkTemplate ));
$this -> updateVersion ( $pdo , '1.2.2' );
return true ;
} catch ( PDOException $e ) {
return false ;
}
2020-11-19 22:59:57 +01:00
}
function updateUserTable1202_1203 ( $prefix , $version , $dbname ) {
$pdo = $this -> pdo ;
try {
if ( $version != " 1.2.2 " ) {
$ret = $this -> updateUserTable1201_1202 ( $prefix , $version , $dbname );
if ( ! $ret ) {
return false ;
}
}
DbUtils :: overrulePrefix ( $prefix );
$this -> updateVersion ( $pdo , '1.2.3' );
return true ;
} catch ( PDOException $e ) {
return false ;
}
2020-11-19 22:59:47 +01:00
}
2020-11-19 23:00:01 +01:00
function updateUserTable1203_1204 ( $prefix , $version , $dbname ) {
$pdo = $this -> pdo ;
try {
if ( $version != " 1.2.3 " ) {
$ret = $this -> updateUserTable1202_1203 ( $prefix , $version , $dbname );
if ( ! $ret ) {
return false ;
}
}
DbUtils :: overrulePrefix ( $prefix );
$this -> updateVersion ( $pdo , '1.2.4' );
return true ;
} catch ( PDOException $e ) {
return false ;
}
2020-11-19 23:00:05 +01:00
}
function updateUserTable1204_1205 ( $prefix , $version , $dbname ) {
$pdo = $this -> pdo ;
try {
if ( $version != " 1.2.4 " ) {
$ret = $this -> updateUserTable1203_1204 ( $prefix , $version , $dbname );
if ( ! $ret ) {
return false ;
}
}
DbUtils :: overrulePrefix ( $prefix );
$sql = " INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL,?,?) " ;
$stmt = $pdo -> prepare ( $this -> basedb -> resolveTablenamesInSqlString ( $sql ));
$stmt -> execute ( array ( 'oneprodworkreceipts' , 0 ));
$stmt -> execute ( array ( 'digiprintwork' , 1 ));
$this -> updateVersion ( $pdo , '1.2.5' );
return true ;
} catch ( PDOException $e ) {
return false ;
}
2020-11-19 23:00:09 +01:00
}
function updateUserTable1205_1206 ( $prefix , $version , $dbname ) {
$pdo = $this -> pdo ;
try {
if ( $version != " 1.2.5 " ) {
$ret = $this -> updateUserTable1204_1205 ( $prefix , $version , $dbname );
if ( ! $ret ) {
return false ;
}
}
DbUtils :: overrulePrefix ( $prefix );
$this -> updateVersion ( $pdo , '1.2.6' );
return true ;
} catch ( PDOException $e ) {
return false ;
}
2020-11-19 23:00:14 +01:00
}
function updateUserTable1206_1207 ( $prefix , $version , $dbname ) {
$pdo = $this -> pdo ;
try {
if ( $version != " 1.2.6 " ) {
$ret = $this -> updateUserTable1205_1206 ( $prefix , $version , $dbname );
if ( ! $ret ) {
return false ;
}
}
DbUtils :: overrulePrefix ( $prefix );
$this -> updateVersion ( $pdo , '1.2.7' );
return true ;
} catch ( PDOException $e ) {
return false ;
}
2020-11-19 23:00:18 +01:00
}
function updateUserTable1207_1208 ( $prefix , $version , $dbname ) {
$pdo = $this -> pdo ;
try {
if ( $version != " 1.2.7 " ) {
$ret = $this -> updateUserTable1206_1207 ( $prefix , $version , $dbname );
if ( ! $ret ) {
return false ;
}
}
DbUtils :: overrulePrefix ( $prefix );
$this -> basedb -> createLogTable ( $pdo );
$this -> updateVersion ( $pdo , '1.2.8' );
return true ;
} catch ( PDOException $e ) {
return false ;
}
2020-11-19 23:00:22 +01:00
}
function updateUserTable1208_1209 ( $prefix , $version , $dbname ) {
$pdo = $this -> pdo ;
try {
if ( $version != " 1.2.8 " ) {
$ret = $this -> updateUserTable1207_1208 ( $prefix , $version , $dbname );
if ( ! $ret ) {
return false ;
}
}
DbUtils :: overrulePrefix ( $prefix );
$this -> updateVersion ( $pdo , '1.2.9' );
return true ;
} catch ( PDOException $e ) {
return false ;
}
2020-11-19 23:00:01 +01:00
}
2020-11-19 23:00:27 +01:00
function updateUserTable1209_1210 ( $prefix , $version , $dbname ) {
$pdo = $this -> pdo ;
try {
if ( $version != " 1.2.9 " ) {
$ret = $this -> updateUserTable1208_1209 ( $prefix , $version , $dbname );
if ( ! $ret ) {
return false ;
}
}
DbUtils :: overrulePrefix ( $prefix );
$this -> updateVersion ( $pdo , '1.2.10' );
return true ;
} catch ( PDOException $e ) {
return false ;
}
}
2020-11-19 23:00:31 +01:00
function updateUserTable1210_1211 ( $prefix , $version , $dbname ) {
$pdo = $this -> pdo ;
try {
if ( $version != " 1.2.10 " ) {
$ret = $this -> updateUserTable1209_1210 ( $prefix , $version , $dbname );
if ( ! $ret ) {
return false ;
}
}
DbUtils :: overrulePrefix ( $prefix );
$sql = " INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL,?,?) " ;
$stmt = $pdo -> prepare ( $this -> basedb -> resolveTablenamesInSqlString ( $sql ));
$stmt -> execute ( array ( 'taxaustrianormal' , '20.0' ));
$stmt -> execute ( array ( 'taxaustriaerm1' , '10.0' ));
$stmt -> execute ( array ( 'taxaustriaerm2' , '13.0' ));
$stmt -> execute ( array ( 'taxaustriaspecial' , '19.0' ));
$this -> execSql ( $pdo , " ALTER TABLE %products% ADD taxaustria INT (1) NULL AFTER tax " );
$this -> execSql ( $pdo , " ALTER TABLE %products% ADD amount INT (5) NULL AFTER taxaustria " );
$this -> execSql ( $pdo , " ALTER TABLE %histprod% ADD taxaustria INT (1) NULL AFTER tax " );
$this -> execSql ( $pdo , " ALTER TABLE %queue% ADD taxaustria INT (1) NULL AFTER tax " );
$this -> updateVersion ( $pdo , '1.2.11' );
return true ;
} catch ( PDOException $e ) {
return false ;
}
}
2020-11-19 23:00:35 +01:00
function updateUserTable1211_1212 ( $prefix , $version , $dbname ) {
$pdo = $this -> pdo ;
try {
if ( $version != " 1.2.11 " ) {
$ret = $this -> updateUserTable1210_1211 ( $prefix , $version , $dbname );
if ( ! $ret ) {
return false ;
}
}
DbUtils :: overrulePrefix ( $prefix );
$this -> execSql ( $pdo , " ALTER TABLE %histprod% MODIFY extras VARCHAR(300) NULL " );
$this -> updateVersion ( $pdo , '1.2.12' );
return true ;
} catch ( PDOException $e ) {
return false ;
}
}
2020-11-19 22:47:44 +01:00
function setVersion ( $prefix , $theVersion ) {
$pdo = $this -> pdo ;
try {
$adminCl = new Admin ();
DbUtils :: overrulePrefix ( $prefix );
$this -> updateVersion ( $pdo , $theVersion );
return true ;
} catch ( PDOException $e ) {
return false ;
}
}
function signLastBillId () {
$pdo = $this -> pdo ;
$this -> basedb -> signLastBillid ( $pdo );
}
2020-11-19 22:58:45 +01:00
function getDefaultCustomRecTemplate () {
$rect = " l; \n t:llllllllllllllllllll; f: ; a_ID:rrrrrrrr \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 ;
}
2020-11-19 22:59:54 +01:00
function getDefaultWorkTemplateFood () {
$rect = " SS:Speisen \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 ;
}
function getDefaultWorkTemplateDrinks () {
$rect = " SS:Getränke \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 22:59:47 +01:00
function createTables ( $decpoint , $billlanguage , $currency , $timezone )
{
$pdo = $this -> pdo ;
2020-11-19 22:47:44 +01:00
$this -> basedb -> setTimeZone ( $timezone );
$this -> basedb -> dropTables ( $pdo );
2020-11-19 23:00:18 +01:00
$this -> basedb -> createLogTable ( $pdo );
2020-11-19 22:47:44 +01:00
$this -> basedb -> createRatingsTable ( $pdo );
2020-11-19 22:59:47 +01:00
$this -> createPaymentTable ( $pdo );
$this -> basedb -> createUserTable ( $pdo );
2020-11-19 22:47:44 +01:00
$this -> basedb -> createRoomTable ( $pdo );
$this -> basedb -> createRestTables ( $pdo );
$this -> basedb -> createTableMapsTable ( $pdo );
2020-11-19 22:59:47 +01:00
$this -> basedb -> createTablePosTable ( $pdo );
$this -> basedb -> createConfigTable ( $pdo );
$this -> basedb -> createProdTypeTable ( $pdo );
$this -> basedb -> createProductTable ( $pdo );
$this -> basedb -> createPriceLevelTable ( $pdo );
$this -> basedb -> createClosingTable ( $pdo );
$this -> basedb -> createBillTable ( $pdo );
$this -> basedb -> createQueueTable ( $pdo );
$this -> basedb -> createBillProductsTable ( $pdo );
2020-11-19 22:47:44 +01:00
$this -> basedb -> createHistTables ( $pdo );
2020-11-19 22:59:47 +01:00
$this -> defineHistActions ( $pdo );
2020-11-19 22:47:44 +01:00
$this -> basedb -> createPrintJobsTable ( $pdo );
$this -> basedb -> createWorkTable ( $pdo );
$this -> basedb -> createCommentsTable ( $pdo );
$this -> basedb -> createReservationsTable ( $pdo );
$this -> basedb -> createLogoTable ( $pdo );
$this -> basedb -> createExtrasTable ( $pdo );
$this -> basedb -> createExtrasprodsTable ( $pdo );
$this -> basedb -> createQueueExtrasTable ( $pdo );
2020-11-19 22:58:45 +01:00
$rect = $this -> getDefaultCustomRecTemplate ();
2020-11-19 22:59:54 +01:00
$foodtemplate = $this -> getDefaultWorkTemplateFood ();
$drinktemplate = $this -> getDefaultWorkTemplateDrinks ();
2020-11-19 22:58:39 +01:00
$printpass = md5 ( " 123 " );
2020-11-19 22:47:44 +01:00
$this -> basedb -> doSQL ( $pdo , " INSERT INTO `%pricelevel%` (`id` , `name`,`info`,`info_en`,`info_esp`) VALUES ('1', 'A', 'Normale Preisstufe', 'Normal', 'Normal') " );
$this -> basedb -> doSQL ( $pdo , " INSERT INTO `%pricelevel%` (`id` , `name`,`info`,`info_en`,`info_esp`) VALUES ('2', 'B', 'Wochenendtarif', 'Weekend prices','Tarifa del fin de semana') " );
$this -> basedb -> doSQL ( $pdo , " INSERT INTO `%pricelevel%` (`id` , `name`,`info`,`info_en`,`info_esp`) VALUES ('3', 'C', 'Happy Hour', 'Happy Hour','Happy Hour') " );
2020-11-19 22:59:47 +01:00
$this -> basedb -> doSQL ( $pdo , " INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'pricelevel', '1') " );
2020-11-19 22:47:44 +01:00
$this -> basedb -> doSQL ( $pdo , " INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'tax', '19.0') " );
2020-11-19 22:59:47 +01:00
$this -> basedb -> doSQL ( $pdo , " INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'togotax', '7.0') " );
2020-11-19 23:00:31 +01:00
$this -> basedb -> doSQL ( $pdo , " INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'taxaustrianormal', '20.0') " );
$this -> basedb -> doSQL ( $pdo , " INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'taxaustriaerm1', '10.0') " );
$this -> basedb -> doSQL ( $pdo , " INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'taxaustriaerm2', '13.0') " );
$this -> basedb -> doSQL ( $pdo , " INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'taxaustriaspecial', '19.0') " );
2020-11-19 22:59:47 +01:00
$this -> basedb -> doSQL ( $pdo , " INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'stornocode', '123') " );
$this -> basedb -> doSQL ( $pdo , " INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'printpass', ' $printpass ') " );
2020-11-19 22:47:44 +01:00
$this -> basedb -> doSQL ( $pdo , " INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'companyinfo', 'Musterrestaurant \n Beispielstrasse 123 \n 12345 Musterort') " );
2020-11-19 22:58:39 +01:00
$this -> basedb -> doSQL ( $pdo , " INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'rectemplate', ' $rect ') " );
2020-11-19 22:59:54 +01:00
$this -> basedb -> doSQL ( $pdo , " INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'foodtemplate', ' $foodtemplate ') " );
$this -> basedb -> doSQL ( $pdo , " INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'drinktemplate', ' $drinktemplate ') " );
2020-11-19 22:47:44 +01:00
$resTxt = 'Vielen Dank für Ihre Reservierung am DATUM um ZEIT Uhr für ANZAHL Personen.\n\nWir freuen uns auf Ihren Besuch!\n\nBETRIEBSINFO' ;
$this -> basedb -> doSQL ( $pdo , " INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'reservationnote', ' $resTxt ') " );
$this -> basedb -> doSQL ( $pdo , " INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'serverurl', '') " );
$this -> basedb -> doSQL ( $pdo , " INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'email', '') " );
2020-11-19 22:59:47 +01:00
$this -> basedb -> doSQL ( $pdo , " INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'receiveremail', '') " );
2020-11-19 22:47:44 +01:00
$this -> basedb -> doSQL ( $pdo , " INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'payprinttype', 's') " );
$this -> basedb -> doSQL ( $pdo , " INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'billlanguage', $billlanguage ) " );
$this -> basedb -> doSQL ( $pdo , " INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'currency', ' $currency ') " );
2020-11-19 22:59:47 +01:00
$this -> basedb -> doSQL ( $pdo , " INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'receiptfontsize', '12') " );
2020-11-19 23:00:35 +01:00
$this -> basedb -> doSQL ( $pdo , " INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'version', '1.2.12') " );
2020-11-19 22:47:44 +01:00
$this -> basedb -> doSQL ( $pdo , " INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'paymentconfig', '0') " );
$this -> basedb -> doSQL ( $pdo , " INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'remoteaccesscode', null) " );
$this -> basedb -> doSQL ( $pdo , " INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'decpoint', ' $decpoint ') " );
$this -> basedb -> doSQL ( $pdo , " INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'timezone', ' $timezone ') " );
$this -> basedb -> doSQL ( $pdo , " INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'webimpressum', 'Musterrestaurant \n Beispielstrasse 123 \n 12345 Musterort') " );
$this -> basedb -> doSQL ( $pdo , " INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'cancelunpaidcode', '') " );
2020-11-19 22:48:24 +01:00
$this -> basedb -> doSQL ( $pdo , " INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'bigfontworkreceipt', '0') " );
2020-11-19 22:52:25 +01:00
$this -> basedb -> doSQL ( $pdo , " INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'prominentsearch', '0') " );
2020-11-19 22:53:50 +01:00
$this -> basedb -> doSQL ( $pdo , " INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'groupworkitems', '1') " );
2020-11-19 22:59:50 +01:00
$this -> basedb -> doSQL ( $pdo , " INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'addreceipttoprinter', null) " );
2020-11-19 22:47:44 +01:00
$this -> basedb -> doSQL ( $pdo , " INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'smtphost', '') " );
$this -> basedb -> doSQL ( $pdo , " INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'smtpauth', '1') " );
$this -> basedb -> doSQL ( $pdo , " INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'smtpuser', '') " );
$this -> basedb -> doSQL ( $pdo , " INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'smtppass', '') " );
$this -> basedb -> doSQL ( $pdo , " INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'smtpsecure', '1') " );
$this -> basedb -> doSQL ( $pdo , " INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'smtpport', '587') " );
2020-11-19 22:58:17 +01:00
$this -> basedb -> doSQL ( $pdo , " INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'discount1', '50') " );
$this -> basedb -> doSQL ( $pdo , " INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'discount2', '20') " );
$this -> basedb -> doSQL ( $pdo , " INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'discount3', '10') " );
$this -> basedb -> doSQL ( $pdo , " INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'austria', '0') " );
2020-11-19 22:58:20 +01:00
$this -> basedb -> doSQL ( $pdo , " INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'paydeskid', 'OrderSprinter-1') " );
$this -> basedb -> doSQL ( $pdo , " INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'aeskey', '0102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f20') " );
$this -> basedb -> doSQL ( $pdo , " INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'certificatesn', '1234567') " );
2020-11-19 22:58:17 +01:00
2020-11-19 22:58:36 +01:00
$this -> basedb -> doSQL ( $pdo , " INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'digigopaysetready', '1') " );
2020-11-19 22:58:42 +01:00
$this -> basedb -> doSQL ( $pdo , " INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'waitergopayprint', '0') " );
2020-11-19 22:58:36 +01:00
2020-11-19 23:00:05 +01:00
$this -> basedb -> doSQL ( $pdo , " INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'oneprodworkreceipts', '0') " );
$this -> basedb -> doSQL ( $pdo , " INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'digiprintwork', '1') " );
2020-11-19 22:47:44 +01:00
// prepare for later inconsistency check if version is obsolete
date_default_timezone_set ( $timezone );
$installDate = date ( 'Y-m-d H:i:s' );
$this -> basedb -> doSQL ( $pdo , " INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'installdate', ' $installDate ') " );
$this -> readConfigTableAndSendToHist ( $pdo );
2020-11-19 22:59:47 +01:00
return ;
2020-11-19 22:47:44 +01:00
}
public function getCurrentVersion () {
try {
$pdo = $this -> pdo ;
$sql = " SELECT setting FROM %config% WHERE name=? " ;
$stmt = $pdo -> prepare ( $this -> basedb -> resolveTablenamesInSqlString ( $sql ));
$stmt -> execute ( array ( " version " ));
$row = $stmt -> fetchObject ();
return ( $row -> setting );
} catch ( Exception $e ) {
return null ;
}
}
2020-11-19 22:50:09 +01:00
public function isTherePreviousVersion ( $db , $prefix ) {
try {
$pdo = $this -> pdo ;
$sql = " SELECT count(*) as thecount FROM information_schema.tables WHERE table_schema = ' $db ' AND table_name = ' " . $prefix . " config' LIMIT 1 " ;
$stmt = $pdo -> prepare ( $this -> basedb -> resolveTablenamesInSqlString ( $sql ));
$stmt -> execute ();
$row = $stmt -> fetchObject ();
if ( $row -> thecount == 1 ) {
return true ;
} else {
return false ;
}
} catch ( Exception $e ) {
return false ;
}
}
2020-11-19 22:59:47 +01:00
function readConfigTableAndSendToHist ( $pdo ) {
$sql_query = " SELECT * FROM %config% " ;
$sql_insert_histconfig = " INSERT INTO %histconfig% (id,configid,setting) VALUES (NULL,?,?) " ;
$stmt_query = $pdo -> prepare ( $this -> basedb -> resolveTablenamesInSqlString ( $sql_query ));
$stmt_insert_histconfig = $pdo -> prepare ( $this -> basedb -> resolveTablenamesInSqlString ( $sql_insert_histconfig ));
$stmt_query -> execute ();
$result = $stmt_query -> fetchAll ();
foreach ( $result as $row ){
$stmt_insert_histconfig -> execute ( array ( $row [ 'id' ], $row [ 'setting' ]));
$newRefIdForHist = $pdo -> lastInsertId ();
$this -> insertIntoHist ( $pdo , '2' , $newRefIdForHist );
}
2020-11-19 22:47:44 +01:00
}
2020-11-19 22:59:47 +01:00
private function insertIntoHist ( $pdo , $action , $refIdForHist ) {
date_default_timezone_set ( $this -> timezone );
$currentTime = date ( 'Y-m-d H:i:s' );
$sql_insert_hist = " INSERT INTO %hist% (id,date,action,refid) VALUES (NULL,?,?,?) " ;
$stmt_insert_hist = $pdo -> prepare ( $this -> basedb -> resolveTablenamesInSqlString ( $sql_insert_hist ));
$stmt_insert_hist -> execute ( array ( $currentTime , $action , $refIdForHist ));
2020-11-19 22:47:44 +01:00
}
function insertUser ( $username , $adminpass , $is_admin , $right_waiter , $right_kitchen , $right_bar ,
$right_supply , $right_paydesk , $right_statistics , $right_bill , $right_products , $right_changeprice ,
2020-11-19 22:59:47 +01:00
$right_manager , $right_closing , $right_reservation , $right_rating , $lang , $prefertablemap ) {
2020-11-19 22:47:44 +01:00
$md5adminpass = md5 ( $adminpass );
$pdo = $this -> pdo ;
2020-11-19 22:59:47 +01:00
$userInsertSql = " INSERT INTO `%user%` (`id` , `username` , `userpassword`, `is_admin`, `right_waiter`,`right_kitchen`,`right_bar`,`right_supply`,`right_paydesk`,`right_statistics`,`right_bill`,`right_products`,`right_changeprice`,`right_manager`,`right_closing`,`right_reservation`,`right_rating`,`language`,`prefertablemap`,`keeptypelevel`,`extrasapplybtnpos`,`active`) VALUES (NULL,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,'1','1') " ;
2020-11-19 22:47:44 +01:00
$stmt = $pdo -> prepare ( DbUtils :: substTableAlias ( $userInsertSql ));
2020-11-19 22:59:47 +01:00
$stmt -> execute ( array ( $username , $md5adminpass , $is_admin , $right_waiter , $right_kitchen , $right_bar , $right_supply , $right_paydesk , $right_statistics , $right_bill , $right_products , $right_changeprice , $right_manager , $right_closing , $right_reservation , $right_rating , $lang , $prefertablemap , 0 ));
2020-11-19 22:47:44 +01:00
$newUserIdForHist = $pdo -> lastInsertId ();
// now insert into hist
2020-11-19 22:59:47 +01:00
$sql_insert_histuser = " INSERT INTO %histuser% (`id` , `userid`, `username` ,
`is_admin` , `right_waiter` , `right_kitchen` , `right_bar` , `right_supply` , `right_paydesk` ,
`right_statistics` , `right_bill` , `right_products` , `right_changeprice` , `right_manager` , `right_closing` , `right_reservation` , `right_rating` , `active` ) VALUES (
NULL , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? ) " ;
$stmt_insert_histuser = $pdo -> prepare ( $this -> basedb -> resolveTablenamesInSqlString ( $sql_insert_histuser ));
$stmt_insert_histuser -> execute ( array ( $newUserIdForHist , $username , $is_admin , $right_waiter , $right_kitchen , $right_bar , $right_supply , $right_paydesk , $right_statistics , $right_bill , $right_products , $right_changeprice , $right_manager , $right_closing , $right_reservation , $right_rating , 1 ));
$newRefIdForHist = $pdo -> lastInsertId ();
2020-11-19 22:47:44 +01:00
$this -> insertIntoHist ( $pdo , '3' , $newRefIdForHist );
}
2020-11-19 22:59:47 +01:00
2020-11-19 22:47:44 +01:00
function createPaymentTable ( $pdo ) {
2020-11-19 22:59:47 +01:00
$this -> basedb -> createPaymentTable ( $pdo );
$sql = " INSERT INTO %payment% (id,name,name_en,name_esp) VALUES (?,?,?,?) " ;
$stmt = $pdo -> prepare ( $this -> basedb -> resolveTablenamesInSqlString ( $sql ));
2020-11-19 22:47:44 +01:00
$stmt -> execute ( array ( '1' , 'Barzahlung' , 'Cash' , 'Contado' ));
$stmt = $pdo -> prepare ( $this -> basedb -> resolveTablenamesInSqlString ( $sql ));
2020-11-19 22:59:47 +01:00
2020-11-19 22:47:44 +01:00
$stmt -> execute ( array ( '2' , 'EC-Kartenzahlung' , 'Electr. purse (EC)' , 'Pago con tarjeta EC' ));
2020-11-19 22:59:47 +01:00
$stmt = $pdo -> prepare ( $this -> basedb -> resolveTablenamesInSqlString ( $sql ));
2020-11-19 22:47:44 +01:00
$stmt -> execute ( array ( '3' , 'Kreditkartenzahlung' , 'Credit card' , 'Tarjeta de credito' ));
2020-11-19 22:59:47 +01:00
$stmt = $pdo -> prepare ( $this -> basedb -> resolveTablenamesInSqlString ( $sql ));
2020-11-19 22:47:44 +01:00
$stmt -> execute ( array ( '4' , 'Rechnung' , 'bill' , 'Factura' ));
2020-11-19 22:59:47 +01:00
$stmt = $pdo -> prepare ( $this -> basedb -> resolveTablenamesInSqlString ( $sql ));
2020-11-19 22:47:44 +01:00
$stmt -> execute ( array ( '5' , 'Ueberweisung' , 'Bank transfer' , 'Transferencia' ));
2020-11-19 22:59:47 +01:00
$stmt = $pdo -> prepare ( $this -> basedb -> resolveTablenamesInSqlString ( $sql ));
$stmt -> execute ( array ( '6' , 'Lastschrift' , 'Debit' , 'Cargo en cuenta' ));
}
public function defineHistActions ( $pdo ) {
$sql = " INSERT INTO %histactions% (id,name,description) VALUES (?,?,?) " ;
$stmt = $pdo -> prepare ( $this -> basedb -> resolveTablenamesInSqlString ( $sql ));
$stmt -> execute ( array ( '1' , 'ProdInit' , 'Initiales Befuellen der Produkttabelle' ));
$stmt -> execute ( array ( '2' , 'ConfigInit' , 'Initiales Befuellen der Konfigurationstabelle' ));
$stmt -> execute ( array ( '3' , 'UserInit' , 'Initiales Befuellen der Benutzertabelle' ));
$stmt -> execute ( array ( '4' , 'ProdChange' , 'Modifikation der Produktdaten' ));
$stmt -> execute ( array ( '5' , 'ProdCreation' , 'Neues Produkt' ));
$stmt -> execute ( array ( '6' , 'ConfigChange' , 'Modifikation der Konfiguration' ));
$stmt -> execute ( array ( '7' , 'UserCreation' , 'Neuer Benutzer' ));
$stmt -> execute ( array ( '8' , 'UserChange' , 'Modifikation eines Benutzers' ));
2020-11-19 22:47:44 +01:00
}
function testDbConnection ( $host , $dbname , $user , $pass ) {
2020-11-19 22:59:47 +01:00
$pdo = $this -> openDbAndReturnPdo ( $host , $dbname , $user , $pass );
if ( ! is_null ( $pdo )) {
echo json_encode ( " OK " );
} else {
echo json_encode ( " ERROR " );
}
2020-11-19 22:47:44 +01:00
}
function writeConfigFile ( $host , $db , $user , $password , $prefix ) {
$errorlevel = " <?php \n error_reporting(E_ERROR); \n \n " ; // development: E_ALL
2020-11-19 22:59:47 +01:00
$hostlines = " // Zum Aufbau der Verbindung zur Datenbank \n " ;
2020-11-19 22:47:44 +01:00
$hostlines .= " // die Daten erhalten Sie von Ihrem Provider \n " ;
$hostlines .= " defined('MYSQL_HOST') || define ( 'MYSQL_HOST',' $host ' ); " ;
2020-11-19 22:59:47 +01:00
$userlines = " defined('MYSQL_USER') || define ( 'MYSQL_USER', ' $user ' ); " ;
2020-11-19 22:47:44 +01:00
$dbpasslines = " defined('MYSQL_PASSWORD') || define ( 'MYSQL_PASSWORD', ' $password ' ); " ;
2020-11-19 22:59:47 +01:00
$dblines = " defined('MYSQL_DB') || define ( 'MYSQL_DB', ' $db ' ); " ;
2020-11-19 22:47:44 +01:00
$dbloglines = " defined('LOG') || define ( 'LOG', false ); " ;
$prefixlines = " defined('TAB_PREFIX') || define ('TAB_PREFIX', ' $prefix '); " ;
$installstatusline = " defined('INSTALLSTATUS') || define ('INSTALLSTATUS', 'installed'); " ;
$configText = " $errorlevel\n $hostlines\n $userlines\n $dbpasslines\n $dblines\n $dbloglines\n $prefixlines\n $installstatusline\n ?> " ;
file_put_contents ( " ../php/config.php " , $configText );
try {
file_put_contents ( " ../php/config1.php " , $configText );
} catch ( Exception $e ) {
// nothing
}
}
function createSslKeys ( $pdo ) {
2020-11-19 22:59:47 +01:00
$sslconfig = array (
" digest_alg " => " sha512 " ,
" private_key_bits " => 4096 ,
" private_key_type " => OPENSSL_KEYTYPE_RSA ,
2020-11-19 22:47:44 +01:00
);
2020-11-19 22:59:47 +01:00
// thus the signature is exactly 512 bytes
// Create the private and public key
$res = openssl_pkey_new ( $sslconfig );
2020-11-19 22:47:44 +01:00
if ( is_null ( $res ) || ( $res == " " )) {
// openssl may be incorrectly installed
return false ;
}
2020-11-19 22:59:47 +01:00
// Extract the private key from $res to $privKey
openssl_pkey_export ( $res , $privKey );
// Extract the public key from $res to $pubKey
$pubKey = openssl_pkey_get_details ( $res );
2020-11-19 22:47:44 +01:00
$pubKey = $pubKey [ " key " ];
$sql = " INSERT INTO `%work%` (`id` , `item`,`value`,`signature`) VALUES ( NULL,?,?,?) " ;
$stmt = $pdo -> prepare ( $this -> basedb -> resolveTablenamesInSqlString ( $sql ));
$stmt -> execute ( array ( " privkey " , " privkey " , $privKey ));
$sql = " INSERT INTO `%work%` (`id` , `item`,`value`,`signature`) VALUES ( NULL,?,?,?) " ;
$stmt = $pdo -> prepare ( $this -> basedb -> resolveTablenamesInSqlString ( $sql ));
$stmt -> execute ( array ( " cert " , " cert " , $pubKey ));
return true ;
}
static function insertSampleMenu ( $pdo , $adminCl ) {
$menu = file_get_contents ( " ../customer/speisekarte.txt " );
$adminCl -> fillSpeisekarteCore ( $pdo , $menu );
}
function insertSample ( $level , $lang , $adminpass , $workflow , $timezone ) {
$pdo = $this -> pdo ;
$adminCl = new Admin ();
$adminCl :: overruleTimeZone ( $timezone );
$adminCl -> changeOneConfigDbItem ( $pdo , " workflowconfig " , $workflow , " %config% " , true );
if ( $level == 1 ) {
// nothing to do - empty db
} else {
$roomTxt1 = array ( " Raum 1 (Tischkarte) " , " Room 1 (table map) " , " Espacio 1 (mapa de mesas) " );
$roomTxt2 = array ( " Raum 2 (Tischbuttons) " , " Room 2 (table buttons) " , " Espacio (botones des mesas) " );
$tableTxt = array ( " Tisch " , " Table " , " Mesa " );
$waiterTxt = array ( " Karl Kellner " , " Walter Waiter " , " Carlo Camarero " );
$cookTxt = array ( " Koch 1 " , " Charlie Cook " , " Cocinero 1 " );
$bossTxt = array ( " Charlie Chef " , " Maggy Manager " , " Jefe " );
$sql = " INSERT INTO `%room%` (`id`, `roomname`) VALUES (?,?) " ;
$stmt = $pdo -> prepare ( DbUtils :: substTableAlias ( $sql ));
$stmt -> execute ( array ( 1 , $roomTxt1 [ $lang ]));
if ( $level == 3 ) {
$stmt -> execute ( array ( 2 , $roomTxt2 [ $lang ]));
}
$sql = " INSERT INTO `%resttables%` (`id` , `tableno`, `roomid`) VALUES (? ,?,?) " ;
$stmt = $pdo -> prepare ( DbUtils :: substTableAlias ( $sql ));
for ( $i = 1 ; $i < 7 ; $i ++ ) {
$stmt -> execute ( array ( $i , $tableTxt [ $lang ] . " $i " , 1 ));
if ( $level == 3 ) {
$stmt -> execute ( array ( $i + 6 , $tableTxt [ $lang ] . " " . ( $i + 6 ), 2 ));
}
}
if ( $level == 3 ) {
$sql = " INSERT INTO `%tablemaps%` (`id` , `roomid`, `img`,`sizex`,`sizey`) VALUES (NULL ,?,?,?,?) " ;
$stmt = $pdo -> prepare ( DbUtils :: substTableAlias ( $sql ));
$room = file_get_contents ( " ../customer/innenraum.png " );
$stmt -> execute ( array ( 1 , $room , 739 , 490 ));
$sql = " INSERT INTO `%tablepos%` (`id` , `tableid`, `x`,`y`) VALUES (NULL ,?,?,?) " ;
$stmt = $pdo -> prepare ( DbUtils :: substTableAlias ( $sql ));
$stmt -> execute ( array ( 1 , 70 , 74 ));
$stmt -> execute ( array ( 2 , 9 , 57 ));
$stmt -> execute ( array ( 3 , 19 , 37 ));
$stmt -> execute ( array ( 4 , 30 , 21 ));
$stmt -> execute ( array ( 5 , 49 , 21 ));
$stmt -> execute ( array ( 6 , 76 , 22 ));
}
if ( $workflow == 2 ) {
// only receipts - no views kitchen,bar,supply
2020-11-19 22:59:54 +01:00
$this -> insertUser ( $waiterTxt [ $lang ], $adminpass , 0 , 1 , 0 , 0 , 0 , 1 , 0 , 1 , 0 , 0 , 0 , 0 , 1 , 0 , $lang , 1 );
2020-11-19 22:47:44 +01:00
if ( $level == 3 ) {
2020-11-19 22:59:54 +01:00
$this -> insertUser ( $bossTxt [ $lang ], $adminpass , 0 , 1 , 0 , 0 , 0 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , $lang , 1 );
2020-11-19 22:47:44 +01:00
}
} else {
2020-11-19 22:59:54 +01:00
$this -> insertUser ( $waiterTxt [ $lang ], $adminpass , 0 , 1 , 0 , 0 , 1 , 1 , 0 , 1 , 0 , 0 , 0 , 0 , 1 , 0 , $lang , 1 );
2020-11-19 22:47:44 +01:00
if ( $level == 3 ) {
2020-11-19 22:59:54 +01:00
$this -> insertUser ( $cookTxt [ $lang ], $adminpass , 0 , 0 , 1 , 1 , 1 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , $lang , 1 );
$this -> insertUser ( $bossTxt [ $lang ], $adminpass , 0 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , $lang , 1 );
2020-11-19 22:47:44 +01:00
}
}
$logoimg = file_get_contents ( " ../customer/logo.png " );
$sql = " INSERT INTO %logo% (id,name,setting) VALUES(1,?,?) " ;
$stmt = $pdo -> prepare ( DbUtils :: substTableAlias ( $sql ));
$stmt -> execute ( array ( " logoimg " , $logoimg ));
self :: insertSampleMenu ( $pdo , $adminCl );
}
}
}
$command = $_GET [ " command " ];
if ( $command == 'checkWriteAccess' ) {
$checker = new Checks ();
$checker -> checkWriteAccess ();
} else if ( $command == 'checkPhpStatus' ) {
$checker = new InstallAdmin ();
$checker -> checkPhpStatus ();
} else if ( $command == 'testDbConnection' ) {
$admin = new InstallAdmin ();
try {
2020-11-19 22:59:47 +01:00
if ( isset ( $_POST [ 'host' ]) && isset ( $_POST [ 'dbname' ]) && isset ( $_POST [ 'user' ]) && isset ( $_POST [ 'pass' ])) {
2020-11-19 22:47:44 +01:00
$admin -> testDbConnection ( $_POST [ 'host' ], $_POST [ 'dbname' ], $_POST [ 'user' ], $_POST [ 'pass' ]);
} else {
echo json_encode ( " ERROR " );
}
} catch ( Exception $e ) {
echo json_encode ( " ERROR " );
}
} else if ( $command == 'getConfig' ) {
$configWriter = new ConfigWriter ();
$configWriter -> getConfigVals ();
} else if ( $command == 'install' ) {
$admin = new InstallAdmin ();
$pdo = $admin -> openDbAndReturnPdo ( $_POST [ 'host' ], $_POST [ 'db' ], $_POST [ 'user' ], $_POST [ 'password' ]);
$admin -> setPdo ( $pdo );
$admin -> setPrefix ( $_POST [ 'prefix' ]);
$admin -> setTimeZone ( $_POST [ 'timezone' ]);
DbUtils :: overruleTimeZone ( $_POST [ 'timezone' ]);
DbUtils :: overrulePrefix ( $_POST [ 'prefix' ]);
set_time_limit ( 60 * 5 );
$admin -> createTables ( $_POST [ 'point' ], $_POST [ 'lang' ], $_POST [ 'currency' ], $_POST [ 'timezone' ]);
$ok = $admin -> createSslKeys ( $pdo );
$admin -> signLastBillId ();
if ( ! $ok ) {
echo json_encode ( " Fehler: Ist OpenSSL richtig installiert? " );
return ;
}
2020-11-19 22:59:54 +01:00
$admin -> insertUser ( " admin " , $_POST [ 'adminpass' ], 1 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 1 , 1 , 1 , 0 , 0 , $_POST [ 'lang' ], 1 );
2020-11-19 22:47:44 +01:00
$admin -> writeConfigFile ( $_POST [ 'host' ], $_POST [ 'db' ], $_POST [ 'user' ], $_POST [ 'password' ], $_POST [ 'prefix' ]);
if ( session_id () == '' ) {
session_start ();
}
session_destroy ();
echo json_encode ( " OK " );
} else if ( $command == 'insertsamplecontent' ) {
try {
$admin = new InstallAdmin ();
$pdo = $admin -> openDbAndReturnPdo ( $_POST [ 'host' ], $_POST [ 'db' ], $_POST [ 'user' ], $_POST [ 'password' ]);
$admin -> setPdo ( $pdo );
$admin -> setPrefix ( $_POST [ 'prefix' ]);
$admin -> setTimeZone ( $_POST [ " timezone " ]);
$admin -> insertSample ( intval ( $_POST [ " level " ]), intval ( $_POST [ " lang " ]), $_POST [ 'adminpass' ], $_POST [ " workflow " ], $_POST [ " timezone " ]);
echo json_encode ( " OK " );
}
catch ( PDOException $e ) {
echo json_encode ( " ERROR: $e " );
}
} else if ( $command == 'gettimezones' ) {
$timezone_identifiers = DateTimeZone :: listIdentifiers ();
$zones = array ();
for ( $i = 0 ; $i < count ( $timezone_identifiers ); $i ++ ) {
$zones [] = $timezone_identifiers [ $i ];
}
echo json_encode ( $zones );
} else if ( $command == 'update' ) {
2020-11-19 23:00:05 +01:00
2020-11-19 23:00:35 +01:00
$installerVersion = " 1.2.12 " ;
2020-11-19 22:58:17 +01:00
2020-11-19 22:47:44 +01:00
$admin = new InstallAdmin ();
$pdo = $admin -> openDbAndReturnPdo ( $_POST [ 'host' ], $_POST [ 'db' ], $_POST [ 'user' ], $_POST [ 'password' ]);
$admin -> setPdo ( $pdo );
$admin -> setPrefix ( $_POST [ 'prefix' ]);
2020-11-19 22:50:09 +01:00
$isPreviousInstallation = $admin -> isTherePreviousVersion ( $_POST [ 'db' ], $_POST [ 'prefix' ]);
if ( ! $isPreviousInstallation ) {
echo json_encode ( " Stimmt der Tabellenpräfix? " );
return ;
}
2020-11-19 22:47:44 +01:00
$version = $admin -> getCurrentVersion ();
2020-11-19 22:58:17 +01:00
if ( $version == $installerVersion ) {
echo json_encode ( " Version bereits installiert " );
return ;
}
2020-11-19 22:47:44 +01:00
if ( is_null ( $version )) {
echo json_encode ( " Version nicht bestimmbar " );
return ;
}
2020-11-19 22:52:55 +01:00
$supportedVersions = array ( " 1.0.22 " , " 1.0.23 " , " 1.0.24 " , " 1.0.25 " , " 1.0.26 " , " 1.0.27 " , " 1.0.28 " , " 1.0.29 " ,
" 1.0.30 " , " 1.0.31 " , " 1.0.32 " , " 1.0.33 " , " 1.0.34 " , " 1.0.35 " , " 1.0.36 " , " 1.0.37 " , " 1.0.38 " , " 1.0.39 " ,
2020-11-19 22:55:09 +01:00
" 1.0.40 " , " 1.0.41 " , " 1.0.42 " , " 1.0.43 " ,
2020-11-19 22:56:38 +01:00
" 1.1.0 " , " 1.1.1 " , " 1.1.2 " , " 1.1.3 " , " 1.1.4 " , " 1.1.5 " , " 1.1.6 " , " 1.1.7 " , " 1.1.8 " , " 1.1.9 " , " 1.1.10 " , " 1.1.11 " , " 1.1.12 " , " 1.1.13 " , " 1.1.14 " , " 1.1.15 " , " 1.1.16 " , " 1.1.17 " ,
2020-11-19 22:59:50 +01:00
" 1.1.18 " , " 1.1.19 " , " 1.1.20 " , " 1.1.21 " , " 1.1.22 " , " 1.1.23 " , " 1.1.24 " , " 1.1.25 " , " 1.1.26 " , " 1.1.27 " , " 1.1.28 " , " 1.1.29 " , " 1.1.30 " ,
2020-11-19 23:00:35 +01:00
" 1.2.0 " , " 1.2.1 " , " 1.2.2 " , " 1.2.3 " , " 1.2.4 " , " 1.2.5 " , " 1.2.6 " , " 1.2.7 " , " 1.2.8 " , " 1.2.9 " , " 1.2.10 " , " 1.2.11 "
2020-11-19 22:52:55 +01:00
);
if ( ! in_array ( $version , $supportedVersions )) {
2020-11-19 22:47:44 +01:00
echo json_encode ( " Quellversion nicht unterstützt " );
return ;
}
2020-11-19 23:00:35 +01:00
$ret = $admin -> updateUserTable1211_1212 ( $_POST [ 'prefix' ], $version , $_POST [ 'db' ]);
2020-11-19 22:52:55 +01:00
2020-11-19 22:47:44 +01:00
if ( session_id () == '' ) {
session_start ();
}
session_destroy ();
if ( $ret ) {
$admin -> writeConfigFile ( $_POST [ 'host' ], $_POST [ 'db' ], $_POST [ 'user' ], $_POST [ 'password' ], $_POST [ 'prefix' ]);
echo json_encode ( " OK " );
} else {
echo json_encode ( " ERROR " );
}
}
?>