OrderSprinter 1.2.19

This commit is contained in:
Geno 2020-11-19 23:00:58 +01:00
parent 70ab4d14d7
commit d80ea37553
63 changed files with 2815 additions and 160 deletions

Binary file not shown.

6
spider/3rdparty/jquery-2.0.3.min.js vendored Normal file

File diff suppressed because one or more lines are too long

43
spider/3rdparty/jquery-LICENSE.txt vendored Normal file
View File

@ -0,0 +1,43 @@
Copyright jQuery Foundation and other contributors, https://jquery.org/
This software consists of voluntary contributions made by many
individuals. For exact contribution history, see the revision history
available at https://github.com/jquery/jquery-ui
The following license applies to all parts of this software except as
documented below:
====
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
====
Copyright and related rights for sample code are waived via CC0. Sample
code is defined as all source code contained within the demos directory.
CC0: http://creativecommons.org/publicdomain/zero/1.0/
====
All files located in the node_modules and external directories are
externally maintained libraries used by this software which have their
own licenses; we recommend you read them, as their terms may differ from
the terms above.

View File

@ -0,0 +1,25 @@
Copyright (c) 2012 Paul Bakaus, http://jqueryui.com/
This software consists of voluntary contributions made by many
individuals (AUTHORS.txt, http://jqueryui.com/about) For exact
contribution history, see the revision history and logs, available
at http://jquery-ui.googlecode.com/svn/
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

33
spider/clientdetails.html Normal file
View File

@ -0,0 +1,33 @@
<html>
<!-- Selection of the client -->
<p><div id="clientselection"></div></p>
<!-- in tabs the details of the selected client are displayed -->
<div id="detailstabs">
<ul>
<li><a href="#today-1" class="clientconfig">Übersicht Einnahmen heutiger Tag</a></li>
<li><a href="#msg-2">Mitteilungen</a></li>
</ul>
<div id="today-1">
<p>
<!-- In this area shall be the summary of sums for each hour of today -->
<div id=hourlytablearea></div>
</p>
</div>
<div id="msg-2">
<!-- In this area shall be the messages area -->
<p>
<form>
<table class=genTable>
<tr><th colspan=3>Nachrichten</tr>
<tr><th>Nachrichtentyp<th>Nachricht<th>Aktion</tr>
<tr><td>Login-Nachricht<td><input type="text" value="" id=loginmsg><td><input value='Löschen' id='delLoginMessage' type='button' /><input value='Ändern' id='sendLoginMessage' type='button' /></tr>
<tr><td>Kellner-Nachricht<td><input type="text" value="" id=waitermsg><td><input value='Löschen' id='delWaiterMessage' type='button' /><input value='Ändern' id='sendWaiterMessage' type='button' /></tr>
</table>
</form>
</p>
</div>
</div>
</html>

41
spider/clientset.html Normal file
View File

@ -0,0 +1,41 @@
<html>
<div id=clientoverviewlist></div>
<table class=genTable>
<tr><th colspan=2>Betriebe-Tabelle managen</tr>
<tr><td>
<form>
<input type="submit" value="Sichern" id="backup_btn" style="width:100%;height:40px;color:red;"/>
</form>
<td>
<div id=restorearea>
<form id="restoreform" enctype="multipart/form-data" action="php/clients.php?command=readclients" method="POST" data-ajax="false">
<input type="hidden" name="MAX_FILE_SIZE" value="50000000" />
Diese Datei hochladen:
<input style="width:100%;height:40px;color:green;" name="userfile" id="userfile" type="file" />
<input style="width:100%;height:40px;color:red;" type="submit" value="Betriebe-Tabelle einlesen" formaction="php/clients.php?command=readclients"/>
</form>
</div> <!-- restore -->
</tr>
</table>
<br><hr><br>
<div id=spiderconfigarea style="border:2px solid black;">
<p>
<form>
&nbsp;&nbsp;&nbsp;Anzahl der Abrufe (Refresh-Rate):
<select id="refreshselection" style="height:40px;">
<option value="1">1 pro Stunde</option>
<option value="2">2 pro Stunde</option>
<option value="6">alle 10 Minuten</option>
<option value="60">jede Minute</option>
<option value="720">alle 5 Sekunden</option>
</select>
</form>
</p>
</div>
</html>

BIN
spider/img/green.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 160 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 47 KiB

BIN
spider/img/spider-logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 297 KiB

121
spider/index.html Normal file
View File

@ -0,0 +1,121 @@
<html>
<head>
<title>OrderSprinter Spider Startseite</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<link rel="stylesheet" type="text/css" href="styles/spider.css">
<script src="3rdparty/jquery-2.0.3.min.js"></script>
<script src="utils.js"></script>
</head>
<body>
<script>
/**
* Check if installation exists or needs to be done. This way the user can call the index.html page
* independently of the fact if he starts a fresh installation or uses an existing one.
*/
function startInstallationOrUseIt() {
doAjax("GET", "php/generals.php?command=isInstalled", null, handleResultOfInstallCheck, "PHP-Problem");
}
/**
* Handle the result of the check if the installatinón was done already. If not the user
* is forwarded to the install page.
*/
function handleResultOfInstallCheck(is_installed) {
if (is_installed == "Yes") {
useInstallation();
} else {
reloadPage("install.html");
}
}
/**
* If the user could be logged in forward him to the overview page. Otherwise give a
* useful message.
*/
function handleLoginResult(status) {
if (status == "Yes") {
// user could be logged in
reloadPage("overview.html");
} else {
// user entered wrong access code
alert("Falscher Zugangscode");
}
}
/**
* If the user is logged in the navigation menu and the logout button is shown. Otherwise
* the panel to log in is displayed.
*/
function handleLoginStatus(isLoggedIn) {
if (isLoggedIn == "YES") {
// no login mask!
$("#loginwindow").hide();
$("#logoutsection").show();
bindLogout();
} else {
// user needs to log in!
$("#loginwindow").show();
$("#logoutsection").hide();
// enable the function to log in
$("#loginbtn").on("click", function (e) {
e.stopImmediatePropagation();
e.preventDefault();
doAjax("POST", "php/generals.php?command=login", { authcode:$("#accesspass").val() }, handleLoginResult,null );
});
}
}
/**
* This method is called if it is clear that no installation is required. The existing
* installation shall be used. The next steps depend on if the user is already logged in.
*/
function useInstallation() {
doAjax("GET","php/generals.php?command=getSpiderVersion",null,insertSpiderVersion,null);
// is the user logged in already
doAjax("POST","php/generals.php?command=isUserLoggedIn",null,handleLoginStatus,null);
}
/**
* This is the first script entry for jQuery enabled sites.
*/
$( document ).ready(function() {
// check what might be the next step (installation or use of existing installation)
startInstallationOrUseIt();
});
</script>
<p>
<div>
<img src=img/spider-logo.png />
</div>
</p>
<div id="loginwindow">
<h1>OrderSprinter Spider</h1>
<form>
<table class="gentable">
<tr><td>Zugangspasswort:<td><input type="password" id="accesspass" /></tr>
<tr><td colspan=2><input type="submit" style="width:100%;height:70px;" value="Einloggen" id="loginbtn"/></tr>
</table>
</form>
</div>
<div id=logoutsection class="gentable">
<form>
<input type="submit" style="width:100%;height:70px;" value="Ausloggen" id="logoutbtn"/>
</form>
</div>
<br>
<div><i>OrderSprinter Spider - Version <span id=spiderversion></span></i></div>
</body>
</html>

65
spider/infopage.html Normal file
View File

@ -0,0 +1,65 @@
<html>
<head>
<head>
<title>OrderSprinter Spider Startseite</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<link rel="stylesheet" type="text/css" href="styles/spider.css">
<script src="3rdparty/jquery-2.0.3.min.js"></script>
<script src="utils.js"></script>
</head>
<body>
<script>
var nexturl = "";
$( document ).ready(function() {
var urlsuffix = location.search;
if (urlsuffix.length!=0) {
var urlstr=urlsuffix.slice(1);
var parts = urlstr.split("=");
var infotype = parts[0];
nexturl = parts[1];
var msg = parts[2].replace(/_/g," ");
if (infotype == "e") {
$("#head").html("Fehler/Error");
} else {
$("#head").html("Information");
}
$("#infotextarea").html(msg);
}
$("#confirmbutton").off("click").on("click", function (e) {
e.stopImmediatePropagation();
e.preventDefault();
setTimeout(function(){document.location.href = nexturl},500);
});
});
</script>
<div data-role="page" id="index-page">
<div data-role="panel" id="modulepanel" data-position="right" data-display="overlay">
</div><!-- /panel -->
<div data-role="header" data-theme="b" data-position="fixed" id="theheader">
<h1>Info</h1>
</div>
<table class=genTable>
<tr><th colspan=2 id="head">Information</tr>
<tr><td>Meldung<td id=infotextarea></tr>
<tr><td colspan=2><input type="submit" id="confirmbutton" value="Bestätigen" /></tr>
</table>
</div>
</body>
</html>

113
spider/install.html Normal file
View File

@ -0,0 +1,113 @@
<html>
<head>
<head>
<title>Installation</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<link rel="stylesheet" type="text/css" href="styles/spider.css">
<script src="3rdparty/jquery-2.0.3.min.js"></script>
<script src="utils.js"></script>
</head>
<body>
<script>
function getConfig() {
doAjax("GET",
"install/installer.php?command=getConfig",
null,fillDbVals,
"Kommunikation zum Server fehlerhaft");
}
/**
* Fill the user interface with the database connection parameters that are
* stored in the config.php file.
*/
function fillDbVals(dbVals) {
if (dbVals.status == "OK") {
var db = dbVals.result;
$("#db_host").val(db.host);
$("#db_name").val(db.db);
$("#db_user").val(db.user);
$("#db_pass").val(db.password);
$("#table_prefix").val(db.tabprefix);
testdb();
}
}
/**
* Bind the "install" button: The values from the user interface are
* collected and the transferred to the server installer script.
*/
function handleInstallBtn() {
$("#startinstallbtn").on("click", function (e) {
e.stopImmediatePropagation();
e.preventDefault();
var accesspass = $("#passwd").val();
if (accesspass == "") {
alert("Zugangspasswort muss gesetzt werden!");
} else {
var configData = {
host:$("#db_host").val(),
db:$("#db_name").val(),
user:$("#db_user").val(),
password:$("#db_pass").val(),
prefix:$("#table_prefix").val(),
adminpass:accesspass
};
doAjax("POST",
"install/installer.php?command=install",
configData,handleInstallResult,
"Kommunikation zum Server fehlerhaft");
};
});
}
/**
* Handle the result of the installation. If the installation completed without errors the
* user is forwarded to the login page (index.thml). Otherwise he gets an information with
* some hints to check what might have been the root cause for the failures.
*/
function handleInstallResult(result) {
if (result.status == "OK") {
reloadPage("index.html");
} else {
alert("Die Installation war nicht erfolgreich. Wurden die richtigen Datenbankparameter angegeben? Kann das PHP-Verzeichnis gelesen werden? Ist die Datei php/config.php beschreibbar? Die Fehlermeldung lautet: " + result.msg);
}
}
/**
* jQuery entry point after loading the web page
*/
$( document ).ready(function() {
getConfig();
handleInstallBtn();
});
</script>
<h1>Installation OrderSprinter <i>Spider</i></h1>
<div id=dbsettings>
Bitte geben Sie die Datenbank-Settings und das Zugangspasswort ein, mit dem nach der Installation der Zugang zu OrderSprinter Spider möglich sein soll:<br><br>
<form>
<table class=gentable>
<tr><th>Attribut<th>Wert<th>Erklärung</tr>
<tr><td>DB-Server<td><input id="db_host" /><td>Server, auf dem die Datenbank läuft</tr>
<tr><td>DB-Name<td><input id="db_name"/><td>Jede Datenbank des Datenbankservers hat einen eigenen Namen.</tr>
<tr><td>DB-Benutzer<td><input id="db_user" /><td>Verschiedene Benutzer können auf eine Datenbank mit benutzerspezifischen Rechten zugreifen.</tr>
<tr><td>DB-Passwort<td><input type="password" id="db_pass" /><td>Passwort des Datenbank-Benutzers</tr>
<tr><td>DB-Tabellenpräfix<td><input id="table_prefix" /><td>Allen Tabellen in der Datenbank wird dieses Präfix vorangestellt. Damit können mehrere Applikationen eine gemeinsame Datenbank nutzen.</tr>
<tr><td>Zugangspasswort<td><input type="password" id="passwd" /><td>Passwort, welches vor der Nutzung von OrderSprinter Spider eingegeben werden muss.</tr>
<tr><td colspan=3><input type="submit" id="startinstallbtn" value="Installation starten" style="width:100%;height:50px;"/></tr>
</table>
</form>
</div>
</body>
</html>

View File

@ -0,0 +1,137 @@
<?php
error_reporting(E_ALL);
require_once ('../php/dbutils.php');
require_once ('../php/globals.php');
require_once ('../php/config.php');
require_once ('../php/database/database.php');
class DbConfig {
/**
* Return the basic configuration that is needed to access the database and its content.
*/
static function getConfigVals() {
$retArray = array(
"host" => MYSQL_HOST,
"db" => MYSQL_DB,
"user" => MYSQL_USER,
"password" => MYSQL_PASSWORD,
"tabprefix" => TAB_PREFIX);
echo json_encode(array("status" => "OK","result" => $retArray));
}
/**
* Write the file php/config.php
*
* @param unknown $host
* @param unknown $db
* @param unknown $user
* @param unknown $password
* @param unknown $prefix
*/
static function writeConfigFile($host,$db,$user,$password,$prefix) {
$configFile = "../php/config.php";
if (is_file($configFile) and !is_writable($configFile)) {
return array("status" => "ERROR","msg" => "The configuration file does not exist or cannot be overwritten!");
}
try {
$errorlevel = "<?php\nerror_reporting(E_ALL);\n\n";
$hostlines = "// Zum Aufbau der Verbindung zur Datenbank\n";
$hostlines .= "// die Daten erhalten Sie von Ihrem Provider\n";
$hostlines .= "define ( 'MYSQL_HOST','$host' );";
$userlines = "define ( 'MYSQL_USER', '$user' );";
$dbpasslines = "define ( 'MYSQL_PASSWORD', '$password' );";
$dblines = "define ( 'MYSQL_DB', '$db' );";
$dbloglines = "define ( 'LOG', false );";
$prefixlines = "define ('TAB_PREFIX', '$prefix');";
$installstatusline = "define ('INSTALLSTATUS', 'installed');";
$configText = "$errorlevel\n$hostlines\n$userlines\n$dbpasslines\n$dblines\n$dbloglines\n$prefixlines\n$installstatusline\n?>";
file_put_contents($configFile, $configText);
return array("status" => "OK");
} catch (Exception $e) {
// Directory or file not writeable
return array("status" => "ERROR","msg" => "The exception during installation: " . $e);
}
}
}
class Installer {
/**
* Start a fresh installation! This means:
* - write the config.php
* - create the data base tables
* - fill initial values in the data base like version and access parameter
*
* @param unknown $host
* @param unknown $dbname
* @param unknown $user
* @param unknown $pass
* @param unknown $prefix
* @param unknown $adminpass
* @return boolean
*/
static function install($host,$dbname,$user,$pass,$prefix,$adminpass) {
$configstatus = DbConfig::writeConfigFile($host,$dbname,$user,$pass,$prefix);
if ($configstatus["status"] != "OK") {
return $configstatus;
}
$pdo = Database::openDbAndReturnPdo($host,$dbname,$user,$pass);
if (is_null($pdo)) {
return array("status" => "ERROR","msg" => "Database connection not possible. Is PDO extension installed for PHP?");
}
Database::dropTables($pdo);
Database::createEmptyTables($pdo, $prefix);
Database::setVersion($pdo,$prefix,"1.2.19");
Database::setAccessPassword($pdo,$prefix,$adminpass);
Database::setRefreshRate($pdo,$prefix,"5"); // default: 5 times per hour
return array("status" => "OK","msg" => "Installation successful");
}
}
// This is the command that is send via GET in the URL
$command = $_GET["command"];
if ($command == 'getConfig') {
// to be displayed on the install page as start parameters - fetched from the config.php
DbConfig::getConfigVals();
} else if ($command == 'install') {
// start a fresh installation
$ok = Installer::install($_POST['host'],$_POST['db'],$_POST['user'],$_POST['password'],$_POST['prefix'],$_POST['adminpass']);
if ($ok["status"] == "OK") {
// log out all users, i.e. kill all existing sessions
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"]
);
}
// kill all sessions - but does not seem to work correctly...
ini_set('session.gc_max_lifetime', 0);
ini_set('session.gc_probability', 1);
ini_set('session.gc_divisor', 1);
session_destroy();
echo json_encode($ok);
} else {
echo json_encode($ok);
}
} else if ($command == 'update') {
// to be filled when next version is available
}
?>

102
spider/js/client.js Normal file
View File

@ -0,0 +1,102 @@
/**
*
*/
function Client (id,name,url,remoteaccesscode,basicAuthUser,basicAuthPassword,remark) {
this.id = id;
this.name = name;
this.url = url;
this.remoteaccesscode = remoteaccesscode;
this.basicAuthUser = basicAuthUser;
this.basicAuthPassword = basicAuthPassword;
this.remark = remark;
}
/**
* Display the parameters of a client as an HTML form.
*
* @returns {String}
*/
Client.prototype.showSettings = function() {
var txt = "";
if (this.id == "new") {
txt += "<tr><td><input value='' placeholder='" + this.name + "' id='client_name_" + this.id + "'/>";
txt += "<td><input value='' placeholder='" + this.url + "' id='client_url_" + this.id + "'/>";
txt += "<td><input value='' placeholder='" + this.remoteaccesscode + "' id='client_remoteaccesscode_" + this.id + "'/>";
txt += "<td><input value='' placeholder='" + this.basicAuthUser + "' id='client_basicAuthUser_" + this.id + "'/>";
txt += "<td><input value='' placeholder='" + this.basicAuthPassword + "' id='client_basicAuthPassword_" + this.id + "'/>";
txt += "<td><input value='' placeholder='" + this.remark + "' id='client_remark_" + this.id + "'/>";
txt += "<td><input value='Neu anlegen' id='createNewClient' type='button' />";
txt += "</tr></table></form>";
} else {
txt += "<tr><td><input value='" + this.name + "' id='client_name_" + this.id + "'/>";
txt += "<td><input value='" + this.url + "' id='client_url_" + this.id + "'/>";
txt += "<td><input value='" + this.remoteaccesscode + "' id='client_remoteaccesscode_" + this.id + "'/>";
txt += "<td><input value='" + this.basicAuthUser + "' id='client_basicAuthUser_" + this.id + "'/>";
txt += "<td><input value='" + this.basicAuthPassword + "' id='client_basicAuthPassword_" + this.id + "'/>";
txt += "<td><input value='" + this.remark + "' id='client_remark_" + this.id + "'/>";
txt += "<td><input value='Ändern' id='changeClient_" + this.id + "' type='button' />";
txt += "&nbsp;&nbsp;<input value='Löschen' id='deleteClient_" + this.id + "' type='button' />";
txt += "</tr>";
}
return txt;
};
/**
* Bind the action buttons (create new client, delete or change clients settings) to the
* functions that are responsible for its execution.
*/
Client.prototype.handleactions = function() {
var self = this;
$("#changeClient_" + this.id).off("click").on("click", function (e) {
e.stopImmediatePropagation();
e.preventDefault();
var data = self.getData(this.id.split("_")[1]);
doAjax("POST","php/clients.php?command=changeclient",data,self.handleactionresult,"Kommunikationsfehler");
});
$("#deleteClient_" + this.id).off("click").on("click", function (e) {
e.stopImmediatePropagation();
e.preventDefault();
var data = self.getData(this.id.split("_")[1]);
doAjax("POST","php/clients.php?command=deleteclient",data,self.handleactionresult,"Kommunikationsfehler");
});
$("#createNewClient").off("click").on("click", function (e) {
e.stopImmediatePropagation();
e.preventDefault();
var data = self.getData("new");
doAjax("POST","php/clients.php?command=createclient",data,self.handleactionresult,"Kommunikationsfehler");
});
}
/**
* Read the parameters of an instance from the web UI and add the "id" to the data set.
*
* @param id id of the client (is used also in the id of the html input fields)
* @returns an object that contains the data in a format that can be handled by the PHP client methods
*/
Client.prototype.getData = function(id) {
var data = {
id:id,
name:$("#client_name_" + id).val(),
url:$("#client_url_" + id).val(),
code:$("#client_remoteaccesscode_" + id).val(),
basicauthuser:$("#client_basicAuthUser_" + id).val(),
basicauthpass:$("#client_basicAuthPassword_" + id).val(),
remark:$("#client_remark_" + id).val()
};
return data;
}
/**
* Handle the answer of an AJAX call to create, change or delete a client
* @param answer
*/
Client.prototype.handleactionresult = function(answer) {
if (answer.status[0] == 1) {
reloadPage(window.location.href);
} else {
alert("Fehler: " + answer.status[1]);
}
}

166
spider/js/clientdetails.js Normal file
View File

@ -0,0 +1,166 @@
/**
* Set of clients
*/
function ClientDetails () {
//
};
/**
* the selected client id - needed statically for cyclic refresh
*/
ClientDetails.selectedClientId = null;
/**
* Save the status of the messages are inserted in the UI. They should not
* be overwritten with each cyclic refresh, so that user inputs won't be
* overwritten.
*/
ClientDetails.messagesInserted = false;
/**
* Selection box at which the user can select the client.
* This method also binds the change event, i.e. the function that is called
* once the user has changed the selection.
*
* @param clients
* @param htmlid
*/
ClientDetails.createSelectionBox = function(clients,htmlid) {
$("#detailstabs").tabs();
var html = "";
if (clients.length == 0) {
html = "Es wurden noch keine Betriebe eingegeben.";
} else {
ClientDetails.selectedClientId = clients[0].id;
ClientDetails.requestReport(clients[0].id);
html = "<select style='color:green;height:60px;background-color:Lavender;'>";
for (var i=0;i<clients.length;i++) {
var client = clients[i];
html += "<option id='option_client_" + client.id + "' value='" + client.id + "'>" + client.name + "</option>";
}
}
$(htmlid).html("Auswahl Betrieb: " + html);
// handle a change
$(htmlid).change(function() {
var clientid = $( htmlid + " option:selected" ).val();
ClientDetails.selectedClientId = clientid;
ClientDetails.requestReport(clientid);
});
// handle button events for the selected client
$("#delLoginMessage").on("click", function (e) {
$("#loginmsg").val("");
ClientDetails.sendMessage(e,"","sendloginmessage");
});
$("#sendLoginMessage").on("click", function (e) {
ClientDetails.sendMessage(e,$("#loginmsg").val(),"sendloginmessage");
});
$("#delWaiterMessage").on("click", function (e) {
$("#waitermsg").val("");
ClientDetails.sendMessage(e,"","sendwaitermessage");
});
$("#sendWaiterMessage").on("click", function (e) {
ClientDetails.sendMessage(e,$("#waitermsg").val(),"sendwaitermessage");
});
};
/**
* Send a message as login or waiter message to the client. If the message is an
* empty string it works as if the message has to be deleted.
* @param e
* @param message
* @param command
*/
ClientDetails.sendMessage = function(e,message,command) {
e.stopImmediatePropagation();
e.preventDefault();
if (ClientDetails.selectedClientId != null) {
var msg = "";
var data = {
clientid:ClientDetails.selectedClientId,
message:message
};
doAjaxTransmitValue("POST","php/datacollector.php?command=" + command,data,null,data,null);
}
}
ClientDetails.requestReport = function(clientid) {
$("#hourlytablearea").html("");
var data = {
clientid:clientid,
action:"report"
};
doAjaxTransmitValue("POST","php/datacollector.php?command=getreport",data,ClientDetails.insertClientValue,data,null);
if (!ClientDetails.messagesInserted) {
$("#loginmsg").val("");
$("#waitermsg").val("");
var data = { clientid:clientid,action:"getwaitermessage" };
doAjaxTransmitValue("POST","php/datacollector.php?command=getwaitermessage",data,ClientDetails.insertClientMessage,data,null);
var data = { clientid:clientid,action:"getloginmessage" };
doAjaxTransmitValue("POST","php/datacollector.php?command=getloginmessage",data,ClientDetails.insertClientMessage,data,null);
ClientDetails.messagesInserted = true;
}
};
ClientDetails.updateReport = function() {
var clientid = ClientDetails.selectedClientId;
if (clientid != null) {
ClientDetails.requestReport(clientid);
}
};
ClientDetails.insertClientValue = function(answer,data) {
if (data.action == "report") {
// has no status
// first calculate the max value
var today = answer.today.content;
var i=0;
var max = 0.0;
for (i=0;i<today.length;i++) {
var sum = parseFloat(today[i].sum);
if (sum > max) {
max=sum;
}
}
var html = "<table class=genTable width='100%'>";
html += "<tr><th>Stunde<th>Einnahme<th width='70%'>Visuelle Anzeige</tr>";
for (i=0;i<today.length;i++) {
var hour = today[i].iter;
var sum = parseFloat(today[i].sum);
var formattedSum = sum.toFixed(2).replace(".",",");
var width = 0.0;
if (max != 0.0) {
width = sum/max * 98.0;
}
var graph = "<img src=img/green.png style='height:20px;width:" + width + "%;' />";
html += "<tr><td>" + hour + "<td>" + formattedSum + "<td>" + graph + "</tr>";
}
html += "</table>";
$("#hourlytablearea").html(html);
}
};
ClientDetails.insertClientMessage = function(answer,data) {
if (answer.status == 1) {
var msg = answer.message;
var id = "";
if (data.action == "getloginmessage") {
$("#loginmsg").val(msg);
} else if (data.action == "getwaitermessage") {
$("#waitermsg").val(msg);
}
}
}

127
spider/js/clientinfo.js Normal file
View File

@ -0,0 +1,127 @@
/**
* Set of clients
*/
function ClientInfo () {
//
};
/**
* Create the table of all clients and fill this table with the overall information
* about the current status like how many open tables etc.
*
* @param clients
* @param htmlid
*/
ClientInfo.showInfoOfAllClients = function(clients,htmlid) {
var html = "";
if (clients.length == 0) {
html = "Es wurden noch keine Betriebe eingegeben.";
} else {
// create a table framework, that can later be dynamically filled by data
html = "<table class=genTable><tr><th>&nbsp;<th colspan=" + clients.length + ">Betriebe</tr><tr><th>&nbsp;";
var i=0;
for (i=0;i<clients.length;i++) {
var client = clients[i];
html += "<th>" + client.name;
}
html += "</tr>";
// the header is now completed
html += ClientInfo.createHtmlRow(clients,"Softwareversion","Version");
html += ClientInfo.createHtmlRow(clients,"Offene Rechnungen","OpenBills");
html += ClientInfo.createHtmlRow(clients,"Noch nicht abgerechnete Tische","OpenTables");
html += ClientInfo.createHtmlRow(clients,"Letzter Tagesabschluss","LastClosing");
html += "</table>";
for (var i=0;i<clients.length;i++) {
var client = clients[i];
}
}
$(htmlid).html(html);
ClientInfo.requestDataOfClients(clients);
};
/**
* Request the clients information (open tables, not paid sum, version) in the table that
* was created by showInfoOfAllClients
*
* To prevent problems with the "same origin policy" the data of the different clients is
* fetched by a php process on the server.
*
* @param clients
*/
ClientInfo.requestDataOfClients = function(clients) {
var html = "";
if (clients.length > 0) {
var i=0;
for (i=0;i<clients.length;i++) {
var client = clients[i];
// version info of the clients
var data = {
clientid:client.id,
action:"version"
};
doAjaxTransmitValue("POST","php/datacollector.php?command=getclientversion",data,ClientInfo.insertClientValue,data,null);
// sum of the last closing
data = {
clientid:client.id,
number:1,
action:"lastclosing"
};
doAjaxTransmitValue("POST", "php/datacollector.php?command=getlastclosings", data, ClientInfo.insertClientValue, data, null);
// getOpenTables: how many tables are in the pipeline to pay and how much
data = {
remoteaccesscode: client.remoteaccesscode,
clientid:client.id,
action:"opentables"
};
doAjaxTransmitValue("POST", "php/datacollector.php?command=getopentables", data, ClientInfo.insertClientValue, data, null);
}
}
};
/**
* Handle the answer of a specific call (e.g. get version) of one client and insert
* the received value into the correct table cell.
*
* @param answer
* @param data
*/
ClientInfo.insertClientValue = function(answer,data) {
if (answer.status == 1) {
if (data.action == "version") {
$("#Version_" + data.clientid).html(answer.version);
} else if (data.action == "lastclosing") {
var sum = parseFloat(answer.closings[0].billsum);
var formattedSum = sum.toFixed(2).replace(".",",");
$("#LastClosing_" + data.clientid).html(formattedSum);
} else if (data.action == "opentables") {
var formattedSum = answer.sum.toFixed(2).replace(".",",");
$("#OpenBills_" + data.clientid).html(formattedSum);
$("#OpenTables_" + data.clientid).html(answer.opentables);
}
}
};
/**
* Prepare a table row for a specific item (e.g. version) with columns
* for all configured clients.
*
* @param clients
* @param rowTitle
* @param rowId
* @returns {String}
*/
ClientInfo.createHtmlRow = function(clients,rowTitle,rowId) {
var html = "<tr><td class='topic'>" + rowTitle;
for (var i=0;i<clients.length;i++) {
var client = clients[i];
html += "<td id=" + rowId + "_" + client.id + " style='text-align:right;'>&nbsp;";
}
return html + "</tr>";
}

120
spider/js/clientset.js Normal file
View File

@ -0,0 +1,120 @@
/**
* Set of clients
*/
function ClientSet () {
//this.clients = clients;
}
ClientSet.overviewHtmlFieldId = "";
ClientSet.clients = [];
ClientSet.readAllClientsFromDb = function(htmlFieldId) {
ClientSet.overviewHtmlFieldId = htmlFieldId;
doAjax("POST","php/clients.php?command=getallclients",null,ClientSet.fillclientset,"Kommunikationsfehler");
}
/**
* Return the array of all clients that have been read from the database, take care not
* to return the placeholder for a new instance!
*
* @returns {Array}
*/
ClientSet.getAllReadClients = function() {
var existingClients = [];
ClientSet.clients.forEach(function(entry) {
if (entry.id != "new") {
existingClients[existingClients.length] = entry;
}
});
return existingClients;
}
/**
* Use the given client parameter information to fill up the web ui
* @param clients
*/
ClientSet.fillclientset = function(clients) {
ClientSet.clients = [];
for (var i=0;i<clients.length;i++) {
var aClient = clients[i];
// id,name,url,remoteaccesscode,basicAuthUser,basicAuthPassword,remark
ClientSet.clients[ClientSet.clients.length] = new Client(aClient.id,aClient.name,aClient.url,aClient.remoteaccesscode,aClient.basicauthuser,aClient.basicauthpass,aClient.remark);
}
// now add an empty entry for a "new" client
ClientSet.clients[ClientSet.clients.length] = new Client("new","Name3","http://","Fernzugang","BasicAuthUser","BasicAuthPassword","Bemerkung3");
$(ClientSet.overviewHtmlFieldId).html(ClientSet.getTableOfAllClients());
ClientSet.bindActionsOfAllClients();
ClientSet.bindRateSelection();
}
ClientSet.bindRateSelection = function() {
$('#refreshselection').change(function() {
var rate = $( "#refreshselection option:selected" ).val();
var data = { rate: rate};
doAjax("POST","php/generals.php?command=setrate",data,ClientSet.reloadOverviewPage,null);
});
}
ClientSet.reloadOverviewPage = function() {
reloadPage("overview.html");
};
/**
* Table th-headers that describe the content of the columns for the clients parameters
* @returns {String} html string
*/
ClientSet.getHeader = function() {
return "<tr><th>Name<th>Internetadresse<th>Fernzugangscode<th>Basic Authentication Benutzer<th>Basic Authentication Passwort<th>Bemerkung<th>Aktionen</tr>";
};
/**
* Get the full clients parameters table of all clients
*
* @returns {String} the html string
*/
ClientSet.getTableOfAllClients = function() {
var txt = "<form><table class=gentable>" + this.getHeader();
var i=0;
for (i=0;i<ClientSet.clients.length;i++) {
var aClient = this.clients[i];
txt += aClient.showSettings();
}
txt += "</table></form>";
return txt;
};
/**
* Bind the action buttons (create new client, delete or change clients settings) to the
* functions that are responsible for its execution.
* This function does this for all clients in the set. It must be called
* after the rendering in the user interface!
*/
ClientSet.bindActionsOfAllClients = function() {
var txt = "<form><table class=gentable>" + this.getHeader();
var i=0;
for (i=0;i<ClientSet.clients.length;i++) {
var aClient = ClientSet.clients[i];
aClient.handleactions();
}
};
/**
* Read the parameters of all clients and show the parameter list in the html element
* with the given id.
*/
function showClient() {
ClientSet.readAllClientsFromDb("#clientoverviewlist");
}
/**
* Bindings for buttons that work on the complete set of clients, e.g. backup
*/
function bindClientSetManageFunctions() {
$("#backup_btn").on("click", function (e) {
e.stopImmediatePropagation();
e.preventDefault();
window.location.href = "php/clients.php?command=saveclients";
});
}

9
spider/logout.php Normal file
View File

@ -0,0 +1,9 @@
<?php
session_start();
session_destroy();
$hostname = $_SERVER['HTTP_HOST'];
$path = dirname($_SERVER['PHP_SELF']);
header('Location: http://'.$hostname.($path == '/' ? '' : $path).'/index.html');
?>

151
spider/overview.html Normal file
View File

@ -0,0 +1,151 @@
<html>
<head>
<title>OrderSprinter Spider</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<link rel="stylesheet" type="text/css" href="styles/spider.css">
<link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
<script src="3rdparty/jquery-2.0.3.min.js"></script>
<script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
<script src="utils.js"></script>
<script src="js/client.js"></script>
<script src="js/clientset.js"></script>
<script src="js/clientinfo.js"></script>
<script src="js/clientdetails.js"></script>
</head>
<body>
<!-- define style here because they are specific to this page and too late in spider.css -->
<style>
.ui-tabs .clientconfig {
background: Khaki;
}
.ui-tabs .clientinfo {
background: #ffd3af;
}
.ui-tabs .clientdetails {
background: DarkKhaki;
}
</style>
<script>
/**
* If the user is logged the overview shall be displayed. Otherwise forward to login page.
*/
function handleLoginStatus(isLoggedIn) {
if (isLoggedIn == "YES") {
// show overview
showClient();
} else {
// user needs to log in -> forward to entry page
setTimeout(function(){document.location.href = "index.html"},250);
}
}
function checkIntervalLoginStatus() {
var refreshId = setInterval(function() {
doAjaxTransmitValue("POST","php/datacollector.php?command=isloggedin",null,handleIsLoggedIn,null,null);
}, 5000);
}
function handleIsLoggedIn(answer) {
if (answer !== "YES") {
setTimeout(function(){document.location.href = "index.html"},500);
}
}
function refreshClientInfo() {
ClientInfo.showInfoOfAllClients(ClientSet.getAllReadClients(),"#clientinfos");
}
function handleRefreshRate(rateinfo) {
var refreshRate = 1; // default: 1 time / hour
if (rateinfo.status[0] == 1) {
refreshRate = parseInt(rateinfo.rate);
}
$("#refreshselection").val(refreshRate);
// update information in intervals
var refreshId = setInterval(function() {
refreshClientInfo();
ClientDetails.updateReport();
}, 3600000/refreshRate);
}
/**
* This is the first script entry for jQuery enabled sites.
*/
$( document ).ready(function() {
$.ajaxSetup({ cache: false });
doAjax("GET","php/generals.php?command=getSpiderVersion",null,insertSpiderVersion,null);
$("#clientoviewarea").load("clientset.html");
$("#clientsdetailsarea").load("clientdetails.html");
doAjax("POST","php/generals.php?command=isUserLoggedIn",null,handleLoginStatus,null);
bindLogout();
bindClientSetManageFunctions();
$("#tabs").tabs();
$('#tabs .ui-tabs-nav a[href="#tabs-1"], #tabs-1').addClass('clientconfig');
$('#tabs .ui-tabs-nav a[href="#tabs-2"], #tabs-2').addClass('clientinfo');
$('#tabs .ui-tabs-nav a[href="#tabs-3"], #tabs-3').addClass('clientdetails');
// initialize tables
refreshClientInfo();
// insert a selection box of clients for detailed view
ClientDetails.createSelectionBox(ClientSet.getAllReadClients(),"#clientselection");
// fetch the value by which the data shall be refreshed
doAjax("GET","php/generals.php?command=getrate",null,handleRefreshRate,null);
checkIntervalLoginStatus();
});
</script>
<table border=0>
<tr><td><img src=img/spider-logo-30s.png />
<td><h1>Übersicht über alle Betriebe</h1>
</tr></table>
<div id="tabs">
<ul>
<li><a href="#tabs-1" class="clientconfig">Betriebe festlegen</a></li>
<li><a href="#tabs-2">Übersicht</a></li>
<li><a href="#tabs-3">Detailansicht</a></li>
</ul>
<div id="tabs-1">
<p>
<div id=clientoviewarea>
</div> <!-- Area with list of all clients and the buttons to manage the set -->
</p>
</div>
<div id="tabs-2">
<p>
<div id=clientinfos></div>
</p>
</div>
<div id="tabs-3">
<div id="clientsdetailsarea"></div>
</div>
</div>
<div id=logoutsection class="gentable">
<form>
<input type="submit" style="width:100%;height:70px;" value="Ausloggen" id="logoutbtn"/>
</form>
</div>
<br>
<div><i>OrderSprinter Spider - Version <span id=spiderversion></span></i></div>
</body>
</html>

185
spider/php/clients.php Normal file
View File

@ -0,0 +1,185 @@
<?php
require_once ('config.php');
require_once ('database/database.php');
require_once ('globals.php');
require_once ('utils.php');
if (!isUserLoggedInCore()) {
return;
}
$command = $_GET["command"];
if ($command == 'createclient') {
createclient($_POST['name'],$_POST['url'],$_POST['code'],$_POST['basicauthuser'],$_POST['basicauthpass'],$_POST['remark']);
} else if ($command == 'deleteclient') {
deleteclient($_POST['id']);
} else if ($command == 'changeclient') {
changeclient($_POST['id'],$_POST['name'],$_POST['url'],$_POST['code'],$_POST['basicauthuser'],$_POST['basicauthpass'],$_POST['remark']);
} else if ($command == 'getallclients') {
getallclients();
} else if ($command == 'saveclients') {
saveclients();
} else if ($command == 'readclients') {
readclients();
}
/**
* Fetch the parameters of all clients from the data base
*/
function getallclients() {
$pdo = DbUtils::openDbAndReturnPdo();
$sql = "SELECT * FROM %clients%";
$stmt = $pdo->prepare(DbUtils::substTableAlias($sql));
$stmt->execute();
echo json_encode($stmt->fetchAll());
}
/**
* Create en entry for a new client in the database if the client does not exist already.
* The existence is tested by checking the name and the url.
*
* @param unknown $name a name for the client
* @param unknown $url the http address of the client
* @param unknown $code the remote access code
* @param unknown $basicAuthUser user of basic authentication
* @param unknown $basicAuthPass password for basic authentication
* @param unknown $remark a remark for the client that can be set by the user
*/
function createclient($name,$url,$code,$basicAuthUser,$basicAuthPass,$remark) {
$pdo = DbUtils::openDbAndReturnPdo();
$pdo->beginTransaction();
$sql = "SELECT id FROM %clients% WHERE name=? OR url=?";
$stmt = $pdo->prepare(DbUtils::substTableAlias($sql));
$stmt->execute(array($name,$url));
$foundSameClients = $stmt->rowCount();
if ($foundSameClients > 0) {
$pdo->rollBack();
echo json_encode(array("status" => array(ERROR_CLIENT_EXISTS,ERROR_CLIENT_EXISTS_MSG)));
return;
}
// at this point it is checked that the client does not exist and thus is can be inserted as new client
$sql = "INSERT INTO %clients% (`id` , `name`,`url`,`remoteaccesscode`,`basicauthuser`,`basicauthpass`,`remark`) VALUES (NULL,?,?,?,?,?,?)";
$stmt = $pdo->prepare(DbUtils::substTableAlias($sql));
$stmt->execute(array($name,$url,$code,$basicAuthUser,$basicAuthPass,$remark));
$pdo->commit();
echo json_encode(array("status" => array(ACTION_OK,ACTION_OK_MSG)));
}
/**
* Change the parameters of an existing client in the database
*
* @param unknown $id
* @param unknown $name
* @param unknown $url
* @param unknown $code
* @param unknown $basicAuthUser
* @param unknown $basicAuthPass
* @param unknown $remark
*/
function changeclient($id,$name,$url,$code,$basicAuthUser,$basicAuthPass,$remark) {
$pdo = DbUtils::openDbAndReturnPdo();
$pdo->beginTransaction();
$sql = "SELECT id FROM %clients% WHERE id=?";
$stmt = $pdo->prepare(DbUtils::substTableAlias($sql));
$stmt->execute(array($id));
$foundSameClients = $stmt->rowCount();
if ($foundSameClients == 0) {
$pdo->rollBack();
echo json_encode(array("status" => array(ERROR_CLIENT_EXISTS,ERROR_CLIENT_EXISTS_MSG)));
return;
}
$sql = "UPDATE %clients% SET name=?,url=?,remoteaccesscode=?,basicauthuser=?,basicauthpass=?,remark=? WHERE id=?";
$stmt = $pdo->prepare(DbUtils::substTableAlias($sql));
$stmt->execute(array($name,$url,$code,$basicAuthUser,$basicAuthPass,$remark,$id));
$pdo->commit();
echo json_encode(array("status" => array(ACTION_OK,ACTION_OK_MSG)));
}
/**
* Delete the client in the data base
* @param unknown $id
*/
function deleteclient($id) {
$pdo = DbUtils::openDbAndReturnPdo();
$pdo->beginTransaction();
$sql = "SELECT id FROM %clients% WHERE id=?";
$stmt = $pdo->prepare(DbUtils::substTableAlias($sql));
$stmt->execute(array($id));
$foundSameClients = $stmt->rowCount();
if ($foundSameClients == 0) {
$pdo->rollBack();
echo json_encode(array("status" => array(ERROR_CLIENT_DOES_NOT_EXIST,ERROR_CLIENT_DOES_NOT_EXIST_MSG)));
return;
}
$sql = "DELETE FROM %clients% WHERE id=?";
$stmt = $pdo->prepare(DbUtils::substTableAlias($sql));
$stmt->execute(array($id));
$pdo->commit();
echo json_encode(array("status" => array(ACTION_OK,ACTION_OK_MSG)));
}
/**
* Fetch the information about all configured clients from the database and
* return it as a json stream for download by the user.
*/
function saveclients() {
$pdo = DbUtils::openDbAndReturnPdo();
$sql = "SELECT * FROM %clients%";
$stmt = $pdo->prepare(DbUtils::substTableAlias($sql));
$stmt->execute();
$retStr = json_encode($stmt->fetchAll());
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: public");
header("Content-Description: File Transfer");
header("Content-type: application/octet-stream");
header("Content-Disposition: attachment; filename=\"backup-clients.json\"");
header("Content-Transfer-Encoding: binary");
header("Content-Length: ". strlen($retStr));
echo $retStr;
}
/**
* Read in a json file with the set of clients and save them in the
* database as a new set.
*
*/
function readclients() {
if ($_FILES['userfile']['error'] != UPLOAD_ERR_OK //checks for errors
&& is_uploaded_file($_FILES['userfile']['tmp_name'])) { //checks that file is uploaded
header("Location: ../infopage.html?e=overview.html=Kann_Datei_nicht_laden.");
exit();
}
if(!file_exists($_FILES['userfile']['tmp_name']) || !is_uploaded_file($_FILES['userfile']['tmp_name'])) {
header("Location: ../infopage.html?e=overview.html=Datei_nicht_angegeben.");
exit();
}
$content = json_decode(file_get_contents($_FILES['userfile']['tmp_name']));
$pdo = DbUtils::openDbAndReturnPdo();
$pdo->beginTransaction();
$sql = "DELETE FROM %clients%";
$stmt = $pdo->prepare(DbUtils::substTableAlias($sql));
$stmt->execute();
foreach ($content as $client) {
$sql = "INSERT INTO %clients% (`id` , `name`,`url`,`remoteaccesscode`,`basicauthuser`,`basicauthpass`,`remark`) VALUES (NULL,?,?,?,?,?,?)";
$stmt = $pdo->prepare(DbUtils::substTableAlias($sql));
$stmt->execute(array($client->name,$client->url,$client->code,$client->basicauthuser,$client->basicauthpass,$client->remark));
}
$pdo->commit();
header("Location: ../infopage.html?i=overview.html=Import_war_erfolgreich."); /* Browser umleiten */
exit;
}
?>

14
spider/php/config.php Normal file
View File

@ -0,0 +1,14 @@
<?php
error_reporting(E_ALL);
// Zum Aufbau der Verbindung zur Datenbank
// die Daten erhalten Sie von Ihrem Provider
define ( 'MYSQL_HOST','localhost' );
define ( 'MYSQL_USER', 'benutzer' );
define ( 'MYSQL_PASSWORD', 'password' );
define ( 'MYSQL_DB', 'database' );
define ( 'LOG', false );
define ('TAB_PREFIX', 'spider_');
define ('INSTALLSTATUS', 'new');
?>

View File

@ -0,0 +1,200 @@
<?php
require_once (__DIR__. '/../dbutils.php');
class Database {
/**
* Open a connection to the data base.
* Don't use the DbUtils function to be sure that not the previous config.php but the new parameters
* are used for the connection!
*
* @param unknown $host
* @param unknown $dbname
* @param unknown $user
* @param unknown $pass
* @return NULL|PDO: null if no connection could be established, otherwise the PDO instance
*/
public static function openDbAndReturnPdo($host,$dbname,$user,$pass) {
$dsn = 'mysql:host=' . $host . ';dbname=' . $dbname;
$user = $user;
$password = $pass;
$pdo = null;
try {
$pdo = new PDO($dsn, $user, $password);
$pdo ->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
}
catch (PDOException $e) {
return null;
}
return $pdo;
}
static function doSQL($pdo,$sql) {
$stmt = $pdo->prepare(DbUtils::substTableAlias($sql));
$stmt->execute();
}
/**
* Execute the SQL command, but in case of errors catch and ignore them.
* This method is intended to be used during installation when the existence of
* database tables can not be guaranteed.
*
* @param unknown $pdo
* @param unknown $sql the command to be executed
*/
static function doSqlSuppressError($pdo,$sql) {
try {
$stmt = $pdo->prepare(DbUtils::substTableAlias($sql));
$stmt->execute();
} catch (Exception $e) {
// nothing - table not present or whatever...
}
}
/**
* To clean up the database before a fresh installation drop the
* tables that will be recreated for the instance. If the tables
* do not exist (first installation) then errors are suppressed.
* @param unknown $pdo
*/
static function dropTables($pdo) {
self::doSqlSuppressError($pdo, "drop TABLE `%config%`");
self::doSqlSuppressError($pdo, "drop TABLE `%clients%`");
}
static function createConfigTable($pdo,$prefix) {
$sql = "
CREATE TABLE `%config%` (
`id` INT (10) NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`name` VARCHAR ( 1000 ) ,
`setting` VARCHAR ( 10000 )
) CHARACTER SET latin1 COLLATE latin1_german1_ci ENGINE = InnoDb ;
";
$stmt = $pdo->prepare(DbUtils::substTableAliasWithPrefix($sql,$prefix));
$stmt->execute();
}
static function createClientsTable($pdo,$prefix) {
$sql = "
CREATE TABLE `%clients%` (
`id` INT (10) NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`name` VARCHAR ( 100 ) ,
`url` VARCHAR ( 200 ) ,
`remoteaccesscode` VARCHAR ( 200 ),
`basicauthuser` VARCHAR ( 50 ),
`basicauthpass` VARCHAR ( 50 ),
`remark` VARCHAR ( 300 )
) CHARACTER SET latin1 COLLATE latin1_german1_ci ENGINE = InnoDb ;
";
$stmt = $pdo->prepare(DbUtils::substTableAliasWithPrefix($sql,$prefix));
$stmt->execute();
}
/**
* Create empty tables for the installation.
* @param unknown $pdo
* @param unknown $prefix
*/
static function createEmptyTables($pdo,$prefix)
{
self::createConfigTable($pdo, $prefix);
self::createClientsTable($pdo, $prefix);
}
/**
* Set the version as parameter into the config table. This version
* can be used for the update procedure to check from which source
* version the software needs to be updated.
*
* @param unknown $pdo
* @param unknown $prefix
* @param unknown $version
*/
static function setVersion($pdo,$prefix,$version) {
self::changeOneConfigItem($pdo, "version", $version, $prefix);
}
/**
* Set the access password that is needed to use spider
*
* @param unknown $pdo
* @param unknown $prefix
* @param unknown $password
*/
static function setAccessPassword($pdo,$prefix,$password) {
self::changeOneConfigItem($pdo, "accesspassword", $password, $prefix);
}
static function setRefreshRate($pdo,$prefix,$rate) {
if (is_null($prefix)) {
// is not part of installer procedure -> use prefix in config
$prefix = TAB_PREFIX;
}
self::changeOneConfigItem($pdo, "refreshrate", $rate, $prefix);
}
/**
* Change only one item in the config table. If the item does not exist
* at the moment it will be created.
* The method expects that there is only one set with the given parameter,
* it does not check for duplicates!
*
* @param unknown $pdo
* @param unknown $theItem the name of the parameter
* @param unknown $theValue the value that shall be assigned to the parameter
* @param unknown $prefix table prefix
*/
static private function changeOneConfigItem($pdo,$theItem,$theValue,$prefix) {
// is the value already there, or has it to be created?
$sql = "SELECT setting from %config% WHERE name=?";
$stmt = $pdo->prepare(DbUtils::substTableAliasWithPrefix($sql,$prefix));
$stmt->execute(array($theItem));
$row = $stmt->fetchObject();
if ($stmt->rowCount() > 0) {
$sql = "UPDATE %config% SET setting=? WHERE name=?";
$stmt = $pdo->prepare(DbUtils::substTableAliasWithPrefix($sql,$prefix));
$stmt->execute(array($theValue,$theItem));
} else {
$sql = "INSERT INTO %config% (`id` , `name`,`setting`) VALUES (NULL , ? , ?)";
$stmt = $pdo->prepare(DbUtils::substTableAliasWithPrefix($sql,$prefix));
$stmt->execute(array($theItem,$theValue));
}
}
/**
* Get a setting from the config table as a string value. If the item does not
* exist an empty string ("") will be returned.
*
* @param unknown $pdo
* @param unknown $key
* @return string|unknown
*/
static public function getConfigItem($pdo,$key) {
$sql = "SELECT setting FROM %config% WHERE name=?";
if (is_null($pdo)) {
return "";
}
$stmt = $pdo->prepare(DbUtils::substTableAlias($sql));
$stmt->execute(array($key));
$row = $stmt->fetchObject();
if ($stmt->rowCount() == 0) {
return "";
}
$theValue = $row->setting;
if (is_null($theValue)) {
return "";
} else {
return $theValue;
}
}
}
?>

View File

@ -0,0 +1,129 @@
<?php
/*
* This part fetches the information from the various clients. It is necessary
* to use this PHP class instead of doing this on the client side by JavaScript
* because the "same origin policy" does not allow this on the client side.
*/
require_once ('config.php');
require_once ('database/database.php');
require_once ('globals.php');
require_once ('utils.php');
$command = $_GET["command"];
if ($command == 'isloggedin') {
echo json_encode(isUserLoggedInCore() ? "YES" : "NO");
}
if (!isUserLoggedInCore()) {
return;
}
if ($command == 'getclientversion') {
getClientVersion($_POST['clientid']);
} else if ($command == 'getlastclosings') {
getLastClosings($_POST['clientid'],$_POST['number']);
} else if ($command == 'getopentables') {
getOpenTables($_POST['clientid']);
} else if ($command == 'getreport') {
getReport($_POST['clientid']);
} else if ($command == 'getwaitermessage') {
getWaiterMessage($_POST['clientid']);
} else if ($command == 'getloginmessage') {
getLoginMessage($_POST['clientid']);
} else if ($command == 'sendwaitermessage') {
sendWaiterMessage($_POST['clientid'],$_POST['message']);
} else if ($command == 'sendloginmessage') {
sendLoginMessage($_POST['clientid'],$_POST['message']);
}
/**
* Get the version of a client.
* @param unknown $clientid
*/
function getClientVersion($clientid) {
getDataFromClient($clientid,"getVersion",array());
}
/**
* Get the last closings of a client.
* @param unknown $clientid
* @param unknown $number
*/
function getLastClosings($clientid,$number) {
$data = array('number' => "$number");
getDataFromClient($clientid,"getLastClosings",$data);
}
/**
* Get the sum of still unpaid tables and the number of open tables.
* @param unknown $clientid
*/
function getOpenTables($clientid) {
getDataFromClient($clientid,"getOpenTables",array());
}
function getReport($clientid) {
getDataFromClient($clientid,"getReport",array());
}
function getWaiterMessage($clientid) {
getDataFromClient($clientid,"getWaiterMessage",array());
}
function sendWaiterMessage($clientid,$message) {
getDataFromClient($clientid,"sendWaiterMessage",array("message" => $message));
}
function getLoginMessage($clientid) {
getDataFromClient($clientid,"getLoginMessage",array());
}
function sendLoginMessage($clientid,$message) {
getDataFromClient($clientid,"sendLoginMessage",array("message" => $message));
}
/**
* Fetch the parameters of a client with the given clientid from the data base
* by use of the remote access command of that client.
*/
function getDataFromClient($clientid,$command,$data) {
$pdo = DbUtils::openDbAndReturnPdo();
$sql = "SELECT * FROM %clients% WHERE id=?";
$stmt = $pdo->prepare(DbUtils::substTableAlias($sql));
$stmt->execute(array($clientid));
if ($stmt->rowCount() > 0) {
$client =$stmt->fetchObject();
$clientname = $client->name;
$clienturl = $client->url . "/php/remoteaccess.php?command=$command";
$clientaccesscode = $client->remoteaccesscode;
$clientAuthUser = $client->basicauthuser;
$clientAuthPass = $client->basicauthpass;
}
$data = array_merge($data,array('remoteaccesscode' => "$clientaccesscode"));
$query = http_build_query($data);
$opts = array(
'http'=>array(
'header' => "Content-Type: application/x-www-form-urlencoded\r\n".
"Authorization: Basic " . base64_encode("$clientAuthUser:$clientAuthPass") .
"Content-Length: ".strlen($query)."\r\n".
"User-Agent:MyAgent/1.0\r\n",
'method' => 'POST',
'content' => $query
)
);
$context = stream_context_create($opts);
// Open the file using the HTTP headers set above
$file = file_get_contents($clienturl, false, $context);
echo $file;
}
?>

54
spider/php/dbutils.php Normal file
View File

@ -0,0 +1,54 @@
<?php
// Data base configuration and a bit more
require_once ('config.php');
define ('DB_CONFIG_TABLE', TAB_PREFIX . 'config');
class DbUtils {
/**
* Open a PDO connection to the database based on the config.php file that
* is written during the installation
*
* @return NULL|PDO: null if no connection could be established, otherwise the PDO instance
*/
public static function openDbAndReturnPdo() {
$dsn = 'mysql:host=' . MYSQL_HOST . ';dbname=' . MYSQL_DB;
$user = MYSQL_USER;
$password = MYSQL_PASSWORD;
$pdo = null;
try {
$pdo = new PDO($dsn, $user, $password);
$pdo ->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
}
catch (PDOException $e) {
return null;
}
return $pdo;
}
/*
* To use sql strings that are easy to read the table names are used
* without variables. But since the user can specify a prefix for all
* tables the substitution must be done somewhere. This is the function
* that replaces the %TABLE% by $prefix_table
*/
public static function substTableAlias($sqlString) {
return self::substTableAliasWithPrefix($sqlString, TAB_PREFIX);
}
/**
* Like substTableAlias, but can be used with a defined prefix
*
* @param unknown $sqlString
* @param unknown $prefix
* @return mixed
*/
public static function substTableAliasWithPrefix($sqlString,$prefix) {
$out = $sqlString;
$out = str_replace("%config%",$prefix . "config",$out);
$out = str_replace("%clients%",$prefix . "clients",$out);
return ($out);
}
}
?>

112
spider/php/generals.php Normal file
View File

@ -0,0 +1,112 @@
<?php
require_once ('config.php');
require_once ('database/database.php');
require_once ('globals.php');
require_once ('utils.php');
$command = $_GET["command"];
if ($command == 'isInstalled') {
isInstalled();
} else if ($command == 'getSpiderVersion') {
getSpiderVersion();
} else if ($command == 'isUserLoggedIn') {
isUserLoggedIn();
} else if ($command == 'login') {
login($_POST["authcode"]);
} else if ($command == 'logout') {
logout();
} else if ($command == 'setrate') {
setRate($_POST["rate"]);
} else if ($command == "getrate") {
getRate();
} else {
echo "unknown command";
}
function isInstalled() {
if(defined('INSTALLSTATUS')){
if (INSTALLSTATUS == 'new') {
echo json_encode("No");
} else {
echo json_encode("Yes");
}
}
}
function getSpiderVersion() {
$pdo = DbUtils::openDbAndReturnPdo();
if (is_null($pdo)) {
echo json_encode("");
return;
}
$sql = "SELECT setting FROM %config% WHERE name=?";
$stmt = $pdo->prepare(DbUtils::substTableAlias($sql));
$stmt->execute(array("version"));
if ($stmt->rowCount() > 0) {
echo json_encode($stmt->fetchObject()->setting);
} else {
echo json_encode("");
}
}
function setRate($rate) {
if (isUserLoggedInCore()) {
$pdo = DbUtils::openDbAndReturnPdo();
Database::setRefreshRate($pdo, null, $rate);
}
echo json_encode(array("status" => array(ACTION_OK,ACTION_OK_MSG)));
}
function getRate() {
if (isUserLoggedInCore()) {
$pdo = DbUtils::openDbAndReturnPdo();
$rate = Database::getConfigItem($pdo,'refreshrate');
echo json_encode(array("status" => array(ACTION_OK,ACTION_OK_MSG), "rate" => $rate));
}
}
function isUserLoggedIn() {
if (isUserLoggedInCore()) {
echo json_encode("YES");
} else {
echo json_encode("NO");
}
}
function login($password) {
$authenticated = false;
$pdo = DbUtils::openDbAndReturnPdo();
if (is_null($pdo)) {
echo json_encode(NO);
return;
}
$authCode = Database::getConfigItem($pdo, "accesspassword");
if ($password == $authCode) {
$authenticated = true;
}
if ($authenticated) {
if(session_id() == '') {
session_start();
}
$_SESSION['loggedin'] = true;
}
if ($authenticated) {
echo json_encode(YES);
} else {
echo json_encode(NO);
}
}
function logout() {
if(session_id() == '') {
session_start();
session_destroy();
}
echo json_encode(YES);
}
?>

16
spider/php/globals.php Normal file
View File

@ -0,0 +1,16 @@
<?php
define ( 'OK', "OK");
define ( 'YES', "Yes");
define ( 'NO', "No");
define ( 'ERROR', "Error");
define ('ACTION_OK',1);
define ('ACTION_OK_MSG',"Aktion war erfolgreich");
define ('ERROR_CLIENT_EXISTS',10);
define ('ERROR_CLIENT_EXISTS_MSG',"Client-Name oder -URL existiert bereits.");
define ('ERROR_CLIENT_DOES_NOT_EXIST',11);
define ('ERROR_CLIENT_DOES_NOT_EXIST_MSG',"Client existiert nicht.");
?>

15
spider/php/utils.php Normal file
View File

@ -0,0 +1,15 @@
<?php
function isUserLoggedInCore() {
if(session_id() == '') {
session_start();
}
if (!isset($_SESSION['loggedin']) || !$_SESSION['loggedin']) {
// no user logged in
return false;
} else {
return true;
}
}
?>

57
spider/styles/spider.css Normal file
View File

@ -0,0 +1,57 @@
@CHARSET "UTF-8";
table.gentable {
width: 100%;
display: block;
table-layout: fixed;
}
table.gentable th {
background:#7abe5f;
font-size:12pt;
border-bottom:1px solid rgba(255,255,255,.7);
-webkit-box-shadow:inset 0 1px 0 rgba(255,255,255,.2);
-moz-box-shadow:inset 0 1px 0 rgba(255,255,255,.2);
-o-box-shadow:inset 0 1px 0 rgba(255,255,255,.2);
box-shadow:inset 0 1px 0 rgba(255,255,255,.2);
padding:6px 10px;}
table.gentable td {
background:#eed33f;
font-size:10pt;
border-bottom:1px solid #fafafa;
border-bottom:1px solid rgba(255,255,255,.5);
padding:6px 10px;
color:rgba(0,0,0,255);}
table.gentable td.topic {
background:#eed33f;
font-size:10pt;
font-weight: bold;
font-style: italic;
border-bottom:1px solid #fafafa;
border-bottom:1px solid rgba(255,255,255,.5);
padding:6px 10px;
color:rgba(0,0,0,255);}
table.gentable th.complete {
background:#17370b;
color:rgba(255,255,255,0);}
table.gentable th.incomplete {
background:#9c9224;
color:rgba(0,0,0,255);}
table.gentable td.complete {
background:#78bb5e;
color:rgba(0,0,0,255);}
table.gentable td.incomplete {
background:#eed33f;
color:rgba(0,0,0,255);}
table.gentable tr:last-child td {
border-bottom:none;
}
table.gentable tr:hover td {
background-color: #ffaaff;
}

80
spider/utils.js Normal file
View File

@ -0,0 +1,80 @@
function doAjax(getOrPost,url,data,fct,errorMsg) {
$.ajax({ type: getOrPost,
url: url,
dataType: "json",
data: data,
async: false,
success : function(answer)
{
if (fct != null) {
fct(answer);
}
},
error: function( text ) {
if (errorMsg != null) {
alert( "Kommunikationsfehler zum Server: " + errorMsg);
} else {
// do nothing
}
}
});
}
function doAjaxTransmitValue(getOrPost,url,data,fct,aValue,errorMsg) {
$.ajax({ type: getOrPost,
url: url,
dataType: "json",
data: data,
async: false,
success : function(answer)
{
if (fct != null) {
fct(answer,aValue);
}
},
error: function( text ) {
if (errorMsg != null) {
alert( "Kommunikationsfehler zum Server: " + errorMsg);
} else {
// do nothing
}
}
});
}
function toHtml(text) {
if (typeof text === 'string') {
return (text.replace(/"/g, '&quot;').replace(/</g, "&lt;").replace(/>/g, "&gt;"));
} else {
return text;
}
}
function reloadPage(url) {
// use a timeout so that also Chrome does always a reload
setTimeout(function(){document.location.href = url},250);
}
/**
* Bind the logout button: log out the user and forward him to login page
*/
function bindLogout() {
$("#logoutbtn").off("click").on("click", function (e) {
e.stopImmediatePropagation();
e.preventDefault();
doAjax("POST", "php/generals.php?command=logout", null, handleLogout, null);
});
}
/**
* Logout button action completed -> forward to login page (index.html)
* @param status
*/
function handleLogout(status) {
// status is always OK -> just reload the page
reloadPage("index.html");
}
function insertSpiderVersion(version) {
$("#spiderversion").html(version);
}

Binary file not shown.

View File

@ -5,7 +5,7 @@
<meta http-equiv="content-type" content="text/html; charset=utf-8"> <meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta name="author" content="Stefan Pichel"> <meta name="author" content="Stefan Pichel">
<link rel="stylesheet" type="text/css" href="css/bestformat.css?v=1.2.18"> <link rel="stylesheet" type="text/css" href="css/bestformat.css?v=1.2.19">
<link rel="stylesheet" href="php/3rdparty/orderstyle/orderstyle.min.css" /> <link rel="stylesheet" href="php/3rdparty/orderstyle/orderstyle.min.css" />
<link rel="stylesheet" href="php/3rdparty/orderstyle/jquery.mobile.icons.min.css" /> <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

@ -1 +1 @@
.ordereditem-container{display:-webkit-flex;display:flex;-webkit-flex-direction:column;flex-direction:column;background-color:lightgrey}.ordereditem-sentcontainer{display:-webkit-flex;display:flex;-webkit-flex-direction:row;flex-direction:row;-webkit-flex-wrap:wrap;flex-wrap:wrap;background-color:lightgrey}.ordereditem-item-new{background-color:cornflowerblue;height:120px;margin:5px;overflow:hidden}.ordereditem-item-sent{background-color:lightsteelblue;height:120px;margin:5px;width:200px;color:black;box-shadow:10px 10px 5px #888;overflow:hidden}.ordereditem-item-sent>*{width:100%}.ordereditem-name{font-weight:bold}#ordereditemdlg{display:-webkit-flex;display:flex;-webkit-flex-flow:row wrap;flex-flow:row wrap;font-weight:bold;text-align:center;border:2px solid #73ad21;background-color:#ddd}#ordereditem-info{width:100%}#orderedcancelpanel{width:100%}#ordereditemdlg>*{padding:10px}#ordereditemcancel{width:140px;background-color:#aaa}#ordereditemremove{background-color:red;width:140px}#ordereditemreorder{width:140px} .ordereditem-container{display:-webkit-flex;display:flex;-webkit-flex-direction:column;flex-direction:column;background-color:lightgrey}.ordereditem-sentcontainer{display:-webkit-flex;display:flex;-webkit-flex-direction:row;flex-direction:row;-webkit-flex-wrap:wrap;flex-wrap:wrap;background-color:lightgrey}.ordereditem-item-new{background-color:cornflowerblue;height:120px;margin:5px;overflow:hidden}.ordereditem-item-sent{background-color:lightsteelblue;height:120px;margin:5px;width:200px;color:black;box-shadow:10px 10px 5px #888;overflow:hidden}.ordereditem-item-sent>*{width:100%}.ordereditem-name{font-weight:bold}.waitermsg{color:black;background-color:#f1a899;font-weight:normal}#ordereditemdlg{display:-webkit-flex;display:flex;-webkit-flex-flow:row wrap;flex-flow:row wrap;font-weight:bold;text-align:center;border:2px solid #73ad21;background-color:#ddd}#ordereditem-info{width:100%}#orderedcancelpanel{width:100%}#ordereditemdlg>*{padding:10px}#ordereditemcancel{width:140px;background-color:#aaa}#ordereditemremove{background-color:red;width:140px}#ordereditemreorder{width:140px}

View File

@ -1 +1 @@
html{overflow-y:scroll}.ospage{display:-webkit-flex;display:flex;-webkit-flex-flow:row wrap;flex-flow:row wrap;text-align:center;color:white}.ospage>*{padding:10px;flex:100%}.main{text-align:left;background:cornflowerblue;-webkit-flex:5;flex:5;-webkit-flex-flow:nowrap;flex-flow:nowrap}.header{background:black}.footer{display:-webkit-flex;display:flex;-webkit-justify-content:center;justify-content:center;-webkit-flex-wrap:row nowrap;flex-flow:row nowrap;background:black;-webkit-align-items:stretch;align-items:stretch}#loggedinuser{text-align:left;width:50%}#versioninfo{text-align:right;color:white;width:50%}.aside1{background:moccasin;color:black;width:0;-webkit-flex:2;flex:2}.aside2{background:violet;-webkit-flex:1;flex:1}@media all and (min-width:400px){.aside1{order:1}.main{order:2}.aside2{order:3}.ordereditem-sentcontainer{order:4}.footer{order:5}}.input100{width:100%;height:50px;font-weight:bold;text-align:center}.input90{width:89%;height:50px;font-weight:bold;text-align:center}.input50{width:49%;height:50px;font-weight:bold;text-align:center}.area10{width:9%;height:50px;text-align:center}.inputwhite[type="text"]{background-color:white}.inputwhite[type="submit"]{background-color:white}.inputgreen[type="text"]{background-color:#0f0}.inputgreen[type="submit"]{background-color:#0f0}.inputblue[type="text"]{background-color:#8ee5ee}.inputblue[type="submit"]{background-color:#8ee5ee}.infoarea{width:49%;background-color:#afa;color:black;font-weight:bold;font-size:20px;display:-webkit-flex;display:flex;-webkit-justify-content:center;justify-content:center;-webkit-align-items:center;align-items:center;border:2px solid red}.mainmenuchoice{list-style-type:none;padding:0;border:1px solid #ddd}.mainmenuitem{padding:8px 16px;border-bottom:1px solid #ddd;background-color:#fff6b5;height:40px;font-size:16px;font-weight:bold}.mainmenuitem:hover{background-color:#eed33f}.commentitem:last-child{border-bottom:0}.commentitem{padding:8px 16px;border-bottom:1px solid #ddd;background-color:#fff6b5;height:40px;font-size:16px;font-weight:bold}.commentitem:last-child{border-bottom:0}#loggedinuser{color:black}.buttonarea{box-shadow:10px 10px 5px #888} html{overflow-y:scroll}.ospage{display:-webkit-flex;display:flex;-webkit-flex-flow:row wrap;flex-flow:row wrap;text-align:center;color:white}.ospage>*{padding:10px;flex:100%}.main{text-align:left;background:cornflowerblue;-webkit-flex:5;flex:5;-webkit-flex-flow:nowrap;flex-flow:nowrap}.header{background:black}.footer{display:-webkit-flex;display:flex;-webkit-justify-content:center;justify-content:center;-webkit-flex-wrap:row nowrap;flex-flow:row nowrap;background:black;-webkit-align-items:stretch;align-items:stretch}#loggedinuser{text-align:left;width:50%}#versioninfo{text-align:right;color:white;width:50%}.aside1{background:moccasin;color:black;width:0;-webkit-flex:2;flex:2}.aside2{background:violet;-webkit-flex:1;flex:1}@media all and (min-width:400px){.aside1{order:1}.main{order:2}.aside2{order:3}.ordereditem-sentcontainer{order:4}.waitermsg{order:5}.footer{order:6}}.input100{width:100%;height:50px;font-weight:bold;text-align:center}.input90{width:89%;height:50px;font-weight:bold;text-align:center}.input50{width:49%;height:50px;font-weight:bold;text-align:center}.area10{width:9%;height:50px;text-align:center}.inputwhite[type="text"]{background-color:white}.inputwhite[type="submit"]{background-color:white}.inputgreen[type="text"]{background-color:#0f0}.inputgreen[type="submit"]{background-color:#0f0}.inputblue[type="text"]{background-color:#8ee5ee}.inputblue[type="submit"]{background-color:#8ee5ee}.infoarea{width:49%;background-color:#afa;color:black;font-weight:bold;font-size:20px;display:-webkit-flex;display:flex;-webkit-justify-content:center;justify-content:center;-webkit-align-items:center;align-items:center;border:2px solid red}.mainmenuchoice{list-style-type:none;padding:0;border:1px solid #ddd}.mainmenuitem{padding:8px 16px;border-bottom:1px solid #ddd;background-color:#fff6b5;height:40px;font-size:16px;font-weight:bold}.mainmenuitem:hover{background-color:#eed33f}.commentitem:last-child{border-bottom:0}.commentitem{padding:8px 16px;border-bottom:1px solid #ddd;background-color:#fff6b5;height:40px;font-size:16px;font-weight:bold}.commentitem:last-child{border-bottom:0}#loggedinuser{color:black}.buttonarea{box-shadow:10px 10px 5px #888}

View File

@ -1 +1 @@
.paypanel{display:-webkit-flex;display:flex;-webkit-justify-content:left;justify-content:left;-webkit-flex-wrap:row wrap;flex-flow:row wrap;background-color:lightgrey}.payitem{width:100px;height:100px;margin:10px;border-radius:25px;border:2px solid #73ad21;padding-top:20px;padding-left:20px;padding-bottom:0;padding-right:20px;color:black;font-weight:bold;text-align:center;font-size:12px;word-wrap:break-word;white-space:pre-line;overflow:hidden;display:-webkit-flex;display:flex;-webkit-justify-content:center;justify-content:center;-webkit-flex-wrap:row wrap;flex-flow:row wrap;box-shadow:10px 10px 5px #888}.paystillopen{background-color:#ff0}.payallaccounted{background-color:#ddd}#oben{color:black;font-weight:bold;font-size:20px;min-height:100px}#receiptpanel{position:relative;margin:10px auto;padding:0;width:100%;height:auto;border-collapse:collapse;background-color:#ddd;color:black;box-shadow:10px 10px 5px #888;border:2px solid #333}.payitem>*{flex:100%}.payitemmain{height:50px}.payitemaccounted{color:red;font-size:20px;font-weight:bold}.paymentitem{padding:8px 16px;border-bottom:1px solid #ddd;background-color:#ff9;height:40px;font-size:16px;font-weight:bold}.paymentitem:hover{padding:8px 16px;border-bottom:1px solid #ddd;background-color:#ff0;height:40px;font-size:16px;font-weight:bold}.paymentcancel{padding:8px 16px;border-bottom:1px solid #ddd;background-color:red;height:40px;font-size:16px;font-weight:bold}#paybuttonpanel{display:-webkit-flex;display:flex;-webkit-justify-content:center;justify-content:center;-webkit-flex-wrap:row nowrap;flex-flow:row nowrap}#paybuttonpanel>*{flex:100%}.btnswitchon{border:1px solid black;border-left:0;padding:.1em .3em;position:relative}.btnswitchon:before{display:block;content:".";color:transparent;font-size:0;border-left:5px solid green;height:100%;position:absolute;left:0;padding:1px 0;top:-1px;bottom:-1px}.btnswitchoff{border:1px solid black;border-left:0;padding:.1em .3em;position:relative}.btnswitchoff:before{display:block;content:".";color:transparent;font-size:0;border-left:5px solid red;height:100%;position:absolute;left:0;padding:1px 0;top:-1px;bottom:-1px} .paypanel{display:-webkit-flex;display:flex;-webkit-justify-content:left;justify-content:left;-webkit-flex-wrap:row wrap;flex-flow:row wrap;background-color:lightgrey}.payitem{width:100px;height:100px;margin:10px;border-radius:25px;border:2px solid #73ad21;padding-top:20px;padding-left:20px;padding-bottom:0;padding-right:20px;color:black;font-weight:bold;text-align:center;font-size:12px;word-wrap:break-word;white-space:pre-line;overflow:hidden;display:-webkit-flex;display:flex;-webkit-justify-content:center;justify-content:center;-webkit-flex-wrap:row wrap;flex-flow:row wrap;box-shadow:10px 10px 5px #888}.paystillopen{background-color:#ff0}.payallaccounted{background-color:#ddd}#oben{color:black;font-weight:bold;font-size:20px;min-height:100px}#receiptpanel{position:relative;margin:10px auto;padding:0;width:100%;height:auto;border-collapse:collapse;background-color:#ddd;color:black;box-shadow:10px 10px 5px #888;border:2px solid #333}.payitem>*{flex:100%}.payitemmain{height:50px}.payitemaccounted{color:red;font-size:20px;font-weight:bold}.paymentitem{padding:8px 16px;border-bottom:1px solid #ddd;background-color:#ff9;height:40px;font-size:16px;font-weight:bold}.paymentitem:hover{padding:8px 16px;border-bottom:1px solid #ddd;background-color:#ff0;height:40px;font-size:16px;font-weight:bold}.paymentcancel{padding:8px 16px;border-bottom:1px solid #ddd;background-color:red;height:40px;font-size:16px;font-weight:bold}#paybuttonpanel{display:-webkit-flex;display:flex;-webkit-justify-content:center;justify-content:center;-webkit-flex-wrap:row nowrap;flex-flow:row nowrap}#paybuttonpanel>*{flex:100%}.btnswitchon{border:1px solid black;border-left:0;padding:.1em .3em;position:relative}.btnswitchon:before{display:block;content:".";color:transparent;font-size:0;border-left:5px solid green;height:100%;position:absolute;left:0;padding:1px 0;top:-1px;bottom:-1px}.btnswitchoff{border:1px solid black;border-left:0;padding:.1em .3em;position:relative}.btnswitchoff:before{display:block;content:".";color:transparent;font-size:0;border-left:5px solid red;height:100%;position:absolute;left:0;padding:1px 0;top:-1px;bottom:-1px}.guestselectionbutton{padding:8px 16px;border-bottom:1px solid #ddd;background-color:#dd0;height:40px;font-size:16px;font-weight:bold;width:100%}.guestselectionlist{padding:8px 16px;border-bottom:1px solid #ddd;background-color:#4f4;height:40px;font-size:16px;font-weight:bold;width:100%}

View File

@ -4,7 +4,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="content-type" content="text/html; charset=utf-8"> <meta http-equiv="content-type" content="text/html; charset=utf-8">
<link rel="stylesheet" type="text/css" href="css/bestformat.css?v=1.2.18"> <link rel="stylesheet" type="text/css" href="css/bestformat.css?v=1.2.19">
<link rel="stylesheet" href="php/3rdparty/orderstyle/orderstyle.min.css" /> <link rel="stylesheet" href="php/3rdparty/orderstyle/orderstyle.min.css" />
<link rel="stylesheet" href="php/3rdparty/orderstyle/jquery.mobile.icons.min.css" /> <link rel="stylesheet" href="php/3rdparty/orderstyle/jquery.mobile.icons.min.css" />

View File

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

View File

@ -679,7 +679,7 @@ $(document).ready(function() {
<tr id=updateline> <tr id=updateline>
<td>&nbsp;</td> <td>&nbsp;</td>
<td align=center> <td align=center>
<button id="updatebtn">Update -> 1.2.18</button> <button id="updatebtn">Update -> 1.2.19</button>
</td> </td>
<td>&nbsp;</td> <td>&nbsp;</td>
</tr> </tr>

View File

@ -96,39 +96,6 @@ $ret = array("extensions_status" => $extensions_status, "missing_extensions" =>
echo json_encode($ret); echo json_encode($ret);
} }
private function getForeignKeyName($pdo,$fromtable,$totable,$dbname) {
$foreignKey = null;
try {
$sql = "SELECT constraint_name as foreignkey FROM information_schema.REFERENTIAL_CONSTRAINTS WHERE constraint_schema = '$dbname' AND table_name = '%$fromtable%' AND REFERENCED_TABLE_NAME='%$totable%'";
$stmt = $pdo->prepare($this->basedb->resolveTablenamesInSqlString($sql));
$stmt->execute();
$result = $stmt->fetchAll();
if (count($result) != 1) {
return null;
}
$foreignKey = $result[0]["foreignkey"];
} catch (Exception $e) {
return null;
}
return $foreignKey;
}
private function replaceForeignIdKey($pdo,$fromtable,$totable,$dbname,$foreignkeyname,$colname) {
$foreignkeyorig = $this->getForeignKeyName($pdo, $fromtable, $totable, $dbname);
if (!is_null($foreignkeyorig)) {
$this->execSql($pdo, "alter table %$fromtable% drop foreign key $foreignkeyorig");
$this->execSql($pdo, "ALTER TABLE %$fromtable% ADD CONSTRAINT $foreignkeyname FOREIGN KEY ($colname) REFERENCES %$totable%(id)");
}
}
private function replaceForeignKeysToBillAndClosing($pdo,$dbname) {
$this->replaceForeignIdKey($pdo, 'billproducts', 'bill', $dbname, 'billprodref', 'billid');
$this->replaceForeignIdKey($pdo, 'queue', 'bill', $dbname, 'queuebillref', 'billid');
$this->replaceForeignIdKey($pdo, 'bill', 'closing', $dbname, 'billclosingref', 'closingid');
$this->replaceForeignIdKey($pdo, 'bill', 'bill', $dbname, 'billbillref', 'ref');
}
function updateVersion($pdo,$version) { function updateVersion($pdo,$version) {
$setVersion = "update %config% set setting=? where name='version'"; $setVersion = "update %config% set setting=? where name='version'";
$stmt = $pdo->prepare($this->basedb->resolveTablenamesInSqlString($setVersion)); $stmt = $pdo->prepare($this->basedb->resolveTablenamesInSqlString($setVersion));
@ -1223,8 +1190,6 @@ return false;
DbUtils::overrulePrefix($prefix); DbUtils::overrulePrefix($prefix);
$this->replaceForeignKeysToBillAndClosing($pdo,$dbname);
$this->execSql($pdo, "ALTER TABLE %user% ADD right_closing INT (1) NULL AFTER right_products"); $this->execSql($pdo, "ALTER TABLE %user% ADD right_closing INT (1) NULL AFTER right_products");
$this->execSql($pdo, "ALTER TABLE %histuser% ADD right_closing INT (1) NULL AFTER right_products"); $this->execSql($pdo, "ALTER TABLE %histuser% ADD right_closing INT (1) NULL AFTER right_products");
$this->execSql($pdo, "UPDATE %user% SET right_closing=right_manager"); $this->execSql($pdo, "UPDATE %user% SET right_closing=right_manager");
@ -1639,6 +1604,45 @@ return false;
} }
} }
function updateUserTable1218_1219($prefix, $version, $dbname) {
$pdo = $this->pdo;
try {
if ($version != "1.2.18") {
$ret = $this->updateUserTable1217_1218($prefix, $version, $dbname);
if (!$ret) {
echo "Version update v1.2.17 to 1.2.18 not successful.";
return false;
}
}
DbUtils::overrulePrefix($prefix);
$sql = "INSERT INTO %payment% (id,name,name_en,name_esp) VALUES (?,?,?,?)";
$stmt = $pdo->prepare($this->basedb->resolveTablenamesInSqlString($sql));
$stmt->execute(array('7', 'Hotelzimmer','Hotel room','Habitación'));
$this->basedb->createHsinTable($pdo);
$this->basedb->createHsoutTable($pdo);
$sql = "ALTER TABLE %bill% ADD reservationid VARCHAR(30) NULL AFTER reason";
$stmt = $pdo->prepare(DbUtils::substTableAlias($sql));
$stmt->execute();
$sql = "ALTER TABLE %bill% ADD guestinfo VARCHAR(30) NULL AFTER reservationid";
$stmt = $pdo->prepare(DbUtils::substTableAlias($sql));
$stmt->execute();
$sql = "INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL,?,?)";
$stmt = $pdo->prepare($this->basedb->resolveTablenamesInSqlString($sql));
$stmt->execute(array('memorylimit','256'));
$this->updateVersion($pdo, '1.2.19');
return true;
} catch (PDOException $e) {
echo "Error in v1.2.18 to 1.2.19: $e";
return false;
}
}
function setVersion($prefix,$theVersion) { function setVersion($prefix,$theVersion) {
$pdo = $this->pdo; $pdo = $this->pdo;
try { try {
@ -1723,6 +1727,8 @@ $this->basedb->createLogoTable($pdo);
$this->basedb->createExtrasTable($pdo); $this->basedb->createExtrasTable($pdo);
$this->basedb->createExtrasprodsTable($pdo); $this->basedb->createExtrasprodsTable($pdo);
$this->basedb->createQueueExtrasTable($pdo); $this->basedb->createQueueExtrasTable($pdo);
$this->basedb->createHsinTable($pdo);
$this->basedb->createHsoutTable($pdo);
$rect = $this->getDefaultCustomRecTemplate(); $rect = $this->getDefaultCustomRecTemplate();
$foodtemplate = $this->getDefaultWorkTemplateFood(); $foodtemplate = $this->getDefaultWorkTemplateFood();
@ -1756,7 +1762,7 @@ $this->basedb->doSQL($pdo,"INSERT INTO `%config%` (`id` , `name`, `setting`) VAL
$this->basedb->doSQL($pdo,"INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'billlanguage', $billlanguage)"); $this->basedb->doSQL($pdo,"INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'billlanguage', $billlanguage)");
$this->basedb->doSQL($pdo,"INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'currency', '$currency')"); $this->basedb->doSQL($pdo,"INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'currency', '$currency')");
$this->basedb->doSQL($pdo,"INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'receiptfontsize', '12')"); $this->basedb->doSQL($pdo,"INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'receiptfontsize', '12')");
$this->basedb->doSQL($pdo,"INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'version', '1.2.18')"); $this->basedb->doSQL($pdo,"INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'version', '1.2.19')");
$this->basedb->doSQL($pdo,"INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'paymentconfig', '0')"); $this->basedb->doSQL($pdo,"INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'paymentconfig', '0')");
$this->basedb->doSQL($pdo,"INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'remoteaccesscode', null)"); $this->basedb->doSQL($pdo,"INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'remoteaccesscode', null)");
$this->basedb->doSQL($pdo,"INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'decpoint', '$decpoint')"); $this->basedb->doSQL($pdo,"INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'decpoint', '$decpoint')");
@ -1793,6 +1799,11 @@ $this->basedb->doSQL($pdo,"INSERT INTO `%config%` (`id` , `name`, `setting`) VAL
$this->basedb->doSQL($pdo,"INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'printandqueuejobs', '0')"); $this->basedb->doSQL($pdo,"INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'printandqueuejobs', '0')");
$this->basedb->doSQL($pdo,"INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'cashenabled', '1')"); $this->basedb->doSQL($pdo,"INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'cashenabled', '1')");
$this->basedb->doSQL($pdo,"INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'beepcooked', '0')"); $this->basedb->doSQL($pdo,"INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'beepcooked', '0')");
$this->basedb->doSQL($pdo,"INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'hotelinterface', '0')");
$this->basedb->doSQL($pdo,"INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'hsinfile', '')");
$this->basedb->doSQL($pdo,"INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'hsoutfile', '')");
$this->basedb->doSQL($pdo,"INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'hscurrency', 'EUR')");
$this->basedb->doSQL($pdo,"INSERT INTO `%config%` (`id` , `name`, `setting`) VALUES (NULL , 'memorylimit', '256')");
// prepare for later inconsistency check if version is obsolete // prepare for later inconsistency check if version is obsolete
date_default_timezone_set($timezone); date_default_timezone_set($timezone);
@ -1901,6 +1912,8 @@ $stmt = $pdo->prepare($this->basedb->resolveTablenamesInSqlString($sql));
$stmt->execute(array('5', 'Ueberweisung','Bank transfer','Transferencia')); $stmt->execute(array('5', 'Ueberweisung','Bank transfer','Transferencia'));
$stmt = $pdo->prepare($this->basedb->resolveTablenamesInSqlString($sql)); $stmt = $pdo->prepare($this->basedb->resolveTablenamesInSqlString($sql));
$stmt->execute(array('6', 'Lastschrift','Debit','Cargo en cuenta')); $stmt->execute(array('6', 'Lastschrift','Debit','Cargo en cuenta'));
$stmt = $pdo->prepare($this->basedb->resolveTablenamesInSqlString($sql));
$stmt->execute(array('7', 'Hotelzimmer','Hotel room','Habitación'));
} }
public function defineHistActions ($pdo) { public function defineHistActions ($pdo) {
@ -2128,7 +2141,7 @@ $zones[] = $timezone_identifiers[$i];
} }
echo json_encode($zones); echo json_encode($zones);
} else if ($command == 'update') { } else if ($command == 'update') {
$installerVersion = "1.2.18"; $installerVersion = "1.2.19";
$admin = new InstallAdmin(); $admin = new InstallAdmin();
$pdo = $admin->openDbAndReturnPdo($_POST['host'],$_POST['db'],$_POST['user'],$_POST['password']); $pdo = $admin->openDbAndReturnPdo($_POST['host'],$_POST['db'],$_POST['user'],$_POST['password']);
@ -2158,7 +2171,8 @@ $supportedVersions = array("1.0.22","1.0.23","1.0.24","1.0.25","1.0.26","1.0.27"
"1.0.40","1.0.41","1.0.42","1.0.43", "1.0.40","1.0.41","1.0.42","1.0.43",
"1.1.0","1.1.1","1.1.2","1.1.3","1.1.4","1.1.5","1.1.6","1.1.7","1.1.8", "1.1.9","1.1.10","1.1.11","1.1.12","1.1.13","1.1.14","1.1.15","1.1.16","1.1.17", "1.1.0","1.1.1","1.1.2","1.1.3","1.1.4","1.1.5","1.1.6","1.1.7","1.1.8", "1.1.9","1.1.10","1.1.11","1.1.12","1.1.13","1.1.14","1.1.15","1.1.16","1.1.17",
"1.1.18","1.1.19","1.1.20","1.1.21","1.1.22","1.1.23","1.1.24","1.1.25","1.1.26","1.1.27","1.1.28","1.1.29","1.1.30", "1.1.18","1.1.19","1.1.20","1.1.21","1.1.22","1.1.23","1.1.24","1.1.25","1.1.26","1.1.27","1.1.28","1.1.29","1.1.30",
"1.2.0","1.2.1","1.2.2", "1.2.3", "1.2.4","1.2.5","1.2.6","1.2.7","1.2.8","1.2.9","1.2.10","1.2.11","1.2.12","1.2.13","1.2.14","1.2.15","1.2.16","1.2.17" "1.2.0","1.2.1","1.2.2", "1.2.3", "1.2.4","1.2.5","1.2.6","1.2.7","1.2.8","1.2.9","1.2.10","1.2.11","1.2.12","1.2.13","1.2.14","1.2.15","1.2.16","1.2.17",
"1.2.18"
); );
if (!in_array($version, $supportedVersions)) { if (!in_array($version, $supportedVersions)) {
@ -2166,7 +2180,7 @@ echo json_encode("Quellversion nicht unterstützt");
return; return;
} }
$ret = $admin->updateUserTable1217_1218($_POST['prefix'], $version, $_POST['db']); $ret = $admin->updateUserTable1218_1219($_POST['prefix'], $version, $_POST['db']);
if(session_id() == '') { if(session_id() == '') {
session_start(); session_start();

View File

@ -5,7 +5,7 @@
<meta http-equiv="content-type" content="text/html; charset=utf-8"> <meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta name="author" content="Stefan Pichel"> <meta name="author" content="Stefan Pichel">
<link rel="stylesheet" type="text/css" href="css/bestformat.css?v=1.2.18"> <link rel="stylesheet" type="text/css" href="css/bestformat.css?v=1.2.19">
<link rel="stylesheet" href="php/3rdparty/orderstyle/orderstyle.min.css" /> <link rel="stylesheet" href="php/3rdparty/orderstyle/orderstyle.min.css" />
<link rel="stylesheet" href="php/3rdparty/orderstyle/jquery.mobile.icons.min.css" /> <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 http-equiv="content-type" content="text/html; charset=utf-8">
<meta name="author" content="Stefan Pichel"> <meta name="author" content="Stefan Pichel">
<link rel="stylesheet" type="text/css" href="css/bestformat.css?v=1.2.18"> <link rel="stylesheet" type="text/css" href="css/bestformat.css?v=1.2.19">
<link rel="stylesheet" href="php/3rdparty/orderstyle/orderstyle.min.css" /> <link rel="stylesheet" href="php/3rdparty/orderstyle/orderstyle.min.css" />
<link rel="stylesheet" href="php/3rdparty/orderstyle/jquery.mobile.icons.min.css" /> <link rel="stylesheet" href="php/3rdparty/orderstyle/jquery.mobile.icons.min.css" />
@ -256,6 +256,7 @@ var MAN_SMTPUSER = ["SMTP-Benutzername","SMTP User name","SMTP usario"];
var MAN_SMTPPASS = ["SMTP-Passwort","SMTP password","SMTP contraseña"]; var MAN_SMTPPASS = ["SMTP-Passwort","SMTP password","SMTP contraseña"];
var MAN_SMTPSECURE = ["SMTP-Protokoll","SMTP Protocol","SMTP Seguridad"]; var MAN_SMTPSECURE = ["SMTP-Protokoll","SMTP Protocol","SMTP Seguridad"];
var MAN_SMTPPORT = ["SMTP-Port","SMTP Port","SMTP Port"]; var MAN_SMTPPORT = ["SMTP-Port","SMTP Port","SMTP Port"];
var MAN_MEMORYLIMIT = ["PHP Memory Limit (MB)","PHP Memory Limit (MB)","PHP Memory Limit (MB)"];
var MAN_WEBIMPRESSUM = ["Webimpressum","Web company info","www café info"]; var MAN_WEBIMPRESSUM = ["Webimpressum","Web company info","www café info"];
var MAN_TAX_ASSIGN = ["Umsatzsteuer-Zuweisung","Taxes assigment","Asignar impuestos"]; var MAN_TAX_ASSIGN = ["Umsatzsteuer-Zuweisung","Taxes assigment","Asignar impuestos"];
var MAN_TAX_ASS_DESC = ["An dieser Stelle können pauschal zwei unterschiedliche Steuersätze den Speisen und den Getränken zugewiesen werden. Das ist für die Nutzung der Software in Österreich interessant. <b>Die Zuweisungen wirken sich nur im Betriebsmodus 'Österreich' aus!</b></b>", var MAN_TAX_ASS_DESC = ["An dieser Stelle können pauschal zwei unterschiedliche Steuersätze den Speisen und den Getränken zugewiesen werden. Das ist für die Nutzung der Software in Österreich interessant. <b>Die Zuweisungen wirken sich nur im Betriebsmodus 'Österreich' aus!</b></b>",
@ -312,8 +313,13 @@ var MAN_BEEP_COOKED = ["Signalton, wenn neues Produkt serviert werden kann (expe
var MAN_SPECIAL_SETTINGS_TXT = ["Einstellungen für spezielle Abläufe:","Settings for special workflows:","Configuración para workflows muy escpeciales:"]; var MAN_SPECIAL_SETTINGS_TXT = ["Einstellungen für spezielle Abläufe:","Settings for special workflows:","Configuración para workflows muy escpeciales:"];
var MAN_ROOMCHANGE_WARNING = ["Alten Raumplan löschen und neuen festlegen? Bestellungen offener Tische gehen verloren!","Replace room map? Orders of open tables will be lost!","Sustituir mapa de mesas? Orders de mesas abiertas van a ser borradas!"]; var MAN_ROOMCHANGE_WARNING = ["Alten Raumplan löschen und neuen festlegen? Bestellungen offener Tische gehen verloren!","Replace room map? Orders of open tables will be lost!","Sustituir mapa de mesas? Orders de mesas abiertas van a ser borradas!"];
var MAN_HOTELINTERFACE = ["Anbindung Hotelsoftware","Interface hotel software","Conección programa de hotel"];
var MAN_HSINFILE = ["HS/3 Datei HS3CASH.IN","HS/3 file HS3CASH.IN","HS/3 file HS3CASH.IN"];
var MAN_HSOUTFILE = ["HS/3 Datei HS3CASH.OUT","HS/3 file HS3CASH.OUT","HS/3 file HS3CASH.OUT"];
var MAN_HSCURRENCY = ["HS/3 Währungsangabe","HS/3 Currency","HS/3 Moneda"];
var lang = 0; 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]; 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];
var numberOfClosings = 0; var numberOfClosings = 0;
@ -372,7 +378,13 @@ var generalValuesSettings = [
["paydeskid",MAN_PAYDESKID[lang],"i",0,""], ["paydeskid",MAN_PAYDESKID[lang],"i",0,""],
["aeskey",MAN_AESKEY[lang],"i",0,""], ["aeskey",MAN_AESKEY[lang],"i",0,""],
["certificatesn",MAN_CERTIFICATE_SN[lang],"i",0,""] ["certificatesn",MAN_CERTIFICATE_SN[lang],"i",0,""],
["hotelinterface",MAN_HOTELINTERFACE[lang],"s",22],
["hsinfile",MAN_HSINFILE[lang],"i",0],
["hsoutfile",MAN_HSOUTFILE[lang],"i",0],
["hscurrency",MAN_HSCURRENCY[lang],"i",0],
["memorylimit",MAN_MEMORYLIMIT[lang],"i",0,""]
]; ];
var predef = ""; var predef = "";
@ -425,6 +437,8 @@ function setLanguage(l) {
$("#smtppasstxt").html(MAN_SMTPPASS[l]); $("#smtppasstxt").html(MAN_SMTPPASS[l]);
$("#smtpporttxt").html(MAN_SMTPPORT[l]); $("#smtpporttxt").html(MAN_SMTPPORT[l]);
$("#memorylimittxt").html(MAN_MEMORYLIMIT[l]);
$("#paydeskidtxt").html(MAN_PAYDESKID[l]); $("#paydeskidtxt").html(MAN_PAYDESKID[l]);
$("#austriahint").html(MAN_AUSTRIA_INCOMPLETE[l]); $("#austriahint").html(MAN_AUSTRIA_INCOMPLETE[l]);
$("#digigopaysetreadyhint").html("<p style='padding-left: 50px;padding-right: 50px;'><i>" + MAN_DIGI_GOPAY_DESCR[l] + "</i></p>"); $("#digigopaysetreadyhint").html("<p style='padding-left: 50px;padding-right: 50px;'><i>" + MAN_DIGI_GOPAY_DESCR[l] + "</i></p>");
@ -484,6 +498,9 @@ function setLanguage(l) {
$("#specialsettingssectiontxt").html(MAN_SPECIAL_SETTINGS_TXT[l]); $("#specialsettingssectiontxt").html(MAN_SPECIAL_SETTINGS_TXT[l]);
$("#printandqueuehint").html(MAN_PRINT_AND_QUEUE_HINT[l]); $("#printandqueuehint").html(MAN_PRINT_AND_QUEUE_HINT[l]);
$("#cashhint").html(MAN_CASH_HINT[l]); $("#cashhint").html(MAN_CASH_HINT[l]);
$("#hsinfiletxt").html(MAN_HSINFILE[l]);
$("#hsoutfiletxt").html(MAN_HSOUTFILE[l]);
$("#hscurrencytxt").html(MAN_HSCURRENCY[l]);
} }
function createMonthSelection(label) { function createMonthSelection(label) {
@ -609,6 +626,10 @@ function insertGeneralConfigItems(configResult) {
$("#cancelunpaidcode").val(values.cancelunpaidcode); $("#cancelunpaidcode").val(values.cancelunpaidcode);
$("#hsinfile").val(values.hsinfile);
$("#hsoutfile").val(values.hsoutfile);
$("#hscurrency").val(values.hscurrency);
generalVals[5] = values.smtpauth; generalVals[5] = values.smtpauth;
generalVals[6] = values.smtpsecure; generalVals[6] = values.smtpsecure;
generalVals[7] = values.bigfontworkreceipt; generalVals[7] = values.bigfontworkreceipt;
@ -629,6 +650,7 @@ function insertGeneralConfigItems(configResult) {
generalVals[19] = values.printandqueuejobs; generalVals[19] = values.printandqueuejobs;
generalVals[20] = values.cashenabled; generalVals[20] = values.cashenabled;
generalVals[21] = values.beepcooked; generalVals[21] = values.beepcooked;
generalVals[22] = values.hotelinterface;
$("#smtphost").val(values.smtphost); $("#smtphost").val(values.smtphost);
$("#partOfSmtpauth").html(createSMTPAuth(values.smtpauth)); $("#partOfSmtpauth").html(createSMTPAuth(values.smtpauth));
@ -637,10 +659,14 @@ function insertGeneralConfigItems(configResult) {
$("#partOfSmtpsecure").html(createSMTPSecure(values.smtpsecure)); $("#partOfSmtpsecure").html(createSMTPSecure(values.smtpsecure));
$("#smtpport").val(values.smtpport); $("#smtpport").val(values.smtpport);
$("#memorylimit").val(values.memorylimit);
$("#paydeskid").val(values.paydeskid); $("#paydeskid").val(values.paydeskid);
$("#aeskey").val(values.aeskey); $("#aeskey").val(values.aeskey);
$("#certificatesn").val(values.certificatesn); $("#certificatesn").val(values.certificatesn);
$("#partOfHotelInterface").html(createHotelInterfacePart(values.hotelinterface));
$("#configpart").trigger("create"); $("#configpart").trigger("create");
} else { } else {
setTimeout(function(){document.location.href = "index.html"},250); // not logged in setTimeout(function(){document.location.href = "index.html"},250); // not logged in
@ -891,6 +917,20 @@ function createBillLanguagePart(language) {
html += '</select></div>'; html += '</select></div>';
return html; return html;
} }
function createHotelInterfacePart(hotelinterface) {
var html = '<div class="ui-field-contain">';
html += '<label for="hotelinterface">' + MAN_HOTELINTERFACE[lang] + ':</label>';
html += '<select name="hotelinterface" id="hotelinterface" data-theme="e">';
if (hotelinterface == '0') {
html += '<option value="0" selected>-</option>';
html += '<option value="1">HS/3 Standardinterface</option>';
} else if (hotelinterface == '1'){
html += '<option value="0">-</option>';
html += '<option value="1" selected>HS/3 Standardinterface</option>';
}
html += '</select></div>';
return html;
}
function changeConfig(changedEntries) { function changeConfig(changedEntries) {
doAjax("POST","php/contenthandler.php?module=admin&command=changeConfig",{changed:changedEntries},reactOnConfigChange,"Fehler"); doAjax("POST","php/contenthandler.php?module=admin&command=changeConfig",{changed:changedEntries},reactOnConfigChange,"Fehler");
@ -1306,6 +1346,7 @@ function binding() {
setVisibilityOfAustriaButtons(); setVisibilityOfAustriaButtons();
setVisibilityDueToWorkflow(); setVisibilityDueToWorkflow();
setVisibilityDueToPrintType(); setVisibilityDueToPrintType();
setVisibilityHs3DueToHotelInterface();
}); });
bindSelectionsWithActions(); bindSelectionsWithActions();
@ -1340,6 +1381,16 @@ function bindSelectionsWithActions() {
$("#configpart").trigger("create"); $("#configpart").trigger("create");
bindSelectionsWithActions(); bindSelectionsWithActions();
}); });
$("#hotelinterface").off("change").on("change", function (e) {
e.stopImmediatePropagation();
e.preventDefault();
var newval = $("#hotelinterface").find(":selected").val();
$("#partOfHotelInterface").html(createHotelInterfacePart(newval));
setVisibilityHs3DueToHotelInterface();
$("#configpart").trigger("create");
bindSelectionsWithActions();
});
} }
function setVisibilityOfAustriaButtons() { function setVisibilityOfAustriaButtons() {
@ -1367,7 +1418,6 @@ function setVisibilityDueToWorkflow() {
} }
function setVisibilityDueToPrintType() { function setVisibilityDueToPrintType() {
// partAddrecPrinterIfServerPrint
var payprinttype = $("#payprinttype").find(":selected").val(); var payprinttype = $("#payprinttype").find(":selected").val();
if (payprinttype == 2) { if (payprinttype == 2) {
$("#partAddrecPrinterIfServerPrint").show(); $("#partAddrecPrinterIfServerPrint").show();
@ -1376,6 +1426,15 @@ function setVisibilityDueToPrintType() {
} }
} }
function setVisibilityHs3DueToHotelInterface() {
var hotelinterface = $("#hotelinterface").find(":selected").val();
if (hotelinterface == 1) {
$("#hs3area").show();
} else {
$("#hs3area").hide();
}
}
function confirmMsg (result) { function confirmMsg (result) {
if (result.status != 'OK') { if (result.status != 'OK') {
var code = result.code; var code = result.code;
@ -2413,11 +2472,11 @@ $(document).on("pageinit", "#admin-page", function () {
</div> </div>
<div id=taxusage></div> <div id=taxusage></div>
<div data-role="fieldcontain"> <div data-role="fieldcontain">
<label for="stornocode">Stornocode:</label> <label for="stornocode">Stornocode (Bons):</label>
<input type="password" value="" data-mini="true" id="stornocode" class="genConfigEl"/> <input type="password" value="" data-mini="true" id="stornocode" class="genConfigEl"/>
</div> </div>
<div data-role="fieldcontain"> <div data-role="fieldcontain">
<label for="cancelunpaidcode">Stornocode unbez. Bestellungen:</label> <label for="cancelunpaidcode">Stornocode (unbez. Bestellungen):</label>
<input type="password" value="" data-mini="true" id="cancelunpaidcode" class="genConfigEl"/> <input type="password" value="" data-mini="true" id="cancelunpaidcode" class="genConfigEl"/>
</div> </div>
<div data-role="fieldcontain"> <div data-role="fieldcontain">
@ -2530,7 +2589,26 @@ $(document).on("pageinit", "#admin-page", function () {
<div id="partOfDiscount2"></div> <div id="partOfDiscount2"></div>
<div id="partOfDiscount3"></div> <div id="partOfDiscount3"></div>
<div id="partOfHotelInterface"></div>
<div id="hs3area">
<div data-role="fieldcontain">
<label for="hsinfile"><span id="hsinfiletxt">HS/3 CASH.IN:</span></label>
<input type="text" value="" data-mini="true" placeholder="c:\\HS3CASH.IN" id="hsinfile" data-theme="c" class="genConfigEl"/>
</div>
<div data-role="fieldcontain">
<label for="hsoutfile"><span id="hsinfiletxt">HS/3 CASH.OUT:</span></label>
<input type="text" value="" data-mini="true" placeholder="c:\\HS3CASH.OUT" id="hsoutfile" data-theme="c" class="genConfigEl"/>
</div>
<div data-role="fieldcontain">
<label for="hscurrency"><span id="hsinfiletxt">HS/3 Währung:</span></label>
<input type="text" value="" data-mini="true" placeholder="EUR" id="hscurrency" data-theme="c" class="genConfigEl"/>
</div>
</div>
<div data-role="fieldcontain">
<label for="memorylimit"><span id="memorylimittxt">PHP Memory Limit:</span></label>
<input type="text" value="" data-mini="true" placeholder="password" id="memorylimit" data-theme="c" class="genConfigEl"/>
</div>
<div id="partOfAustria"></div> <div id="partOfAustria"></div>

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/sorter.php');
require_once ('utilities/Logger.php'); require_once ('utilities/Logger.php');
require_once ('utilities/Emailer.php'); require_once ('utilities/Emailer.php');
require_once ('hotelinterface.php');
class Admin { class Admin {
var $dbutils; var $dbutils;
@ -74,7 +75,8 @@ class Admin {
"getApplyExtrasBtnPos" => array("loggedin" => 1, "isadmin" => 0, "rights" => null), "getApplyExtrasBtnPos" => array("loggedin" => 1, "isadmin" => 0, "rights" => null),
"isInstalled" => array("loggedin" => 0, "isadmin" => 0, "rights" => null), "isInstalled" => array("loggedin" => 0, "isadmin" => 0, "rights" => null),
"isPrinterServerActive" => array("loggedin" => 1, "isadmin" => 0, "rights" => null) "isPrinterServerActive" => array("loggedin" => 1, "isadmin" => 0, "rights" => null),
"getWaiterMessage" => array("loggedin" => 1, "isadmin" => 0, "rights" => null)
); );
@ -266,6 +268,8 @@ class Admin {
$this->isInstalled(); $this->isInstalled();
} else if ($command == 'isPrinterServerActive') { } else if ($command == 'isPrinterServerActive') {
$this->isPrinterServerActive(); $this->isPrinterServerActive();
} else if ($command == 'getWaiterMessage') {
$this->getWaiterMessage();
} }
else { else {
echo "Command not supported."; echo "Command not supported.";
@ -289,11 +293,15 @@ class Admin {
} }
private function isPrinterServerActive() { private function isPrinterServerActive() {
$pdo = DbUtils::openDbAndReturnPdoStatic();
Hotelinterface::hs3sync($pdo);
$TIMEOUT = 20; $TIMEOUT = 20;
$active = json_encode(array("status" => "OK","msg" => 1)); $active = json_encode(array("status" => "OK","msg" => 1));
$notActive = json_encode(array("status" => "OK","msg" => 0)); $notActive = json_encode(array("status" => "OK","msg" => 0));
// check printmode // check printmode
$pdo = DbUtils::openDbAndReturnPdoStatic();
$printMode = CommonUtils::getConfigValue($pdo, 'payprinttype', "s"); $printMode = CommonUtils::getConfigValue($pdo, 'payprinttype', "s");
if ($printMode != "s") { if ($printMode != "s") {
echo $active; echo $active;
@ -790,6 +798,10 @@ class Admin {
$emailbadrating = CommonUtils::getConfigValue($pdo,"emailbadrating",""); $emailbadrating = CommonUtils::getConfigValue($pdo,"emailbadrating","");
$emailratingcontact = CommonUtils::getConfigValue($pdo,"emailratingcontact",""); $emailratingcontact = CommonUtils::getConfigValue($pdo,"emailratingcontact","");
$billlanguage = CommonUtils::getConfigValue($pdo,"billlanguage",null); $billlanguage = CommonUtils::getConfigValue($pdo,"billlanguage",null);
$hotelinterface = CommonUtils::getConfigValue($pdo,"hotelinterface",0);
$hsinfile = CommonUtils::getConfigValue($pdo,"hsinfile",null);
$hsoutfile = CommonUtils::getConfigValue($pdo,"hsoutfile",null);
$hscurrency = CommonUtils::getConfigValue($pdo,"hscurrency",null);
$currency = CommonUtils::getConfigValue($pdo,"currency",null); $currency = CommonUtils::getConfigValue($pdo,"currency",null);
$receiptfontsize = CommonUtils::getConfigValue($pdo,"receiptfontsize",null); $receiptfontsize = CommonUtils::getConfigValue($pdo,"receiptfontsize",null);
$reservationnote = CommonUtils::getConfigValue($pdo,"reservationnote",null); $reservationnote = CommonUtils::getConfigValue($pdo,"reservationnote",null);
@ -816,6 +828,8 @@ class Admin {
$smtpport = CommonUtils::getConfigValue($pdo,"smtpport",""); $smtpport = CommonUtils::getConfigValue($pdo,"smtpport","");
} }
$memorylimit = CommonUtils::getConfigValue($pdo,"memorylimit",256);
$paydeskid = CommonUtils::getConfigValue($pdo,"paydeskid",""); $paydeskid = CommonUtils::getConfigValue($pdo,"paydeskid","");
$aeskey = CommonUtils::getConfigValue($pdo,"aeskey",""); $aeskey = CommonUtils::getConfigValue($pdo,"aeskey","");
$certificatesn = CommonUtils::getConfigValue($pdo,"certificatesn",""); $certificatesn = CommonUtils::getConfigValue($pdo,"certificatesn","");
@ -836,6 +850,7 @@ class Admin {
$retVal = array("companyinfo" => $companyInfo, "rectemplate" => $rectemplate, "foodtemplate" => $foodtemplate, "drinktemplate" => $drinktemplate, $retVal = array("companyinfo" => $companyInfo, "rectemplate" => $rectemplate, "foodtemplate" => $foodtemplate, "drinktemplate" => $drinktemplate,
"version" => $version, "decpoint" => $decpoint, "version" => $version, "decpoint" => $decpoint,
"serverurl" => $serverurl, "email" => $email, "receiveremail" => $receiveremail, "billlanguage" => $billlanguage, "serverurl" => $serverurl, "email" => $email, "receiveremail" => $receiveremail, "billlanguage" => $billlanguage,
"hotelinterface" => $hotelinterface, "hsinfile" => $hsinfile, "hsoutfile" => $hsoutfile, "hscurrency" => $hscurrency,
"payprinttype" => $payprinttype, "tax" => $tax, "togotax" => $togotax, "currency" => $currency, "payprinttype" => $payprinttype, "tax" => $tax, "togotax" => $togotax, "currency" => $currency,
"taxaustrianormal" => $taxaustrianormal, "taxaustriaerm1" => $taxaustriaerm1, "taxaustriaerm2" => $taxaustriaerm2, "taxaustriaspecial" => $taxaustriaspecial, "taxaustrianormal" => $taxaustrianormal, "taxaustriaerm1" => $taxaustriaerm1, "taxaustriaerm2" => $taxaustriaerm2, "taxaustriaspecial" => $taxaustriaspecial,
"userlanguage" => $userlang, "receiptprinter" => $receiptprinter, "userlanguage" => $userlang, "receiptprinter" => $receiptprinter,
@ -846,7 +861,7 @@ class Admin {
"smtphost" => $smtphost,"smtpauth" => $smtpauth,"smtpuser" => $smtpuser,"smtppass" => $smtppass,"smtpsecure" => $smtpsecure,"smtpport" => $smtpport, "smtphost" => $smtphost,"smtpauth" => $smtpauth,"smtpuser" => $smtpuser,"smtppass" => $smtppass,"smtpsecure" => $smtpsecure,"smtpport" => $smtpport,
"webimpressum" => $webimpressum, "cancelunpaidcode" => $cancelunpaidcode, "discount1" => $discount1,"discount2" => $discount2,"discount3" => $discount3, "webimpressum" => $webimpressum, "cancelunpaidcode" => $cancelunpaidcode, "discount1" => $discount1,"discount2" => $discount2,"discount3" => $discount3,
"austria" => $austria, "digigopaysetready" => $digigopaysetready, "waitergopayprint" => $waitergopayprint, "oneprodworkreceipts" => $oneprodworkreceipts, "austria" => $austria, "digigopaysetready" => $digigopaysetready, "waitergopayprint" => $waitergopayprint, "oneprodworkreceipts" => $oneprodworkreceipts,
"digiprintwork" => $digiprintwork, "digiprintwork" => $digiprintwork, "memorylimit" => $memorylimit,
"paydeskid" => $paydeskid, "aeskey" => $aeskey, "certificatesn" => $certificatesn, "addreceipttoprinter" => $addreceipttoprinter, "paydeskid" => $paydeskid, "aeskey" => $aeskey, "certificatesn" => $certificatesn, "addreceipttoprinter" => $addreceipttoprinter,
"printandqueuejobs" => $printandqueuejobs, "cashenabled" => $cashenabled, "beepcooked" => $beepcooked "printandqueuejobs" => $printandqueuejobs, "cashenabled" => $cashenabled, "beepcooked" => $beepcooked
); );
@ -940,7 +955,7 @@ class Admin {
$view = "preferences.html"; $view = "preferences.html";
} }
echo json_encode($view . "?v=1.2.18"); echo json_encode($view . "?v=1.2.19");
} }
} }
@ -1146,24 +1161,24 @@ class Admin {
if (!self::isOnlyRatingUser($rights, $right_rating, true)) { if (!self::isOnlyRatingUser($rights, $right_rating, true)) {
if ($_SESSION['modus'] == 0) { if ($_SESSION['modus'] == 0) {
if ($_SESSION['right_waiter']) { $mainMenu[] = array("name" => $waitertxt[$lang], "link" => "waiter.html?v=1.2.18"); }; if ($_SESSION['right_waiter']) { $mainMenu[] = array("name" => $waitertxt[$lang], "link" => "waiter.html?v=1.2.19"); };
} else { } else {
if ($_SESSION['right_waiter']) { $mainMenu[] = array("name" => $waiterdesktxt[$lang], "link" => "waiterdesktop.php?v=1.2.18"); }; if ($_SESSION['right_waiter']) { $mainMenu[] = array("name" => $waiterdesktxt[$lang], "link" => "waiterdesktop.php?v=1.2.19"); };
} }
if ($_SESSION['right_kitchen']) { $mainMenu[] = array("name" => $kitchentxt[$lang], "link" => "kitchen.html?v=1.2.18"); }; if ($_SESSION['right_kitchen']) { $mainMenu[] = array("name" => $kitchentxt[$lang], "link" => "kitchen.html?v=1.2.19"); };
if ($_SESSION['right_bar']) { $mainMenu[] = array("name" => "Bar", "link" => "bar.html?v=1.2.18"); }; if ($_SESSION['right_bar']) { $mainMenu[] = array("name" => "Bar", "link" => "bar.html?v=1.2.19"); };
if ($_SESSION['right_supply']) { $mainMenu[] = array("name" => $supplytxt[$lang], "link" => "supplydesk.html?v=1.2.18"); }; if ($_SESSION['right_supply']) { $mainMenu[] = array("name" => $supplytxt[$lang], "link" => "supplydesk.html?v=1.2.19"); };
if ($_SESSION['modus'] == 0) { if ($_SESSION['modus'] == 0) {
if ($_SESSION['right_paydesk']) { $mainMenu[] = array("name" => $paydesktxt[$lang], "link" => "paydesk.html?v=1.2.18"); }; if ($_SESSION['right_paydesk']) { $mainMenu[] = array("name" => $paydesktxt[$lang], "link" => "paydesk.html?v=1.2.19"); };
} }
if ($_SESSION['right_statistics']) { $mainMenu[] = array("name" => $stattxt[$lang], "link" => "reports.html?v=1.2.18"); }; if ($_SESSION['right_statistics']) { $mainMenu[] = array("name" => $stattxt[$lang], "link" => "reports.html?v=1.2.19"); };
if ($_SESSION['right_bill']) { $mainMenu[] = array("name" => $bontxt[$lang], "link" => "bill.html?v=1.2.18"); }; if ($_SESSION['right_bill']) { $mainMenu[] = array("name" => $bontxt[$lang], "link" => "bill.html?v=1.2.19"); };
if ($_SESSION['right_products']) { $mainMenu[] = array("name" => $prodtxt[$lang], "link" => "products.html?v=1.2.18"); }; if ($_SESSION['right_products']) { $mainMenu[] = array("name" => $prodtxt[$lang], "link" => "products.html?v=1.2.19"); };
if ($_SESSION['right_reservation']) { $mainMenu[] = array("name" => $restxt[$lang], "link" => "reservation.html?v=1.2.18"); }; if ($_SESSION['right_reservation']) { $mainMenu[] = array("name" => $restxt[$lang], "link" => "reservation.html?v=1.2.19"); };
if ($_SESSION['right_rating']) { $mainMenu[] = array("name" => $ratingtxt[$lang], "link" => "rating.html?v=1.2.18"); }; if ($_SESSION['right_rating']) { $mainMenu[] = array("name" => $ratingtxt[$lang], "link" => "rating.html?v=1.2.19"); };
if ($_SESSION['right_manager'] || $_SESSION['is_admin'] || $_SESSION['right_closing']) { $mainMenu[] = array("name" => $admintxt[$lang], "link" => "manager.html?v=1.2.18"); }; if ($_SESSION['right_manager'] || $_SESSION['is_admin'] || $_SESSION['right_closing']) { $mainMenu[] = array("name" => $admintxt[$lang], "link" => "manager.html?v=1.2.19"); };
$mainMenu[] = array("name" => $settingtxt[$lang], "link" => "preferences.html?v=1.2.18"); $mainMenu[] = array("name" => $settingtxt[$lang], "link" => "preferences.html?v=1.2.19");
$mainMenu[] = array("name" => "Feedback", "link" => "feedback.html?v=1.2.18"); $mainMenu[] = array("name" => "Feedback", "link" => "feedback.html?v=1.2.19");
} }
$mainMenu[] = array("name" => $logout[$lang], "link" => "logout.php"); $mainMenu[] = array("name" => $logout[$lang], "link" => "logout.php");
@ -1172,7 +1187,7 @@ class Admin {
$waiterMessage = $this->getMessage(null, "waitermessage"); $waiterMessage = $this->getMessage(null, "waitermessage");
} }
// CAUTION: change version also in config.txt!!! // CAUTION: change version also in config.txt!!!
$mainMenuAndVersion = array ("version" => "OrderSprinter 1.2.18", $mainMenuAndVersion = array ("version" => "OrderSprinter 1.2.19",
"user" => $currentUser, "user" => $currentUser,
"menu" => $mainMenu, "menu" => $mainMenu,
"waitermessage" => $waiterMessage, "waitermessage" => $waiterMessage,
@ -1181,6 +1196,31 @@ class Admin {
return($mainMenuAndVersion); return($mainMenuAndVersion);
} }
private function getWaiterMessage() {
try {
$pdo = DbUtils::openDbAndReturnPdoStatic();
$waiterMessage = $this->getMessage(null, "waitermessage");
echo json_encode(array("status" => "OK","msg" => $waiterMessage));
} catch (Exception $e) {
echo json_encode(array("status" => "ERROR","msg" => "Error: $e"));
return;
}
}
private function getHotelInfo($pdo) {
try {
$hotelinterface = CommonUtils::getConfigValue($pdo, "hotelinterface", 0);
$guests = array();
if ($hotelinterface == 1) {
$sql = "SELECT reservationid,object,guest FROM %hsout%";
$guests = CommonUtils::fetchSqlAll($pdo, $sql, null);
}
return(array("status" => "OK","hotelinterface" => $hotelinterface,"guests" => $guests));
} catch (Exception $e) {
return(array("status" => "ERROR","hotelinterface" => 0,"guests" => array()));
}
}
function getUserList() { function getUserList() {
$pdo = DbUtils::openDbAndReturnPdoStatic(); $pdo = DbUtils::openDbAndReturnPdoStatic();
$sql = "SELECT * FROM %user% WHERE active='1' ORDER BY is_admin"; $sql = "SELECT * FROM %user% WHERE active='1' ORDER BY is_admin";
@ -1288,12 +1328,17 @@ class Admin {
} }
$pdo = $this->dbutils->openDbAndReturnPdo(); $pdo = $this->dbutils->openDbAndReturnPdo();
$hotelinterface = CommonUtils::getConfigValue($pdo, "hotelinterface", 0);
$where = " WHERE id <> 7";
if ($hotelinterface != 0) {
$where = "";
}
$lang = $_SESSION['language']; $lang = $_SESSION['language'];
$sql = "SELECT id,name FROM %payment%"; $sql = "SELECT id,name FROM %payment% $where";
if ($lang == 1) { if ($lang == 1) {
$sql = "SELECT id,name_en as name FROM %payment%"; $sql = "SELECT id,name_en as name FROM %payment% $where";
} else if ($lang == 2) { } else if ($lang == 2) {
$sql = "SELECT id,name_esp as name FROM %payment%"; $sql = "SELECT id,name_esp as name FROM %payment% $where";
} }
$stmt_query = $pdo->prepare($this->dbutils->resolveTablenamesInSqlString($sql)); $stmt_query = $pdo->prepare($this->dbutils->resolveTablenamesInSqlString($sql));
@ -1306,7 +1351,10 @@ class Admin {
$entry = array("id"=> $row['id'], "name" => $row['name']); $entry = array("id"=> $row['id'], "name" => $row['name']);
$retArray[] = $entry; $retArray[] = $entry;
} }
echo json_encode($retArray);
$hotelinfo = $this->getHotelInfo($pdo);
echo json_encode(array("payments" => $retArray, "hotelinterface" => $hotelinfo["hotelinterface"],"guests" => $hotelinfo["guests"]));
} }
function sendJsonValueFromConfigTable($pdo,$whichValue) { function sendJsonValueFromConfigTable($pdo,$whichValue) {
@ -1395,6 +1443,10 @@ class Admin {
"workflowconfig" => array("dbcol" => "workflowconfig","checknum" => 0), "workflowconfig" => array("dbcol" => "workflowconfig","checknum" => 0),
"receiptfontsize" => array("dbcol" => "receiptfontsize","checknum" => 0), "receiptfontsize" => array("dbcol" => "receiptfontsize","checknum" => 0),
"billlanguage" => array("dbcol" => "billlanguage","checknum" => 0), "billlanguage" => array("dbcol" => "billlanguage","checknum" => 0),
"hotelinterface" => array("dbcol" => "hotelinterface","checknum" => 0),
"hsinfile" => array("dbcol" => "hsinfile","checknum" => 0),
"hsoutfile" => array("dbcol" => "hsoutfile","checknum" => 0),
"hscurrency" => array("dbcol" => "hscurrency","checknum" => 0),
"reservationnote" => array("dbcol" => "reservationnote","checknum" => 0), "reservationnote" => array("dbcol" => "reservationnote","checknum" => 0),
"remoteaccesscode" => array("dbcol" => "remoteaccesscode","checknum" => 0), "remoteaccesscode" => array("dbcol" => "remoteaccesscode","checknum" => 0),
"webimpressum" => array("dbcol" => "webimpressum","checknum" => 0), "webimpressum" => array("dbcol" => "webimpressum","checknum" => 0),
@ -1409,6 +1461,8 @@ class Admin {
"smtpsecure" => array("dbcol" => "smtpsecure","checknum" => 1), "smtpsecure" => array("dbcol" => "smtpsecure","checknum" => 1),
"smtpport" => array("dbcol" => "smtpport","checknum" => 0), "smtpport" => array("dbcol" => "smtpport","checknum" => 0),
"memorylimit" => array("dbcol" => "memorylimit","checknum" => 0),
"paydeskid" => array("dbcol" => "paydeskid","checknum" => 0), "paydeskid" => array("dbcol" => "paydeskid","checknum" => 0),
"aeskey" => array("dbcol" => "aeskey","checknum" => 0), "aeskey" => array("dbcol" => "aeskey","checknum" => 0),
"certificatesn" => array("dbcol" => "certificatesn","checksum" => 0) "certificatesn" => array("dbcol" => "certificatesn","checksum" => 0)
@ -1445,6 +1499,19 @@ class Admin {
$aVal = md5($aVal); $aVal = md5($aVal);
} }
if ($name == "memorylimit") {
$aVal = trim($aVal);
if ($aVal != "-1") {
if (!ctype_digit($aVal)) {
$aVal = "256";
}
$aVal = intval($aVal);
if (($aVal < 64) || ($aVal > 65535)) {
$aVal = 256;
}
}
}
$association = $assoc_vals[$name]; $association = $assoc_vals[$name];
$dbcol = $association["dbcol"]; $dbcol = $association["dbcol"];
$check = $association["checknum"]; $check = $association["checknum"];
@ -1833,12 +1900,12 @@ class Admin {
private function getAllTablesToBackupRestore() { private function getAllTablesToBackupRestore() {
return array("closing","logo","printjobs","ratings","work","payment","room","resttables","tablepos","tablemaps","pricelevel","prodtype","products","config", return array("closing","logo","printjobs","ratings","work","payment","room","resttables","tablepos","tablemaps","pricelevel","prodtype","products","config",
"user","reservations","bill","queue","billproducts","comments","histprod","histconfig","histuser","histactions","hist","extras","extrasprods","queueextras"); "user","reservations","bill","queue","billproducts","hsin","hsout","comments","histprod","histconfig","histuser","histactions","hist","extras","extrasprods","queueextras");
} }
private function getAllWithLogsTablesToBackupRestore() { private function getAllWithLogsTablesToBackupRestore() {
return array("log","closing","logo","printjobs","ratings","work","payment","room","resttables","tablepos","tablemaps","pricelevel","prodtype","products","config", return array("log","closing","logo","printjobs","ratings","work","payment","room","resttables","tablepos","tablemaps","pricelevel","prodtype","products","config",
"user","reservations","bill","queue","billproducts","comments","histprod","histconfig","histuser","histactions","hist","extras","extrasprods","queueextras"); "user","reservations","bill","queue","billproducts","hsin","hsout","comments","histprod","histconfig","histuser","histactions","hist","extras","extrasprods","queueextras");
} }
public function backup($theType,$remoteaccesscode) { public function backup($theType,$remoteaccesscode) {
@ -2101,15 +2168,46 @@ class Admin {
self::doSql($pdo, "OPTIMIZE TABLE %billproducts%", null); self::doSql($pdo, "OPTIMIZE TABLE %billproducts%", null);
self::doSql($pdo, "OPTIMIZE TABLE %extrasprods%", null); self::doSql($pdo, "OPTIMIZE TABLE %extrasprods%", null);
self::doSql($pdo, "OPTIMIZE TABLE %queueextras%", null); self::doSql($pdo, "OPTIMIZE TABLE %queueextras%", null);
self::doSql($pdo, "OPTIMIZE TABLE %log%", null);
echo json_encode(array("status" => "OK")); echo json_encode(array("status" => "OK"));
} catch (Exception $ex) { } catch (Exception $ex) {
echo json_encode(array("status" => "ERROR", "code" => ERROR_COMMAND_ERROR, "msg" => ERROR_COMMAND_ERROR_MSG)); echo json_encode(array("status" => "ERROR", "code" => ERROR_COMMAND_ERROR, "msg" => ERROR_COMMAND_ERROR_MSG));
} }
} }
private function golive() {
private static function getForeignKeyName($pdo,$fromtable,$totable,$dbname,$default = null) {
$foreignKey = null;
try { try {
$sql = "SELECT constraint_name as foreignkey FROM information_schema.REFERENTIAL_CONSTRAINTS WHERE constraint_schema = '$dbname' AND table_name = '%$fromtable%' AND REFERENCED_TABLE_NAME='%$totable%'";
$test = DbUtils::substTableAlias($sql);
$stmt = $pdo->prepare(DbUtils::substTableAlias($sql));
$stmt->execute();
$result = $stmt->fetchAll();
if (count($result) != 1) {
return $default;
}
$foreignKey = $result[0]["foreignkey"];
} catch (Exception $e) {
return $default;
}
return $foreignKey;
}
private function golive() {
$pdo = DButils::openDbAndReturnPdoStatic(); $pdo = DButils::openDbAndReturnPdoStatic();
try {
$billprodref_fk = self::getForeignKeyName($pdo, 'billproducts', 'bill', MYSQL_DB);
$queuebillref_fk = self::getForeignKeyName($pdo, 'queue', 'bill', MYSQL_DB);
$billclosingref_fk = self::getForeignKeyName($pdo, 'bill', 'closing', MYSQL_DB);
$billbillref_fk = self::getForeignKeyName($pdo, 'bill', 'bill', MYSQL_DB);
} catch (Exception $ex) {
echo json_encode(array("status" => "ERROR", "code" => ERROR_COMMAND_ERROR, "msg" => ERROR_COMMAND_ERROR_MSG . " - impossible to get foreign keys: $e"));
}
try {
self::doSql($pdo, "DELETE FROM %hist%", null); self::doSql($pdo, "DELETE FROM %hist%", null);
self::doSql($pdo, "DELETE FROM %histprod%", null); self::doSql($pdo, "DELETE FROM %histprod%", null);
self::doSql($pdo, "DELETE FROM %histconfig%", null); self::doSql($pdo, "DELETE FROM %histconfig%", null);
@ -2153,18 +2251,18 @@ class Admin {
self::doSql($pdo, "DELETE FROM %hist% where action='4'", null); self::doSql($pdo, "DELETE FROM %hist% where action='4'", null);
} }
self::doSql($pdo, "alter table %bill% drop foreign key billbillref", null); self::doSql($pdo, "alter table %bill% drop foreign key $billbillref_fk", null);
self::doSql($pdo, "alter table %billproducts% drop foreign key billprodref", null); self::doSql($pdo, "alter table %billproducts% drop foreign key $billprodref_fk", null);
self::doSql($pdo, "alter table %queue% drop foreign key queuebillref", null); self::doSql($pdo, "alter table %queue% drop foreign key $queuebillref_fk", null);
self::doSql($pdo, "ALTER TABLE %bill% DROP id", null); self::doSql($pdo, "ALTER TABLE %bill% DROP id", null);
self::doSql($pdo, "ALTER TABLE %bill% ADD id INT (10) NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST", null); self::doSql($pdo, "ALTER TABLE %bill% ADD id INT (10) NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST", null);
self::doSql($pdo, "ALTER TABLE %bill% ADD CONSTRAINT billbillref FOREIGN KEY (ref) REFERENCES %bill%(id)", null); self::doSql($pdo, "ALTER TABLE %bill% ADD CONSTRAINT $billbillref_fk FOREIGN KEY (ref) REFERENCES %bill%(id)", null);
self::doSql($pdo, "ALTER TABLE %billproducts% ADD CONSTRAINT billprodref FOREIGN KEY (billid) REFERENCES %bill%(id)", null); self::doSql($pdo, "ALTER TABLE %billproducts% ADD CONSTRAINT $billprodref_fk FOREIGN KEY (billid) REFERENCES %bill%(id)", null);
self::doSql($pdo, "ALTER TABLE %queue% ADD CONSTRAINT queuebillref FOREIGN KEY (billid) REFERENCES %bill%(id)", null); self::doSql($pdo, "ALTER TABLE %queue% ADD CONSTRAINT $queuebillref_fk FOREIGN KEY (billid) REFERENCES %bill%(id)", null);
self::doSql($pdo, "alter table %bill% drop foreign key billclosingref", null); self::doSql($pdo, "alter table %bill% drop foreign key $billclosingref_fk", null);
self::doSql($pdo, "ALTER TABLE %closing% DROP id", null); self::doSql($pdo, "ALTER TABLE %closing% DROP id", null);
self::doSql($pdo, "ALTER TABLE %closing% ADD id INT (10) NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST", null); self::doSql($pdo, "ALTER TABLE %closing% ADD id INT (10) NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST", null);
self::doSql($pdo, "ALTER TABLE %bill% ADD CONSTRAINT billclosingref FOREIGN KEY (closingid) REFERENCES %closing%(id)", null); self::doSql($pdo, "ALTER TABLE %bill% ADD CONSTRAINT $billclosingref_fk FOREIGN KEY (closingid) REFERENCES %closing%(id)", null);
$basedb = new Basedb(); $basedb = new Basedb();
$basedb->setPrefix(TAB_PREFIX); $basedb->setPrefix(TAB_PREFIX);
@ -2179,7 +2277,7 @@ class Admin {
echo json_encode(array("status" => "OK")); echo json_encode(array("status" => "OK"));
} catch(Exception $e) { } catch(Exception $e) {
echo json_encode(array("status" => "ERROR", "code" => ERROR_COMMAND_ERROR, "msg" => ERROR_COMMAND_ERROR_MSG)); echo json_encode(array("status" => "ERROR", "code" => ERROR_COMMAND_ERROR, "msg" => ERROR_COMMAND_ERROR_MSG . " - Error message: $e"));
} }
} }

View File

@ -183,7 +183,7 @@ class Bill {
* *
* @param unknown $billid * @param unknown $billid
*/ */
function getBillWithId($pdo,$billid,$language,$printer) { function getBillWithId($pdo,$billid,$language,$printer,$includeGuestInfo = false) {
set_time_limit(120); set_time_limit(120);
// is bill correct with signature? // is bill correct with signature?
@ -211,16 +211,16 @@ class Bill {
if ($qrow->countid == 0) { if ($qrow->countid == 0) {
if ($tableid == 0) { if ($tableid == 0) {
// togo // togo
$sql = "SELECT DISTINCT billdate,brutto,netto,'-' as tablename,username,host,IFNULL(%bill%.status,'') as status FROM %bill%,%user% WHERE %bill%.id=? AND userid=%user%.id AND tableid='0' "; $sql = "SELECT DISTINCT billdate,brutto,netto,'-' as tablename,username,host,IFNULL(%bill%.status,'') as status,guestinfo FROM %bill%,%user% WHERE %bill%.id=? AND userid=%user%.id AND tableid='0' ";
} else { } else {
$sql = "SELECT DISTINCT billdate,brutto,netto,tableno as tablename,username,host,IFNULL(%bill%.status,'') as status FROM %bill%,%user%,%resttables% WHERE %bill%.id=? AND userid=%user%.id AND tableid=%resttables%.id "; $sql = "SELECT DISTINCT billdate,brutto,netto,tableno as tablename,username,host,IFNULL(%bill%.status,'') as status,guestinfo FROM %bill%,%user%,%resttables% WHERE %bill%.id=? AND userid=%user%.id AND tableid=%resttables%.id ";
} }
} else { } else {
if ($tableid == 0) { if ($tableid == 0) {
// togo // togo
$sql = "SELECT DISTINCT billdate,brutto,netto,'-' as tablename,username,host,IFNULL(%bill%.status,'') as status FROM %bill%,%user%,%queue% WHERE %bill%.id=? AND %bill%.id=%queue%.billid AND userid=%user%.id AND tableid='0' AND paidtime is not null "; $sql = "SELECT DISTINCT billdate,brutto,netto,'-' as tablename,username,host,IFNULL(%bill%.status,'') as status,guestinfo FROM %bill%,%user%,%queue% WHERE %bill%.id=? AND %bill%.id=%queue%.billid AND userid=%user%.id AND tableid='0' AND paidtime is not null ";
} else { } else {
$sql = "SELECT DISTINCT billdate,brutto,netto,tableno as tablename,username,host,IFNULL(%bill%.status,'') as status FROM %bill%,%user%,%resttables%,%queue% WHERE %bill%.id=? AND %bill%.id=%queue%.billid AND userid=%user%.id AND tableid=%resttables%.id AND paidtime is not null "; $sql = "SELECT DISTINCT billdate,brutto,netto,tableno as tablename,username,host,IFNULL(%bill%.status,'') as status,guestinfo FROM %bill%,%user%,%resttables%,%queue% WHERE %bill%.id=? AND %bill%.id=%queue%.billid AND userid=%user%.id AND tableid=%resttables%.id AND paidtime is not null ";
} }
} }
$stmt = $pdo->prepare(DbUtils::substTableAlias($sql)); $stmt = $pdo->prepare(DbUtils::substTableAlias($sql));
@ -282,6 +282,13 @@ class Bill {
"printer" => $printer, "printer" => $printer,
"host" => $host "host" => $host
); );
if ($includeGuestInfo) {
if (is_null($row->guestinfo)) {
$billoverallinfo["guestinfo"] = '';
} else {
$billoverallinfo["guestinfo"] = $row->guestinfo;
}
}
$billtranslations = array( $billtranslations = array(
"sum" => $this->P_SUM[$language], "sum" => $this->P_SUM[$language],
@ -475,7 +482,7 @@ class Bill {
"shortdate" => $shortdate, "shortdate" => $shortdate,
"brutto" => $zeile['brutto'], "brutto" => $zeile['brutto'],
"tablename" => $commonUtils->getTableNameFromId($pdo,$zeile['tableid']), "tablename" => $commonUtils->getTableNameFromId($pdo,$zeile['tableid']),
"billcontent" => $this->getBillWithId($pdo,$theId,$l,0), "billcontent" => $this->getBillWithId($pdo,$theId,$l,0,true),
"isClosed" => $isClosed, "isClosed" => $isClosed,
"host" => $zeile['host'] "host" => $zeile['host']
); );
@ -544,7 +551,7 @@ class Bill {
$ids[] = $anId["queueid"]; $ids[] = $anId["queueid"];
} }
$sql = "SELECT brutto,netto,tableid,paymentid,tax FROM %bill% WHERE id=?"; $sql = "SELECT brutto,netto,tableid,paymentid,tax,reservationid,guestinfo FROM %bill% WHERE id=?";
$stmt = $pdo->prepare(DbUtils::substTableAlias($sql)); $stmt = $pdo->prepare(DbUtils::substTableAlias($sql));
$stmt->execute(array($billid)); $stmt->execute(array($billid));
$row = $stmt->fetchObject(); $row = $stmt->fetchObject();
@ -556,14 +563,14 @@ class Bill {
return; return;
} }
$this->recreateBill($pdo, $ids, $row->brutto, $row->netto, $row->tableid, $row->paymentid, $row->tax, 1-$isNowHost); $this->recreateBill($pdo, $ids, $row->brutto, $row->netto, $row->tableid, $row->paymentid, $row->tax, 1-$isNowHost,$row->reservationid,$row->guestinfo);
$pdo->commit(); $pdo->commit();
echo json_encode(array("status" => "OK", "code" => OK)); echo json_encode(array("status" => "OK", "code" => OK));
} }
function recreateBill($pdo,$ids_array,$brutto,$netto,$tableid,$paymentId,$tax,$host) { function recreateBill($pdo,$ids_array,$brutto,$netto,$tableid,$paymentId,$tax,$host,$reservationid,$guestinfo) {
$userid = $this->getUserId(); $userid = $this->getUserId();
@ -590,9 +597,10 @@ class Bill {
// now calculate the signature for the bill entry // now calculate the signature for the bill entry
$signature = $commonUtils->calcSignatureForBill($pdo,$currentTime, $brutto, $netto, '0.00', $userid); $signature = $commonUtils->calcSignatureForBill($pdo,$currentTime, $brutto, $netto, '0.00', $userid);
$billInsertSql = "INSERT INTO `%bill%` (`id` , `billdate`,`brutto`,`netto`,`tableid`,`paymentid`,`userid`,`ref`,`tax`,`host`,`signature`) VALUES (?,?,?,?,?,?,?,NULL,NULL,?,?)"; $billInsertSql = "INSERT INTO `%bill%` (`id` , `billdate`,`brutto`,`netto`,`tableid`,`paymentid`,`userid`,`ref`,`tax`,`host`,`reservationid`,`guestinfo`,`signature`) VALUES (?,?,?,?,?,?,?,NULL,NULL,?,?,?,?)";
$stmt = $pdo->prepare($this->dbutils->resolveTablenamesInSqlString($billInsertSql)); $stmt = $pdo->prepare($this->dbutils->resolveTablenamesInSqlString($billInsertSql));
$stmt->execute(array($billid,$currentTime,$brutto,$netto,$tableid,$paymentId,$userid,$host,$signature)); $stmt->execute(array($billid,$currentTime,$brutto,$netto,$tableid,$paymentId,$userid,$host,$reservationid,$guestinfo,$signature));
$newBillId = $pdo->lastInsertId();
// now declare them all to be paid: // now declare them all to be paid:
for ($i=0;$i<count($ids_array);$i++) { for ($i=0;$i<count($ids_array);$i++) {
@ -606,6 +614,8 @@ class Bill {
$stmt = $pdo->prepare($this->dbutils->resolveTablenamesInSqlString($billProdsSql)); $stmt = $pdo->prepare($this->dbutils->resolveTablenamesInSqlString($billProdsSql));
$stmt->execute(array($queueid,$billid)); $stmt->execute(array($queueid,$billid));
} }
Hotelinterface::insertIntoHsin($pdo, $newBillId);
} }
/* /*
@ -650,7 +660,7 @@ class Bill {
} }
// is the bill already closed? In this case no cancel is allowed! // is the bill already closed? In this case no cancel is allowed!
$sql = "SELECT brutto,netto,tax,tableid,closingid,status,paymentid FROM %bill% WHERE id=?"; $sql = "SELECT brutto,netto,tax,tableid,closingid,status,paymentid,reservationid,guestinfo FROM %bill% WHERE id=?";
$stmt = $pdo->prepare($this->dbutils->resolveTablenamesInSqlString($sql)); $stmt = $pdo->prepare($this->dbutils->resolveTablenamesInSqlString($sql));
$stmt->execute(array($billid)); $stmt->execute(array($billid));
$row =$stmt->fetchObject(); $row =$stmt->fetchObject();
@ -665,6 +675,8 @@ class Bill {
$tableid = $row->tableid; $tableid = $row->tableid;
$status = $row->status; $status = $row->status;
$paymentid = $row->paymentid; $paymentid = $row->paymentid;
$reservationid = $row->reservationid;
$guestinfo = $row->guestinfo;
} }
if (!is_null($closingId) || ($status == 's') || ($status == 'x')) { if (!is_null($closingId) || ($status == 's') || ($status == 'x')) {
@ -735,9 +747,9 @@ class Bill {
$commonUtils = new CommonUtils(); $commonUtils = new CommonUtils();
$signature = $commonUtils->calcSignatureForBill($pdo,$currentTime, $stornval, $stornonettoval, $tax, $userIdOfStornoUser); $signature = $commonUtils->calcSignatureForBill($pdo,$currentTime, $stornval, $stornonettoval, $tax, $userIdOfStornoUser);
$sql = "INSERT INTO `%bill%` (`id` , `billdate`,`brutto`,`netto`,`tax`,`tableid`, `status`, `paymentid`,`userid`,`ref`,`host`,`signature`) VALUES (?,?,?,?,?,?, 's', ?,?,?,?,?)"; $sql = "INSERT INTO `%bill%` (`id` , `billdate`,`brutto`,`netto`,`tax`,`tableid`, `status`, `paymentid`,`userid`,`ref`,`host`,`reservationid`,`guestinfo`,`signature`) VALUES (?,?,?,?,?,?, 's', ?,?,?,?,?,?,?)";
$stmt = $pdo->prepare($this->dbutils->resolveTablenamesInSqlString($sql)); $stmt = $pdo->prepare($this->dbutils->resolveTablenamesInSqlString($sql));
$stmt->execute(array($nextbillid,$currentTime,$stornval,$stornonettoval,$tax,$tableid,$paymentid,$userIdOfStornoUser,$billid,0,$signature)); $stmt->execute(array($nextbillid,$currentTime,$stornval,$stornonettoval,$tax,$tableid,$paymentid,$userIdOfStornoUser,$billid,0,$reservationid,$guestinfo,$signature));
$refIdOfStornoEntry = $pdo->lastInsertId(); $refIdOfStornoEntry = $pdo->lastInsertId();
$sql = "SELECT brutto,netto,prevbrutto,prevnetto FROM %bill% WHERE id=?"; $sql = "SELECT brutto,netto,prevbrutto,prevnetto FROM %bill% WHERE id=?";
@ -766,6 +778,8 @@ class Bill {
$stmt->execute(array($aQueueid,$refIdOfStornoEntry)); $stmt->execute(array($aQueueid,$refIdOfStornoEntry));
} }
Hotelinterface::insertIntoHsin($pdo,$refIdOfStornoEntry);
if ($doOwnTransaction) { if ($doOwnTransaction) {
$pdo->commit(); $pdo->commit();
} }

View File

@ -287,6 +287,15 @@ class CommonUtils {
} }
return ($stmt->fetchObject()); return ($stmt->fetchObject());
} }
public static function fetchSqlAll($pdo,$sql,$params) {
$stmt = $pdo->prepare(DbUtils::substTableAlias($sql));
if (is_null($params)) {
$stmt->execute();
} else {
$stmt->execute($params);
}
return ($stmt->fetchAll());
}
public static function execSql($pdo,$sql,$params) { public static function execSql($pdo,$sql,$params) {
$stmt = $pdo->prepare(DbUtils::substTableAlias($sql)); $stmt = $pdo->prepare(DbUtils::substTableAlias($sql));

View File

@ -12,6 +12,7 @@ require_once ('printqueue.php');
require_once ('feedback.php'); require_once ('feedback.php');
require_once ('reservation.php'); require_once ('reservation.php');
require_once ('rating.php'); require_once ('rating.php');
require_once ('commonutils.php');
require_once ('utilities/Logger.php'); require_once ('utilities/Logger.php');
$module = $_GET["module"]; $module = $_GET["module"];
@ -21,6 +22,14 @@ Logger::logcmd($module,$command,"");
$plugins = havePlugins(); $plugins = havePlugins();
$pdo = DbUtils::openDbAndReturnPdoStatic();
$memlimit = CommonUtils::getConfigValue($pdo, "memorylimit", '256');
if ($memlimit != "-1") {
$memlimit = $memlimit . 'M';
}
ini_set('memory_limit',$memlimit);
$pdo = null;
if ($module == 'admin') { if ($module == 'admin') {
$adminModule = new Admin(); $adminModule = new Admin();
$adminModule->handleCommand($command); $adminModule->handleCommand($command);

View File

@ -17,6 +17,8 @@ define ('DB_CLOSING_TABLE', TAB_PREFIX . 'closing');
define ('DB_PRINTJOB_TABLE', TAB_PREFIX . 'printjob'); define ('DB_PRINTJOB_TABLE', TAB_PREFIX . 'printjob');
define ('DB_WORK_TABLE', TAB_PREFIX . 'work'); define ('DB_WORK_TABLE', TAB_PREFIX . 'work');
define ('DB_COMMENTS_TABLE', TAB_PREFIX . 'comments'); define ('DB_COMMENTS_TABLE', TAB_PREFIX . 'comments');
define ('DB_HSIN_TABLE', TAB_PREFIX . 'hsin');
define ('DB_HSOUT_TABLE', TAB_PREFIX . 'hsout');
define ('DB_LOGO_TABLE', TAB_PREFIX . 'logo'); define ('DB_LOGO_TABLE', TAB_PREFIX . 'logo');
define ('DB_EXTRAS_TABLE', TAB_PREFIX . 'extras'); define ('DB_EXTRAS_TABLE', TAB_PREFIX . 'extras');
define ('DB_EXTRASPRODS_TABLE', TAB_PREFIX . 'extrasprods'); define ('DB_EXTRASPRODS_TABLE', TAB_PREFIX . 'extrasprods');
@ -127,6 +129,8 @@ class DbUtils {
$out = str_replace("%billproducts%", $prefix . 'billproducts',$out); $out = str_replace("%billproducts%", $prefix . 'billproducts',$out);
$out = str_replace("%work%",$prefix . 'work',$out); $out = str_replace("%work%",$prefix . 'work',$out);
$out = str_replace("%comments%",$prefix . 'comments',$out); $out = str_replace("%comments%",$prefix . 'comments',$out);
$out = str_replace("%hsin%",$prefix . 'hsin',$out);
$out = str_replace("%hsout%",$prefix . 'hsout',$out);
$out = str_replace("%reservations%",$prefix . 'reservations',$out); $out = str_replace("%reservations%",$prefix . 'reservations',$out);
$out = str_replace("%logo%",$prefix . 'logo',$out); $out = str_replace("%logo%",$prefix . 'logo',$out);

View File

@ -0,0 +1,206 @@
<?php
require_once ('dbutils.php');
require_once ('commonutils.php');
class Hotelinterface {
private static $SYNC_INTERVAL = 300; // 5 * 60;
public static function hs3sync($pdo) {
$hotelinterface = CommonUtils::getConfigValue($pdo, "hotelinterface", 0);
if ($hotelinterface != 1) {
// HS/3 is not active thus do nothing
return array("status" => "OK");
}
date_default_timezone_set(DbUtils::getTimeZone());
$currentTime = date('Y-m-d H:i:s');
$itemNameForLastSync = 'lasths3sync';
$sql = "SELECT count(id) as countid FROM %work% WHERE item=?";
$row = CommonUtils::getRowSqlObject($pdo, $sql, array($itemNameForLastSync));
if ($row->countid > 0) {
$sql = "SELECT TIMESTAMPDIFF(SECOND,value,NOW()) as synctimediff FROM %work% WHERE item=?";
$row = CommonUtils::getRowSqlObject($pdo, $sql, array($itemNameForLastSync));
$lastdone = $row->synctimediff;
if ($lastdone < self::$SYNC_INTERVAL) {
return array("status" => "OK");
}
} else {
$sql = "INSERT INTO %work% (item,value) VALUES(?,?)";
CommonUtils::execSql($pdo, $sql, array($itemNameForLastSync,$currentTime));
}
$sql = "UPDATE %work% SET value=? WHERE item=?";
CommonUtils::execSql($pdo, $sql, array($currentTime,$itemNameForLastSync));
$resultOfHsOutSync = self::syncHs3Out($pdo);
$resultOfHsInSync = self::syncHs3In($pdo);
return array("status" => "OK");
}
private static function syncHs3Out($pdo) {
$hsoutfile = CommonUtils::getConfigValue($pdo, 'hsoutfile', '');
if ($hsoutfile !== '') {
if ( !file_exists($hsoutfile) ) {
CommonUtils::log($pdo, "HS3", "Error HS3CASH.OUT does not exist.");
return array("status" => "ERROR","msg" => "Fehler beim Zugriff auf HS3CASH.OUT. Datei $hsoutfile existiert nicht.");
}
try {
$pdo->beginTransaction();
if (($handle = fopen($hsoutfile, "r")) !== FALSE) {
$sql = "DELETE FROM %hsout%";
CommonUtils::execSql($pdo, $sql, null);
$sql = "INSERT INTO %hsout% (reservationid,object,guest) VALUES(?,?,?)";
$stmt = $pdo->prepare(DbUtils::substTableAlias($sql));
while (($data = fgetcsv($handle, 0, ";")) !== FALSE) {
$num = count($data);
if ($num >= 3) {
$reservationid = $data[0];
$objectid = $data[1];
$guestname = $data[2];
$stmt->execute(array($reservationid,$objectid,$guestname));
}
}
$pdo->commit();
fclose($handle);
CommonUtils::log($pdo, "HS3", "HS/3 Outfile read.");
$ok = unlink($hsoutfile);
if (!$ok) {
CommonUtils::log($pdo, "HS3", "Error deleting HS3CASH.OUT.");
return array("status" => "ERROR","msg" => "Datei HS3CASH.OUT konnte nicht gelöscht werden.");
}
} else {
$pdo->rollBack();
CommonUtils::log($pdo, "HS3", "Error accessing HS3CASH.OUT.");
return array("status" => "ERROR","msg" => "Fehler beim Zugriff auf HS3CASH.OUT.");
}
} catch (Exception $e) {
$pdo->rollBack();
return array("status" => "ERROR","msg" => "Fehler beim Zugriff auf HS3CASH.OUT. Meldung: $e");
}
}
return array("status" => "OK");
}
private static function syncHs3In($pdo) {
$hsinfile = CommonUtils::getConfigValue($pdo, 'hsinfile', '');
if ($hsinfile !== '') {
if ( file_exists($hsinfile) ) {
CommonUtils::log($pdo, "HS3", "HS3CASH.IN still exists - cannot transmit data.");
return array("status" => "ERROR","msg" => "Fehler beim Zugriff auf HS3CASH.IN. Datei $hsinfile existiert noch.");
}
try {
$txt = '';
$pdo->beginTransaction();
$sql = "SELECT * from %hsin%";
$result = CommonUtils::fetchSqlAll($pdo, $sql, null);
if (count($result) > 0) {
$lines = array();
foreach($result as $anEntry) {
$entryArr = array();
$entryArr[] = '"' . $anEntry["reservationid"] . '"';
$entryArr[] = '"' . $anEntry["billid"] . '"';
$entryArr[] = '"' . $anEntry["date"] . '"';
$entryArr[] = '"' . $anEntry["time"] . '"';
$entryArr[] = '"' . $anEntry["number"] . '"';
$entryArr[] = '"' . $anEntry["prodid"] . '"';
$entryArr[] = '"' . $anEntry["prodname"] . '"';
$entryArr[] = '"' . str_replace(".",',',$anEntry['tax']) . '"';
$entryArr[] = '"' . str_replace(".",',',$anEntry['brutto']) . '"';
$entryArr[] = '"' . str_replace(".",',',$anEntry['total']) . '"';
$entryArr[] = '"' . $anEntry["currency"] . '"';
$entryArr[] = '"' . $anEntry["waiterid"] . '"';
$entryArr[] = '"' . $anEntry["waitername"] . '"';
$entryTxt = join(',',$entryArr);
$lines[] = $entryTxt;
}
$fullFileContent = implode("\r\n",$lines);
if (file_put_contents($hsinfile, $fullFileContent) == FALSE) {
$pdo->rollBack();
CommonUtils::log($pdo, "HS3", "Error accessing HS3CASH.IN. Cannot write to file.");
return array("status" => "ERROR","msg" => "Fehler beim Zugriff auf HS3CASH.IN. Datei nicht beschreibbar.");
}
}
$sql = "DELETE FROM %hsin%";
CommonUtils::execSql($pdo, $sql, null);
$pdo->commit();
CommonUtils::log($pdo, "HS3", "HS/3 Infile written.");
return array("status" => "OK");
} catch (Exception $e) {
$pdo->rollBack();
return array("status" => "ERROR","msg" => "Fehler beim Zugriff auf HS3CASH.IN. Meldung: $e");
}
}
}
public static function insertIntoHsin($pdo,$billid) {
$hotelinterface = CommonUtils::getConfigValue($pdo, "hotelinterface", 0);
if ($hotelinterface != 1) {
// HS/3 is not active thus do nothing
return;
}
$hscurrency = CommonUtils::getConfigValue($pdo, "hscurrency", "EUR");
if (strlen($hscurrency) > 3) {
$hscurrency = substr($hscurrency,0,3);
}
$sql = "SELECT DATE_FORMAT(DATE(billdate),'%d.%m.%Y') as billdate,TIME_FORMAT(TIME(billdate),'%H:%i') as billtime,reservationid,userid,username,brutto,paymentid from %bill%,%user% WHERE %bill%.id=? AND userid=%user%.id";
$row = CommonUtils::getRowSqlObject($pdo, $sql, array($billid));
if ($row->paymentid != 7) {
return;
}
$waitername = substr($row->username,0,20);
$sign = '';
if ($row->brutto < 0) {
$sign = '-';
}
$sql = "SELECT COUNT(id) as count,productid,productname,tax,price,SUM(price) as sumprice FROM %queue%,%billproducts% WHERE %billproducts%.billid=? AND %billproducts%.queueid=%queue%.id GROUP BY productid,price,tax";
$items = CommonUtils::fetchSqlAll($pdo, $sql, array($billid));
foreach ($items as $anItem) {
$sql = "INSERT INTO %hsin% (reservationid,billid,date,time,number,prodid,prodname,tax,brutto,total,currency,waiterid,waitername) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?)";
$tax = str_replace(".",',',$anItem['tax']);
$brutto = $sign . $anItem['price'];
$total = $sign . $anItem['sumprice'];
$prodname = $anItem['productname'];
if (strlen($prodname) > 100) {
$prodname = substr($prodname, 0,100);
}
try {
CommonUtils::execSql($pdo, $sql, array(
$row->reservationid,
$billid,
$row->billdate,
$row->billtime,
$anItem['count'],
$anItem['productid'],
$prodname,
$tax,
$brutto,
$total,
$hscurrency,
$row->userid,
$waitername
));
} catch (Exception $e) {
echo $e;
}
}
}
}
?>

View File

@ -461,6 +461,8 @@ class PrintQueue {
if (in_array($printer, $printersArr)) { if (in_array($printer, $printersArr)) {
if (is_null($fl)) { if (is_null($fl)) {
$receiptJob = array("id" => $printJobId,"bill" => $bill->getBillWithId($pdo,$aBillId,$language,$printer)); $receiptJob = array("id" => $printJobId,"bill" => $bill->getBillWithId($pdo,$aBillId,$language,$printer));
} else if ($fl >= 4) {
$receiptJob = array("id" => $printJobId,"bill" => $bill->getBillWithId($pdo,$aBillId,$language,$printer,true), "template" => $template);
} else if ($fl >= 1) { } else if ($fl >= 1) {
$receiptJob = array("id" => $printJobId,"bill" => $bill->getBillWithId($pdo,$aBillId,$language,$printer), "template" => $template); $receiptJob = array("id" => $printJobId,"bill" => $bill->getBillWithId($pdo,$aBillId,$language,$printer), "template" => $template);
} }

View File

@ -102,7 +102,7 @@ class QueueContent {
$this->getJsonProductsOfTableToPay($_GET['tableid']); $this->getJsonProductsOfTableToPay($_GET['tableid']);
} else if ($command == 'declarePaidCreateBillReturnBillId') { } else if ($command == 'declarePaidCreateBillReturnBillId') {
$pdo = DbUtils::openDbAndReturnPdoStatic(); $pdo = DbUtils::openDbAndReturnPdoStatic();
$this->declarePaidCreateBillReturnBillId($pdo,$_POST['ids'],$_POST['tableid'],$_POST['paymentid'],$_POST['declareready'],$_POST['host']); $this->declarePaidCreateBillReturnBillId($pdo,$_POST['ids'],$_POST['tableid'],$_POST['paymentid'],$_POST['declareready'],$_POST['host'],false,$_POST['reservationid'],$_POST['guestinfo']);
} else { } else {
echo "Command not supported."; echo "Command not supported.";
} }
@ -1632,7 +1632,14 @@ class QueueContent {
* Create bill * Create bill
* Return a bill id * Return a bill id
*/ */
function declarePaidCreateBillReturnBillId($pdo,$ids,$tableid,$paymentId,$declareready,$host,$calledInternally = false) { function declarePaidCreateBillReturnBillId($pdo,$ids,$tableid,$paymentId,$declareready,$host,$calledInternally = false,$reservationid,$guestinfo) {
if ($reservationid != "") {
$reservationid = substr($reservationid, 0, 30);
}
if ($guestinfo != "") {
$guestinfo = substr($guestinfo, 0, 30);
}
$userid = $this->getUserId(); $userid = $this->getUserId();
@ -1726,9 +1733,9 @@ class QueueContent {
// now calculate the signature for the bill entry // now calculate the signature for the bill entry
$signature = $this->commonUtils->calcSignatureForBill($pdo,$currentTime, $brutto, $netto, '0.00', $userid); $signature = $this->commonUtils->calcSignatureForBill($pdo,$currentTime, $brutto, $netto, '0.00', $userid);
$billInsertSql = "INSERT INTO `%bill%` (`id` , `billdate`,`brutto`,`netto`,`prevbrutto`,`prevnetto`,`tableid`,`paymentid`,`userid`,`ref`,`tax`,`host`,`signature`) VALUES (?,?,?,?,?,?,?,?,?,NULL,NULL,?,?)"; $billInsertSql = "INSERT INTO `%bill%` (`id` , `billdate`,`brutto`,`netto`,`prevbrutto`,`prevnetto`,`tableid`,`paymentid`,`userid`,`ref`,`tax`,`host`,`reservationid`,`guestinfo`,`signature`) VALUES (?,?,?,?,?,?,?,?,?,NULL,NULL,?,?,?,?)";
$stmt = $pdo->prepare($this->dbutils->resolveTablenamesInSqlString($billInsertSql)); $stmt = $pdo->prepare($this->dbutils->resolveTablenamesInSqlString($billInsertSql));
$stmt->execute(array($billid,$currentTime,$brutto,$netto,$newprevbrutto,$newprevnetto,$tableid,$paymentId,$userid,$host,$signature)); $stmt->execute(array($billid,$currentTime,$brutto,$netto,$newprevbrutto,$newprevnetto,$tableid,$paymentId,$userid,$host,$reservationid,$guestinfo,$signature));
// now declare them all to be paid: // now declare them all to be paid:
for ($i=0;$i<count($ids_array);$i++) { for ($i=0;$i<count($ids_array);$i++) {
@ -1749,6 +1756,7 @@ class QueueContent {
$stmt->execute(array($queueid,$billid)); $stmt->execute(array($queueid,$billid));
} }
} }
Hotelinterface::insertIntoHsin($pdo,$billid);
} }
if (!$calledInternally) { if (!$calledInternally) {
$pdo->commit(); $pdo->commit();

View File

@ -112,6 +112,8 @@ class Basedb {
$out = str_replace("%billproducts%",$this->prefix . "billproducts",$out); $out = str_replace("%billproducts%",$this->prefix . "billproducts",$out);
$out = str_replace("%work%",$this->prefix . "work",$out); $out = str_replace("%work%",$this->prefix . "work",$out);
$out = str_replace("%comments%",$this->prefix . "comments",$out); $out = str_replace("%comments%",$this->prefix . "comments",$out);
$out = str_replace("%hsin%",$this->prefix . "hsin",$out);
$out = str_replace("%hsout%",$this->prefix . "hsout",$out);
$out = str_replace("%reservations%",$this->prefix . "reservations",$out); $out = str_replace("%reservations%",$this->prefix . "reservations",$out);
$out = str_replace("%logo%",$this->prefix . "logo",$out); $out = str_replace("%logo%",$this->prefix . "logo",$out);
$out = str_replace("%log%",$this->prefix . "log",$out); $out = str_replace("%log%",$this->prefix . "log",$out);
@ -119,10 +121,14 @@ class Basedb {
$out = str_replace("%extrasprods%",$this->prefix . "extrasprods", $out); $out = str_replace("%extrasprods%",$this->prefix . "extrasprods", $out);
$out = str_replace("%queueextras%",$this->prefix . "queueextras", $out); $out = str_replace("%queueextras%",$this->prefix . "queueextras", $out);
$out = str_replace("%ratings%",$this->prefix . "ratings", $out); $out = str_replace("%ratings%",$this->prefix . "ratings", $out);
$out = str_replace("%hsin%",$this->prefix . "hsin", $out);
$out = str_replace("%hsout%",$this->prefix . "hsout", $out);
return (str_replace("%prodtype%",$this->prefix . "prodtype",$out)); return (str_replace("%prodtype%",$this->prefix . "prodtype",$out));
} }
function dropTables($pdo) { function dropTables($pdo) {
$this->doSQLcatch($pdo, "DROP TABLE `%hsout%`");
$this->doSQLcatch($pdo, "DROP TABLE `%hsin%`");
$this->doSQLcatch($pdo, "DROP TABLE `%comments%`"); $this->doSQLcatch($pdo, "DROP TABLE `%comments%`");
$this->doSQLcatch($pdo, "DROP TABLE `%reservations%`"); $this->doSQLcatch($pdo, "DROP TABLE `%reservations%`");
$this->doSQLcatch($pdo, "DROP TABLE `%work%`"); $this->doSQLcatch($pdo, "DROP TABLE `%work%`");
@ -158,6 +164,8 @@ class Basedb {
} }
function dropTablesNoCatch($pdo) { function dropTablesNoCatch($pdo) {
$this->doSQL($pdo, "DROP TABLE `%hsin%`");
$this->doSQL($pdo, "DROP TABLE `%hsout%`");
$this->doSQL($pdo, "DROP TABLE `%comments%`"); $this->doSQL($pdo, "DROP TABLE `%comments%`");
$this->doSQL($pdo, "DROP TABLE `%reservations%`"); $this->doSQL($pdo, "DROP TABLE `%reservations%`");
$this->doSQL($pdo, "DROP TABLE `%work%`"); $this->doSQL($pdo, "DROP TABLE `%work%`");
@ -365,7 +373,7 @@ class Basedb {
CREATE TABLE `%extras%` ( CREATE TABLE `%extras%` (
`id` INT (10) NOT NULL AUTO_INCREMENT PRIMARY KEY , `id` INT (10) NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`name` VARCHAR ( 150 ) NOT NULL, `name` VARCHAR ( 150 ) NOT NULL,
`price` " . DECIMALSMALL . "NOT NULL, `price` " . DECIMALSMALL . " NOT NULL,
`removed` INT(1) NULL `removed` INT(1) NULL
) CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE = InnoDb ; ) CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE = InnoDb ;
"; ";
@ -487,11 +495,13 @@ class Basedb {
`tax` " . DECIMALSMALL . " NULL, `tax` " . DECIMALSMALL . " NULL,
`host` INT(2) NULL, `host` INT(2) NULL,
`reason` VARCHAR ( 150 ) NULL, `reason` VARCHAR ( 150 ) NULL,
`reservationid` VARCHAR( 30 ) NULL,
`guestinfo` VARCHAR( 30 ) NULL,
`signature`blob NULL, `signature`blob NULL,
FOREIGN KEY billclosingref (closingid) REFERENCES %closing%(id), FOREIGN KEY (closingid) REFERENCES %closing%(id),
FOREIGN KEY (paymentid) REFERENCES %payment%(id), FOREIGN KEY (paymentid) REFERENCES %payment%(id),
FOREIGN KEY (userid) REFERENCES %user%(id), FOREIGN KEY (userid) REFERENCES %user%(id),
FOREIGN KEY billbillref (ref) REFERENCES %bill%(id) FOREIGN KEY (ref) REFERENCES %bill%(id)
) CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE = InnoDb ; ) CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE = InnoDb ;
"; ";
$stmt = $pdo->prepare($this->resolveTablenamesInSqlString($sql)); $stmt = $pdo->prepare($this->resolveTablenamesInSqlString($sql));
@ -530,7 +540,7 @@ class Basedb {
FOREIGN KEY (tablenr) REFERENCES %resttables%(id), FOREIGN KEY (tablenr) REFERENCES %resttables%(id),
FOREIGN KEY (pricelevel) REFERENCES %pricelevel%(id), FOREIGN KEY (pricelevel) REFERENCES %pricelevel%(id),
FOREIGN KEY (productid) REFERENCES %products%(id), FOREIGN KEY (productid) REFERENCES %products%(id),
FOREIGN KEY queuebillref (billid) REFERENCES %bill%(id), FOREIGN KEY (billid) REFERENCES %bill%(id),
FOREIGN KEY (cooking) REFERENCES %user%(id), FOREIGN KEY (cooking) REFERENCES %user%(id),
FOREIGN KEY (orderuser) REFERENCES %user%(id) FOREIGN KEY (orderuser) REFERENCES %user%(id)
) CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE = InnoDb ; ) CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE = InnoDb ;
@ -544,7 +554,7 @@ class Basedb {
`queueid` INT( 10 ) NOT NULL, `queueid` INT( 10 ) NOT NULL,
`billid` INT(10) NOT NULL, `billid` INT(10) NOT NULL,
FOREIGN KEY (queueid) REFERENCES %queue%(id), FOREIGN KEY (queueid) REFERENCES %queue%(id),
FOREIGN KEY billprodref (billid) REFERENCES %bill%(id) FOREIGN KEY (billid) REFERENCES %bill%(id)
) CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE = InnoDb ; ) CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE = InnoDb ;
"; ";
$this->doSQL($pdo,$sql); $this->doSQL($pdo,$sql);
@ -692,6 +702,40 @@ class Basedb {
} }
} }
function createHsinTable($pdo) {
$sql = "
CREATE TABLE `%hsin%` (
`id` INT( 10 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`reservationid` VARCHAR( 30 ) NULL ,
`billid` INT(10) NULL,
`date` VARCHAR( 10 ) NULL,
`time` VARCHAR( 5 ) NULL,
`number` INT(10) NULL,
`prodid` INT(10) NULL,
`prodname` VARCHAR( 100 ) NULL,
`tax` VARCHAR( 50 ) NULL,
`brutto` " . DECIMALSMALL . " NOT NULL,
`total` " . DECIMALSMALL . " NOT NULL,
`currency` VARCHAR( 5 ) NULL,
`waiterid` VARCHAR( 20 ) NULL,
`waitername` VARCHAR( 20 ) NULL
) CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE = InnoDb ;
";
$this->doSQL($pdo,$sql);
}
function createHsoutTable($pdo) {
$sql = "
CREATE TABLE `%hsout%` (
`id` INT( 10 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`reservationid` VARCHAR( 50 ) NULL ,
`object` VARCHAR( 50 ) NULL ,
`guest` VARCHAR( 100 ) NULL
) CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE = InnoDb ;
";
$this->doSQL($pdo,$sql);
}
function createCommentsTable($pdo) { function createCommentsTable($pdo) {
$sql = " $sql = "
CREATE TABLE `%comments%` ( CREATE TABLE `%comments%` (
@ -748,6 +792,8 @@ class Basedb {
$this->createPrintJobsTable($pdo); $this->createPrintJobsTable($pdo);
$this->createWorkTable($pdo); $this->createWorkTable($pdo);
$this->createCommentsTable($pdo); $this->createCommentsTable($pdo);
$this->createHsinTable($pdo);
$this->createHsoutTable($pdo);
$this->createReservationsTable($pdo); $this->createReservationsTable($pdo);
$this->createLogoTable($pdo); $this->createLogoTable($pdo);
$this->createExtrasTable($pdo); $this->createExtrasTable($pdo);

View File

@ -5,7 +5,7 @@
<meta http-equiv="content-type" content="text/html; charset=utf-8"> <meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta name="author" content="Stefan Pichel"> <meta name="author" content="Stefan Pichel">
<link rel="stylesheet" type="text/css" href="css/bestformat.css?v=1.2.18"> <link rel="stylesheet" type="text/css" href="css/bestformat.css?v=1.2.19">
<link rel="stylesheet" href="php/3rdparty/orderstyle/orderstyle.min.css" /> <link rel="stylesheet" href="php/3rdparty/orderstyle/orderstyle.min.css" />
<link rel="stylesheet" href="php/3rdparty/orderstyle/jquery.mobile.icons.min.css" /> <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 http-equiv="content-type" content="text/html; charset=utf-8">
<meta name="author" content="Stefan Pichel"> <meta name="author" content="Stefan Pichel">
<link rel="stylesheet" type="text/css" href="css/bestformat.css?v=1.2.18"> <link rel="stylesheet" type="text/css" href="css/bestformat.css?v=1.2.19">
<link rel="stylesheet" href="php/3rdparty/orderstyle/orderstyle.min.css" /> <link rel="stylesheet" href="php/3rdparty/orderstyle/orderstyle.min.css" />
<link rel="stylesheet" href="php/3rdparty/orderstyle/jquery.mobile.icons.min.css" /> <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 http-equiv="content-type" content="text/html; charset=utf-8">
<meta name="author" content="Stefan Pichel"> <meta name="author" content="Stefan Pichel">
<link rel="stylesheet" type="text/css" href="css/bestformat.css?v=1.2.18"> <link rel="stylesheet" type="text/css" href="css/bestformat.css?v=1.2.19">
<link rel="stylesheet" href="php/3rdparty/orderstyle/orderstyle.min.css" /> <link rel="stylesheet" href="php/3rdparty/orderstyle/orderstyle.min.css" />
<link rel="stylesheet" href="php/3rdparty/orderstyle/jquery.mobile.icons.min.css" /> <link rel="stylesheet" href="php/3rdparty/orderstyle/jquery.mobile.icons.min.css" />

View File

@ -74,7 +74,7 @@ function generateProdPart(decPoint,entryListForReceipt) {
/** /**
* Generate HTML output on base of db content * Generate HTML output on base of db content
*/ */
function generateHtmlBillFromScratch(lang,billid,billcontent,currency,decPoint,companyInfo,hosthtml) { function generateHtmlBillFromScratch(lang,billid,billcontent,currency,decPoint,companyInfo,hosthtml,guestinfo) {
var table = '<table id="receiptpart" class="receipttable" border=1 style="table-layout: fixed;">'; var table = '<table id="receiptpart" class="receipttable" border=1 style="table-layout: fixed;">';
var overallinfo = billcontent.billoverallinfo; var overallinfo = billcontent.billoverallinfo;
@ -83,7 +83,7 @@ function generateHtmlBillFromScratch(lang,billid,billcontent,currency,decPoint,c
var username = overallinfo.username; var username = overallinfo.username;
var tablename = overallinfo.table; var tablename = overallinfo.table;
var header = genCreateReceiptHeader(lang,billid,tablename,username,currency); var header = genCreateReceiptHeader(lang,billid,tablename,username,currency,guestinfo);
var products = generateProdPartByDbContent(decPoint,prods); var products = generateProdPartByDbContent(decPoint,prods);

View File

@ -7,7 +7,7 @@
<meta http-equiv="content-type" content="text/html; charset=utf-8"> <meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta name="author" content="Stefan Pichel"> <meta name="author" content="Stefan Pichel">
<link rel="stylesheet" type="text/css" href="css/bestformat.css?v=1.2.18"> <link rel="stylesheet" type="text/css" href="css/bestformat.css?v=1.2.19">
<link rel="stylesheet" href="php/3rdparty/orderstyle/orderstyle.min.css" /> <link rel="stylesheet" href="php/3rdparty/orderstyle/orderstyle.min.css" />
<link rel="stylesheet" href="php/3rdparty/orderstyle/jquery.mobile.icons.min.css" /> <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 name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="content-type" content="text/html; charset=utf-8"> <meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta name="author" content="Stefan Pichel"> <meta name="author" content="Stefan Pichel">
<link rel="stylesheet" type="text/css" href="css/bestformat.css?v=1.2.18"> <link rel="stylesheet" type="text/css" href="css/bestformat.css?v=1.2.19">
<link rel="stylesheet" href="php/3rdparty/orderstyle/orderstyle.min.css" /> <link rel="stylesheet" href="php/3rdparty/orderstyle/orderstyle.min.css" />
<link rel="stylesheet" href="php/3rdparty/orderstyle/jquery.mobile.icons.min.css" /> <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 http-equiv="content-type" content="text/html; charset=utf-8">
<meta name="author" content="Stefan Pichel"> <meta name="author" content="Stefan Pichel">
<link rel="stylesheet" type="text/css" href="css/bestformat.css?v=1.2.18"> <link rel="stylesheet" type="text/css" href="css/bestformat.css?v=1.2.19">
<link rel="stylesheet" href="php/3rdparty/orderstyle/orderstyle.min.css" /> <link rel="stylesheet" href="php/3rdparty/orderstyle/orderstyle.min.css" />
<link rel="stylesheet" href="php/3rdparty/orderstyle/jquery.mobile.icons.min.css" /> <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