Backported extra yeast fields and the SO4:Cl ratio changes into the recipes editor.

Tue, 03 Dec 2019 13:36:24 +0100

author
Michiel Broek <mbroek@mbse.eu>
date
Tue, 03 Dec 2019 13:36:24 +0100
changeset 559
10cc2400b5d5
parent 558
a8e065a9f851
child 560
850e82c1021d

Backported extra yeast fields and the SO4:Cl ratio changes into the recipes editor.

www/includes/db_recipes.php file | annotate | diff | comparison | revisions
www/js/prod_edit.js file | annotate | diff | comparison | revisions
www/js/rec_edit.js file | annotate | diff | comparison | revisions
www/rec_edit.php file | annotate | diff | comparison | revisions
--- a/www/includes/db_recipes.php	Mon Dec 02 20:56:01 2019 +0100
+++ b/www/includes/db_recipes.php	Tue Dec 03 13:36:24 2019 +0100
@@ -285,8 +285,15 @@
 			$yeast .= ',"y_tolerance":' . $item['y_tolerance'];
 			$yeast .= ',"y_inventory":' . $item['y_inventory'];
 			$yeast .= ',"y_use":' . $item['y_use'];
+			$yeast .= ',"y_sta1":' . $item['y_sta1'];
+                        $yeast .= ',"y_bacteria":' . $item['y_bacteria'];
+                        $yeast .= ',"y_harvest_top":' . $item['y_harvest_top'];
+                        $yeast .= ',"y_harvest_time":' . $item['y_harvest_time'];
+                        $yeast .= ',"y_pitch_temperature":' . $item['y_pitch_temperature'];
+                        $yeast .= ',"y_pofpos":' . $item['y_pofpos'];
+                        $yeast .= ',"y_zymocide":' . $item['y_zymocide'];
 			$yeast .= ',"y_cost":' . $item['y_cost'] . '}';
-			syslog(LOG_NOTICE, $yeast);
+			//syslog(LOG_NOTICE, $yeast);
 			$yeasts .= $yeast;
 		}
 	}
@@ -518,7 +525,8 @@
 				$yeasts[$i]['y_avail'] = 0;       // Ingredient not in db
 				if (! isset($yeasts[$i]['y_tolerance']))
 					$yeasts[$i]['y_tolerance'] = 0;
-				$sql2 = "SELECT inventory,tolerance FROM inventory_yeasts ";
+				$sql2 = "SELECT inventory,tolerance,sta1,bacteria,harvest_top,harvest_time,pitch_temperature,pofpos,zymocide ";
+				$sql2 .= "FROM inventory_yeasts ";
 				$sql2 .= "WHERE name='".str_replace($rescapers, $rreplacements, $yeasts[$i]['y_name'])."' AND";
 			       	$sql2 .= " form='".str_replace($rescapers, $rreplacements, $yeasts[$i]['y_form'])."' AND";
 				$sql2 .= " laboratory='".str_replace($rescapers, $rreplacements, $yeasts[$i]['y_laboratory'])."' AND";
@@ -527,9 +535,23 @@
 					if ($obj = mysqli_fetch_object($result2)) {
 						$yeasts[$i]['y_inventory'] = floatval($obj->inventory);
 						$yeasts[$i]['y_avail'] = 1;
-						if ($yeasts[$i]['y_tolerance'] == 0) {
+						if ($yeasts[$i]['y_tolerance'] == 0)
 							$yeasts[$i]['y_tolerance'] = floatval($obj->tolerance); // Upgrade alcohol tolerance
-						}
+						// Upgrade new fields
+                                                if (! isset($yeasts[$i]['y_sta1']))
+                                                        $yeasts[$i]['y_sta1'] = intval($obj->sta1);
+                                                if (! isset($yeasts[$i]['y_bacteria']))
+                                                        $yeasts[$i]['y_bacteria'] = intval($obj->bacteria);
+                                                if (! isset($yeasts[$i]['y_harvest_top']))
+                                                        $yeasts[$i]['y_harvest_top'] = intval($obj->harvest_top);
+                                                if (! isset($yeasts[$i]['y_harvest_time']))
+                                                        $yeasts[$i]['y_harvest_time'] = intval($obj->harvest_time);
+                                                if (! isset($yeasts[$i]['y_pitch_temperature']))
+                                                        $yeasts[$i]['y_pitch_temperature'] = floatval($obj->pitch_temperature);
+                                                if (! isset($yeasts[$i]['y_pofpos']))
+                                                        $yeasts[$i]['y_pofpos'] = intval($obj->pofpos);
+                                                if (! isset($yeasts[$i]['y_zymocide']))
+                                                        $yeasts[$i]['y_zymocide'] = intval($obj->zymocide);
 					}
 					mysqli_free_result($result2);
 				}
--- a/www/js/prod_edit.js	Mon Dec 02 20:56:01 2019 +0100
+++ b/www/js/prod_edit.js	Tue Dec 03 13:36:24 2019 +0100
@@ -2046,16 +2046,14 @@
   for (i = 0; i < rows.length; i++) {
    row = rows[i];
    total_ibus += toIBU(row.h_useat, row.h_form, preboil_sg, parseFloat(dataRecord.batch_size),
-                       parseFloat(row.h_amount), parseFloat(row.h_time), parseFloat(row.h_alpha), dataRecord.ibu_method,
-                       dataRecord.brew_whirlpool9, dataRecord.brew_whirlpool7, dataRecord.brew_whirlpool6);
+    parseFloat(row.h_amount), parseFloat(row.h_time), parseFloat(row.h_alpha), dataRecord.ibu_method,
+    dataRecord.brew_whirlpool9, dataRecord.brew_whirlpool7, dataRecord.brew_whirlpool6);
    ferm_ibus += toIBU(row.h_useat, row.h_form, preboil_sg,
-                      parseFloat(dataRecord.brew_fermenter_volume) + parseFloat(dataRecord.brew_fermenter_tcloss),
-                      parseFloat(row.h_amount), parseFloat(row.h_time), parseFloat(row.h_alpha), dataRecord.ibu_method,
-                      dataRecord.brew_whirlpool9, dataRecord.brew_whirlpool7, dataRecord.brew_whirlpool6);
-   hop_flavour += hopFlavourContribution(parseFloat(row.h_time), parseFloat(dataRecord.batch_size),
-                                        row.h_useat, parseFloat(row.h_amount));
-   hop_aroma += hopAromaContribution(parseFloat(row.h_time), parseFloat(dataRecord.batch_size),
-                                        row.h_useat, parseFloat(row.h_amount));
+    parseFloat(dataRecord.brew_fermenter_volume) + parseFloat(dataRecord.brew_fermenter_tcloss),
+    parseFloat(row.h_amount), parseFloat(row.h_time), parseFloat(row.h_alpha), dataRecord.ibu_method,
+    dataRecord.brew_whirlpool9, dataRecord.brew_whirlpool7, dataRecord.brew_whirlpool6);
+   hop_flavour += hopFlavourContribution(parseFloat(row.h_time), parseFloat(dataRecord.batch_size), row.h_useat, parseFloat(row.h_amount));
+   hop_aroma += hopAromaContribution(parseFloat(row.h_time), parseFloat(dataRecord.batch_size), row.h_useat, parseFloat(row.h_amount));
    if ((((dataRecord.inventory_reduced <= 2) && (row.h_useat <= 4)) ||  // Mash, FW, Boil, Aroma, Whirlpool
         ((dataRecord.inventory_reduced <= 6) && (row.h_useat == 5))) && // Dry-hop
         (row.h_inventory < row.h_amount))
--- a/www/js/rec_edit.js	Mon Dec 02 20:56:01 2019 +0100
+++ b/www/js/rec_edit.js	Tue Dec 03 13:36:24 2019 +0100
@@ -494,9 +494,13 @@
 }
 
 
-function GetOptClSO4ratio() {
- var BUGU = GetBUGU();
- return (-1.2 * BUGU + 1.4);
+function GetOptSO4Clratio() {
+ if (parseFloat($('#pr_sulfate').jqxNumberInput('decimal')) > 0 && parseFloat($('#pr_chloride').jqxNumberInput('decimal'))) {
+  return (parseFloat($('#pr_sulfate').jqxNumberInput('decimal')) / parseFloat($('#pr_chloride').jqxNumberInput('decimal')));
+ } else {
+  var BUGU = GetBUGU();
+  return (-1.2 * BUGU + 1.4);
+ }
 }
 
 
@@ -1534,6 +1538,13 @@
     { name: 'y_cells', type: 'float' },
     { name: 'y_tolerance', type: 'float' },
     { name: 'y_inventory', type: 'float' },
+    { name: 'y_sta1', type: 'int' },
+    { name: 'y_bacteria', type: 'int' },
+    { name: 'y_harvest_top', type: 'int' },
+    { name: 'y_harvest_time', type: 'int' },
+    { name: 'y_pitch_temperature', type: 'float' },
+    { name: 'y_pofpos', type: 'int' },
+    { name: 'y_zymocide', type: 'int' },
     { name: 'y_avail', type: 'int' }
    ],
    addrow: function(rowid, rowdata, position, commit) {
@@ -1600,6 +1611,13 @@
       row['y_cells'] = datarecord.cells;
       row['y_tolerance'] = datarecord.tolerance;
       row['y_inventory'] = datarecord.inventory;
+      row['y_sta1'] = datarecord.sta1;
+      row['y_bacteria'] = datarecord.bacteria;
+      row['y_harvest_top'] = datarecord.harvest_top;
+      row['y_harvest_time'] = datarecord.harvest_time;
+      row['y_pitch_temperature'] = datarecord.pitch_temperature;
+      row['y_pofpos'] = datarecord.pofpos;
+      row['y_zymocide'] = datarecord.zymocide;
       $('#yeastGrid').jqxGrid('addrow', null, row);
      }
      $('#yaddrowbutton').jqxDropDownList('clearSelection');
@@ -1920,7 +1938,7 @@
   AT, BT, result, pK1, pK2, pK3, MolWt, AcidSG, AcidPrc,
   r1d, r2d, f1d, f2d, f3d,
   deltapH, deltapd, pd, n,
-  piCLSO4_low, piCLSO4_high, Res,
+  Res,
   wg_calcium, wg_sodium, wg_total_alkalinity, wg_chloride, wg_sulfate, wg_bicarbonate;
 
   if (dataRecord.w1_name == '') {
@@ -2226,39 +2244,50 @@
    chloride = wg_chloride + RA;
   }
 
-  // 2:1 Sulfate to Chroride IPA's, Pale Ales.
-  // 1:1 Sulfate to Chloride Balanced
-  // 1:2 Sulfate to Chloride Malty
-  // Note, values below are the other way, cl to so4!
-  // So: 0.5 is IPA's, Pale Ales.
-  //       1 Balanced
-  //       2 Malty.
-  $('#tgt_bu').val(Math.round(GetBUGU() * 100) / 100);
+  var BUGU = GetBUGU();
+  $('#tgt_bu').val(Round(BUGU, 2));
   // From brouwhulp.
-  if (GetBUGU() < 0.32)
+  if (BUGU < 0.32)
    $('#wr_bu').html("<span style='vertical-align: top; font-size: 14px; font-style: italic;'>Zeer moutig en zoet</span>");
-  else if (GetBUGU() < 0.43)
+  else if (BUGU < 0.43)
    $('#wr_bu').html("<span style='vertical-align: top; font-size: 14px; font-style: italic;'>Moutig, zoet</span>");
-  else if (GetBUGU() < 0.52)
+  else if (BUGU < 0.52)
    $('#wr_bu').html("<span style='vertical-align: top; font-size: 14px; font-style: italic;'>Evenwichtig</span>");
-  else if (GetBUGU() < 0.63)
+  else if (BUGU < 0.63)
    $('#wr_bu').html("<span style='vertical-align: top; font-size: 14px; font-style: italic;'>Licht hoppig, bitter</span>");
   else
    $('#wr_bu').html("<span style='vertical-align: top; font-size: 14px; font-style: italic;'>Extra hoppig, zeer bitter</span>");
-  $('#tgt_cl_so4').val(Math.round(GetOptClSO4ratio() * 10) / 10);
-  if (sulfate > 0)
-   RA = chloride / sulfate;
+
+  // Sulfate to Chloride ratio (Palmer).
+  var OptSO4Clratio = GetOptSO4Clratio();
+  $('#tgt_so4_cl').val(Round(OptSO4Clratio, 1));
+  if (OptSO4Clratio < 0.4)
+   $('#wrt_so4_cl').html("<span style='vertical-align: top; font-size: 14px; font-style: italic;'>Te moutig</span>");
+  else if (OptSO4Clratio < 0.6)
+   $('#wrt_so4_cl').html("<span style='vertical-align: top; font-size: 14px; font-style: italic;'>Zeer moutig</span>");
+  else if (OptSO4Clratio < 0.8)
+   $('#wrt_so4_cl').html("<span style='vertical-align: top; font-size: 14px; font-style: italic;'>Moutig</span>");
+  else if (OptSO4Clratio < 1.5)
+   $('#wrt_so4_cl').html("<span style='vertical-align: top; font-size: 14px; font-style: italic;'>Gebalanceerd</span>");
+  else if (OptSO4Clratio < 2.0)
+   $('#wrt_so4_cl').html("<span style='vertical-align: top; font-size: 14px; font-style: italic;'>Licht bitter</span>");
+  else if (OptSO4Clratio < 4.0)
+   $('#wrt_so4_cl').html("<span style='vertical-align: top; font-size: 14px; font-style: italic;'>Bitter</span>");
+  else if (OptSO4Clratio < 9.0)
+   $('#wrt_so4_cl').html("<span style='vertical-align: top; font-size: 14px; font-style: italic;'>Zeer bitter</span>");
+  else
+   $('#wrt_so4_cl').html("<span style='vertical-align: top; font-size: 14px; font-style: italic;'>Te bitter</span>");
+  if (chloride > 0)
+   RA = sulfate / chloride;
   else
    RA = 10;
-  $('#got_cl_so4').val(Math.round(RA * 10) / 10);
-  piCLSO4_low = 0.8 * GetOptClSO4ratio();
-  piCLSO4_high = 1.2 * GetOptClSO4ratio();
+  $('#got_so4_cl').val(Round(RA, 1));
   Res = 'normaal';
-  if (RA < piCLSO4_low)
+  if (RA < (0.8 * OptSO4Clratio))
    Res = 'laag';
-  else if (RA > piCLSO4_high)
+  else if (RA > (1.2 * OptSO4Clratio))
    Res = 'hoog';
-  setRangeIndicator('cl_so4', Res);
+  setRangeIndicator('so4_cl', Res);
 
   $('#wb_calcium').val(Round(calcium, 1));
   $('#wb_magnesium').val(Round(magnesium, 1));
@@ -3514,6 +3543,13 @@
    y_cells: yeastData.y_cells,
    y_tolerance: yeastData.y_tolerance,
    y_inventory: yeastData.y_inventory,
+   y_sta1: yeastData.y_sta1,
+   y_bacteria: yeastData.y_bacteria,
+   y_harvest_top: yeastData.y_harvest_top,
+   y_harvest_time: yeastData.y_harvest_time,
+   y_pitch_temperature: yeastData.y_pitch_temperature,
+   y_pofpos: yeastData.y_pofpos,
+   y_zymocide: yeastData.y_zymocide,
    y_avail: yeastData.y_avail
   };
   $('#yeastGrid').jqxGrid('updaterow', rowID, row);
@@ -3560,9 +3596,16 @@
    yeastData.y_attenuation = datarecord.attenuation;
    yeastData.y_cells = datarecord.cells;
    yeastData.y_inventory = datarecord.inventory;
+   yeastData.y_sta1 = datarecord.sta1;
+   yeastData,y_bacteria = datarecord.bacteria;
+   yeastData.y_harvest_top = datarecord.harvest_top;
+   yeastData.y_harvest_time = datarecord.harvest_time;
+   yeastData.y_pitch_temperature = datarecord.pitch_temperature;
+   yeastData.y_pofpos = datarecord.pofpos;
+   yeastData.y_zymocide = datarecord.zymocide;
    if (yeastData.y_form == 0) {
     $('#wy_pmpt_amount').html('Pak(ken):');
-   } else if (yeastData.y_form == 1) {
+   } else if (yeastData.y_form == 1 || yeastData.y_form == 6) {
     $('#wy_pmpt_amount').html('Gewicht gram:');
    } else {
     $('#wy_pmpt_amount').html('Volume ml:');
@@ -3746,8 +3789,8 @@
 
  // Tab 7, Water
  $('#tgt_bu').jqxNumberInput(Show2wat);
- $('#tgt_cl_so4').jqxNumberInput(Show1wat);
- $('#got_cl_so4').jqxNumberInput(Show1wat);
+ $('#tgt_so4_cl').jqxNumberInput(Show1wat);
+ $('#got_so4_cl').jqxNumberInput(Show1wat);
 
  // Water source 1
  $('#w1_name').jqxDropDownList({
@@ -3880,6 +3923,7 @@
    $('#pr_sodium').val(datarecord.sodium);
    $('#pr_magnesium').val(datarecord.magnesium);
    $('#pr_total_alkalinity').val(datarecord.total_alkalinity);
+   calcWater();
   }
  });
  $('#pr_calcium').jqxNumberInput(Show1wat);
--- a/www/rec_edit.php	Mon Dec 02 20:56:01 2019 +0100
+++ b/www/rec_edit.php	Tue Dec 03 13:36:24 2019 +0100
@@ -199,10 +199,10 @@
           <tr>
            <td style="vertical-align: top; float: right; padding: 3px;">Bitterheidsindex:</td>
            <td style="padding: 3px;"><div style="float: left;" id="tgt_bu"></div><div style="float: left; margin-left: 10px;" id="wr_bu"></div></td>
-           <td style="vertical-align: top; float: right; padding: 3px;">Richtgetal Cl/SO4:</td>
-           <td style="padding: 3px;"><div id="tgt_cl_so4"></div></td>
-           <td style="vertical-align: top; float: right; padding: 3px;">Huidig Cl/SO4:</td>
-           <td style="padding: 3px;"><div style="float: left;" id="got_cl_so4"></div><div style="float: left; margin-left: 10px;" id="wr_cl_so4"></div></td>
+           <td style="vertical-align: top; float: right; padding: 3px;">Richtgetal SO4:Cl:</td>
+           <td style="padding: 3px;"><div style="float: left;" id="tgt_so4_cl"></div><div style="float: left; margin-left: 10px;" id="wrt_so4_cl"></div></td>
+           <td style="vertical-align: top; float: right; padding: 3px;">Huidig SO4:Cl:</td>
+           <td style="padding: 3px;"><div style="float: left;" id="got_so4_cl"></div><div style="float: left; margin-left: 10px;" id="wr_so4_cl"></div></td>
           </tr>
          </table>
         </td>

mercurial