0) { $DEFAULT_BATCH_SZ = $row_user['defaultBatchSize']; } else { if ($row_pref['measFluid2'] == "gallons") $DEFAULT_BATCH_SZ = 5; else $DEFAULT_BATCH_SZ = 19; } $gravity = (isset($_POST['gravity']))?$_POST['gravity']:''; if (($action == "calculate") || ($action == "entry")) { // The $form variable and 'form' $_POST key are in reference to // the format of the hops, i.e. whole/plug or pellet. // It's easy to confuse this with fact that it's being // submitted via an HTML form. // @TODO: Format this form as $_POST['hops'][$i]['weight|aa|utilization|form'] so we can foreach over it $submittedHops = 0; for ($i = 0; $i < MAX_HOPS; $i++) { if (isset($_POST['hopWeight'][$i])) { $submittedHops = $i + 1; } $hopWeight[$i] = isset($_POST['hopWeight'][$i])?$_POST['hopWeight'][$i]:NULL; $hopAA[$i] = isset($_POST['hopAA'][$i])?$_POST['hopAA'][$i]:NULL; $utilization[$i] = isset($_POST['utilization'][$i])?$_POST['utilization'][$i]:NULL; $form[$i] = isset($_POST['form'][$i])?$_POST['form'][$i]:NULL; } $preBoilVol = $_POST['preBoilVol']; $finalVol = $_POST['finalVol']; $desiredIBUs = $_POST['desiredIBUs']; $elevation = $_POST['elevation']; $units = $_POST['units']; // Tinseth method $ibuT = 0; $ibu_T = array_fill(0, MAX_HOPS, NULL); for ($i = 0; $i < MAX_HOPS; $i++) { if (!isset($hopWeight[$i])) { continue; } $ibu_T[$i] = calc_bitter_tinseth($utilization[$i], $gravity, $hopAA[$i], $hopWeight[$i], $finalVol, $form[$i], $units); $ibuT += $ibu_T[$i]; } // Rager Method $ibuR = 0; $ibu_R = array_fill(0, MAX_HOPS, NULL); for ($i = 0; $i < MAX_HOPS; $i++) { if (!isset($hopWeight[$i])) { continue; } $ibu_R[$i] = calc_bitter_rager($utilization[$i], $gravity, $hopAA[$i], $hopWeight[$i], $finalVol, $form[$i], $units); $ibuR += $ibu_R[$i]; } // Daniels Method $ibuD = 0; $ibu_D = array_fill(0, MAX_HOPS, NULL); for ($i = 0; $i < MAX_HOPS; $i++) { if (!isset($hopWeight[$i])) { continue; } $ibu_D[$i] = calc_bitter_daniels($utilization[$i], $gravity, $hopAA[$i], $hopWeight[$i], $finalVol, $form[$i], $units); $ibuD += $ibu_D[$i]; } // Garetz Method $ibuG = 0; $ibu_G = array_fill(0, MAX_HOPS, NULL); if (($preBoilVol > 0) && ($desiredIBUs > 0) && ($elevation >= 0)) { for ($i = 0; $i < MAX_HOPS; $i++) { if (!isset($hopWeight[$i])) { continue; } $ibu_G[$i] = calc_bitter_garetz($utilization[$i], $gravity, $hopAA[$i], $hopWeight[$i], $finalVol, $form[$i], $units, $preBoilVol, $desiredIBUs, $elevation); $ibuG += $ibu_G[$i]; } } } // End if calculate if (($action == "default") || ($action == "entry")) { ?>
">
International Bitterness Unit (IBU) Calculator
'; echo ''."\n"; echo ''."\n"; echo ''."\n"; echo ''."\n"; echo ''."\n"; echo ''."\n"; echo ''."\n"; echo ''."\n"; echo ''."\n"; } } create_hop_entries(0, $INIT_HOP_ENTRIES - 1); // Add any extra hop entries if the user previously gave values for them. if ($action == "entry") { $endHopEntries = 0; for ($i = $INIT_HOP_ENTRIES; $i < MAX_HOPS; $i++) { if ($hopWeight[$i] > 0) $endHopEntries = $i; } if ($endHopEntries > 0) create_hop_entries($INIT_HOP_ENTRIES, $endHopEntries); } ?>
Hop ' . ($i + 1) . ' Weight:'; if ($i == 0) echo '*'; echo 'Hop ' . ($i + 1) . ' AA%:'; if ($i == 0) echo '*'; echo 'Hop ' . ($i + 1) . ' Time (min):'; if ($i == 0) echo '*'; echo 'Form:'; echo 'Pellet '; echo 'Whole/Plug
0)) echo $endHopEntries + 1; else echo $INIT_HOP_ENTRIES; ?>);" class="add-button">
Final Volume:* " />
Original Gravity:* " /> e.g., 1.045
Target IBUs: " /> (only required for Garetz)
Elevation: " /> feet or meters (only required for Garetz)
Pre-Boil Volume: " /> (only required for Garetz)
Units * indicates required field
/button_calculate_Brilliant.png" alt="Calculate" class="calcButton" value="Calculate" /> /button_clear_Brilliant.png" border="0" title="Clear" alt="Clear"/>
'; echo ''; echo ''; echo ''; } ?>
">
International Bitterness Unit Calculator
0) $endHopEntries = $i; } for ($i = 0; $i <= $endHopEntries; $i++) { echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; } ?> 0) { echo ''; } else { echo ''; } ?> 0) { echo ''; echo ''; echo ''; echo ''; } ?>
  Daniels Garetz Rager Tinseth
Hop ' . ($i + 1) . ' IBU: ' . round($ibu_D[$i], 1) . '' . round($ibu_G[$i], 1) . '' . round($ibu_R[$i], 1) . '' . round($ibu_T[$i], 1) . '
Total IBUs:
Average IBUs: '; $ibuAverage = ($ibuG + $ibuR + $ibuT + $ibuD) / 4; echo round ($ibuAverage, 1) . ''; $ibuAverage = ($ibuR + $ibuT + $ibuD) / 3; echo round ($ibuAverage, 1); echo '(Garetz formula excluded from avg.)
Target IBUs:' . $desiredIBUs . '
/button_back_Brilliant.png" alt="Re-Enter Values" class="calcButton" value="Re-Enter Values" />