Sat, 05 Jan 2019 17:10:39 +0100
Added fermentation graph screen
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/www/getfermentlog.php Sat Jan 05 17:10:39 2019 +0100 @@ -0,0 +1,30 @@ +<?php + +require_once('config.php'); + +if (isset($_GET["code"])) + $code = $_GET["code"]; +else + $code = "CB0068"; + +$query = "SELECT datetime,temperature_air,temperature_beer,temperature_chiller,temperature_room,target_low,target_high,heater_power,cooler_power FROM log_fermentation WHERE product_code='".$code."'"; +$connect = mysqli_connect(DBASE_HOST,DBASE_USER,DBASE_PASS,DBASE_NAME); +if (! $connect) { + echo "[]"; + return; +} +$result = mysqli_query($connect, $query); +while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { + $logs[] = array( + 'date' => $row['datetime'], + 'air' => $row['temperature_air'], + 'beer' => $row['temperature_beer'], + 'chiller' => $row['temperature_chiller'], + 'room' => $row['temperature_room'], + 'tlo' => $row['target_low'], + 'thi' => $row['target_high'], + 'heater' => $row['heater_power'], + 'cooler' => $row['cooler_power'] + ); +} +echo json_encode($logs);
--- a/www/includes/global.inc.php Fri Jan 04 21:51:59 2019 +0100 +++ b/www/includes/global.inc.php Sat Jan 05 17:10:39 2019 +0100 @@ -38,6 +38,14 @@ $my_return = $_GET['return']; else $my_return = ''; +if (isset($_GET['code'])) + $my_code = $_GET['code']; +else + $my_code = ''; +if (isset($_GET['name'])) + $my_name = $_GET['name']; +else + $my_name = ''; $escapers = array("\\", "/", "\"", "\n", "\r", "\t", "\x08", "\x0c"); $replacements = array("\\\\", "\\/", "\\\"", "\\n", "\\r", "\\t", "\\f", "\\b"); @@ -69,7 +77,7 @@ $my_brix_correction = floatval($row['brix_correction']); $my_grain_absorbtion = floatval($row['grain_absorbtion']); } -//mysqli_free_result($result); + function page_header($title, $loadjs) { @@ -77,6 +85,8 @@ global $my_version; global $my_record; global $my_return; + global $my_name; + global $my_code; global $my_brewery_name; global $my_factor_mashhop; global $my_factor_fwh; @@ -101,6 +111,8 @@ var theme = "<?php echo $my_style; ?>"; var my_record = "<?php echo $my_record; ?>"; var my_return = "<?php echo $my_return; ?>"; + var my_name= "<?php echo $my_name; ?>"; + var my_code= "<?php echo $my_code; ?>"; var my_brewery_name = "<?php echo $my_brewery_name; ?>"; var my_factor_mashhop = "<?php echo $my_factor_mashhop; ?>"; var my_factor_fwh = "<?php echo $my_factor_fwh; ?>"; @@ -140,6 +152,8 @@ <script src="jqwidgets/jqxdatetimeinput.js"></script> <script src="jqwidgets/jqxcalendar.js"></script> <script src="jqwidgets/jqxgauge.js"></script> + <script src="jqwidgets/jqxchart.core.js"></script> + <script src="jqwidgets/jqxchart.rangeselector.js"></script> <script src="jqwidgets/jqxdraw.js"></script> <script src="jqwidgets/jqxprogressbar.js"></script> <script src="jqwidgets/globalization/globalize.js"></script>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/www/js/log_fermentation.js Sat Jan 05 17:10:39 2019 +0100 @@ -0,0 +1,158 @@ +/***************************************************************************** + * Copyright (C) 2019 + * + * Michiel Broek <mbroek at mbse dot eu> + * + * This file is part of BMS + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2, or (at your option) any + * later version. + * + * Brewery Managment System is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with ThermFerm; see the file COPYING. If not, write to the Free + * Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + *****************************************************************************/ + + +$(document).ready(function () { + + $("#jqxLoader").jqxLoader({ + width: 250, + height: 150, + isModal: true, + text: "Opmaken grafiek ...", + theme: theme + }); + $('#jqxLoader').jqxLoader('open'); + + function getExportServer() { + return "https://www.jqwidgets.com/export_server/export.php"; + } + + var sourceA = { + datatype: "json", + datafields: [ + { name: "date", type: "date", format: "yyyy-MM-dd HH:mm" }, + { name: "air", type: "float" }, + { name: "beer", type: "float" }, + { name: "tlo", type: "float" }, + { name: "thi", type: "float" }, + { name: "heater", type: "int" }, + { name: "cooler", type: "int" }, + { name: "room", type: "float" }, + { name: "chiller", type: "float" } + ], + url: 'getfermentlog.php?code=' + my_code + }; + var dataAdapter = new $.jqx.dataAdapter(sourceA, { + autoBind: true, + async: false, + loadComplete: function () { + $('#jqxLoader').jqxLoader('close'); + }, + loadError: function (jqXHR, status, error) { + } + }); + + var settings = { + title: my_code + ' "' + my_name + '"', + description: "", + source: dataAdapter, + xAxis: { + dataField: 'date', + type: 'date', + formatFunction: function (value) { + return value.getDate() + '-' + (value.getMonth() + 1) + '-' + value.getFullYear(); + }, + toolTipFormatFunction: function (value) { + var h = value.getHours(); + var m = value.getMinutes(); + return value.getDate() + '-' + (value.getMonth() + 1) + '-' + value.getFullYear() + + ' ' + (h < 10 ? '0' + h : h) + ':' + (m < 10 ? '0' + m : m); + }, + textRotationAngle: 45, + howGridLines: false, + rangeSelector: { + size: 90, + dataField: 'beer', + serieType: 'line', + gridLines: {visible: false}, + } + }, + colorScheme: 'scheme01', + seriesGroups: [ + { + type: "line", + valueAxis: { + minValue: 0, + maxValue: 100, + displayValueAxis: false, + description: "Heat/Cool %" + }, + series: [ + { dataField: "cooler", lineWidth: 1, displayText: "Cool %", opacity: 0.3 }, + { dataField: "heater", lineWidth: 1, displayText: "Heat %", opacity: 0.3 } + ] + }, + { + type: 'spline', + valueAxis: { + minValue: 0, + description: 'Graden C' + }, + series: [ + { dataField: "air", lineWidth: 1, displayText: "Air" }, + { dataField: "beer", lineWidth: 2, displayText: "Beer" }, + { dataField: "tlo", lineWidth: 1, displayText: "Target Lo", opacity: 0.7 }, + { dataField: "thi", lineWidth: 1, displayText: "Target Hi", opacity: 0.7 }, + { dataField: "room", lineWidth: 1, displayText: "Room", opacity: 0.5 }, + { dataField: "chiller", lineWidth: 1, displayText: "Chiller", color: '#0000bb' } + ] + } + ] + }; + $("#fermentor_chart").jqxChart(settings); + + $("#print").click(function () { + var content = $("#fermentor_chart")[0].outerHTML; + var newWindow = window.open("", "", "width=865, height=425"), + document = newWindow.document.open(), + pageContent = + '<!DOCTYPE html>' + + '<html>' + + '<head>' + + '<link rel="stylesheet" href="jqwidgets/styles/jqx.base.css" type="text/css" />' + + '<meta charset="utf-8" />' + + '<title>jQWidgets Chart</title>' + + '</head>' + + '<body>' + content + '</body></html>'; + document.write(pageContent); + document.close(); + newWindow.print(); + }); + $("#print").jqxButton({ template: "info", width: 125, theme: theme }); + + + $("#pdfButton").click(function () { + $("#fermentor_chart").jqxChart("saveAsPDF", "vergisting_"+my_code+".pdf", getExportServer()); + }); + $("#pdfButton").jqxButton({ template: "info", width: 125, theme: theme }); + + $("#pngButton").click(function () { + $("#fermentor_chart").jqxChart("saveAsPNG", "vergisting_"+my_code+".png", getExportServer()); + }); + $("#pngButton").jqxButton({ template: "info", width: 125, theme: theme }); + + $("#Close").jqxButton({ template: "success", width: 125, theme: theme }); + $("#Close").click(function () { + window.close(); + }); +}); +
--- a/www/js/prod_edit.js Fri Jan 04 21:51:59 2019 +0100 +++ b/www/js/prod_edit.js Sat Jan 05 17:10:39 2019 +0100 @@ -3268,7 +3268,7 @@ $("#FLog").jqxButton({ template: "info", width: '150px', theme: theme }); $("#FLog").click(function () { // Open log in a new tab. - var url="log_fermentation.php?code=" + dataRecord.code; + var url="log_fermentation.php?code=" + dataRecord.code + "&name=" + dataRecord.name; window.open(url); });
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/www/log_fermentation.php Sat Jan 05 17:10:39 2019 +0100 @@ -0,0 +1,19 @@ +<?php +require_once($_SERVER['DOCUMENT_ROOT'].'/includes/global.inc.php'); +page_header('Vergisting grafiek', "log_fermentation"); +?> + + <div id="MainPanel"> + <div id="ContentPanel"></div> + <div id="fermentor_chart" style="width:1130px; height:610px; float:left; margin-left: 10px; margin-top: 10px;"></div> + <div style="margin-top: 10px; margin-left: 10px;"> + <input style="float: left; margin-left: 10px;" id="print" type="button" value="Print grafiek" /> + <input style="float: left; margin-left: 10px; margin-top: 10px;" id="pdfButton" type="button" value="Maak PDF" /> + <input style="float: left; margin-left: 10px; margin-top: 10px;" id="pngButton" type="button" value="Maak PNG" /> + <input style="float: left; margin-left: 10px; margin-top: 10px;" id="Close" type="button" value="Sluiten" /> + </div> + </div> + +<?php +page_footer(); +?>