# HG changeset patch # User Michiel Broek # Date 1543530102 -3600 # Node ID ad31f4bd4036da9ef4e37e503d0c5ad28d9b65bc # Parent 4935e86b2775836b3262ea7d9186c120151926e9 Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table. diff -r 4935e86b2775 -r ad31f4bd4036 www/includes/db_inventory_equipments.php --- a/www/includes/db_inventory_equipments.php Wed Nov 28 21:57:06 2018 +0100 +++ b/www/includes/db_inventory_equipments.php Thu Nov 29 23:21:42 2018 +0100 @@ -11,26 +11,22 @@ // 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']); +if (isset($_GET['insert']) || isset($_GET['update'])) { + if (isset($_GET['insert'])) { + // INSERT COMMAND + $sql = "INSERT INTO `inventory_equipments` SET "; + } + if (isset($_GET['update'])) { + // UPDATE COMMAND + $sql = "UPDATE `inventory_equipments` SET "; + } + $sql .= "name='" . mysqli_real_escape_string($connect, $_GET['name']); $sql .= "', boil_size='" . $_GET['boil_size']; + $batch = '$_GET[\'boil_size\'] - ($_GET[\'evap_rate\'] * ($_GET[\'boil_time\'] / 60))'; + $sql .= "', batch_size='" . eval('return ' . $batch . ';'); $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") { @@ -40,60 +36,39 @@ } else if ($material == "Koper") { $sql .= "', tun_specific_heat='0.092"; } + $sql .= "', tun_material='" . $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 .= "', lauter_height='" . $_GET['lauter_height'] / 100.0; $sql .= "', mash_volume='" . $_GET['mash_volume']; $sql .= "', efficiency='" . $_GET['efficiency']; - $sql .= "';"; + if (isset($_GET['insert'])) { + $sql .= "';"; + } + if (isset($_GET['update'])) { + $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: 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']); + if (isset($_GET['update'])) { + syslog(LOG_NOTICE, "db_inventory_equipment: updated record ".$_GET['record']); + } else { + $lastid = mysqli_insert_id($connect); + syslog(LOG_NOTICE, "db_inventory_equipment: inserted record ".$lastid); + } } echo $result; @@ -120,20 +95,22 @@ 'batch_size' => $row['batch_size'], 'tun_volume' => $row['tun_volume'], 'tun_weight' => $row['tun_weight'], + 'tun_specific_heat' => $row['tun_specific_heat'], + 'tun_material' => $row['tun_material'], + 'tun_height' => $row['tun_height'] * 100.0, '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'], + 'calc_boil_volume' => $row['calc_boil_volume'], 'top_up_kettle' => $row['top_up_kettle'], 'hop_utilization' => $row['hop_utilization'], 'notes' => $row['notes'], 'lauter_volume' => $row['lauter_volume'], + 'lauter_height' => $row['lauter_height'] * 100.0, + 'lauter_deadspace' => $row['lauter_deadspace'], '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'] ); diff -r 4935e86b2775 -r ad31f4bd4036 www/includes/db_product.php --- a/www/includes/db_product.php Wed Nov 28 21:57:06 2018 +0100 +++ b/www/includes/db_product.php Thu Nov 29 23:21:42 2018 +0100 @@ -10,6 +10,9 @@ } mysqli_set_charset($connect, "utf8" ); +$escapers = array("\\", "/", "\"", "\n", "\r", "\t", "\x08", "\x0c"); +$replacements = array("\\\\", "\\/", "\\\"", "\\n", "\\r", "\\t", "\\f", "\\b"); + if (isset($_POST['insert']) || isset($_POST['update'])) { if (isset($_POST['insert'])) { @@ -60,7 +63,7 @@ $sql .= "', eq_kettle_height='" . $_POST['eq_kettle_height']; $sql .= "', eq_mash_volume='" . $_POST['eq_mash_volume']; $sql .= "', eq_efficiency='" . $_POST['eq_efficiency']; - + $sql .= "', eq_top_up_water='" . $_POST['eq_top_up_water']; syslog(LOG_NOTICE, $sql); if (isset($_POST['insert'])) { @@ -70,18 +73,19 @@ $sql .= "' WHERE record='" . $_POST['record'] . "';"; } - $result = mysqli_query($connect, $sql); - if (! $result) { - syslog(LOG_NOTICE, "db_product: result: ".mysqli_error($connect)); - } else { - if (isset($_POST['update'])) { - syslog(LOG_NOTICE, "db_product: updated record ".$_POST['record']); - } else { - $lastid = mysqli_insert_id($connect); - syslog(LOG_NOTICE, "db_product: inserted record ".$lastid); - } - } - echo $result; + +// $result = mysqli_query($connect, $sql); +// if (! $result) { +// syslog(LOG_NOTICE, "db_product: result: ".mysqli_error($connect)); +// } else { +// if (isset($_POST['update'])) { +// syslog(LOG_NOTICE, "db_product: updated record ".$_POST['record']); +// } else { +// $lastid = mysqli_insert_id($connect); +// syslog(LOG_NOTICE, "db_product: inserted record ".$lastid); +// } +// } +// echo $result; } else if (isset($_POST['delete'])) { // DELETE COMMAND @@ -120,107 +124,167 @@ /* * Default, select all */ - $query = "SELECT * FROM prod_main ORDER BY birth,code;"; + if (isset($_GET['record'])) { + syslog(LOG_NOTICE, "Request record GET " . $_GET['record']); + } else if (isset($_POST['record'])) { + syslog(LOG_NOTICE, "Request record POST " . $_POST['record']); + } else { + syslog(LOG_NOTICE, "No record requested"); + } + $query = "SELECT * FROM prod_main LEFT JOIN prod_recipes ON prod_main.uuid = prod_recipes.uuid ORDER BY birth,code;"; $result = mysqli_query($connect, $query) or die("SQL Error 1: " . mysqli_error($connect)); + $brews = '['; + $comma = FALSE; while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { - $brews[] = array( - 'record' => $row['record'], - 'uuid' => $row['uuid'], - 'name' => $row['name'], - 'code' => $row['code'], - 'birth' => $row['birth'], - 'stage' => $row['stage'], - 'notes' => $row['notes'], - 'log_brew' => $row['log_brew'], - 'log_fermentation' => $row['log_fermentation'], - 'inventory_reduced' => $row['inventory_reduced'], - 'locked' => $row['locked'], - 'eq_name' => $row['eq_name'], - 'eq_notes' => $row['eq_notes'], - 'eq_boil_size' => $row['eq_boil_size'], - 'eq_batch_size' => $row['eq_batch_size'], - 'eq_tun_volume' => $row['eq_tun_volume'], - 'eq_tun_weight' => $row['eq_tun_weight'], - 'eq_tun_specific_heat' => $row['eq_tun_specific_heat'], - 'eq_tun_material' => $row['eq_tun_material'], - 'eq_tun_height' => $row['eq_tun_height'], - 'eq_top_up_water' => $row['eq_top_up_water'], - 'eq_trub_chiller_loss' => $row['eq_trub_chiller_loss'], - 'eq_evap_rate' => $row['eq_evap_rate'], - 'eq_boil_time' => $row['eq_boil_time'], - 'eq_calc_boil_volume' => $row['eq_calc_boil_volume'], - 'eq_top_up_kettle' => $row['eq_top_up_kettle'], - 'eq_hop_utilization' => $row['eq_hop_utilization'], - 'eq_lauter_volume' => $row['eq_lauter_volume'], - 'eq_lauter_height' => $row['eq_lauter_height'], - 'eq_lauter_deadspace' => $row['eq_lauter_deadspace'], - 'eq_kettle_volume' => $row['eq_kettle_volume'], - 'eq_kettle_height' => $row['eq_kettle_height'], - 'eq_mash_volume' => $row['eq_mash_volume'], - 'eq_efficiency' => $row['eq_efficiency'], - 'brew_date_start' => $row['brew_date_start'], - 'brew_mash_ph' => $row['brew_mash_ph'], - 'brew_mash_sg' => $row['brew_mash_sg'], - 'brew_sparge_temperature' => $row['brew_sparge_temperature'], - 'brew_sparge_volume' => $row['brew_sparge_volume'], - 'brew_preboil_volume' => $row['brew_preboil_volume'], - 'brew_preboil_sg' => $row['brew_preboil_sg'], - 'brew_preboil_ph' => $row['brew_preboil_ph'], - 'brew_aboil_volume' => $row['brew_aboil_volume'], - 'brew_aboil_sg' => $row['brew_aboil_sg'], - 'brew_aboil_ph' => $row['brew_aboil_ph'], - 'brew_aboil_efficiency' => $row['brew_aboil_efficiency'], - 'brew_cooling_method' => $row['brew_cooling_method'], - 'brew_cooling_time' => $row['brew_cooling_time'], - 'brew_cooling_to' => $row['brew_cooling_to'], - 'brew_whirlpool9' => $row['brew_whirlpool9'], - 'brew_whirlpool7' => $row['brew_whirlpool7'], - 'brew_whirlpool6' => $row['brew_whirlpool6'], - 'brew_whirlpool2' => $row['brew_whirlpool2'], - 'brew_fermenter_volume' => $row['brew_fermenter_volume'], - 'brew_fermenter_extrawater' => $row['brew_fermenter_extrawater'], - 'brew_aeration_time' => $row['brew_aeration_time'], - 'brew_aeration_speed' => $row['brew_aeration_speed'], - 'brew_aeration_type' => $row['brew_aeration_type'], - 'brew_fermenter_sg' => $row['brew_fermenter_sg'], - 'brew_fermenter_ibu' => $row['brew_fermenter_ibu'], - 'brew_date_end' => $row['brew_date_end'], - 'brew_log_available' => $row['brew_log_available'], - 'primary_start_temp' => $row['primary_start_temp'], - 'primary_max_temp' => $row['primary_max_temp'], - 'primary_end_temp' => $row['primary_end_temp'], - 'primary_end_sg' => $row['primary_end_sg'], - 'primary_end_date' => $row['primary_end_date'], - 'secondary_temp' => $row['secondary_temp'], - 'secondary_end_date' => $row['secondary_end_date'], - 'tertiary_temp' => $row['tertiary_temp'], - 'package_date' => $row['package_date'], - 'bottle_amount' => $row['bottle_amount'], - 'bottle_carbonation' => $row['bottle_carbonation'], - 'bottle_priming_sugar' => $row['bottle_priming_sugar'], - 'bottle_priming_amount' => $row['bottle_priming_amount'], - 'bottle_carbonation_temp' => $row['bottle_carbonation_temp'], - 'keg_amount' => $row['keg_amount'], - 'keg_carbonation' => $row['keg_carbonation'], - 'keg_priming_sugar' => $row['keg_priming_sugar'], - 'keg_priming_amount' => $row['keg_priming_amount'], - 'keg_carbonation_temp' => $row['keg_carbonation_temp'], - 'keg_forced_carb' => $row['keg_forced_carb'], - 'keg_pressure' => $row['keg_pressure'], - 'keg_priming_factor' => $row['keg_priming_factor'], - 'taste_notes' => $row['taste_notes'], - 'taste_rate' => $row['taste_rate'], - 'taste_date' => $row['taste_date'], - 'taste_color' => $row['taste_color'], - 'taste_transparency' => $row['taste_transparency'], - 'taste_head' => $row['taste_head'], - 'taste_aroma' => $row['taste_aroma'], - 'taste_taste' => $row['taste_taste'], - 'taste_mouthfeel' => $row['taste_mouthfeel'], - 'taste_aftertaste' => $row['taste_aftertaste'] - ); + // Manual encode to JSON. + if ($comma) + $brews .= ','; + $comma = TRUE; + $brew = '{"record":' . $row['record']; + $brew .= ',"uuid":"' . str_replace($escapers, $replacements, $row['uuid']); + $brew .= '","name":"' . str_replace($escapers, $replacements, $row['name']); + $brew .= '","code":"' . str_replace($escapers, $replacements, $row['code']); + $brew .= '","birth":"' . str_replace($escapers, $replacements, $row['birth']); + $brew .= '","stage":"' . str_replace($escapers, $replacements, $row['stage']); + $brew .= '","notes":"' . str_replace($escapers, $replacements, $row['notes']); + $brew .= '","log_brew":' . $row['log_brew']; + $brew .= ',"log_fermentation":' . $row['log_fermentation']; + $brew .= ',"inventory_reduced":' . $row['inventory_reduced']; + $brew .= ',"locked":' . $row['locked']; + $brew .= ',"eq_name":"' . str_replace($escapers, $replacements, $row['eq_name']); + $brew .= '","eq_notes":"' . str_replace($escapers, $replacements, $row['eq_notes']); + $brew .= '","eq_boil_size":' . floatval($row['eq_boil_size']); + $brew .= ',"eq_batch_size":' . floatval($row['eq_batch_size']); + $brew .= ',"eq_tun_volume":' . floatval($row['eq_tun_volume']); + $brew .= ',"eq_tun_weight":' . floatval($row['eq_tun_weight']); + $brew .= ',"eq_tun_specific_heat":' . floatval($row['eq_tun_specific_heat']); + $brew .= ',"eq_tun_material":"' . $row['eq_tun_material']; + $brew .= '","eq_tun_height":' . floatval($row['eq_tun_height']); + $brew .= ',"eq_top_up_water":' . floatval($row['eq_top_up_water']); + $brew .= ',"eq_trub_chiller_loss":' . floatval($row['eq_trub_chiller_loss']); + $brew .= ',"eq_evap_rate":' . floatval($row['eq_evap_rate']); + $brew .= ',"eq_boil_time":' . floatval($row['eq_boil_time']); + $brew .= ',"eq_calc_boil_volume":' . $row['eq_calc_boil_volume']; + $brew .= ',"eq_calc_boil_volume":' . floatval($row['eq_calc_boil_volume']); + $brew .= ',"eq_top_up_kettle":' . floatval($row['eq_top_up_kettle']); + $brew .= ',"eq_hop_utilization":' . floatval($row['eq_hop_utilization']); + $brew .= ',"eq_lauter_volume":' . floatval($row['eq_lauter_volume']); + $brew .= ',"eq_lauter_height":' . floatval($row['eq_lauter_height']); + $brew .= ',"eq_lauter_deadspace":' . floatval($row['eq_lauter_deadspace']); + $brew .= ',"eq_kettle_volume":' . floatval($row['eq_kettle_volume']); + $brew .= ',"eq_kettle_height":' . floatval($row['eq_kettle_height']); + $brew .= ',"eq_mash_volume":' . floatval($row['eq_mash_volume']); + $brew .= ',"eq_efficiency":' . floatval($row['eq_efficiency']); + $brew .= ',"eq_top_up_water":' . floatval($row['eq_top_up_water']); + $brew .= ',"brew_date_start":"' . $row['brew_date_start']; + $brew .= '","brew_mash_ph":' . floatval($row['brew_mash_ph']); + $brew .= ',"brew_mash_sg":' . floatval($row['brew_mash_sg']); + $brew .= ',"brew_sparge_temperature":' . floatval($row['brew_sparge_temperature']); + $brew .= ',"brew_sparge_volume":' . floatval($row['brew_sparge_volume']); + $brew .= ',"brew_preboil_volume":' . floatval($row['brew_preboil_volume']); + $brew .= ',"brew_preboil_sg":' . floatval($row['brew_preboil_sg']); + $brew .= ',"brew_preboil_ph":' . floatval($row['brew_preboil_ph']); + $brew .= ',"brew_aboil_volume":' . floatval($row['brew_aboil_volume']); + $brew .= ',"brew_aboil_sg":' . floatval($row['brew_aboil_sg']); + $brew .= ',"brew_aboil_ph":' . floatval($row['brew_aboil_ph']); + $brew .= ',"brew_aboil_efficiency":' . floatval($row['brew_aboil_efficiency']); + $brew .= ',"brew_cooling_method":"' . $row['brew_cooling_method']; + $brew .= '","brew_cooling_time":' . floatval($row['brew_cooling_time']); + $brew .= ',"brew_cooling_to":' . floatval($row['brew_cooling_to']); + $brew .= ',"brew_whirlpool9":' . floatval($row['brew_whirlpool9']); + $brew .= ',"brew_whirlpool7":' . floatval($row['brew_whirlpool7']); + $brew .= ',"brew_whirlpool6":' . floatval($row['brew_whirlpool6']); + $brew .= ',"brew_whirlpool2":' . floatval($row['brew_whirlpool2']); + $brew .= ',"brew_fermenter_volume":' . floatval($row['brew_fermenter_volume']); + $brew .= ',"brew_fermenter_extrawater":' . floatval($row['brew_fermenter_extrawater']); + $brew .= ',"brew_aeration_time":' . floatval($row['brew_aeration_time']); + $brew .= ',"brew_aeration_speed":' . floatval($row['brew_aeration_speed']); + $brew .= ',"brew_aeration_type":' . floatval($row['brew_aeration_type']); + $brew .= ',"brew_fermenter_sg":' . floatval($row['brew_fermenter_sg']); + $brew .= ',"brew_fermenter_ibu":' . floatval($row['brew_fermenter_ibu']); + $brew .= ',"brew_date_end":"' . $row['brew_date_end']; + $brew .= '","brew_log_available":' . $row['brew_log_available']; + $brew .= ',"primary_start_temp":' . floatval($row['primary_start_temp']); + $brew .= ',"primary_max_temp":' . floatval($row['primary_max_temp']); + $brew .= ',"primary_end_temp":' . floatval($row['primary_end_temp']); + $brew .= ',"primary_end_sg":' . floatval($row['primary_end_sg']); + $brew .= ',"primary_end_date":"' . $row['primary_end_date']; + $brew .= '","secondary_temp":' . floatval($row['secondary_temp']); + $brew .= ',"secondary_end_date":"' . $row['secondary_end_date']; + $brew .= '","tertiary_temp":' . floatval($row['tertiary_temp']); + $brew .= ',"package_date":"' . $row['package_date']; + $brew .= '","bottle_amount":' . floatval($row['bottle_amount']); + $brew .= ',"bottle_carbonation":' . floatval($row['bottle_carbonation']); + $brew .= ',"bottle_priming_sugar":"' . str_replace($escapers, $replacements, $row['bottle_priming_sugar']); + $brew .= '","bottle_priming_amount":' . floatval($row['bottle_priming_amount']); + $brew .= ',"bottle_carbonation_temp":' . floatval($row['bottle_carbonation_temp']); + $brew .= ',"keg_amount":' . floatval($row['keg_amount']); + $brew .= ',"keg_carbonation":' . floatval($row['keg_carbonation']); + $brew .= ',"keg_priming_sugar":"' . str_replace($escapers, $replacements, $row['keg_priming_sugar']); + $brew .= '","keg_priming_amount":' . floatval($row['keg_priming_amount']); + $brew .= ',"keg_carbonation_temp":' . floatval($row['keg_carbonation_temp']); + $brew .= ',"keg_forced_carb":' . floatval($row['keg_forced_carb']); + $brew .= ',"keg_pressure":' . floatval($row['keg_pressure']); + $brew .= ',"keg_priming_factor":' . floatval($row['keg_priming_factor']); + $brew .= ',"taste_notes":"' . str_replace($escapers, $replacements, $row['taste_notes']); + $brew .= '","taste_rate":' . floatval($row['taste_rate']); + $brew .= ',"taste_date":"' . str_replace($escapers, $replacements, $row['taste_date']); + $brew .= '","taste_color":"' . str_replace($escapers, $replacements, $row['taste_color']); + $brew .= '","taste_transparency":"' . str_replace($escapers, $replacements, $row['taste_transparency']); + $brew .= '","taste_head":"' . str_replace($escapers, $replacements, $row['taste_head']); + $brew .= '","taste_aroma":"' . str_replace($escapers, $replacements, $row['taste_aroma']); + $brew .= '","taste_taste":"' . str_replace($escapers, $replacements, $row['taste_taste']); + $brew .= '","taste_mouthfeel":"' . str_replace($escapers, $replacements, $row['taste_mouthfeel']); + $brew .= '","taste_aftertaste":"' . str_replace($escapers, $replacements, $row['taste_aftertaste']); + $brew .= '","st_guide":"' . str_replace($escapers, $replacements, $row['st_guide']); + $brew .= '","st_letter":"' . str_replace($escapers, $replacements, $row['st_letter']); + $brew .= '","st_name":"' . str_replace($escapers, $replacements, $row['st_name']); + $brew .= '","st_type":"' . str_replace($escapers, $replacements, $row['st_type']); + $brew .= '","st_category":"' . str_replace($escapers, $replacements, $row['st_category']); + $brew .= '","st_category_number":' . floatval($row['st_category_number']); + $brew .= ',"st_og_min":' . floatval($row['st_og_min']); + $brew .= ',"st_og_max":' . floatval($row['st_og_max']); + $brew .= ',"st_fg_min":' . floatval($row['st_fg_min']); + $brew .= ',"st_fg_max":' . floatval($row['st_fg_max']); + $brew .= ',"st_ibu_min":' . floatval($row['st_ibu_min']); + $brew .= ',"st_ibu_max":' . floatval($row['st_ibu_max']); + $brew .= ',"st_color_min":' . floatval($row['st_color_min']); + $brew .= ',"st_color_max":' . floatval($row['st_color_max']); + $brew .= ',"st_carb_min":' . floatval($row['st_carb_min']); + $brew .= ',"st_carb_max":' . floatval($row['st_carb_max']); + $brew .= ',"st_abv_min":' . floatval($row['st_abv_min']); + $brew .= ',"st_abv_max":' . floatval($row['st_abv_max']); + $brew .= ',"r_notes":"' . str_replace($escapers, $replacements, $row['notes']); + $brew .= '","type":"' . $row['type']; + $brew .= '","batch_size":' . floatval($row['batch_size']); + $brew .= ',"boil_size":' . floatval($row['boil_size']); + $brew .= ',"boil_time":' . floatval($row['boil_time']); + $brew .= ',"efficiency":' . floatval($row['efficiency']); + $brew .= ',"est_og":' . floatval($row['est_og']); + $brew .= ',"est_fg":' . floatval($row['est_fg']); + $brew .= ',"est_abv":' . floatval($row['est_abv']); + $brew .= ',"est_carb":' . floatval($row['est_carb']); + $brew .= ',"est_color":' . floatval($row['est_color']); + $brew .= ',"color_method":"' . $row['color_method']; + $brew .= '","est_ibu":' . floatval($row['est_ibu']); + $brew .= ',"ibu_method":"' . $row['ibu_method']; + $brew .= '","mash_sparge_temp":' . $row['mash_sparge_temp']; + $brew .= ',"mash_ph":' . $row['mash_ph']; + $brew .= ',"mash_name":"' . $row['mash_name']; + $brew .= '","fermentables":' . $row['json_fermentables']; + $brew .= ',"hops":' . $row['json_hops']; + $brew .= ',"miscs":' . $row['json_miscs']; + $brew .= ',"yeasts":' . $row['json_yeasts']; + $brew .= ',"waters":' . $row['json_waters']; + $brew .= ',"mashs":' . $row['json_mashs']; + $brew .= '}'; +// syslog(LOG_NOTICE, $brew); + $brews .= $brew; +// syslog(LOG_NOTICE, 'Size: '.strlen($brews).PHP_EOL); } -// syslog(LOG_NOTICE, json_encode($brews)); - echo json_encode($brews); + $brews .= ']'; +// syslog(LOG_NOTICE, $brews); + header("Content-type: application/json"); + echo $brews; } ?> diff -r 4935e86b2775 -r ad31f4bd4036 www/js/prod_edit.js --- a/www/js/prod_edit.js Wed Nov 28 21:57:06 2018 +0100 +++ b/www/js/prod_edit.js Thu Nov 29 23:21:42 2018 +0100 @@ -47,6 +47,7 @@ $(document).ready(function () { var brewstage = 0; // Numeric value of stage + var this_uuid = ''; console.log("record:" + my_record + " return:" + my_return + " theme:" + theme); @@ -60,19 +61,22 @@ { name: 'batch_size', type: 'float' }, { name: 'tun_volume', type: 'float' }, { name: 'tun_weight', type: 'float' }, + { name: 'tun_specific_heat', type: 'float' }, + { name: 'tun_material', type: 'string' }, + { name: 'tun_height', type: 'float' }, + { name: 'top_up_water', type: 'float' }, { name: 'trub_chiller_loss', type: 'float' }, { name: 'evap_rate', type: 'float' }, { name: 'boil_time', type: 'float' }, - { name: 'lauter_deadspace', type: 'float' }, + { name: 'calc_boil_volume', type: 'bool' }, { name: 'top_up_kettle', type: 'float' }, { name: 'hop_utilization', type: 'float' }, { name: 'notes', type: 'string' }, { name: 'lauter_volume', type: 'float' }, + { name: 'lauter_height', type: 'float' }, + { name: 'lauter_deadspace', type: 'float' }, { name: 'kettle_volume', type: 'float' }, - { name: 'tun_material', type: 'string' }, - { name: 'tun_height', type: 'float' }, { name: 'kettle_height', type: 'float' }, - { name: 'lauter_height', type: 'float' }, { name: 'mash_volume', type: 'float' }, { name: 'efficiency', type: 'float' } ], @@ -102,19 +106,22 @@ $("#eq_batch_size").val(datarecord.batch_size); $("#eq_tun_volume").val(datarecord.tun_volume); $("#eq_tun_weight").val(datarecord.tun_weight); + $("#eq_tun_specific_heat").val(datarecord.tun_specific_heat); + $("#eq_tun_material").val(datarecord.tun_material); + $("#eq_tun_height").val(datarecord.tun_height); + $("#eq_top_up_water").val(datarecord.top_up_water); $("#eq_trub_chiller_loss").val(datarecord.trub_chiller_loss); $("#eq_evap_rate").val(datarecord.evap_rate); $("#eq_boil_time").val(datarecord.boil_time); - $("#eq_lauter_deadspace").val(datarecord.lauter_deadspace); + $("#eq_calc_boil_volume").val(datarecord.calc_boil_volume); $("#eq_top_up_kettle").val(datarecord.top_up_kettle); $("#eq_hop_utilization").val(datarecord.hop_utilization); $("#eq_notes").val(datarecord.notes); $("#eq_lauter_volume").val(datarecord.lauter_volume); + $("#eq_lauter_height").val(datarecord.lauter_height); + $("#eq_lauter_deadspace").val(datarecord.lauter_deadspace); $("#eq_kettle_volume").val(datarecord.kettle_volume); - $("#eq_tun_material").val(datarecord.tun_material); - $("#eq_tun_height").val(datarecord.tun_height); $("#eq_kettle_height").val(datarecord.kettle_height); - $("#eq_lauter_height").val(datarecord.lauter_height); $("#eq_mash_volume").val(datarecord.mash_volume); $("#eq_efficiency").val(datarecord.efficiency); } @@ -170,19 +177,22 @@ { name: 'eq_batch_size', type: 'float' }, { name: 'eq_tun_volume', type: 'float' }, { name: 'eq_tun_weight', type: 'float' }, + { name: 'eq_tun_specific_heat', type: 'float' }, + { name: 'eq_tun_material', type: 'string' }, + { name: 'eq_tun_height', type: 'float' }, + { name: 'eq_top_up_water', type: 'float' }, { name: 'eq_trub_chiller_loss', type: 'float' }, { name: 'eq_evap_rate', type: 'float' }, { name: 'eq_boil_time', type: 'float' }, - { name: 'eq_lauter_deadspace', type: 'float' }, + { name: 'eq_calc_boil_volume', type: 'bool' }, { name: 'eq_top_up_kettle', type: 'float' }, { name: 'eq_hop_utilization', type: 'float' }, { name: 'eq_notes', type: 'string' }, { name: 'eq_lauter_volume', type: 'float' }, + { name: 'eq_lauter_height', type: 'float' }, + { name: 'eq_lauter_deadspace', type: 'float' }, { name: 'eq_kettle_volume', type: 'float' }, - { name: 'eq_tun_material', type: 'string' }, - { name: 'eq_tun_height', type: 'float' }, - { name: 'eq_kettle_height', type: 'float' }, - { name: 'eq_lauter_height', type: 'float' }, + { name: 'eq_kettle_height', type: 'float' }, { name: 'eq_mash_volume', type: 'float' }, { name: 'eq_efficiency', type: 'float' }, { name: 'brew_date_start', type: 'string' }, @@ -192,7 +202,9 @@ { name: 'brew_date_end', type: 'string' } ], id: 'record', +// data: "record=" + my_record, url: url + // url: url + '?record=' + my_record, }; // Load data and select one record. var dataAdapter = new $.jqx.dataAdapter(source, { @@ -200,6 +212,7 @@ var records = dataAdapter.records; dataRecord = records[0]; // Hidden record uuid + this_uuid = dataRecord.uuid; $("#name").val(dataRecord.name); $("#code").val(dataRecord.code); $("#birth").val(dataRecord.birth); @@ -210,23 +223,26 @@ $("#inventory_reduced").val(dataRecord.inventory_reduced); $("#locked").val(dataRecord.locked); $("#eq_name").val(dataRecord.eq_name); + $("#eq_notes").val(dataRecord.eq_notes); $("#eq_boil_size").val(dataRecord.eq_boil_size); $("#eq_batch_size").val(dataRecord.eq_batch_size); $("#eq_tun_volume").val(dataRecord.eq_tun_volume); $("#eq_tun_weight").val(dataRecord.eq_tun_weight); + $("#eq_tun_specific_heat").val(dataRecord.eq_tun_specific_heat); + $("#eq_tun_material").val(dataRecord.eq_tun_material); + $("#eq_tun_height").val(dataRecord.eq_tun_height); + $("#eq_top_up_water").val(dataRecord.eq_top_up_water); $("#eq_trub_chiller_loss").val(dataRecord.eq_trub_chiller_loss); $("#eq_evap_rate").val(dataRecord.eq_evap_rate); $("#eq_boil_time").val(dataRecord.eq_boil_time); - $("#eq_lauter_deadspace").val(dataRecord.eq_lauter_deadspace); + $("#eq_calc_boil_volume").val(dataRecord.eq_calc_boil_volume); $("#eq_top_up_kettle").val(dataRecord.eq_top_up_kettle); $("#eq_hop_utilization").val(dataRecord.eq_hop_utilization); - $("#eq_notes").val(dataRecord.eq_notes); $("#eq_lauter_volume").val(dataRecord.eq_lauter_volume); + $("#eq_lauter_height").val(dataRecord.eq_lauter_height); + $("#eq_lauter_deadspace").val(dataRecord.eq_lauter_deadspace); $("#eq_kettle_volume").val(dataRecord.eq_kettle_volume); - $("#eq_tun_material").val(dataRecord.eq_tun_material); - $("#eq_tun_height").val(dataRecord.eq_tun_height); $("#eq_kettle_height").val(dataRecord.eq_kettle_height); - $("#eq_lauter_height").val(dataRecord.eq_lauter_height); $("#eq_mash_volume").val(dataRecord.eq_mash_volume); $("#eq_efficiency").val(dataRecord.eq_efficiency); $("#brew_date_start").val(dataRecord.brew_date_start); @@ -318,19 +334,22 @@ $("#eq_batch_size").jqxNumberInput({ inputMode: 'simple', readOnly: true, theme: theme, width: 70, height: 23, decimalDigits: 1 }); $("#eq_tun_volume").jqxNumberInput({ inputMode: 'simple', readOnly: true, theme: theme, width: 70, height: 23, decimalDigits: 1 }); $("#eq_tun_weight").jqxNumberInput({ inputMode: 'simple', readOnly: true, theme: theme, width: 70, height: 23, decimalDigits: 2 }); + $("#eq_tun_specific_heat").jqxNumberInput({ inputMode: 'simple', readOnly: true, theme: theme, width: 70, height: 23, decimalDigits: 3 }); + $("#eq_tun_material").jqxInput({ theme: theme, width: 100, height: 23 }); + $("#eq_tun_height").jqxNumberInput({ inputMode: 'simple', readOnly: true, theme: theme, width: 70, height: 23, decimalDigits: 1 }); + $("#eq_top_up_water").jqxNumberInput({ inputMode: 'simple', readOnly: true, theme: theme, width: 70, height: 23, decimalDigits: 1 }); $("#eq_trub_chiller_loss").jqxNumberInput({ inputMode: 'simple', readOnly: true, theme: theme, width: 70, height: 23, decimalDigits: 1 }); $("#eq_evap_rate").jqxNumberInput({ inputMode: 'simple', readOnly: true, theme: theme, width: 70, height: 23, decimalDigits: 2, }); $("#eq_boil_time").jqxNumberInput({ inputMode: 'simple', readOnly: true, theme: theme, width: 70, height: 23, decimalDigits: 0 }); - $("#eq_lauter_deadspace").jqxNumberInput({ inputMode: 'simple', readOnly: true, theme: theme, width: 70, height: 23, decimalDigits: 1 }); + $("#eq_calc_boil_volume").jqxCheckBox({ theme: theme, width: 120, height: 23 }); $("#eq_top_up_kettle").jqxNumberInput({ inputMode: 'simple', readOnly: true, theme: theme, width: 70, height: 23, decimalDigits: 1 }); $("#eq_hop_utilization").jqxNumberInput({ inputMode: 'simple', readOnly: true, theme: theme, width: 70, height: 23, decimalDigits: 0 }); $("#eq_notes").jqxInput({ theme: theme, width: 640, height: 100 }); $("#eq_lauter_volume").jqxNumberInput({ inputMode: 'simple', readOnly: true, theme: theme, width: 70, height: 23, decimalDigits: 1 }); + $("#eq_lauter_height").jqxNumberInput({ inputMode: 'simple', readOnly: true, theme: theme, width: 70, height: 23, decimalDigits: 1 }); + $("#eq_lauter_deadspace").jqxNumberInput({ inputMode: 'simple', readOnly: true, theme: theme, width: 70, height: 23, decimalDigits: 1 }); $("#eq_kettle_volume").jqxNumberInput({ inputMode: 'simple', readOnly: true, theme: theme, width: 70, height: 23, decimalDigits: 1 }); - $("#eq_tun_material").jqxInput({ theme: theme, width: 100, height: 23 }); - $("#eq_tun_height").jqxNumberInput({ inputMode: 'simple', readOnly: true, theme: theme, width: 70, height: 23, decimalDigits: 1 }); $("#eq_kettle_height").jqxNumberInput({ inputMode: 'simple', readOnly: true, theme: theme, width: 70, height: 23, decimalDigits: 1 }); - $("#eq_lauter_height").jqxNumberInput({ inputMode: 'simple', readOnly: true, theme: theme, width: 70, height: 23, decimalDigits: 1 }); $("#eq_mash_volume").jqxNumberInput({ inputMode: 'simple', readOnly: true, theme: theme, width: 70, height: 23, decimalDigits: 1 }); $("#eq_efficiency").jqxNumberInput({ inputMode: 'simple', readOnly: true, theme: theme, width: 70, height: 23, decimalDigits: 1 }); @@ -385,7 +404,7 @@ $("#Save").click(function () { var row = { record: my_record, - uuid: $("#uuid").val(), + uuid: this_uuid, name: $("#name").val(), code: $("#code").val(), birth: $("#birth").val(), @@ -400,19 +419,22 @@ eq_batch_size: parseFloat($("#eq_batch_size").jqxNumberInput('decimal')), eq_tun_volume: parseFloat($("#eq_tun_volume").jqxNumberInput('decimal')), eq_tun_weight: parseFloat($("#eq_tun_weight").jqxNumberInput('decimal')), + eq_tun_specific_heat: parseFloat($("#eq_tun_specific_heat").jqxNumberInput('decimal')), + eq_tun_material: $("#eq_tun_material").val(), + eq_tun_height: parseFloat($("#eq_tun_height").jqxNumberInput('decimal')), + eq_top_up_water: parseFloat($("#eq_top_up_water").jqxNumberInput('decimal')), eq_trub_chiller_loss: parseFloat($("#eq_trub_chiller_loss").jqxNumberInput('decimal')), eq_evap_rate: parseFloat($("#eq_evap_rate").jqxNumberInput('decimal')), eq_boil_time: parseFloat($("#eq_boil_time").jqxNumberInput('decimal')), - eq_lauter_deadspace: parseFloat($("#eq_lauter_deadspace").jqxNumberInput('decimal')), + eq_calc_boil_volume: $("#eq_calc_boil_volume").val(), eq_top_up_kettle: parseFloat($("#eq_top_up_kettle").jqxNumberInput('decimal')), eq_hop_utilization: parseFloat($("#eq_hop_utilization").jqxNumberInput('decimal')), eq_notes: $("#eq_notes").val(), eq_lauter_volume: parseFloat($("#eq_lauter_volume").jqxNumberInput('decimal')), + eq_lauter_height: parseFloat($("#eq_lauter_height").jqxNumberInput('decimal')), + eq_lauter_deadspace: parseFloat($("#eq_lauter_deadspace").jqxNumberInput('decimal')), eq_kettle_volume: parseFloat($("#eq_kettle_volume").jqxNumberInput('decimal')), - eq_tun_material: $("#eq_tun_material").val(), - eq_tun_height: parseFloat($("#eq_tun_height").jqxNumberInput('decimal')), eq_kettle_height: parseFloat($("#eq_kettle_height").jqxNumberInput('decimal')), - eq_lauter_height: parseFloat($("#eq_lauter_height").jqxNumberInput('decimal')), eq_mash_volume: parseFloat($("#eq_mash_volume").jqxNumberInput('decimal')), eq_efficiency: parseFloat($("#eq_efficiency").jqxNumberInput('decimal')) }; diff -r 4935e86b2775 -r ad31f4bd4036 www/prod_edit.php --- a/www/prod_edit.php Wed Nov 28 21:57:06 2018 +0100 +++ b/www/prod_edit.php Thu Nov 29 23:21:42 2018 +0100 @@ -74,7 +74,9 @@ Installatie naam: - + + Bereken kookvolume: +
Opmerkingen: @@ -104,43 +106,49 @@ Maischkuip materiaal: - + Verdamping per uur l:
+ Maischkuip specific heat: +
+ Kooktijd in minuten: +
+ + Maischwater l:
- Kooktijd in minuten: -
+ Extra water bij koken l: +
Filteren - Extra water bij koken l: -
+ Hopfactor %: +
Filter volume l:
- Hopfactor %: -
- - - Filterkuip hoogte cm: -
Volume eind koken l:
+ Filterkuip hoogte cm: +
+ Koelen + + Filterkuip verlies l:
- Koelen + Trub verlies kookketel l: +
Brouwzaalrendement %:
- Trub verlies kookketel l: -
+ Extra water in gistvatl: +