# HG changeset patch # User Michiel Broek # Date 1536061442 -7200 # Node ID 7224109adfe1f61f19821b2bcc40ac9483953346 # Parent 6d94167c26974c492f3731357f943f2e6540ff8b More recipe editor changes diff -r 6d94167c2697 -r 7224109adfe1 www/import/from_brouwhulp.php --- a/www/import/from_brouwhulp.php Sat Sep 01 22:24:09 2018 +0200 +++ b/www/import/from_brouwhulp.php Tue Sep 04 13:44:02 2018 +0200 @@ -478,11 +478,46 @@ if ($recipe->STYLE) { if ($recipe->STYLE->NAME) - $sql .= "', style_name='" . mysqli_real_escape_string($db, $recipe->STYLE->NAME); + $sql .= "', st_name='" . mysqli_real_escape_string($db, $recipe->STYLE->NAME); if ($recipe->STYLE->STYLE_LETTER) - $sql .= "', style_letter='" . mysqli_real_escape_string($db, $recipe->STYLE->STYLE_LETTER); - if ($recipe->STYLE->STYLE_GUIDE) - $sql .= "', style_guide='" . mysqli_real_escape_string($db, $recipe->STYLE->STYLE_GUIDE); + $sql .= "', st_letter='" . mysqli_real_escape_string($db, $recipe->STYLE->STYLE_LETTER); + if ($recipe->STYLE->STYLE_GUIDE) { + if ($recipe->STYLE->STYLE_GUIDE == "Biertypengids Derek Walsh") { + $sql .= "', st_guide='BKG 2015"; + } else if ($recipe->STYLE->STYLE_GUIDE == "BKG Biertypen") { + $sql .= "', st_guide='BKG 2015"; + } else { + $sql .= "', st_guide='" . mysqli_real_escape_string($db, $recipe->STYLE->STYLE_GUIDE); + } + } + if ($recipe->STYLE->OG_MIN) + $sql .= "', st_og_min='" . floatval($recipe->STYLE->OG_MIN); + if ($recipe->STYLE->OG_MAX) + $sql .= "', st_og_max='" . floatval($recipe->STYLE->OG_MAX); + if ($recipe->STYLE->FG_MIN) + $sql .= "', st_fg_min='" . floatval($recipe->STYLE->FG_MIN); + if ($recipe->STYLE->FG_MAX) + $sql .= "', st_fg_max='" . floatval($recipe->STYLE->FG_MAX); + if ($recipe->STYLE->IBU_MIN) + $sql .= "', st_ibu_min='" . floatval($recipe->STYLE->IBU_MIN); + if ($recipe->STYLE->IBU_MAX) + $sql .= "', st_ibu_max='" . floatval($recipe->STYLE->IBU_MAX); + if ($recipe->STYLE->COLOR_MIN) { + $srm = floatval($recipe->STYLE->COLOR_MIN); + $sql .= "', st_color_min='" . srm_to_ebc($srm); + } + if ($recipe->STYLE->COLOR_MAX) { + $srm = floatval($recipe->STYLE->COLOR_MAX); + $sql .= "', st_color_max='" . srm_to_ebc($srm); + } + if ($recipe->STYLE->CARB_MIN) + $sql .= "', st_carb_min='" . floatval($recipe->STYLE->CARB_MIN); + if ($recipe->STYLE->CARB_MAX) + $sql .= "', st_carb_max='" . floatval($recipe->STYLE->CARB_MAX); + if ($recipe->STYLE->ABV_MIN) + $sql .= "', st_abv_min='" . floatval($recipe->STYLE->ABV_MIN); + if ($recipe->STYLE->ABV_MAX) + $sql .= "', st_abv_max='" . floatval($recipe->STYLE->ABV_MAX); } /* @@ -495,43 +530,43 @@ if ($comma) $fermentables .= ','; $comma = TRUE; - $fermentables .= '{"name":"' . mysqli_real_escape_string($db, $fermentable->NAME) . '"'; - $fermentables .= ',"amount":' . floatval($fermentable->AMOUNT); - $fermentables .= ',"cost":' . floatval($fermentable->COST); - $fermentables .= ',"type":"' . mysqli_real_escape_string($db, $fermentable->TYPE) . '"'; - $fermentables .= ',"yield":' . floatval($fermentable->YIELD); + $fermentables .= '{"f_name":"' . mysqli_real_escape_string($db, $fermentable->NAME) . '"'; + $fermentables .= ',"f_amount":' . floatval($fermentable->AMOUNT); + $fermentables .= ',"f_cost":' . floatval($fermentable->COST); + $fermentables .= ',"f_type":"' . mysqli_real_escape_string($db, $fermentable->TYPE) . '"'; + $fermentables .= ',"f_yield":' . floatval($fermentable->YIELD); if ($fermentable->COLOR) { $srm = floatval($fermentable->COLOR); $ebc = srm_to_ebc($srm); - $fermentables .= ',"color":' . $ebc; + $fermentables .= ',"f_color":' . $ebc; } if ($fermentable->COARSE_FINE_DIFF) { - $fermentables .= ',"coarse_fine_diff":' . floatval($fermentable->COARSE_FINE_DIFF); + $fermentables .= ',"f_coarse_fine_diff":' . floatval($fermentable->COARSE_FINE_DIFF); } if ($fermentable->MOISTURE) { - $fermentables .= ',"moisture":' . floatval($fermentable->MOISTURE); + $fermentables .= ',"f_moisture":' . floatval($fermentable->MOISTURE); } if ($fermentable->DIASTATIC_POWER) { - $fermentables .= ',"diastatic_power":' . floatval($fermentable->DIASTATIC_POWER); + $fermentables .= ',"f_diastatic_power":' . floatval($fermentable->DIASTATIC_POWER); } if ($fermentable->PROTEIN) { - $fermentables .= ',"protein":' . floatval($fermentable->PROTEIN); + $fermentables .= ',"f_protein":' . floatval($fermentable->PROTEIN); } if ($fermentable->MAX_IN_BATCH) { - $fermentables .= ',"max_in_batch":' . floatval($fermentable->MAX_IN_BATCH); + $fermentables .= ',"f_max_in_batch":' . floatval($fermentable->MAX_IN_BATCH); } if ($fermentable->GRAINTYPE) { - $fermentables .= ',"graintype":"' . mysqli_real_escape_string($db, $fermentable->GRAINTYPE) . '"'; + $fermentables .= ',"f_graintype":"' . mysqli_real_escape_string($db, $fermentable->GRAINTYPE) . '"'; } if ($fermentable->ADDED) { - $fermentables .= ',"added":"' . mysqli_real_escape_string($db, $fermentable->ADDED) . '"'; + $fermentables .= ',"f_added":"' . mysqli_real_escape_string($db, $fermentable->ADDED) . '"'; } if ($fermentable->DISSOLVED_PROTEIN) { - $fermentables .= ',"dissolved_protein":' . floatval($fermentable->DISSOLVED_PROTEIN); + $fermentables .= ',"f_dissolved_protein":' . floatval($fermentable->DISSOLVED_PROTEIN); } - ($fermentable->ADJUST_TO_TOTAL_100 == "TRUE") ? $fermentables .= ',"adjust_to_total_100":true' : $fermentables .= ',"adjust_to_total_100":false'; + ($fermentable->ADJUST_TO_TOTAL_100 == "TRUE") ? $fermentables .= ',"f_adjust_to_total_100":true' : $fermentables .= ',"f_adjust_to_total_100":false'; if ($fermentable->DI_pH) { - $fermentables .= ',"di_ph":' . floatval($fermentable->DI_pH); + $fermentables .= ',"f_di_ph":' . floatval($fermentable->DI_pH); } $fermentables .= "}"; } @@ -553,23 +588,23 @@ if ($comma) $hops .= ','; $comma = TRUE; - $hops .= '{"name":"' . mysqli_real_escape_string($db, $hop->NAME) . '"'; - $hops .= ',"amount":' . floatval($hop->AMOUNT); - $hops .= ',"cost":' . floatval($hop->COST); - $hops .= ',"type":"' . mysqli_real_escape_string($db, $hop->TYPE) . '"'; - $hops .= ',"form":"' . mysqli_real_escape_string($db, $hop->FORM) . '"'; - $hops .= ',"use":"' . mysqli_real_escape_string($db, $hop->USE) . '"'; + $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_use":"' . mysqli_real_escape_string($db, $hop->USE) . '"'; if ($hop->TIME) - $hops .= ',"time":' . floatval($hop->TIME); - $hops .= ',"alpha":' . floatval($hop->ALPHA); - $hops .= ',"beta":' . floatval($hop->BETA); - $hops .= ',"hsi":' . floatval($hop->HSI); - $hops .= ',"humulene":' . floatval($hop->HUMULENE); - $hops .= ',"carophyllene":' . floatval($hop->CAROPHYLLENE); - $hops .= ',"cohumulone":' . floatval($hop->COHUMULONE); - $hops .= ',"myrcene":' . floatval($hop->MYRCENE); + $hops .= ',"h_time":' . floatval($hop->TIME); + $hops .= ',"h_alpha":' . floatval($hop->ALPHA); + $hops .= ',"h_beta":' . floatval($hop->BETA); + $hops .= ',"h_hsi":' . floatval($hop->HSI); + $hops .= ',"h_humulene":' . floatval($hop->HUMULENE); + $hops .= ',"h_carophyllene":' . floatval($hop->CAROPHYLLENE); + $hops .= ',"h_cohumulone":' . floatval($hop->COHUMULONE); + $hops .= ',"h_myrcene":' . floatval($hop->MYRCENE); if ($hop->TOTAL_OIL) - $hops .= ',"total_oil":' . floatval($hop->TOTAL_OIL); + $hops .= ',"h_total_oil":' . floatval($hop->TOTAL_OIL); $hops .= "}"; } @@ -590,15 +625,15 @@ if ($comma) $miscs .= ','; $comma = TRUE; - $miscs .= '{"name":"' . mysqli_real_escape_string($db, $misc->NAME) . '"'; - $miscs .= ',"amount":' . floatval($misc->AMOUNT); + $miscs .= '{"m_name":"' . mysqli_real_escape_string($db, $misc->NAME) . '"'; + $miscs .= ',"m_amount":' . floatval($misc->AMOUNT); if ($misc->COST) - $miscs .= ',"cost":' . floatval($misc->COST); - $miscs .= ',"type":"' . mysqli_real_escape_string($db, $misc->TYPE) . '"'; - $miscs .= ',"use":"' . mysqli_real_escape_string($db, $misc->USE) . '"'; - ($misc->AMOUNT_IS_WEIGHT== "TRUE") ? $miscs .= ',"amount_is_weight":true' : $miscs.= ',"amount_is_weight":false'; + $miscs .= ',"m_cost":' . floatval($misc->COST); + $miscs .= ',"m_type":"' . mysqli_real_escape_string($db, $misc->TYPE) . '"'; + $miscs .= ',"m_use":"' . mysqli_real_escape_string($db, $misc->USE) . '"'; + ($misc->AMOUNT_IS_WEIGHT== "TRUE") ? $miscs .= ',"m_amount_is_weight":true' : $miscs.= ',"m_amount_is_weight":false'; if ($misc->TIME) - $miscs .= ',"time":' . floatval($misc->TIME); + $miscs .= ',"m_time":' . floatval($misc->TIME); $miscs .= "}"; } @@ -619,21 +654,21 @@ if ($comma) $yeasts .= ','; $comma = TRUE; - $yeasts .= '{"name":"' . mysqli_real_escape_string($db, $yeast->NAME) . '"'; - $yeasts .= ',"amount":' . floatval($yeast->AMOUNT); + $yeasts .= '{"y_name":"' . mysqli_real_escape_string($db, $yeast->NAME) . '"'; + $yeasts .= ',"y_amount":' . floatval($yeast->AMOUNT); if ($yeast->COST) - $yeasts .= ',"cost":' . floatval($yeast->COST); - $yeasts .= ',"laboratory":"' . mysqli_real_escape_string($db, $yeast->LABORATORY) . '"'; - $yeasts .= ',"product_id":"' . mysqli_real_escape_string($db, $yeast->PRODUCT_ID) . '"'; - $yeasts .= ',"type":"' . mysqli_real_escape_string($db, $yeast->TYPE) . '"'; - $yeasts .= ',"form":"' . mysqli_real_escape_string($db, $yeast->FORM) . '"'; - ($yeast->AMOUNT_IS_WEIGHT== "TRUE") ? $yeasts .= ',"amount_is_weight":true' : $yeasts.= ',"amount_is_weight":false'; + $yeasts .= ',"y_cost":' . floatval($yeast->COST); + $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) . '"'; + ($yeast->AMOUNT_IS_WEIGHT== "TRUE") ? $yeasts .= ',"y_amount_is_weight":true' : $yeasts.= ',"y_amount_is_weight":false'; if ($yeast->ADD_TO_SECONDARY=="FALSE") { - $yeasts .= ',"use":"Primary"'; + $yeasts .= ',"y_use":"Primary"'; } else if ($yeast->PRODUCT_ID=="F2") { - $yeasts .= ',"use":"Bottle"'; + $yeasts .= ',"y_use":"Bottle"'; } else { - $yeasts .= ',"use":"Secondary"'; + $yeasts .= ',"y_use":"Secondary"'; } $yeasts .= "}"; } @@ -655,24 +690,29 @@ if ($comma) $waters .= ','; $comma = TRUE; - $waters .= '{"name":"' . mysqli_real_escape_string($db, $water->NAME) . '"'; - $waters .= ',"amount":' . floatval($water->AMOUNT); + $waters .= '{"w_name":"' . mysqli_real_escape_string($db, $water->NAME) . '"'; + $waters .= ',"w_amount":' . floatval($water->AMOUNT); if ($water->CALCIUM) - $waters .= ',"calcium":' . floatval($water->CALCIUM); + $waters .= ',"w_calcium":' . floatval($water->CALCIUM); if ($water->BICARBONATE) - $waters .= ',"bicarbonate":' . floatval($water->BICARBONATE); + $waters .= ',"w_bicarbonate":' . floatval($water->BICARBONATE); if ($water->SULFATE) - $waters .= ',"sulfate":' . floatval($water->SULFATE); + $waters .= ',"w_sulfate":' . floatval($water->SULFATE); if ($water->CHLORIDE) - $waters .= ',"chloride":' . floatval($water->CHLORIDE); + $waters .= ',"w_chloride":' . floatval($water->CHLORIDE); if ($water->SODIUM) - $waters .= ',"sodium":' . floatval($water->SODIUM); + $waters .= ',"w_sodium":' . floatval($water->SODIUM); if ($water->MAGNESIUM) - $waters .= ',"magnesium":' . floatval($water->MAGNESIUM); + $waters .= ',"w_magnesium":' . floatval($water->MAGNESIUM); if ($water->PH) - $waters .= ',"ph":' . floatval($water->PH); + $waters .= ',"w_ph":' . floatval($water->PH); if ($water->TOTAL_ALKALINITY) - $waters .= ',"total_alkalinity":' . floatval($water->TOTAL_ALKALINITY); + $waters .= ',"w_total_alkalinity":' . floatval($water->TOTAL_ALKALINITY); + if ($water->COST) + $waters .= ',"w_cost":' . floatval($water->COST); + else + $waters .= ',"w_cost":0.00'; + ($water->DEFAULT_WATER== "TRUE") ? $waters .= ',"w_default_water":true' : $waters.= ',"w_default_water":false'; $waters .= "}"; } @@ -687,44 +727,39 @@ * Put the mash in a json array */ if ($recipe->MASH) { - $mash = '{"sparge_temp":' . floatval($recipe->MASH->SPARGE_TEMP); - $mash .= ',"ph":' . floatval($recipe->MASH->PH); + $sql .= "',mash_sparge_temp='" . floatval($recipe->MASH->SPARGE_TEMP); + $sql .= "',mash_ph='" . floatval($recipe->MASH->PH); if ($recipe->MASH->NAME) - $mash .= ',"name":"' . mysqli_real_escape_string($db, $recipe->MASH->NAME) . '"'; + $sql .= "',mash_name='" . mysqli_real_escape_string($db, $recipe->MASH->NAME); + if ($recipe->MASH->MASH_STEPS) { - $steps = ',"mash_steps":['; + $steps = '['; $comma = FALSE; foreach ($recipe->MASH->MASH_STEPS->MASH_STEP as $step) { if ($comma) $steps .= ','; $comma = TRUE; $steps .= '{"step_name":"' . mysqli_real_escape_string($db, $step->NAME) . '"'; - if ($step->TYPE) { + if ($step->TYPE) $steps .= ',"step_type":"' . $step->TYPE . '"'; - } - if ($step->STEP_TEMP) { - $steps .= ',"step_temp":"' . $step->STEP_TEMP . '"'; - } - if ($step->STEP_TIME) { - $steps .= ',"step_time":"' . $step->STEP_TIME . '"'; - } - if ($step->RAMP_TIME) { - $steps .= ',"ramp_time":"' . $step->RAMP_TIME . '"'; - } - if ($step->END_TEMP) { - $steps .= ',"end_temp":"' . $step->END_TEMP . '"'; - } + if ($step->INFUSE_AMOUNT) + $steps .= ',"step_infuse_amount":"' . floatval($step->INFUSE_AMOUNT) . '"'; + if ($step->STEP_TEMP) + $steps .= ',"step_temp":"' . floatval($step->STEP_TEMP) . '"'; + if ($step->STEP_TIME) + $steps .= ',"step_time":"' . floatval($step->STEP_TIME) . '"'; + if ($step->RAMP_TIME) + $steps .= ',"ramp_time":"' . floatval($step->RAMP_TIME) . '"'; + if ($step->END_TEMP) + $steps .= ',"end_temp":"' . floatval($step->END_TEMP) . '"'; $steps .= "}"; } $steps .= ']'; - $mash .= $steps; +// echo $steps . PHP_EOL; + $sql .= "', json_mashs='" . $steps; + if (strlen($steps) > $len_mash) + $len_mash = strlen($steps); } - - $mash .= '}'; -// echo $mash . PHP_EOL; - $sql .= "', json_mash='" . $mash; - if (strlen($mash) > $len_mash) - $len_mash = strlen($mash); } $sql .= "';"; diff -r 6d94167c2697 -r 7224109adfe1 www/includes/db_recipes.php --- a/www/includes/db_recipes.php Sat Sep 01 22:24:09 2018 +0200 +++ b/www/includes/db_recipes.php Tue Sep 04 13:44:02 2018 +0200 @@ -16,7 +16,7 @@ $replacements = array("\\\\", "\\/", "\\\"", "\\n", "\\r", "\\t", "\\f", "\\b"); // get data and store in a json array -$query = "SELECT * FROM recipes ORDER BY style_guide,style_letter,style_name,name"; +$query = "SELECT * FROM recipes ORDER BY st_guide,st_letter,st_name,name"; if (isset($_GET['insert'])) { // // INSERT COMMAND // $sql = "INSERT INTO `profile_mash` SET name='" . mysqli_real_escape_string($connect, $_GET['name']); @@ -68,10 +68,22 @@ } $comma = TRUE; $recipes .= '{"record":' . $row['record']; - $recipes .= ',"style_guide":"' . str_replace($escapers, $replacements, $row['style_guide']); - $recipes .= '","style_letter":"' . str_replace($escapers, $replacements, $row['style_letter']); - $recipes .= '","style_name":"' . str_replace($escapers, $replacements, $row['style_name']); - $recipes .= '","name":"' . str_replace($escapers, $replacements, $row['name']); + $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_og_min":' . floatval($row['st_og_min']); + $recipes .= ',"st_og_max":' . floatval($row['st_og_max']); + $recipes .= ',"st_fg_min":' . floatval($row['st_fg_min']); + $recipes .= ',"st_fg_max":' . floatval($row['st_fg_max']); + $recipes .= ',"st_ibu_min":' . floatval($row['st_ibu_min']); + $recipes .= ',"st_ibu_max":' . floatval($row['st_ibu_max']); + $recipes .= ',"st_color_min":' . floatval($row['st_color_min']); + $recipes .= ',"st_color_max":' . floatval($row['st_color_max']); + $recipes .= ',"st_carb_min":' . floatval($row['st_carb_min']); + $recipes .= ',"st_carb_max":' . floatval($row['st_carb_max']); + $recipes .= ',"st_abv_min":' . floatval($row['st_abv_min']); + $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']); @@ -83,12 +95,15 @@ $recipes .= ',"color_method":"' . $row['color_method']; $recipes .= '","est_ibu":' . floatval($row['est_ibu']); $recipes .= ',"ibu_method":"' . $row['ibu_method']; + $recipes .= '","mash_sparge_temp":' . $row['mash_sparge_temp']; + $recipes .= ',"mash_ph":' . $row['mash_ph']; + $recipes .= ',"mash_name":"' . $row['mash_name']; $recipes .= '","fermentables":' . $row['json_fermentables']; $recipes .= ',"hops":' . $row['json_hops']; $recipes .= ',"miscs":' . $row['json_miscs']; $recipes .= ',"yeasts":' . $row['json_yeasts']; $recipes .= ',"waters":' . $row['json_waters']; - $recipes .= ',"mash":' . $row['json_mash']; + $recipes .= ',"mashs":' . $row['json_mashs']; $recipes .= '}'; } $recipes .= ']'; diff -r 6d94167c2697 -r 7224109adfe1 www/includes/global.inc.php --- a/www/includes/global.inc.php Sat Sep 01 22:24:09 2018 +0200 +++ b/www/includes/global.inc.php Tue Sep 04 13:44:02 2018 +0200 @@ -62,6 +62,7 @@ + diff -r 6d94167c2697 -r 7224109adfe1 www/js/inv_fermentables.js --- a/www/js/inv_fermentables.js Sat Sep 01 22:24:09 2018 +0200 +++ b/www/js/inv_fermentables.js Tue Sep 04 13:44:02 2018 +0200 @@ -33,8 +33,8 @@ okButton: $('#delOk'), cancelButton: $('#delCancel'), initContent: function () { - $('#delOk').jqxButton({ width: '65px', theme: theme }); - $('#delCancel').jqxButton({ width: '65px', theme: theme }); + $('#delOk').jqxButton({ template: "danger", width: '65px', theme: theme }); + $('#delCancel').jqxButton({ template: "success", width: '65px', theme: theme }); $('#delCancel').focus(); } }); diff -r 6d94167c2697 -r 7224109adfe1 www/js/recipes.js --- a/www/js/recipes.js Sat Sep 01 22:24:09 2018 +0200 +++ b/www/js/recipes.js Tue Sep 04 13:44:02 2018 +0200 @@ -47,7 +47,7 @@ // tooltips $("#name").jqxTooltip({ content: 'De naam voor dit recept.' }); $("#notes").jqxTooltip({ content: 'De uitgebreide opmerkingen over dit recept.' }); - $("#style_name").jqxTooltip({ content: 'De bierstijl naam voor dit recept.'}); + $("#st_name").jqxTooltip({ content: 'De bierstijl naam voor dit recept.'}); $("#type").jqxTooltip({ content: 'Het brouw type van dit recept.' }); // prepare the data var source = { @@ -55,9 +55,11 @@ cache: false, datafields: [ { name: 'record', type: 'number' }, - { name: 'style_name', type: 'string' }, - { name: 'style_letter', type: 'string' }, - { name: 'style_guide', type: 'string' }, + { name: 'st_name', type: 'string' }, + { name: 'st_letter', type: 'string' }, + { name: 'st_guide', type: 'string' }, + { name: 'st_og_min', type: 'float' }, + { name: 'st_og_max', type: 'float' }, { name: 'name', type: 'string' }, { name: 'notes', type: 'string' }, { name: 'type', type: 'number' }, @@ -70,12 +72,15 @@ { name: 'color_method', type: 'string' }, { name: 'est_ibu', type: 'float' }, { name: 'ibu_method', type: 'string' }, - { name: 'json_fermentables', type: 'string' }, - { name: 'json_hops', type: 'string' }, - { name: 'json_miscs', type: 'string' }, - { name: 'json_yeasts', type: 'string' }, - { name: 'json_waters', type: 'string' }, - { name: 'json_mash', type: 'string' } + { name: 'mash_sparge_temp', type: 'float' }, + { name: 'mash_ph', type: 'float' }, + { name: 'mash_name', type: 'string' }, + { name: 'fermentables', type: 'string' }, + { name: 'hops', type: 'string' }, + { name: 'miscs', type: 'string' }, + { name: 'yeasts', type: 'string' }, + { name: 'waters', type: 'array' }, + { name: 'mashs', type: 'string' } ], id: 'record', url: url, @@ -129,28 +134,35 @@ } }; var dataAdapter = new $.jqx.dataAdapter(source); - // Inline steps editor -/* var editsteps = function (data) { - var generaterow = function () { - var row = {}; - row["step_name"] = "Stap 1"; - row["step_type"] = "Infusion"; - row["step_temp"] = 62.0; - row['step_time'] = 20.0; - row['ramp_time'] = 1.0; - row['end_temp'] = 62.0; - return row; - } - var stepSource = { - localdata: data.steps, + + // Inline waters editor + var editWater = function (data) { +// var generaterow = function () { +// var row = {}; +// row["w_name"] = "Water 1"; +// row["step_type"] = "Infusion"; +// row["w_amount"] = 22.0; +// row['step_time'] = 20.0; +// row['ramp_time'] = 1.0; +// row['end_temp'] = 62.0; +// return row; +// } + var waterSource = { + localdata: data.waters, datatype: "local", datafields: [ - { name: 'step_name', type: 'string' }, - { name: 'step_type', type: 'string' }, - { name: 'step_temp', type: 'float' }, - { name: 'step_time', type: 'float' }, - { name: 'ramp_time', type: 'float' }, - { name: 'end_temp', type: 'float' } + { name: 'w_name', type: 'string' }, + { name: 'w_amount', type: 'float' }, + { name: 'w_calcium', type: 'float' }, + { name: 'w_bicarbonate', type: 'float' }, + { name: 'w_sulfate', type: 'float' }, + { name: 'w_chloride', type: 'float' }, + { name: 'w_sodium', type: 'float' }, + { name: 'w_magnesium', type: 'float' }, + { name: 'w_ph', type: 'float' }, + { name: 'w_total_alkalinity', type: 'float' }, + { name: 'w_cost', type: 'float' }, + { name: 'w_default_water', type: 'bool' } ], addrow: function (rowid, rowdata, position, commit) { commit(true); @@ -159,15 +171,18 @@ commit(true); } }; - var stepAdapter = new $.jqx.dataAdapter(stepSource); - $("#grid").jqxGrid({ - width: 640, - height: 330, - source: stepAdapter, + var waterAdapter = new $.jqx.dataAdapter(waterSource); + $("#waterGrid").jqxGrid({ + width: 960, + height: 200, + source: waterAdapter, theme: theme, selectionmode: 'singlerow', editmode: 'selectedrow', editable: true, + showstatusbar: true, + statusbarheight: 50, + showaggregates: true, showtoolbar: true, rendertoolbar: function (toolbar) { var me = this; @@ -177,87 +192,72 @@ container.append(''); $("#addrowbutton").jqxButton({ theme: theme, width: 150 }); $("#deleterowbutton").jqxButton({ theme: theme, width: 150 }); - // create new row. - $("#addrowbutton").on('click', function () { - var datarow = generaterow(); - var commit = $("#grid").jqxGrid('addrow', null, datarow); - }); + // create new row. Dropdown uit water inventory. +// $("#addrowbutton").on('click', function () { +// var datarow = generaterow(); +// var commit = $("#waterGrid").jqxGrid('addrow', null, datarow); +// }); // delete row. - $("#deleterowbutton").on('click', function () { - var selectedrowindex = $("#grid").jqxGrid('getselectedrowindex'); - var rowscount = $("#grid").jqxGrid('getdatainformation').rowscount; - if (selectedrowindex >= 0 && selectedrowindex < rowscount) { - var id = $("#grid").jqxGrid('getrowid', selectedrowindex); - var commit = $("#grid").jqxGrid('deleterow', id); - } - }); + // Overgebleven waters in volume verhogen met het verwijderde water. +// $("#deleterowbutton").on('click', function () { +// var selectedrowindex = $("#grid").jqxGrid('getselectedrowindex'); +// var rowscount = $("#grid").jqxGrid('getdatainformation').rowscount; +// if (selectedrowindex >= 0 && selectedrowindex < rowscount) { +// var id = $("#grid").jqxGrid('getrowid', selectedrowindex); +// var commit = $("#grid").jqxGrid('deleterow', id); +// } +// }); }, columns: [ - { text: 'Stap naam', datafield: 'step_name' }, - { text: 'Stap type', datafield: 'step_type', width: 100, columntype: 'dropdownlist', - createeditor: function (row, cellvalue, editor, celltext, cellwidth, cellheight) { - var dataSource = [ "Infusion", "Temperature", "Decoction" ]; - editor.jqxDropDownList({ source: dataSource, dropDownHeight: 95 }); - } - }, - { text: 'Temperatuur', datafield: 'step_temp', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'f1', + { text: 'Water bron', editable: false, datafield: 'w_name' }, + { text: 'Volume', datafield: 'w_amount', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'f1', + columntype: 'numberinput', + aggregates: ['sum'], validation: function (cell, value) { - if (value < 35 || value > 80) { - return { result: false, message: "De temperatuur moet tussen 35 en 80 zijn." }; + if (value < 0 || value > 100000000000 ) { + return { result: false, message: "Volume moet 0-~ zijn" }; } return true; } }, - { text: 'Eind', datafield: 'end_temp', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'f1', - validation: function (cell, value) { - if (value < 35 || value > 80) { - return { result: false, message: "De temperatuur moet tussen 35 en 80 zijn." }; - } - return true; - } - }, - { text: 'Tijd', datafield: 'step_time', width: 70, align: 'right', cellsalign: 'right', - validation: function (cell, value) { - if (value < 1 || value > 360) { - return { result: false, message: "De tijd moet tussen 1 en 360 zijn." }; - } - return true; - } - }, - { text: 'Stap', datafield: 'ramp_time', width: 70, align: 'right', cellsalign: 'right', - validation: function (cell, value) { - if (value < 1 || value > 60) { - return { result: false, message: "De tijd moet tussen 1 en 60 zijn." }; - } - return true; - } - } + // TODO: validator test max is hoeveelheid maischwater. Dan water verdelen voor totaal. + { text: 'Ca', editable: false, datafield: 'w_calcium', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'f1' }, + { text: 'Mg', editable: false, datafield: 'w_magnesium', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'f1' }, + { text: 'Na', editable: false, datafield: 'w_sodium', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'f1' }, + { text: 'Tot Alk', editable: false, datafield: 'w_total_alkalinity', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'f1' }, + { text: 'CaSO4', editable: false, datafield: 'w_sulfate', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'f1' }, + { text: 'Cl', editable: false, datafield: 'w_chloride', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'f1' }, + { text: 'pH', editable: false, datafield: 'w_ph', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'f1' } ] }); - $("#grid").on('cellendedit', function (event) { - $('#grid').jqxGrid('sortby', 'step_temp', 'asc'); - }); - }; -*/ +// $("#grid").on('cellendedit', function (event) { +// $('#grid').jqxGrid('sortby', 'step_temp', 'asc'); +// }); + }; // editWater = function (data) { + // initialize the input fields. var srcType = [ "All Grain", "Partial Mash", "Extract" ]; var srcColor = [ "Morey", "Mosher", "Daniels" ]; var srcIBU = [ "Tinseth", "Rager", "Garetz", "Daniels", "Mosher", "Noonan" ]; $("#name").jqxInput({ theme: theme, width: 640, height: 23 }); $("#notes").jqxInput({ theme: theme, width: 960, height: 200 }); - $("#style_name").jqxInput({ theme: theme, width: 250, height: 23 }); - $("#style_letter").jqxInput({ theme: theme, width: 100, height: 23 }); - $("#style_guide").jqxInput({ theme: theme, width: 250, height: 23 }); + $("#st_name").jqxInput({ theme: theme, width: 250, height: 23 }); + $("#st_letter").jqxInput({ theme: theme, width: 100, height: 23 }); + $("#st_guide").jqxInput({ theme: theme, width: 250, 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_time").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', template: "success", 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, max: 1.9, decimalDigits: 3, spinButtons: true, spinButtonsStep: 0.001 }); + $("#st_og_min").jqxNumberInput({ disabled: true, inputMode: 'simple', width: 50, height: 23, decimalDigits: 3, readOnly: true }); + $("#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, min: 0.980, max: 1.040, decimalDigits: 3, readOnly: true }); $("#est_color").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: 1, max: 200, decimalDigits: 0, spinButtons: true }); $("#color_method").jqxDropDownList({ theme: theme, source: srcColor, width: 125, height: 23, dropDownHeight: 95 }); $("#est_ibu").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: 0, max: 200, decimalDigits: 0, spinButtons: true }); $("#ibu_method").jqxDropDownList({ theme: theme, source: srcIBU, width: 125, height: 23, dropDownHeight: 180 }); + $("#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 }); var editrow = -1; // initialize jqxGrid $("#jqxgrid").jqxGrid({ @@ -280,9 +280,9 @@ $("#popupWindow").jqxWindow({ position: { x: 40, y: 20 } }); $("#name").val(''); $("#notes").val(''); - $("#style_name").val(''); - $("#style_letter").val(''); - $("#style_guide").val(''); + $("#st_name").val(''); + $("#st_letter").val(''); + $("#st_guide").val(''); $("#type").val('All Grain'); $("#batch_size").val(20); $("#boil_time").val(90); @@ -293,16 +293,16 @@ $("#color_method").val('Morey'); $("#est_ibu").val(0); $("#ibu_method").val('Tinseth'); - // editsteps(''); + editWater(''); $("#popupWindow").jqxWindow('open'); }); }, filterable: true, filtermode: 'excel', columns: [ - { text: 'Stijlgids', datafield: 'style_guide', width: 120 }, - { text: 'Letter', datafield: 'style_letter', width: 60 }, - { text: 'Stijl', datafield: 'style_name', width: 150 }, + { text: 'Stijlgids', datafield: 'st_guide', width: 120 }, + { text: 'Letter', datafield: 'st_letter', width: 60 }, + { text: 'Stijl', datafield: 'st_name', width: 150 }, { text: 'Naam', datafield: 'name' }, { text: 'OG', datafield: 'est_og', width: 60, align: 'right', cellsalign: 'right', cellsformat: 'f3' }, { text: 'EBC', datafield: 'est_color', width: 60, align: 'right', cellsalign: 'right', cellsformat: 'f0' }, @@ -317,26 +317,31 @@ var dataRecord = $("#jqxgrid").jqxGrid('getrowdata', editrow); $("#name").val(dataRecord.name); $("#notes").val(dataRecord.notes); - $("#style_name").val(dataRecord.style_name); - $("#style_letter").val(dataRecord.style_letter); - $("#style_guide").val(dataRecord.style_guide); + $("#st_name").val(dataRecord.st_name); + $("#st_letter").val(dataRecord.st_letter); + $("#st_guide").val(dataRecord.st_guide); $("#type").val(dataRecord.type); $("#batch_size").val(dataRecord.batch_size); $("#boil_time").val(dataRecord.boil_time); $("#efficiency").val(dataRecord.efficiency); $("#est_og").val(dataRecord.est_og); + $("#st_og_min").val(dataRecord.st_og_min); + $("#st_og_max").val(dataRecord.st_og_max); $("#est_fg").val(dataRecord.est_fg); $("#est_color").val(dataRecord.est_color); $("#color_method").val(dataRecord.color_method); $("#est_ibu").val(dataRecord.est_ibu); $("#ibu_method").val(dataRecord.ibu_method); + $("#mash_name").val(dataRecord.mash_name); + $("#mash_ph").val(dataRecord.mash_ph); + editWater(dataRecord); // editsteps(dataRecord); // show the popup window. $("#popupWindow").jqxWindow('open'); } } ], - groups: ['style_guide','style_letter' ] + groups: ['st_guide','st_letter' ] }); // initialize the popup window and buttons. @@ -385,9 +390,9 @@ record: rowID, name: $("#name").val(), notes: $("#notes").val(), - style_name: $('#style_name').val(), - style_letter: $('#style_letter').val(), - style_guide: $('#style_guide').val(), + st_name: $('#st_name').val(), + st_letter: $('#st_letter').val(), + st_guide: $('#st_guide').val(), type: $("#type").val(), batch_size: parseFloat($("#batch_size").jqxNumberInput('decimal')), boil_time: parseFloat($("#boil_time").jqxNumberInput('decimal')), @@ -397,7 +402,9 @@ est_color: parseFloat($("#est_color").jqxNumberInput('decimal')), color_method: $("#color_method").val(), est_ibu: parseFloat($("#est_ibu").jqxNumberInput('decimal')), - ibu_method: $("#ibu_method").val() + ibu_method: $("#ibu_method").val(), + mash_name: $("#mash_name").val(), + mash_ph: parseFloat($("#mash_ph").jqxNumberInput('decimal')) // steps: steprows }; $('#jqxgrid').jqxGrid('updaterow', rowID, row); @@ -408,9 +415,9 @@ record: -1, name: $("#name").val(), notes: $("#notes").val(), - style_name: $('#style_name').val(), - style_letter: $('#style_letter').val(), - style_guide: $('#style_guide').val(), + st_name: $('#st_name').val(), + st_letter: $('#st_letter').val(), + st_guide: $('#st_guide').val(), type: $("#type").val(), batch_size: parseFloat($("#batch_size").jqxNumberInput('decimal')), boil_time: parseFloat($("#boil_time").jqxNumberInput('decimal')), @@ -420,7 +427,9 @@ est_color: parseFloat($("#est_color").jqxNumberInput('decimal')), color_method: $("#color_method").val(), est_ibu: parseFloat($("#est_ibu").jqxNumberInput('decimal')), - ibu_method: $("#ibu_method").val() + ibu_method: $("#ibu_method").val(), + mash_name: $("#mash_name").val(), + mash_ph: parseFloat($("#mash_ph").jqxNumberInput('decimal')) // steps: steprows }; $('#jqxgrid').jqxGrid('addrow', null, newrow); diff -r 6d94167c2697 -r 7224109adfe1 www/recipes.php --- a/www/recipes.php Sat Sep 01 22:24:09 2018 +0200 +++ b/www/recipes.php Tue Sep 04 13:44:02 2018 +0200 @@ -36,11 +36,11 @@ Stijlgids: - + Bier stijl: - + Bier groep: - + Brouw type: @@ -60,7 +60,7 @@ Start SG: -
+
Eind SG:
@@ -91,28 +91,75 @@
-2e tab + + + + + +
Ingredienten:
Graat
+
-Hoppen +
+ + + + + +
Hoppen:
Graat
+
+
-Misc +
+ + + + + +
Diversen:
Graat
+
+
-Gisten +
+ + + + + +
Gisten:
Graat
+
+
-Water +
+ + + + + + +
Water:
+
- - - + + + + + @@ -123,9 +170,9 @@ -
Maischchema:
Maischchema:Maish pH:
Stappen: