# HG changeset patch # User Michiel Broek # Date 1659465300 -7200 # Node ID 45e87aa8d02ccf298a69a3daefce94cd781ad577 # Parent 4a9f469d2201cb37ac0e1f1cb182f3698d644cad Removed import brewlog diff -r 4a9f469d2201 -r 45e87aa8d02c www/Makefile --- a/www/Makefile Tue Aug 02 11:01:33 2022 +0200 +++ b/www/Makefile Tue Aug 02 20:35:00 2022 +0200 @@ -8,14 +8,14 @@ getfermenter.php getfermentlog.php gethopsources.php getmiscsources.php getnode.php \ getwatersources.php getyeastsources.php getispindel.php getispindellog.php \ import_ingredients.php index.php \ - log_brew.php log_co2pressure.php log_fermentation.php log_ispindel.php \ + log_co2pressure.php log_fermentation.php log_ispindel.php \ mon_brewer.php mon_co2meter.php mon_fermenter.php mon_ispindel.php mon_node.php \ prod_beerxml.php prod_checklist.php prod_divide.php prod_duplicate.php \ prod_edit.php prod_export.php prod_forum.php \ prod_impbrew.php prod_inprod.php prod_new.php prod_print.php prod_torecipe.php \ rec_beerxml.php rec_duplicate.php rec_edit.php rec_export.php rec_forum.php \ rec_import.php rec_main.php rec_new.php rec_print.php rec_toproduct.php \ - upl_brew.php upl_fermentables.php upl_hops.php upl_miscs.php upl_recipe.php \ + upl_fermentables.php upl_hops.php upl_miscs.php upl_recipe.php \ upl_styles.php upl_yeasts.php version.php SUB = version.php.in images/* css/* jqwidgets/* jqwidgets/styles/* \ jqwidgets/styles/images/* jqwidgets/globalization/* js/* \ diff -r 4a9f469d2201 -r 45e87aa8d02c www/includes/global.inc.php --- a/www/includes/global.inc.php Tue Aug 02 11:01:33 2022 +0200 +++ b/www/includes/global.inc.php Tue Aug 02 20:35:00 2022 +0200 @@ -226,7 +226,6 @@
  • Recepten diff -r 4a9f469d2201 -r 45e87aa8d02c www/js/log_brew.js --- a/www/js/log_brew.js Tue Aug 02 11:01:33 2022 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,136 +0,0 @@ -/***************************************************************************** - * 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() { - - $('#jqxMenu').jqxMenu('destroy'); - $('#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: 'version', type: 'int' }, - { name: 'code', type: 'string' }, - { name: 'name', type: 'string' }, - { name: 'pv_mlt', type: 'float' }, - { name: 'pv_hlt', type: 'float' }, - { name: 'pv_room', type: 'float' }, - { name: 'sp_mlt', type: 'float' }, - { name: 'sp_hlt', type: 'float' }, - { name: 'pwm_mlt', type: 'int' }, - { name: 'pwm_hlt', type: 'int' }, - { name: 'event', type: 'string' } - ], - url: 'getbrewlog.php?code=' + my_code - }, - dataAdapter = new $.jqx.dataAdapter(sourceA, { - autoBind: true, - async: false, - loadComplete: function() { - $('#jqxLoader').jqxLoader('close'); - }, - loadError: function(jqXHR, status, error) { - } - }), - settings = { - title: my_code + ' "' + my_name + '"', - description: '', - source: dataAdapter, - xAxis: { - dataField: 'date', - type: 'date', - formatFunction: function(value) { - return value.getHours() + ':' + value.getMinutes(); - }, - toolTipFormatFunction: function(value) { - var h = value.getHours(), m = value.getMinutes(); - return value.getDate() + '-' + (value.getMonth() + 1) + '-' + value.getFullYear() + - ' ' + (h < 10 ? '0' + h : h) + ':' + (m < 10 ? '0' + m : m); - }, - textRotationAngle: 300, - }, - colorScheme: 'scheme01', - seriesGroups: [{ - type: 'spline', - valueAxis: { - minValue: 0, - description: 'Graden C' - }, - series: [ - { dataField: 'pv_mlt', lineWidth: 2, displayText: 'MLT' }, - { dataField: 'sp_mlt', lineWidth: 1, displayText: 'mlt', opacity: 0.7 }, - { dataField: 'pv_hlt', lineWidth: 1, displayText: 'HLT' }, - { dataField: 'sp_hlt', lineWidth: 1, displayText: 'hlt', opacity: 0.7 }, - { dataField: 'pv_room', lineWidth: 1, displayText: 'Ruimte', opacity: 0.5 } - ] - }] - }; - $('#brew_chart').jqxChart(settings); - - $('#print').click(function() { - var content = $('#brew_chart')[0].outerHTML, - newWindow = window.open('', '', 'width=865, height=425'), - document = newWindow.document.open(), - pageContent = - '' + - '' + - '' + - '' + - '' + - '' + my_code + ' ' + my_name + ' brouwdag' + - '' + - '' + content + ''; - document.write(pageContent); - document.close(); - newWindow.print(); - }); - $('#print').jqxButton({ template: 'primary', width: 125, theme: theme }); - - $('#pdfButton').click(function() { - $('#brew_chart').jqxChart('saveAsPDF', 'brouw_' + my_code + '.pdf', getExportServer()); - }); - $('#pdfButton').jqxButton({ template: 'primary', width: 125, theme: theme }); - - $('#pngButton').click(function() { - $('#brew_chart').jqxChart('saveAsPNG', 'brouw_' + my_code + '.png', getExportServer()); - }); - $('#pngButton').jqxButton({ template: 'primary', width: 125, theme: theme }); - - $('#Close').jqxButton({ template: 'success', width: 125, theme: theme }); - $('#Close').click(function() { - window.close(); - }); -}); - diff -r 4a9f469d2201 -r 45e87aa8d02c www/log_brew.php --- a/www/log_brew.php Tue Aug 02 11:01:33 2022 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,19 +0,0 @@ - - -
    -
    -
    -
    - - - - -
    -
    - - diff -r 4a9f469d2201 -r 45e87aa8d02c www/upl_brew.php --- a/www/upl_brew.php Tue Aug 02 11:01:33 2022 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,123 +0,0 @@ - 500000 && $uploadOk) { - echo "Fout 2: het bestand is te groot. "; - $uploadOk = 0; -} -// Allow certain file formats -if ($imageFileType != "json" && $uploadOk) { - echo "Fout 3: alleen JSON bestanden toegestaan. "; - $uploadOk = 0; -} -// Check if $uploadOk is set to 0 by an error -if ($uploadOk == 0) { - exit; -} - -if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) { - echo "Verwerken bestand ". basename( $_FILES["fileToUpload"]["name"]). "
    "; -} else { - echo "Fout 4: er ging iets fout met de upload."; - exit; -} - -$json= file_get_contents($target_file); -$brew = json_decode($json, true); -$records = count($brew); -if ($records != 1) { - echo "Fout 5: dit is geen JSON brouw logfile"; - exit; -} - -$connect = mysqli_connect(DBASE_HOST, DBASE_USER, DBASE_PASS, DBASE_NAME); -if (! $connect) { - echo "Fout 6: ".mysqli_connect_errno()." ".mysqli_connect_error(); - exit; -} -mysqli_set_charset($connect, "utf8" ); -date_default_timezone_set('Europe/Amsterdam'); - -foreach($brew as $brewdata) { - - foreach($brewdata as $item) { - $temps = $item['brewdata']; - $events = $item['annotations']; - $date = date("Y-m-d H:i:s" , strtotime($item['Date'])); - $code = strtok($item['Recipe'], " "); - $name = strtok('\0'); - $insert = 0; - $update = 0; - $delete = 0; - - $sql = "SELECT uuid FROM products WHERE code='".$code."';"; - $result = mysqli_query($connect, $sql) or die("SQL Error 1: " . mysqli_error($connect)); - if ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { - $uuid = $row['uuid']; - } - echo "Brouw: ".$code." ".$name."
    "; - - $sql = "DELETE FROM log_brews WHERE code='".$code."';"; - $result = mysqli_query($connect, $sql) or die("SQL Error 1: " . mysqli_error($connect)); - $delete += mysqli_affected_rows($connect); - - foreach($temps as $temp) { - // Create full datetime from the Label - $t = floatval(substr($temp['Label'], 0, 2)) * 60 + floatval(substr($temp['Label'], 3, 2)); - $time = new DateTime($date); - $time->add(new DateInterval('PT' . $t . 'M')); - $stamp = $time->format('Y-m-d H:i:s'); - - $sql = "INSERT INTO log_brews SET version='2"; - $sql .= "', datetime='" . $stamp; - $sql .= "', uuid='" . $uuid; - $sql .= "', code='" . $code; - $sql .= "', name='" . mysqli_real_escape_string($connect, $name); - $sql .= "', pv_mlt='" . $temp['MLT_pv']; - $sql .= "', sp_mlt='" . $temp['MLT_sp']; - $sql .= "', pwm_mlt='" . $temp['MLT_pwm']; - if (isset($temp['HLT_pv'])) - $sql .= "', pv_hlt='" . $temp['HLT_pv']; - if (isset($temp['HLT_sp'])) - $sql .= "', sp_hlt='" . $temp['HLT_sp']; - if (isset($temp['HLT_pwm'])) - $sql .= "', pwm_hlt='" . $temp['HLT_pwm']; - $sql .= "';"; - $result = mysqli_query($connect, $sql) or die("SQL Error 1: " . mysqli_error($connect)); - $insert += mysqli_affected_rows($connect); - } - - // The events are annotations in the JSON file. - foreach($events as $event) { - $t = floatval(substr($event['value'], 0, 2)) * 60 + floatval(substr($event['value'], 3, 2)); - $time = new DateTime($date); - $time->add(new DateInterval('PT' . $t . 'M')); - $stamp = $time->format('Y-m-d H:i:s'); - - $sql = "UPDATE log_brews SET event='".mysqli_real_escape_string($connect, $event['label']['content'])."' WHERE "; - $sql .= "datetime='".$stamp."' AND uuid='".$uuid."';"; - $result = mysqli_query($connect, $sql) or die("SQL Error 1: " . mysqli_error($connect)); - $update += mysqli_affected_rows($connect); - } - - $sql = "UPDATE products SET log_brew='1' WHERE code='".$code."';"; - $result = mysqli_query($connect, $sql) or die("SQL Error 1: " . mysqli_error($connect)); - $update += mysqli_affected_rows($connect); - echo "Database delete: ".$delete.", insert: ".$insert.", update: ".$update." records." . PHP_EOL; - } -} -// Don't clutter the upload directory. -unlink($target_file); - -?>