Removed import brewlog

Tue, 02 Aug 2022 20:35:00 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Tue, 02 Aug 2022 20:35:00 +0200
changeset 803
45e87aa8d02c
parent 802
4a9f469d2201
child 804
ac5c3e97fcf1

Removed import brewlog

www/Makefile file | annotate | diff | comparison | revisions
www/includes/global.inc.php file | annotate | diff | comparison | revisions
www/js/log_brew.js file | annotate | diff | comparison | revisions
www/log_brew.php file | annotate | diff | comparison | revisions
www/upl_brew.php file | annotate | diff | comparison | revisions
--- 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/* \
--- 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 @@
       <ul style='width: 200px;'>
        <li><img style='float: left; margin-right: 5px;' src='images/beerstyles.png' /><a href="prod_inprod.php">In bewerking</a></li>
        <li><img style='float: left; margin-right: 5px;' src='images/list-add.png' /><a href="prod_new.php?return=index.php">Start nieuw</a></li>
-       <li><img style='float: left; margin-right: 5px;' src='images/insert-object.png' /><a href="prod_impbrew.php">Brouw log</a></li>
       </ul>
      </li>
      <li style='width: 80px;'>Recepten
--- 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 <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() {
-
- $('#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 =
-   '<!DOCTYPE html>' +
-   '<html>' +
-   '<head>' +
-   '<link rel="stylesheet" href="jqwidgets/styles/jqx.base.css" type="text/css" />' +
-   '<meta charset="utf-8" />' +
-   '<title>' + my_code + ' ' + my_name + ' brouwdag</title>' +
-   '</head>' +
-   '<body>' + content + '</body></html>';
-  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();
- });
-});
-
--- 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 @@
-<?php
-require_once($_SERVER['DOCUMENT_ROOT'].'/includes/global.inc.php');
-page_header('Brouw sessie grafiek', "log_brew");
-?>
-
-   <div id="MainPanel">
-    <div id="ContentPanel"></div>
-    <div id="brew_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();
-?>
--- 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 @@
-<?php
-require_once('config.php');
-
-$target_dir = "tmp/";
-$target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]);
-$uploadOk = 1;
-$imageFileType = pathinfo($target_file,PATHINFO_EXTENSION);
-
-// Check if file already exists
-if (file_exists($target_file)) {
-	echo "Fout 1: bestand bestaat al. ";
-	$uploadOk = 0;
-}
-// Check file size
-if ($_FILES["fileToUpload"]["size"] > 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"]). "<br />";
-} 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."<br />";
-
-		$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);
-
-?>

mercurial