# HG changeset patch # User Michiel Broek # Date 1548795128 -3600 # Node ID 14e349ff2a1076e37d2c0dbd43ae5371e9b56d2f # Parent 4c21eabb3c0edcbd8474166016f39670a08655f9 Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values. diff -r 4c21eabb3c0e -r 14e349ff2a10 www/import/from_brouwhulp.php --- a/www/import/from_brouwhulp.php Sun Jan 27 23:35:19 2019 +0100 +++ b/www/import/from_brouwhulp.php Tue Jan 29 21:52:08 2019 +0100 @@ -98,8 +98,6 @@ if ($fermentable->MAX_IN_BATCH) $sql .= "', max_in_batch='" . floatval($fermentable->MAX_IN_BATCH); ($fermentable->RECOMMEND_MASH == "TRUE") ? $sql .= "', recommend_mash='1" : $sql .= "', recommend_mash='0"; - if ($fermentable->IBU_GAL_PER_LB) - $sql .= "', ibu_gal_per_lb='" . floatval($fermentable->IBU_GAL_PER_LB); ($fermentable->ALWAYS_ON_STOCK == "TRUE") ? $sql .= "', always_on_stock='1" : $sql .= "', always_on_stock='0"; if ($fermentable->INVENTORY) $sql .= "', inventory='" . floatval($fermentable->INVENTORY); @@ -714,8 +712,20 @@ $famount = floatval($fermentable->AMOUNT); $fermentables .= ',"f_amount":' . $famount; $fermentables .= ',"f_cost":' . floatval($fermentable->COST); - $ftype = mysqli_real_escape_string($db, $fermentable->TYPE); - $fermentables .= ',"f_type":"' . $ftype . '"'; + + if ($fermentable->TYPE == 'Grain') + $fermentables .= ',"f_type":0'; + else if ($fermentable->TYPE == 'Sugar') + $fermentables .= ',"f_type":1'; + else if ($fermentable->TYPE == 'Extract') + $fermentables .= ',"f_type":2'; + else if ($fermentable->TYPE == 'Dry extract') + $fermentables .= ',"f_type":3'; + else if ($fermentable->TYPE == 'Adjunct') + $fermentables .= ',"f_type":4'; + else + echo "Unknown TYPE " . $fermentable->TYPE . PHP_EOL; + $fyield = floatval($fermentable->YIELD); $fermentables .= ',"f_yield":' . $fyield; if ($fermentable->COLOR) { @@ -748,17 +758,37 @@ $fermentables .= ',"f_max_in_batch":' . floatval($fermentable->MAX_IN_BATCH); else $fermentables .= ',"f_max_in_batch":100.0'; - $fgraintype = mysqli_real_escape_string($db, $fermentable->GRAINTYPE); - if ($fermentable->GRAINTYPE) - $fgraintype = mysqli_real_escape_string($db, $fermentable->GRAINTYPE); + + if ($fermentable->GRAINTYPE == 'Base') + $fermentables .= ',"f_graintype":0'; + else if ($fermentable->GRAINTYPE == 'Roast') + $fermentables .= ',"f_graintype":1'; + else if ($fermentable->GRAINTYPE == 'Crystal') + $fermentables .= ',"f_graintype":2'; + else if ($fermentable->GRAINTYPE == 'Kilned') + $fermentables .= ',"f_graintype":3'; + else if ($fermentable->GRAINTYPE == 'Sour malt') + $fermentables .= ',"f_graintype":4'; + else if ($fermentable->GRAINTYPE == 'Special') + $fermentables .= ',"f_graintype":5'; + else if ($fermentable->GRAINTYPE == 'No malt') + $fermentables .= ',"f_graintype":6'; else - $fgraintype = "Base"; - $fermentables .= ',"f_graintype":"' . $fgraintype . '"'; - if ($fermentable->ADDED) - $fadded = mysqli_real_escape_string($db, $fermentable->ADDED); + echo "Unknown GRAINTYPE " . $fermentable->GRAINTYPE . PHP_EOL; + + if ($fermentable->ADDED == 'Mash') + $fermentables .= ',"f_added":0'; + else if ($fermentable->ADDED == 'Boil') + $fermentables .= ',"f_added":1'; + else if ($fermentable->ADDED == 'Fermentation') + $fermentables .= ',"f_added":2'; + else if ($fermentable->ADDED == 'Lagering') + $fermentables .= ',"f_added":3'; + else if ($fermentable->ADDED == 'Bottle') + $fermentables .= ',"f_added":4'; else - $fadded = "Mash"; - $fermentables .= ',"f_added":"'.$fadded.'"'; + echo "Unknown ADDED " . $fermentable->ADDED . PHP_EOL; + ($fermentable->ADD_AFTER_BOIL== "TRUE") ? $fermentables .= ',"f_add_after_boil":1' : $fermentables .= ',"f_add_after_boil":0'; ($fermentable->RECOMMEND_MASH== "TRUE") ? $fermentables .= ',"f_recommend_mash":1' : $fermentables .= ',"f_recommend_mash":0'; if ($fermentable->DISSOLVED_PROTEIN) @@ -779,12 +809,12 @@ $fermentables .= "}"; /* Sugars */ $d = $famount * ($fyield / 100) * (1 - $fmoisture / 100); - if ($fadded == "Mash") + if ($fermentable->ADDED == 'Mash') $d = floatval($efficiency) / 100 * $d; $f_sugars += $d; - if ($fgraintype == "Crystal") + if ($fermentable->GRAINTYPE == 'Crystal') $pCara += $percent; - if ($ftype == "Sugar") + if ($fermentable->TYPE == 'Sugar') $pSugar += $percent; } $fermentables .= ']'; @@ -804,9 +834,39 @@ $hops .= '{"h_name":"' . mysqli_real_escape_string($db, $hop->NAME) . '"'; $hops .= ',"h_amount":' . floatval($hop->AMOUNT); $hops .= ',"h_cost":' . floatval($hop->COST); - $hops .= ',"h_type":"' . mysqli_real_escape_string($db, $hop->TYPE) . '"'; - $hops .= ',"h_form":"' . mysqli_real_escape_string($db, $hop->FORM) . '"'; - $hops .= ',"h_useat":"' . mysqli_real_escape_string($db, $hop->USE) . '"'; + + if ($hop->TYPE == 'Bittering') + $hops .= ',"h_type":0'; + else if ($hop->TYPE == 'Aroma') + $hops .= ',"h_type":1'; + else if ($hop->TYPE == 'Both') + $hops .= ',"h_type":2'; + else + echo "Unknown TYPE " . $hop->TYPE . PHP_EOL; + + if ($hop->FORM == 'Pellet') + $hops .= ',"h_form":0'; + else if ($hop->FORM == 'Plug') + $hops .= ',"h_form":1'; + else if ($hop->FORM == 'Leaf') + $hops .= ',"h_form":2'; + else + echo "Unknown FORM " . $hop->FORM . PHP_EOL; + + if ($hop->USE == 'Mash') + $hops .= ',"h_useat":0'; + else if ($hop->USE == 'First wort') + $hops .= ',"h_useat":1'; + else if ($hop->USE == 'Boil') + $hops .= ',"h_useat":2'; + else if ($hop->USE == 'Aroma') + $hops .= ',"h_useat":3'; + else if ($hop->USE == 'Whirlpool') + $hops .= ',"h_useat":4'; + else if ($hop->USE == 'Dry hop') + $hops .= ',"h_useat":5'; + else + echo "Unknown USE " . $hop->USE . PHP_EOL; if ($hop->TIME) $hops .= ',"h_time":' . floatval($hop->TIME); else @@ -855,14 +915,42 @@ $miscs .= ',"m_cost":0'; } } - $miscs .= ',"m_type":"' . mysqli_real_escape_string($db, $misc->TYPE) . '"'; - $miscs .= ',"m_use_use":"' . mysqli_real_escape_string($db, $misc->USE) . '"'; + + if ($misc->TYPE == 'Spice') + $miscs .= ',"m_type":0'; + else if ($misc->TYPE == 'Herb') + $miscs .= ',"m_type":1'; + else if ($misc->TYPE == 'Flavor') + $miscs .= ',"m_type":2'; + else if ($misc->TYPE == 'Fining') + $miscs .= ',"m_type":3'; + else if ($misc->TYPE == 'Water agent') + $miscs .= ',"m_type":4'; + else if ($misc->TYPE == 'Yeast nutrient') + $miscs .= ',"m_type":5'; + else if ($misc->TYPE == 'Other') + $miscs .= ',"m_type":6'; + else + echo "Unknown TYPE " . $misc->TYPE . PHP_EOL; + + if ($misc->USE == 'Starter') + $miscs .= ',"m_use_use":0'; + else if ($misc->USE == 'Mash') + $miscs .= ',"m_use_use":1'; + else if ($misc->USE == 'Boil') + $miscs .= ',"m_use_use":2'; + else if ($misc->USE == 'Primary') + $miscs .= ',"m_use_use":3'; + else if ($misc->USE == 'Secondary') + $miscs .= ',"m_use_use":4'; + else if ($misc->USE == 'Bottling') + $miscs .= ',"m_use_use":5'; + else + echo "Unknown USE " . $misc->USE . PHP_EOL; + ($misc->AMOUNT_IS_WEIGHT== "TRUE") ? $miscs .= ',"m_amount_is_weight":1' : $miscs.= ',"m_amount_is_weight":0'; if ($misc->TIME) { - if (mysqli_real_escape_string($db, $misc->USE) == "Secondary") - $miscs .= ',"m_time":' . floatval($misc->TIME) / 1440; - else - $miscs .= ',"m_time":' . floatval($misc->TIME); + $miscs .= ',"m_time":' . floatval($misc->TIME); } else $miscs .= ',"m_time":0'; $miscs .= "}"; @@ -894,16 +982,46 @@ $yeasts .= ',"y_cost":0'; $yeasts .= ',"y_laboratory":"' . mysqli_real_escape_string($db, $yeast->LABORATORY) . '"'; $yeasts .= ',"y_product_id":"' . mysqli_real_escape_string($db, $yeast->PRODUCT_ID) . '"'; - $yeasts .= ',"y_type":"' . mysqli_real_escape_string($db, $yeast->TYPE) . '"'; - $yeasts .= ',"y_form":"' . mysqli_real_escape_string($db, $yeast->FORM) . '"'; + + if ($yeast->TYPE == 'Lager') + $yeasts .= ',"y_type":0'; + else if ($yeast->TYPE == 'Ale') + $yeasts .= ',"y_type":1'; + else if ($yeast->TYPE == 'Wheat') + $yeasts .= ',"y_type":2'; + else if ($yeast->TYPE == 'Wine') + $yeasts .= ',"y_type":3'; + else if ($yeast->TYPE == 'Champagne') + $yeasts .= ',"y_type":4'; + else + echo "Unknown TYPE " . $yeast->TYPE . PHP_EOL; + + if ($yeast->FORM == 'Liquid') { + if ($yeast->LABORATORY == 'Imperial Yeast') + $yeasts .= ',"y_form":0,"y_cells":200000000000'; + else + $yeasts .= ',"y_form":0,"y_cells":100000000000'; + } else if ($yeast->FORM == 'Dry') + $yeasts .= ',"y_form":1,"y_cells":15000000000'; + else if ($yeast->FORM == 'Slant') + $yeasts .= ',"y_form":2,"y_cells":1700000000'; + else if ($yeast->FORM == 'Culture') + $yeasts .= ',"y_form":3,"y_cells":1700000000'; + else if ($yeast->FORM == 'Frozen') + $yeasts .= ',"y_form":4,"y_cells":1700000000'; + else if ($yeast->FORM == 'Bottle') + $yeasts .= ',"y_form":5,"y_cells":1700000000'; + else + echo "Unknown FORM " . $yeast->FORM . PHP_EOL; + ($yeast->AMOUNT_IS_WEIGHT== "TRUE") ? $yeasts .= ',"y_amount_is_weight":1' : $yeasts.= ',"y_amount_is_weight":0'; if ($yeast->ADD_TO_SECONDARY=="FALSE") { - $yeasts .= ',"y_use":"Primary"'; + $yeasts .= ',"y_use":0'; // Primary $svg = floatval($yeast->ATTENUATION); } else if ($yeast->PRODUCT_ID=="F2") { - $yeasts .= ',"y_use":"Bottle"'; + $yeasts .= ',"y_use":3'; // Bottle } else { - $yeasts .= ',"y_use":"Secondary"'; + $yeasts .= ',"y_use":1'; // Secondary } $yeasts .= ',"y_min_temperature":' . floatval($yeast->MIN_TEMPERATURE); $yeasts .= ',"y_max_temperature":' . floatval($yeast->MAX_TEMPERATURE); @@ -944,6 +1062,8 @@ return $waters; } + + function recipe_mash_steps($recipe) { global $db; @@ -955,8 +1075,16 @@ $steps .= ','; $comma = TRUE; $steps .= '{"step_name":"' . mysqli_real_escape_string($db, $step->NAME) . '"'; - if ($step->TYPE) - $steps .= ',"step_type":"' . $step->TYPE . '"'; + + if ($step->TYPE == 'Infusion') + $steps .= ',"step_type":0'; + else if ($step->TYPE == 'Temperature') + $steps .= ',"step_type":1'; + else if ($step->TYPE == 'Decoction') + $steps .= ',"step_type":2'; + else + echo "Unknown step TYPE " . $step->TYPE . PHP_EOL; + if ($step->INFUSE_AMOUNT) $steps .= ',"step_infuse_amount":"' . floatval($step->INFUSE_AMOUNT) . '"'; if ($step->STEP_TEMP) @@ -1010,10 +1138,16 @@ $sql .= "', notes='" . mysqli_real_escape_string($db, $recipe->NOTES); else $sql .= "', notes='"; - if ($recipe->TYPE) - $sql .= "', type='" . mysqli_real_escape_string($db, $recipe->TYPE); + + if ($recipe->TYPE == 'Extract') + $sql .= "', type='0"; + else if ($recipe->TYPE == 'Partial Mash') + $sql .= "', type='1"; + else if ($recipe->TYPE == 'All Grain') + $sql .= "', type='2"; else - $sql .= "', type='"; + echo "Unknown TYPE " . $recipe->TYPE . PHP_EOL; + if ($recipe->BATCH_SIZE) $batch_size = floatval($recipe->BATCH_SIZE); $sql .= "', batch_size='" . $batch_size; @@ -1030,12 +1164,26 @@ /* Don't use $recipe->EST_OG but recalculate it */ /* Don't use $recipe->EST_FG but recalculate it */ /* Don't use $recipe->EST_COLOR but recalculate it */ - if ($recipe->COLOR_METHOD) - $sql .= "', color_method='" . mysqli_real_escape_string($db, $recipe->COLOR_METHOD); + if ($recipe->COLOR_METHOD == 'Morey') + $sql .= "', color_method='0"; + else if ($recipe->COLOR_METHOD == 'Mosher') + $sql .= "', color_method='1"; + else if ($recipe->COLOR_METHOD == 'Daniels') + $sql .= "', color_method='2"; + else + echo "Unknown COLOR_METHO " . $recipe->COLOR_METHOD . PHP_EOL; + if ($recipe->IBU) $sql .= "', est_ibu='" . floatval($recipe->IBU); - if ($recipe->IBU_METHOD) - $sql .= "', ibu_method='" . mysqli_real_escape_string($db, $recipe->IBU_METHOD); + if ($recipe->IBU_METHOD == 'Tinseth') + $sql .= "', ibu_method='0"; + else if ($recipe->IBU_METHOD == 'Rager') + $sql .= "', ibu_method='1"; + else if ($recipe->IBU_METHOD == 'Daniels') + $sql .= "', ibu_method='2"; + else + echo "Unknown IBU_METHOD " . $recipe->IBU_METHOD . PHP_EOL; + if ($recipe->CARBONATION) $sql .= "', est_carb='" . floatval($recipe->CARBONATION); @@ -1049,13 +1197,13 @@ $sql .= "', mash_ph='" . floatval($recipe->TARGET_PH); } if ($recipe->SPARGE_ACID_TYPE && ($recipe->SPARGE_ACID_TYPE == "Lactic")) { - $sql .= "', sparge_acid_type='Melkzuur"; + $sql .= "', sparge_acid_type='0"; } else if ($recipe->SPARGE_ACID_TYPE && ($recipe->SPARGE_ACID_TYPE == "Hydrochloric")) { - $sql .= "', sparge_acid_type='Zoutzuur"; + $sql .= "', sparge_acid_type='1"; } else if ($recipe->SPARGE_ACID_TYPE && ($recipe->SPARGE_ACID_TYPE == "Phosphoric")) { - $sql .= "', sparge_acid_type='Fosforzuur"; + $sql .= "', sparge_acid_type='2"; } else if ($recipe->SPARGE_ACID_TYPE && ($recipe->SPARGE_ACID_TYPE == "Sulfuric")) { - $sql .= "', sparge_acid_type='Zwavelzuur"; + $sql .= "', sparge_acid_type='3"; } if ($recipe->ACID_SPARGE_PERC) { $sql .= "', sparge_acid_perc='" . floatval($recipe->ACID_SPARGE_PERC); diff -r 4c21eabb3c0e -r 14e349ff2a10 www/includes/db_recipes.php --- a/www/includes/db_recipes.php Sun Jan 27 23:35:19 2019 +0100 +++ b/www/includes/db_recipes.php Tue Jan 29 21:52:08 2019 +0100 @@ -36,7 +36,7 @@ $sql .= "', st_name='" . mysqli_real_escape_string($connect, $_POST['st_name']); $sql .= "', st_letter='" . mysqli_real_escape_string($connect, $_POST['st_letter']); $sql .= "', st_guide='" . mysqli_real_escape_string($connect, $_POST['st_guide']); - $sql .= "', st_type='" . mysqli_real_escape_string($connect, $_POST['st_type']); + $sql .= "', st_type='" . $_POST['st_type']; $sql .= "', st_category='" . mysqli_real_escape_string($connect, $_POST['st_category']); $sql .= "', st_category_number='" . $_POST['st_category_number']; $sql .= "', st_og_min='" . $_POST['st_og_min']; @@ -100,29 +100,82 @@ $sql .= "', w2_ph='" . $_POST['w2_ph']; $sql .= "', w2_cost='" . $_POST['w2_cost']; } + $sql .= "', wa_acid_name='" . $_POST['wa_acid_name']; + $sql .= "', wa_acid_perc='" . $_POST['wa_acid_perc']; + $sql .= "', wa_base_name='" . $_POST['wa_base_name']; syslog(LOG_NOTICE, $sql); + $fermentables = '['; + $comma = FALSE; if (isset($_POST['fermentables'])) { $array = $_POST['fermentables']; foreach($array as $key => $item){ - foreach ($disallowed as $disallowed_key) { - unset($array[$key]["$disallowed_key"]); - } + /* + * Manual encode to json. + */ + if ($comma) + $fermentables .= ','; + $comma = TRUE; + $fermentable = '{"f_name":"' . str_replace($rescapers,$rreplacements,$item['f_name']); + $fermentable .= '","f_origin":"' . str_replace($rescapers,$rreplacements,$item['f_origin']); + $fermentable .= '","f_supplier":"' . str_replace($rescapers,$rreplacements,$item['f_supplier']); + $fermentable .= '","f_amount":' . $item['f_amount']; + $fermentable .= ',"f_cost":' . $item['f_cost']; + $fermentable .= ',"f_type":' . $item['f_type']; + $fermentable .= ',"f_yield":' . $item['f_yield']; + $fermentable .= ',"f_color":' . $item['f_color']; + $fermentable .= ',"f_coarse_fine_diff":' . $item['f_coarse_fine_diff']; + $fermentable .= ',"f_moisture":' . $item['f_moisture']; + $fermentable .= ',"f_diastatic_power":' . $item['f_diastatic_power']; + $fermentable .= ',"f_protein":' . $item['f_protein']; + $fermentable .= ',"f_dissolved_protein":' . $item['f_dissolved_protein']; + $fermentable .= ',"f_max_in_batch":' . $item['f_max_in_batch']; + $fermentable .= ',"f_graintype":' . $item['f_graintype']; + $fermentable .= ',"f_added":' . $item['f_added']; + $fermentable .= ',"f_recommend_mash":' . $item['f_recommend_mash']; + $fermentable .= ',"f_add_after_boil":' . $item['f_add_after_boil']; + $fermentable .= ',"f_adjust_to_total_100":' . $item['f_adjust_to_total_100']; + $fermentable .= ',"f_percentage":' . $item['f_percentage']; + $fermentable .= ',"f_di_ph":' . $item['f_di_ph']; + $fermentable .= ',"f_acid_to_ph_57":' . $item['f_acid_to_ph_57'] . '}'; + syslog(LOG_NOTICE, $fermentable); + $fermentables .= $fermentable; } - syslog(LOG_NOTICE, "json_fermentables=: ".str_replace($rescapers,$rreplacements,json_encode($array))); - $sql .= "', json_fermentables='" . str_replace($rescapers,$rreplacements,json_encode($array)); } + $fermentables .= ']'; + $sql .= "', json_fermentables='" . $fermentables; + $hops = '['; + $comma = FALSE; if (isset($_POST['hops'])) { $array = $_POST['hops']; foreach($array as $key => $item){ - foreach ($disallowed as $disallowed_key) { - unset($array[$key]["$disallowed_key"]); - } + if ($comma) + $hops .= ','; + $comma = TRUE; + $hop = '{"h_name":"' . str_replace($rescapers,$rreplacements,$item['h_name']); + $hop .= '","h_origin":"' . str_replace($rescapers,$rreplacements,$item['h_origin']); + $hop .= '","h_amount":' . $item['h_amount']; + $hop .= ',"h_cost":' . $item['h_cost']; + $hop .= ',"h_type":' . $item['h_type']; + $hop .= ',"h_form":' . $item['h_form']; + $hop .= ',"h_useat":' . $item['h_useat']; + $hop .= ',"h_time":' . $item['h_time']; + $hop .= ',"h_alpha":' . $item['h_alpha']; + $hop .= ',"h_beta":' . $item['h_beta']; + $hop .= ',"h_hsi":' . $item['h_hsi']; + $hop .= ',"h_humulene":' . $item['h_humulene']; + $hop .= ',"h_carophyllene":' . $item['h_carophyllene']; + $hop .= ',"h_cohumulone":' . $item['h_cohumulone']; + $hop .= ',"h_myrcene":' . $item['h_myrcene']; + $hop .= ',"h_total_oil":' . $item['h_total_oil']; + $hop .= ',"h_weight":' . $item['h_weight'] . '}'; + syslog(LOG_NOTICE, $hop); + $hops .= $hop; } - syslog(LOG_NOTICE, "json_hops: ".str_replace($rescapers,$rreplacements,json_encode($array))); - $sql .= "', json_hops='" . str_replace($rescapers,$rreplacements,json_encode($array)); } + $hops .= ']'; + $sql .= "', json_hops='" . $hops; if (isset($_POST['miscs'])) { $array = $_POST['miscs']; @@ -212,8 +265,8 @@ $recipes .= ',"st_guide":"' . str_replace($escapers, $replacements, $row['st_guide']); $recipes .= '","st_letter":"' . str_replace($escapers, $replacements, $row['st_letter']); $recipes .= '","st_name":"' . str_replace($escapers, $replacements, $row['st_name']); - $recipes .= '","st_type":"' . str_replace($escapers, $replacements, $row['st_type']); - $recipes .= '","st_category":"' . str_replace($escapers, $replacements, $row['st_category']); + $recipes .= '","st_type":' . $row['st_type']; + $recipes .= ',"st_category":"' . str_replace($escapers, $replacements, $row['st_category']); $recipes .= '","st_category_number":' . floatval($row['st_category_number']); $recipes .= ',"st_og_min":' . floatval($row['st_og_min']); $recipes .= ',"st_og_max":' . floatval($row['st_og_max']); @@ -229,8 +282,8 @@ $recipes .= ',"st_abv_max":' . floatval($row['st_abv_max']); $recipes .= ',"name":"' . str_replace($escapers, $replacements, $row['name']); $recipes .= '","notes":"' . str_replace($escapers, $replacements, $row['notes']); - $recipes .= '","type":"' . $row['type']; - $recipes .= '","batch_size":' . floatval($row['batch_size']); + $recipes .= '","type":' . $row['type']; + $recipes .= ',"batch_size":' . floatval($row['batch_size']); $recipes .= ',"boil_size":' . floatval($row['boil_size']); $recipes .= ',"boil_time":' . floatval($row['boil_time']); $recipes .= ',"efficiency":' . floatval($row['efficiency']); @@ -239,15 +292,15 @@ $recipes .= ',"est_abv":' . floatval($row['est_abv']); $recipes .= ',"est_carb":' . floatval($row['est_carb']); $recipes .= ',"est_color":' . floatval($row['est_color']); - $recipes .= ',"color_method":"' . $row['color_method']; - $recipes .= '","est_ibu":' . floatval($row['est_ibu']); - $recipes .= ',"ibu_method":"' . $row['ibu_method']; - $recipes .= '","sparge_temp":' . $row['sparge_temp']; + $recipes .= ',"color_method":' . $row['color_method']; + $recipes .= ',"est_ibu":' . floatval($row['est_ibu']); + $recipes .= ',"ibu_method":' . $row['ibu_method']; + $recipes .= ',"sparge_temp":' . $row['sparge_temp']; $recipes .= ',"sparge_ph":' . $row['sparge_ph']; $recipes .= ',"sparge_volume":' . $row['sparge_volume']; $recipes .= ',"sparge_source":"' . $row['sparge_source']; - $recipes .= '","sparge_acid_type":"' . $row['sparge_acid_type']; - $recipes .= '","sparge_acid_perc":' . $row['sparge_acid_perc']; + $recipes .= '","sparge_acid_type":' . $row['sparge_acid_type']; + $recipes .= ',"sparge_acid_perc":' . $row['sparge_acid_perc']; $recipes .= ',"sparge_acid_amount":' . $row['sparge_acid_amount']; $recipes .= ',"mash_ph":' . $row['mash_ph']; $recipes .= ',"mash_name":"' . $row['mash_name']; @@ -272,6 +325,9 @@ $recipes .= ',"w2_total_alkalinity":' . $row['w2_total_alkalinity']; $recipes .= ',"w2_ph":' . $row['w2_ph']; $recipes .= ',"w2_cost":' . $row['w2_cost']; + $recipes .= ',"wa_acid_name":' . $row['wa_acid_name']; + $recipes .= ',"wa_acid_perc":' . $row['wa_acid_perc']; + $recipes .= ',"wa_base_name":' . $row['wa_base_name']; $recipes .= ',"fermentables":' . $row['json_fermentables']; $recipes .= ',"hops":' . $row['json_hops']; $recipes .= ',"miscs":' . $row['json_miscs']; diff -r 4c21eabb3c0e -r 14e349ff2a10 www/js/global.js --- a/www/js/global.js Sun Jan 27 23:35:19 2019 +0100 +++ b/www/js/global.js Tue Jan 29 21:52:08 2019 +0100 @@ -125,6 +125,21 @@ }; var HopFormAdapter = new $.jqx.dataAdapter(HopFormSource); +var HopUseData = [ + { id: 0, en: 'Mash', nl: 'maischhop' }, + { id: 1, en: 'First wort', nl: 'first wort hop' }, + { id: 2, en: 'Boil', nl: 'koken' }, + { id: 3, en: 'Aroma', nl: 'vlamuit' }, + { id: 4, en: 'Whirlpool', nl: 'whirlpool' }, + { id: 5, en: 'Dry hop', nl: 'koudhop' } +]; +var HopUseSource = { + localdata: HopUseData, + datatype: "array", + datafields: [{ name: 'id' }, { name: 'en' }, { name: 'nl' }] +}; +var HopUseAdapter = new $.jqx.dataAdapter(HopUseSource); + var YeastTypeData = [ { id: 0, en: 'Lager', nl: 'ondergist' }, { id: 1, en: 'Ale', nl: 'bovengist' }, @@ -154,6 +169,19 @@ }; var YeastFormAdapter = new $.jqx.dataAdapter(YeastFormSource); +var YeastUseData = [ + { id: 0, en: 'Primary', nl: 'Hoofdgisting' }, + { id: 1, en: 'Secondary', nl: 'Nagisting' }, + { id: 2, en: 'Tertiary', nl: 'Lagering' }, + { id: 3, en: 'Bottle', nl: 'Bottelen' } +]; +var YeastUseSource = { + localdata: YeastUseData, + datatype: "array", + datafields: [{ name: 'id' }, { name: 'en' }, { name: 'nl' }, { name: 'cells' }] +}; +var YeastUseAdapter = new $.jqx.dataAdapter(YeastUseSource); + var FlocculationData = [ { id: 0, en: 'Low', nl: 'laag' }, { id: 1, en: 'Medium', nl: 'medium' }, @@ -342,6 +370,12 @@ }; var BaseTypeAdapter = new $.jqx.dataAdapter(BaseTypeSource); +var SpargeSourceData = [ + { id: 0, en: 'Source 1', nl: 'Bron 1' }, + { id: 1, en: 'Source 2', nl: 'Bron 2' }, + { id: 2, en: 'Mixed', nl: 'Gemengd' } +]; + // options for editors @@ -360,6 +394,9 @@ var Spin2dec5 = { inputMode: 'simple', spinMode: 'simple', theme: theme, width: 110, height: 23, min: 0, decimalDigits: 2, spinButtons: true, spinButtonsStep: 0.05 }; +var Spin3dec5 = { + inputMode: 'simple', spinMode: 'simple', theme: theme, width: 110, height: 23, min: 0, decimalDigits: 3, spinButtons: true, spinButtonsStep: 0.005 +}; var SpinpH = { inputMode: 'simple', spinMode: 'simple', theme: theme, width: 110, height: 23, min: 1, max: 14, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.1 }; @@ -400,7 +437,7 @@ { name: 'category_number', type: 'number' }, { name: 'style_letter', type: 'string' }, { name: 'style_guide', type: 'string' }, - { name: 'type', type: 'string' }, + { name: 'type', type: 'int' }, { name: 'og_min', type: 'float' }, { name: 'og_max', type: 'float' }, { name: 'fg_min', type: 'float' }, @@ -434,13 +471,13 @@ { name: 'tun_volume', type: 'float' }, { name: 'tun_weight', type: 'float' }, { name: 'tun_specific_heat', type: 'float' }, - { name: 'tun_material', type: 'string' }, + { name: 'tun_material', type: 'int' }, { 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: 'calc_boil_volume', type: 'bool' }, + { name: 'calc_boil_volume', type: 'int' }, { name: 'top_up_kettle', type: 'float' }, { name: 'hop_utilization', type: 'float' }, { name: 'notes', type: 'string' }, @@ -464,10 +501,10 @@ datafields: [ { name: 'record', type: 'number' }, { name: 'name', type: 'string' }, - { name: 'type', type: 'string' }, + { name: 'type', type: 'int' }, { name: 'yield', type: 'float' }, { name: 'color', type: 'float' }, - { name: 'add_after_boil', type: 'bool' }, + { name: 'add_after_boil', type: 'int' }, { name: 'origin', type: 'string' }, { name: 'supplier', type: 'string' }, { name: 'coarse_fine_diff', type: 'float' }, @@ -475,8 +512,8 @@ { name: 'diastatic_power', type: 'float' }, { name: 'protein', type: 'float' }, { name: 'max_in_batch', type: 'float' }, - { name: 'recommend_mash', type: 'bool' }, - { name: 'graintype', type: 'string' }, + { name: 'recommend_mash', type: 'int' }, + { name: 'graintype', type: 'int' }, { name: 'di_ph', type: 'float' }, { name: 'inventory', type: 'float' }, { name: 'cost', type: 'float' } @@ -507,7 +544,7 @@ { name: 'record', type: 'number' }, { name: 'name', type: 'string' }, { name: 'origin', type: 'string' }, - { name: 'type', type: 'string' }, + { name: 'type', type: 'int' }, { name: 'alpha', type: 'float' }, { name: 'beta', type: 'float' }, { name: 'humulene', type: 'float' }, @@ -515,8 +552,8 @@ { name: 'cohumulone', type: 'float' }, { name: 'myrcene', type: 'float' }, { name: 'hsi', type: 'float' }, - { name: 'useat', type: 'string' }, - { name: 'form', type: 'string' }, + { name: 'useat', type: 'int' }, + { name: 'form', type: 'int' }, { name: 'total_oil', type: 'float' }, { name: 'inventory', type: 'float' }, { name: 'cost', type: 'float' } @@ -546,9 +583,9 @@ datafields: [ { name: 'record', type: 'number' }, { name: 'name', type: 'string' }, - { name: 'type', type: 'string' }, - { name: 'use_use', type: 'string' }, - { name: 'amount_is_weight', type: 'bool' }, + { name: 'type', type: 'int' }, + { name: 'use_use', type: 'int' }, + { name: 'amount_is_weight', type: 'int' }, { name: 'time', type: 'float' }, { name: 'inventory', type: 'float' }, { name: 'cost', type: 'float' } @@ -578,8 +615,8 @@ datafields: [ { name: 'record', type: 'number' }, { name: 'name', type: 'string' }, - { name: 'type', type: 'string' }, - { name: 'form', type: 'string' }, + { name: 'type', type: 'int' }, + { name: 'form', type: 'int' }, { name: 'laboratory', type: 'string' }, { name: 'product_id', type: 'string' }, { name: 'min_temperature', type: 'float' }, @@ -613,7 +650,7 @@ datafields: [ { name: 'record', type: 'number' }, { name: 'name', type: 'string' }, - { name: 'unlimited_stock', type: 'bool' }, + { name: 'unlimited_stock', type: 'int' }, { name: 'calcium', type: 'float' }, { name: 'sulfate', type: 'float' }, { name: 'chloride', type: 'float' }, @@ -778,11 +815,11 @@ */ function kw_to_srm(colormethod, c) { - if (colormethod == "Morey") + if (colormethod == 0) // Morey return 1.4922 * Math.pow(c, 0.6859); - if (colormethod == "Mosher") + if (colormethod == 1) // Mosher return 0.3 * c + 4.7; - if (colormethod == "Daniels") + if (colormethod == 2) // Daniels return 0.2 * c + 8.4; } @@ -808,22 +845,22 @@ var pfactor = 1.0; var ibu = 0; - if ((Use == "Dry Hop") || (Use == "Dry hop") || (Use == "Whirlpool") || (Use == "Aroma")) { + if ((Use == 3) || (Use == 4) || (Use == 5)) { // Aroma, Whirlpool or Dry hop. fmoment = 0.0; - } else if (Use == "Mash") { - fmoment += my_factor_mashhop / 100; // Brouwhulp - } else if ((Use == "First Wort") || (Use == "First wort")) { - fmoment += my_factor_fwh / 100; // Brouwhulp, Louis, Ozzie + } else if (Use == 0) { // Mash + fmoment += my_factor_mashhop / 100; // Brouwhulp + } else if (Use == 1) { // First wort + fmoment += my_factor_fwh / 100; // Brouwhulp, Louis, Ozzie } - if (Form == "Pellet") { + if (Form == 0) { // Pellet pfactor += my_factor_pellet / 100; } - if (Form == "Plug" ) { + if (Form == 1 ) { // Plug pfactor += my_factor_plug / 100; } - if (Method == "Tinseth") { + if (Method == 0) { // Tinseth /* http://realbeer.com/hops/research.html */ var AddedAlphaAcids = (alpha * mass * 1000) / liters; var Bigness_factor = 1.65 * Math.pow( 0.000125, gravity - 1); @@ -831,10 +868,10 @@ var utiisation = Bigness_factor * BoilTime_factor; ibu = Math.round(utiisation * AddedAlphaAcids * fmoment * pfactor * 10) / 10.0; } - if (Method == "Daniels") { + if (Method == 2) { // Daniels var boilfactor; var sgfactor; - if (Form == "Leaf") + if (Form == 2) // Leaf boilfactor = -(0.0041*time*time)+(0.6162*time)+1.5779; else boilfactor = -(0.0051*time*time)+(0.7835*time)+1.9348; @@ -844,7 +881,7 @@ sgfactor = (gravity - 1050) / 200; ibu = Math.round(fmoment * ((mass * (alpha * 100) * boilfactor * 0.1) / (liters * (1 + sgfactor))) * 10) / 10; } - if (Method == "Rager") { + if (Method == 1) { // Rager var boilfactor; var sgfactor; boilfactor = fmoment * 18.11 + 13.86 * Math.tanh((time * 31.32) / 18.27); diff -r 4c21eabb3c0e -r 14e349ff2a10 www/js/rec_edit.js --- a/www/js/rec_edit.js Sun Jan 27 23:35:19 2019 +0100 +++ b/www/js/rec_edit.js Tue Jan 29 21:52:08 2019 +0100 @@ -74,6 +74,15 @@ var MMNaCl = 58.443; var MMCaOH2 = 74.06268; + var fermentableRow = 0; + var fermentableData = {}; + var hopRow = 0; + var hopData = {}; + var miscRow = 0; + var miscData = {}; + var yeastRow = 0; + var yeastData = {}; + console.log("record:" + my_record + " return:" + my_return + " theme:" + theme); $("#jqxLoader").jqxLoader({ width: 250, @@ -85,17 +94,18 @@ function setReadonly(ro) { var rw = ! ro; - var w100 = 100; + var w100 = 110; var w80 = 80; if (ro) { // jqxNumberInput width -20 for no spinbuttons - w100 = 80; + w100 = 90; w80 = 60; } $("#batch_size").jqxNumberInput({ spinButtons: rw, readOnly: ro, width: w100 }); $("#boil_size").jqxNumberInput({ spinButtons: rw, readOnly: ro, width: w100 }); $("#boil_time").jqxNumberInput({ spinButtons: rw, readOnly: ro, width: w100 }); $("#efficiency").jqxNumberInput({ spinButtons: rw, readOnly: ro, width: w100 }); - $("#est_og").jqxNumberInput({ spinButtons: rw, readOnly: ro }); + $("#est_og").jqxNumberInput({ spinButtons: rw, readOnly: ro, width: w100 }); + // id="st_fg_min" margin-left 15/35 maken $("#type").jqxDropDownList({ disabled: ro }); $("#styleSelect").jqxDropDownList({ disabled: ro }); $("#color_method").jqxDropDownList({ disabled: ro }); @@ -157,12 +167,12 @@ var row = rows[i]; if (row.f_adjust_to_total_100) my_100 = true; - if (row.f_type == "Sugar") + if (row.f_type == 1) // Sugar psugar += row.f_percentage; - if (row.f_graintype == "Crystal") + if (row.f_graintype == 2) // Crystal pcara += row.f_percentage; var d = row.f_amount * (row.f_yield / 100) * (1 - row.f_moisture / 100); - if (row.f_added == "Mash") { + if (row.f_added == 0) { // Mash d = parseFloat(dataRecord.efficiency) / 100 * d; sugarsm += d; mashkg += row.f_amount; @@ -171,6 +181,11 @@ colorw += row.f_amount * ebc_to_srm(row.f_color) / parseFloat(dataRecord.batch_size) * 8.34436; } to_100 = my_100; + if (to_100) { + $("#wf_amount").jqxNumberInput({ width: 90, readOnly: true, spinButtons: false }); + } else { + $("#wf_amount").jqxNumberInput({ width: 110, readOnly: false, spinButtons: true }); + } var est_og = estimate_sg(sugarsf, parseFloat(dataRecord.batch_size)); $('#est_og').val(est_og); $('#est_og2').val(est_og); @@ -191,7 +206,7 @@ function hopFlavourContribution(bt, vol, use, amount) { var result; - if ((use == "First Wort") || (use == "First wort")) { + if (use == 1) { // First wort result = 0.15; // assume 15% flavourcontribution for fwh } else if (bt > 50) { result = 0.10; // assume 10% flavourcontribution as a minimum @@ -212,13 +227,13 @@ result = 0; } else if (bt > 7.5) { result = 10.03 / (4 * Math.sqrt(2 * Math.PI)) * Math.exp(-0.5 * Math.pow((bt - 7.5) /4, 2)); - } else if (use == "Boil") { + } else if (use == 2) { // Boil result = 1; - } else if (use == "Aroma") { + } else if (use == 3) { // Aroma / vlamuit result = 1.2; - } else if (use == "Whirlpool") { + } else if (use == 4) { // Whirlpool result = 1.2; - } else if ((use == "Dry Hop") || (use == "Dry hop")) { + } else if (use == 5) { // Dry hop result = 1.33; } result = (result * amount * 1000) / vol; @@ -252,7 +267,7 @@ var rows = $('#yeastGrid').jqxGrid('getrows'); for (var i = 0; i < rows.length; i++) { var row = rows[i]; - if (row.y_use == "Primary") + if (row.y_use == 0) // Primary svg = parseFloat(row.y_attenuation); } } @@ -412,7 +427,7 @@ var rows = $('#fermentableGrid').jqxGrid('getrows'); for (var i = 0; i < rows.length; i++) { var row = rows[i]; - if (row.f_added == 'Mash' && row.f_graintype != 'No malt') { + if (row.f_added == 0 && row.f_graintype != 6) { // Added == Mash && graintype != No Malt // Check if acid is required var C1 = 0; if ((row.f_di_ph != 5.7) && ((row.f_acid_to_ph_57 < - 0.1) || (row.f_acid_to_ph_57 > 0.1))) { @@ -421,16 +436,16 @@ // If the acid_to_ph_5.7 is unknown from the maltster, guess the required acid. var ebc = row.f_color; switch (row.f_graintype) { - case 'Base': - case 'Special': - case 'Kilned': C1 = 0.014 * ebc - 34.192; - break; - case 'Crystal': C1 = -0.0597 * ebc - 32.457; - break; - case 'Roast': C1 = 0.0107 * ebc - 54.768; - break; - case 'Sour': C1 = -149; - break; + case 0: // Base, Special, Kilned + case 3: + case 5: C1 = 0.014 * ebc - 34.192; + break; + case 2: C1 = -0.0597 * ebc - 32.457; // Crystal + break; + case 1: C1 = 0.0107 * ebc - 54.768; // Roast + break; + case 4: C1 = -149; // Sour malt + break; } } x = C1 * (pHZ - row.f_di_ph); // AcidRequired(ZpH) @@ -462,39 +477,40 @@ function GetAcidSpecs(AT) { switch(AT) { - case 'Melkzuur': return { - pK1: 3.08, - pK2: 20, - pK3: 20, - MolWt: 90.08, - AcidSG: 1214, - AcidPrc: 0.88 - }; - case 'Zoutzuur': return { - pK1: -10, - pK2: 20, - pK3: 20, - MolWt: 36.46, - AcidSG: 1142, - AcidPrc: 0.28 - }; - case 'Fosforzuur': return { - pK1: 2.12, - pK2: 7.20, - pK3: 12.44, - MolWt: 98.00, - AcidSG: 1170, - AcidPrc: 0.25 - }; - case 'Zwavelzuur': return { - pK1: -10, - pK2: 1.92, - pK3: 20, - MolWt: 98.07, - AcidSG: 1700, - AcidPrc: 0.93 - }; + case 0: return { // Melkzuur + pK1: 3.08, + pK2: 20, + pK3: 20, + MolWt: 90.08, + AcidSG: 1214, + AcidPrc: 0.88 + }; + case 1: return { // Zoutzuur + pK1: -10, + pK2: 20, + pK3: 20, + MolWt: 36.46, + AcidSG: 1142, + AcidPrc: 0.28 + }; + case 2: return { // Fosforzuur + pK1: 2.12, + pK2: 7.20, + pK3: 12.44, + MolWt: 98.00, + AcidSG: 1170, + AcidPrc: 0.25 + }; + case 3: return { // Zwavelzuur + pK1: -10, + pK2: 1.92, + pK3: 20, + MolWt: 98.07, + AcidSG: 1700, + AcidPrc: 0.93 + }; } + console.log("Bummer, AT is " + AT); } // Procedure TFrmWaterAdjustment.CalcWater2; @@ -595,8 +611,8 @@ last_base = 'NaHCO3'; } - var AT = $("#wa_acid_name").val(); - var BT = $("#wa_base_name").val(); + var AT = dataRecord.wa_acid_name; // parseFloat($("#wa_acid_name").jqxNumberInput('decimal')); + var BT = parseFloat($("#wa_base_name").jqxNumberInput('decimal')); var result = GetAcidSpecs(AT); var pK1 = result.pK1; @@ -637,79 +653,79 @@ var f2d = f1d * r1d; var f3d = f2d * r2d; switch (BT) { - case 'NaHCO3': RA = -protonDeficit / (f1d - f3d); //mmol totaal - RA = RA * MMNaHCO3/1000; //gram - $("#wa_base").val(Math.round(RA * 100) / 100); - setWaterAgent(BT, Math.round(RA * 100) / 100); - if (liters > 0) { - // Na - RA = parseFloat($("#wa_nacl").jqxNumberInput('decimal')) * MMNa / MMNaCl + - parseFloat($("#wa_base").jqxNumberInput('decimal')) * MMNa / MMNaHCO3; - RA = 1000 * RA / liters; - sodium = wg_sodium + RA; - // HCO3 - RA = parseFloat($("#wa_base").jqxNumberInput('decimal')) * MMHCO3 / MMNaHCO3; - RA = 1000 * RA / liters; - bicarbonate = wg_bicarbonate + RA; - total_alkalinity = bicarbonate * 50 / 61; - RA = ResidualAlkalinity(wb_total_alkalinity, wb_calcium, wb_magnesium); - } - break; - case 'Na2CO3': RA = -protonDeficit / (2 * f1d + f2d); //mmol totaal - RA = RA * MMNa2CO3/1000; //gram - $("#wa_base").val(Math.round(RA * 100) / 100); - setWaterAgent(BT, Math.round(RA * 100) / 100); - if (liters > 0) { - RA = parseFloat($("#wa_nacl").jqxNumberInput('decimal')) * MMNa / MMNaCl + - parseFloat($("#wa_base").jqxNumberInput('decimal')) * 2 * MMNa / MMNa2CO3; - RA = 1000 * RA / liters; - sodium = wg_sodium + RA; - // HCO3 - RA = parseFloat($("#wa_base").jqxNumberInput('decimal')) * MMHCO3 / MMNa2CO3; - RA = 1000 * RA / liters; - bicarbonate = wg_bicarbonate + RA; - total_alkalinity = bicarbonate * 50 / 61; - RA = ResidualAlkalinity(wb_total_alkalinity, wb_calcium, wb_magnesium); - } - break; - case 'CaCO3': RA = -protonDeficit * (f1d - f3d); //mmol totaal - RA = RA * MMCaCO3/1000; //gram - //but only 1/3 is effective, so add 3 times as much - RA = 3 * RA; - $("#wa_base").val(Math.round(RA * 100) / 100); - setWaterAgent(BT, Math.round(RA * 100) / 100); - if (liters > 0) { - //Bicarbonate - RA = parseFloat($("#wa_base").jqxNumberInput('decimal')) / 3 * MMHCO3 / MMCaCO3; - RA = 1000 * RA / liters; - bicarbonate = wg_bicarbonate + RA; - total_alkalinity = bicarbonate * 50 / 61; - //Ca precipitates out as Ca10(PO4)6(OH)2 - RA = parseFloat($("#wa_cacl2").jqxNumberInput('decimal')) * MMCa / MMCaCl2 + - parseFloat($("#wa_caso4").jqxNumberInput('decimal')) * MMCa / MMCaSO4 + - parseFloat($("#wa_base").jqxNumberInput('decimal')) * MMCa / MMCaCO3; - RA = 1000 * RA / liters; - calcium = wg_calcium + RA; - RA = ResidualAlkalinity(wb_total_alkalinity, wb_calcium, wb_magnesium); - } - break; - case 'Ca(OH)2': RA = -protonDeficit / 19.3; // g - $("#wa_base").val(Math.round(RA * 100) / 100); - setWaterAgent(BT, Math.round(RA * 100) / 100); - if (liters > 0) { - // Bicarbonate - RA = -protonDeficit / liters; - total_alkalinity = wg_total_alkalinity + RA; - bicarbonate = total_alkalinity * 61 / 50; - // Calcium - RA = parseFloat($("#wa_cacl2").jqxNumberInput('decimal')) * MMCa / MMCaCl2 + - parseFloat($("#wa_caso4").jqxNumberInput('decimal')) * MMCa / MMCaSO4 + - parseFloat($("#wa_base").jqxNumberInput('decimal')) * MMCa / MMCaOH2; - RA = 1000 * RA / liters; - calcium = wg_calcium + RA; - RA = ResidualAlkalinity(wb_total_alkalinity, wb_calcium, wb_magnesium); - } - break; + case 0: RA = -protonDeficit / (f1d - f3d); //Sodiumbicarbonate, mmol totaal + RA = RA * MMNaHCO3/1000; //gram + $("#wa_base").val(Math.round(RA * 100) / 100); + setWaterAgent(BT, Math.round(RA * 100) / 100); + if (liters > 0) { + // Na + RA = parseFloat($("#wa_nacl").jqxNumberInput('decimal')) * MMNa / MMNaCl + + parseFloat($("#wa_base").jqxNumberInput('decimal')) * MMNa / MMNaHCO3; + RA = 1000 * RA / liters; + sodium = wg_sodium + RA; + // HCO3 + RA = parseFloat($("#wa_base").jqxNumberInput('decimal')) * MMHCO3 / MMNaHCO3; + RA = 1000 * RA / liters; + bicarbonate = wg_bicarbonate + RA; + total_alkalinity = bicarbonate * 50 / 61; + RA = ResidualAlkalinity(wb_total_alkalinity, wb_calcium, wb_magnesium); + } + break; + case 1: RA = -protonDeficit / (2 * f1d + f2d); // Sodiumcarbonate, mmol totaal + RA = RA * MMNa2CO3/1000; //gram + $("#wa_base").val(Math.round(RA * 100) / 100); + setWaterAgent(BT, Math.round(RA * 100) / 100); + if (liters > 0) { + RA = parseFloat($("#wa_nacl").jqxNumberInput('decimal')) * MMNa / MMNaCl + + parseFloat($("#wa_base").jqxNumberInput('decimal')) * 2 * MMNa / MMNa2CO3; + RA = 1000 * RA / liters; + sodium = wg_sodium + RA; + // HCO3 + RA = parseFloat($("#wa_base").jqxNumberInput('decimal')) * MMHCO3 / MMNa2CO3; + RA = 1000 * RA / liters; + bicarbonate = wg_bicarbonate + RA; + total_alkalinity = bicarbonate * 50 / 61; + RA = ResidualAlkalinity(wb_total_alkalinity, wb_calcium, wb_magnesium); + } + break; + case 2: RA = -protonDeficit * (f1d - f3d); // Calciumcarbonate, mmol totaal + RA = RA * MMCaCO3/1000; //gram + //but only 1/3 is effective, so add 3 times as much + RA = 3 * RA; + $("#wa_base").val(Math.round(RA * 100) / 100); + setWaterAgent(BT, Math.round(RA * 100) / 100); + if (liters > 0) { + //Bicarbonate + RA = parseFloat($("#wa_base").jqxNumberInput('decimal')) / 3 * MMHCO3 / MMCaCO3; + RA = 1000 * RA / liters; + bicarbonate = wg_bicarbonate + RA; + total_alkalinity = bicarbonate * 50 / 61; + //Ca precipitates out as Ca10(PO4)6(OH)2 + RA = parseFloat($("#wa_cacl2").jqxNumberInput('decimal')) * MMCa / MMCaCl2 + + parseFloat($("#wa_caso4").jqxNumberInput('decimal')) * MMCa / MMCaSO4 + + parseFloat($("#wa_base").jqxNumberInput('decimal')) * MMCa / MMCaCO3; + RA = 1000 * RA / liters; + calcium = wg_calcium + RA; + RA = ResidualAlkalinity(wb_total_alkalinity, wb_calcium, wb_magnesium); + } + break; + case 3: RA = -protonDeficit / 19.3; // Calciumhydroxide + $("#wa_base").val(Math.round(RA * 100) / 100); + setWaterAgent(BT, Math.round(RA * 100) / 100); + if (liters > 0) { + // Bicarbonate + RA = -protonDeficit / liters; + total_alkalinity = wg_total_alkalinity + RA; + bicarbonate = total_alkalinity * 61 / 50; + // Calcium + RA = parseFloat($("#wa_cacl2").jqxNumberInput('decimal')) * MMCa / MMCaCl2 + + parseFloat($("#wa_caso4").jqxNumberInput('decimal')) * MMCa / MMCaSO4 + + parseFloat($("#wa_base").jqxNumberInput('decimal')) * MMCa / MMCaOH2; + RA = 1000 * RA / liters; + calcium = wg_calcium + RA; + RA = ResidualAlkalinity(wb_total_alkalinity, wb_calcium, wb_magnesium); + } + break; } } ph = TpH; @@ -720,42 +736,43 @@ if (parseFloat($("#wa_base").jqxNumberInput('decimal')) > 0) { if (liters > 0) { switch (BT) { - case 'NaHCO3': // Na - RA = parseFloat($("#wa_nacl").jqxNumberInput('decimal')) * MMNa / MMNaCl + - parseFloat($("#wa_base").jqxNumberInput('decimal')) * MMNa / MMNaHCO3; - RA = 1000 * RA / liters; - sodium = wg_sodium + RA; - // HCO3 - RA = parseFloat($("#wa_base").jqxNumberInput('decimal')) * MMHCO3 / MMNaHCO3; - RA = 1000 * RA / liters; - bicarbonate = wg_bicarbonate + RA; - total_alkalinity = bicarbonate * 50 / 61; - RA = ResidualAlkalinity(wb_total_alkalinity, wb_calcium, wb_magnesium); - break; - case 'Na2CO3': RA = parseFloat($("#wa_nacl").jqxNumberInput('decimal')) * MMNa / MMNaCl + - parseFloat($("#wa_base").jqxNumberInput('decimal')) * 2 * MMNa / MMNa2CO3; - RA = 1000 * RA / liters; - sodium = wg_sodium + RA; - // HCO3 - RA = parseFloat($("#wa_base").jqxNumberInput('decimal')) * MMHCO3 / MMNa2CO3; - RA = 1000 * RA / liters; - bicarbonate = wg_bicarbonate + RA; - total_alkalinity = bicarbonate * 50 / 61; - RA = ResidualAlkalinity(wb_total_alkalinity, wb_calcium, wb_magnesium); - break; - case 'CaCO3': // Bicarbonate - RA = parseFloat($("#wa_base").jqxNumberInput('decimal')) / 3 * MMHCO3 / MMCaCO3; - RA = 1000 * RA / liters; - bicarbonate = wg_bicarbonate + RA; - total_alkalinity = bicarbonate * 50 / 61; - RA = ResidualAlkalinity(wb_total_alkalinity, wb_calcium, wb_magnesium); - // Ca - RA = parseFloat($("#wa_cacl2").jqxNumberInput('decimal')) * MMCa / MMCaCl2 + - parseFloat($("#wa_caso4").jqxNumberInput('decimal')) * MMCa / MMCaSO4 + - parseFloat($("#wa_base").jqxNumberInput('decimal')) * MMCa / MMCaCO3; - RA = 1000 * RA / liters; - calcium = wg_calcium + RA; - break; + case 0: // Sodiumbicarbonate, Na + RA = parseFloat($("#wa_nacl").jqxNumberInput('decimal')) * MMNa / MMNaCl + + parseFloat($("#wa_base").jqxNumberInput('decimal')) * MMNa / MMNaHCO3; + RA = 1000 * RA / liters; + sodium = wg_sodium + RA; + // HCO3 + RA = parseFloat($("#wa_base").jqxNumberInput('decimal')) * MMHCO3 / MMNaHCO3; + RA = 1000 * RA / liters; + bicarbonate = wg_bicarbonate + RA; + total_alkalinity = bicarbonate * 50 / 61; + RA = ResidualAlkalinity(wb_total_alkalinity, wb_calcium, wb_magnesium); + break; + case 1: // Sodiumcarbonate + RA = parseFloat($("#wa_nacl").jqxNumberInput('decimal')) * MMNa / MMNaCl + + parseFloat($("#wa_base").jqxNumberInput('decimal')) * 2 * MMNa / MMNa2CO3; + RA = 1000 * RA / liters; + sodium = wg_sodium + RA; + // HCO3 + RA = parseFloat($("#wa_base").jqxNumberInput('decimal')) * MMHCO3 / MMNa2CO3; + RA = 1000 * RA / liters; + bicarbonate = wg_bicarbonate + RA; + total_alkalinity = bicarbonate * 50 / 61; + RA = ResidualAlkalinity(wb_total_alkalinity, wb_calcium, wb_magnesium); + break; + case 2: // Calciumcarbonate: Bicarbonate + RA = parseFloat($("#wa_base").jqxNumberInput('decimal')) / 3 * MMHCO3 / MMCaCO3; + RA = 1000 * RA / liters; + bicarbonate = wg_bicarbonate + RA; + total_alkalinity = bicarbonate * 50 / 61; + RA = ResidualAlkalinity(wb_total_alkalinity, wb_calcium, wb_magnesium); + // Ca + RA = parseFloat($("#wa_cacl2").jqxNumberInput('decimal')) * MMCa / MMCaCl2 + + parseFloat($("#wa_caso4").jqxNumberInput('decimal')) * MMCa / MMCaSO4 + + parseFloat($("#wa_base").jqxNumberInput('decimal')) * MMCa / MMCaCO3; + RA = 1000 * RA / liters; + calcium = wg_calcium + RA; + break; } } } @@ -802,13 +819,13 @@ } } - if ((AT == 'Zwavelzuur') && (liters > 0)) { + if ((AT == 3) && (liters > 0)) { // Sulfuctic / Zwavelzuur RA = parseFloat($("#wa_caso4").jqxNumberInput('decimal')) * MMSO4 / MMCaSO4 + parseFloat($("#wa_mgso4").jqxNumberInput('decimal')) * MMSO4 / MMMgSO4 + Acidmg / 1000 * MMSO4 / (MMSO4 + 2); RA = 1000 * RA / liters; sulfate = wg_sulfate + RA; // Not add to sulfate?? - } else if ((AT == 'Zoutzuur') && (liters > 0)) { + } else if ((AT == 1) && (liters > 0)) { // Hydrochloric, Zoutzuur RA = parseFloat($("#wa_cacl2").jqxNumberInput('decimal')) * MMCl / MMCaCl2 + parseFloat($("#wa_nacl").jqxNumberInput('decimal')) * MMCl / MMNaCl + Acidmg / 1000 * MMCl / (MMCL + 1); @@ -932,9 +949,9 @@ //Step 6. Use these to compute the milliequivalents acid required per liter (mEq/L) var Acid = alkalinity * ((f1g-f1)+(f3-f3g)) + Math.pow(10, -TargetpH) - Math.pow(10, -Source_pH); //mEq/l - if ($("#sparge_acid_type").val() == "") { - $("#sparge_acid_type").val('Melkzuur'); - dataRecord.sparge_acid_type = 'Melkzuur'; + if ($("#sparge_acid_type").val() == NaN) { + $("#sparge_acid_type").val(0); + dataRecord.sparge_acid_type = 0; } var AT = dataRecord.sparge_acid_type; var result = GetAcidSpecs(AT); @@ -974,7 +991,7 @@ for (var i = 0; i < rows.length; i++) { var row = rows[i]; var d = row.f_percentage / 100 * (row.f_yield / 100) * (1 - row.f_moisture / 100); - if (row.f_added == "Mash") + if (row.f_added == 0) // Mash d = efficiency / 100 * d; tot += d; } @@ -1069,8 +1086,12 @@ }); $('#wa_acid_perc').on('change', function (event) { calcWater(); }); - $('#color_method').on('change', function (event) { calcFermentables(); }); + $('#color_method').on('change', function (event) { + dataRecord.color_method = event.args.index; + calcFermentables(); + }); $('#ibu_method').on('change', function (event) { + dataRecord.ibu_method = event.args.index; calcFermentables(); calcIBUs(); }); @@ -1157,8 +1178,8 @@ theme: theme, source: styleslist, displayMember: "name", - width: 150, - height: 27, + width: 180, + height: 23, dropDownVerticalAlignment: 'top', dropDownWidth: 500, dropDownHeight: 380, @@ -1176,7 +1197,7 @@ $("#st_category_number").val(datarecord.category_number); $("#st_letter").val(datarecord.style_letter); $("#st_guide").val(datarecord.style_guide); - $("#st_type").val(datarecord.type); + $("#st_type").val(StyleTypeData[datarecord.type].nl); $("#st_og_min").val(datarecord.og_min); $("#st_og_max").val(datarecord.og_max); $("#st_fg_min").val(datarecord.fg_min); @@ -1194,54 +1215,6 @@ var dataRecord = {}; var url = "includes/db_recipes.php"; - // tooltips - $("#name").jqxTooltip({ content: 'De naam voor dit recept.' }); - $("#notes").jqxTooltip({ content: 'De uitgebreide opmerkingen over dit recept.' }); - $("#type").jqxTooltip({ content: 'Het brouw type van dit recept.' }); - $("#batch_size").jqxTooltip({ content: 'Het volume van het gekoelde wort na het koken.' }); - $("#boil_time").jqxTooltip({ content: 'De kooktijd in minuten.' }); - $("#boil_size").jqxTooltip({ content: 'Het volume van het wort voor het koken.' }); - $("#efficiency").jqxTooltip({ content: 'Het rendement van maischen en koken.' }); - $("#est_og").jqxTooltip({ content: 'Het begin SG wat je wilt bereiken. De moutstort wordt automatisch herberekend.' }); - $("#est_og2").jqxTooltip({ content: 'Het begin SG wat je wilt bereiken. De moutstort wordt automatisch herberekend.' }); - $("#est_fg").jqxTooltip({ content: 'Het eind SG. Dit wordt automatisch berekend.' }); - $("#est_color").jqxTooltip({ content: 'De kleur in EBC. Dit wordt automatisch berekend.' }); - $("#est_color2").jqxTooltip({ content: 'De kleur in EBC. Dit wordt automatisch berekend.' }); - $("#est_ibu").jqxTooltip({ content: 'De bitterheid in IBU. Dit wordt automatisch berekend.' }); - $("#est_ibu2").jqxTooltip({ content: 'De bitterheid in IBU. Dit wordt automatisch berekend.' }); - $("#est_abv").jqxTooltip({ content: 'Alcohol volume %. Dit wordt automatisch berekend.' }); - $("#est_carb").jqxTooltip({ content: 'Koolzuur volume. Dit wordt automatisch berekend.' }); - - $("#st_name").jqxTooltip({ content: 'De bierstijl naam voor dit recept.'}); - $("#st_letter").jqxTooltip({ content: 'De bierstijl letter voor dit recept.'}); - $("#st_guide").jqxTooltip({ content: 'De bierstijl gids voor dit recept.'}); - $("#st_category").jqxTooltip({ content: 'De Amerikaanse bierstijl categorie.'}); - $("#st_category_number").jqxTooltip({ content: 'De Amerikaanse bierstijl categorie sub nummer.'}); - $("#st_type").jqxTooltip({ content: 'Het bierstijl type.'}); - $("#st_og_min").jqxTooltip({ content: 'Het minimum begin SG voor deze bierstijl.'}); - $("#st_og_max").jqxTooltip({ content: 'Het maximum begin SG voor deze bierstijl.'}); - $("#st_fg_min").jqxTooltip({ content: 'Het minimum eind SG voor deze bierstijl.'}); - $("#st_fg_max").jqxTooltip({ content: 'Het maximum eind SG voor deze bierstijl.'}); - $("#st_color_min").jqxTooltip({ content: 'De minimum kleur voor deze bierstijl.'}); - $("#st_color_max").jqxTooltip({ content: 'De maximum kleur voor deze bierstijl.'}); - $("#st_ibu_min").jqxTooltip({ content: 'De minimum bitterheid voor deze bierstijl.'}); - $("#st_ibu_max").jqxTooltip({ content: 'De maximum bitterheid voor deze bierstijl.'}); - $("#st_abv_min").jqxTooltip({ content: 'Het minimum alcohol volume % voor deze bierstijl.'}); - $("#st_abv_max").jqxTooltip({ content: 'Het maximum alcohol volume % voor deze bierstijl.'}); - $("#st_carb_min").jqxTooltip({ content: 'Het minimum koolzuur volume voor deze bierstijl.'}); - $("#st_carb_max").jqxTooltip({ content: 'Het maximum koolzuur volume voor deze bierstijl.'}); - $("#mash_ph").jqxTooltip({ content: 'Maisch pH tussen 5.2 en 5.6. Gebruik 5.2 voor lichte en 5.5 voor donkere bieren.'}); - $("#wa_cacl2").jqxTooltip({ content: 'Voor het maken van een ander waterprofiel. Voegt calcium en chloride toe. Voor het verbeteren van zoetere bieren.'}); - $("#wa_caso4").jqxTooltip({ content: 'Gips. Voor het maken van een ander waterprofiel. Voegt calcium en sulfaat toe. Voor het verbeteren van bittere bieren.'}); - $("#wa_mgso4").jqxTooltip({ content: 'Epsom zout. Voor het maken van een ander waterprofiel. Voegt magnesium en sulfaat toe. Gebruik spaarzaam!'}); - $("#wa_nacl").jqxTooltip({ content: 'Keukenzout. Voor het maken van een ander waterprofiel. Voegt natrium en chloride toe. Voor het accentueren van zoetheid. Bij hoge dosering wordt het bier ziltig.'}); - $("#w2_amount").jqxTooltip({ content: 'De verdeling van het hoofd en meng water. Het totale maisch water volume blijft gelijk.'}); - - $("#wb_calcium").jqxTooltip({ content: 'De ideale hoeveelheid Calcium is tussen 40 en 150.'}); - $("#wb_magnesium").jqxTooltip({ content: 'De ideale hoeveelheid Magnesium is lager dan 30.'}); - $("#wb_sodium").jqxTooltip({ content: 'De ideale hoeveelheid Natrium is lager dan 150.'}); - $("#wb_chloride").jqxTooltip({ content: 'De ideale hoeveelheid Chloride is lager dan 100.'}); - $("#wb_sulfate").jqxTooltip({ content: 'De ideale hoeveelheid Sulfaat is lager dan 350.'}); // prepare the data var source = { @@ -1254,7 +1227,7 @@ { name: 'st_name', type: 'string' }, { name: 'st_letter', type: 'string' }, { name: 'st_guide', type: 'string' }, - { name: 'st_type', type: 'string' }, + { name: 'st_type', type: 'int' }, { name: 'st_category', type: 'string' }, { name: 'st_category_number', type: 'float' }, { name: 'st_og_min', type: 'float' }, @@ -1271,7 +1244,7 @@ { name: 'st_abv_max', type: 'float' }, { name: 'name', type: 'string' }, { name: 'notes', type: 'string' }, - { name: 'type', type: 'string' }, + { name: 'type', type: 'int' }, { name: 'batch_size', type: 'float' }, { name: 'boil_size', type: 'float' }, { name: 'boil_time', type: 'float' }, @@ -1280,15 +1253,15 @@ { name: 'est_fg', type: 'float' }, { name: 'est_abv', type: 'float' }, { name: 'est_color', type: 'float' }, - { name: 'color_method', type: 'string' }, + { name: 'color_method', type: 'int' }, { name: 'est_ibu', type: 'float' }, - { name: 'ibu_method', type: 'string' }, + { name: 'ibu_method', type: 'int' }, { name: 'est_carb', type: 'float' }, { name: 'sparge_temp', type: 'float' }, { name: 'sparge_ph', type: 'float' }, { name: 'sparge_volume', type: 'float' }, { name: 'sparge_source', type: 'string' }, - { name: 'sparge_acid_type', type: 'string' }, + { name: 'sparge_acid_type', type: 'int' }, { name: 'sparge_acid_perc', type: 'float' }, { name: 'sparge_acid_amount', type: 'float' }, { name: 'mash_ph', type: 'float' }, @@ -1314,11 +1287,14 @@ { name: 'w2_total_alkalinity', type: 'float' }, { name: 'w2_ph', type: 'float' }, { name: 'w2_cost', type: 'float' }, + { name: 'wa_acid_name', type: 'int' }, + { name: 'wa_acid_perc', type: 'int' }, + { name: 'wa_base_name', type: 'int' }, { name: 'fermentables', type: 'array' }, - { name: 'hops', type: 'string' }, - { name: 'miscs', type: 'string' }, - { name: 'yeasts', type: 'string' }, - { name: 'mashs', type: 'string' } + { name: 'hops', type: 'array' }, + { name: 'miscs', type: 'array' }, + { name: 'yeasts', type: 'array' }, + { name: 'mashs', type: 'array' } ], id: 'record', url: url + '?record=' + my_record @@ -1337,7 +1313,7 @@ $("#st_guide").val(dataRecord.st_guide); $("#st_category").val(dataRecord.st_category); $("#st_category_number").val(dataRecord.st_category_number); - $("#st_type").val(dataRecord.st_type); + $("#st_type").val(StyleTypeData[dataRecord.st_type].nl); $("#type").val(dataRecord.type); $("#batch_size").val(dataRecord.batch_size); $("#boil_size").val(dataRecord.boil_size); @@ -1396,6 +1372,9 @@ $("#w2_total_alkalinity").val(dataRecord.w2_total_alkalinity); $("#w2_ph").val(dataRecord.w2_ph); $("#w2_cost").val(dataRecord.w2_cost); + $("#wa_acid_name").val(dataRecord.wa_acid_name); + $("#wa_acid_perc").val(dataRecord.wa_acid_perc); + $("#wa_base_name").val(dataRecord.wa_base_name); editFermentable(dataRecord); editHop(dataRecord); editMisc(dataRecord); @@ -1424,7 +1403,7 @@ { name: 'f_supplier', type: 'string' }, { name: 'f_amount', type: 'float' }, { name: 'f_cost', type: 'float' }, - { name: 'f_type', type: 'string' }, + { name: 'f_type', type: 'int' }, { name: 'f_yield', type: 'float' }, { name: 'f_color', type: 'float' }, { name: 'f_coarse_fine_diff', type: 'float' }, @@ -1432,15 +1411,16 @@ { name: 'f_diastatic_power', type: 'float' }, { name: 'f_protein', type: 'float' }, { name: 'f_max_in_batch', type: 'float' }, - { name: 'f_graintype', type: 'string' }, - { name: 'f_added', type: 'string' }, + { name: 'f_graintype', type: 'int' }, + { name: 'f_added', type: 'int' }, { name: 'f_dissolved_protein', type: 'float' }, - { name: 'f_recommend_mash', type: 'bool' }, - { name: 'f_add_after_boil', type: 'bool' }, - { name: 'f_adjust_to_total_100', type: 'bool' }, + { name: 'f_recommend_mash', type: 'int' }, + { name: 'f_add_after_boil', type: 'int' }, + { name: 'f_adjust_to_total_100', type: 'int' }, { name: 'f_percentage', type: 'float' }, { name: 'f_di_ph', type: 'float' }, - { name: 'f_acid_to_ph_57', type: 'float' } + { name: 'f_acid_to_ph_57', type: 'float' }, + { name: 'f_stock', type: 'float' }, ], addrow: function (rowid, rowdata, position, commit) { commit(true); @@ -1451,13 +1431,11 @@ }; var fermentableAdapter = new $.jqx.dataAdapter(fermentableSource); $("#fermentableGrid").jqxGrid({ - width: 1150, + width: 1240, height: 400, source: fermentableAdapter, theme: theme, selectionmode: 'singlerow', - editmode: 'selectedcell', - editable: true, localization: getLocalization(), showtoolbar: true, rendertoolbar: function (toolbar) { @@ -1504,13 +1482,13 @@ row["f_max_in_batch"] = datarecord.max_in_batch; row["f_graintype"] = datarecord.graintype; if (datarecord.add_after_boil) { - row["f_added"] = "Primary"; - } else if ((datarecord.type == "Sugar") || (datarecord.type == "Adjunct")) { - row["f_added"] = "Boil"; + row["f_added"] = 2; // Fermentation + } else if ((datarecord.type == 1) || (datarecord.type == 4)) { // Sugar or Adjunct + row["f_added"] = 1; // Boil } else { - row["f_added"] = "Mash"; + row["f_added"] = 0; // Mash } - row["f_dissolved_protein"] = 0; + row["f_dissolved_protein"] = datarecord.dissolved_protein; row["f_recommend_mash"] = datarecord.recommend_mash; row["f_add_after_boil"] = datarecord.add_after_boil; if (rowscount == 0) { @@ -1580,137 +1558,44 @@ $('#jqxTabs').jqxTabs('next'); }, columns: [ - { text: 'Vergistbaar ingrediënt', editable: false, datafield: 'f_name', + { text: 'Vergistbaar ingrediënt', datafield: 'f_name', cellsrenderer: function (row, columnfield, value, defaulthtml, columnproperties) { var rowData = $("#fermentableGrid").jqxGrid('getrowdata', row); return "" +rowData.f_supplier+" / "+rowData.f_name+" ("+rowData.f_color+" EBC)"; } }, - { text: 'Type', editable: false, align: 'center', cellsalign: 'center', width: 100, datafield: 'f_type' }, - { text: 'Moment', width: 110, align: 'center', cellsalign: 'center', datafield: 'f_added', columntype: 'dropdownlist', - createeditor: function (row, column, editor) { - var srcAdded = [ "Mash", "Boil", "Fermentation", "Lagering", "Bottle" ]; - editor.jqxDropDownList({ autoDropDownHeight: true, source: srcAdded }); + { text: 'Type', width: 100, datafield: 'f_type', + cellsrenderer: function (index, datafield, value, defaultvalue, column, rowdata) { + return "
" + FermentableTypeData[value].nl + "
"; + } + }, + { text: 'Moment', width: 110, datafield: 'f_added', + cellsrenderer: function (index, datafield, value, defaultvalue, column, rowdata) { + return "
" + AddedData[value].nl + "
"; } }, { text: 'Opbrengst', editable: false, datafield: 'f_yield', width: 90, align: 'right', cellsalign: 'right', cellsformat: 'p1' }, - { text: 'Gewicht Kg', datafield: 'f_amount', width: 120, align: 'right', cellsalign: 'right', cellsformat: 'f3', - columntype: 'numberinput', - validation: function (cell, value) { - // Maximum weight is the batch_size, just a simple check. - var maxmout = parseFloat($("#batch_size").jqxNumberInput('decimal')); - if (value < 0 || value > maxmout) { - return { result: false, message: "Gewicht moet 0-"+maxmout+" zijn" }; - } - return true; - }, - initeditor: function (row, cellvalue, editor) { - editor.jqxNumberInput({ inputMode: 'simple', min: 0, decimalDigits: 3, spinButtons: false }); - }, - cellvaluechanging: function (row, column, columntype, oldvalue, newvalue) { - if (to_100) { - return oldvalue; // When using percentages, don't allow edited results. - } - } - }, - { text: 'Percentage', datafield: 'f_percentage', width: 110, align: 'right', cellsalign: 'right', cellsformat: 'p1', - columntype: 'numberinput', - validation: function (cell, value) { - if (value < 0 || value > 100) { - return { result: false, message: "Percentage moet 0-100 zijn" }; + { text: 'Gewicht Kg', datafield: 'f_amount', width: 120, align: 'right', cellsalign: 'right', cellsformat: 'f3' }, + { text: 'Voorr. Kg', datafield: 'f_stock', width: 120, align: 'right', cellsalign: 'right', cellsformat: 'f3' }, + { text: 'Percent', datafield: 'f_percentage', width: 90, align: 'right', cellsalign: 'right', cellsformat: 'p1' }, + { text: '100%', align: 'center', datafield: 'f_adjust_to_total_100', columntype: 'checkbox', width: 70 }, + { text: 'Wijzig', datafield: 'Edit', columntype: 'button', width: 100, align: 'center', cellsrenderer: function () { + return "Wijzig"; + }, buttonclick: function (row) { + fermentableRow = row; + fermentableData = $("#fermentableGrid").jqxGrid('getrowdata', fermentableRow); + $("#wf_name").val(fermentableData.f_name); + $("#wf_amount").val(fermentableData.f_amount); + $("#wf_percentage").val(fermentableData.f_percentage); + $("#wf_adjust_to_total_100").val(fermentableData.f_adjust_to_total_100); + $("#wf_added").val(fermentableData.f_added); + // show the popup window. + $("#popupFermentable").jqxWindow('open'); } - return true; - }, - initeditor: function (row, cellvalue, editor) { - editor.jqxNumberInput({ decimalDigits: 1, min: 0, max: 100, spinButtons: false }); - }, - cellvaluechanging: function (row, column, columntype, oldvalue, newvalue) { - oldvalue = Math.round(oldvalue * 10) / 10.0; - var rowscount = $("#fermentableGrid").jqxGrid('getdatainformation').rowscount; - if ((oldvalue != newvalue) && (rowscount > 1)) { - var rowdata = $("#fermentableGrid").jqxGrid('getrowdata', row); - if (rowdata.f_adjust_to_total_100) { - return oldvalue; - } - var diff = newvalue - oldvalue; - var tw = 0; // total weight - for (i = 0; i < rowscount; i++) { - var rowdata = $("#fermentableGrid").jqxGrid('getrowdata', i); - tw += rowdata.f_amount; - } - if (to_100) { - // Adjust this row and the 100% row. - var rowdata = $("#fermentableGrid").jqxGrid('getrowdata', row); - rowdata.f_amount += tw * diff / 100; - for (i = 0; i < rowscount; i++) { - var rowdata = $("#fermentableGrid").jqxGrid('getrowdata', i); - if (rowdata.f_adjust_to_total_100) { - rowdata.f_percentage -= diff; - rowdata.f_amount -= tw * diff / 100; - } - } - } else { - // Adjust all the rows. - var nw = tw * diff / 100; - for (i = 0; i < rowscount; i++) { - var rowdata = $("#fermentableGrid").jqxGrid('getrowdata', i); - if (i == row) { - rowdata.f_amount += nw; - } else { - rowdata.f_amount -= nw / (rowscount - 1); - rowdata.f_percentage = Math.round((rowdata.f_amount / tw) * 1000) / 10.0; - } - } - } - } - } - }, - { text: '100%', align: 'center', datafield: 'f_adjust_to_total_100', columntype: 'checkbox', width: 80, - cellvaluechanging: function (row, column, columntype, oldvalue, newvalue) { - if (to_100) { - var rowscount = $("#fermentableGrid").jqxGrid('getdatainformation').rowscount; - for (i = 0; i < rowscount; i++) { - if (i != row) { - var rowdata = $("#fermentableGrid").jqxGrid('getrowdata', i); - rowdata.f_adjust_to_total_100 = false; - } - } - } - } - } + } ] }); - $("#fermentableGrid").on('cellendedit', function (event) { - var args = event.args; - console.log("Event Type: cellendedit, Column: " + args.datafield + ", Row: " + (args.rowindex) + ", Value: " + args.value); - // Make sure the grid itself is updated. - $("#fermentableGrid").jqxGrid('setcellvalue', args.rowindex, args.datafield, args.value); - if ((args.datafield == 'f_amount') && (! to_100)) { - // If one of the amounts is changed, recalculate the percentages. - console.log("adjust percentages"); - var rowscount = $("#fermentableGrid").jqxGrid('getdatainformation').rowscount; - if (rowscount > 1) { - var tw = 0; - for (i = 0; i < rowscount; i++) { - var rowdata = $("#fermentableGrid").jqxGrid('getrowdata', i); - tw += rowdata.f_amount; - }; - for (i = 0; i < rowscount; i++) { - var rowdata = $("#fermentableGrid").jqxGrid('getrowdata', i); - var percentage = Math.round(rowdata.f_amount / tw * 1000) / 10.0; - $("#fermentableGrid").jqxGrid('setcellvalue', i, "f_percentage", percentage); - }; - } else { - $("#fermentableGrid").jqxGrid('setcellvalue', 0, "f_percentage", 100); - } - }; - $('#fermentableGrid').jqxGrid('sortby', 'f_amount', 'desc'); // TODO: not reliable - calcFermentables(); - calcSVG(); - calcABV(); - calcIBUs(); // Depends on gravity, so recalculate. - }); }; // Inline hops editor @@ -1725,9 +1610,9 @@ { name: 'h_origin', type: 'string' }, { name: 'h_amount', type: 'float' }, { name: 'h_cost', type: 'float' }, - { name: 'h_type', type: 'string' }, - { name: 'h_form', type: 'string' }, - { name: 'h_useat', type: 'string' }, + { name: 'h_type', type: 'int' }, + { name: 'h_form', type: 'int' }, + { name: 'h_useat', type: 'int' }, { name: 'h_time', type: 'float' }, { name: 'h_alpha', type: 'float' }, { name: 'h_beta', type: 'float' }, @@ -1945,10 +1830,10 @@ { name: 'm_name', type: 'string' }, { name: 'm_amount', type: 'float' }, { name: 'm_cost', type: 'float' }, - { name: 'm_type', type: 'string' }, - { name: 'm_use_use', type: 'string' }, + { name: 'm_type', type: 'int' }, + { name: 'm_use_use', type: 'int' }, { name: 'm_time', type: 'float' }, - { name: 'm_amount_is_weight', type: 'bool' }, + { name: 'm_amount_is_weight', type: 'int' }, { name: 'm_weight', type: 'float' } ], addrow: function (rowid, rowdata, position, commit) { @@ -1975,41 +1860,41 @@ break; case 'NaCl': $("#wa_nacl").val(row.m_weight); break; - case 'Melkzuur': $("#wa_acid_name").val('Melkzuur'); + case 'Melkzuur': $("#wa_acid_name").val(0); $("#wa_acid").val(row.m_weight); $("#wa_acid_perc").val(80); - last_acid = 'Melkzuur'; + last_acid = 0; break; - case 'Zoutzuur': $("#wa_acid_name").val('Zoutzuur'); + case 'Zoutzuur': $("#wa_acid_name").val(1); $("#wa_acid").val(row.m_weight); $("#wa_acid_perc").val(80); - last_acid = 'Zoutzuur'; + last_acid = 1; break; - case 'Fosforzuur': $("#wa_acid_name").val('Fosforzuur'); + case 'Fosforzuur': $("#wa_acid_name").val(2); $("#wa_acid").val(row.m_weight); $("#wa_acid_perc").val(80); - last_acid = 'Fosforzuur'; + last_acid = 2; break; - case 'Zwavelzuur': $("#wa_acid_name").val('Zwavelzuur'); + case 'Zwavelzuur': $("#wa_acid_name").val(3); $("#wa_acid").val(row.m_weight); $("#wa_acid_perc").val(80); - last_acid = 'Zwavelzuur'; + last_acid = 3; break; - case 'NaHCO3': $("#wa_base_name").val('NaHCO3'); + case 'NaHCO3': $("#wa_base_name").val(0); $("#wa_base").val(row.m_weight); - last_base = 'NaHCO3'; + last_base = 0; break; - case 'Na2CO3': $("#wa_base_name").val('Na2CO3'); + case 'Na2CO3': $("#wa_base_name").val(1); $("#wa_base").val(row.m_weight); - last_base = 'Na2CO3'; + last_base = 1; break; - case 'CaCO3': $("#wa_base_name").val('CaCO3'); + case 'CaCO3': $("#wa_base_name").val(2); $("#wa_base").val(row.m_weight); - last_base = 'CaCO3'; + last_base = 2; break; - case 'Ca(OH)2': $("#wa_base_name").val('Ca(OH)2'); + case 'Ca(OH)2': $("#wa_base_name").val(3); $("#wa_base").val(row.m_weight); - last_base = 'Ca(OH)2'; + last_base = 3; break; } } @@ -2178,14 +2063,14 @@ { name: 'y_product_id', type: 'string' }, { name: 'y_amount', type: 'float' }, { name: 'y_cost', type: 'float' }, - { name: 'y_type', type: 'string' }, - { name: 'y_form', type: 'string' }, + { name: 'y_type', type: 'int' }, + { name: 'y_form', type: 'int' }, { name: 'y_time', type: 'float' }, { name: 'y_min_temperature', type: 'float' }, { name: 'y_max_temperature', type: 'float' }, { name: 'y_attenuation', type: 'float' }, - { name: 'y_amount_is_weight', type: 'bool' }, - { name: 'y_use', type: 'string' }, + { name: 'y_amount_is_weight', type: 'int' }, + { name: 'y_use', type: 'int' }, { name: 'y_weight', type: 'float' } ], addrow: function (rowid, rowdata, position, commit) { @@ -2257,9 +2142,9 @@ row["y_form"] = datarecord.form; row["y_amount"] = 0; row["y_cost"] = datarecord.cost; - row["y_use"] = "Primary"; + row["y_use"] = 0; row["y_time"] = 0; - if (datarecord.form == "Dry") { + if (datarecord.form == 1) { row["y_amount_is_weight"] = 1; } else { row["y_amount_is_weight"] = 0; @@ -2353,7 +2238,7 @@ var generaterow = function () { var row = {}; row["step_name"] = "Stap 1"; - row["step_type"] = "Infusion"; + row["step_type"] = 0; row["step_infuse_amount"] = 15; row["step_temp"] = 62.0; row['step_time'] = 20.0; @@ -2368,7 +2253,7 @@ async: false, datafields: [ { name: 'step_name', type: 'string' }, - { name: 'step_type', type: 'string' }, + { name: 'step_type', type: 'int' }, { name: 'step_infuse_amount', type: 'float' }, { name: 'step_temp', type: 'float' }, { name: 'step_time', type: 'float' }, @@ -2388,7 +2273,7 @@ var data = new Array(); for (var i = 0; i < records.length; i++) { var row = records[i]; - if (row.step_type == 'Infusion') + if (row.step_type == 0) // Infusion mash_infuse += parseFloat(row.step_infuse_amount); } }, @@ -2490,66 +2375,280 @@ }; // initialize the input fields. - var srcType = [ "All Grain", "Partial Mash", "Extract" ]; - var srcColor = [ "Morey", "Mosher", "Daniels" ]; - //var srcIBU = [ "Tinseth", "Rager", "Garetz", "Daniels", "Mosher", "Noonan" ]; - var srcIBU = [ "Tinseth", "Rager", "Daniels" ]; // Only these are supported at this time. var srcBase = [ "NaHCO3", "Na2CO3", "CaCO3", "Ca(OH)2" ]; var srcAcid = [ "Melkzuur", "Zoutzuur", "Fosforzuur", "Zwavelzuur" ]; var srcSource = [ "Bron 1", "Bron 2", "Gemengd" ]; + + // Tab 1, Algemeen + $("#name").jqxTooltip({ content: 'De naam voor dit recept.' }); $("#name").jqxInput({ theme: theme, width: 640, height: 23 }); $("#locked").jqxCheckBox({ theme: theme, width: 120, height: 23 }); + $("#notes").jqxTooltip({ content: 'De uitgebreide opmerkingen over dit recept.' }); $("#notes").jqxInput({ theme: theme, width: 960, height: 200 }); + $("#type").jqxTooltip({ content: 'Het brouw type van dit recept.' }); + $("#type").jqxDropDownList({ + theme: theme, + source: RecipeTypeAdapter, + valueMember: 'id', + displayMember: 'nl', + width: 180, + height: 23, + autoDropDownHeight: true + }); + $("#efficiency").jqxTooltip({ content: 'Het rendement van maischen en koken.' }); + $("#efficiency").jqxNumberInput( Perc1dec5 ); + $("#batch_size").jqxTooltip({ content: 'Het volume van het gekoelde wort na het koken.' }); + $("#batch_size").jqxNumberInput( Spin1dec5 ); + $("#batch_size").jqxNumberInput({ min: 4 }); + $("#boil_size").jqxTooltip({ content: 'Het volume van het wort voor het koken.' }); + $("#boil_size").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 90, height: 23, decimalDigits: 2, readOnly: true }); + $("#boil_time").jqxTooltip({ content: 'De kooktijd in minuten.' }); + $("#boil_time").jqxNumberInput( PosInt ); + $("#boil_time").jqxNumberInput({ min: 4, max: 360 }); + + $("#st_name").jqxTooltip({ content: 'De bierstijl naam voor dit recept.'}); $("#st_name").jqxInput({ theme: theme, width: 250, height: 23 }); + $("#st_letter").jqxTooltip({ content: 'De bierstijl letter voor dit recept.'}); $("#st_letter").jqxInput({ theme: theme, width: 100, height: 23 }); + $("#st_guide").jqxTooltip({ content: 'De bierstijl gids voor dit recept.'}); $("#st_guide").jqxInput({ theme: theme, width: 250, height: 23 }); + $("#st_category").jqxTooltip({ content: 'De Amerikaanse bierstijl categorie.'}); $("#st_category").jqxInput({ theme: theme, width: 250, height: 23 }); + $("#st_category_number").jqxTooltip({ content: 'De Amerikaanse bierstijl categorie sub nummer.'}); $("#st_category_number").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 0, readOnly: true }); - $("#st_type").jqxInput({ theme: theme, width: 90, height: 23 }); - $("#type").jqxDropDownList({ theme: theme, source: srcType, width: 125, height: 23, dropDownHeight: 95 }); - $("#batch_size").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: 4, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.1, symbol: 'L', symbolPosition: 'right' }); - $("#boil_size").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 100, height: 23, decimalDigits: 2, readOnly: true, symbol: 'L', symbolPosition: 'right' }); - $("#boil_time").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: 4, max: 360, decimalDigits: 0, spinButtons: true }); - $("#efficiency").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: 40, max: 100, decimalDigits: 0, spinButtons: true, symbol: '%', symbolPosition: 'right' }); - $("#est_og").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: 1.000, max: 1.200, decimalDigits: 3, spinButtons: true, spinButtonsStep: 0.001 }); - $("#est_og2").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 100, height: 23, decimalDigits: 3, readOnly: true }); + $("#st_type").jqxTooltip({ content: 'Het bierstijl type.'}); + $("#st_type").jqxInput({ theme: theme, width: 180, height: 23 }); + + $("#est_og").jqxTooltip({ content: 'Het begin SG wat je wilt bereiken. De moutstort wordt automatisch herberekend.' }); + $("#est_og").jqxNumberInput( SGopts ); + $("#st_og_min").jqxTooltip({ content: 'Het minimum begin SG voor deze bierstijl.'}); $("#st_og_min").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 3, readOnly: true }); + $("#st_og_max").jqxTooltip({ content: 'Het maximum begin SG voor deze bierstijl.'}); $("#st_og_max").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 3, readOnly: true }); - $("#est_fg").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 100, height: 23, decimalDigits: 3, readOnly: true }); + $("#est_fg").jqxTooltip({ content: 'Het eind SG. Dit wordt automatisch berekend.' }); + $("#est_fg").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 90, height: 23, decimalDigits: 3, readOnly: true }); + $("#st_fg_min").jqxTooltip({ content: 'Het minimum eind SG voor deze bierstijl.'}); $("#st_fg_min").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 3, readOnly: true }); + $("#st_fg_max").jqxTooltip({ content: 'Het maximum eind SG voor deze bierstijl.'}); $("#st_fg_max").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 3, readOnly: true }); + $("#est_abv").jqxTooltip({ content: 'Alcohol volume %. Dit wordt automatisch berekend.' }); $("#est_abv").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 1, readOnly: true }); + $("#st_abv_min").jqxTooltip({ content: 'Het minimum alcohol volume % voor deze bierstijl.'}); $("#st_abv_min").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 1, readOnly: true }); + $("#st_abv_max").jqxTooltip({ content: 'Het maximum alcohol volume % voor deze bierstijl.'}); $("#st_abv_max").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 1, readOnly: true }); - $("#est_color").jqxNumberInput({ inputMode: 'simple', theme: theme, symbol: ' EBC', symbolPosition: 'right', width: 100, height: 23, decimalDigits: 0, readOnly: true }); - $("#est_color2").jqxNumberInput({ inputMode: 'simple', theme: theme, symbol: ' EBC', symbolPosition: 'right', width: 100, height: 23, decimalDigits: 0, readOnly: true }); + $("#est_color").jqxTooltip({ content: 'De kleur in EBC. Dit wordt automatisch berekend.' }); + $("#est_color").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 90, height: 23, decimalDigits: 0, readOnly: true }); + $("#st_color_min").jqxTooltip({ content: 'De minimum kleur voor deze bierstijl.'}); $("#st_color_min").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 0, readOnly: true }); + $("#st_color_max").jqxTooltip({ content: 'De maximum kleur voor deze bierstijl.'}); $("#st_color_max").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 0, readOnly: true }); - $("#color_method").jqxDropDownList({ theme: theme, source: srcColor, width: 125, height: 23, dropDownHeight: 95 }); + $("#color_method").jqxDropDownList({ + theme: theme, + source: ColorMethodAdapter, + valueMember: 'id', + displayMember: 'nl', + width: 180, + height: 23, + autoDropDownHeight: true + }); - $("#est_ibu").jqxNumberInput({ inputMode: 'simple', theme: theme, symbol: ' IBU', symbolPosition: 'right', width: 100, height: 23, decimalDigits: 0, readOnly: true }); - $("#est_ibu2").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 0, readOnly: true }); + $("#est_ibu").jqxTooltip({ content: 'De bitterheid in IBU. Dit wordt automatisch berekend.' }); + $("#est_ibu").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 90, height: 23, decimalDigits: 0, readOnly: true }); + $("#st_ibu_min").jqxTooltip({ content: 'De minimum bitterheid voor deze bierstijl.'}); $("#st_ibu_min").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 0, readOnly: true }); + $("#st_ibu_max").jqxTooltip({ content: 'De maximum bitterheid voor deze bierstijl.'}); $("#st_ibu_max").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 0, readOnly: true }); - $("#ibu_method").jqxDropDownList({ theme: theme, source: srcIBU, width: 125, height: 23, dropDownHeight: 95, dropDownVerticalAlignment: 'top' }); + $("#ibu_method").jqxDropDownList({ + theme: theme, + source: IBUmethodAdapter, + valueMember: 'id', + displayMember: 'nl', + width: 180, + height: 23, + autoDropDownHeight: true, + dropDownVerticalAlignment: 'top' + }); + $("#est_carb").jqxTooltip({ content: 'Koolzuur volume. Dit wordt automatisch berekend.' }); $("#est_carb").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 1, readOnly: true }); + $("#st_carb_min").jqxTooltip({ content: 'Het minimum koolzuur volume voor deze bierstijl.'}); $("#st_carb_min").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 1, readOnly: true }); + $("#st_carb_max").jqxTooltip({ content: 'Het maximum koolzuur volume voor deze bierstijl.'}); $("#st_carb_max").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 1, readOnly: true }); - $("#mash_name").jqxInput({ theme: theme, width: 320, height: 23 }); - $("#mash_ph").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: 4, max: 8, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.1 }); - // Several gauges - $("#hop_flavour").jqxProgressBar({ width: 300, height: 23, theme: theme, showText: true }); - $("#hop_aroma").jqxProgressBar({ width: 300, height: 23, theme: theme, showText: true }); + // Tab 2, Vergistbaar + $("#est_color2").jqxTooltip({ content: 'De kleur in EBC. Dit wordt automatisch berekend.' }); + $("#est_color2").jqxNumberInput({ inputMode: 'simple', theme: theme, symbol: ' EBC', symbolPosition: 'right', width: 100, height: 23, decimalDigits: 0, readOnly: true }); + $("#est_og2").jqxTooltip({ content: 'Het begin SG wat je wilt bereiken. De moutstort wordt automatisch herberekend.' }); + $("#est_og2").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 100, height: 23, decimalDigits: 3, readOnly: true }); $("#perc_malts").jqxProgressBar({ width: 300, height: 23, theme: theme, showText: true }); $("#perc_sugars").jqxProgressBar({ width: 300, height: 23, theme: theme, showText: true }); $("#perc_cara").jqxProgressBar({ width: 300, height: 23, theme: theme, showText: true }); + $("#popupFermentable").jqxWindow({ + width: 800, + height: 300, + position: { x: 230, y: 100 }, + resizable: false, + theme: theme, + isModal: true, + autoOpen: false, + cancelButton: $("#FermentableReady"), + modalOpacity: 0.40 + }); + $("#FermentableReady").jqxButton({ template: "success", width: '90px', theme: theme }); + $("#FermentableReady").click(function () { + $("#fermentableGrid").jqxGrid('setcellvalue', fermentableRow, 'f_name', $("#wf_name").val()); - // Water treatment + // $("#fermentableGrid").jqxGrid('sortby', 'f_amount', 'desc'); + // Recalc percentages + // calcFermentables(); + // calcSVG(); + // calcABV(); + // calcIBUs(); + // Waters: yes there is impact. + }); + $("#wf_name").jqxInput({ theme: theme, width: 320, height: 23 }); + $("#wf_amount").jqxNumberInput( Spin3dec5 ); + $('#wf_amount').on('change', function (event) { + console.log("amount changed: "+event.args.value); + $("#fermentableGrid").jqxGrid('setcellvalue', fermentableRow, 'f_amount', event.args.value); + if (! to_100) { + // Recalculate percentages + console.log("adjust percentages"); + var rowscount = $("#fermentableGrid").jqxGrid('getdatainformation').rowscount; + if (rowscount > 1) { + var tw = 0; + for (i = 0; i < rowscount; i++) { + var rowdata = $("#fermentableGrid").jqxGrid('getrowdata', i); + tw += rowdata.f_amount; + }; + for (i = 0; i < rowscount; i++) { + var rowdata = $("#fermentableGrid").jqxGrid('getrowdata', i); + var percentage = Math.round(rowdata.f_amount / tw * 1000) / 10.0; + $("#fermentableGrid").jqxGrid('setcellvalue', i, "f_percentage", percentage); + // if (i == fermentableRow) // Will crash the script. + // $("#wf_percentage").val(percentage); + }; + } else { + $("#fermentableGrid").jqxGrid('setcellvalue', 0, "f_percentage", 100); + } + calcFermentables(); + }; + }); + $("#wf_percentage").jqxNumberInput( Perc1dec1 ); + $("#wf_percentage").on('change', function (event) { + var oldvalue = Math.round(fermentableData.f_percentage * 10) / 10.0; + var newvalue = event.args.value; + console.log("percentage changed: "+newvalue+" old: "+oldvalue); + var rowscount = $("#fermentableGrid").jqxGrid('getdatainformation').rowscount; + if ((oldvalue != newvalue) && (rowscount > 1)) { + var rowdata = $("#fermentableGrid").jqxGrid('getrowdata', fermentableRow); + if (rowdata.f_adjust_to_total_100) { + $("#wf_percentage").val(oldvalue); + } else { + var diff = newvalue - oldvalue; + var tw = 0; // total weight + for (i = 0; i < rowscount; i++) { + var rowdata = $("#fermentableGrid").jqxGrid('getrowdata', i); + tw += rowdata.f_amount; + } + if (to_100) { + // Adjust this row and the 100% row. + var damount = tw * diff / 100; + var rowdata = $("#fermentableGrid").jqxGrid('getrowdata', fermentableRow); + var namount = rowdata.f_amount + damount; + $("#fermentableGrid").jqxGrid('setcellvalue', fermentableRow, 'f_amount', namount); + $("#wf_amount").val(namount); + $("#fermentableGrid").jqxGrid('setcellvalue', fermentableRow, 'f_percentage', rowdata.f_percentage + diff); + for (i = 0; i < rowscount; i++) { + var rowdata = $("#fermentableGrid").jqxGrid('getrowdata', i); + if (rowdata.f_adjust_to_total_100) { + namount = rowdata.f_amount - damount; + $("#fermentableGrid").jqxGrid('setcellvalue', i, 'f_percentage', rowdata.f_percentage - diff); + $("#fermentableGrid").jqxGrid('setcellvalue', i, 'f_amount', namount); + } + } + calcFermentables(); + } else { + // Adjust all the rows. + var nw = tw * diff / 100; + for (i = 0; i < rowscount; i++) { + var rowdata = $("#fermentableGrid").jqxGrid('getrowdata', i); + if (i == fermentableRow) { + var namount = rowdata.f_amount + nw; + $("#fermentableGrid").jqxGrid('setcellvalue', i, 'f_amount', namount); + // $("#wf_amount").val(namount); // Will crash the script. + $("#fermentableGrid").jqxGrid('setcellvalue', i, 'f_percentage', newvalue); + } else { + var namount = rowdata.f_amount - (nw / (rowscount - 1)); + var newperc = Math.round((namount / tw) * 1000) / 10.0; + $("#fermentableGrid").jqxGrid('setcellvalue', i, 'f_amount', namount); + $("#fermentableGrid").jqxGrid('setcellvalue', i, 'f_percentage', newperc); + } + } + calcFermentables(); + } + } + } + + }); + $("#wf_adjust_to_total_100").jqxCheckBox({ theme: theme, width: 120, height: 23 }); + $("#wf_adjust_to_total_100").on('checked', function (event) { + if (fermentableData.f_adjust_to_total_100 == 0) { + // console.log("wf_adjust_to_total_100: checked row: "+fermentableRow+" old: "+fermentableData.f_adjust_to_total_100); + if (to_100) { + // Reset other flag first. + var rowscount = $("#fermentableGrid").jqxGrid('getdatainformation').rowscount; + for (var i = 0; i < rowscount; i++) { + if (i != fermentableRow) { + $("#fermentableGrid").jqxGrid('setcellvalue', i, 'f_adjust_to_total_100', 0); + } + } + } + $("#fermentableGrid").jqxGrid('setcellvalue', fermentableRow, 'f_adjust_to_total_100', 1); + calcFermentables(); + } + }); + $("#wf_adjust_to_total_100").on('unchecked', function (event) { + if (fermentableData.f_adjust_to_total_100 != 0) { + // console.log("wf_adjust_to_total_100: unchecked row: "+fermentableRow+" old: "+fermentableData.f_adjust_to_total_100); + $("#fermentableGrid").jqxGrid('setcellvalue', fermentableRow, 'f_adjust_to_total_100', 0); + calcFermentables(); + } + }); + $("#wf_added").jqxDropDownList({ + theme: theme, + source: AddedAdapter, + valueMember: 'id', + displayMember: 'nl', + width: 180, + height: 23, + autoDropDownHeight: true, + dropDownVerticalAlignment: 'top' + }); + + // Tab 3, Hoppen + $("#est_ibu2").jqxTooltip({ content: 'De bitterheid in IBU. Dit wordt automatisch berekend.' }); + $("#est_ibu2").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 0, readOnly: true }); + $("#hop_flavour").jqxProgressBar({ width: 300, height: 23, theme: theme, showText: true }); + $("#hop_aroma").jqxProgressBar({ width: 300, height: 23, theme: theme, showText: true }); + + // Tab 4, Diversen + + // Tab 5, Gist + + // Tab 6, Maischen + $("#mash_name").jqxInput({ theme: theme, width: 320, height: 23 }); + + // Tab 7, Water + $("#tgt_bu").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 2, readOnly: true }); + $("#tgt_cl_so4").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true }); + + // Water source 1 $("#w1_name").jqxDropDownList({ placeHolder: "Kies hoofd water:", theme: theme, @@ -2592,7 +2691,7 @@ $("#w1_chloride").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true }); $("#w1_sulfate").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true }); $("#w1_ph").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true }); - + // Water source 2 $("#w2_name").jqxDropDownList({ placeHolder: "Kies meng water:", theme: theme, @@ -2628,6 +2727,7 @@ calcWater(); } }); + $("#w2_amount").jqxTooltip({ content: 'De verdeling van het hoofd en meng water. Het totale maisch water volume blijft gelijk.'}); $("#w2_amount").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 94, height: 23, min: 0, max: 0, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.5, readOnly: true }); $("#w2_calcium").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true }); $("#w2_magnesium").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true }); @@ -2636,7 +2736,7 @@ $("#w2_chloride").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true }); $("#w2_sulfate").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true }); $("#w2_ph").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true }); - + // Water mixed $("#wg_amount").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true }); $("#wg_calcium").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true }); $("#wg_magnesium").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true }); @@ -2645,15 +2745,20 @@ $("#wg_chloride").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true }); $("#wg_sulfate").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true }); $("#wg_ph").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true }); - + // Water treated + $("#wb_calcium").jqxTooltip({ content: 'De ideale hoeveelheid Calcium is tussen 40 en 150.'}); $("#wb_calcium").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true }); + $("#wb_magnesium").jqxTooltip({ content: 'De ideale hoeveelheid Magnesium is lager dan 30.'}); $("#wb_magnesium").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true }); + $("#wb_sodium").jqxTooltip({ content: 'De ideale hoeveelheid Natrium is lager dan 150.'}); $("#wb_sodium").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true }); + $("#wb_chloride").jqxTooltip({ content: 'De ideale hoeveelheid Chloride is lager dan 100.'}); + $("#wb_chloride").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true }); + $("#wb_sulfate").jqxTooltip({ content: 'De ideale hoeveelheid Sulfaat is lager dan 350.'}); + $("#wb_sulfate").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true }); $("#wb_total_alkalinity").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true }); - $("#wb_chloride").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true }); - $("#wb_sulfate").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true }); $("#wb_ph").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true }); - + // Water target profile $("#pr_name").jqxDropDownList({ placeHolder: "Kies doel profiel:", theme: theme, @@ -2683,21 +2788,40 @@ $("#pr_chloride").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true }); $("#pr_sulfate").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true }); - $("#tgt_bu").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 2, readOnly: true }); - $("#tgt_cl_so4").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true }); - + // Water agents + $("#wa_cacl2").jqxTooltip({ content: 'Voor het maken van een ander waterprofiel. Voegt calcium en chloride toe. Voor het verbeteren van zoetere bieren.'}); $("#wa_cacl2").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: 0, max: 1000, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.1, symbol: ' gr', symbolPosition: 'right' }); + $("#wa_caso4").jqxTooltip({ content: 'Gips. Voor het maken van een ander waterprofiel. Voegt calcium en sulfaat toe. Voor het verbeteren van bittere bieren.'}); $("#wa_caso4").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: 0, max: 1000, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.1, symbol: ' gr', symbolPosition: 'right' }); + $("#wa_mgso4").jqxTooltip({ content: 'Epsom zout. Voor het maken van een ander waterprofiel. Voegt magnesium en sulfaat toe. Gebruik spaarzaam!'}); $("#wa_mgso4").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: 0, max: 1000, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.1, symbol: ' gr', symbolPosition: 'right' }); + $("#wa_nacl").jqxTooltip({ content: 'Keukenzout. Voor het maken van een ander waterprofiel. Voegt natrium en chloride toe. Voor het accentueren van zoetheid. Bij hoge dosering wordt het bier ziltig.'}); $("#wa_nacl").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: 0, max: 1000, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.1, symbol: ' gr', symbolPosition: 'right' }); - + $("#mash_ph").jqxTooltip({ content: 'Maisch pH tussen 5.2 en 5.6. Gebruik 5.2 voor lichte en 5.5 voor donkere bieren.'}); + $("#mash_ph").jqxNumberInput( SpinpH ); $("#calc_acid").jqxCheckBox({ theme: theme, width: 120, height: 23 }); - $("#wa_base_name").jqxDropDownList({ theme: theme, source: srcBase, width: 100, height: 23, dropDownHeight: 128 }); + $("#wa_base_name").jqxDropDownList({ + theme: theme, + source: BaseTypeAdapter, + valueMember: 'id', + displayMember: 'nl', + width: 180, + height: 23, + autoDropDownHeight: true + }); $("#wa_base").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: 0, decimalDigits: 2, spinButtons: true, spinButtonsStep: 0.05, symbol: ' gr', symbolPosition: 'right' }); - $("#wa_acid_name").jqxDropDownList({ theme: theme, source: srcAcid, width: 100, height: 23, dropDownHeight: 128 }); + $("#wa_acid_name").jqxDropDownList({ + theme: theme, + source: AcidTypeAdapter, + valueMember: 'id', + displayMember: 'nl', + width: 180, + height: 23, + autoDropDownHeight: true + }); $("#wa_acid").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: 0, decimalDigits: 2, spinButtons: true, spinButtonsStep: 0.05, symbol: ' ml', symbolPosition: 'right' }); $("#wa_acid_perc").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 80, height: 23, min: 0, max: 100, decimalDigits: 0, spinButtons: true, symbol: '%', symbolPosition: 'right' }); - + // Sparge water $("#sparge_temp").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: 70, max: 98, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.5 }); $("#sparge_volume").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.1 }); $("#sparge_ph").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: 4.5, max: 6.5, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.1 }); @@ -2772,7 +2896,7 @@ st_name: $('#st_name').val(), st_letter: $('#st_letter').val(), st_guide: $('#st_guide').val(), - st_type: $('#st_type').val(), + st_type: dataRecord.st_type, st_category: $('#st_category').val(), st_category_number: parseFloat($("#st_category_number").jqxNumberInput('decimal')), st_og_min: parseFloat($("#st_og_min").jqxNumberInput('decimal')), @@ -2830,6 +2954,9 @@ w2_total_alkalinity: parseFloat($("#w2_total_alkalinity").jqxNumberInput('decimal')), w2_ph: parseFloat($("#w2_ph").jqxNumberInput('decimal')), w2_cost: dataRecord.w2_cost, + wa_acid_name: $("#wa_acid_name").val(), + wa_acid_perc: parseFloat($("#wa_acid_perc").jqxNumberInput('decimal')), + wa_base_name: $("#wa_base_name").val(), fermentables: fermentablerow, hops: hoprow, miscs: miscrow, diff -r 4c21eabb3c0e -r 14e349ff2a10 www/rec_edit.php --- a/www/rec_edit.php Sun Jan 27 23:35:19 2019 +0100 +++ b/www/rec_edit.php Tue Jan 29 21:52:08 2019 +0100 @@ -32,15 +32,15 @@ Brouw type:
- Brouwzaal rendement: + Brouwzaal rendement %:
- Brouw volume: + Brouw volume L:
Kooktijd minuten:
- Kook volume: + Kook volume L:
@@ -77,16 +77,16 @@
- Kleur: -
+ Kleur EBC: +
Kleur methode:
Koolzuur vol:
- Bitterheid: -
+ Bitterheid IBU: +
Bitterheid methode:
@@ -124,7 +124,7 @@
-
+
@@ -335,6 +335,39 @@ +
+
Wijzig vergistbaar ingrediënt.
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
Ingrediënt naam:
Hoeveelheid kg:
Percentage %:
Aanvullen tot 100%:
Toevoegen tijdens:
+ +
+
+
+