# HG changeset patch # User Michiel Broek # Date 1542466693 -3600 # Node ID f433193f7bb64912a2af7fb0f03c557e0f66a0b7 # Parent 92d6bc8a4cdd73217525f4ed9a4a5302979932e2 Removed default water setting from the inventory_waters table. Added global setup record with default settings and the default water selection. Added a setup screen. diff -r 92d6bc8a4cdd -r f433193f7bb6 www/getwatersources.php --- a/www/getwatersources.php Fri Nov 16 16:20:17 2018 +0100 +++ b/www/getwatersources.php Sat Nov 17 15:58:13 2018 +0100 @@ -20,7 +20,6 @@ 'magnesium' => $row['magnesium'], 'ph' => $row['ph'], 'total_alkalinity' => $row['total_alkalinity'], - 'default_water' => $row['default_water'], 'cost' => $row['cost'] ); } diff -r 92d6bc8a4cdd -r f433193f7bb6 www/import/from_brouwhulp.php --- a/www/import/from_brouwhulp.php Fri Nov 16 16:20:17 2018 +0100 +++ b/www/import/from_brouwhulp.php Sat Nov 17 15:58:13 2018 +0100 @@ -212,7 +212,6 @@ ($water->NAME == "Spa Reine") || ($water->NAME == "Velsen") || ($water->NAME == "Zutphen") || ($water->NAME == "Aurele Bronwater (Colruyt)")) { $sql = "INSERT INTO inventory_waters SET name='" . mysqli_real_escape_string($db, $water->NAME); - ($water->DEFAULT_WATER == 'TRUE') ? $sql .= "', default_water='1" : $sql .= "', default_water='0"; } else { $sql = "INSERT INTO profile_water SET name='" . mysqli_real_escape_string($db, $water->NAME); } @@ -801,7 +800,6 @@ $waters .= ',"w_cost":' . floatval($water->COST); else $waters .= ',"w_cost":0.00'; - ($water->DEFAULT_WATER== "TRUE") ? $waters .= ',"w_default_water":true' : $waters.= ',"w_default_water":false'; $waters .= "}"; } diff -r 92d6bc8a4cdd -r f433193f7bb6 www/includes/db_inventory_water.php --- a/www/includes/db_inventory_water.php Fri Nov 16 16:20:17 2018 +0100 +++ b/www/includes/db_inventory_water.php Sat Nov 17 15:58:13 2018 +0100 @@ -10,19 +10,6 @@ } mysqli_set_charset($connect, "utf8" ); -/* - * If a new default will be set, clear the old default. - */ -function clear_default() { - global $connect; - - $usql = "UPDATE inventory_waters SET default_water='0' WHERE (default_water = '1');"; - $result = mysqli_query($connect, $usql); - if (! $result) { - syslog(LOG_NOTICE, "db_inventory_waters: " . $usql . " result: ".mysqli_error($connect)); - } -} - // get data and store in a json array $query = "SELECT * FROM inventory_waters ORDER BY name"; @@ -39,12 +26,6 @@ $sql .= "', ph='" . $_GET['ph']; $sql .= "', notes='" . mysqli_real_escape_string($connect, $_GET['notes']); $sql .= "', total_alkalinity='" . $_GET['total_alkalinity']; - if ($_GET['default_water'] == 'true') { - clear_default(); - $sql .= "', default_water='1"; - } else { - $sql .= "', default_water='0"; - } $sql .= "', inventory='" . $_GET['inventory']; $sql .= "', cost='" . $_GET['cost']; $sql .= "';"; @@ -69,12 +50,6 @@ $sql .= "', ph='" . $_GET['ph']; $sql .= "', notes='" . mysqli_real_escape_string($connect, $_GET['notes']); $sql .= "', total_alkalinity='" . $_GET['total_alkalinity']; - if ($_GET['default_water'] == 'true') { - clear_default(); - $sql .= "', default_water='1"; - } else { - $sql .= "', default_water='0"; - } $sql .= "', inventory='" . $_GET['inventory']; $sql .= "', cost='" . $_GET['cost']; $sql .= "' WHERE record='" . $_GET['record'] . "';"; @@ -114,7 +89,6 @@ 'ph' => $row['ph'], 'notes' => $row['notes'], 'total_alkalinity' => $row['total_alkalinity'], - 'default_water' => $row['default_water'], 'inventory' => $row['inventory'], 'cost' => $row['cost'] ); diff -r 92d6bc8a4cdd -r f433193f7bb6 www/includes/db_setup.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/www/includes/db_setup.php Sat Nov 17 15:58:13 2018 +0100 @@ -0,0 +1,69 @@ + diff -r 92d6bc8a4cdd -r f433193f7bb6 www/includes/global.inc.php --- a/www/includes/global.inc.php Fri Nov 16 16:20:17 2018 +0100 +++ b/www/includes/global.inc.php Sat Nov 17 15:58:13 2018 +0100 @@ -149,11 +149,12 @@
  • Voorraad lijst
  • -
  • Profielen +
  • Instellingen
  • Over diff -r 92d6bc8a4cdd -r f433193f7bb6 www/inv_waters.php --- a/www/inv_waters.php Fri Nov 16 16:20:17 2018 +0100 +++ b/www/inv_waters.php Sat Nov 17 15:58:13 2018 +0100 @@ -48,9 +48,7 @@ Onbeperkt op voorraad: -
    - Standaard water: -
    +
    Voorraad: diff -r 92d6bc8a4cdd -r f433193f7bb6 www/js/inv_waters.js --- a/www/js/inv_waters.js Fri Nov 16 16:20:17 2018 +0100 +++ b/www/js/inv_waters.js Sat Nov 17 15:58:13 2018 +0100 @@ -56,7 +56,6 @@ $("#magnesium").jqxTooltip({ content: 'Magnesium (Mg).' }); $("#ph").jqxTooltip({ content: 'De zuurgraad (pH).' }); $("#total_alkalinity").jqxTooltip({ content: 'Totale alkaliniteit.' }); - $("#default_water").jqxTooltip({ content: 'Is dit het standaard water voor de meeste bieren.' }); $("#inventory").jqxTooltip({ content: 'Voorraad in liters.' }); $("#cost").jqxTooltip({ content: 'Kostprijs per liter. 5 cijfers achter de comma zodat het kraanwater er ook in kan.' }); // prepare the data @@ -76,7 +75,6 @@ { name: 'ph', type: 'float' }, { name: 'notes', type: 'string' }, { name: 'total_alkalinity', type: 'float' }, - { name: 'default_water', type: 'bool' }, { name: 'inventory', type: 'float' }, { name: 'cost', type: 'float' } ], @@ -144,7 +142,6 @@ $("#notes").jqxInput({ theme: theme, width: 640, height: 100 }); $("#total_alkalinity").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 70, height: 23, min: 0, decimalDigits: 1, spinButtons: true }); - $("#default_water").jqxCheckBox({ theme: theme, width: 120, height: 23 }); $("#inventory").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 70, height: 23, min: 0, decimalDigits: 1, spinButtons: true }); $("#cost").jqxNumberInput({inputMode: 'simple', spinMode: 'simple', theme: theme, width: 110, height: 23, min: 0, decimalDigits: 5, spinButtons: true }); var dataAdapter = new $.jqx.dataAdapter(source); @@ -178,7 +175,6 @@ $("#ph").val(''); $("#notes").val(''); $("#total_alkalinity").val(''); - $("#default_water").val(''); $("#inventory").val(''); $("#cost").val(''); $("#popupWindow").jqxWindow('open'); @@ -189,7 +185,6 @@ columns: [ { text: 'Water leverancier', datafield: 'name', width: 225 }, { text: 'Opmerkingen', datafield: 'notes' }, - { text: 'Standaard', datafield: 'default_water', columntype: 'checkbox', width: 80 }, { text: 'Onbeperkt', datafield: 'unlimited_stock', columntype: 'checkbox', width: 80 }, { text: 'Liters', datafield: 'inventory', width: 70, align: 'right', cellsalign: 'right', cellsformat: 'f1' }, { text: 'Wijzig', datafield: 'Edit', width: 120, align: 'center', columntype: 'button', cellsrenderer: function () { @@ -211,7 +206,6 @@ $("#ph").val(dataRecord.ph); $("#notes").val(dataRecord.notes); $("#total_alkalinity").val(dataRecord.total_alkalinity); - $("#default_water").val(dataRecord.default_water); $("#inventory").val(dataRecord.inventory); $("#cost").val(dataRecord.cost); // show the popup window. @@ -258,7 +252,6 @@ ph: parseFloat($("#ph").jqxNumberInput('decimal')), notes: $("#notes").val(), total_alkalinity: parseFloat($("#total_alkalinity").jqxNumberInput('decimal')), - default_water: $("#default_water").val(), inventory: parseFloat($("#inventory").jqxNumberInput('decimal')), cost: parseFloat($("#cost").jqxNumberInput('decimal')) }; @@ -279,7 +272,6 @@ ph: parseFloat($("#ph").jqxNumberInput('decimal')), notes: $("#notes").val(), total_alkalinity: parseFloat($("#total_alkalinity").jqxNumberInput('decimal')), - default_water: $("#default_water").val(), inventory: parseFloat($("#inventory").jqxNumberInput('decimal')), cost: parseFloat($("#cost").jqxNumberInput('decimal')) }; diff -r 92d6bc8a4cdd -r f433193f7bb6 www/js/profile_setup.js --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/www/js/profile_setup.js Sat Nov 17 15:58:13 2018 +0100 @@ -0,0 +1,147 @@ +/***************************************************************************** + * Copyright (C) 2018 + * + * Michiel Broek + * + * This file is part of BMS + * + * 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. + *****************************************************************************/ + + +$(document).ready(function () { + + var dataRecord = {}; + + // dropdownlist datasource from inventory_waters, must load sync + var waterUrl = "getwatersources.php"; + var waterInvSource = { + datatype: "json", + datafields: [ + { name: 'name', type: 'string' }, + ], + url: waterUrl, + async: false + }; + var waterlist = new $.jqx.dataAdapter(waterInvSource); + + var url = "includes/db_setup.php"; + + // Tooltips + $("#brewery_name").jqxTooltip({ content: 'De naam voor deze brouwerij.' }); + $("#factor_mashhop").jqxTooltip({ content: 'Het efficientie percentage voor hop tijdens de maisch.' }); + $("#factor_fwh").jqxTooltip({ content: 'Het efficientie percentage voor First Wort Hop.' }); + $("#factor_pellet").jqxTooltip({ content: 'Het efficientie percentage bij gebruik van hop pellets.' }); + $("#factor_plug").jqxTooltip({ content: 'Het efficientie percentage bij gebruik van hop plugs.' }); + $("#brix_correction").jqxTooltip({ content: 'Omzettingsfactor voor Plato naar Brix' }); + $("#grain_absorbtion").jqxTooltip({ content: 'Absorbtie van water door graan (L/Kg)' }); + + // Prepare the data + var source = { + datatype: "json", + cache: false, + datafields: [ + { name: 'brewery_name', type: 'string' }, + /* { name: 'brewery_logo', type: 'array' }, */ + { name: 'factor_mashhop', type: 'number' }, + { name: 'factor_fwh', type: 'number' }, + { name: 'factor_pellet', type: 'number' }, + { name: 'factor_plug', type: 'number' }, + { name: 'ibu_method', type: 'string' }, + { name: 'color_method', type: 'string' }, + { name: 'brix_correction', type: 'float' }, + { name: 'grain_absorbtion', type: 'float' }, + { name: 'default_water', type: 'string' } + ], + url: url + }; + + // Load data and select one record. + var dataAdapter = new $.jqx.dataAdapter(source, { + loadComplete: function () { + var records = dataAdapter.records; + dataRecord = records[0]; + $("#brewery_name").val(dataRecord.brewery_name); + $("#factor_mashhop").val(dataRecord.factor_mashhop); + $("#factor_fwh").val(dataRecord.factor_fwh); + $("#factor_pellet").val(dataRecord.factor_pellet); + $("#factor_plug").val(dataRecord.factor_plug); + $("#color_method").val(dataRecord.color_method); + $("#ibu_method").val(dataRecord.ibu_method); + $("#brix_correction").val(dataRecord.brix_correction); + $("#grain_absorbtion").val(dataRecord.grain_absorbtion); + $("#default_water").val(dataRecord.default_water); + }, + loadError: function (jqXHR, status, error) { + }, + }); + dataAdapter.dataBind(); + + // Editers + var srcColor = [ "Morey", "Mosher", "Daniels" ]; + var srcIBU = [ "Tinseth", "Rager", "Daniels" ]; // Only these are supported at this time. + $("#brewery_name").jqxInput({ theme: theme, width: 640, height: 23 }); + $("#factor_fwh").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: -50, max: 50, decimalDigits: 0, spinButtons: true, symbol: '%', symbolPosition: 'right' }); + $("#factor_mashhop").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: -50, max: 50, decimalDigits: 0, spinButtons: true, symbol: '%', symbolPosition: 'right' }); + $("#factor_pellet").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: -50, max: 50, decimalDigits: 0, spinButtons: true, symbol: '%', symbolPosition: 'right' }); + $("#factor_plug").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: -50, max: 50, decimalDigits: 0, spinButtons: true, symbol: '%', symbolPosition: 'right' }); + $("#brix_correction").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: 1.00, max: 1.08, decimalDigits: 2, spinButtons: true, spinButtonsStep: 0.01 }); + $("#grain_absorbtion").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: 1.00, max: 1.25, decimalDigits: 2, spinButtons: true, spinButtonsStep: 0.01 }); + $("#color_method").jqxDropDownList({ theme: theme, source: srcColor, width: 125, height: 23, dropDownHeight: 95 }); + $("#ibu_method").jqxDropDownList({ theme: theme, source: srcIBU, width: 125, height: 23, dropDownHeight: 95 }); + $('#default_water').jqxDropDownList({ + placeHolder: "Kies water:", + theme: theme, + source: waterlist, + valueMember: "name", + displayMember: "name", + width: 250, + height: 27, + dropDownHorizontalAlignment: 'right', + dropDownWidth: 300 + }); + $('#default_water').jqxDropDownList( 'selectItem', dataRecord.default_water ); + + $("#Save").jqxButton({ template: "success", width: '90px', theme: theme }); + $("#Save").click(function () { + var row = { + record: 1, + brewery_name: $("#brewery_name").val(), + factor_mashhop: $("#factor_mashhop").val(), + factor_fwh: $("#factor_fwh").val(), + factor_pellet: $("#factor_pellet").val(), + factor_plug: $("#factor_plug").val(), + color_method: $("#color_method").val(), + ibu_method: $("#ibu_method").val(), + brix_correction: parseFloat($("#brix_correction").jqxNumberInput('decimal')), + grain_absorbtion: parseFloat($("#grain_absorbtion").jqxNumberInput('decimal')), + default_water: $("#default_water").val() + }; + var data = "update=true&" + $.param(row); + $.ajax({ + dataType: 'json', + url: url, + cache: false, + data: data, + type: "POST", + success: function (data, status, xhr) { + // update command is executed. + //window.location.href = my_return; + }, + error: function(jqXHR, textStatus, errorThrown) { + } + }); + }); +}); diff -r 92d6bc8a4cdd -r f433193f7bb6 www/js/rec_edit.js --- a/www/js/rec_edit.js Fri Nov 16 16:20:17 2018 +0100 +++ b/www/js/rec_edit.js Sat Nov 17 15:58:13 2018 +0100 @@ -992,7 +992,6 @@ { name: 'w_ph', type: 'float' }, { name: 'w_total_alkalinity', type: 'float' }, { name: 'w_cost', type: 'float' }, - { name: 'w_default_water', type: 'bool' } ], addrow: function (rowid, rowdata, position, commit) { commit(true); @@ -1018,7 +1017,6 @@ { name: 'ph', type: 'float' }, { name: 'total_alkalinity', type: 'float' }, { name: 'cost', type: 'float' }, - { name: 'default_water', type: 'bool' } ], url: waterUrl, async: true @@ -1065,7 +1063,6 @@ row["w_magnesium"] = datarecord.magnesium; row["w_ph"] = datarecord.ph; row["w_total_alkalinity"] = datarecord.total_alkalinity; - row["w_default_water"] = datarecord.default_water; row["w_cost"] = datarecord.cost; var commit = $("#waterGrid").jqxGrid('addrow', null, row); } diff -r 92d6bc8a4cdd -r f433193f7bb6 www/profile_setup.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/www/profile_setup.php Sat Nov 17 15:58:13 2018 +0100 @@ -0,0 +1,54 @@ + + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Brouwerij naam:

    Brouw instellingen
    First Wort Hop factor:
    Maischhop factor:
    Kleur methode:
    Pellet factor:
    Plug factor:
    Bitterheid methode:
    Brix correctie factor:
    Graan absorbtie:
    Standaard water:
    +
    + +
    +
    +
    + +