OrderSprinter 1.4.8

This commit is contained in:
Geno 2020-11-19 23:10:26 +01:00
parent 29d9104286
commit 0984d9236f
41 changed files with 1835 additions and 3804 deletions

View File

@ -9,8 +9,8 @@
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta name="author" content="Stefan Pichel">
<link rel="stylesheet" href="css/gueststyle.css?v=1.4.7" />
<link rel="stylesheet" href="php/3rdparty/orderstyle/orderstyle.min.css?v=1.4.7" />
<link rel="stylesheet" href="css/gueststyle.css?v=1.4.8" />
<link rel="stylesheet" href="php/3rdparty/orderstyle/orderstyle.min.css?v=1.4.8" />
<link rel="stylesheet" href="php/3rdparty/orderstyle/jquery.mobile.icons.min.css" />
<link rel="stylesheet" href="php/3rdparty/jquery.mobile-1.4.0.min.css" type="text/css" />
<script src="php/3rdparty/jquery-1.11.3.min.js"></script>
@ -105,7 +105,7 @@
<div data-role="footer" data-theme="b" id="thefooter1">
<div class="ui-grid-a">
<div class="ui-block-a">&nbsp;&nbsp;OrderSprinter</div>
<div class="ui-block-b grid_right" id="versioninfo">1.4.7&nbsp;&nbsp;</div>
<div class="ui-block-b grid_right" id="versioninfo">1.4.8&nbsp;&nbsp;</div>
</div><!-- /grid-a -->
</div>
</div>

View File

@ -90,10 +90,10 @@ if (isset($_POST['code'])) {
} else {
echo "<html>";
echo "<head><title>Installation Gastsystem</title>";
echo '<link rel="stylesheet" type="text/css" href="css/gueststyle.css?v=1.4.7">';
echo '<link rel="stylesheet" type="text/css" href="css/gueststyle.css?v=1.4.8">';
echo "</head>";
echo "<body><div class=surround>";
echo "<span class=headerline>Installation OrderSprinter-Gastsystem 1.4.7</span><br><br>";
echo "<span class=headerline>Installation OrderSprinter-Gastsystem 1.4.8</span><br><br>";
echo "<form action='install.php' method='post'><input class=installfield name=code id=code type=text placeholder='Installationscode' />";
echo "<br><input type=submit value='Installation starten' class=installbtn />";
echo "</form></div></html>";

Binary file not shown.

View File

@ -85,7 +85,7 @@ class Installer {
}
Database::dropTables($pdo);
Database::createEmptyTables($pdo, $prefix);
Database::setVersion($pdo,$prefix,"1.4.7");
Database::setVersion($pdo,$prefix,"1.4.8");
Database::setAccessPassword($pdo,$prefix,$adminpass);
Database::setRefreshRate($pdo,$prefix,"5"); // default: 5 times per hour
return array("status" => "OK","msg" => "Installation successful");

Binary file not shown.

View File

@ -5,7 +5,7 @@
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta name="author" content="Stefan Pichel">
<link rel="stylesheet" type="text/css" href="css/bestformat.css?v=1.4.7">
<link rel="stylesheet" type="text/css" href="css/bestformat.css?v=1.4.8">
<link rel="stylesheet" href="php/contenthandler.php?module=admin&command=getmobilecss" />
<link rel="stylesheet" href="php/3rdparty/orderstyle/jquery.mobile.icons.min.css" />

View File

@ -5,7 +5,7 @@
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta name="author" content="Stefan Pichel">
<link rel="stylesheet" type="text/css" href="css/bestformat.css?v=1.4.7">
<link rel="stylesheet" type="text/css" href="css/bestformat.css?v=1.4.8">
<link rel="stylesheet" href="php/contenthandler.php?module=admin&command=getmobilecss" />
<link rel="stylesheet" href="php/3rdparty/orderstyle/jquery.mobile.icons.min.css" />

File diff suppressed because one or more lines are too long

View File

@ -4,7 +4,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<link rel="stylesheet" type="text/css" href="css/bestformat.css?v=1.4.7">
<link rel="stylesheet" type="text/css" href="css/bestformat.css?v=1.4.8">
<link rel="stylesheet" href="php/contenthandler.php?module=admin&command=getmobilecss" />
<link rel="stylesheet" href="php/3rdparty/orderstyle/jquery.mobile.icons.min.css" />
@ -52,15 +52,15 @@
<script>
var FEED_SENT_TXT = ["Wenn eine Kopie der Nachricht an die angegebene Emailadresse gesendet wurde, scheint der Mailversand an den Entwickler erfolgreich gewesen zu sein.",
"If a copy of the mail was sent to the given email address the mail transfer to the developer seems to be successful.",
"Si una copia del email ha sido enviado a su dirección, el transmisión al programador tuvo probablemente éxito."];
var FEED_SENT_TXT = ["Feedback übermittelt.",
"Feedback sent.",
"Mensaje enviado."];
var FEED_ERROR_TXT = ["Fehler beim Nachrichtenversand: ","Error during mail transmisión: ","Error durante envío del mail: "];
var FEED_INFO_TXT = ["Diese Seite dient zur Übermittlung von Feedback an den Entwickler. Die Email wird über das Mailkonto des Betreibers versendet.",
"This page serves for sending a feedmail email to the developer of this software. The email will be send by use of the mail account of the administrator.",
"Esta página sirve para enviar un email al programador de este software. El email va a ser enviado por la cuenta del administrador."];
var FEED_INFO_TXT = ["Diese Seite dient zur Übermittlung von Feedback an den Entwickler. Das funktioniert nur, wenn der OrderSprinter-Server eine Verbindung ins Internet hat.",
"This page can be used to transmit a message to the developer. It only works if the OrderSprinter server is connected to the internet.",
"Esta página sirve para enviar un mensaje al programador de este software. Un acceso al internet esta necesario."];
var FEED_LABEL_ROLE = ["Rolle:","Role:","Posición:"];
var FEED_LABEL_WAITER = ["Kellner","Waiter","Camarero"];
@ -83,7 +83,6 @@ var FEED_PLEASE_TEL = ["Bitte <i>Telefonnummer</i> angeben, wenn eine <b>Antwort
"Por favor, inserte un número de telefono si quiere recibir una <b>respuesta</b> por telefono."];
var FEED_EMPTY_MSG = ["Nachrichtenfeld ist leer.","Message box is empty.","No hay ningún noticia."];
var FEED_MISS_EMAIL = ["Email-Adresse angeben!","Missing email address","Falta dirección de email"];
var FEED_MAYBE_ANSWER = ["Eine Antwort des Entwicklers kann nicht garantiert werden! Informationen über den verwendeten Internetbrowser wird an den Entwickler gesendet, damit mögliche Fragen oder Probleme leichter identifiziert werden können.",
"An answer of the developer cannot be guaranteed. Information about the used browser will always be transmitted to the developer so that questions and problems can answered more easily.",
"Una respuesta del programador no se puede ser garantizado. Informaciones sobre el browser usado siempre esta enviado al programador para que él pueda apoyar más facilmente en caso de problemas o preguntas."];
@ -165,11 +164,6 @@ function binding() {
var content = $("#content").val();
var rights = $("#rights").val();
if (email == '') {
alert(FEED_MISS_EMAIL[lang]);
return;
}
if (content == '') {
alert(FEED_EMPTY_MSG[lang]);
return;
@ -184,15 +178,15 @@ function binding() {
content : content
};
doAjax("POST","php/contenthandler.php?module=feedback&command=sendMail",data,mailWasSent,"Fehler Nachrichtenversand");
doAjax("POST","php/contenthandler.php?module=feedback&command=sendMail",data,mailWasSent,"Fehler Nachrichtenversand",true);
});
}
function mailWasSent(jsonText) {
if (jsonText == "OK") {
if (jsonText.status == "OK") {
alert (FEED_SENT_TXT[lang]);
} else {
alert (FEED_ERROR_TXT[lang] + jsonText);
alert (FEED_ERROR_TXT[lang] + jsonText.msg);
}
$("#emailaddr").val("");

View File

@ -9,8 +9,8 @@
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta name="author" content="Stefan Pichel">
<link rel="stylesheet" type="text/css" href="css/bestformat.css?v=1.4.7">
<link rel="stylesheet" type="text/css" href="css/numfield.css?v=1.4.7">
<link rel="stylesheet" type="text/css" href="css/bestformat.css?v=1.4.8">
<link rel="stylesheet" type="text/css" href="css/numfield.css?v=1.4.8">
<link rel="stylesheet" href="php/3rdparty/orderstyle/orderstyle.min.css" />
<link rel="stylesheet" href="php/3rdparty/orderstyle/jquery.mobile.icons.min.css" />
@ -215,7 +215,7 @@ function handleResultOfInstallCheck(is_installed) {
if (is_installed == "Yes") {
useInstallation();
} else {
setTimeout(function(){document.location.href = "install.html?v=1.4.7"},500);
setTimeout(function(){document.location.href = "install.html?v=1.4.8"},500);
}
}

View File

@ -727,7 +727,7 @@ $(document).ready(function() {
<tr id=updateline>
<td>&nbsp;</td>
<td align=center>
<button id="updatebtn">Update -> 1.4.7</button>
<button id="updatebtn">Update -> 1.4.8</button>
<span id="updateinprogresstxt" style="display:none;">Update... bitte warten.</span>
</td>
<td>&nbsp;</td>

File diff suppressed because it is too large Load Diff

View File

@ -5,7 +5,7 @@
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta name="author" content="Stefan Pichel">
<link rel="stylesheet" type="text/css" href="css/bestformat.css?v=1.4.7">
<link rel="stylesheet" type="text/css" href="css/bestformat.css?v=1.4.8">
<link rel="stylesheet" href="php/contenthandler.php?module=admin&command=getmobilecss" />
<link rel="stylesheet" href="php/3rdparty/orderstyle/jquery.mobile.icons.min.css" />

View File

@ -5,7 +5,7 @@
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta name="author" content="Stefan Pichel">
<link rel="stylesheet" type="text/css" href="css/bestformat.css?v=1.4.7">
<link rel="stylesheet" type="text/css" href="css/bestformat.css?v=1.4.8">
<link rel="stylesheet" href="php/contenthandler.php?module=admin&command=getmobilecss" />
<link rel="stylesheet" href="php/3rdparty/orderstyle/jquery.mobile.icons.min.css" />
@ -395,6 +395,7 @@ var MAN_CREATECLOS_TXT = ["Tageserfassung erstellen","Create closing","Crear cer
var MAN_TMPDIRHINT = ["Wird das PHP-Tmp-Verzeichnis angegeben, so können z.B. komprimierte Backups erstellt werden. In der Regel sollte der Default-Wert der PHP-Umgebung stimmen, aber einige Provider biegen den Pfad um, ohne die PHP-Konfiguration anzupassen!",
"If the PHP tmp directory is set it is possible to create compressed backups and more. Usually the default value of the PHP framework should fit, but sometimes the providers change the tmp directory without adapting the PHP framework!",
"Si el tmp esta espcificado es posible crear backups comprimidos por ejemplo. Normalmente el valor default es corecto pero de vez en cuando los providers cambian el valor sin adaptar el PHP framework!"];
var MAN_IMPORT_IN_PROGRESS = ["Der Importvorgang ist aktiv. Bitte warten...","The import process is activated. Please wait...","El proceso del importe esta activo. Por favor espere un poco...."];
var lang = 0;
var generalVals = [12,2,0,3,0,1,1,0,0,1, 0,50,20,10,1,0,0,0,1,0,1,0,0,1,1, 1,1,1,1,1,1,1,1,1,1, 1,2,3, 1,0, 1,0,1, 1,1,0];
@ -1238,20 +1239,27 @@ function initRestoreFileUpload() {
showFileCounter: false,
dragDropStr: "<span>Datei zum Wiederherstellen</span>",
extErrorStr: " ist nicht erlaubt. Erlaubte Dateiendung: ",
onSubmit: function() {
$("#waitimportinprogress").html(MAN_IMPORT_IN_PROGRESS[lang] + ' <img id="progressimginpopup" src="php/3rdparty/images/ajax-loader.gif" />');
$("#waitimportinprogress").show();
},
onSuccess:function(files,data,xhr)
{
$("#waitimportinprogress").hide();
var answer = jQuery.parseJSON(data);
if (answer.status != "OK") {
alert("Upload war nicht erfolgreich: " + answer.msg);
} else {
alert("Import war erfolgreich.");
setTimeout(function(){
document.location.href = "index.html?v=1.4.7";
document.location.href = "index.html?v=1.4.8";
},250);
}
},
onError: function(files,status,errMsg)
{
$("#waitimportinprogress").hide();
$("#restorestatus").html("<font color='red'>Upload fehlgeschlagen</font>");
}
}
@ -1783,9 +1791,9 @@ function handleUpdateCheckResult(answer) {
var millis=getMillis();
setTimeout(function(){
document.location.href = "install.html?v=1.4.7&mode=onlyupdate&n=" + millis;
document.location.href = "install.html?v=1.4.8&mode=onlyupdate&n=" + millis;
},250);
document.location.href = "install.html?v=1.4.7&mode=onlyupdate&n=" + millis;
document.location.href = "install.html?v=1.4.8&mode=onlyupdate&n=" + millis;
}
function handleUpdateReplace(answer) {
@ -2792,7 +2800,7 @@ function createClosingPart (aText,id,totalsum,cashsum,usersums,taxessums,cashops
var receiverEmail = $("#receiveremail").val();
closingPart += '<fieldset class="ui-grid-a" id="emailfieldset' + id + '">';
closingPart += '<div class="ui-block-a">';
closingPart += '<input type="text" name="email_' + id + '" id="email_' + id + '" value="' + receiverEmail + '" class="whiteinput" /></div>';
closingPart += '<input type="email" name="email_' + id + '" id="email_' + id + '" value="' + receiverEmail + '" class="whiteinput" /></div>';
closingPart += '<div class="ui-block-b"><button type="submit" data-theme="c" class="csvEmailAllButton" data-icon="arrow-r" id="csvallemail_' + id + '">' + MAN_EMAIL_DATA[lang] + '</button></div>';
closingPart += '<button type="submit" data-theme="f" class="printButton" data-icon="check" id="printexport_' + id + '">' + MAN_PRINT_ALL[lang] + '</button>';
@ -3322,19 +3330,19 @@ $(document).on("pageinit", "#admin-page", function () {
</div>
<div data-role="fieldcontain">
<label for="email"><span id="fromemailtxt">Sender-Email:</span></label>
<input type="text" value="" data-mini="true" placeholder="gastwirt@anbieter.de" id="email" data-theme="c" class="genConfigEl"/>
<input type="email" value="" data-mini="true" placeholder="gastwirt@anbieter.de" id="email" data-theme="c" class="genConfigEl"/>
</div>
<div data-role="fieldcontain">
<label for="emailbadrating"><span id="emailbadratingtxt">Sender-Email:</span></label>
<input type="text" value="" data-mini="true" placeholder="gastwirt@anbieter.de" id="emailbadrating" data-theme="c" class="genConfigEl"/>
<input type="email" value="" data-mini="true" placeholder="gastwirt@anbieter.de" id="emailbadrating" data-theme="c" class="genConfigEl"/>
</div>
<div data-role="fieldcontain">
<label for="emailratingcontact"><span id="emailratingcontacttxt">Sender-Email:</span></label>
<input type="text" value="" data-mini="true" placeholder="gastwirt@anbieter.de" id="emailratingcontact" data-theme="c" class="genConfigEl"/>
<input type="email" value="" data-mini="true" placeholder="gastwirt@anbieter.de" id="emailratingcontact" data-theme="c" class="genConfigEl"/>
</div>
<div data-role="fieldcontain">
<label for="receiveremail"><span id="toemailtxt">Standard Emailempfänger:</span></label>
<input type="text" value="" data-mini="true" placeholder="gastwirt@anbieter.de" id="receiveremail" data-theme="c" class="genConfigEl"/>
<input type="email" value="" data-mini="true" placeholder="gastwirt@anbieter.de" id="receiveremail" data-theme="c" class="genConfigEl"/>
</div>
<div data-role="fieldcontain">
@ -3857,6 +3865,7 @@ $(document).on("pageinit", "#admin-page", function () {
<span id=uplfiletxt>Diese Datei hochladen (<i>importieren</i>):</span>
<div id="restorefilearea">Upload</div>
<div id="restorestatus"></div>
<div id="waitimportinprogress" style="display:none;">Warten...</div>
</div>
<p><button type="submit" data-theme="d" id="golive"><span id="golivetxt">Starte Produktivbetrieb</span></button>

View File

@ -5,7 +5,7 @@
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta name="author" content="Stefan Pichel">
<link rel="stylesheet" type="text/css" href="css/bestformat.css?v=1.4.7">
<link rel="stylesheet" type="text/css" href="css/bestformat.css?v=1.4.8">
<link rel="stylesheet" href="php/contenthandler.php?module=admin&command=getmobilecss" />
<link rel="stylesheet" href="php/3rdparty/orderstyle/jquery.mobile.icons.min.css" />

File diff suppressed because one or more lines are too long

View File

@ -10,6 +10,7 @@ require_once ('utilities/decimaldefs.php');
require_once ('utilities/sorter.php');
require_once ('utilities/Logger.php');
require_once ('utilities/Emailer.php');
require_once ('utilities/version.php');
require_once ('hotelinterface.php');
class Admin {
@ -76,6 +77,7 @@ class Admin {
"setKeepTypeLevel" => array("loggedin" => 1, "isadmin" => 0, "rights" => null),
"setMobileTheme" => array("loggedin" => 1, "isadmin" => 0, "rights" => null),
"setApplyExtrasBtnPos" => array("loggedin" => 1, "isadmin" => 0, "rights" => null),
"setTablesAfterSend" => array("loggedin" => 1, "isadmin" => 0, "rights" => null),
"setPreferimgdesk" => array("loggedin" => 1, "isadmin" => 0, "rights" => null),
"setPreferimgmobile" => array("loggedin" => 1, "isadmin" => 0, "rights" => null),
"setPrefershowplusminus" => array("loggedin" => 1, "isadmin" => 0, "rights" => null),
@ -86,6 +88,7 @@ class Admin {
"getKeepTypeLevel" => array("loggedin" => 1, "isadmin" => 0, "rights" => null),
"getMobileTheme" => array("loggedin" => 1, "isadmin" => 0, "rights" => null),
"getApplyExtrasBtnPos" => array("loggedin" => 1, "isadmin" => 0, "rights" => null),
"getTablesAfterSend" => array("loggedin" => 1, "isadmin" => 0, "rights" => null),
"getPreferimgdesk" => array("loggedin" => 1, "isadmin" => 0, "rights" => null),
"getPreferimgmobile" => array("loggedin" => 1, "isadmin" => 0, "rights" => null),
"getPrefershowplusminus" => array("loggedin" => 1, "isadmin" => 0, "rights" => null),
@ -305,6 +308,10 @@ class Admin {
if ($this->isUserAlreadyLoggedInForPhp()) {
$this->setExtrasApplyBtnPos($_POST['applyextrasbtnpos']);
}
} else if ($command == 'setTablesAfterSend') {
if ($this->isUserAlreadyLoggedInForPhp()) {
$this->setTablesAfterSend($_POST['tablesaftersend']);
}
} else if ($command == 'getOrderVolume') {
if ($this->isUserAlreadyLoggedInForPhp()) {
$this->getOrderVolume();
@ -347,6 +354,10 @@ class Admin {
if ($this->isUserAlreadyLoggedInForPhp()) {
$this->getApplyExtrasBtnPos();
}
} else if ($command == 'getTablesAfterSend') {
if ($this->isUserAlreadyLoggedInForPhp()) {
$this->getTablesAfterSend();
}
} else if ($command == 'isInstalled') {
$this->isInstalled();
} else if ($command == 'isPrinterServerActive') {
@ -814,6 +825,9 @@ class Admin {
self::getUserValue('extrasapplybtnpos', 1);
}
function getTablesAfterSend() {
self::getUserValue('tablesaftersend', 1);
}
function getOrderVolume() {
self::getUserValue('ordervolume',0);
}
@ -869,7 +883,12 @@ class Admin {
function setExtrasApplyBtnPos($preferValue) {
self::setUserValue('extrasapplybtnpos',$preferValue);
}
function setTablesAfterSend($preferValue) {
if ($preferValue == 1) {
$preferValue = null;
}
self::setUserValue('tablesaftersend',$preferValue);
}
function setLastModuleOfUser($view) {
if ($this->isUserAlreadyLoggedInForPhp()) {
if ($view != "logout.php") {
@ -962,7 +981,7 @@ class Admin {
$right_changeprice = 0;
$supplyRight = 0;
if ($userLoggedIn) {
$sql = "SELECT language,right_supply,right_changeprice,keeptypelevel,extrasapplybtnpos,right_paydesk,IFNULL(preferimgdesk,0) as preferimgdesk,IFNULL(preferimgmobile,0) as preferimgmobile,IFNULL(showplusminus,0) as showplusminus,IFNULL(preferfixbtns,0) as preferfixbtns FROM %user%,%roles% WHERE %user%.id=? AND %user%.roleid=%roles%.id";
$sql = "SELECT language,right_supply,right_changeprice,keeptypelevel,extrasapplybtnpos,right_paydesk,IFNULL(preferimgdesk,0) as preferimgdesk,IFNULL(preferimgmobile,0) as preferimgmobile,IFNULL(showplusminus,0) as showplusminus,IFNULL(preferfixbtns,0) as preferfixbtns,IFNULL(tablesaftersend,1) as tablesaftersend FROM %user%,%roles% WHERE %user%.id=? AND %user%.roleid=%roles%.id";
$stmt = $pdo->prepare(DbUtils::substTableAlias($sql));
$stmt->execute(array($_SESSION['userid']));
$row = $stmt->fetchObject();
@ -980,6 +999,7 @@ class Admin {
"buttonsizes" => $buttonSizes,
"keeptypelevel" => $row->keeptypelevel,
"extrasapplybtnpos" => $row->extrasapplybtnpos,
"tablesaftersend" => $row->tablesaftersend,
"isUserLoggedIn" => 1,
"jsonMenuItemsAndVersion" => $jsonMenuItems,
"preferimgdesk" => $row->preferimgdesk,
@ -1253,7 +1273,7 @@ class Admin {
$view = "preferences.html";
}
echo json_encode($view . "?v=1.4.7");
echo json_encode($view . "?v=1.4.8");
}
}
@ -1464,27 +1484,27 @@ class Admin {
if (!self::isOnlyRatingUser($rights, $right_rating, true)) {
if ($_SESSION['modus'] == 0) {
if ($_SESSION['right_waiter']) { $mainMenu[] = array("name" => $waitertxt[$lang], "link" => "waiter.html?v=1.4.7"); };
if ($_SESSION['right_waiter']) { $mainMenu[] = array("name" => $waitertxt[$lang], "link" => "waiter.html?v=1.4.8"); };
} else {
if ($_SESSION['right_waiter']) { $mainMenu[] = array("name" => $waiterdesktxt[$lang], "link" => "waiterdesktop.php?v=1.4.7"); };
if ($_SESSION['right_waiter']) { $mainMenu[] = array("name" => $waiterdesktxt[$lang], "link" => "waiterdesktop.php?v=1.4.8"); };
}
if ($_SESSION['right_kitchen']) { $mainMenu[] = array("name" => $kitchentxt[$lang], "link" => "kitchen.html?v=1.4.7"); };
if ($_SESSION['right_bar']) { $mainMenu[] = array("name" => "Bar", "link" => "bar.html?v=1.4.7"); };
if ($_SESSION['right_supply']) { $mainMenu[] = array("name" => $supplytxt[$lang], "link" => "supplydesk.html?v=1.4.7"); };
if ($_SESSION['right_kitchen']) { $mainMenu[] = array("name" => $kitchentxt[$lang], "link" => "kitchen.html?v=1.4.8"); };
if ($_SESSION['right_bar']) { $mainMenu[] = array("name" => "Bar", "link" => "bar.html?v=1.4.8"); };
if ($_SESSION['right_supply']) { $mainMenu[] = array("name" => $supplytxt[$lang], "link" => "supplydesk.html?v=1.4.8"); };
if ($_SESSION['modus'] == 0) {
if ($_SESSION['right_paydesk']) { $mainMenu[] = array("name" => $paydesktxt[$lang], "link" => "paydesk.html?v=1.4.7"); };
if ($_SESSION['right_paydesk']) { $mainMenu[] = array("name" => $paydesktxt[$lang], "link" => "paydesk.html?v=1.4.8"); };
}
if ($_SESSION['right_statistics']) { $mainMenu[] = array("name" => $stattxt[$lang], "link" => "reports.html?v=1.4.7"); };
if ($_SESSION['right_bill']) { $mainMenu[] = array("name" => $bontxt[$lang], "link" => "bill.html?v=1.4.7"); };
if ($_SESSION['right_products']) { $mainMenu[] = array("name" => $prodtxt[$lang], "link" => "products.html?v=1.4.7"); };
if ($_SESSION['right_reservation']) { $mainMenu[] = array("name" => $restxt[$lang], "link" => "reservation.html?v=1.4.7"); };
if ($_SESSION['right_rating']) { $mainMenu[] = array("name" => $ratingtxt[$lang], "link" => "rating.html?v=1.4.7"); };
if ($_SESSION['right_customers']) { $mainMenu[] = array("name" => $customerstxt[$lang], "link" => "customers.html?v=1.4.7"); };
if ($_SESSION['right_dash']) { $mainMenu[] = array("name" => $dashtxt[$lang], "link" => "dash.php?v=1.4.7"); };
if ($_SESSION['right_manager'] || $_SESSION['is_admin'] || $_SESSION['right_closing']) { $mainMenu[] = array("name" => $admintxt[$lang], "link" => "manager.html?v=1.4.7"); };
$mainMenu[] = array("name" => $settingtxt[$lang], "link" => "preferences.html?v=1.4.7");
$mainMenu[] = array("name" => "Hilfe", "link" => "help.php?v=1.4.7");
$mainMenu[] = array("name" => "Feedback", "link" => "feedback.html?v=1.4.7");
if ($_SESSION['right_statistics']) { $mainMenu[] = array("name" => $stattxt[$lang], "link" => "reports.html?v=1.4.8"); };
if ($_SESSION['right_bill']) { $mainMenu[] = array("name" => $bontxt[$lang], "link" => "bill.html?v=1.4.8"); };
if ($_SESSION['right_products']) { $mainMenu[] = array("name" => $prodtxt[$lang], "link" => "products.html?v=1.4.8"); };
if ($_SESSION['right_reservation']) { $mainMenu[] = array("name" => $restxt[$lang], "link" => "reservation.html?v=1.4.8"); };
if ($_SESSION['right_rating']) { $mainMenu[] = array("name" => $ratingtxt[$lang], "link" => "rating.html?v=1.4.8"); };
if ($_SESSION['right_customers']) { $mainMenu[] = array("name" => $customerstxt[$lang], "link" => "customers.html?v=1.4.8"); };
if ($_SESSION['right_dash']) { $mainMenu[] = array("name" => $dashtxt[$lang], "link" => "dash.php?v=1.4.8"); };
if ($_SESSION['right_manager'] || $_SESSION['is_admin'] || $_SESSION['right_closing']) { $mainMenu[] = array("name" => $admintxt[$lang], "link" => "manager.html?v=1.4.8"); };
$mainMenu[] = array("name" => $settingtxt[$lang], "link" => "preferences.html?v=1.4.8");
$mainMenu[] = array("name" => "Hilfe", "link" => "help.php?v=1.4.8");
$mainMenu[] = array("name" => "Feedback", "link" => "feedback.html?v=1.4.8");
}
$mainMenu[] = array("name" => $logout[$lang], "link" => "logout.php");
@ -1864,9 +1884,21 @@ class Admin {
}
}
private static function changeItemInTable($pdo,$theItem,$theValue,$theTable) {
$sql = "SELECT id FROM $theTable WHERE name=?";
$result = CommonUtils::fetchSqlAll($pdo, $sql, array($theItem));
if (count($result) == 0) {
$sql = "INSERT INTO $theTable (name,setting) VALUES(?,?)";
CommonUtils::execSql($pdo, $sql, array($theItem,$theValue));
} else {
$sql = "UPDATE $theTable SET setting=? WHERE name=?";
CommonUtils::execSql($pdo, $sql, array($theValue,$theItem));
}
}
private function deletelogo() {
$pdo = $this->dbutils->openDbAndReturnPdo();
$this->changeOneConfigDbItem($pdo, "logoimg", null,"%logo%",false);
$pdo = DbUtils::openDbAndReturnPdoStatic();
self::changeItemInTable($pdo, "logoimg", null, "%logo%");
echo json_encode("OK");
}
@ -1896,9 +1928,9 @@ class Admin {
exit();
}
$pdo = $this->dbutils->openDbAndReturnPdo();
$pdo = DbUtils::openDbAndReturnPdoStatic();
$this->changeOneConfigDbItem($pdo, "logoimg", $content,"%logo%",false);
self::changeItemInTable($pdo, "logoimg", $content, "%logo%");
header("Location: ../infopage.html?i=manager.html=Import_war_erfolgreich."); /* Browser umleiten */
exit;
@ -2092,12 +2124,12 @@ class Admin {
if ($check == 1) {
if (is_numeric($aVal)) {
$this->changeOneConfigDbItem($pdo,$dbcol,$aVal,"%config%",true);
$this->changeOneConfigDbItem($pdo,$dbcol,$aVal);
} else {
$problem = true;
}
} else {
$this->changeOneConfigDbItem($pdo,$dbcol,$aVal,"%config%",true);
$this->changeOneConfigDbItem($pdo,$dbcol,$aVal);
}
}
if (!$problem) {
@ -2107,35 +2139,9 @@ class Admin {
}
}
function changeOneConfigDbItem($pdo,$theItem,$theValue,$table,$doHist) {
$sql = "SELECT setting from $table WHERE name=?";
$stmt = $pdo->prepare(DbUtils::substTableAlias($sql));
$stmt->execute(array($theItem));
$row = $stmt->fetchObject();
if ($stmt->rowCount() > 0) {
$sql = "UPDATE $table SET setting=? WHERE name=?";
$stmt = $pdo->prepare(DbUtils::substTableAlias($sql));
$stmt->execute(array($theValue,$theItem));
} else {
$sql = "INSERT INTO `$table` (`id` , `name`,`setting`) VALUES (NULL , ? , ?)";
$stmt = $pdo->prepare(DbUtils::substTableAlias($sql));
$stmt->execute(array($theItem,$theValue));
}
if ($doHist) {
$this->histfiller->updateConfigInHist($pdo,$theItem, $theValue);
}
}
private function findActiveUserWithName($username) {
$sql_find_id = "SELECT id FROM %user% WHERE active='1' AND username='$username'";
$pdo = $this->dbutils->openDbAndReturnPdo();
$stmt_query = $pdo->query($this->dbutils->resolveTablenamesInSqlString($sql_find_id));
$row =$stmt_query->fetchObject();
$theUserId = $row->id;
return $theUserId;
function changeOneConfigDbItem($pdo,$theItem,$theValue) {
$histFiller = new HistFiller();
$histFiller->updateConfigInHist($pdo, $theItem, $theValue);
}
public static function isRoleAdmin($pdo,$roleid) {
@ -2465,13 +2471,13 @@ class Admin {
private function getAllTablesToBackupRestore() {
return array("closing","logo","printjobs","ratings","work","payment","room","resttables","tablepos","tablemaps","pricelevel","prodtype","prodimages","products","config",
"roles","user","reservations","customers","groups","groupcustomer","vacations","bill","customerlog","queue","billproducts","hsin","hsout","comments","histprod","histconfig","histuser","histactions","hist",
"roles","user","reservations","customers","groups","groupcustomer","vacations","bill","customerlog","queue","records","recordsqueue","billproducts","hsin","hsout","comments","histprod","histconfig","histuser","histactions","hist",
"extras","extrasprods","queueextras");
}
private function getAllWithLogsTablesToBackupRestore() {
return array("log","closing","logo","printjobs","ratings","work","payment","room","resttables","tablepos","tablemaps","pricelevel","prodtype","prodimages","products","config",
"roles","user","reservations","customers","groups","groupcustomer","vacations","bill","customerlog","queue","billproducts","hsin","hsout","comments","histprod","histconfig","histuser","histactions","hist",
"roles","user","reservations","customers","groups","groupcustomer","vacations","bill","customerlog","queue","records","recordsqueue","billproducts","hsin","hsout","comments","histprod","histconfig","histuser","histactions","hist",
"extras","extrasprods","queueextras");
}
@ -2659,7 +2665,6 @@ class Admin {
readfile($zipfile);
}
// REM now clean up
foreach($filenames as $afilename) {
unlink($afilename["file"]);
}
@ -2742,31 +2747,29 @@ class Admin {
}
}
private function restoreFromJson($pdo) {
$binaryFields = array("signature","img","setting","content");
private function getContextOfImportedJsonFile($dbContent) {
$content = file_get_contents($_FILES['userfile']['tmp_name']);
$basedb = new Basedb();
$basedb->setPrefix(TAB_PREFIX);
$basedb->setTimeZone(DbUtils::getTimeZone());
$pdo->beginTransaction();
$genInfo = $this->getGeneralConfigItems(false, $pdo);
$version = $genInfo["version"];
$timezone = DbUtils::getTimeZone();
$dbContent = json_decode($content,true);
$tableKey = 'table';
$fieldKey = 'fieldname';
$contentKey = 'content';
$valueKey = 'value';
if (count($dbContent) > 0) {
$sampleTable = $dbContent[0];
if (isset($sampleTable['t'])) {
$fieldKey = 'f';
$contentKey = 'c';
$tableKey = 't';
$valueKey = 'v';
}
}
foreach($dbContent as $table) {
if ($table['t'] == 'config') {
if ($table[$tableKey] == 'config') {
$foundConfigItem = null;
foreach($table['c'] as $aConfigItem) {
foreach($table[$contentKey] as $aConfigItem) {
foreach($aConfigItem as $aConfigDbPart) {
if (($aConfigDbPart['f'] == 'name') && ($aConfigDbPart['v'] == 'version')) {
if (($aConfigDbPart[$fieldKey] == 'name') && ($aConfigDbPart[$valueKey] == 'version')) {
$foundConfigItem = $aConfigItem;
break;
}
@ -2774,97 +2777,19 @@ class Admin {
}
if (!is_null($foundConfigItem)) {
foreach($foundConfigItem as $aConfigDbPart) {
if ($aConfigDbPart['f'] == 'setting') {
$bakVersion = base64_decode($aConfigDbPart['v']);
if ($bakVersion != $version) {
echo json_encode(array("status" => "ERROR","msg" => "Backup hat die falsche Version $bakVersion."));
exit();
}
if ($aConfigDbPart[$fieldKey] == 'setting') {
$bakVersion = base64_decode($aConfigDbPart[$valueKey]);
return array($bakVersion,$tableKey,$fieldKey,$contentKey,$valueKey);
}
}
}
}
}
$basedb->dropTables($pdo);
$basedb->createEmptyTables($pdo);
$typeIsOnlyConfig = true;
self::doSql($pdo, "SET foreign_key_checks = 0;", null);
foreach($dbContent as $table) {
$tablename = "%" . $table['t'] . "%";
$tablecontent = $table['c'];
if ($table['t'] == "queue") {
$typeIsOnlyConfig = false;
return array("0",$tableKey,$fieldKey,$contentKey,$valueKey);
}
if ($table['t'] == "bill") {
$sql = "SET FOREIGN_KEY_CHECKS = 0";
$stmt = $pdo->prepare(DbUtils::substTableAlias($sql));
$stmt->execute();
}
foreach($tablecontent as $row) {
$cols = array();
$vals = array();
$quests = array();
foreach ($row as $field) {
$fieldname = $field['f'];
$cols[] = $fieldname;
if (in_array($fieldname, $binaryFields)) {
$vals[] = base64_decode($field['v']);
} else {
$vals[] = $field['v'];
}
$quests[] = '?';
}
$colstr = implode(",",$cols);
$queststr = implode(",",$quests);
$sql = "INSERT INTO $tablename ($colstr) VALUES ($queststr)";
$stmt = $pdo->prepare($this->dbutils->resolveTablenamesInSqlString($sql));
try {
$stmt->execute($vals);
} catch (Exception $e) {
$errorMsg = $e->getMessage();
}
}
if ($table['t'] == "bill") {
$sql = "SET FOREIGN_KEY_CHECKS = 1";
$stmt = $pdo->prepare(DbUtils::substTableAlias($sql));
$stmt->execute();
}
}
if (!$typeIsOnlyConfig) {
HistFiller::insertRestoreHistEntry($pdo);
}
self::doSql($pdo, "SET foreign_key_checks = 1;", null);
$basedb->signLastBillid($pdo);
$setVersion = "update %config% set setting=? where name='version'";
$stmt = $pdo->prepare($basedb->resolveTablenamesInSqlString($setVersion));
$stmt->execute(array($version));
$sql = "SELECT name FROM %config% WHERE name=?";
$stmt = $pdo->prepare(DbUtils::substTableAlias($sql));
$stmt->execute(array("timezone"));
$row = $stmt->fetchObject();
if ($stmt->rowCount() == 0) {
$this->changeOneConfigDbItem($pdo, "timezone", $timezone, "%config%", true);
}
$pdo->commit();
private function completeImportProcess($pdo) {
if(session_id() == '') {
session_start();
}
@ -2879,14 +2804,135 @@ class Admin {
$params["secure"], $params["httponly"]
);
}
ini_set('session.gc_max_lifetime', 0);
ini_set('session.gc_probability', 1);
ini_set('session.gc_divisor', 1);
session_destroy();
echo json_encode(array("status" => "OK"));
$ok = Version::runUpdateProcess($pdo, TAB_PREFIX, MYSQL_DB, null,false);
if ($ok["status"] != "OK") {
echo json_encode($ok);
return;
}
$sql = "SELECT name FROM %config% WHERE name=?";
$stmt = $pdo->prepare(DbUtils::substTableAlias($sql));
$stmt->execute(array("timezone"));
$row = $stmt->fetchObject();
if ($stmt->rowCount() == 0) {
$timezone = DbUtils::getTimeZone();
$this->changeOneConfigDbItem($pdo, "timezone", $timezone);
}
echo json_encode(self::optimizeCore($pdo));
}
private function createTablesAndUpdateUntilVersion($pdo,$basedb,$version) {
$basedb->dropTables($pdo);
$basedb->createAndIntializeTables($pdo,'.',0,'Euro', DbUtils::getTimeZone());
Version::runUpdateProcess($pdo, TAB_PREFIX, MYSQL_DB, $version,false);
}
private function restoreFromJson($pdo) {
$binaryFields = array("signature","img","setting","content");
$content = file_get_contents($_FILES['userfile']['tmp_name']);
$basedb = new Basedb();
$basedb->setPrefix(TAB_PREFIX);
$basedb->setTimeZone(DbUtils::getTimeZone());
$pdo->beginTransaction();
$dbContent = json_decode($content,true);
$context = $this->getContextOfImportedJsonFile($dbContent);
$bakVersion = $context[0];
$tableKey = $context[1];
$fieldKey = $context[2];
$contentKey = $context[3];
$valueKey = $context[4];
if ((CommonUtils::startsWith($bakVersion, "1.0")) || (CommonUtils::startsWith($bakVersion, "1.1")) || (CommonUtils::startsWith($bakVersion, "1.2"))) {
echo json_encode(array("status" => "ERROR","msg" => "Backup hat eine zu frühe Version zum Import ($bakVersion)."));
exit();
}
$this->createTablesAndUpdateUntilVersion($pdo, $basedb, $bakVersion);
$typeIsOnlyConfig = true;
self::doSql($pdo, "SET foreign_key_checks = 0;", null);
foreach($dbContent as $table) {
$tablename = "%" . $table[$tableKey] . "%";
$sql = "DELETE FROM $tablename";
CommonUtils::execSql($pdo, $sql, null);
$tablecontent = $table[$contentKey];
if ($table[$tableKey] == "queue") {
$typeIsOnlyConfig = false;
}
if ($table[$tableKey] == "bill") {
$sql = "SET FOREIGN_KEY_CHECKS = 0";
$stmt = $pdo->prepare(DbUtils::substTableAlias($sql));
$stmt->execute();
}
foreach($tablecontent as $row) {
$cols = array();
$vals = array();
$quests = array();
foreach ($row as $field) {
$fieldname = $field[$fieldKey];
$cols[] = $fieldname;
if (in_array($fieldname, $binaryFields)) {
$vals[] = base64_decode($field[$valueKey]);
} else {
$vals[] = $field[$valueKey];
}
$quests[] = '?';
}
$colstr = implode(",",$cols);
$queststr = implode(",",$quests);
$sql = "INSERT INTO $tablename ($colstr) VALUES ($queststr)";
$stmt = $pdo->prepare(DbUtils::substTableAlias($sql));
try {
$stmt->execute($vals);
} catch (Exception $e) {
$errorMsg = $e->getMessage();
}
}
if ($table[$tableKey] == "bill") {
$sql = "SET FOREIGN_KEY_CHECKS = 1";
$stmt = $pdo->prepare(DbUtils::substTableAlias($sql));
$stmt->execute();
}
}
if (!$typeIsOnlyConfig) {
HistFiller::insertRestoreHistEntry($pdo);
}
self::doSql($pdo, "SET foreign_key_checks = 1;", null);
$basedb->signLastBillid($pdo);
$pdo->commit();
$this->completeImportProcess($pdo);
}
private function restoreFromZip($pdo) {
@ -2917,24 +2963,16 @@ class Admin {
$basedb->setPrefix(TAB_PREFIX);
$basedb->setTimeZone(DbUtils::getTimeZone());
$bakVersion = file_get_contents($tmpdir . "/version");
$genInfo = $this->getGeneralConfigItems(false, $pdo);
$version = $genInfo["version"];
$timezone = DbUtils::getTimeZone();
$versionOfUploadedFile = file_get_contents($tmpdir . "/version");
if ($versionOfUploadedFile != $version) {
echo json_encode(array("status" => "ERROR","msg" => "Backup hat die falsche Version $versionOfUploadedFile."));
if ((CommonUtils::startsWith($bakVersion, "1.0")) || (CommonUtils::startsWith($bakVersion, "1.1")) || (CommonUtils::startsWith($bakVersion, "1.2"))) {
echo json_encode(array("status" => "ERROR","msg" => "Backup hat eine zu frühe Version zum Import ($bakVersion)."));
exit();
}
$pdo->beginTransaction();
$basedb->dropTables($pdo);
$basedb->createEmptyTables($pdo);
$this->createTablesAndUpdateUntilVersion($pdo, $basedb, $bakVersion);
$typeIsOnlyConfig = true;
@ -2946,6 +2984,10 @@ class Admin {
}
$tablename = "%" . $table . "%";
$sql = "DELETE FROM $tablename";
CommonUtils::execSql($pdo, $sql, null);
$tablecontent = json_decode(file_get_contents($tmpdir . "/" . $table),true);
if ($table == "queue") {
@ -3011,41 +3053,9 @@ class Admin {
$basedb->signLastBillid($pdo);
$setVersion = "update %config% set setting=? where name='version'";
$stmt = $pdo->prepare($basedb->resolveTablenamesInSqlString($setVersion));
$stmt->execute(array($version));
$sql = "SELECT name FROM %config% WHERE name=?";
$stmt = $pdo->prepare(DbUtils::substTableAlias($sql));
$stmt->execute(array("timezone"));
$row = $stmt->fetchObject();
if ($stmt->rowCount() == 0) {
$this->changeOneConfigDbItem($pdo, "timezone", $timezone, "%config%", true);
}
$pdo->commit();
if(session_id() == '') {
session_start();
}
$_SESSION = array();
// Swipe via memory
if (ini_get("session.use_cookies")) {
// Prepare and swipe cookies
$params = session_get_cookie_params();
// clear cookies and sessions
setcookie(session_name(), '', time() - 42000,
$params["path"], $params["domain"],
$params["secure"], $params["httponly"]
);
}
ini_set('session.gc_max_lifetime', 0);
ini_set('session.gc_probability', 1);
ini_set('session.gc_divisor', 1);
session_destroy();
echo json_encode(array("status" => "OK"));
$this->completeImportProcess($pdo);
}
private function shutdown() {
@ -3066,10 +3076,9 @@ class Admin {
}
private function optimize() {
public static function optimizeCore($pdo) {
set_time_limit(60 * 20);
try {
$pdo = DButils::openDbAndReturnPdoStatic();
self::doSql($pdo, "OPTIMIZE TABLE %queue%", null);
self::doSql($pdo, "OPTIMIZE TABLE %billproducts%", null);
self::doSql($pdo, "OPTIMIZE TABLE %products%", null);
@ -3078,12 +3087,18 @@ class Admin {
self::doSql($pdo, "OPTIMIZE TABLE %queueextras%", null);
self::doSql($pdo, "OPTIMIZE TABLE %log%", null);
self::doSql($pdo, "OPTIMIZE TABLE %roles%", null);
echo json_encode(array("status" => "OK"));
return array("status" => "OK");
} catch (Exception $ex) {
echo json_encode(array("status" => "ERROR", "code" => ERROR_COMMAND_ERROR, "msg" => ERROR_COMMAND_ERROR_MSG));
return array("status" => "ERROR", "code" => ERROR_COMMAND_ERROR, "msg" => ERROR_COMMAND_ERROR_MSG);
}
}
private function optimize() {
$pdo = DButils::openDbAndReturnPdoStatic();
$ok = self::optimizeCore($pdo);
echo json_encode($ok);
}
private static function getForeignKeyName($pdo,$fromtable,$totable,$dbname,$default = null) {
$foreignKey = null;
try {
@ -3210,5 +3225,3 @@ class Admin {
}
}
}
?>

View File

@ -693,6 +693,11 @@ class Bill {
date_default_timezone_set(DbUtils::getTimeZone());
$currentTime = date('Y-m-d H:i:s');
$recordaction = T_BILLSTORNO;
if ($removeproducts) {
$recordaction = T_BILLSTORNOREMOVE;
}
$stornocodeInDb = CommonUtils::getConfigValue($pdo, 'stornocode', null);
if (is_null($stornocodeInDb)) {
@ -806,8 +811,7 @@ class Bill {
} else {
$sql = "UPDATE %queue% SET ordertime=null,paidtime=null,billid=null WHERE billid=?";
}
$stmt = $pdo->prepare($this->dbutils->resolveTablenamesInSqlString($sql));
$stmt->execute(array($billid));
CommonUtils::execSql($pdo, $sql, array($billid));
$userIdOfStornoUser = $this->getUserId();
$stornval = 0.0 - floatval($brutto);
@ -845,6 +849,14 @@ class Bill {
$stmt->execute(array($aQueueid,$refIdOfStornoEntry));
}
$sql = "INSERT INTO %records% (date,userid,tableid,action) VALUES(?,?,?,?)";
CommonUtils::execSql($pdo, $sql, array($currentTime,$userIdOfStornoUser,$tableid,$recordaction));
$recordid = $pdo->lastInsertId();
foreach ($queueIdArray as $aQueueid) {
$sql = "INSERT INTO %recordsqueue% (recordid,queueid) VALUES(?,?)";
CommonUtils::execSql($pdo, $sql, array($recordid,$aQueueid));
}
Hotelinterface::insertIntoHsin($pdo,$refIdOfStornoEntry);
if ($doOwnTransaction) {

View File

@ -146,7 +146,7 @@ $decpoint = $this->getDecPoint();
date_default_timezone_set(DbUtils::getTimeZone());
$closingTime = date('Y-m-d H:i:s');
$pdo = $this->dbutils->openDbAndReturnPdo();
$pdo = DbUtils::openDbAndReturnPdoStatic();
if (!$this->isClosingAllowed($pdo)) {
echo json_encode(array("status" => "ERROR", "msg" => "Time between closings too short", "code" => ERROR_CLOSING_TIME_LIMIT));
@ -162,6 +162,9 @@ return;
}
CommonUtils::callPlugin($pdo, "createClosing", "before");
CommonUtils::execSql($pdo, 'DELETE FROM %recordsqueue%', null);
CommonUtils::execSql($pdo, 'DELETE FROM %records%', null);
$closingEntrySql = "INSERT INTO `%closing%` (`id` , `closingdate`,`remark`,`billcount`,`billsum`,`signature`) VALUES (NULL ,?,?,?,?,?)";
$stmt = $pdo->prepare($this->dbutils->resolveTablenamesInSqlString($closingEntrySql));
$stmt->execute(array($closingTime,$remark,0,0.0,null));
@ -566,7 +569,7 @@ header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Pragma: no-cache");
header("Expires: 0");
$csv .= $this->t['ID'][$l] . ";" . $this->t['Date'][$l] . ";" . $this->t['Tablename'][$l] . ";" . $this->t['Prod'][$l] . ";" . $this->t['Brutto'][$l] . "($currency);";
$csv .= $this->t['ID'][$l] . ";" . $this->t['Date'][$l] . ";" . $this->t['Tablename'][$l] . ";" . $this->t['Prod'][$l] . ";" . $this->t['Option'][$l] . ";" . $this->t['Brutto'][$l] . "($currency);";
$csv .= $this->t['Netto'][$l] . "($currency);";
$csv .= $this->t['Tax'][$l] . ";";
$csv .= $this->t['PayWay'][$l] . ";";
@ -642,6 +645,7 @@ $retValues[] = array (
"tablename" => '',
"paidtime" => $billdate,
"productname" => $this->t['cashaction'][$l], // Kassenaktion
"option" => '',
"price" => $brutto,
"netto" => $netto,
"tax" => number_format(0.00, 2, $decpoint, ''),
@ -655,14 +659,14 @@ $csv .= "$aBillId; \"$billdate\" ; \"$tablename\" ; \"" . $this->t['cashaction']
}
} else {
$sql = "SELECT DISTINCT productname,price,%queue%.tax as tax FROM %queue%,%billproducts% WHERE %billproducts%.billid=? AND %billproducts%.queueid=%queue%.id";
$sql = "SELECT DISTINCT productname,price,%queue%.tax as tax,anoption FROM %queue%,%billproducts% WHERE %billproducts%.billid=? AND %billproducts%.queueid=%queue%.id";
if ($status == 'x') {
$statusTxt = $this->t["laterCancelled"][$l];
} else if ($status == 's') {
$statusTxt = $this->t["storno"][$l];
} else {
$statusTxt = "";
$sql = "SELECT productname,paidtime,price,tax FROM %queue% WHERE billid=?";
$sql = "SELECT productname,anoption,paidtime,price,tax FROM %queue% WHERE billid=?";
}
$stmt = $pdo->prepare(DbUtils::substTableAlias($sql));
@ -670,6 +674,7 @@ $stmt->execute(array($aBillId));
$result = $stmt->fetchAll();
foreach ($result as $zeile) {
$productname = $zeile['productname'];
$option = $zeile['anoption'];
$tax = $zeile['tax'];
$paidtime = ($billdate == null ? "" : $billdate) ;
@ -685,6 +690,7 @@ $retValues[] = array (
"tablename" => $tablename,
"paidtime" => $paidtime,
"productname" => $productname,
"option" => $option,
"price" => $price,
"netto" => $netto,
"tax" => $formattedtax,
@ -694,8 +700,9 @@ $retValues[] = array (
"status" => $statusTxt,
"ref" => $ref);
$productname = str_replace('"','""',$productname);
$option = str_replace('"','""',$option);
if ($doCsvExport || $onlyresultreturn) {
$csv .= "$aBillId; \"$paidtime\" ; \"$tablename\" ; \"$productname\" ; \"$price\" ; \"$netto\" ; \"$formattedtax\" ; \"$paymentArray[$paymentid]\"; $userid; \"$username\"; \"$statusTxt\"; $ref\n";
$csv .= "$aBillId; \"$paidtime\" ; \"$tablename\" ; \"$productname\" ; \"$option\" ; \"$price\" ; \"$netto\" ; \"$formattedtax\" ; \"$paymentArray[$paymentid]\"; $userid; \"$username\"; \"$statusTxt\"; $ref\n";
}
}
}

View File

@ -2,6 +2,13 @@
require_once ('dbutils.php');
defined('T_ORDER') || define ('T_ORDER', 0);
defined('T_BILL') || define ('T_BILL', 1);
defined('T_REMOVE') || define ('T_REMOVE', 2);
defined('T_BILLSTORNO') || define ('T_BILLSTORNO', 3);
defined('T_BILLSTORNOREMOVE') || define ('T_BILLSTORNOREMOVE', 4);
defined('T_FROM_TABLE') || define ('T_FROM_TABLE', 5);
defined('T_TO_TABLE') || define ('T_TO_TABLE', 6);
class CommonUtils {
var $dbutils;
@ -406,4 +413,10 @@ class CommonUtils {
{
return $needle === "" || substr($haystack, -strlen($needle)) === $needle;
}
public static function startsWith($aText, $needle)
{
return $needle === "" || strpos($aText, $needle) === 0;
}
}

0
webapp/php/config.php Normal file → Executable file
View File

View File

@ -115,6 +115,8 @@ class DbUtils {
$out = str_replace("%ratings%",$prefix . 'ratings', $out);
$out = str_replace("%prodimages%",$prefix . 'prodimages', $out);
$out = str_replace("%roles%",$prefix . 'roles', $out);
$out = str_replace("%recordsqueue%",$prefix . 'recordsqueue', $out);
$out = str_replace("%records%",$prefix . 'records', $out);
return (str_replace("%prodtype%",$prefix . 'prodtype',$out));
}

View File

@ -27,7 +27,7 @@ if (isset($_POST["cmd"])) {
if (strlen($status) > 150) {
$status = substr($status, 0,149);
}
$version = "1.4.7";
$version = "1.4.8";
$arr = array("cmd" => $cmd,"fct" => $fct, "xhr" => $xhr,"errormsg" => $errormsg,"status" => $status,"version" => $version,"phpversion" => $phpversion);
} else {

View File

@ -72,9 +72,9 @@ class Feedback {
$drinkjobs = $this->sqlresult($pdo,"select count(id) as number from %printjobs% where type=2","number");
$payjobs = $this->sqlresult($pdo,"select count(id) as number from %printjobs% where type=3","number");
$info .= "Speisebons: $foodjobs\n";
$info .= "Getr<EFBFBD>nkebons: $drinkjobs\n";
$info .= "Kassenbons: $payjobs\n\n";
$info .= "Fs: $foodjobs\n";
$info .= "Ds: $drinkjobs\n";
$info .= "Rs: $payjobs\n\n";
// db sizes
$info .= $this->getDatabaseSizes($pdo);
@ -94,61 +94,83 @@ class Feedback {
$dbInfo = "DB-info:\n";
foreach($result as $row) {
$dbInfo .= "Database '$row[0]', db size in MB: $row[1], free space in MB: $row[2]\n";
$dbInfo .= "DB '$row[0]', db (MB): $row[1], free (MB): $row[2]\n";
}
$dbInfo .= "used DB '" . MYSQL_DB . "'\n\n";
return $dbInfo;
}
function sendMail($role,$topic,$email,$tel,$allowSendRights,$content) {
if (!$this->spamcheck($email)) {
echo json_encode("Falsche Emailadresse eingegeben!");
return;
}
$rights = "Keine Rechteinformation";
$from = $this->getGeneralItemFromDb('email');
$version = $this->getGeneralItemFromDb('version');
if ($this->spamcheck($from)) {
if ($this->isUserAlreadyLoggedInForPhp()) {
if ($allowSendRights) {
$rights = "Userid = " . $_SESSION['userid'] . "\n";
$rights .= "Username = " . $_SESSION['currentuser'] . "\n";
$rights .= "isAdmin = " . ($_SESSION['is_admin'] ? "ja" : "nein") . "\n";
$rights .= "right_waiter = " . ($_SESSION['right_waiter'] ? "ja" : "nein") . "\n";
$rights .= "right_kitchen = " . ($_SESSION['right_kitchen'] ? "ja" : "nein") . "\n";
$rights .= "right_bar = " . ($_SESSION['right_bar'] ? "ja" : "nein") . "\n";
$rights .= "right_supply = " . ($_SESSION['right_supply'] ? "ja" : "nein") . "\n";
$rights .= "right_paydesk = " . ($_SESSION['right_paydesk'] ? "ja" : "nein") . "\n";
$rights .= "right_statistics = " . ($_SESSION['right_statistics'] ? "ja" : "nein") . "\n";
$rights .= "right_bill = " . ($_SESSION['right_bill'] ? "ja" : "nein") . "\n";
$rights .= "right_products = " . ($_SESSION['right_products'] ? "ja" : "nein") . "\n";
$rights .= "right_manager = " . ($_SESSION['right_manager'] ? "ja" : "nein");
$rights = "UID=" . $_SESSION['userid'] . "\n";
$rights .= "UN=" . $_SESSION['currentuser'] . "\n";
$rights .= " RA=" . ($_SESSION['is_admin'] ? "1" : "0") . "\n";
$rights .= " RW=" . ($_SESSION['right_waiter'] ? "1" : "0") . "\n";
$rights .= " RPay=" . ($_SESSION['right_paydesk'] ? "1" : "0") . "\n";
$rights .= " RB=" . ($_SESSION['right_bill'] ? "1" : "0") . "\n";
$rights .= " RProd = " . ($_SESSION['right_products'] ? "1" : "0") . "\n";
$rights .= " RM=" . ($_SESSION['right_manager'] ? "1" : "0");
$rights .= $this->getdbinfo();
}
$server = $_SERVER['HTTP_USER_AGENT'];
$msg = "Rolle: $role\nEmail: $email\nTel.: $tel\nRechte: $rights\nServer:$server\n\nOrderSprinter-Version:$version\n\nNachricht:\n$content";
$msg = wordwrap($msg, 70);
// Verarbeitet \r\n's zuerst, so dass sie nicht doppelt konvertiert werden
$msg = str_replace("\n", "\r\n", $msg);
$msg = "Rolle:$role\nEmail:$email\nTel.:$tel\nRechte:$rights\nServer:$server\n\nVersion:$version\n\nNachricht:\n$content";
$pdo = DbUtils::openDbAndReturnPdoStatic();
if (Emailer::sendEmail($pdo, $msg, "feedback@ordersprinter.de", $topic)) {
echo json_encode("OK");
$version = CommonUtils::getConfigValue($pdo, 'version', 'no-version');
$ok = $this->sendFeedbackToServer($topic, $msg, $version);
echo json_encode($ok);
} else {
echo json_encode("Fehler: Mail konnte nicht verschickt werden! Stimmt die PHP-Konfiguration auf dem Server?");
echo json_encode(array("status" => "ERROR","msg" => "Fehler: Benutzer nicht eingeloggt!"));
}
}
function sendFeedbackToServer($topic, $msg, $version) {
$cmd = '';
$fct = 'Feedback-Form';
$xhr = $msg;
$errormsg = $topic;
$status = '';
$phpversion = phpversion();
if (strlen($xhr) > 900) {
$xhr = substr($xhr, 0, 899);
}
if (strlen($errormsg) > 150) {
$errormsg = substr($errormsg, 0, 149);
}
$arr = array("cmd" => $cmd, "fct" => $fct, "xhr" => $xhr, "errormsg" => $errormsg, "status" => $status, "version" => $version, "phpversion" => $phpversion);
$url = "http://www.ordersprinter.de/debug/save.php?cmd=save";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 5);
$query = http_build_query($arr);
curl_setopt($ch, CURLOPT_POSTFIELDS, $query);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$server_output = curl_exec ($ch);
if($server_output === false)
{
$msg = 'Curl-Fehler: ' . curl_error($ch);
curl_close ($ch);
return array("status" => "ERROR","msg" => $msg);
} else {
echo json_encode("Fehler: Benutzer nicht eingeloggt!");
}
} else {
echo json_encode("Mailkonfiguration von OrderSprinter fehlerhaft!");
curl_close ($ch);
return array("status" => "OK");
}
}
}
?>

View File

@ -208,7 +208,7 @@ class Guestsync {
$allProducts = CommonUtils::fetchSqlAll($pdo, $sql, array("%$dayofweek%"));
$sql = "select id,name,IFNULL(reference,0) as reference from %prodtype% where removed is null";
$sql = "select id,name,IFNULL(reference,0) as reference,sorting from %prodtype% where removed is null";
$allTypes = CommonUtils::fetchSqlAll($pdo, $sql, null);
$filteredTypes = self::filterUsedTypes($allTypes, $allProducts);
@ -230,8 +230,10 @@ class Guestsync {
$keys = array_keys(self::$typesWithContent);
foreach($keys as $aKey) {
$t = self::$typesWithContent[$aKey];
$out[] = array("id" => $t["id"],"reference" => $t["reference"],"name" => $t["name"]);
$out[] = array("id" => $t["id"],"reference" => $t["reference"],"name" => $t["name"],"sorting" => $t["sorting"]);
}
usort($out,"Products::cmptypes");
return $out;
}
@ -247,8 +249,9 @@ class Guestsync {
private static function declareProdTypeAndParentsInUse($alltypes,$aType) {
$typeid = $aType["id"];
$reference = $aType["reference"];
$sorting = $aType["sorting"];
if (!array_key_exists($typeid, self::$typesWithContent)) {
self::$typesWithContent[$typeid] = array("id" => $typeid,"name" => $aType["name"],"reference" => $reference);
self::$typesWithContent[$typeid] = array("id" => $typeid,"name" => $aType["name"],"reference" => $reference, "sorting" => $sorting);
$parent = null;
foreach($alltypes as $a) {

View File

@ -66,6 +66,8 @@ class QueueContent {
if ($command == 'addProductListToQueue') {
$this->addProductListToQueue($_POST["tableid"],$_POST["prods"],$_POST["print"],$_POST["payprinttype"]);
} else if ($command == 'getRecords') {
$this->getRecords($_GET["tableid"]);
} else if ($command == 'kitchenToCook') {
$this->kitchenToCook();
} else if ($command == 'declareProductBeCookingOrCooked') {
@ -820,6 +822,48 @@ class QueueContent {
}
}
function getRecords($tableid) {
if (!($this->userrights->hasCurrentUserRight('right_waiter')) && !($this->userrights->hasCurrentUserRight('right_paydesk'))) {
echo json_encode(array("status" => "ERROR","msg" => "Benutzerrechte nicht ausreichend"));
return false;
}
$pdo = DbUtils::openDbAndReturnPdoStatic();
if ($tableid != 0) {
$sql = "SELECT id,TIME(date) as time,(IF(userid is null,'-',(SELECT username FROM %user% WHERE %user%.id=userid))) as username,action,tableid FROM %records% WHERE tableid=? ORDER BY time DESC";
$entries = CommonUtils::fetchSqlAll($pdo, $sql, array($tableid));
} else {
$sql = "SELECT id,TIME(date) as time,(IF(userid is null,'-',(SELECT username FROM %user% WHERE %user%.id=userid))) as username,action,tableid FROM %records% WHERE tableid is null ORDER BY time DESC";
$entries = CommonUtils::fetchSqlAll($pdo, $sql, null);
}
$records = array();
foreach($entries as $anEntry) {
$sql = "SELECT queueid FROM %recordsqueue% WHERE recordid=?";
$queueids = CommonUtils::fetchSqlAll($pdo, $sql, array($anEntry["id"]));
$prods = array();
foreach($queueids as $queueid) {
$sql = "SELECT productid,longname FROM %products%,%queue% WHERE %queue%.id=? AND %queue%.productid=%products%.id";
$prodInfo = CommonUtils::fetchSqlAll($pdo, $sql, array($queueid["queueid"]));
if (count($prodInfo) == 0) {
break;
}
$sql = "SELECT extraid,name FROM %queueextras% WHERE queueid=?";
$extras = CommonUtils::fetchSqlAll($pdo, $sql, array($queueid["queueid"]));
$extrasArr = array();
foreach($extras as $e) {
$extrasArr[] = $e["name"];
}
$extrasStr = implode(',', $extrasArr);
$prods[] = array("name" => $prodInfo[0]["longname"],"extras" => $extrasStr);
}
$records[] = array("id" => $anEntry["id"],"time" => $anEntry["time"],"username" => $anEntry["username"],"action" => $anEntry["action"],"prods" => $prods);
}
echo json_encode(array("status" => "OK","msg" => $records));
}
/*
* Add a product list to the queue as if it was ordered by the waiter.
* The ordertime is set by the time that this method is invoked.
@ -859,6 +903,10 @@ class QueueContent {
$insertedQueueIds = array();
$sql = "INSERT INTO %records% (date,userid,tableid,action) VALUES(?,?,?,?)";
CommonUtils::execSql($pdo, $sql, array($ordertime,$_SESSION['userid'],$theTableid,T_ORDER));
$recordid = $pdo->lastInsertId();
$i = 0;
for ($i=0;$i<count($prods);$i++) {
$aProd = $prods[$i];
@ -964,6 +1012,9 @@ class QueueContent {
$stmt->execute(array($theTableid,$productid,$currentPriceLevelId,$price,$tax,$taxaustrianumber,$productname,$ordertime,$_SESSION['userid'],$theOption,($theChangedPrice == "NO" ? 0 : 1),$togo));
$queueid = $pdo->lastInsertId();
$sql = "INSERT INTO %recordsqueue% (recordid,queueid) VALUES(?,?)";
CommonUtils::execSql($pdo, $sql, array($recordid,$queueid));
if (!is_null($extras) && ($extras != "")) {
for ($j=0;$j<count($extras);$j++) {
$anExtra = $extras[$j];
@ -1022,6 +1073,10 @@ class QueueContent {
$pdo->beginTransaction();
$sql = "INSERT INTO %records% (date,userid,tableid,action) VALUES(?,?,?,?)";
CommonUtils::execSql($pdo, $sql, array($ordertime,null,$theTableid,T_ORDER));
$recordid = $pdo->lastInsertId();
$tax = CommonUtils::getExistingConfigValue($pdo, 'tax');
$workflowconfig = CommonUtils::getExistingConfigValue($pdo, 'workflowconfig');
@ -1077,9 +1132,12 @@ class QueueContent {
VALUES ( ?,?,?,?,?,?,?,?,?,?,?,?, null, null, NULL,NULL,'0',NULL,'0');";
$stmt = $pdo->prepare(DbUtils::substTableAlias($insertSql));
$stmt->execute(array($theTableid,$productid,$currentPriceLevelId,$price,$tax,$taxaustrianumber,$productname,$ordertime,$_SESSION['userid'],$theOption,($theChangedPrice == "NO" ? 0 : 1),0));
$stmt->execute(array($theTableid,$productid,$currentPriceLevelId,$price,$tax,$taxaustrianumber,$productname,$ordertime,null,$theOption,($theChangedPrice == "NO" ? 0 : 1),0));
$queueid = $pdo->lastInsertId();
$sql = "INSERT INTO %recordsqueue% (recordid,queueid) VALUES(?,?)";
CommonUtils::execSql($pdo, $sql, array($recordid,$queueid));
if (($workflowconfig == 3) && ($doPrint == 0)) {
$this->reallyDeclareAsCooked($pdo,$queueid);
@ -1117,7 +1175,18 @@ class QueueContent {
*/
function removeProductFromQueue($queueid,$isPaid,$isCooking,$isReady) {
if (is_numeric($queueid)) {
$pdo = $this->dbutils->openDbAndReturnPdo();
$pdo = DbUtils::openDbAndReturnPdoStatic();
date_default_timezone_set(DbUtils::getTimeZone());
$currentTime = date('Y-m-d H:i:s');
$userid = $this->getUserId();
$sql = "SELECT tablenr FROM %queue% WHERE id=?";
$result = CommonUtils::fetchSqlAll($pdo, $sql, array($queueid));
if (count($result) == 0) {
echo json_encode(array("status" => "OK"));
return;
}
$tableid = $result[0]["tablenr"];
$sql = "SELECT count(id) as countid FROM %bill%";
$row = CommonUtils::getRowSqlObject($pdo, $sql, null);
@ -1148,12 +1217,19 @@ class QueueContent {
$sql .= " AND (billid is null OR (";
$sql .= " billid = %bill%.id AND %bill%.closingid is null)) ";
}
$stmt = $pdo->prepare($this->dbutils->resolveTablenamesInSqlString($sql));
$stmt = $pdo->prepare(DbUtils::substTableAlias($sql));
$stmt->execute(array($queueid));
$rowsAffected = $stmt->rowCount();
if ($rowsAffected == 1) {
Workreceipts::createCancelWorkReceipt($pdo, $queueid);
$sql = "INSERT INTO %records% (date,userid,tableid,action) VALUES(?,?,?,?)";
CommonUtils::execSql($pdo, $sql, array($currentTime,$userid,$tableid,T_REMOVE));
$recordid = $pdo->lastInsertId();
$sql = "INSERT INTO %recordsqueue% (recordid,queueid) VALUES(?,?)";
CommonUtils::execSql($pdo, $sql, array($recordid,$queueid));
echo json_encode(array("status" => "OK"));
} else {
echo json_encode(array("status" => "Failed", "msg" => "Affected rows: $rowsAffected"));
@ -1332,6 +1408,21 @@ class QueueContent {
$pdo = $this->dbutils->openDbAndReturnPdo();
$pdo->beginTransaction();
date_default_timezone_set(DbUtils::getTimeZone());
$currentTime = date('Y-m-d H:i:s');
$userid = $this->getUserId();
$sql = "INSERT INTO %records% (date,userid,tableid,action) VALUES(?,?,?,?)";
CommonUtils::execSql($pdo, $sql, array($currentTime,$userid,$fromTableId,T_FROM_TABLE));
$recordidFromTable = $pdo->lastInsertId();
$sql = "INSERT INTO %records% (date,userid,tableid,action) VALUES(?,?,?,?)";
CommonUtils::execSql($pdo, $sql, array($currentTime,$userid,$toTableId,T_TO_TABLE));
$recordidToTable = $pdo->lastInsertId();
$sql = "INSERT INTO %recordsqueue% (recordid,queueid) VALUES(?,?)";
foreach($ids as $id) {
CommonUtils::execSql($pdo, $sql, array($recordidFromTable,$id));
CommonUtils::execSql($pdo, $sql, array($recordidToTable,$id));
}
$sql = "UPDATE %queue% SET tablenr=? WHERE id IN($queueids) AND tablenr=?";
$stmt = $pdo->prepare(DbUtils::substTableAlias($sql));
$stmt->execute(array($toTableId,$fromTableId));
@ -1726,6 +1817,8 @@ class QueueContent {
* Return a bill id
*/
function declarePaidCreateBillReturnBillId($pdo,$ids,$tableid,$paymentId,$declareready,$host,$calledInternally = false,$reservationid='',$guestinfo='',$intguestid='') {
date_default_timezone_set(DbUtils::getTimeZone());
$currentTime = date('Y-m-d H:i:s');
if ($intguestid == '') {
$intguestid = null;
@ -1769,9 +1862,6 @@ class QueueContent {
}
}
date_default_timezone_set(DbUtils::getTimeZone());
$currentTime = date('Y-m-d H:i:s');
$billid = (-1);
if ($allNotPaid == true) {
$billid = -1;
@ -1816,6 +1906,12 @@ class QueueContent {
$tableid = 0;
}
if (!$calledInternally) {
$sql = "INSERT INTO %records% (date,userid,tableid,action) VALUES(?,?,?,?)";
CommonUtils::execSql($pdo, $sql, array($currentTime,$userid,$tableid,T_BILL));
$recordid = $pdo->lastInsertId();
}
$idlist = join("','",$ids_array);
$sql = "SELECT SUM(price) as brutto,ROUND(SUM(price/(1 + %queue%.tax/100.0)),6) as netto FROM %queue% WHERE id IN ('$idlist')";
$row = CommonUtils::getRowSqlObject($pdo, $sql, null);
@ -1844,6 +1940,11 @@ class QueueContent {
$billProdsSql = "INSERT INTO `%billproducts%` (`queueid`,`billid`) VALUES ( ?,?)";
$stmt = $pdo->prepare($this->dbutils->resolveTablenamesInSqlString($billProdsSql));
$stmt->execute(array($queueid,$billid));
if (!$calledInternally) {
$sql = "INSERT INTO %recordsqueue% (recordid,queueid) VALUES(?,?)";
CommonUtils::execSql($pdo, $sql, array($recordid,$queueid));
}
}
}
Hotelinterface::insertIntoHsin($pdo,$billid);

View File

@ -4,6 +4,7 @@ $this->t = array(
"Tablename" => array("Tisch","Table","Mesa"),
"Date" => array("Zahlungsdatum","Pay date","Fecha de pago"),
"Prod" => array("Produkt","Product","Producto"),
"Option" => array("Bemerkung","Comment","Comentario"),
"Brutto" => array("Bruttopreis","Gross","Bruto"),
"Netto" => array("Nettopreis","Net","Neto"),
"Tax" => array("MwSt (%)","Tax (%)","IVA (%)"),

View File

@ -192,23 +192,28 @@ class HistFiller {
self::insertIntoHist($pdo, 10, null);
}
public function updateConfigInHist($pdo,$theItem, $theValue) {
$sql_find_id = "SELECT id FROM %config% WHERE name='$theItem'";
$sql_insert_histconfig = "INSERT INTO %histconfig% (id,configid,setting) VALUES (NULL,?,?)";
$pdo->beginTransaction();
$stmt_query = $pdo->query(DbUtils::substTableAlias($sql_find_id));
$row =$stmt_query->fetchObject();
$theConfigId = $row->id;
$stmt_insert_histconfig = $pdo->prepare(DbUtils::substTableAlias($sql_insert_histconfig));
$stmt_insert_histconfig->execute(array($theConfigId,"$theValue"));
$newRefIdForHist = $pdo->lastInsertId();
self::insertIntoHist($pdo, '6', $newRefIdForHist);
$pdo->commit();
$sql = "SELECT id FROM %config% WHERE name=?";
$result = CommonUtils::fetchSqlAll($pdo, $sql, array($theItem));
if (count($result) == 0) {
$sql = "INSERT INTO %config% (name,setting) VALUES(?,?)";
CommonUtils::execSql($pdo, $sql, array($theItem,$theValue));
$idInConfig = $pdo->lastInsertId();
$action = 2;
} else {
$sql = "UPDATE %config% SET setting=? WHERE name=?";
CommonUtils::execSql($pdo, $sql, array($theValue,$theItem));
$idInConfig = $result[0]["id"];
$action = 6;
}
$sql = "INSERT INTO %histconfig% (configid,setting) VALUES (?,?)";
CommonUtils::execSql($pdo, $sql, array($idInConfig,$theValue));
$newRefIdForHist = $pdo->lastInsertId();
self::insertIntoHist($pdo, $action, $newRefIdForHist);
}
/*
* Read the complete config table and fill in these values to the histtable
*/
@ -237,8 +242,7 @@ class HistFiller {
private static function insertIntoHist($pdo,$action,$refIdForHist) {
date_default_timezone_set(DbUtils::getTimeZone());
$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(DbUtils::substTableAlias($sql_insert_hist));
$stmt_insert_hist->execute(array($currentTime, $action, $refIdForHist));
$sql = "INSERT INTO %hist% (date,action,refid) VALUES (?,?,?)";
CommonUtils::execSql($pdo, $sql, array($currentTime, $action, $refIdForHist));
}
}

View File

@ -180,7 +180,6 @@ class ProductEntry {
}
}
// REMÜ show ext parameters if there are any
if (count($extArr) > 0) {
$prodText .= " # " . join("; ", $extArr);
}

View File

@ -77,13 +77,13 @@ class Basedb {
}
function doSQL($pdo,$sql) {
$stmt = $pdo->prepare($this->resolveTablenamesInSqlString($sql));
$stmt = $pdo->prepare(DbUtils::substTableAlias($sql));
$stmt->execute();
}
function doSQLcatch($pdo,$sql) {
try {
$stmt = $pdo->prepare($this->resolveTablenamesInSqlString($sql));
$stmt = $pdo->prepare(DbUtils::substTableAlias($sql));
$stmt->execute();
} catch (Exception $e) {
// nothing - table not present or whatever...
@ -91,7 +91,7 @@ class Basedb {
}
function resolveTablenamesInSqlString($sqlString) {
return DbUtils::substTableAliasCore($sqlString, $this->prefix);
return DbUtils::substTableAlias($sqlString);
}
function dropTables($pdo) {
@ -111,11 +111,14 @@ class Basedb {
$this->doSQLcatch($pdo, "drop TABLE `%extras%`");
$this->doSQLcatch($pdo, "drop TABLE `%billproducts%`");
$this->doSQLcatch($pdo, "drop TABLE `%recordsqueue%`");
$this->doSQLcatch($pdo, "drop TABLE `%records%`");
$this->doSQLcatch($pdo, "drop TABLE `%queue%`");
$this->doSQLcatch($pdo, "drop TABLE `%printjobs%`");
$this->doSQLcatch($pdo, "drop TABLE `%customerlog%`");
$this->doSQLcatch($pdo, "drop TABLE `%bill%`");
$this->doSQLcatch($pdo, "drop TABLE `%ratings%`");
$this->doSQLcatch($pdo, "drop TABLE `%user%`");
$this->doSQLcatch($pdo, "drop TABLE `%roles%`");
$this->doSQLcatch($pdo, "drop TABLE `%closing%`");
@ -148,14 +151,14 @@ class Basedb {
`customerid` INT(10) NULL,
`billid` INT(10) NULL,
`action` INT(2) NULL,
`userid` INT(3) NULL,
`userid` INT(10) NULL,
`remark` VARCHAR ( 500 ) NULL,
FOREIGN KEY (billid) REFERENCES %bill%(id),
FOREIGN KEY (customerid) REFERENCES %customers%(id),
FOREIGN KEY (userid) REFERENCES %user%(id)
) CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE = InnoDb
";
$stmt = $pdo->prepare($this->resolveTablenamesInSqlString($sql));
$stmt = $pdo->prepare(DbUtils::substTableAlias($sql));
$stmt->execute();
}
@ -168,7 +171,7 @@ class Basedb {
`message` VARCHAR ( 500 ) NULL
) CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE = InnoDb
";
$stmt = $pdo->prepare($this->resolveTablenamesInSqlString($sql));
$stmt = $pdo->prepare(DbUtils::substTableAlias($sql));
$stmt->execute();
}
@ -181,7 +184,7 @@ class Basedb {
`name_esp` VARCHAR ( 20 ) NOT NULL
) CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE = InnoDb
";
$stmt = $pdo->prepare($this->resolveTablenamesInSqlString($sql));
$stmt = $pdo->prepare(DbUtils::substTableAlias($sql));
$stmt->execute();
}
@ -192,25 +195,32 @@ class Basedb {
`id` INT (10) NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`username` VARCHAR ( 150 ) NOT NULL,
`userpassword` VARCHAR ( 150 ) NOT NULL,
`is_admin` INT (1) NOT NULL,
`right_waiter` INT (1) NOT NULL,
`right_kitchen` INT (1) NOT NULL,
`right_bar` INT (1) NOT NULL,
`right_supply` INT (1) NOT NULL,
`right_paydesk` INT (1) NOT NULL,
`right_statistics` INT (1) NOT NULL,
`right_bill` INT (1) NOT NULL,
`right_products` INT (1) NOT NULL,
`right_manager` INT (1) NOT NULL,
`right_closing` INT (1) NOT NULL,
`right_reservation` INT (1) NOT NULL,
`right_rating` INT (1) NOT NULL,
`right_changeprice` INT (1) NOT NULL,
`right_customers` INT (1) NOT NULL,
`lastmodule` VARCHAR ( 30 ) NULL,
`ordervolume` INT (2) NULL,
`language` INT (2) NULL,
`mobiletheme` INT(2) NULL,
`receiptprinter` INT (1) NULL,
`roombtnsize` INT(1) NULL,
`tablebtnsize` INT(1) NULL,
`prodbtnsize` INT(1) NULL,
`prefertablemap` INT(1) NULL,
`preferimgdesk` INT(1) NULL,
`preferimgmobile` INT(1) NULL,
`preferfixbtns` INT(1) NULL,
`showplusminus` INT(1) NULL,
`keeptypelevel` INT(1) NOT NULL,
`extrasapplybtnpos` INT(1) NOT NULL,
`failedlogins` VARCHAR(20) NULL,
`active` INT (2) NOT NULL,
`roleid` INT (10) NULL,
FOREIGN KEY (roleid) REFERENCES %roles%(id)
`active` INT (2) NOT NULL
) CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE = InnoDb ;
";
$this->doSQL($pdo,$sql);
@ -259,7 +269,7 @@ class Basedb {
`sorting` INT(2) NULL
) CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE = InnoDb ;
";
$stmt = $pdo->prepare($this->resolveTablenamesInSqlString($sql));
$stmt = $pdo->prepare(DbUtils::substTableAlias($sql));
$stmt->execute();
}
@ -301,16 +311,12 @@ class Basedb {
`id` INT (10) NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`tableno` VARCHAR ( 150 ) NOT NULL,
`roomid` INT ( 10 ) NOT NULL,
`code` VARCHAR ( 200 ) NULL,
`name` VARCHAR ( 50 ) NULL,
`active` INT(1) NULL,
`allowoutorder` INT(1) NULL,
`removed` INT(2) NULL,
`sorting` INT(2) NULL,
FOREIGN KEY (roomid) REFERENCES %room%(id)
) CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE = InnoDb ;
";
$stmt = $pdo->prepare($this->resolveTablenamesInSqlString($sql));
$stmt = $pdo->prepare(DbUtils::substTableAlias($sql));
$stmt->execute();
}
@ -322,7 +328,7 @@ class Basedb {
`setting` VARCHAR ( 10000 )
) CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE = InnoDb ;
";
$stmt = $pdo->prepare($this->resolveTablenamesInSqlString($sql));
$stmt = $pdo->prepare(DbUtils::substTableAlias($sql));
$stmt->execute();
}
@ -334,7 +340,7 @@ class Basedb {
`setting` BLOB
) CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE = InnoDb ;
";
$stmt = $pdo->prepare($this->resolveTablenamesInSqlString($sql));
$stmt = $pdo->prepare(DbUtils::substTableAlias($sql));
$stmt->execute();
}
@ -363,7 +369,6 @@ class Basedb {
`id` INT (10) NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`name` VARCHAR ( 150 ) NOT NULL,
`price` " . DECIMALSMALL . " NOT NULL,
`sorting` INT(2) NULL,
`removed` INT(1) NULL
) CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE = InnoDb ;
";
@ -407,8 +412,6 @@ class Basedb {
`priceA` " . DECIMALSMALL . " NULL,
`priceB` " . DECIMALSMALL . " NULL,
`priceC` " .DECIMALSMALL . " NULL,
`unit` INT(2) NULL,
`days` VARCHAR(20) NULL,
`tax` " . DECIMALSMALL . " NULL,
`taxaustria` INT(1) NULL,
`amount` INT(5) NULL,
@ -417,12 +420,8 @@ class Basedb {
`sorting` INT(2) NULL,
`available` INT(2) NOT NULL,
`audio` VARCHAR ( 150 ) NULL,
`prodimageid` INT(10) NULL,
`display` VARCHAR(3) NULL,
`removed` INT(1) NULL,
INDEX pcatindex (category),
FOREIGN KEY (category) REFERENCES %prodtype%(id),
FOREIGN KEY (prodimageid) REFERENCES %prodimages%(id)
FOREIGN KEY (category) REFERENCES %prodtype%(id)
) CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE = InnoDb ;
";
$this->doSQL($pdo,$sql);
@ -438,7 +437,7 @@ class Basedb {
`info_esp` VARCHAR ( 1000 )
) CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE = InnoDb ;
";
$stmt = $pdo->prepare($this->resolveTablenamesInSqlString($sql));
$stmt = $pdo->prepare(DbUtils::substTableAlias($sql));
$stmt->execute();
}
@ -453,7 +452,7 @@ class Basedb {
`remark` VARCHAR ( 1000 )
) CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE = InnoDb ;
";
$stmt = $pdo->prepare($this->resolveTablenamesInSqlString($sql));
$stmt = $pdo->prepare(DbUtils::substTableAlias($sql));
$stmt->execute();
}
@ -468,7 +467,7 @@ class Basedb {
) CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE = InnoDb ;
";
$stmt = $pdo->prepare($this->resolveTablenamesInSqlString($sql));
$stmt = $pdo->prepare(DbUtils::substTableAlias($sql));
$stmt->execute();
}
@ -479,7 +478,7 @@ class Basedb {
`id` INT (10) NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`billdate` DATETIME NOT NULL ,
`brutto` " . DECIMALMIDDLE . " NULL,
`netto` " . DECIMALMIDDLEEXACT . " NULL,
`netto` " . DECIMALMIDDLE . " NULL,
`prevbrutto` " . DECIMALBIG . " NULL,
`prevnetto` " . DECIMALBIG . " NULL,
`tableid` VARCHAR ( 150 ) NOT NULL,
@ -503,7 +502,7 @@ class Basedb {
FOREIGN KEY (intguestid) REFERENCES %customers%(id)
) CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE = InnoDb ;
";
$stmt = $pdo->prepare($this->resolveTablenamesInSqlString($sql));
$stmt = $pdo->prepare(DbUtils::substTableAlias($sql));
$stmt->execute();
}
@ -518,14 +517,12 @@ class Basedb {
`phone` VARCHAR(30) NULL,
`mobil` VARCHAR(30) NULL,
`www` VARCHAR(50) NULL,
`hello` VARCHAR(100) NULL,
`regards` VARCHAR(100) NULL,
`remark` VARCHAR(500) NULL,
`created` DATETIME NULL,
`lastmodified` DATETIME NULL
) CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE = InnoDb ;
";
$stmt = $pdo->prepare($this->resolveTablenamesInSqlString($sql));
$stmt = $pdo->prepare(DbUtils::substTableAlias($sql));
$stmt->execute();
}
@ -539,7 +536,7 @@ class Basedb {
`created` DATETIME NULL
) CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE = InnoDb ;
";
$stmt = $pdo->prepare($this->resolveTablenamesInSqlString($sql));
$stmt = $pdo->prepare(DbUtils::substTableAlias($sql));
$stmt->execute();
}
@ -554,7 +551,7 @@ class Basedb {
FOREIGN KEY (customerid) REFERENCES %customers%(id)
) CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE = InnoDb ;
";
$stmt = $pdo->prepare($this->resolveTablenamesInSqlString($sql));
$stmt = $pdo->prepare(DbUtils::substTableAlias($sql));
$stmt->execute();
}
@ -571,7 +568,7 @@ class Basedb {
FOREIGN KEY (customerid) REFERENCES %customers%(id)
) CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE = InnoDb ;
";
$stmt = $pdo->prepare($this->resolveTablenamesInSqlString($sql));
$stmt = $pdo->prepare(DbUtils::substTableAlias($sql));
$stmt->execute();
}
@ -592,7 +589,7 @@ class Basedb {
`taxaustria` INT(1) NULL,
`productname` VARCHAR( 150 ) NULL,
`ordertime` DATETIME NULL ,
`orderuser` INT(10) NULL ,
`orderuser` INT(10) NOT NULL ,
`anoption` VARCHAR( 150 ) NULL ,
`pricechanged` INT(1) NULL ,
`togo` INT(1) NULL ,
@ -603,11 +600,7 @@ class Basedb {
`toremove` INT(3) NOT NULL,
`cooking` INT(10) NULL,
`workprinted` INT(2) NOT NULL,
`printjobid` INT(1) NULL,
`isclosed` INT(1) NULL,
INDEX tqueue (tablenr),
INDEX pqueue (productid),
INDEX bqueue (billid),
FOREIGN KEY (tablenr) REFERENCES %resttables%(id),
FOREIGN KEY (pricelevel) REFERENCES %pricelevel%(id),
FOREIGN KEY (productid) REFERENCES %products%(id),
@ -667,16 +660,12 @@ class Basedb {
`priceA` " . DECIMALSMALL . " NULL,
`priceB` " . DECIMALSMALL . " NULL,
`priceC` " . DECIMALSMALL . " NULL,
`unit` INT(2) NULL,
`days` VARCHAR(20) NULL,
`tax` " . DECIMALSMALL . " NULL,
`taxaustria` INT(1) NULL,
`sorting` INT(2) NULL,
`available` INT(2) NOT NULL,
`favorite` INT(1) NULL,
`audio` VARCHAR ( 150 ) NULL,
`prodimageid` INT(10) NULL,
`display` VARCHAR(3) NULL,
`extras` VARCHAR ( 300 ) NULL,
FOREIGN KEY (prodid) REFERENCES %products%(id)
) CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE = InnoDb
@ -709,7 +698,6 @@ class Basedb {
`right_products` INT (1) NOT NULL,
`right_manager` INT (1) NOT NULL,
`right_closing` INT (1) NOT NULL,
`right_dash` INT (1) NOT NULL,
`right_reservation` INT (1) NOT NULL,
`right_rating` INT (1) NOT NULL,
`right_changeprice` INT (1) NOT NULL,
@ -736,11 +724,10 @@ class Basedb {
`id` INT (10) NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`content` TEXT NOT NULL ,
`type` INT (2) NOT NULL ,
`printer` INT(2) NULL,
`removed` INT(1) NULL
`printer` INT(2) NULL
) CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE = InnoDb ;
";
$stmt = $pdo->prepare($this->resolveTablenamesInSqlString($sql));
$stmt = $pdo->prepare(DbUtils::substTableAlias($sql));
$stmt->execute();
}
@ -753,13 +740,43 @@ class Basedb {
`signature` blob NULL
) CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE = InnoDb ;
";
$stmt = $pdo->prepare($this->resolveTablenamesInSqlString($sql));
$stmt = $pdo->prepare(DbUtils::substTableAlias($sql));
$stmt->execute();
}
function createRecordsQueueTable($pdo) {
$sql = "
CREATE TABLE `%recordsqueue%` (
`id` INT (10) NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`recordid` INT (10) NOT NULL,
`queueid` INT (10) NOT NULL,
FOREIGN KEY (recordid) REFERENCES %records%(id),
FOREIGN KEY (queueid) REFERENCES %queue%(id)
) CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE = InnoDb ;
";
$stmt = $pdo->prepare(DbUtils::substTableAlias($sql));
$stmt->execute();
}
function createRecordsTable($pdo) {
$sql = "
CREATE TABLE `%records%` (
`id` INT (10) NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`date` DATETIME NOT NULL ,
`userid` INT (10) NULL,
`tableid` INT (10) NULL,
`action` INT (3) NOT NULL,
FOREIGN KEY (userid) REFERENCES %user%(id),
FOREIGN KEY (tableid) REFERENCES %resttables%(id)
) CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE = InnoDb ;
";
$stmt = $pdo->prepare(DbUtils::substTableAlias($sql));
$stmt->execute();
}
function getPrivkey($pdo) {
$sql = "SELECT signature FROM %work% WHERE item=?";
$stmt = $pdo->prepare($this->resolveTablenamesInSqlString($sql));
$stmt = $pdo->prepare(DbUtils::substTableAlias($sql));
$stmt->execute(array("privkey"));
$row = $stmt->fetchObject();
$privkey = $row->signature;
@ -768,7 +785,7 @@ class Basedb {
function signLastBillid($pdo) {
$sql = "SELECT MAX(id) as maxbillid FROM %bill%";
$stmt = $pdo->prepare($this->resolveTablenamesInSqlString($sql));
$stmt = $pdo->prepare(DbUtils::substTableAlias($sql));
$stmt->execute();
$row =$stmt->fetchObject();
if ($row != null) {
@ -783,15 +800,15 @@ class Basedb {
$signature = base64_encode($signature);
$sql = "SELECT id FROM %work% WHERE item=?";
$stmt = $pdo->prepare($this->resolveTablenamesInSqlString($sql));
$stmt = $pdo->prepare(DbUtils::substTableAlias($sql));
$stmt->execute(array("lastbillid"));
if ($stmt->rowCount() > 0) {
$sql = "UPDATE %work% SET value=?, signature=? WHERE item=?";
$stmt = $pdo->prepare($this->resolveTablenamesInSqlString($sql));
$stmt = $pdo->prepare(DbUtils::substTableAlias($sql));
$stmt->execute(array($lastBillId,$signature,"lastbillid"));
} else {
$sql = "INSERT INTO `%work%` (`id` , `item`,`value`,`signature`) VALUES ( NULL,?,?,?)";
$stmt = $pdo->prepare($this->resolveTablenamesInSqlString($sql));
$stmt = $pdo->prepare(DbUtils::substTableAlias($sql));
$stmt->execute(array("lastbillid",$lastBillId,$signature));
}
}
@ -799,12 +816,12 @@ class Basedb {
function initTableOrder($pdo) {
$maxNoOfRoom = array();
$sql = "SELECT id,roomid FROM %resttables% WHERE removed is null";
$stmt = $pdo->prepare($this->resolveTablenamesInSqlString($sql));
$stmt = $pdo->prepare(DbUtils::substTableAlias($sql));
$stmt->execute();
$result = $stmt->fetchAll(PDO::FETCH_ASSOC);
$sql = "UPDATE %resttables% SET sorting=? WHERE id=?";
$stmt = $pdo->prepare($this->resolveTablenamesInSqlString($sql));
$stmt = $pdo->prepare(DbUtils::substTableAlias($sql));
foreach ($result as $r) {
$tableid = $r["id"];
$roomid = $r["roomid"];
@ -816,25 +833,25 @@ class Basedb {
$stmt->execute(array($nextSort,$tableid));
}
$sql = "UPDATE %resttables% SET active='1' WHERE active is null";
$stmt = $pdo->prepare($this->resolveTablenamesInSqlString($sql));
$stmt = $pdo->prepare(DbUtils::substTableAlias($sql));
$stmt->execute();
$sql = "UPDATE %resttables% SET allowoutorder='1' WHERE allowoutorder is null";
$stmt = $pdo->prepare($this->resolveTablenamesInSqlString($sql));
$stmt = $pdo->prepare(DbUtils::substTableAlias($sql));
$stmt->execute();
$sql = "UPDATE %resttables% SET name=tableno WHERE name is null";
$stmt = $pdo->prepare($this->resolveTablenamesInSqlString($sql));
$stmt = $pdo->prepare(DbUtils::substTableAlias($sql));
$stmt->execute();
}
function initRoomOrder($pdo) {
$sql = "SELECT id FROM %room% WHERE removed IS NULL ORDER BY id";
$stmt = $pdo->prepare($this->resolveTablenamesInSqlString($sql));
$stmt = $pdo->prepare(DbUtils::substTableAlias($sql));
$stmt->execute();
$result = $stmt->fetchAll(PDO::FETCH_ASSOC);
$counter = 1;
$sql = "UPDATE %room% SET sorting=? WHERE id=?";
$stmt = $pdo->prepare($this->resolveTablenamesInSqlString($sql));
$stmt = $pdo->prepare(DbUtils::substTableAlias($sql));
foreach($result as $aRoom) {
$stmt->execute(array($counter,$aRoom["id"]));
$counter++;
@ -913,7 +930,6 @@ class Basedb {
{
$this->createLogTable($pdo);
$this->createPaymentTable($pdo);
$this->createRolesTable($pdo);
$this->createUserTable($pdo);
$this->createRoomTable($pdo);
$this->createRestTables($pdo);
@ -921,7 +937,6 @@ class Basedb {
$this->createTablePosTable($pdo);
$this->createConfigTable($pdo);
$this->createProdTypeTable($pdo);
$this->createProdimagesTable($pdo);
$this->createProductTable($pdo);
$this->createPriceLevelTable($pdo);
$this->createClosingTable($pdo);
@ -931,7 +946,6 @@ class Basedb {
$this->createGroupCustomerTable($pdo);
$this->createVacationsTable($pdo);
$this->createBillTable($pdo);
$this->createCustomerLogTable($pdo);
$this->createQueueTable($pdo);
$this->createBillProductsTable($pdo);
$this->createHistTables($pdo);
@ -947,6 +961,158 @@ class Basedb {
$this->createQueueExtrasTable($pdo);
}
private function createContentInPaymentTable($pdo) {
$sql = "INSERT INTO %payment% (id,name,name_en,name_esp) VALUES (?,?,?,?)";
$stmt = $pdo->prepare(DbUtils::substTableAlias($sql));
$stmt->execute(array('1', 'Barzahlung', 'Cash', 'Contado'));
$stmt = $pdo->prepare(DbUtils::substTableAlias($sql));
$stmt->execute(array('2', 'EC-Kartenzahlung','Electr. purse (EC)','Pago con tarjeta EC'));
$stmt->execute(array('3', 'Kreditkartenzahlung','Credit card','Tarjeta de credito'));
$stmt->execute(array('4', 'Rechnung','bill','Factura'));
$stmt->execute(array('5', 'Ueberweisung','Bank transfer','Transferencia'));
$stmt->execute(array('6', 'Lastschrift','Debit','Cargo en cuenta'));
$stmt->execute(array('7', 'Hotelzimmer','Hotel room','Habitación'));
$stmt->execute(array('8', 'Gast','Guest','Cliente'));
}
public function defineHistActions ($pdo) {
$sql = "INSERT INTO %histactions% (id,name,description) VALUES (?,?,?)";
$stmt = $pdo->prepare(DbUtils::substTableAlias($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 readConfigTableAndSendToHist($pdo) {
$sql_query = "SELECT * FROM %config%";
$sql_insert_histconfig = "INSERT INTO %histconfig% (id,configid,setting) VALUES (NULL,?,?)";
$stmt_query = $pdo->prepare(DbUtils::substTableAlias($sql_query));
$stmt_insert_histconfig = $pdo->prepare(DbUtils::substTableAlias($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(DbUtils::substTableAlias($sql_insert_hist));
$stmt_insert_hist->execute(array($currentTime, $action, $refIdForHist));
}
function createAndIntializeTables($pdo,$decpoint, $billlanguage, $currency, $timezone) {
$this->setTimeZone($timezone);
$this->dropTables($pdo);
$this->createEmptyTables($pdo);
$this->createContentInPaymentTable($pdo);
$this->defineHistActions($pdo);
$rect = Version::getDefaultCustomRecTemplate();
$foodtemplate = Version::getDefaultWorkTemplateFood();
$drinktemplate = Version::getDefaultWorkTemplateDrinks();
$printpass = md5("123");
$this->doSQL($pdo, "INSERT INTO `%pricelevel%` (`id` , `name`,`info`,`info_en`,`info_esp`) VALUES ('1', 'A', 'Normale Preisstufe', 'Normal', 'Normal')");
$this->doSQL($pdo, "INSERT INTO `%pricelevel%` (`id` , `name`,`info`,`info_en`,`info_esp`) VALUES ('2', 'B', 'Wochenendtarif', 'Weekend prices','Tarifa del fin de semana')");
$this->doSQL($pdo, "INSERT INTO `%pricelevel%` (`id` , `name`,`info`,`info_en`,`info_esp`) VALUES ('3', 'C', 'Happy Hour', 'Happy Hour','Happy Hour')");
$this->doSQL($pdo, "INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'pricelevel', '1')");
$this->doSQL($pdo, "INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'tax', '19.0')");
$this->doSQL($pdo, "INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'togotax', '7.0')");
$this->doSQL($pdo, "INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'taxaustrianormal', '20.0')");
$this->doSQL($pdo, "INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'taxaustriaerm1', '10.0')");
$this->doSQL($pdo, "INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'taxaustriaerm2', '13.0')");
$this->doSQL($pdo, "INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'taxaustriaspecial', '19.0')");
$this->doSQL($pdo, "INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'stornocode', '123')");
$this->doSQL($pdo, "INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'printpass', '$printpass')");
$this->doSQL($pdo, "INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'companyinfo', 'Musterrestaurant\nBeispielstrasse 123\n12345 Musterort')");
$this->doSQL($pdo, "INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'rectemplate', '$rect')");
$this->doSQL($pdo, "INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'foodtemplate', '$foodtemplate')");
$this->doSQL($pdo, "INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'drinktemplate', '$drinktemplate')");
$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->doSQL($pdo, "INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'reservationnote', '$resTxt')");
$this->doSQL($pdo, "INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'serverurl', '')");
$this->doSQL($pdo, "INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'email', '')");
$this->doSQL($pdo, "INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'receiveremail', '')");
$this->doSQL($pdo, "INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'payprinttype', 's')");
$this->doSQL($pdo, "INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'billlanguage', $billlanguage)");
$this->doSQL($pdo, "INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'currency', '$currency')");
$this->doSQL($pdo, "INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'receiptfontsize', '12')");
$this->doSQL($pdo, "INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'version', '1.3.0')");
$this->doSQL($pdo, "INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'paymentconfig', '0')");
$this->doSQL($pdo, "INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'remoteaccesscode', null)");
$this->doSQL($pdo, "INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'decpoint', '$decpoint')");
$this->doSQL($pdo, "INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'timezone', '$timezone')");
$this->doSQL($pdo, "INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'webimpressum', 'Musterrestaurant\nBeispielstrasse 123\n12345 Musterort')");
$this->doSQL($pdo, "INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'cancelunpaidcode', '')");
$this->doSQL($pdo, "INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'bigfontworkreceipt', '0')");
$this->doSQL($pdo, "INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'prominentsearch', '0')");
$this->doSQL($pdo, "INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'groupworkitems', '1')");
$this->doSQL($pdo, "INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'addreceipttoprinter', null)");
$this->doSQL($pdo, "INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'smtphost', '')");
$this->doSQL($pdo, "INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'smtpauth', '1')");
$this->doSQL($pdo, "INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'smtpuser', '')");
$this->doSQL($pdo, "INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'smtppass', '')");
$this->doSQL($pdo, "INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'smtpsecure', '1')");
$this->doSQL($pdo, "INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'smtpport', '587')");
$this->doSQL($pdo, "INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'discount1', '50')");
$this->doSQL($pdo, "INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'discount2', '20')");
$this->doSQL($pdo, "INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'discount3', '10')");
$this->doSQL($pdo, "INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'austria', '0')");
$this->doSQL($pdo, "INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'paydeskid', 'OrderSprinter-1')");
$this->doSQL($pdo, "INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'aeskey', '0102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f20')");
$this->doSQL($pdo, "INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'certificatesn', '1234567')");
$this->doSQL($pdo, "INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'digigopaysetready', '1')");
$this->doSQL($pdo, "INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'waitergopayprint', '0')");
$this->doSQL($pdo, "INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'oneprodworkreceipts', '0')");
$this->doSQL($pdo, "INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'digiprintwork', '1')");
$this->doSQL($pdo, "INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'printandqueuejobs', '0')");
$this->doSQL($pdo, "INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'cashenabled', '1')");
$this->doSQL($pdo, "INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'beepcooked', '0')");
$this->doSQL($pdo, "INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'hotelinterface', '0')");
$this->doSQL($pdo, "INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'hsinfile', '')");
$this->doSQL($pdo, "INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'hsoutfile', '')");
$this->doSQL($pdo, "INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'hscurrency', 'EUR')");
$this->doSQL($pdo, "INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'hs3refresh', '60')");
$this->doSQL($pdo, "INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'memorylimit', '256')");
$this->doSQL($pdo, "INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'restaurantmode', '1')");
// prepare for later inconsistency check if version is obsolete
date_default_timezone_set($timezone);
$installDate = date('Y-m-d H:i:s');
$this->doSQL($pdo, "INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'installdate', '$installDate')");
$this->readConfigTableAndSendToHist($pdo);
return;
}
public static function loadSampleProdImages($pdo) {
$sql = "UPDATE %products% SET prodimageid=?";
CommonUtils::execSql($pdo, $sql, array(null));
@ -981,7 +1147,6 @@ class Basedb {
$sql = "UPDATE %prodtype% SET sorting=? WHERE id=?";
if (!array_key_exists($id, $orderedTypeIds)) {
$brothersAndMe = self::getAllTypesOfSameParent($alltypes, $aType);
// REMÜ* start from 1
$sort = 1;
foreach($brothersAndMe as $brotherid) {
CommonUtils::execSql($pdo, $sql, array($sort,$brotherid));

View File

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

View File

@ -5,7 +5,7 @@
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta name="author" content="Stefan Pichel">
<link rel="stylesheet" type="text/css" href="css/bestformat.css?v=1.4.7">
<link rel="stylesheet" type="text/css" href="css/bestformat.css?v=1.4.8">
<link rel="stylesheet" href="php/contenthandler.php?module=admin&command=getmobilecss" />
<link rel="stylesheet" href="php/3rdparty/orderstyle/jquery.mobile.icons.min.css" />
@ -67,6 +67,9 @@ var PREF_APPLY_EXTRA_POS = ["Position Extras-Anwenden-Button","Position apply ex
var PREF_APPLY_EXTRAS_OPTION_TOP = ["Listenanfang","Start of list","Al inicio de la lista"];
var PREF_APPLY_EXTRAS_OPTION_BOTTOM = ["Listenende","End of list","Al final de la lista"];
var PREF_APPLY_EXTRAS_OPTION_BOTH = ["Listenanfang und -ende","Start and end of list","Al inicio y final de la lista"];
var PREF_TABLES_AFTER_SEND = ["Mobilansicht: Nach Produktübermittlung","Mobile view: After sending to server","Vista movíl: Despues transmitir"];
var PREF_TABLES_AFTER_SEND_TABLES = ["Tischauswahl","Table selection","Seleccion de las mesas"];
var PREF_TABLES_AFTER_SEND_ROOMS = ["Raumauswahl","Room selection","Seleccion de las habitaciones"];
var PREF_THEME_TITEL = ["Design","Appearance","Design"];
var PREF_THEME = ["Mobil-Ansicht","Mobile view","Vista movíl"];
@ -254,6 +257,9 @@ function setMobileTheme() {
function setApplyBtnPos() {
doAjax("GET","php/contenthandler.php?module=admin&command=getApplyExtrasBtnPos",null,fillExtrasApplyBtnPosPart,"Keine Information über Position Extra-Anwenden-Button");
}
function setTablesAfterSend() {
doAjax("GET","php/contenthandler.php?module=admin&command=getTablesAfterSend",null,fillTablesAfterSendPart,"Keine Information über Navigation nach Bestellübermittlung");
}
function fillOrderVolume(volume) {
$("#slidervolume").val(volume);
@ -337,6 +343,18 @@ function createPreferExtrasApplyBtnPosPart(prefervalue,label,labeltxt) {
return html;
}
function createPreferTablesAfterSendPart(prefervalue,label,labeltxt) {
var html = '<div class="ui-field-contain">';
html += '<label for="' + label + '"><span id="' + label + 'txt">' + labeltxt + '</span>:</label>';
html += '<select name="' + label + '" id="' + label + '" data-theme="e">';
html += '<option value="0"' + isSelected(0,prefervalue) + '>' + PREF_TABLES_AFTER_SEND_ROOMS[l] + '</option>';
html += '<option value="1"' + isSelected(1,prefervalue) + '>' + PREF_TABLES_AFTER_SEND_TABLES[l] + '</option>';
html += '</select></div>';
return html;
}
function fillButtonSizes(buttonsizes) {
$("#roombtnpart").html(createBtnSizePart(buttonsizes.roombtnsize, "roombtnsize", PREF_ROOM_BTN_SIZE[l]));
$("#tablebtnpart").html(createBtnSizePart(buttonsizes.tablebtnsize, "tablebtnsize", PREF_TABLE_BTN_SIZE[l]));
@ -378,6 +396,10 @@ function fillExtrasApplyBtnPosPart(applyPos) {
$("#preferapplypospart").html(createPreferExtrasApplyBtnPosPart(applyPos, "preferapplyposlabel", PREF_APPLY_EXTRA_POS[l]));
$("#preferktlpartbox").trigger("create");
}
function fillTablesAfterSendPart(thevalue) {
$("#prefertablesaftersendpart").html(createPreferTablesAfterSendPart(thevalue, "prefertablesaftersendlabel", PREF_TABLES_AFTER_SEND[l]));
$("#preferktlpartbox").trigger("create");
}
function handleBtnSize(jsonResult) {
if (jsonResult != "OK") {
@ -504,6 +526,14 @@ function binding() {
doAjax("POST","php/contenthandler.php?module=admin&command=setApplyExtrasBtnPos",{applyextrasbtnpos:newVal},handleGeneralAnswer,"Apply Extras Button Position");
binding();
});
$("#prefertablesaftersendlabel").off('change').on('change', function(e) {
var newVal = $("#prefertablesaftersendlabel").find(":selected").val();
$("#prefertablesaftersendpart").html(createPreferTablesAfterSendPart(newVal, "prefertablesaftersendlabel", PREF_TABLES_AFTER_SEND[l]));
$("#preferktlpartbox").trigger("create");
doAjax("POST","php/contenthandler.php?module=admin&command=setTablesAfterSend",{tablesaftersend:newVal},handleGeneralAnswer,"Anwenden Auswahl nach Bestellübvermittlung");
binding();
});
}
$(document).on("pageinit", "#pref-page", function () {
@ -517,6 +547,7 @@ $(document).on("pageinit", "#pref-page", function () {
setKeepTypeLevel();
setMobileTheme();
setApplyBtnPos();
setTablesAfterSend();
setPreferimgdesk();
setPreferimgmobile();
setShowplusminus();
@ -592,6 +623,7 @@ $(document).on("pageinit", "#pref-page", function () {
<p><span id="preferktldesc">Beschreibung</span></p>
<div id="preferktlbtnpart"></div>
<div id="preferapplypospart"></div>
<div id="prefertablesaftersendpart"></div>
</div>
<div id="preferthemepartbox" data-role="collapsible" data-collapsed="false" data-theme="e" data-content-theme="c" class="noprint">

View File

@ -7,7 +7,7 @@
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta name="author" content="Stefan Pichel">
<link rel="stylesheet" type="text/css" href="css/bestformat.css?v=1.4.7">
<link rel="stylesheet" type="text/css" href="css/bestformat.css?v=1.4.8">
<link rel="stylesheet" href="php/contenthandler.php?module=admin&command=getmobilecss" />
<link rel="stylesheet" href="php/3rdparty/orderstyle/jquery.mobile.icons.min.css" />
@ -550,88 +550,63 @@ function setLanguage(language) {
}
}
var prodproperties = [
{ prop: "longname", field: "prodlong_input", fieldtype: "v", default: '', isnum: false, allowempty: false},
{ prop: "shortname", field: "prodshort_input", fieldtype: "v", default: '', isnum: false, allowempty: "longname"},
{ prop: "priceA", field: "prodpriceA_input", fieldtype: "v", default: '', isnum: true, allowempty: false},
{ prop: "priceB", field: "prodpriceB_input", fieldtype: "v", default: '', isnum: true, allowempty: "priceA"},
{ prop: "priceC", field: "prodpriceC_input", fieldtype: "v", default: '', isnum: true, allowempty: "priceA"},
{ prop: "unit", field: "produnit_input", fieldtype: "v", default: '', isnum: false, allowempty: true},
{ prop: "display", field: "proddisplay_input", fieldtype: "v", default: '', isnum: false, allowempty: true},
{ prop: "days", field: "proddays_input", fieldtype: "v", default: '0123456', isnum: false, allowempty: true},
{ prop: "tax", field: "prodtax_input", fieldtype: "v", default: 'null', isnum: true, allowempty: true},
{ prop: "amount", field: "prodamount_input", fieldtype: "v", default: 'null', isnum: false, allowempty: true},
{ prop: "taxaustria", field: "taxaustriasel", fieldtype: "sval", default: '', isnum: false, allowempty: true},
{ prop: "selectedAudioFile", field: "audiosel", fieldtype: "stext", default: '', isnum: false, allowempty: true},
{ prop: "available", field: "prodavail", fieldtype: "scal", default: '1', isnum: false, allowempty: true},
{ prop: "favorite", field: "prodfav", fieldtype: "scal", default: '1', isnum: false, allowempty: true}
];
function parsePricesAndProperties(prodid) {
var longname = $("#prodlong_input_" + prodid).val();
var shortname = $("#prodshort_input_" + prodid).val();
var priceA = $("#prodpriceA_input_" + prodid).val().trim();
var priceB = $("#prodpriceB_input_" + prodid).val().trim();
var priceC = $("#prodpriceC_input_" + prodid).val().trim();
var unit = $("#produnit_input_" + prodid).val();
var display = $("#proddisplay_input_" + prodid).val();
var days = $("#proddays_input_" + prodid).val().trim();
var tax = $("#prodtax_input_" + prodid).val().trim();
if (tax == "") {
tax = "null";
var retValue = {};
for (var i=0;i<prodproperties.length;i++) {
var aProperty = prodproperties[i];
var aVal = '';
if (aProperty.fieldtype == 'v') {
var untrimmedVal = $("#" + aProperty.field + "_" + prodid).val();
if (untrimmedVal != null) {
aVal = untrimmedVal.trim();
}
if (aVal == '') {
if (aProperty.allowempty === false) {
return { status:false };
} else if (aProperty.allowempty === true) {
aVal = aProperty.default;
} else {
tax = tax.toString().replace(decpoint,".");
aVal = retValue[aProperty.allowempty];
}
}
} else if (aProperty.fieldtype == 'sval') {
aVal = $("#" + aProperty.field + "_" + prodid + " option:selected").val();
} else if (aProperty.fieldtype == 'stext') {
aVal = $("#" + aProperty.field + "_" + prodid + " option:selected").text();
};
if (aProperty.isnum) {
aVal = aVal.toString().replace(decpoint,".");
if ((aVal != '') && (!$.isNumeric(aVal))) {
return { status:false };
};
}
var amount = $("#prodamount_input_" + prodid).val().trim();
if (amount === "") {
amount = "null";
} else {
amount = amount.toString().replace(decpoint,".");
retValue[aProperty.prop] = aVal;
}
var selectedTaxAustria = $("#taxaustriasel_" + prodid + " option:selected").val();
var selectedAudioFile = $("#audiosel_" + prodid + " option:selected").text();
if (selectedAudioFile === 'Kein Ton') {
selectedAudioFile = '';
if (retValue["selectedAudioFile"] == 'Kein Ton') {
retValue["selectedAudioFile"] = '';
}
var available = $( "#prodavail_" + prodid + " option:selected").val();
var favorite = $( "#prodfav_" + prodid + " option:selected").val();
var priceA_Arr = convertToDecimalPoint(priceA);
if (priceB.length !== 0) {
var priceB_Arr = convertToDecimalPoint(priceB);
} else {
var priceB_Arr = convertToDecimalPoint(priceA);
}
if (priceC.length !== 0) {
var priceC_Arr = convertToDecimalPoint(priceC);
} else {
var priceC_Arr = convertToDecimalPoint(priceA);
}
var taxTxt = tax.toString().replace(decpoint,".");
if (taxTxt != "null") {
if (!$.isNumeric(taxTxt)) {
return false;
}
}
if (days == '') {
days = '0123456';
}
if (priceA_Arr[0] && priceB_Arr[0] && priceC_Arr[0]) {
return {
status:true,
longname:longname,
shortname:shortname,
priceA:priceA_Arr[1],
priceB:priceB_Arr[1],
priceC:priceC_Arr[1],
tax:taxTxt,
unit:unit,
display:display,
days:days,
taxaustria: selectedTaxAustria,
amount: amount,
selectedAudioFile:selectedAudioFile,
available:available,
favorite:favorite
}
} else {
return {
status:false
}
}
retValue["status"] = true;
return retValue;
}
function prodapply(prodid) {
@ -649,11 +624,6 @@ function setLanguage(language) {
return;
}
var days = '0123456';
if (props.days != '') {
days = props.days;
}
var origAssignedExtras = $("#prodextra_" + prodid).data("orig_assignedextras");
var doChangeExtras = 0;
@ -670,28 +640,12 @@ function setLanguage(language) {
}
}
var data = {
id: prodid,
longname: props.longname,
shortname: props.shortname,
priceA: props.priceA,
priceB: props.priceB,
priceC: props.priceC,
unit:props.unit,
display: props.display,
days:days,
tax: props.tax,
taxaustria: props.taxaustria,
amount: props.amount,
available: props.available,
audio: props.selectedAudioFile,
changeExtras: doChangeExtras,
favorite:props.favorite,
extras: assignedExtras,
assignextrastotype: isAssignAllExtrasChecked
};
props["id"] = prodid;
props["changeExtras"] = doChangeExtras;
props["extras"] = assignedExtras;
props["assignextrastotype"] = isAssignAllExtrasChecked;
actionOnProd("php/contenthandler.php?module=products&command=applySingleProdData",prodid,data,true);
actionOnProd("php/contenthandler.php?module=products&command=applySingleProdData",prodid,props,true);
if (isAssignAllExtrasChecked == 1) {
$(".assextralist").html("");
@ -734,41 +688,14 @@ function setLanguage(language) {
function prodnew(typeid) {
var tid = (typeid.split("n"))[1];
var props = parsePricesAndProperties(typeid);
var tax = props.tax;
if (tax.trim() == "") {
tax = "null";
}
var amount = props.amount;
if (amount.trim() == "") {
amount = "null";
}
var days = '0123456';
if (days != '') {
days = props.days;
}
var data = {
longname: props.longname,
shortname: props.shortname,
priceA: props.priceA,
priceB: props.priceB,
priceC: props.priceC,
unit: props.unit,
display: props.display,
days:days,
tax: props.tax,
taxaustria: props.taxaustria,
amount: amount,
available: props.available,
category: tid,
audio: props.selectedAudioFile,
favorite: props.favorite
};
var data = parsePricesAndProperties(typeid);
if (data.status == false) {
alert(PROD_WRONG_FORMAT[lang]);
} else {
data["category"] = tid;
doAjax("POST","php/contenthandler.php?module=products&command=createProduct",data,location.reload(),"Neues Produkt nicht anlegbar");
}
}
function reloadCurrentType() {
doAjax("GET","php/contenthandler.php?module=products&command=getMenu&ref=" + p_currenttypeid,null,saveMenu,"keine Produkthierarchyinformation bekommen");

View File

@ -7,7 +7,7 @@
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta name="author" content="Stefan Pichel">
<link rel="stylesheet" type="text/css" href="css/bestformat.css?v=1.4.7">
<link rel="stylesheet" type="text/css" href="css/bestformat.css?v=1.4.8">
<link rel="stylesheet" href="php/contenthandler.php?module=admin&command=getmobilecss" />
<link rel="stylesheet" href="php/3rdparty/orderstyle/jquery.mobile.icons.min.css" />

View File

@ -7,7 +7,7 @@
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta name="author" content="Stefan Pichel">
<link rel="stylesheet" type="text/css" href="css/bestformat.css?v=1.4.7">
<link rel="stylesheet" type="text/css" href="css/bestformat.css?v=1.4.8">
<link rel="stylesheet" href="php/contenthandler.php?module=admin&command=getmobilecss" />
<link rel="stylesheet" href="php/3rdparty/orderstyle/jquery.mobile.icons.min.css" />

View File

@ -5,7 +5,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta name="author" content="Stefan Pichel">
<link rel="stylesheet" type="text/css" href="css/bestformat.css?v=1.4.7">
<link rel="stylesheet" type="text/css" href="css/bestformat.css?v=1.4.8">
<link rel="stylesheet" href="php/contenthandler.php?module=admin&command=getmobilecss" />
<link rel="stylesheet" href="php/3rdparty/orderstyle/jquery.mobile.icons.min.css" />

View File

@ -5,7 +5,7 @@
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta name="author" content="Stefan Pichel">
<link rel="stylesheet" type="text/css" href="css/bestformat.css?v=1.4.7">
<link rel="stylesheet" type="text/css" href="css/bestformat.css?v=1.4.8">
<link rel="stylesheet" href="php/contenthandler.php?module=admin&command=getmobilecss" />
<link rel="stylesheet" href="php/3rdparty/orderstyle/jquery.mobile.icons.min.css" />

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -51,6 +51,7 @@
<input id="workbtn" class="input100 inputwhite" type="submit" value="Arbeitsbon" style="display:none;" />
<input id="sendNewOrders" class="input100 inputwhite" type="submit" value="Bestellung abschließen" style="display:none;" />
<input id="changetablebtn" class="input100 inputwhite" type="submit" value="Tischwechsel" style="display:none;" />
<input id="tablerecordsbtn" class="input100 inputwhite" type="submit" value="Tischprotokoll" style="display:none;" />
</div>
<div id="neworders" class="ordereditem-container"></div>