www/getbrewlog.php

Tue, 31 Aug 2021 20:48:37 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Tue, 31 Aug 2021 20:48:37 +0200
changeset 774
92e1e8f175a2
parent 297
5e2424bfbc4a
permissions
-rw-r--r--

Split batch, adjust mash step volume. In the duplicated log_brew handle the missing values. In save product, round the mash step sg to 4 decimals. In prod_edit, ingredients are stored as strings, not arrays. This triggered a memory corruption that only happened in rare circumstances. Don't fix mash step fields in the javascript, it is already done during load from the database. Calculation of the mash volume is rounded to 6 decimals. Enter mash step Brix/Plato value, the SG result is rounded to 4 decimals.

<?php

require_once('config.php');

if (isset($_GET["code"]))
	$code = $_GET["code"];
else
	$code = "CB0011";

$connect = mysqli_connect(DBASE_HOST, DBASE_USER, DBASE_PASS, DBASE_NAME);
if (! $connect) {
	die('Connect Error (' . mysqli_connect_errno() . ') ' . mysqli_connect_error());
}
mysqli_set_charset($connect, "utf8" );

$query = "SELECT * FROM log_brews WHERE code='".$code."' ORDER BY datetime;";
$result = mysqli_query($connect, $query) or die("SQL Error 1: " . mysqli_error($connect));
while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) {
	$lines[] = array(
		'record' => $row['record'],
		'date' => substr($row['datetime'],0,16),
		'version' => $row['version'],
		'code' => $row['code'],
		'name' => $row['name'],
		'pv_mlt' => $row['pv_mlt'],
		'pv_hlt' => $row['pv_hlt'],
		'pv_room' => $row['pv_room'],
		'sp_mlt' => $row['sp_mlt'],
		'sp_hlt' => $row['sp_hlt'],
		'pwm_mlt' => $row['pwm_mlt'],
		'pwm_hlt' => $row['pwm_hlt'],
		'event' => $row['event']
	);
}
header("Content-type: application/json");
echo json_encode($lines);

mercurial