3324 lines
99 KiB
PHP
3324 lines
99 KiB
PHP
<?php
|
|
error_reporting(E_ALL);
|
|
|
|
define ('IS_INSTALLMODE', '1');
|
|
|
|
if (is_readable("../php/config1.php")) {
|
|
require_once( "../php/config1.php" );
|
|
} else {
|
|
require_once( "../php/config.php" );
|
|
}
|
|
require_once ('../php/utilities/basedb.php');
|
|
require_once ('../php/utilities/HistFiller.php');
|
|
require_once ('../php/utilities/decimaldefs.php');
|
|
require_once ('../php/utilities/roles.php');
|
|
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;
|
|
}
|
|
|
|
function openDbAndReturnPdo ($host,$db,$user,$password) {
|
|
$dsn = 'mysql:host=' . $host . ';dbname=' . $db;
|
|
$pdo = null;
|
|
try {
|
|
$pdo = new PDO($dsn, $user, $password);
|
|
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
|
}
|
|
catch (PDOException $e) {
|
|
echo 'Verbindungsproblem: ' . $e->getMessage();
|
|
$pdo = null;
|
|
}
|
|
return $pdo;
|
|
}
|
|
|
|
function checkPhpStatus() {
|
|
$extensions = array("gd","mysqli","openssl","pdo_mysql","PDO","session","zlib","curl","zip","ftp");
|
|
$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);
|
|
}
|
|
|
|
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));
|
|
}
|
|
|
|
|
|
function updateUserTable1022_1023($prefix,$version) {
|
|
$pdo = $this->pdo;
|
|
try {
|
|
if ($version != "1.0.22") {
|
|
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;
|
|
}
|
|
}
|
|
|
|
function updateUserTable1023_1024($prefix,$version) {
|
|
$pdo = $this->pdo;
|
|
try {
|
|
if ($version != "1.0.23") {
|
|
$ret = $this->updateUserTable1022_1023($prefix,$version);
|
|
if (!$ret) { return false; }
|
|
}
|
|
|
|
$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;
|
|
}
|
|
}
|
|
|
|
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;
|
|
}
|
|
|
|
function updateUserTable1025_1026($prefix,$version) {
|
|
$pdo = $this->pdo;
|
|
try {
|
|
if ($version != "1.0.25") {
|
|
$ret = $this->updateUserTable1024_1025($prefix,$version);
|
|
if (!$ret) { return false; }
|
|
}
|
|
|
|
$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;
|
|
}
|
|
}
|
|
|
|
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;
|
|
}
|
|
|
|
function updateUserTable1027_1028($prefix,$version) {
|
|
$pdo = $this->pdo;
|
|
try {
|
|
if ($version != "1.0.27") {
|
|
$ret = $this->updateUserTable1026_1027($prefix,$version);
|
|
if (!$ret) { return false; }
|
|
}
|
|
|
|
$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;
|
|
}
|
|
}
|
|
|
|
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;
|
|
}
|
|
|
|
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;
|
|
}
|
|
|
|
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;
|
|
}
|
|
|
|
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;
|
|
}
|
|
|
|
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;
|
|
}
|
|
|
|
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;
|
|
}
|
|
|
|
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;
|
|
}
|
|
|
|
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;
|
|
}
|
|
|
|
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;
|
|
}
|
|
|
|
function updateUserTable1037_1038($prefix,$version) {
|
|
$pdo = $this->pdo;
|
|
try {
|
|
if ($version != "1.0.37") {
|
|
$ret = $this->updateUserTable1036_1037($prefix,$version);
|
|
if (!$ret) {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
$adminCl = new Admin();
|
|
DbUtils::overrulePrefix($prefix);
|
|
|
|
$sql = "ALTER TABLE %queue% DROP action";
|
|
$stmt = $pdo->prepare($this->basedb->resolveTablenamesInSqlString($sql));
|
|
$stmt->execute();
|
|
|
|
$sql = "ALTER TABLE %queue% ADD tax " . DECIMALSMALL . " NULL AFTER price";
|
|
$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();
|
|
|
|
$sql = "ALTER TABLE %queue% MODIFY tax " . DECIMALSMALL . " NOT NULL";
|
|
$stmt = $pdo->prepare($this->basedb->resolveTablenamesInSqlString($sql));
|
|
$stmt->execute();
|
|
|
|
$sql = "ALTER TABLE %products% ADD tax " . DECIMALSMALL . " NULL AFTER priceC";
|
|
$stmt = $pdo->prepare($this->basedb->resolveTablenamesInSqlString($sql));
|
|
$stmt->execute();
|
|
|
|
$sql = "ALTER TABLE %histprod% ADD tax " . DECIMALSMALL . " NULL AFTER priceC";
|
|
$stmt = $pdo->prepare($this->basedb->resolveTablenamesInSqlString($sql));
|
|
$stmt->execute();
|
|
|
|
$this->updateVersion($pdo, "1.0.38");
|
|
|
|
return true;
|
|
} catch (PDOException $e) {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
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;
|
|
}
|
|
|
|
function updateUserTable1039_1040($prefix,$version) {
|
|
$pdo = $this->pdo;
|
|
try {
|
|
if ($version != "1.0.39") {
|
|
$ret = $this->updateUserTable1038_1039($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('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;
|
|
}
|
|
}
|
|
|
|
function updateUserTable1040_1041($prefix,$version) {
|
|
$pdo = $this->pdo;
|
|
try {
|
|
if ($version != "1.0.40") {
|
|
$ret = $this->updateUserTable1039_1040($prefix,$version);
|
|
if (!$ret) {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
$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;
|
|
}
|
|
}
|
|
|
|
function updateUserTable1041_1042($prefix,$version) {
|
|
$pdo = $this->pdo;
|
|
try {
|
|
if ($version != "1.0.41") {
|
|
$ret = $this->updateUserTable1040_1041($prefix,$version);
|
|
if (!$ret) {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
$adminCl = new Admin();
|
|
DbUtils::overrulePrefix($prefix);
|
|
$this->updateVersion($pdo, '1.0.42');
|
|
return true;
|
|
} catch (PDOException $e) {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
function updateUserTable1042_1043($prefix,$version) {
|
|
$pdo = $this->pdo;
|
|
try {
|
|
if ($version != "1.0.42") {
|
|
$ret = $this->updateUserTable1041_1042($prefix,$version);
|
|
if (!$ret) {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
$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;
|
|
}
|
|
}
|
|
|
|
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;
|
|
}
|
|
|
|
function updateUserTable1100_1101($prefix,$version) {
|
|
$pdo = $this->pdo;
|
|
try {
|
|
if ($version != "1.1.0") {
|
|
$ret = $this->updateUserTable1043_1100($prefix,$version);
|
|
if (!$ret) {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
$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));
|
|
$stmt->execute(array(0));
|
|
|
|
$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;
|
|
}
|
|
}
|
|
|
|
function updateUserTable1101_1102($prefix,$version) {
|
|
$pdo = $this->pdo;
|
|
try {
|
|
if ($version != "1.1.1") {
|
|
$ret = $this->updateUserTable1100_1101($prefix,$version);
|
|
if (!$ret) {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
$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;
|
|
}
|
|
}
|
|
|
|
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;
|
|
}
|
|
|
|
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;
|
|
}
|
|
|
|
function updateUserTable1104_1105($prefix,$version) {
|
|
$pdo = $this->pdo;
|
|
try {
|
|
if ($version != "1.1.4") {
|
|
$ret = $this->updateUserTable1103_1104($prefix,$version);
|
|
if (!$ret) {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
$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;
|
|
}
|
|
}
|
|
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;
|
|
}
|
|
|
|
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;
|
|
}
|
|
|
|
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;
|
|
}
|
|
}
|
|
|
|
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;
|
|
}
|
|
|
|
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;
|
|
}
|
|
|
|
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;
|
|
}
|
|
}
|
|
|
|
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;
|
|
}
|
|
}
|
|
|
|
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;
|
|
}
|
|
|
|
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;
|
|
}
|
|
|
|
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;
|
|
}
|
|
|
|
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;
|
|
}
|
|
|
|
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;
|
|
}
|
|
|
|
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;
|
|
}
|
|
|
|
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;
|
|
}
|
|
|
|
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;
|
|
}
|
|
}
|
|
|
|
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'));
|
|
|
|
$sql = "ALTER TABLE %bill% ADD prevbrutto " . DECIMALBIG . " NULL AFTER netto";
|
|
$stmt = $pdo->prepare(DbUtils::substTableAlias($sql));
|
|
$stmt->execute();
|
|
$sql = "ALTER TABLE %bill% ADD prevnetto " . DECIMALBIG . " NULL AFTER prevbrutto";
|
|
$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;
|
|
}
|
|
}
|
|
|
|
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;
|
|
}
|
|
}
|
|
|
|
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;
|
|
}
|
|
|
|
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;
|
|
}
|
|
|
|
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;
|
|
}
|
|
|
|
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;
|
|
}
|
|
}
|
|
|
|
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);
|
|
|
|
$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.28');
|
|
return true;
|
|
} catch (PDOException $e) {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
function updateUserTable1128_1129($prefix,$version) {
|
|
$pdo = $this->pdo;
|
|
try {
|
|
if ($version != "1.1.28") {
|
|
$ret = $this->updateUserTable1127_1128($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('waitergopayprint',0));
|
|
|
|
$this->updateVersion($pdo, '1.1.29');
|
|
return true;
|
|
} catch (PDOException $e) {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
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;
|
|
}
|
|
}
|
|
|
|
private function execSql($pdo,$sql) {
|
|
$stmt = $pdo->prepare(DbUtils::substTableAlias($sql));
|
|
$stmt->execute();
|
|
}
|
|
|
|
private function execSqlWithParam($pdo,$sql,$param) {
|
|
$stmt = $pdo->prepare(DbUtils::substTableAlias($sql));
|
|
$stmt->execute($param);
|
|
}
|
|
|
|
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->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;
|
|
}
|
|
}
|
|
|
|
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;
|
|
}
|
|
}
|
|
|
|
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;
|
|
}
|
|
}
|
|
|
|
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;
|
|
}
|
|
}
|
|
|
|
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;
|
|
}
|
|
}
|
|
|
|
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;
|
|
}
|
|
}
|
|
|
|
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;
|
|
}
|
|
}
|
|
|
|
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;
|
|
}
|
|
}
|
|
|
|
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;
|
|
}
|
|
}
|
|
|
|
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;
|
|
}
|
|
}
|
|
|
|
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;
|
|
}
|
|
}
|
|
|
|
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;
|
|
}
|
|
}
|
|
|
|
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;
|
|
}
|
|
}
|
|
|
|
function updateUserTable1212_1213($prefix, $version, $dbname) {
|
|
$pdo = $this->pdo;
|
|
try {
|
|
if ($version != "1.2.12") {
|
|
$ret = $this->updateUserTable1211_1212($prefix, $version, $dbname);
|
|
if (!$ret) {
|
|
echo "Version update v1.2.11 to 1.2.12 not successful.";
|
|
return false;
|
|
}
|
|
}
|
|
|
|
DbUtils::overrulePrefix($prefix);
|
|
|
|
$this->updateVersion($pdo, '1.2.13');
|
|
return true;
|
|
} catch (PDOException $e) {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
function updateUserTable1213_1214($prefix, $version, $dbname) {
|
|
$pdo = $this->pdo;
|
|
try {
|
|
if ($version != "1.2.13") {
|
|
$ret = $this->updateUserTable1212_1213($prefix, $version, $dbname);
|
|
if (!$ret) {
|
|
echo "Version update v1.2.12 to 1.2.13 not successful.";
|
|
return false;
|
|
}
|
|
}
|
|
|
|
DbUtils::overrulePrefix($prefix);
|
|
|
|
$this->updateVersion($pdo, '1.2.14');
|
|
return true;
|
|
} catch (PDOException $e) {
|
|
echo "Error in v1.2.13 to 1.2.14: $e";
|
|
return false;
|
|
}
|
|
}
|
|
|
|
function updateUserTable1214_1215($prefix, $version, $dbname) {
|
|
$pdo = $this->pdo;
|
|
try {
|
|
if ($version != "1.2.14") {
|
|
$ret = $this->updateUserTable1213_1214($prefix, $version, $dbname);
|
|
if (!$ret) {
|
|
echo "Version update v1.2.13 to 1.2.14 not successful.";
|
|
return false;
|
|
}
|
|
}
|
|
|
|
DbUtils::overrulePrefix($prefix);
|
|
|
|
$this->execSql($pdo, "ALTER TABLE %queue% MODIFY readytime DATETIME NULL");
|
|
$this->execSqlWithParam($pdo, "UPDATE %queue% SET readytime=? WHERE readytime=?",array(null,'0000-00-00 00:00:00'));
|
|
$this->execSqlWithParam($pdo, "UPDATE %queue% SET paidtime=? WHERE paidtime=?",array(null,'0000-00-00 00:00:00'));
|
|
$this->execSqlWithParam($pdo, "UPDATE %queue% SET delivertime=? WHERE delivertime=?",array(null,'0000-00-00 00:00:00'));
|
|
$this->execSql($pdo, "OPTIMIZE TABLE %queue%");
|
|
|
|
$this->updateVersion($pdo, '1.2.15');
|
|
return true;
|
|
} catch (PDOException $e) {
|
|
echo "Error in v1.2.14 to 1.2.15: $e";
|
|
return false;
|
|
}
|
|
}
|
|
|
|
function updateUserTable1215_1216($prefix, $version, $dbname) {
|
|
$pdo = $this->pdo;
|
|
try {
|
|
if ($version != "1.2.15") {
|
|
$ret = $this->updateUserTable1214_1215($prefix, $version, $dbname);
|
|
if (!$ret) {
|
|
echo "Version update v1.2.14 to 1.2.15 not successful.";
|
|
return false;
|
|
}
|
|
}
|
|
|
|
DbUtils::overrulePrefix($prefix);
|
|
|
|
$this->updateVersion($pdo, '1.2.16');
|
|
return true;
|
|
} catch (PDOException $e) {
|
|
echo "Error in v1.2.15 to 1.2.16: $e";
|
|
return false;
|
|
}
|
|
}
|
|
|
|
function updateUserTable1216_1217($prefix, $version, $dbname) {
|
|
$pdo = $this->pdo;
|
|
try {
|
|
if ($version != "1.2.16") {
|
|
$ret = $this->updateUserTable1215_1216($prefix, $version, $dbname);
|
|
if (!$ret) {
|
|
echo "Version update v1.2.15 to 1.2.16 not successful.";
|
|
return false;
|
|
}
|
|
}
|
|
|
|
DbUtils::overrulePrefix($prefix);
|
|
|
|
$this->updateVersion($pdo, '1.2.17');
|
|
return true;
|
|
} catch (PDOException $e) {
|
|
echo "Error in v1.2.16 to 1.2.17: $e";
|
|
return false;
|
|
}
|
|
}
|
|
|
|
function updateUserTable1217_1218($prefix, $version, $dbname) {
|
|
$pdo = $this->pdo;
|
|
try {
|
|
if ($version != "1.2.17") {
|
|
$ret = $this->updateUserTable1216_1217($prefix, $version, $dbname);
|
|
if (!$ret) {
|
|
echo "Version update v1.2.16 to 1.2.17 not successful.";
|
|
return false;
|
|
}
|
|
}
|
|
|
|
DbUtils::overrulePrefix($prefix);
|
|
|
|
$sql = "INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL,?,?)";
|
|
$stmt = $pdo->prepare($this->basedb->resolveTablenamesInSqlString($sql));
|
|
$stmt->execute(array('printandqueuejobs','0'));
|
|
$stmt->execute(array('cashenabled','1'));
|
|
$stmt->execute(array('beepcooked','0'));
|
|
|
|
$this->updateVersion($pdo, '1.2.18');
|
|
return true;
|
|
} catch (PDOException $e) {
|
|
echo "Error in v1.2.17 to 1.2.18: $e";
|
|
return false;
|
|
}
|
|
}
|
|
|
|
function updateUserTable1218_1219($prefix, $version, $dbname) {
|
|
$pdo = $this->pdo;
|
|
try {
|
|
if ($version != "1.2.18") {
|
|
$ret = $this->updateUserTable1217_1218($prefix, $version, $dbname);
|
|
if (!$ret) {
|
|
echo "Version update v1.2.17 to 1.2.18 not successful.";
|
|
return false;
|
|
}
|
|
}
|
|
|
|
DbUtils::overrulePrefix($prefix);
|
|
|
|
$sql = "INSERT INTO %payment% (id,name,name_en,name_esp) VALUES (?,?,?,?)";
|
|
$stmt = $pdo->prepare($this->basedb->resolveTablenamesInSqlString($sql));
|
|
$stmt->execute(array('7', 'Hotelzimmer','Hotel room','Habitación'));
|
|
|
|
$this->basedb->createHsinTable($pdo);
|
|
$this->basedb->createHsoutTable($pdo);
|
|
|
|
$sql = "ALTER TABLE %bill% ADD reservationid VARCHAR(30) NULL AFTER reason";
|
|
$stmt = $pdo->prepare(DbUtils::substTableAlias($sql));
|
|
$stmt->execute();
|
|
$sql = "ALTER TABLE %bill% ADD guestinfo VARCHAR(30) NULL AFTER reservationid";
|
|
$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('memorylimit','256'));
|
|
|
|
$this->updateVersion($pdo, '1.2.19');
|
|
return true;
|
|
} catch (PDOException $e) {
|
|
echo "Error in v1.2.18 to 1.2.19: $e";
|
|
return false;
|
|
}
|
|
}
|
|
|
|
function updateUserTable1219_1220($prefix, $version, $dbname) {
|
|
$pdo = $this->pdo;
|
|
try {
|
|
if ($version != "1.2.19") {
|
|
$ret = $this->updateUserTable1218_1219($prefix, $version, $dbname);
|
|
if (!$ret) {
|
|
echo "Version update v1.2.18 to 1.2.19 not successful.";
|
|
return false;
|
|
}
|
|
}
|
|
|
|
DbUtils::overrulePrefix($prefix);
|
|
|
|
$this->updateVersion($pdo, '1.2.20');
|
|
return true;
|
|
} catch (PDOException $e) {
|
|
echo "Error in v1.2.19 to 1.2.20: $e";
|
|
return false;
|
|
}
|
|
}
|
|
|
|
function updateUserTable1220_1221($prefix, $version, $dbname) {
|
|
$pdo = $this->pdo;
|
|
try {
|
|
if ($version != "1.2.20") {
|
|
$ret = $this->updateUserTable1219_1220($prefix, $version, $dbname);
|
|
if (!$ret) {
|
|
echo "Version update v1.2.19 to 1.2.20 not successful.";
|
|
return false;
|
|
}
|
|
}
|
|
|
|
DbUtils::overrulePrefix($prefix);
|
|
|
|
$sql = "INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL,?,?)";
|
|
$stmt = $pdo->prepare($this->basedb->resolveTablenamesInSqlString($sql));
|
|
$stmt->execute(array('hs3refresh','60'));
|
|
|
|
$this->updateVersion($pdo, '1.2.21');
|
|
return true;
|
|
} catch (PDOException $e) {
|
|
echo "Error in v1.2.20 to 1.2.21: $e";
|
|
return false;
|
|
}
|
|
}
|
|
|
|
function updateUserTable1221_1222($prefix, $version, $dbname) {
|
|
$pdo = $this->pdo;
|
|
try {
|
|
if ($version != "1.2.21") {
|
|
$ret = $this->updateUserTable1220_1221($prefix, $version, $dbname);
|
|
if (!$ret) {
|
|
echo "Version update v1.2.20 to 1.2.21 not successful.";
|
|
return false;
|
|
}
|
|
}
|
|
|
|
DbUtils::overrulePrefix($prefix);
|
|
|
|
$this->updateVersion($pdo, '1.2.22');
|
|
return true;
|
|
} catch (PDOException $e) {
|
|
echo "Error in v1.2.21 to 1.2.22: $e";
|
|
return false;
|
|
}
|
|
}
|
|
|
|
|
|
function updateUserTable1222_1300($prefix, $version, $dbname) {
|
|
$pdo = $this->pdo;
|
|
try {
|
|
if ($version != "1.2.22") {
|
|
$ret = $this->updateUserTable1221_1222($prefix, $version, $dbname);
|
|
if (!$ret) {
|
|
echo "Version update v1.2.21 to 1.2.22 not successful.";
|
|
return false;
|
|
}
|
|
}
|
|
|
|
DbUtils::overrulePrefix($prefix);
|
|
|
|
$sql = "INSERT INTO %payment% (id,name,name_en,name_esp) VALUES (?,?,?,?)";
|
|
$stmt = $pdo->prepare($this->basedb->resolveTablenamesInSqlString($sql));
|
|
$stmt->execute(array('8', 'Gast','Guest','Cliente'));
|
|
|
|
$sql = "ALTER TABLE %user% ADD right_customers INT (1) NULL AFTER right_changeprice";
|
|
$stmt = $pdo->prepare(DbUtils::substTableAlias($sql));
|
|
$stmt->execute();
|
|
$sql = "UPDATE %user% SET right_customers=right_manager";
|
|
$stmt = $pdo->prepare(DbUtils::substTableAlias($sql));
|
|
$stmt->execute();
|
|
$sql = "ALTER TABLE %user% MODIFY right_customers INT (1) NOT NULL";
|
|
$stmt = $pdo->prepare(DbUtils::substTableAlias($sql));
|
|
$stmt->execute();
|
|
$this->execSql($pdo, "OPTIMIZE TABLE %user%");
|
|
|
|
$sql = "ALTER TABLE %histuser% ADD right_customers INT (1) NULL AFTER right_changeprice";
|
|
$stmt = $pdo->prepare(DbUtils::substTableAlias($sql));
|
|
$stmt->execute();
|
|
$sql = "UPDATE %histuser% SET right_customers=?";
|
|
$stmt = $pdo->prepare(DbUtils::substTableAlias($sql));
|
|
$stmt->execute(array(0));
|
|
$sql = "ALTER TABLE %histuser% MODIFY right_customers INT (1) NOT NULL";
|
|
$stmt = $pdo->prepare(DbUtils::substTableAlias($sql));
|
|
$stmt->execute();
|
|
$this->execSql($pdo, "OPTIMIZE TABLE %histuser%");
|
|
|
|
$this->basedb->createCustomersTable($pdo);
|
|
$this->basedb->createGroupsTable($pdo);
|
|
$this->basedb->createGroupCustomerTable($pdo);
|
|
$this->basedb->createVacationsTable($pdo);
|
|
|
|
$sql = "ALTER TABLE %bill% ADD intguestid INT(10) NULL AFTER guestinfo";
|
|
$stmt = $pdo->prepare(DbUtils::substTableAlias($sql));
|
|
$stmt->execute();
|
|
$sql = "ALTER TABLE %bill% ADD intguestpaid INT(2) NULL AFTER intguestid";
|
|
$stmt = $pdo->prepare(DbUtils::substTableAlias($sql));
|
|
$stmt->execute();
|
|
$sql = "ALTER TABLE %bill% ADD FOREIGN KEY (intguestid) REFERENCES %customers%(id)";
|
|
$stmt = $pdo->prepare(DbUtils::substTableAlias($sql));
|
|
$stmt->execute();
|
|
$this->execSql($pdo, "OPTIMIZE TABLE %bill%");
|
|
|
|
$sql = "INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL,?,?)";
|
|
$stmt = $pdo->prepare($this->basedb->resolveTablenamesInSqlString($sql));
|
|
$stmt->execute(array('restaurantmode','1'));
|
|
|
|
$this->updateVersion($pdo, '1.3.0');
|
|
return true;
|
|
} catch (PDOException $e) {
|
|
echo "Error in v1.2.22 to 1.3.0: $e";
|
|
return false;
|
|
}
|
|
}
|
|
|
|
function updateUserTable1300_1301($prefix, $version, $dbname) {
|
|
$pdo = $this->pdo;
|
|
try {
|
|
if ($version != "1.3.0") {
|
|
$ret = $this->updateUserTable1222_1300($prefix, $version, $dbname);
|
|
if (!$ret) {
|
|
echo "Version update v1.2.22 to 1.3.0 not successful.";
|
|
return false;
|
|
}
|
|
}
|
|
|
|
DbUtils::overrulePrefix($prefix);
|
|
|
|
$this->basedb->createCustomerLogTable($pdo);
|
|
|
|
$sql = "INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL,?,?)";
|
|
$stmt = $pdo->prepare($this->basedb->resolveTablenamesInSqlString($sql));
|
|
$stmt->execute(array('cancelguestcode',''));
|
|
|
|
$this->updateVersion($pdo, '1.3.1');
|
|
return true;
|
|
} catch (PDOException $e) {
|
|
echo "Error in v1.3.0 to 1.3.1: $e";
|
|
return false;
|
|
}
|
|
}
|
|
|
|
function updateUserTable1301_1302($prefix, $version, $dbname) {
|
|
$pdo = $this->pdo;
|
|
try {
|
|
if ($version != "1.3.1") {
|
|
$ret = $this->updateUserTable1300_1301($prefix, $version, $dbname);
|
|
if (!$ret) {
|
|
echo "Version update v1.3.0 to 1.3.1 not successful.";
|
|
return false;
|
|
}
|
|
}
|
|
|
|
DbUtils::overrulePrefix($prefix);
|
|
|
|
$sql = "INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL,?,?)";
|
|
$stmt = $pdo->prepare($this->basedb->resolveTablenamesInSqlString($sql));
|
|
$stmt->execute(array('returntoorder','1'));
|
|
|
|
$this->updateVersion($pdo, '1.3.2');
|
|
return true;
|
|
} catch (PDOException $e) {
|
|
echo "Error in v1.3.1 to 1.3.2: $e";
|
|
return false;
|
|
}
|
|
}
|
|
|
|
function updateUserTable1302_1303($prefix, $version, $dbname) {
|
|
$pdo = $this->pdo;
|
|
try {
|
|
if ($version != "1.3.2") {
|
|
$ret = $this->updateUserTable1301_1302($prefix, $version, $dbname);
|
|
if (!$ret) {
|
|
echo "Version update v1.3.1 to 1.3.2 not successful.";
|
|
return false;
|
|
}
|
|
}
|
|
|
|
DbUtils::overrulePrefix($prefix);
|
|
|
|
$sql = "SHOW COLUMNS FROM %customers% LIKE 'hello'";
|
|
$stmt = $pdo->prepare(DbUtils::substTableAlias($sql));
|
|
$stmt->execute();
|
|
$result = $stmt->fetchAll();
|
|
if (count($result) == 0) {
|
|
$this->execSql($pdo, "ALTER TABLE %customers% ADD hello VARCHAR(100) NULL AFTER www");
|
|
$this->execSql($pdo, "ALTER TABLE %customers% ADD regards VARCHAR(100) NULL AFTER hello");
|
|
$this->execSql($pdo, "OPTIMIZE TABLE %customers%");
|
|
}
|
|
|
|
$sql = "INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL,?,?)";
|
|
$stmt = $pdo->prepare($this->basedb->resolveTablenamesInSqlString($sql));
|
|
$stmt->execute(array('rksvserver',''));
|
|
|
|
$this->updateVersion($pdo, '1.3.3');
|
|
return true;
|
|
} catch (PDOException $e) {
|
|
echo "Error in v1.3.2 to 1.3.3: $e";
|
|
return false;
|
|
}
|
|
}
|
|
|
|
function updateUserTable1303_1304($prefix, $version, $dbname) {
|
|
$pdo = $this->pdo;
|
|
try {
|
|
if ($version != "1.3.3") {
|
|
$ret = $this->updateUserTable1302_1303($prefix, $version, $dbname);
|
|
if (!$ret) {
|
|
echo "Version update v1.3.2 to 1.3.3 not successful.";
|
|
return false;
|
|
}
|
|
}
|
|
|
|
DbUtils::overrulePrefix($prefix);
|
|
|
|
$this->updateVersion($pdo, '1.3.4');
|
|
return true;
|
|
} catch (PDOException $e) {
|
|
echo "Error in v1.3.3 to 1.3.4: $e";
|
|
return false;
|
|
}
|
|
}
|
|
|
|
function updateUserTable1304_1305($prefix, $version, $dbname) {
|
|
$pdo = $this->pdo;
|
|
try {
|
|
if ($version != "1.3.4") {
|
|
$ret = $this->updateUserTable1303_1304($prefix, $version, $dbname);
|
|
if (!$ret) {
|
|
echo "Version update v1.3.3 to 1.3.4 not successful.";
|
|
return false;
|
|
}
|
|
}
|
|
|
|
DbUtils::overrulePrefix($prefix);
|
|
|
|
$this->updateVersion($pdo, '1.3.5');
|
|
return true;
|
|
} catch (PDOException $e) {
|
|
echo "Error in v1.3.4 to 1.3.5: $e";
|
|
return false;
|
|
}
|
|
}
|
|
|
|
function updateUserTable1305_1306($prefix, $version, $dbname) {
|
|
$pdo = $this->pdo;
|
|
try {
|
|
if ($version != "1.3.5") {
|
|
$ret = $this->updateUserTable1304_1305($prefix, $version, $dbname);
|
|
if (!$ret) {
|
|
echo "Version update v1.3.4 to 1.3.5 not successful.";
|
|
return false;
|
|
}
|
|
}
|
|
|
|
DbUtils::overrulePrefix($prefix);
|
|
|
|
$this->updateVersion($pdo, '1.3.6');
|
|
return true;
|
|
} catch (PDOException $e) {
|
|
echo "Error in v1.3.5 to 1.3.6: $e";
|
|
return false;
|
|
}
|
|
}
|
|
|
|
function updateUserTable1306_1307($prefix, $version, $dbname) {
|
|
$pdo = $this->pdo;
|
|
try {
|
|
if ($version != "1.3.6") {
|
|
$ret = $this->updateUserTable1305_1306($prefix, $version, $dbname);
|
|
if (!$ret) {
|
|
echo "Version update v1.3.5 to 1.3.6 not successful.";
|
|
return false;
|
|
}
|
|
}
|
|
|
|
DbUtils::overrulePrefix($prefix);
|
|
|
|
$this->execSqlWithParam($pdo, "INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL,?,?)", array('updateurl','http://www.ordersprinter.de/update'));
|
|
|
|
$this->updateVersion($pdo, '1.3.7');
|
|
return true;
|
|
} catch (PDOException $e) {
|
|
echo "Error in v1.3.6 to 1.3.7: $e";
|
|
return false;
|
|
}
|
|
}
|
|
|
|
function updateUserTable1307_1308($prefix, $version, $dbname) {
|
|
$pdo = $this->pdo;
|
|
try {
|
|
if ($version != "1.3.7") {
|
|
$ret = $this->updateUserTable1306_1307($prefix, $version, $dbname);
|
|
if (!$ret) {
|
|
echo "Version update v1.3.6 to 1.3.7 not successful.";
|
|
return false;
|
|
}
|
|
}
|
|
|
|
DbUtils::overrulePrefix($prefix);
|
|
|
|
$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();
|
|
}
|
|
|
|
$sql = "INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL,?,?)";
|
|
$stmt = $pdo->prepare($this->basedb->resolveTablenamesInSqlString($sql));
|
|
$stmt->execute(array('discountname1',''));
|
|
$stmt->execute(array('discountname2',''));
|
|
$stmt->execute(array('discountname3',''));
|
|
|
|
$this->updateVersion($pdo, '1.3.8');
|
|
return true;
|
|
} catch (PDOException $e) {
|
|
echo "Error in v1.3.7 to 1.3.8: $e";
|
|
return false;
|
|
}
|
|
}
|
|
|
|
function updateUserTable1308_1309($prefix, $version, $dbname) {
|
|
$pdo = $this->pdo;
|
|
try {
|
|
if ($version != "1.3.8") {
|
|
$ret = $this->updateUserTable1307_1308($prefix, $version, $dbname);
|
|
if (!$ret) {
|
|
echo "Version update v1.3.7 to 1.3.8 not successful.";
|
|
return false;
|
|
}
|
|
}
|
|
|
|
DbUtils::overrulePrefix($prefix);
|
|
|
|
$this->execSql($pdo, "ALTER TABLE %products% ADD unit INT(2) NULL AFTER priceC");
|
|
$this->execSql($pdo, "ALTER TABLE %histprod% ADD unit INT(2) NULL AFTER priceC");
|
|
|
|
$this->updateVersion($pdo, '1.3.9');
|
|
|
|
$this->execSql($pdo, "ALTER TABLE %products% ADD days VARCHAR(20) NULL AFTER unit");
|
|
$this->execSql($pdo, "ALTER TABLE %histprod% ADD days VARCHAR(20) NULL AFTER unit");
|
|
|
|
$this->execSql($pdo, "ALTER TABLE %user% ADD failedlogins VARCHAR(20) NULL AFTER extrasapplybtnpos");
|
|
|
|
return true;
|
|
} catch (PDOException $e) {
|
|
echo "Error in v1.3.8 to 1.3.9: $e";
|
|
return false;
|
|
}
|
|
}
|
|
|
|
function updateUserTable1309_1310($prefix, $version, $dbname) {
|
|
$pdo = $this->pdo;
|
|
try {
|
|
if ($version != "1.3.9") {
|
|
$ret = $this->updateUserTable1308_1309($prefix, $version, $dbname);
|
|
if (!$ret) {
|
|
echo "Version update v1.3.8 to 1.3.9 not successful.";
|
|
return false;
|
|
}
|
|
}
|
|
|
|
DbUtils::overrulePrefix($prefix);
|
|
|
|
$sql = "INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL,?,?)";
|
|
$stmt = $pdo->prepare($this->basedb->resolveTablenamesInSqlString($sql));
|
|
$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($this->basedb->resolveTablenamesInSqlString($sql));
|
|
$stmt->execute(array("paymentconfig"));
|
|
$row = $stmt->fetchObject();
|
|
$paymentconfig = $row->setting;
|
|
$sql = "INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL,?,?)";
|
|
$stmt = $pdo->prepare($this->basedb->resolveTablenamesInSqlString($sql));
|
|
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'));
|
|
}
|
|
|
|
$this->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++;
|
|
}
|
|
|
|
$this->updateVersion($pdo, '1.3.10');
|
|
|
|
return true;
|
|
} catch (PDOException $e) {
|
|
echo "Error in v1.3.9 to 1.3.10: $e";
|
|
return false;
|
|
}
|
|
}
|
|
|
|
function updateUserTable1310_1311($prefix, $version, $dbname) {
|
|
$pdo = $this->pdo;
|
|
try {
|
|
if ($version != "1.3.10") {
|
|
$ret = $this->updateUserTable1309_1310($prefix, $version, $dbname);
|
|
if (!$ret) {
|
|
echo "Version update v1.3.9 to 1.3.10 not successful.";
|
|
return false;
|
|
}
|
|
}
|
|
|
|
DbUtils::overrulePrefix($prefix);
|
|
|
|
$sql = "INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL,?,?)";
|
|
$stmt = $pdo->prepare($this->basedb->resolveTablenamesInSqlString($sql));
|
|
$hosttext = self::genSampleHostText();
|
|
$stmt->execute(array('hosttext',$hosttext));
|
|
|
|
$this->updateVersion($pdo, '1.3.11');
|
|
|
|
return true;
|
|
} catch (PDOException $e) {
|
|
echo "Error in v1.3.10 to 1.3.11: $e";
|
|
return false;
|
|
}
|
|
}
|
|
|
|
function updateUserTable1311_1312($prefix, $version, $dbname) {
|
|
$pdo = $this->pdo;
|
|
try {
|
|
if ($version != "1.3.11") {
|
|
$ret = $this->updateUserTable1310_1311($prefix, $version, $dbname);
|
|
if (!$ret) {
|
|
echo "Version update v1.3.10 to 1.3.11 not successful.";
|
|
return false;
|
|
}
|
|
}
|
|
|
|
DbUtils::overrulePrefix($prefix);
|
|
|
|
$this->updateVersion($pdo, '1.3.12');
|
|
|
|
return true;
|
|
} catch (PDOException $e) {
|
|
echo "Error in v1.3.11 to 1.3.12: $e";
|
|
return false;
|
|
}
|
|
}
|
|
|
|
function updateUserTable1312_1313($prefix, $version, $dbname) {
|
|
$pdo = $this->pdo;
|
|
try {
|
|
if ($version != "1.3.12") {
|
|
$ret = $this->updateUserTable1311_1312($prefix, $version, $dbname);
|
|
if (!$ret) {
|
|
echo "Version update v1.3.11 to 1.3.12 not successful.";
|
|
return false;
|
|
}
|
|
}
|
|
|
|
DbUtils::overrulePrefix($prefix);
|
|
|
|
$this->updateVersion($pdo, '1.3.13');
|
|
|
|
return true;
|
|
} catch (PDOException $e) {
|
|
echo "Error in v1.3.12 to 1.3.13: $e";
|
|
return false;
|
|
}
|
|
}
|
|
|
|
function updateUserTable1313_1314($prefix, $version, $dbname) {
|
|
$pdo = $this->pdo;
|
|
try {
|
|
if ($version != "1.3.13") {
|
|
$ret = $this->updateUserTable1312_1313($prefix, $version, $dbname);
|
|
if (!$ret) {
|
|
echo "Version update v1.3.12 to 1.3.13 not successful.";
|
|
return false;
|
|
}
|
|
}
|
|
|
|
DbUtils::overrulePrefix($prefix);
|
|
|
|
$sql = "INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL,?,?)";
|
|
$stmt = $pdo->prepare($this->basedb->resolveTablenamesInSqlString($sql));
|
|
$stmt->execute(array('k1prinstance','1'));
|
|
$stmt->execute(array('k2prinstance','1'));
|
|
$stmt->execute(array('k3prinstance','1'));
|
|
$stmt->execute(array('k4prinstance','1'));
|
|
$stmt->execute(array('k5prinstance','1'));
|
|
$stmt->execute(array('k6prinstance','1'));
|
|
$stmt->execute(array('d1prinstance','1'));
|
|
$stmt->execute(array('d2prinstance','1'));
|
|
$stmt->execute(array('f1prinstance','1'));
|
|
$stmt->execute(array('f2prinstance','1'));
|
|
|
|
$stmt->execute(array('dashslot1','1'));
|
|
$stmt->execute(array('dashslot2','2'));
|
|
$stmt->execute(array('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) {
|
|
$this->execSql($pdo, "ALTER TABLE %user% ADD right_dash INT(2) NULL AFTER right_closing");
|
|
$this->execSql($pdo, "ALTER TABLE %histuser% ADD right_dash INT(2) NULL AFTER right_closing");
|
|
|
|
$this->execSqlWithParam($pdo, "UPDATE %user% SET right_dash=?", array(0));
|
|
$this->execSqlWithParam($pdo, "UPDATE %histuser% SET right_dash=?", array(0));
|
|
|
|
$this->execSqlWithParam($pdo, "UPDATE %user% SET right_dash=? WHERE right_manager=? OR is_admin=?", array(1,1,1));
|
|
$this->execSqlWithParam($pdo, "UPDATE %histuser% SET right_dash=? WHERE right_manager=? OR is_admin=?", array(1,1,1));
|
|
|
|
$this->execSql($pdo, "OPTIMIZE TABLE %user%");
|
|
$this->execSql($pdo, "OPTIMIZE TABLE %histuser%");
|
|
}
|
|
|
|
$this->updateVersion($pdo, '1.3.14');
|
|
|
|
return true;
|
|
} catch (PDOException $e) {
|
|
echo "Error in v1.3.13 to 1.3.14: $e";
|
|
return false;
|
|
}
|
|
}
|
|
|
|
function updateUserTable1314_1315($prefix, $version, $dbname) {
|
|
$pdo = $this->pdo;
|
|
try {
|
|
if ($version != "1.3.14") {
|
|
$ret = $this->updateUserTable1313_1314($prefix, $version, $dbname);
|
|
if (!$ret) {
|
|
echo "Version update v1.3.13 to 1.3.14 not successful.";
|
|
return false;
|
|
}
|
|
}
|
|
|
|
DbUtils::overrulePrefix($prefix);
|
|
|
|
$this->updateVersion($pdo, '1.3.15');
|
|
|
|
return true;
|
|
} catch (PDOException $e) {
|
|
echo "Error in v1.3.14 to 1.3.15: $e";
|
|
return false;
|
|
}
|
|
}
|
|
|
|
function updateUserTable1315_1316($prefix, $version, $dbname) {
|
|
$pdo = $this->pdo;
|
|
try {
|
|
if ($version != "1.3.15") {
|
|
$ret = $this->updateUserTable1314_1315($prefix, $version, $dbname);
|
|
if (!$ret) {
|
|
echo "Version update v1.3.14 to 1.3.15 not successful.";
|
|
return false;
|
|
}
|
|
}
|
|
|
|
DbUtils::overrulePrefix($prefix);
|
|
|
|
$sql = "UPDATE %config% SET name=? WHERE name=?";
|
|
$stmt = $pdo->prepare($this->basedb->resolveTablenamesInSqlString($sql));
|
|
$stmt->execute(array('groupworkitemsf','groupworkitems'));
|
|
|
|
$sql = "SELECT setting FROM %config% WHERE name=?";
|
|
$stmt = $pdo->prepare($this->basedb->resolveTablenamesInSqlString($sql));
|
|
$stmt->execute(array('groupworkitemsf'));
|
|
$row = $stmt->fetchObject();
|
|
$groupworkitemsf = $row->setting;
|
|
|
|
$sql = "INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL,?,?)";
|
|
$stmt = $pdo->prepare($this->basedb->resolveTablenamesInSqlString($sql));
|
|
$stmt->execute(array('groupworkitemsd',$groupworkitemsf));
|
|
|
|
$sql = "UPDATE %config% SET name=? WHERE name=?";
|
|
$stmt = $pdo->prepare($this->basedb->resolveTablenamesInSqlString($sql));
|
|
$stmt->execute(array('oneprodworkrecf','oneprodworkreceipts'));
|
|
|
|
$sql = "SELECT setting FROM %config% WHERE name=?";
|
|
$stmt = $pdo->prepare($this->basedb->resolveTablenamesInSqlString($sql));
|
|
$stmt->execute(array('oneprodworkrecf'));
|
|
$row = $stmt->fetchObject();
|
|
$oneprodworkrecf = $row->setting;
|
|
|
|
$sql = "INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL,?,?)";
|
|
$stmt = $pdo->prepare($this->basedb->resolveTablenamesInSqlString($sql));
|
|
$stmt->execute(array('oneprodworkrecd',$oneprodworkrecf));
|
|
|
|
$this->updateVersion($pdo, '1.3.16');
|
|
|
|
return true;
|
|
} catch (PDOException $e) {
|
|
echo "Error in v1.3.15 to 1.3.16: $e";
|
|
return false;
|
|
}
|
|
}
|
|
|
|
function updateUserTable1316_1317($prefix, $version, $dbname) {
|
|
$pdo = $this->pdo;
|
|
try {
|
|
if ($version != "1.3.16") {
|
|
$ret = $this->updateUserTable1315_1316($prefix, $version, $dbname);
|
|
if (!$ret) {
|
|
echo "Version update v1.3.15 to 1.3.16 not successful.";
|
|
return false;
|
|
}
|
|
}
|
|
|
|
DbUtils::overrulePrefix($prefix);
|
|
|
|
$sql = "INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL,?,?)";
|
|
$stmt = $pdo->prepare($this->basedb->resolveTablenamesInSqlString($sql));
|
|
$stmt->execute(array('dblog','1'));
|
|
|
|
$this->updateVersion($pdo, '1.3.17');
|
|
|
|
return true;
|
|
} catch (PDOException $e) {
|
|
echo "Error in v1.3.16 to 1.3.17: $e";
|
|
return false;
|
|
}
|
|
}
|
|
|
|
function updateUserTable1317_1318($prefix, $version, $dbname) {
|
|
$pdo = $this->pdo;
|
|
try {
|
|
if ($version != "1.3.17") {
|
|
$ret = $this->updateUserTable1316_1317($prefix, $version, $dbname);
|
|
if (!$ret) {
|
|
echo "Version update v1.3.16 to 1.3.17 not successful.";
|
|
return false;
|
|
}
|
|
}
|
|
|
|
DbUtils::overrulePrefix($prefix);
|
|
|
|
$sql = "INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL,?,?)";
|
|
$stmt = $pdo->prepare($this->basedb->resolveTablenamesInSqlString($sql));
|
|
$stmt->execute(array('startprodsearch','3'));
|
|
|
|
$this->updateVersion($pdo, '1.3.18');
|
|
|
|
return true;
|
|
} catch (PDOException $e) {
|
|
echo "Error in v1.3.17 to 1.3.18: $e";
|
|
return false;
|
|
}
|
|
}
|
|
|
|
function updateUserTable1318_1319($prefix, $version, $dbname) {
|
|
$pdo = $this->pdo;
|
|
try {
|
|
if ($version != "1.3.18") {
|
|
$ret = $this->updateUserTable1317_1318($prefix, $version, $dbname);
|
|
if (!$ret) {
|
|
echo "Version update v1.3.17 to 1.3.18 not successful.";
|
|
return false;
|
|
}
|
|
}
|
|
|
|
DbUtils::overrulePrefix($prefix);
|
|
$sql = "INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL,?,?)";
|
|
$stmt = $pdo->prepare($this->basedb->resolveTablenamesInSqlString($sql));
|
|
$stmt->execute(array('priceinlist','0'));
|
|
|
|
$this->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) {
|
|
$this->execSql($pdo, "ALTER TABLE %products% ADD prodimageid INT(10) NULL AFTER audio");
|
|
$this->execSql($pdo, "OPTIMIZE TABLE %products%");
|
|
|
|
$this->execSql($pdo, "ALTER TABLE %histprod% ADD prodimageid INT(10) NULL AFTER audio");
|
|
$this->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();
|
|
}
|
|
|
|
$this->updateVersion($pdo, '1.3.19');
|
|
|
|
return true;
|
|
} catch (PDOException $e) {
|
|
echo "Error in v1.3.18 to 1.3.19: $e";
|
|
return false;
|
|
}
|
|
}
|
|
|
|
function updateUserTable1319_1320($prefix, $version, $dbname) {
|
|
$pdo = $this->pdo;
|
|
try {
|
|
if ($version != "1.3.19") {
|
|
$ret = $this->updateUserTable1318_1319($prefix, $version, $dbname);
|
|
if (!$ret) {
|
|
echo "Version update v1.3.18 to 1.3.19 not successful.";
|
|
return false;
|
|
}
|
|
}
|
|
|
|
DbUtils::overrulePrefix($prefix);
|
|
|
|
$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));
|
|
}
|
|
|
|
$this->updateVersion($pdo, '1.3.20');
|
|
|
|
return true;
|
|
} catch (PDOException $e) {
|
|
echo "Error in v1.3.19 to 1.3.20: $e";
|
|
return false;
|
|
}
|
|
}
|
|
|
|
function updateUserTable1320_1321($prefix, $version, $dbname) {
|
|
$pdo = $this->pdo;
|
|
try {
|
|
if ($version != "1.3.20") {
|
|
$ret = $this->updateUserTable1319_1320($prefix, $version, $dbname);
|
|
if (!$ret) {
|
|
echo "Version update v1.3.19 to 1.3.20 not successful.";
|
|
return false;
|
|
}
|
|
}
|
|
|
|
DbUtils::overrulePrefix($prefix);
|
|
|
|
$this->updateVersion($pdo, '1.3.21');
|
|
|
|
return true;
|
|
} catch (PDOException $e) {
|
|
echo "Error in v1.3.20 to 1.3.21: $e";
|
|
return false;
|
|
}
|
|
}
|
|
|
|
|
|
function updateUserTable1321_1322($prefix, $version, $dbname) {
|
|
$pdo = $this->pdo;
|
|
try {
|
|
if ($version != "1.3.21") {
|
|
$ret = $this->updateUserTable1320_1321($prefix, $version, $dbname);
|
|
if (!$ret) {
|
|
echo "Version update v1.3.20 to 1.3.21 not successful.";
|
|
return false;
|
|
}
|
|
}
|
|
|
|
DbUtils::overrulePrefix($prefix);
|
|
|
|
$this->execSqlWithParam($pdo, "INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL,?,?)", array('tmpdir',''));
|
|
$this->execSqlWithParam($pdo, "INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL,?,?)", array('ftphost',''));
|
|
$this->execSqlWithParam($pdo, "INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL,?,?)", array('ftpuser',''));
|
|
$this->execSqlWithParam($pdo, "INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL,?,?)", array('ftppass',''));
|
|
|
|
$this->updateVersion($pdo, '1.3.22');
|
|
|
|
return true;
|
|
} catch (PDOException $e) {
|
|
echo "Error in v1.3.21 to 1.3.22: $e";
|
|
return false;
|
|
}
|
|
}
|
|
|
|
function updateUserTable1322_1323($prefix, $version, $dbname) {
|
|
$pdo = $this->pdo;
|
|
try {
|
|
if ($version != "1.3.22") {
|
|
$ret = $this->updateUserTable1321_1322($prefix, $version, $dbname);
|
|
if (!$ret) {
|
|
echo "Version update v1.3.21 to 1.3.22 not successful.";
|
|
return false;
|
|
}
|
|
}
|
|
|
|
DbUtils::overrulePrefix($prefix);
|
|
|
|
$this->insertIntRow($pdo,"%printjobs%","removed","printer");
|
|
$this->insertIntRow($pdo,"%queue%","printjobid","workprinted");
|
|
|
|
$cancelTemplate = $this->getDefaultCancelWorkTemplate();
|
|
$sql = "INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL,?,?)";
|
|
$stmt = $pdo->prepare($this->basedb->resolveTablenamesInSqlString($sql));
|
|
$stmt->execute(array('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) {
|
|
|
|
$this->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($this->basedb->resolveTablenamesInSqlString($sql));
|
|
$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($this->basedb->resolveTablenamesInSqlString($sql));
|
|
$stmt->execute($params);
|
|
$allUserIdsOfThatRole = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
|
|
|
foreach($allUserIdsOfThatRole as $u) {
|
|
$sql = "UPDATE %user% SET roleid=? WHERE id=?";
|
|
$stmt = $pdo->prepare($this->basedb->resolveTablenamesInSqlString($sql));
|
|
$stmt->execute(array($newroleid,$u["id"]));
|
|
}
|
|
|
|
$i++;
|
|
}
|
|
|
|
foreach ($existingRights as $r) {
|
|
$sql = "ALTER TABLE %user% DROP COLUMN " . $r;
|
|
$stmt = $pdo->prepare($this->basedb->resolveTablenamesInSqlString($sql));
|
|
$stmt->execute();
|
|
}
|
|
|
|
$sql = "UPDATE %user% SET roleid=? WHERE active='0'";
|
|
$stmt = $pdo->prepare($this->basedb->resolveTablenamesInSqlString($sql));
|
|
$stmt->execute(array(null));
|
|
|
|
$sql = "OPTIMIZE TABLE %user%";
|
|
$stmt = $pdo->prepare($this->basedb->resolveTablenamesInSqlString($sql));
|
|
$stmt->execute(array(null));
|
|
}
|
|
|
|
$this->updateVersion($pdo, '1.3.23');
|
|
|
|
return true;
|
|
} catch (PDOException $e) {
|
|
echo "Error in v1.3.22 to 1.3.23: $e";
|
|
return false;
|
|
}
|
|
}
|
|
|
|
function updateUserTable1323_1324($prefix, $version, $dbname) {
|
|
$pdo = $this->pdo;
|
|
try {
|
|
if ($version != "1.3.23") {
|
|
$ret = $this->updateUserTable1322_1323($prefix, $version, $dbname);
|
|
if (!$ret) {
|
|
echo "Version update v1.3.22 to 1.3.23 not successful.";
|
|
return false;
|
|
}
|
|
}
|
|
|
|
DbUtils::overrulePrefix($prefix);
|
|
|
|
$this->updateVersion($pdo, '1.3.24');
|
|
|
|
return true;
|
|
} catch (PDOException $e) {
|
|
echo "Error in v1.3.23 to 1.3.24: $e";
|
|
return false;
|
|
}
|
|
}
|
|
|
|
|
|
function insertIntRow($pdo,$table,$rowToInsert,$afterRow) {
|
|
$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 INT(1) NULL AFTER $afterRow";
|
|
$stmt = $pdo->prepare(DbUtils::substTableAlias($sql));
|
|
$stmt->execute();
|
|
}
|
|
}
|
|
|
|
|
|
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);
|
|
}
|
|
|
|
function getDefaultCustomRecTemplate() {
|
|
$rect = "l;\nt:llllllllllllllllllll; f: ; a_ID:rrrrrrrr\n;f: ;d:w\n\ng:v; c:v\n\nk:rrr; s: ; m:v; s: ; n:rrrrrr; o:rrrrrrr\nf:-\n";
|
|
$rect .= "START_PRODUCTS\na:rrr; s: ; c:v; s: ; b:rrrrrr; d:rrrrrrr\nEND_PRODUCTS\n\n";
|
|
$rect .= "p:rrrrr; q:rrrrrr; r:rrrrrrrr; n:rrrrrrrr\nSTART_TAXES\nt:rrrrr; m:rrrrrr; n:rrrrrrrr; b:rrrrrrrr\nEND_TAXES\n\n";
|
|
$rect .= "f: ; E_Summe:llllllllllllllllllll;\n\nj:l;";
|
|
return $rect;
|
|
}
|
|
|
|
function getDefaultWorkTemplateFood() {
|
|
$rect = "SS:Speisen\n\ni_ID:v\nt:v\nz:v\n";
|
|
$rect .= "\n";
|
|
$rect .= "START_WORK\n";
|
|
$rect .= "f:-;\n";
|
|
$rect .= "N:v;\ns: ;b:v;\n";
|
|
$rect .= "e:v\n";
|
|
$rect .= "END_WORK\n";
|
|
$rect .= "f:-";
|
|
return $rect;
|
|
}
|
|
|
|
function getDefaultWorkTemplateDrinks() {
|
|
$rect = "SS:Getränke\n\ni_ID:v\nt:v\nz:v\n";
|
|
$rect .= "\n";
|
|
$rect .= "START_WORK\n";
|
|
$rect .= "f:-;\n";
|
|
$rect .= "N:v;\ns: ;b:v;\n";
|
|
$rect .= "e:v\n";
|
|
$rect .= "END_WORK\n";
|
|
$rect .= "f:-";
|
|
return $rect;
|
|
}
|
|
|
|
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;
|
|
}
|
|
|
|
function createTables($decpoint,$billlanguage,$currency,$timezone)
|
|
{
|
|
$pdo = $this->pdo;
|
|
|
|
$this->basedb->setTimeZone($timezone);
|
|
|
|
$this->basedb->dropTables($pdo);
|
|
|
|
$this->basedb->createLogTable($pdo);
|
|
$this->basedb->createRatingsTable($pdo);
|
|
$this->createPaymentTable($pdo);
|
|
$this->basedb->createRolesTable($pdo);
|
|
$this->basedb->createUserTable($pdo);
|
|
$this->basedb->createRoomTable($pdo);
|
|
$this->basedb->createRestTables($pdo);
|
|
$this->basedb->createTableMapsTable($pdo);
|
|
$this->basedb->createTablePosTable($pdo);
|
|
$this->basedb->createConfigTable($pdo);
|
|
$this->basedb->createProdTypeTable($pdo);
|
|
$this->basedb->createProdimagesTable($pdo);
|
|
$this->basedb->createProductTable($pdo);
|
|
$this->basedb->createPriceLevelTable($pdo);
|
|
$this->basedb->createClosingTable($pdo);
|
|
$this->basedb->createCustomersTable($pdo);
|
|
$this->basedb->createGroupsTable($pdo);
|
|
$this->basedb->createGroupCustomerTable($pdo);
|
|
$this->basedb->createVacationsTable($pdo);
|
|
$this->basedb->createBillTable($pdo);
|
|
$this->basedb->createCustomerLogTable($pdo);
|
|
$this->basedb->createQueueTable($pdo);
|
|
$this->basedb->createBillProductsTable($pdo);
|
|
$this->basedb->createHistTables($pdo);
|
|
$this->defineHistActions($pdo);
|
|
$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);
|
|
$this->basedb->createHsinTable($pdo);
|
|
$this->basedb->createHsoutTable($pdo);
|
|
|
|
|
|
$rect = $this->getDefaultCustomRecTemplate();
|
|
$foodtemplate = $this->getDefaultWorkTemplateFood();
|
|
$drinktemplate = $this->getDefaultWorkTemplateDrinks();
|
|
$canceltemplate = $this->getDefaultCancelWorkTemplate();
|
|
|
|
$printpass = md5("123");
|
|
|
|
$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')");
|
|
|
|
$this->basedb->doSQL($pdo,"INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'pricelevel', '1')");
|
|
$this->basedb->doSQL($pdo,"INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'tax', '19.0')");
|
|
$this->basedb->doSQL($pdo,"INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'togotax', '7.0')");
|
|
$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')");
|
|
$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')");
|
|
$this->basedb->doSQL($pdo,"INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'companyinfo', 'Musterrestaurant\nBeispielstrasse 123\n12345 Musterort')");
|
|
$this->basedb->doSQL($pdo,"INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'rectemplate', '$rect')");
|
|
$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')");
|
|
$this->basedb->doSQL($pdo,"INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'canceltemplate', '$canceltemplate')");
|
|
$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', '')");
|
|
$this->basedb->doSQL($pdo,"INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'receiveremail', '')");
|
|
$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')");
|
|
$this->basedb->doSQL($pdo,"INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'receiptfontsize', '12')");
|
|
$this->basedb->doSQL($pdo,"INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'version', '1.3.24')");
|
|
$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\nBeispielstrasse 123\n12345 Musterort')");
|
|
$this->basedb->doSQL($pdo,"INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'cancelunpaidcode', '')");
|
|
$this->basedb->doSQL($pdo,"INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'bigfontworkreceipt', '0')");
|
|
$this->basedb->doSQL($pdo,"INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'prominentsearch', '0')");
|
|
$this->basedb->doSQL($pdo,"INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'groupworkitemsf', '1')");
|
|
$this->basedb->doSQL($pdo,"INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'groupworkitemsd', '1')");
|
|
$this->basedb->doSQL($pdo,"INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'addreceipttoprinter', null)");
|
|
|
|
$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')");
|
|
|
|
$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')");
|
|
$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')");
|
|
$this->basedb->doSQL($pdo,"INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'rksvserver', '')");
|
|
|
|
$this->basedb->doSQL($pdo,"INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'digigopaysetready', '1')");
|
|
$this->basedb->doSQL($pdo,"INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'waitergopayprint', '0')");
|
|
|
|
$this->basedb->doSQL($pdo,"INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'oneprodworkrecf', '0')");
|
|
$this->basedb->doSQL($pdo,"INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'oneprodworkrecd', '0')");
|
|
$this->basedb->doSQL($pdo,"INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'digiprintwork', '1')");
|
|
|
|
$this->basedb->doSQL($pdo,"INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'printandqueuejobs', '0')");
|
|
$this->basedb->doSQL($pdo,"INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'cashenabled', '1')");
|
|
$this->basedb->doSQL($pdo,"INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'beepcooked', '0')");
|
|
$this->basedb->doSQL($pdo,"INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'hotelinterface', '0')");
|
|
$this->basedb->doSQL($pdo,"INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'hsinfile', '')");
|
|
$this->basedb->doSQL($pdo,"INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'hsoutfile', '')");
|
|
$this->basedb->doSQL($pdo,"INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'hscurrency', 'EUR')");
|
|
$this->basedb->doSQL($pdo,"INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'hs3refresh', '60')");
|
|
$this->basedb->doSQL($pdo,"INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'memorylimit', '512')");
|
|
$this->basedb->doSQL($pdo,"INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'updateurl', 'http://www.ordersprinter.de/update')");
|
|
$this->basedb->doSQL($pdo,"INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'tmpdir', '')");
|
|
$this->basedb->doSQL($pdo,"INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'ftphost', '')");
|
|
$this->basedb->doSQL($pdo,"INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'ftpuser', '')");
|
|
$this->basedb->doSQL($pdo,"INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'ftppass', '')");
|
|
$this->basedb->doSQL($pdo,"INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'restaurantmode', '1')");
|
|
$this->basedb->doSQL($pdo,"INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'dblog', '1')");
|
|
$this->basedb->doSQL($pdo,"INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'priceinlist', '0')");
|
|
$this->basedb->doSQL($pdo,"INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'startprodsearch', '3')");
|
|
$this->basedb->doSQL($pdo,"INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'returntoorder', '1')");
|
|
|
|
$this->basedb->doSQL($pdo,"INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'discountname1', '')");
|
|
$this->basedb->doSQL($pdo,"INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'discountname2', '')");
|
|
$this->basedb->doSQL($pdo,"INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'discountname3', '')");
|
|
|
|
$this->basedb->doSQL($pdo,"INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'closshowci', '1')");
|
|
$this->basedb->doSQL($pdo,"INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'closshowpaytaxes', '1')");
|
|
$this->basedb->doSQL($pdo,"INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'closshowprods', '1')");
|
|
|
|
$this->basedb->doSQL($pdo,"INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'showpayment2', '1')");
|
|
$this->basedb->doSQL($pdo,"INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'showpayment3', '1')");
|
|
$this->basedb->doSQL($pdo,"INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'showpayment4', '1')");
|
|
$this->basedb->doSQL($pdo,"INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'showpayment5', '1')");
|
|
$this->basedb->doSQL($pdo,"INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'showpayment6', '1')");
|
|
$this->basedb->doSQL($pdo,"INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'showpayment7', '1')");
|
|
$this->basedb->doSQL($pdo,"INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'showpayment8', '1')");
|
|
|
|
$this->basedb->doSQL($pdo,"INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'dashslot1', '1')");
|
|
$this->basedb->doSQL($pdo,"INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'dashslot2', '2')");
|
|
$this->basedb->doSQL($pdo,"INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'dashslot3', '3')");
|
|
|
|
$hosttext = self::genSampleHostText();
|
|
$this->basedb->doSQL($pdo,"INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'hosttext', '$hosttext')");
|
|
|
|
// 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->basedb->doSQL($pdo,"INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'k1prinstance', '1')");
|
|
$this->basedb->doSQL($pdo,"INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'k2prinstance', '1')");
|
|
$this->basedb->doSQL($pdo,"INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'k3prinstance', '1')");
|
|
$this->basedb->doSQL($pdo,"INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'k4prinstance', '1')");
|
|
$this->basedb->doSQL($pdo,"INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'k5prinstance', '1')");
|
|
$this->basedb->doSQL($pdo,"INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'k6prinstance', '1')");
|
|
$this->basedb->doSQL($pdo,"INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'd1prinstance', '1')");
|
|
$this->basedb->doSQL($pdo,"INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'd2prinstance', '1')");
|
|
$this->basedb->doSQL($pdo,"INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'f1prinstance', '1')");
|
|
$this->basedb->doSQL($pdo,"INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'f2prinstance', '1')");
|
|
|
|
$this->readConfigTableAndSendToHist($pdo);
|
|
return;
|
|
}
|
|
|
|
public static function genSampleHostText() {
|
|
$hosttext = "\n\nAngaben zum Nachweis der Höhe\nund der betrieblichen\nVeranlassung von\nBewirtungsaufwendungen\n(Par. 4 Abs. 5 Ziff. 2 EStG)\n\n";
|
|
$hosttext .= "Tag der Bewirtung:\n\n\n";
|
|
$hosttext .= "Ort der Bewirtung:\n\n\n";
|
|
$hosttext .= "Bewirtete Person(en):\n\n\n\n\n\n";
|
|
$hosttext .= "Anlass der Bewirtung:\n\n\n\n\n\n\n";
|
|
$hosttext .= "Ort, Datum Unterschrift\n\n";
|
|
return $hosttext;
|
|
}
|
|
|
|
public 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;
|
|
}
|
|
}
|
|
|
|
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;
|
|
}
|
|
}
|
|
|
|
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);
|
|
}
|
|
}
|
|
|
|
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));
|
|
}
|
|
|
|
|
|
function insertUser($username,$adminpass,$roleid,$lang,$prefertablemap) {
|
|
$md5adminpass = md5($adminpass);
|
|
$pdo = $this->pdo;
|
|
|
|
$userInsertSql = "INSERT INTO `%user%` (`username` , `userpassword`, `roleid`,`language`,`prefertablemap`,`keeptypelevel`,`extrasapplybtnpos`,`showplusminus`,`preferimgdesk`,`preferimgmobile`,`active`) "
|
|
. "VALUES (?,?,?,?,?,?,'1','1','1','1','1')";
|
|
$stmt = $pdo->prepare(DbUtils::substTableAlias($userInsertSql));
|
|
$stmt->execute(array($username,$md5adminpass,$roleid,$lang,$prefertablemap,0));
|
|
|
|
$newUserIdForHist = $pdo->lastInsertId();
|
|
|
|
HistFiller::createUserInHist($pdo, $newUserIdForHist);
|
|
}
|
|
|
|
function createPaymentTable($pdo) {
|
|
$this->basedb->createPaymentTable($pdo);
|
|
|
|
$sql = "INSERT INTO %payment% (id,name,name_en,name_esp) VALUES (?,?,?,?)";
|
|
$stmt = $pdo->prepare($this->basedb->resolveTablenamesInSqlString($sql));
|
|
|
|
$stmt->execute(array('1', 'Barzahlung', 'Cash', 'Contado'));
|
|
$stmt = $pdo->prepare($this->basedb->resolveTablenamesInSqlString($sql));
|
|
|
|
$stmt->execute(array('2', 'EC-Kartenzahlung','Electr. purse (EC)','Pago con tarjeta EC'));
|
|
$stmt = $pdo->prepare($this->basedb->resolveTablenamesInSqlString($sql));
|
|
$stmt->execute(array('3', 'Kreditkartenzahlung','Credit card','Tarjeta de credito'));
|
|
$stmt = $pdo->prepare($this->basedb->resolveTablenamesInSqlString($sql));
|
|
$stmt->execute(array('4', 'Rechnung','bill','Factura'));
|
|
$stmt = $pdo->prepare($this->basedb->resolveTablenamesInSqlString($sql));
|
|
$stmt->execute(array('5', 'Ueberweisung','Bank transfer','Transferencia'));
|
|
$stmt = $pdo->prepare($this->basedb->resolveTablenamesInSqlString($sql));
|
|
$stmt->execute(array('6', 'Lastschrift','Debit','Cargo en cuenta'));
|
|
$stmt = $pdo->prepare($this->basedb->resolveTablenamesInSqlString($sql));
|
|
$stmt->execute(array('7', 'Hotelzimmer','Hotel room','Habitación'));
|
|
$stmt = $pdo->prepare($this->basedb->resolveTablenamesInSqlString($sql));
|
|
$stmt->execute(array('8', 'Gast','Guest','Cliente'));
|
|
}
|
|
|
|
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'));
|
|
}
|
|
|
|
function testDbConnection($host,$dbname,$user,$pass) {
|
|
$pdo = $this->openDbAndReturnPdo($host,$dbname,$user,$pass);
|
|
if (!is_null($pdo)) {
|
|
echo json_encode("OK");
|
|
} else {
|
|
echo json_encode("ERROR");
|
|
}
|
|
}
|
|
|
|
function writeConfigFile($host,$db,$user,$password,$prefix) {
|
|
$errorlevel = "<?php\nerror_reporting(E_ALL);\n\n"; // development: E_ALL
|
|
|
|
$hostlines = "// Zum Aufbau der Verbindung zur Datenbank\n";
|
|
$hostlines .= "// die Daten erhalten Sie von Ihrem Provider\n";
|
|
$hostlines .= "defined('MYSQL_HOST') || define ( 'MYSQL_HOST','$host' );";
|
|
$userlines = "defined('MYSQL_USER') || define ( 'MYSQL_USER', '$user' );";
|
|
$dbpasslines = "defined('MYSQL_PASSWORD') || define ( 'MYSQL_PASSWORD', '$password' );";
|
|
$dblines = "defined('MYSQL_DB') || define ( 'MYSQL_DB', '$db' );";
|
|
$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) {
|
|
$sslconfig = array(
|
|
"digest_alg" => "sha512",
|
|
"private_key_bits" => 4096,
|
|
"private_key_type" => OPENSSL_KEYTYPE_RSA,
|
|
);
|
|
// thus the signature is exactly 512 bytes
|
|
|
|
// Create the private and public key
|
|
$res = openssl_pkey_new($sslconfig);
|
|
if (is_null($res) || ($res=="")) {
|
|
// openssl may be incorrectly installed
|
|
return false;
|
|
}
|
|
|
|
// 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);
|
|
$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) {
|
|
Basedb::loadSampleProdImages($pdo);
|
|
$menu = file_get_contents("../customer/speisekarte.txt");
|
|
$adminCl->fillSpeisekarteCore($pdo, $menu, false);
|
|
}
|
|
|
|
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) {
|
|
$roleid = Roles::insertWorkWaiterRole($pdo);
|
|
$this->insertUser($waiterTxt[$lang], $adminpass, $roleid, $lang, 1);
|
|
|
|
if ($level == 3) {
|
|
$roleid = Roles::insertWorkManagerRole($pdo);
|
|
$this->insertUser($bossTxt[$lang], $adminpass, $roleid, $lang, 1);
|
|
}
|
|
} else {
|
|
$roleid = Roles::insertDigiWaiterRole($pdo);
|
|
$this->insertUser($waiterTxt[$lang], $adminpass, $roleid, $lang, 1);
|
|
|
|
if ($level == 3) {
|
|
$roleid = Roles::insertCookRole($pdo);
|
|
$this->insertUser($cookTxt[$lang], $adminpass, $roleid, $lang, 1);
|
|
|
|
$roleid = Roles::insertDigiManagerRole($pdo);
|
|
$this->insertUser($bossTxt[$lang], $adminpass, $roleid, $lang, 1);
|
|
}
|
|
}
|
|
|
|
|
|
$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);
|
|
}
|
|
|
|
if ($level == 1) {
|
|
$sql = "UPDATE %user% SET preferimgdesk=?,preferimgmobile=?";
|
|
$stmt = $pdo->prepare(DbUtils::substTableAlias($sql));
|
|
$stmt->execute(array(0,0));
|
|
}
|
|
}
|
|
}
|
|
|
|
$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 {
|
|
if (isset($_POST['host']) && isset($_POST['dbname']) && isset($_POST['user']) && isset($_POST['pass'])) {
|
|
$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;
|
|
}
|
|
$roleid = Roles::insertAdminRole($pdo);
|
|
$admin->insertUser("admin", $_POST['adminpass'], $roleid, $_POST['lang'], 1);
|
|
$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') {
|
|
$installerVersion = "1.3.24";
|
|
|
|
$admin = new InstallAdmin();
|
|
$pdo = $admin->openDbAndReturnPdo($_POST['host'],$_POST['db'],$_POST['user'],$_POST['password']);
|
|
$admin->setPdo($pdo);
|
|
$admin->setPrefix($_POST['prefix']);
|
|
|
|
$isPreviousInstallation = $admin->isTherePreviousVersion($_POST['db'],$_POST['prefix']);
|
|
if (!$isPreviousInstallation) {
|
|
echo json_encode("Stimmt der Tabellenpräfix?");
|
|
return;
|
|
}
|
|
|
|
$version = $admin->getCurrentVersion();
|
|
if ($version == $installerVersion) {
|
|
echo json_encode("Version bereits installiert");
|
|
return;
|
|
}
|
|
|
|
if (is_null($version)) {
|
|
echo json_encode("Version nicht bestimmbar");
|
|
return;
|
|
}
|
|
|
|
$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",
|
|
"1.0.40","1.0.41","1.0.42","1.0.43",
|
|
"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",
|
|
"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",
|
|
"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","1.2.12","1.2.13","1.2.14","1.2.15","1.2.16","1.2.17",
|
|
"1.2.18","1.2.19","1.2.20","1.2.21","1.2.22","1.3.0","1.3.1","1.3.2","1.3.3","1.3.4","1.3.5","1.3.6","1.3.7","1.3.8","1.3.9","1.3.10","1.3.11","1.3.12",
|
|
"1.3.13","1.3.14","1.3.15","1.3.16","1.3.17","1.3.18","1.3.19","1.3.20","1.3.21","1.3.22","1.3.23"
|
|
);
|
|
|
|
if (!in_array($version, $supportedVersions)) {
|
|
echo json_encode("Quellversion nicht unterstützt");
|
|
return;
|
|
}
|
|
|
|
$ret = $admin->updateUserTable1323_1324($_POST['prefix'], $version, $_POST['db']);
|
|
|
|
if(session_id() == '') {
|
|
session_start();
|
|
}
|
|
session_destroy();
|
|
|
|
$autoupdate = $_POST["autoupdate"];
|
|
try {
|
|
if ($autoupdate == 1) {
|
|
unlink("../install/installer.php");
|
|
if (file_exists("../install/phpinfo.php")) {
|
|
unlink("../install/phpinfo.php");
|
|
}
|
|
rmdir("../install");
|
|
}
|
|
} catch (Exception $e) {
|
|
echo json_encode("Install-Verzeichnis lässt sich nicht löschen: ". $e->getMessage());
|
|
return;
|
|
}
|
|
|
|
if ($ret) {
|
|
$admin->writeConfigFile($_POST['host'],$_POST['db'],$_POST['user'],$_POST['password'],$_POST['prefix']);
|
|
echo json_encode("OK");
|
|
} else {
|
|
echo json_encode("ERROR");
|
|
}
|
|
} |