# HG changeset patch # User Michiel Broek # Date 1548511389 -3600 # Node ID dc30801e6961b5c2eaba6f3cabf8997575a7b0fd # Parent 578c78abf058e8cc32639710dbe3bba777eeb38c Import set tun_material from the specifix heat value. Equipment database uses POST instead of GET. Equipment editor screen in style with other inventory screens. In stock print now uses the type indexes to translate to text. Also show the correct unit and values of the yeast. diff -r 578c78abf058 -r dc30801e6961 www/import/from_brouwhulp.php --- a/www/import/from_brouwhulp.php Sat Jan 26 11:59:15 2019 +0100 +++ b/www/import/from_brouwhulp.php Sat Jan 26 15:03:09 2019 +0100 @@ -447,7 +447,16 @@ $sql .= "', tun_volume='" . floatval($equipment->TUN_VOLUME); $sql .= "', tun_weight='" . floatval($equipment->TUN_WEIGHT); $sql .= "', tun_specific_heat='" . floatval($equipment->TUN_SPECIFIC_HEAT); - $sql .= "', tun_material='" . mysqli_real_escape_string($db, $equipment->TUN_MATERIAL); + if (floatval($equipment->TUN_SPECIFIC_HEAT) == 0.11) + $sql .= "', tun_material='0"; + else if (floatval($equipment->TUN_SPECIFIC_HEAT) == 0.22) + $sql .= "', tun_material='1"; + else if (floatval($equipment->TUN_SPECIFIC_HEAT) == 0.46) + $sql .= "', tun_material='2"; + else if (floatval($equipment->TUN_SPECIFIC_HEAT) == 0.092) + $sql .= "', tun_material='3"; + else + echo "Unknown TUN_SPECIFIC_HEAT" . $equipment->TUN_SPECIFIC_HEAT . PHP_EOL; $sql .= "', tun_height='" . floatval($equipment->TUN_HEIGHT); $sql .= "', top_up_water='" . floatval($equipment->TOP_UP_WATER); $sql .= "', trub_chiller_loss='" . floatval($equipment->TRUB_CHILLER_LOSS); diff -r 578c78abf058 -r dc30801e6961 www/includes/db_inventory_equipments.php --- a/www/includes/db_inventory_equipments.php Sat Jan 26 11:59:15 2019 +0100 +++ b/www/includes/db_inventory_equipments.php Sat Jan 26 15:03:09 2019 +0100 @@ -9,53 +9,51 @@ } mysqli_set_charset($connect, "utf8" ); -// get data and store in a json array -$query = "SELECT * FROM inventory_equipments ORDER BY name"; -if (isset($_GET['insert']) || isset($_GET['update'])) { - if (isset($_GET['insert'])) { +if (isset($_POST['insert']) || isset($_POST['update'])) { + if (isset($_POST['insert'])) { // INSERT COMMAND $sql = "INSERT INTO `inventory_equipments` SET "; } - if (isset($_GET['update'])) { + if (isset($_POST['update'])) { // UPDATE COMMAND $sql = "UPDATE `inventory_equipments` SET "; } - $sql .= "name='" . mysqli_real_escape_string($connect, $_GET['name']); - $sql .= "', boil_size='" . $_GET['boil_size']; - $sql .= "', batch_size='" . $_GET['batch_size']; - $sql .= "', tun_volume='" . $_GET['tun_volume']; - $sql .= "', tun_weight='" . $_GET['tun_weight']; - $sql .= "', tun_specific_heat='" . $_GET['tun_specific_heat']; - $sql .= "', tun_material='" . mysqli_real_escape_string($connect, $_GET['tun_material']); - $sql .= "', tun_height='" . $_GET['tun_height'] / 100.0; - $sql .= "', top_up_water='" . $_GET['top_up_water']; - $sql .= "', trub_chiller_loss='" . $_GET['trub_chiller_loss']; - $sql .= "', evap_rate='" . $_GET['evap_rate']; - $sql .= "', boil_time='" . $_GET['boil_time']; - ($_GET['calc_boil_volume'] == 'true') ? $sql .= "', calc_boil_volume='1" : $sql .= "', calc_boil_volume='0"; - $sql .= "', top_up_kettle='" . $_GET['top_up_kettle']; - $sql .= "', hop_utilization='" . $_GET['hop_utilization']; - $sql .= "', notes='" . mysqli_real_escape_string($connect, $_GET['notes']); - $sql .= "', lauter_volume='" . $_GET['lauter_volume']; - $sql .= "', lauter_height='" . $_GET['lauter_height'] / 100.0; - $sql .= "', lauter_deadspace='" . $_GET['lauter_deadspace']; - $sql .= "', kettle_volume='" . $_GET['kettle_volume']; - $sql .= "', kettle_height='" . $_GET['kettle_height'] / 100.0; - $sql .= "', mash_volume='" . $_GET['mash_volume']; - $sql .= "', mash_max='" . $_GET['mash_max']; - $sql .= "', efficiency='" . $_GET['efficiency']; - if (isset($_GET['insert'])) { + $sql .= "name='" . mysqli_real_escape_string($connect, $_POST['name']); + $sql .= "', boil_size='" . $_POST['boil_size']; + $sql .= "', batch_size='" . $_POST['batch_size']; + $sql .= "', tun_volume='" . $_POST['tun_volume']; + $sql .= "', tun_weight='" . $_POST['tun_weight']; + $sql .= "', tun_specific_heat='" . $_POST['tun_specific_heat']; + $sql .= "', tun_material='" . $_POST['tun_material']; + $sql .= "', tun_height='" . floatval($_POST['tun_height']) / 100.0; + $sql .= "', top_up_water='" . $_POST['top_up_water']; + $sql .= "', trub_chiller_loss='" . $_POST['trub_chiller_loss']; + $sql .= "', evap_rate='" . $_POST['evap_rate']; + $sql .= "', boil_time='" . $_POST['boil_time']; + ($_POST['calc_boil_volume'] == 'true') ? $sql .= "', calc_boil_volume='1" : $sql .= "', calc_boil_volume='0"; + $sql .= "', top_up_kettle='" . $_POST['top_up_kettle']; + $sql .= "', hop_utilization='" . $_POST['hop_utilization']; + $sql .= "', notes='" . mysqli_real_escape_string($connect, $_POST['notes']); + $sql .= "', lauter_volume='" . $_POST['lauter_volume']; + $sql .= "', lauter_height='" . floatval($_POST['lauter_height']) / 100.0; + $sql .= "', lauter_deadspace='" . $_POST['lauter_deadspace']; + $sql .= "', kettle_volume='" . $_POST['kettle_volume']; + $sql .= "', kettle_height='" . floatval($_POST['kettle_height']) / 100.0; + $sql .= "', mash_volume='" . $_POST['mash_volume']; + $sql .= "', mash_max='" . $_POST['mash_max']; + $sql .= "', efficiency='" . $_POST['efficiency']; + if (isset($_POST['insert'])) { $sql .= "';"; } - if (isset($_GET['update'])) { - $sql .= "' WHERE record='" . $_GET['record'] . "';"; + if (isset($_POST['update'])) { + $sql .= "' WHERE record='" . $_POST['record'] . "';"; } $result = mysqli_query($connect, $sql); if (! $result) { syslog(LOG_NOTICE, "db_inventory_equipment: ".$sql." result: ".mysqli_error($connect)); } else { - if (isset($_GET['update'])) { - syslog(LOG_NOTICE, "db_inventory_equipment: updated record ".$_GET['record']); + if (isset($_POST['update'])) { + syslog(LOG_NOTICE, "db_inventory_equipment: updated record ".$_POST['record']); } else { $lastid = mysqli_insert_id($connect); syslog(LOG_NOTICE, "db_inventory_equipment: inserted record ".$lastid); @@ -63,20 +61,21 @@ } echo $result; -} else if (isset($_GET['delete'])) { +} else if (isset($_POST['delete'])) { // DELETE COMMAND // FIXME: need to check if the record is in use - $sql = "DELETE FROM `inventory_equipments` WHERE record='".$_GET['record']."';"; + $sql = "DELETE FROM `inventory_equipments` WHERE record='".$_POST['record']."';"; $result = mysqli_query($connect, $sql); if (! $result) { syslog(LOG_NOTICE, "db_inventory_equipment: ".$sql." result: ".mysqli_error($connect)); } else { - syslog(LOG_NOTICE, "db_inventory_equipment: deleted record ".$_GET['record']); + syslog(LOG_NOTICE, "db_inventory_equipment: deleted record ".$_POST['record']); } echo $result; } else { // SELECT COMMAND + $query = "SELECT * FROM inventory_equipments ORDER BY name"; $result = mysqli_query($connect, $query) or die("SQL Error 1: " . mysqli_error($connect)); while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { $equipments[] = array( @@ -88,7 +87,7 @@ 'tun_weight' => $row['tun_weight'], 'tun_specific_heat' => $row['tun_specific_heat'], 'tun_material' => $row['tun_material'], - 'tun_height' => $row['tun_height'] * 100.0, + 'tun_height' => floatval($row['tun_height']) * 100.0, 'top_up_water' => $row['top_up_water'], 'trub_chiller_loss' => $row['trub_chiller_loss'], 'evap_rate' => $row['evap_rate'], @@ -98,10 +97,10 @@ 'hop_utilization' => $row['hop_utilization'], 'notes' => $row['notes'], 'lauter_volume' => $row['lauter_volume'], - 'lauter_height' => $row['lauter_height'] * 100.0, + 'lauter_height' => floatval($row['lauter_height']) * 100.0, 'lauter_deadspace' => $row['lauter_deadspace'], 'kettle_volume' => $row['kettle_volume'], - 'kettle_height' => $row['kettle_height'] * 100.0, + 'kettle_height' => floatval($row['kettle_height']) * 100.0, 'mash_volume' => $row['mash_volume'], 'mash_max' => $row['mash_max'], 'efficiency' => $row['efficiency'] diff -r 578c78abf058 -r dc30801e6961 www/inv_equipments.php --- a/www/inv_equipments.php Sat Jan 26 11:59:15 2019 +0100 +++ b/www/inv_equipments.php Sat Jan 26 15:03:09 2019 +0100 @@ -13,7 +13,7 @@