Fri, 28 Sep 2018 17:29:23 +0200
Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
<?php require($_SERVER['DOCUMENT_ROOT']."/config.php"); require($_SERVER['DOCUMENT_ROOT']."/version.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()); } // get data and store in a json array $query = "SELECT * FROM inventory_equipments ORDER BY name"; if (isset($_GET['insert'])) { // INSERT COMMAND $sql = "INSERT INTO `inventory_equipments` SET name='" . mysqli_real_escape_string($connect, $_GET['name']); $sql .= "', boil_size='" . $_GET['boil_size']; $sql .= "', tun_volume='" . $_GET['tun_volume']; $sql .= "', tun_weight='" . $_GET['tun_weight']; $sql .= "', trub_chiller_loss='" . $_GET['trub_chiller_loss']; $sql .= "', evap_rate='" . $_GET['evap_rate']; $sql .= "', boil_time='" . $_GET['boil_time']; $sql .= "', calc_boil_volume='Y"; $batch = '$_GET[\'boil_size\'] - ($_GET[\'evap_rate\'] * ($_GET[\'boil_time\'] / 60))'; $sql .= "', batch_size='" . eval('return ' . $batch . ';'); $sql .= "', lauter_deadspace='" . $_GET['lauter_deadspace']; $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 .= "', kettle_volume='" . $_GET['kettle_volume']; $material = mysqli_real_escape_string($connect, $_GET['tun_material']); $sql .= "', tun_material='" . $material; if ($material == "RVS") { $sql .= "', tun_specific_heat='0.11"; } else if ($material == "Aluminium") { $sql .= "', tun_specific_heat='0.22"; } else if ($material == "Kunststof") { $sql .= "', tun_specific_heat='0.46"; } else if ($material == "Koper") { $sql .= "', tun_specific_heat='0.092"; } $sql .= "', tun_height='" . $_GET['tun_height'] / 100.0; $sql .= "', kettle_height='" . $_GET['kettle_height'] / 100.0; $sql .= "', lauter_height='" . $_GET['lauter_height'] / 100.0; $sql .= "', mash_volume='" . $_GET['mash_volume']; $sql .= "', efficiency='" . $_GET['efficiency']; $sql .= "';"; $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: inserted ".$_GET['name']); } echo $result; } else if (isset($_GET['update'])) { // UPDATE COMMAND $sql = "UPDATE `inventory_equipments` SET name='" . mysqli_real_escape_string($connect, $_GET['name']); $sql .= "', boil_size='" . $_GET['boil_size']; $sql .= "', tun_volume='" . $_GET['tun_volume']; $sql .= "', tun_weight='" . $_GET['tun_weight']; $sql .= "', trub_chiller_loss='" . $_GET['trub_chiller_loss']; $sql .= "', evap_rate='" . $_GET['evap_rate']; $sql .= "', boil_time='" . $_GET['boil_time']; $sql .= "', calc_boil_volume='Y"; $batch = '$_GET[\'boil_size\'] - ($_GET[\'evap_rate\'] * ($_GET[\'boil_time\'] / 60))'; $sql .= "', batch_size='" . eval('return ' . $batch . ';'); $sql .= "', lauter_deadspace='" . $_GET['lauter_deadspace']; $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 .= "', kettle_volume='" . $_GET['kettle_volume']; $material = mysqli_real_escape_string($connect, $_GET['tun_material']); $sql .= "', tun_material='" . $material; if ($material == "RVS") { $sql .= "', tun_specific_heat='0.11"; } else if ($material == "Aluminium") { $sql .= "', tun_specific_heat='0.22"; } else if ($material == "Kunststof") { $sql .= "', tun_specific_heat='0.46"; } else if ($material == "Koper") { $sql .= "', tun_specific_heat='0.092"; } $sql .= "', tun_height='" . $_GET['tun_height'] / 100.0; $sql .= "', kettle_height='" . $_GET['kettle_height'] / 100.0; $sql .= "', lauter_height='" . $_GET['lauter_height'] / 100.0; $sql .= "', mash_volume='" . $_GET['mash_volume']; $sql .= "', efficiency='" . $_GET['efficiency']; $sql .= "' WHERE record='" . $_GET['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: updated record ".$_GET['record']); } echo $result; } else if (isset($_GET['delete'])) { // DELETE COMMAND // FIXME: need to check if the record is in use $sql = "DELETE FROM `inventory_equipments` WHERE record='".$_GET['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']); } echo $result; } else { // SELECT COMMAND $result = mysqli_query($connect, $query) or die("SQL Error 1: " . mysqli_error($connect)); while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { $equipments[] = array( 'record' => $row['record'], 'name' => $row['name'], 'boil_size' => $row['boil_size'], 'batch_size' => $row['batch_size'], 'tun_volume' => $row['tun_volume'], 'tun_weight' => $row['tun_weight'], 'top_up_water' => $row['top_up_water'], 'trub_chiller_loss' => $row['trub_chiller_loss'], 'evap_rate' => $row['evap_rate'], 'boil_time' => $row['boil_time'], 'lauter_deadspace' => $row['lauter_deadspace'], 'top_up_kettle' => $row['top_up_kettle'], 'hop_utilization' => $row['hop_utilization'], 'notes' => $row['notes'], 'lauter_volume' => $row['lauter_volume'], 'kettle_volume' => $row['kettle_volume'], 'tun_material' => $row['tun_material'], 'tun_height' => $row['tun_height'] * 100.0, 'kettle_height' => $row['kettle_height'] * 100.0, 'lauter_height' => $row['lauter_height'] * 100.0, 'mash_volume' => $row['mash_volume'], 'efficiency' => $row['efficiency'] ); } echo json_encode($equipments); } ?>