Wed, 16 Oct 2019 21:05:03 +0200
Added dutch array strings to a global php script. Changed fermentables, hops, yeast and misc inventory scripts to use these strings between the database scripts and javascript scripts. This makes filtering on types strings useable. Added these changes to the product/recipe forum and print exports too.
<?php require_once($_SERVER['DOCUMENT_ROOT'].'/includes/global.inc.php'); require_once($_SERVER['DOCUMENT_ROOT'].'/includes/formulas.php'); require_once($_SERVER['DOCUMENT_ROOT'].'/includes/constants.php'); $link = mysqli_connect(DBASE_HOST,DBASE_USER,DBASE_PASS,DBASE_NAME); if (! $link) { die('Connect Error (' . mysqli_connect_errno() . ') ' . mysqli_connect_error()); } if (! mysqli_set_charset($link, "utf8" )) { echo "error"; return 1; } setlocale ( LC_ALL, 'nl_NL.UTF-8'); $record = $_GET["record"]; $result = mysqli_query($link, "SELECT * FROM recipes WHERE record='".$record."'"); $row = mysqli_fetch_array($result); $preboil_sg = 0; date_default_timezone_set('Europe/Amsterdam'); $prdate = date(DATE_RFC2822); ?> <!DOCTYPE html> <html lang=nl-NL> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title>BMS v<?php echo $my_version;?> - Export recipe</title> <meta name="viewport" content="width=device-width, initial-scale=1 maximum-scale=1 minimum-scale=1" /> </head> <body> <pre> <?php function itemline($item, $content) { echo $item . " "; for ($i = strlen($item); $i < 40; $i++) echo "."; echo ": " . $content . PHP_EOL; } function formatstr($strin, $len) { $strout = null; $cnt = 0; for ($i = 0; $i < strlen($strin); $i++) { $ord = ord($strin[$i]); if ($ord != 195) $cnt++; switch ($strin[$i]) { case '<': $strout .= '<'; break; case '>': $strout .= '>'; break; case '&': $strout .= '&'; break; case '"': $strout .= '"'; break; default: $strout .= $strin[$i]; } if ($cnt >= $len) break; } for ($i = $cnt; $i < $len; $i++) $strout .= " "; return $strout; } echo "BMS v" . $my_version . " - Datum export: " . $prdate . PHP_EOL; echo "----------------------------------------------------------" . PHP_EOL; itemline("Bier naam", $row['name']); itemline("Bier stijl", $row['st_name']); itemline("Recept type", $recipetype[$row['type']]); itemline("Batch grootte", $row['batch_size'].' liter'); itemline("Kooktijd", $row['boil_time'].' minuten'); itemline("Brouwzaal rendement", $row['efficiency'].' %'); itemline("Geschatte begin densiteit", sprintf("%.3f",$row['est_og']).' SG/ '.sprintf("%.1f", sg_to_plato($row['est_og'])).'°P'); itemline("Geschatte eind densiteit", sprintf("%.3f",$row['est_fg']).' SG/ '.sprintf("%.1f", sg_to_plato($row['est_fg'])).'°P'); itemline("Geschat alcohol", sprintf("%.1f",$row['est_abv']).'% vol'); itemline("Kleur (" . $colormethod[$row['color_method']] . ")", $row['est_color'] . ' EBC'); itemline("Bitterheid (" . $ibumethod[$row['ibu_method']] . ")", $row['est_ibu'] . ' IBU'); echo PHP_EOL . PHP_EOL; $sugarsm = 0; $grainabsorbtion = 0; $mashwater = 0; $arr = json_decode($row['json_fermentables'], true); echo "Mout, granen en suikers EBC Gewicht kg % Gebruik tijdens" . PHP_EOL; echo "---------------------------------------- --- ---------- ----- ----------------" . PHP_EOL; foreach($arr as $item) { $name = formatstr($item['f_name'] . " (" . $item['f_supplier'] . ")", 40); $amount = floatval($item['f_amount']); $d = $amount * (floatval($item['f_yield']) / 100) * (1 - floatval($item['f_moisture']) / 100); if ($item['f_added'] == 0) { $d = floatval($row['efficiency']) / 100 * $d; $sugarsm += $d; $grainabsorbtion += $item['f_amount']; } echo sprintf("%s %3.0f %10.3f %5.1f ", $name, floatval($item['f_color']), $amount, floatval($item['f_percentage'])); echo $added[$item['f_added']] . PHP_EOL; } $preboil_sg = estimate_sg($sugarsm, floatval($row['boil_size'])); echo PHP_EOL . PHP_EOL; echo "Hop Vorm α % IBU Gram Toevoegen moment" . PHP_EOL; echo "---------------------------------------- -------- ----- ----- ------ --------------------" . PHP_EOL; $arr = json_decode($row['json_hops'], true); foreach($arr as $item) { $name = formatstr($item['h_name'] . " (" . $item['h_origin'] . ")", 40); $amount = floatval($item['h_amount']) * 1000; $time = floatval($item['h_time']); $alpha = floatval($item['h_alpha']); $ibu = calc_IBU($item['h_useat'], $item['h_form'], $preboil_sg, floatval($row['batch_size']), $amount, $time, $alpha, $row['ibu_method']); $moment = $hopuse[$item['h_useat']]; if (($item['h_useat'] == 2) || ($item['h_useat'] == 4)) { // Boil or Whirlpool $moment = $hopuse[$item['h_useat']].' '.$time." minuten"; } else if ($item['h_useat'] == 5) { // Dryhop $moment = $hopuse[$item['h_useat']].' '.sprintf("%.0f", $time / 1440).' dagen'; } echo sprintf("%s %-8s %5.1f %5.1f %6.1f %-20s", $name, $hopform[$item['h_form']], $alpha, $ibu, $amount, $moment); echo PHP_EOL; } echo PHP_EOL . PHP_EOL; echo "Specerij, kruid, brouwzout etc Type grondstof Gebruik tijdens Hoeveel" . PHP_EOL; echo "------------------------------ --------------- -------------------- -----------" . PHP_EOL; $arr = json_decode($row['json_miscs'], true); foreach($arr as $item) { $amount = floatval($item['m_amount']) * 1000; $aiw = $item['m_amount_is_weight']; $use_use = $item['m_use_use']; $time = floatval($item['m_time']); if ($use_use == 2) // Boil $gebruik = sprintf("%s %d min",$miscuse[$use_use],$time); else $gebruik = $miscuse[$use_use]; $hoeveel = sprintf("%.2f %s",$amount,$aiw ? "gr":"ml"); echo sprintf("%s %-15s %-20s %11s", formatstr($item['m_name'], 30), $misctype[$item['m_type']], $gebruik, $hoeveel) . PHP_EOL; } echo PHP_EOL . PHP_EOL; echo "Gistlab en code Omschrijving Gebruik Vorm Hoeveel" . PHP_EOL; echo "-------------------- ------------------------------ ------------ ------------ ----------" . PHP_EOL; $arr = json_decode($row['json_yeasts'], true); foreach($arr as $item) { $name = formatstr($item['y_name'], 30); $product = formatstr($item['y_laboratory']." ".$item['y_product_id'], 20); if ($item['y_form'] == 0) // Liquid $amount = sprintf("%.0f",floatval($item['y_amount']))." pak"; else if ($item['y_form'] == 1) // Dry $amount = sprintf("%.1f",floatval($item['y_amount'])*1000)." gr"; else $amount = sprintf("%.0f",floatval($item['y_amount'])*1000)." ml"; echo sprintf("%s %s %-12s %-12s %10s", $product, $name, $yeastuse[$item['y_use']], $yeastform[$item['y_form']], $amount) . PHP_EOL; } if ($row['starter_enable'] && $row['prop1_volume']) { $sv = 0; for ($i = 1; $i < 5; $i++) { $pv = "prop".$i."_volume"; if (floatval($row[$pv]) && (floatval($row[$pv]) > $sv)) { $sv = floatval($row[$pv]); } } echo PHP_EOL . "Maak een giststarter van " . sprintf("%.1f", $sv) . " liter." . PHP_EOL; } echo PHP_EOL . PHP_EOL; if ($row['w1_name']) $mashwater += floatval($row['w1_amount']); if ($row['w2_name']) $mashwater += floatval($row['w2_amount']); echo "Maisch stap stap type stap temp rusten opwarmen" . PHP_EOL; echo "-------------------- ---------------------- --------- --------- ---------" . PHP_EOL; $arr = json_decode($row['json_mashs'], true); foreach($arr as $item) { if ($item['step_type'] == 1) { $stype = formatstr($mashtype[$item['step_type']], 22); } else { $stype = formatstr($mashtype[$item['step_type']].' '.sprintf("%.1f", $item['step_infuse_amount']).' liter', 22); } echo sprintf("%s %s %s %s %s", formatstr($item['step_name'], 20), $stype, sprintf("%6.1f °C", $item['step_temp']), sprintf("%4.0f min.", $item['step_time']), sprintf("%4.0f min.", $item['ramp_time'])) . PHP_EOL; } echo PHP_EOL; if ($row['w1_name'] && $row['w2_name']) { itemline("Maischwater 1", sprintf("%.1f",floatval($row['w1_amount'])).' liter water '.$row['w1_name']); itemline("Maischwater 2", sprintf("%.1f",floatval($row['w2_amount'])).' liter water '.$row['w2_name']); } else { itemline("Maischwater", sprintf("%.1f",floatval($row['w1_amount'])).' liter water '.$row['w1_name']); } itemline("Maischwater aanzuren tot pH", $row['mash_ph'].' pH'); $spoelw = ($row['boil_size'] - $mashwater + $grainabsorbtion + $row['eq_lauter_deadspace']) * 1.03; // A small heat correction itemline("Spoelwater geschat", sprintf("%.1f", $spoelw)." liter"); itemline("Spoelwater temperatuur", $row['sparge_temp'].' °C'); itemline("Spoelwater aanzuren tot pH", sprintf("%.1f",$row['sparge_ph']).' pH'); echo PHP_EOL . PHP_EOL; ?> </pre> </body> </html>