Sat, 08 Dec 2018 15:01:23 +0100

Michiel Broek <mbroek@mbse.eu>
Sat, 08 Dec 2018 15:01:23 +0100
changeset 129
parent 114
child 139

Added a loader during recipe load. Recalculate percentages if a fermentable row is deleted. Don't edit amounts if using weight percentages. Update grid percentages if a fermentable amount is changed. Recalculate IBU's after changes with fermentables.

 * Copyright (C) 2014-2018
 * Michiel Broek <mbroek at mbse dot eu>
 * This file is part of Brewery Management System
 * This is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the
 * Free Software Foundation; either version 2, or (at your option) any
 * later version.
 * BrewCloud is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * General Public License for more details.
 * You should have received a copy of the GNU General Public License
 * along with ThermFerm; see the file COPYING.  If not, write to the Free
 * Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.

 * Look for the style names in the jqwidgets/styles directory.
//$my_style = 'ui-darkness';
$my_style = 'ui-mbse';


if (isset($_GET['record']))
	$my_record = $_GET['record'];
	$my_record = -1;
if (isset($_GET['return']))
	$my_return = $_GET['return'];
	$my_return = '';

$escapers = array("\\", "/", "\"", "\n", "\r", "\t", "\x08", "\x0c");
$replacements = array("\\\\", "\\/", "\\\"", "\\n", "\\r", "\\t", "\\f", "\\b");

/* Load setup record */
#Connect to the database
$connect = mysqli_connect(DBASE_HOST, DBASE_USER, DBASE_PASS, DBASE_NAME);
if (! $connect) {
        die('Connect Error (' . mysqli_connect_errno() . ') ' . mysqli_connect_error());
mysqli_set_charset($connect, "utf8" );
$my_default_water = $my_brewery_name = $my_ibu_method = $my_color_method = '';
$my_factor_mashhop = $my_factor_fwh = $my_factor_pellet = $my_factor_plug = 0;
$my_brix_correction = $my_grain_absorbtion = 1.0;

$result = mysqli_query($connect, "SELECT * FROM profile_setup WHERE record='1'") or die("SQL Error 1: " . mysqli_error($connect));
if ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) {
	/* search water name */
	$wresult = mysqli_query($connect, "SELECT name FROM inventory_waters WHERE record='".$row['default_water']."';");
	if ($wrow = mysqli_fetch_array($wresult, MYSQLI_ASSOC))
		$my_default_water = str_replace($escapers, $replacements, $wrow['name']);
	$my_brewery_name = str_replace($escapers, $replacements, $row['brewery_name']);
	$my_factor_mashhop = floatval($row['factor_mashhop']);
	$my_factor_fwh= floatval($row['factor_fwh']);
	$my_factor_pellet= floatval($row['factor_pellet']);
	$my_factor_plug= floatval($row['factor_plug']);
	$my_ibu_method = str_replace($escapers, $replacements, $row['ibu_method']);
	$my_color_method = str_replace($escapers, $replacements, $row['color_method']);
	$my_brix_correction = floatval($row['brix_correction']);
	$my_grain_absorbtion = floatval($row['grain_absorbtion']);

function page_header($title, $loadjs) {
	global $my_style;
	global $my_version;
	global $my_record;
	global $my_return;
	global $my_brewery_name;
	global $my_factor_mashhop;
	global $my_factor_fwh;
	global $my_factor_pellet;
	global $my_factor_plug;
	global $my_ibu_method;
	global $my_color_method;
	global $my_brix_correction;
	global $my_grain_absorbtion;
	global $my_default_water;
<!DOCTYPE html>
<html lang=nl-NL>
  <meta http-equiv="content-type" content="text/html; charset=utf-8" />
  <title>BMS v<?php echo $my_version;?> - <?php echo $title;?></title>
  <link type="text/css" href="css/style.css" rel="stylesheet" media="all" />
  <link type="text/css" href="jqwidgets/styles/jqx.base.css" rel="stylesheet" />
  <link type="text/css" href="jqwidgets/styles/jqx.<?php echo $my_style; ?>.css" rel="stylesheet" />
  <meta name="viewport" content="width=device-width, initial-scale=1 maximum-scale=1 minimum-scale=1" />
	var theme = "<?php echo $my_style; ?>";
	var my_record = "<?php echo $my_record; ?>";
	var my_return = "<?php echo $my_return; ?>";
	var my_brewery_name = "<?php echo $my_brewery_name; ?>";
	var my_factor_mashhop = "<?php echo $my_factor_mashhop; ?>";
	var my_factor_fwh = "<?php echo $my_factor_fwh; ?>";
	var my_factor_pellet = "<?php echo $my_factor_pellet; ?>";
	var my_factor_plug = "<?php echo $my_factor_plug; ?>";
	var my_ibu_method = "<?php echo $my_ibu_method; ?>";
	var my_color_method = "<?php echo $my_color_method; ?>";
	var my_brix_correction = "<?php echo $my_brix_correction; ?>";
	var my_grain_absorbtion = "<?php echo $my_grain_absorbtion; ?>";
	var my_default_water = "<?php echo $my_default_water; ?>";
  <script src="js/jquery-1.11.1.min.js"></script>
  <script src="jqwidgets/jqxcore.js"></script>
  <script src="jqwidgets/jqxwindow.js"></script>
  <script src="jqwidgets/jqxmenu.js"></script>
  <script src="jqwidgets/jqxtabs.js"></script>
  <script src="jqwidgets/jqxdata.js"></script>
  <script src="jqwidgets/jqxdata.export.js"></script>
  <script src="jqwidgets/jqxloader.js"></script>
  <script src="jqwidgets/jqxbuttons.js"></script>
  <script src="jqwidgets/jqxscrollbar.js"></script>
  <script src="jqwidgets/jqxgrid.js"></script>
  <script src="jqwidgets/jqxgrid.grouping.js"></script>
  <script src="jqwidgets/jqxgrid.edit.js"></script>
  <script src="jqwidgets/jqxgrid.sort.js"></script>
  <script src="jqwidgets/jqxgrid.pager.js"></script>
  <script src="jqwidgets/jqxgrid.filter.js"></script>
  <script src="jqwidgets/jqxgrid.selection.js"></script>
  <script src="jqwidgets/jqxnumberinput.js"></script>
  <script src="jqwidgets/jqxlistbox.js"></script>
  <script src="jqwidgets/jqxdropdownlist.js"></script>
  <script src="jqwidgets/jqxdropdownbutton.js"></script>
  <script src="jqwidgets/jqxinput.js"></script>
  <script src="jqwidgets/jqxeditor.js"></script>
  <script src="jqwidgets/jqxtooltip.js"></script>
  <script src="jqwidgets/jqxcheckbox.js"></script>
  <script src="jqwidgets/jqxdatetimeinput.js"></script>
  <script src="jqwidgets/jqxcalendar.js"></script>
  <script src="jqwidgets/jqxgauge.js"></script>
  <script src="jqwidgets/jqxdraw.js"></script>
  <script src="jqwidgets/globalization/globalize.js"></script>
  <script src="js/global.js"></script>
if (strlen($loadjs))
    echo  '  <script src="js/'.$loadjs.'.js"></script>'.PHP_EOL;

 <body class="default">
  <div id="jqxWidget">
   <div id="jqxLoader">

   <!-- Menu -->
   <div id="jqxMenu">
     <li><a href="index.php">Home</a></li>
$result = mysqli_query($connect, "SELECT uuid,node,online,net_address FROM mon_nodes ORDER BY node");
while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) {
    echo '         <li><a href="mon_node.php?uuid='.$row['uuid'].'">'.$row['node'].'</a></li>'.PHP_EOL;
$result = mysqli_query($connect, "SELECT uuid,node,alias,online,mode FROM mon_fermenters ORDER BY node,alias");
while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) {
    echo '         <li><a href="mon_fermenter.php?uuid='.$row['uuid'].'">'.$row['node'].'/'.$row['alias'].'</a></li>'.PHP_EOL;
       <li><a href="prod_inprod.php">In bewerking</a></li>
       <li>Start nieuw</li>
         <li>Op naam</li>
         <li>Op code</li>
         <li>Op datum</li>
	 <li>Brouw log</li>
       <li><a href="rec_main.php">Recepten</a></li>
       <li><a href="inv_suppliers.php">Leveranciers</a></li>
       <li><a href="inv_fermentables.php">Vergistbare ingredienten</a></li>
       <li><a href="inv_hops.php">Hoppen</a></li>
       <li><a href="inv_yeasts.php">Gisten</a></li>
       <li><a href="inv_miscs.php">Overige ingredienten</a></li>
       <li><a href="inv_waters.php">Brouwwater</a></li>
       <li><a href="inv_equipments.php">Brouw apparatuur</a></li>
       <li><a href="inv_instock.php">Voorraad lijst</a></li>
       <li><a href="profile_water.php">Water profielen</a></li>
       <li><a href="profile_mash.php">Maisch schemas</a></li>
       <li><a href="profile_styles.php">Bierstijlen</a></li>
       <li><a href="profile_setup.php">Instellingen</a></li>
       <li><a href="gen_about.php">Informatie</a></li>
   </div> <!-- End menu -->


function confirm_delete() {
   <div id="eventWindow">
     Bevestig verwijderen
      Klik "OK" om dit record definitief te verwijderen.<br>
      Druk "Cancel" om te sluiten zonder dit record te verwijderen.
      <div style="float: right; margin-top: 15px; margin-bottom: 10px;">
       <input type="button" id="delOk" value="OK" style="margin-right: 15px" />
       <input type="button" id="delCancel" value="Cancel" style="margin-right: 65px" />


function page_footer() {
  </div> <!-- jqxWidget -->

/* ============== Translations ========================================== */

function added_type_names($added) {
	if ($added == "Mash")
		return 'Maischen';
	if ($added == "Boil")
		return 'Koken';
	if ($added == "Fermentation")
		return 'Vergisten';
	if ($added == "Lagering")
		return 'Nagisten';
	if ($added == "Bottle")
		return 'Bottelen';
	return $added;

function hop_useat_names($useat) {
	if (($useat == "Dry Hop") || ($useat == "Dry hop"))
		return "Koudhop";
	if ($useat == "Whirlpool")
		return "Whirlpool";
	if ($useat == "Mash")
		return "Maischen";
	if (($useat == "First Wort") || ($useat == "First wort"))
		return "First wort";
	if ($useat == "Aroma")
		return "Vlamuit";
	if ($useat == "Boil")
		return 'Koken';
	return $useat;

function hop_form_names($form) {
	if ($form == "Pellet")
		return 'Pellets';
	if ($form == "Plug")
		return 'Plugs';
	if ($form == "Leaf")
		return 'Bellen';
	return $form;

function yeast_use_names($use) {
	if ($use == "Primary")
		return 'Hoofdgist';
	if ($use == "Bottle")
		return 'Bottelgist';
	return $use;

function yeast_form_names($form) {

	if ($form == "Liquid")
		return 'Vloeibaar';
	if ($form == "Dry")
		return 'Droog';
	if ($form == "Slant")
		return 'Schuine buis';
	if ($form == "Culture")
		return 'Slurry';
	if ($form == "Frozen")
		return 'Ingevroren';
	if ($form == "Bottel")
		return 'Depot';
	return $form;

function misc_type_names($type) {
	if ($type == "Water agent")
		return 'Brouwzout';
	if ($type == "Fining")
		return 'Klaringsmiddel';
	if ($type == "Spice")
		return 'Specerij';
	if ($type == "Herb")
		return 'Kruid';
	if ($type == "Flavor")
		return 'Smaakstof';
	if ($type == "Yeast nutrient")
		return 'Gistvoeding';
	return $type;

function misc_use_names($name) {
	if ($name == "Starter")
		return 'Starter';
	if ($name == "Mash")
		return 'Maischen';
	if ($name == "Boil")
		return 'Koken';
	if ($name == "Primary")
		return 'Hoofdvergisting';
	if ($name == "Secondary")
		return 'Nagisten/lagering';
	if ($name == "Bottling")
		return 'Bottelen';
	return $name;