ordersprinter/webapp/dash.php

230 lines
6.4 KiB
PHP

<html>
<head>
<title>Ansicht Dashboard</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta name="author" content="Stefan Pichel">
<link rel="stylesheet" type="text/css" href="css/bestformat.css?v={VERSION}">
<link rel="stylesheet" href="css/ospage.css" />
<link rel="stylesheet" href="php/3rdparty/jqueryui1-12-0/jquery-ui.min.css" />
<script src="php/3rdparty/jquery-2.2.4.min.js"></script>
<script src="php/3rdparty/jqueryui1-12-0/jquery-ui.min.js"></script>
<script src="utilities.js"></script>
<script src="receiptutils.js"></script>
<script src="elements/dash.js"></script>
<script src="php/3rdparty/Chart.bundle.min.js"></script>
<script>
// insert waiterdesk elements here
</script>
</head>
<style>
.rounddiv {
border-radius: 25px;
border: 5px solid #73AD21;
padding: 20px;
background-color: #111111;
}
.rounddiv h1 {
font-size: 25px;
text-align: center;
color: white;
background-color: gray;
border-bottom: 15px;
}
</style>
<body>
<script>
var lang = 0;
var decpoint = ",";
var currency = "EUR";
var mainmenu = [];
var version = "";
var loggedinUser = "";
var dashslot1 = 1;
var dashslot2 = 2;
var dashslot3 = 3;
$(document).ready(function () {
getGeneralConfigItems();
doAjax("GET", "php/contenthandler.php?module=admin&command=getJsonMenuItemsAndVersion", null, saveMenuInfo, null, true);
});
function getGeneralConfigItems() {
doAjax("GET", "php/contenthandler.php?module=admin&command=getGeneralConfigItems", null, insertGeneralConfigItems, "Fehler Konfigurationsdaten");
intervalGetPrinterStatus(5);
intervalGetDashReports(10);
}
function insertGeneralConfigItems(configResult) {
if (configResult.status == "OK") {
var values = configResult.msg;
decpoint = values.decpoint;
currency = values.currency;
lang = values.userlanguage;
dashslot1 = values.dashslot1;
dashslot2 = values.dashslot2;
dashslot3 = values.dashslot3;
} else {
$("#contentpart").hide();
setTimeout(function(){document.location.href = "index.html"},250); // not logged in
}
}
function saveMenuInfo(menuAndVersion) {
if (menuAndVersion.loggedin == 1) {
loggedinUser = menuAndVersion.user;
$("#loggedinuser").html("&nbsp;" + loggedinUser);
$("#versioninfo").html(menuAndVersion.version);
version = menuAndVersion.version;
$.each(menuAndVersion.menu, function (i, module) {
var name = module.name;
var link = module.link;
mainmenu[mainmenu.length] = { name: name, link: link };
});
$("#mainmenubtn").show();
} else {
$("#mainmenubtn").hide();
}
bindMainMenuButton();
}
function bindMainMenuButton() {
$("#mainmenudlg").dialog(
{autoOpen: false,
modal: true,
height: 400,
width: 200,
position:{my:"right top",at:"right top", of:"body"},
buttons: {
Abbrechen: function() {$(this).dialog("close"); }
}
});
$("#mainmenubtn").off("click").on("click", function (e) {
e.stopImmediatePropagation();
e.preventDefault();
var txt = "<div><ul class='mainmenuchoice'>";
for (var i = 0; i < mainmenu.length; i++) {
txt += "<li id='mainmenu_" + i + "' class='mainmenuitem' >" + toHtml(mainmenu[i].name) + "</li>";
}
txt += "</ul></div>";
$("#mainmenudlg").html(txt);
var height = 280 + mainmenu.length * 40;
$("#mainmenudlg").dialog(
{autoOpen: false,
modal: true,
height: height,
width: 200,
position:{my:"right top",at:"right top", of:"body"},
buttons: {
Abbrechen: function() {$(this).dialog("close"); }
}
});
$("#mainmenudlg").dialog("open");
$(".mainmenuitem").off("click").on("click", function (e) {
e.stopImmediatePropagation();
e.preventDefault();
var selectedmenuindex = parseInt(this.id.split('_')[1]);
var url = mainmenu[selectedmenuindex].link;
$("#mainmenudlg").dialog("close");
setTimeout(function(){document.location.href = url},250);
});
});
}
function intervalGetDashReports(seconds) {
doAjax("GET","php/contenthandler.php?module=admin&command=getdashreports",null,insertDashReports,null,true);
var fetchTimer = setInterval(function() {
doAjax("GET","php/contenthandler.php?module=admin&command=getdashreports",null,insertDashReports,null,true);
}, seconds * 1000);
}
function insertDashReports(answer) {
if (answer.status != "OK") {
alert("Fehler bei der Abfrage: " + answer.msg);
setTimeout(function(){document.location.href = "index.html"},250); // not logged in
} else {
var dash = new Dash();
createDashSlot(dash,"#slot1div",dashslot1,answer.msg.stat);
createDashSlot(dash,"#slot2div",dashslot2,answer.msg.stat);
createDashSlot(dash,"#slot3div",dashslot3,answer.msg.stat);
}
}
function createDashSlot(dash,slotId,diagramNumber,stat) {
if (diagramNumber == 0) {
// REM* nothing
$(slotId).hide();
return;
}
$(slotId).show();
if (diagramNumber == 1) {
dash.createUserCash(slotId,stat.usersums, currency);
} else if (diagramNumber == 2) {
dash.createTablesReport(slotId,stat.tables, currency);
} else if (diagramNumber == 3) {
dash.createProdCountReport(slotId,stat.prodscount, currency);
} else if (diagramNumber == 4) {
dash.createProdSumReport(slotId,stat.prodssum, currency);
} else if (diagramNumber == 5) {
dash.createMonthReport(slotId,stat.thismonth, currency);
} else if (diagramNumber == 6) {
dash.createDayReport(slotId,stat.today, currency);
};
}
</script>
<div class="tabledashheader" style="table-inbox">
<span class="dashheader">Dashboard <img src="img/printerstatus.png" class="printerstatus" style="display:none;" /></span>
<span class="floatright"><input id="mainmenubtn" class="inputwhite" type="submit" value="Hauptmenü" /></span>
</div>
<div id="main">
<table>
<tr>
<td><div id="slot1div" class="rounddiv"><h1></h1><canvas id="slot1" width="550" height="550"></canvas></div>
<td><div id="slot2div" class="rounddiv"><h1></h1><canvas id="slot2" width="550" height="550"></canvas></div>
<td><div id="slot3div" class="rounddiv"><h1></h1><canvas id="slot3" width="550" height="550"></canvas></div>
</tr>
</table>
</div> <!-- main -->
<div class="tablefooter">
<span id="loggedinuser"></span>
<span id="versioninfo"></span>
</div>
</div>
<div id="mainmenudlg" title="Hauptmenü">Hauptmenü</div>
</body>
</html>