# HG changeset patch # User Michiel Broek # Date 1546704639 -3600 # Node ID 684c651dd165b40cb545b08cbbf17d5dfc379a58 # Parent 48cf3ea270f8ceeeaca72dd6406b9fe91da6fa1d Added fermentation graph screen diff -r 48cf3ea270f8 -r 684c651dd165 www/getfermentlog.php --- /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 @@ + $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); diff -r 48cf3ea270f8 -r 684c651dd165 www/includes/global.inc.php --- 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 = ""; var my_record = ""; var my_return = ""; + var my_name= ""; + var my_code= ""; var my_brewery_name = ""; var my_factor_mashhop = ""; var my_factor_fwh = ""; @@ -140,6 +152,8 @@ + + diff -r 48cf3ea270f8 -r 684c651dd165 www/js/log_fermentation.js --- /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 + * + * 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 = + '' + + '' + + '' + + '' + + '' + + 'jQWidgets Chart' + + '' + + '' + content + ''; + 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(); + }); +}); + diff -r 48cf3ea270f8 -r 684c651dd165 www/js/prod_edit.js --- 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); }); diff -r 48cf3ea270f8 -r 684c651dd165 www/log_fermentation.php --- /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 @@ + + +
+
+
+
+ + + + +
+
+ +