www/includes/global.inc.php

Mon, 04 Feb 2019 15:21:49 +0100

author
Michiel Broek <mbroek@mbse.eu>
date
Mon, 04 Feb 2019 15:21:49 +0100
changeset 240
a85c1d4c4d12
parent 231
9881453a49b3
child 289
4082c41f45e9
permissions
-rw-r--r--

Depending on the product stage, more or less fields are saved in the database. Added begin of auto stage increase. Added missing inventory columns in the fermentables grid. New product wizzard now works with the indexed values. Product print works with indexed values and prepared for different print modules depending on the product stage.

<?php
/*****************************************************************************
 * 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
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * 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';

require_once($_SERVER['DOCUMENT_ROOT'].'/config.php');
require_once($_SERVER['DOCUMENT_ROOT'].'/version.php');

if (isset($_GET['record']))
	$my_record = $_GET['record'];
else
	$my_record = -1;
if (isset($_GET['uuid']))
	$my_uuid = $_GET['uuid'];
else
	$my_uuid = '';
if (isset($_GET['return']))
	$my_return = $_GET['return'];
else
	$my_return = '';
if (isset($_GET['code']))
	$my_code = $_GET['code'];
else
	$my_code = '';
if (isset($_GET['name']))
	$my_name = $_GET['name'];
else
	$my_name = '';

$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_uuid;
	global $my_return;
	global $my_name;
	global $my_code;
	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>
 <head>
  <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" />
  <script>
	var theme = "<?php echo $my_style; ?>";
	var my_record = "<?php echo $my_record; ?>";
	var my_return = "<?php echo $my_return; ?>";
	var my_name= "<?php echo $my_name; ?>";
	var my_code= "<?php echo $my_code; ?>";
        var my_uuid= "<?php echo $my_uuid; ?>";
	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>
  <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/jqxswitchbutton.js"></script>
  <script src="jqwidgets/jqxradiobutton.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/jqxchart.core.js"></script>
  <script src="jqwidgets/jqxchart.rangeselector.js"></script>
  <script src="jqwidgets/jqxdraw.js"></script>
  <script src="jqwidgets/jqxprogressbar.js"></script>
  <script src="jqwidgets/globalization/globalize.js"></script>
  <script src="js/global.js"></script>
<?php
if (strlen($loadjs))
    echo  '  <script src="js/'.$loadjs.'.js"></script>'.PHP_EOL;
?>
 </head>

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

   <!-- Menu -->
   <div id="jqxMenu">
    <ul>
     <li><a href="index.php">Home</a></li>
     <li>Monitoren
      <ul>
       <li>Systemen
	<ul>
<?php
$connect = mysqli_connect(DBASE_HOST,DBASE_USER,DBASE_PASS,DBASE_NAME);
$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;
}
mysqli_free_result($result);
?>
	</ul>
       </li>
       <li>Klimaatkasten
	<ul>
<?php
$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;
}
mysqli_free_result($result);
?>
        </ul>
       </li>
      </ul>
     </li>
     <li>Productie
      <ul>
       <li><a href="prod_inprod.php">In bewerking</a></li>
       <li><a href="prod_new.php?return=index.php">Start nieuw</a></li>
       <li>Archief
	<ul>
         <li>Op naam</li>
         <li>Op code</li>
         <li>Op datum</li>
        </ul>
       </li>
       <li>Import
        <ul>
	 <li>Brouw log</li>
	 <li>Etiket</li>
        </ul>
       </li>
       <li>Kalender</li>
      </ul>
     </li>
     <li>Recepten
      <ul>
       <li><a href="rec_main.php">Recepten</a></li>
       <li>Import</li>
      </ul>
     </li>
     <li>Inventaris
      <ul>
       <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>
      </ul>
     </li>
     <li>Instellingen
      <ul>
       <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_fermentation.php">Vergisting profielen</a></li>
       <li><a href="profile_setup.php">Instellingen</a></li>
      </ul>
     </li>
     <li>Over
      <ul>
       <li><a href="gen_about.php">Informatie</a></li>
      </ul>
     </li>
    </ul>
   </div> <!-- End menu -->

<?php
}


function confirm_delete() {
?>
   <div id="eventWindow">
    <div>
     Bevestig verwijderen
    </div>
    <div>
     <div>
      Klik "OK" om dit record definitief te verwijderen.<br>
      Druk "Cancel" om te sluiten zonder dit record te verwijderen.
     </div>
     <div>
      <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" />
      </div>
     </div>
    </div>
   </div>

<?php
}


function page_footer() {
?>
  </div> <!-- jqxWidget -->
 </body>
</html>
<?php
}
?>

mercurial