Wed, 04 Mar 2020 10:48:21 +0100
Workaround for hang during startup. Changed order of displayed fields on the yeast tab. Tooltip text changes. More decimals on the checklist for misc ingredients. More decimals for the starter on product print.
<?php require($_SERVER['DOCUMENT_ROOT']."/config.php"); require($_SERVER['DOCUMENT_ROOT']."/version.php"); require($_SERVER['DOCUMENT_ROOT']."/includes/constants.php"); #Connect to the database $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" ); // get data and store in a json array if (isset($_POST['insert']) || isset($_POST['update'])) { if (isset($_POST['insert'])) { $sql = "INSERT INTO `inventory_yeasts` SET "; } if (isset($_POST['update'])) { $sql = "UPDATE `inventory_yeasts` SET "; } $sql .= "name='" . mysqli_real_escape_string($connect, $_POST['name']); $sql .= "', type='" . array_search($_POST['type'], $yeasttype); $sql .= "', form='" . array_search($_POST['form'], $yeastform); $sql .= "', laboratory='" . mysqli_real_escape_string($connect, $_POST['laboratory']); $sql .= "', product_id='" . mysqli_real_escape_string($connect, $_POST['product_id']); $sql .= "', min_temperature='" . $_POST['min_temperature']; $sql .= "', max_temperature='" . $_POST['max_temperature']; $sql .= "', flocculation='" . $_POST['flocculation']; $sql .= "', attenuation='" . $_POST['attenuation']; $sql .= "', notes='" . mysqli_real_escape_string($connect, $_POST['notes']); $sql .= "', best_for='" . mysqli_real_escape_string($connect, $_POST['best_for']); $sql .= "', max_reuse='" . $_POST['max_reuse']; $sql .= "', cells='" . floatval($_POST['cells']) * 1000000000.0; $sql .= "', tolerance='" . $_POST['tolerance']; ($_POST['sta1'] == 'true') ? $sql .= "', sta1='1" : $sql .= "', sta1='0"; ($_POST['bacteria'] == 'true') ? $sql .= "', bacteria='1" : $sql .= "', bacteria='0"; ($_POST['harvest_top'] == 'true') ? $sql .= "', harvest_top='1" : $sql .= "', harvest_top='0"; $sql .= "', harvest_time='" . $_POST['harvest_time']; $sql .= "', pitch_temperature='" . floatval($_POST['pitch_temperature']); ($_POST['pofpos'] == 'true') ? $sql .= "', pofpos='1" : $sql .= "', pofpos='0"; $sql .= "', zymocide='" . $_POST['zymocide']; $sql .= "', inventory='" . $_POST['inventory']; $sql .= "', cost='" . $_POST['cost'] . "'"; if ($_POST['production_date'] == '') $sql .= ", production_date=NULL"; else $sql .= ", production_date='" . $_POST['production_date'] . "'"; if ($_POST['tht_date'] == '') $sql .= ", tht_date=NULL"; else $sql .= ", tht_date='" . $_POST['tht_date'] . "'"; if (isset($_POST['insert'])) { $sql .= ";"; } if (isset($_POST['update'])) { $sql .= " WHERE record='" . $_POST['record'] . "';"; } syslog(LOG_NOTICE, $sql); $result = mysqli_query($connect, $sql); if (! $result) { syslog(LOG_NOTICE, "db_inventory_yeasts: ".$sql." result: ".mysqli_error($connect)); } else { if (isset($_POST['update'])) { syslog(LOG_NOTICE, "db_inventory_yeasts: updated record ".$_POST['record']); } else { $lastid = mysqli_insert_id($connect); syslog(LOG_NOTICE, "db_inventory_yeasts: inserted record ".$lastid); } } echo $result; } else if (isset($_POST['delete'])) { // DELETE COMMAND $sql = "DELETE FROM `inventory_yeasts` WHERE record='".$_POST['record']."';"; $result = mysqli_query($connect, $sql); if (! $result) { syslog(LOG_NOTICE, "db_inventory_yeasts: ".$sql." result: ".mysqli_error($connect)); } else { syslog(LOG_NOTICE, "db_inventory_yeasts: deleted record ".$_POST['record']); } echo $result; } else { // SELECT COMMAND $query = "SELECT * FROM inventory_yeasts ORDER BY laboratory,product_id,name"; $result = mysqli_query($connect, $query) or die("SQL Error 1: " . mysqli_error($connect)); while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { $yeasts[] = array( 'record' => $row['record'], 'name' => $row['name'], 'type' => $yeasttype[$row['type']], 'form' => $yeastform[$row['form']], 'laboratory' => $row['laboratory'], 'product_id' => $row['product_id'], 'min_temperature' => $row['min_temperature'], 'max_temperature' => $row['max_temperature'], 'flocculation' => $row['flocculation'], 'attenuation' => $row['attenuation'], 'notes' => $row['notes'], 'best_for' => $row['best_for'], 'max_reuse' => $row['max_reuse'], 'inventory' => $row['inventory'], 'cost' => $row['cost'], 'production_date' => $row['production_date'], 'tht_date' => $row['tht_date'], 'cells' => floatval($row['cells']) / 1000000000.0, 'tolerance' => $row['tolerance'], 'sta1' => $row['sta1'], 'bacteria' => $row['bacteria'], 'harvest_top' => $row['harvest_top'], 'harvest_time' => $row['harvest_time'], 'pitch_temperature' => floatval($row['pitch_temperature']), 'pofpos' => $row['pofpos'], 'zymocide' => $row['zymocide'] ); } header("Content-type: application/json"); echo json_encode($yeasts); } ?>