# HG changeset patch # User Michiel Broek # Date 1534428073 -7200 # Node ID 395833e20f88ca881594f241fa45240ad3d1b725 # Parent bb97e0de63cfb78a0230825b3c226f9b640b5abf Better error messages in syslog diff -r bb97e0de63cf -r 395833e20f88 README.design --- a/README.design Mon Aug 13 23:01:25 2018 +0200 +++ b/README.design Thu Aug 16 16:01:13 2018 +0200 @@ -27,6 +27,21 @@ Web interface bouwen met jqwidgets, breeze en knockout. +Database inventaris: + +inventory_equipments +inventory_fermentables Ok. +inventory_hops +inventory_mash_profiles +inventory_mash_steps +inventory_miscs +inventory_styles +inventory_suppliers Ok. +inventory_water_profiles +inventory_water_sources +inventory_yeasts + + Database: 1. Recepten opslaan in json formaat omdat dit flexibel is. diff -r bb97e0de63cf -r 395833e20f88 www/Makefile --- a/www/Makefile Mon Aug 13 23:01:25 2018 +0200 +++ b/www/Makefile Thu Aug 16 16:01:13 2018 +0200 @@ -3,9 +3,10 @@ include ../Makefile.global -SRC = monitor.php getfermenter.php getfermenters.php \ - getnode.php getnodes.php config.php.dist \ - inv_suppliers.php +SRC = getfermenter.php getfermenters.php \ + getnode.php getnodes.php config.php.dist index.php \ + inv_suppliers.php inv_fermentables.php inv_hops.php inv_yeasts.php \ + mon_brewer.php mon_fermenter.php mon_node.php SUB = version.php.in images/* css/* jqwidgets/* jqwidgets/styles/* \ jqwidgets/styles/images/* jqwidgets/globalization/* js/* \ includes/* diff -r bb97e0de63cf -r 395833e20f88 www/includes/db_inventory_fermentables.php --- a/www/includes/db_inventory_fermentables.php Mon Aug 13 23:01:25 2018 +0200 +++ b/www/includes/db_inventory_fermentables.php Thu Aug 16 16:01:13 2018 +0200 @@ -17,7 +17,7 @@ $sql = "INSERT INTO `inventory_fermentables` SET name='" . mysqli_real_escape_string($connect, $_GET['name']); $sql .= "', type='" . $_GET['type']; $sql .= "', yield='" . $_GET['yield']; - $sql .= "', color='" . ebc_to_srm($_GET['color']); + $sql .= "', color='" . $_GET['color']; ($_GET['add_after_boil'] == 'true') ? $sql .= "', add_after_boil='1" : $sql .= "', add_after_boil='0"; $sql .= "', origin='" . mysqli_real_escape_string($connect, $_GET['origin']); $sql .= "', supplier='" . mysqli_real_escape_string($connect, $_GET['supplier']); @@ -37,11 +37,14 @@ $sql .= "', cost='" . $_GET['cost']; $sql .= "', production_date='" . $_GET['production_date']; $sql .= "', tht_date='" . $_GET['tht_date']; - $sql .= "', supplier_rec='" . $_GET['supplier_rec']; + //$sql .= "', supplier_rec='" . $_GET['supplier_rec']; $sql .= "';"; - error_log("\"$sql\""); - $result = mysqli_query($connect, $sql) or die("SQL Error 1: " . mysqli_error($connect)); - error_log("result " . $result); + $result = mysqli_query($connect, $sql); + if (! $result) { + syslog(LOG_NOTICE, "db_inventory_fermentables: ".$sql." result: ".mysqli_error($connect)); + } else { + syslog(LOG_NOTICE, "db_inventory_fermentables: inserted ".$_GET['name']); + } echo $result; } else if (isset($_GET['update'])) { @@ -49,7 +52,7 @@ $sql = "UPDATE `inventory_fermentables` SET name='" . mysqli_real_escape_string($connect, $_GET['name']); $sql .= "', type='" . $_GET['type']; $sql .= "', yield='" . $_GET['yield']; - $sql .= "', color='" . ebc_to_srm($_GET['color']); + $sql .= "', color='" . $_GET['color']; ($_GET['add_after_boil'] == 'true') ? $sql .= "', add_after_boil='1" : $sql .= "', add_after_boil='0"; $sql .= "', origin='" . mysqli_real_escape_string($connect, $_GET['origin']); $sql .= "', supplier='" . mysqli_real_escape_string($connect, $_GET['supplier']); @@ -69,19 +72,25 @@ $sql .= "', cost='" . $_GET['cost']; $sql .= "', production_date='" . $_GET['production_date']; $sql .= "', tht_date='" . $_GET['tht_date']; - $sql .= "', supplier_rec='" . $_GET['supplier_rec']; + //$sql .= "', supplier_rec='" . $_GET['supplier_rec']; $sql .= "' WHERE record='" . $_GET['record'] . "';"; - error_log("\"$sql\""); - $result = mysqli_query($connect, $sql) or die("SQL Error 1: " . mysqli_error($connect)); - error_log("result " . $result); + $result = mysqli_query($connect, $sql); + if (! $result) { + syslog(LOG_NOTICE, "db_inventory_fermentables: ".$sql." result: ".mysqli_error($connect)); + } else { + syslog(LOG_NOTICE, "db_inventory_fermentables: updated record ".$_GET['record']); + } echo $result; } else if (isset($_GET['delete'])) { // DELETE COMMAND $sql = "DELETE FROM `inventory_fermentables` WHERE record='".$_GET['record']."';"; - error_log("\"$sql\""); - $result = mysqli_query($connect, $sql) or die("SQL Error 1: " . mysqli_error($connect)); - error_log("result " . $result); + $result = mysqli_query($connect, $sql); + if (! $result) { + syslog(LOG_NOTICE, "db_inventory_fermentables: ".$sql." result: ".mysqli_error($connect)); + } else { + syslog(LOG_NOTICE, "db_inventory_fermentables: deleted record ".$_GET['record']); + } echo $result; } else { diff -r bb97e0de63cf -r 395833e20f88 www/includes/db_inventory_hops.php --- a/www/includes/db_inventory_hops.php Mon Aug 13 23:01:25 2018 +0200 +++ b/www/includes/db_inventory_hops.php Thu Aug 16 16:01:13 2018 +0200 @@ -3,6 +3,8 @@ require($_SERVER['DOCUMENT_ROOT']."/config.php"); require($_SERVER['DOCUMENT_ROOT']."/version.php"); +syslog(LOG_NOTICE, "db_inventory_hops: script start"); + #Connect to the database $connect = mysqli_connect(DBASE_HOST, DBASE_USER, DBASE_PASS, DBASE_NAME); if (! $connect) { @@ -35,9 +37,12 @@ $sql .= "', supplier_rec='" . $_GET['supplier_rec']; $sql .= "', total_oil'" . $_GET['total_oil']; $sql .= "';"; - error_log("\"$sql\""); - $result = mysqli_query($connect, $sql) or die("SQL Error 1: " . mysqli_error($connect)); - error_log("result " . $result); + $result = mysqli_query($connect, $sql); + if (! $result) { + syslog(LOG_NOTICE, "db_inventory_hops: ".$sql." result: ".mysqli_error($connect)); + } else { + syslog(LOG_NOTICE, "db_inventory_hops: inserted ".$_GET['name']); + } echo $result; } else if (isset($_GET['update'])) { @@ -64,17 +69,23 @@ $sql .= "', supplier_rec='" . $_GET['supplier_rec']; $sql .= "', total_oil'" . $_GET['total_oil']; $sql .= "' WHERE record='" . $_GET['record'] . "';"; - error_log("\"$sql\""); - $result = mysqli_query($connect, $sql) or die("SQL Error 1: " . mysqli_error($connect)); - error_log("result " . $result); + $result = mysqli_query($connect, $sql); + if (! $result) { + syslog(LOG_NOTICE, "db_inventory_hops: ".$sql." result: ".mysqli_error($connect)); + } else { + syslog(LOG_NOTICE, "db_inventory_hops: updated record ".$_GET['record']); + } echo $result; } else if (isset($_GET['delete'])) { // DELETE COMMAND $sql = "DELETE FROM `inventory_hops` WHERE record='".$_GET['record']."';"; - error_log("\"$sql\""); - $result = mysqli_query($connect, $sql) or die("SQL Error 1: " . mysqli_error($connect)); - error_log("result " . $result); + $result = mysqli_query($connect, $sql); + if (! $result) { + syslog(LOG_NOTICE, "db_inventory_hops: ".$sql." result: ".mysqli_error($connect)); + } else { + syslog(LOG_NOTICE, "db_inventory_hops: deleted record ".$_GET['record']); + } echo $result; } else { diff -r bb97e0de63cf -r 395833e20f88 www/includes/db_inventory_suppliers.php --- a/www/includes/db_inventory_suppliers.php Mon Aug 13 23:01:25 2018 +0200 +++ b/www/includes/db_inventory_suppliers.php Thu Aug 16 16:01:13 2018 +0200 @@ -23,9 +23,12 @@ $sql .= "', phone='" . mysqli_real_escape_string($connect, $_GET['phone']); $sql .= "', notes='" . mysqli_real_escape_string($connect, $_GET['notes']); $sql .= "';"; - error_log("\"$sql\""); - $result = mysqli_query($connect, $sql) or die("SQL Error 1: " . mysqli_error($connect)); - error_log("result " . $result); + $result = mysqli_query($connect, $sql); + if (! $result) { + syslog(LOG_NOTICE, "db_inventory_suppliers: ".$sql." result: ".mysqli_error($connect)); + } else { + syslog(LOG_NOTICE, "db_inventory_suppliers: inserted ".$_GET['name']); + } echo $result; } else if (isset($_GET['update'])) { @@ -40,18 +43,24 @@ $sql .= "', phone='" . mysqli_real_escape_string($connect, $_GET['phone']); $sql .= "', notes='" . mysqli_real_escape_string($connect, $_GET['notes']); $sql .= "' WHERE record='" . $_GET['record'] . "';"; - error_log("\"$sql\""); - $result = mysqli_query($connect, $sql) or die("SQL Error 1: " . mysqli_error($connect)); - error_log("result " . $result); + $result = mysqli_query($connect, $sql); + if (! $result) { + syslog(LOG_NOTICE, "db_inventory_suppliers: ".$sql." result: ".mysqli_error($connect)); + } else { + syslog(LOG_NOTICE, "db_inventory_suppliers: updated record ".$_GET['record']); + } echo $result; } else if (isset($_GET['delete'])) { // DELETE COMMAND // FIXME: need to check if the record is in use $sql = "DELETE FROM `inventory_suppliers` WHERE record='".$_GET['record']."';"; - error_log("\"$sql\""); - $result = mysqli_query($connect, $sql) or die("SQL Error 1: " . mysqli_error($connect)); - error_log("result " . $result); + $result = mysqli_query($connect, $sql); + if (! $result) { + syslog(LOG_NOTICE, "db_inventory_suppliers: ".$sql." result: ".mysqli_error($connect)); + } else { + syslog(LOG_NOTICE, "db_inventory_suppliers: deleted record ".$_GET['record']); + } echo $result; } else { diff -r bb97e0de63cf -r 395833e20f88 www/includes/db_inventory_yeasts.php --- a/www/includes/db_inventory_yeasts.php Mon Aug 13 23:01:25 2018 +0200 +++ b/www/includes/db_inventory_yeasts.php Thu Aug 16 16:01:13 2018 +0200 @@ -34,9 +34,12 @@ $sql .= "', production_date='" . $_GET['production_date']; $sql .= "', tht_date='" . $_GET['tht_date']; $sql .= "';"; - error_log("\"$sql\""); - $result = mysqli_query($connect, $sql) or die("SQL Error 1: " . mysqli_error($connect)); - error_log("result " . $result); + $result = mysqli_query($connect, $sql); + if (! $result) { + syslog(LOG_NOTICE, "db_inventory_yeasts: ".$sql." result: ".mysqli_error($connect)); + } else { + syslog(LOG_NOTICE, "db_inventory_yeasts: inserted ".$_GET['name']); + } echo $result; } else if (isset($_GET['update'])) { @@ -62,17 +65,23 @@ $sql .= "', production_date='" . $_GET['production_date']; $sql .= "', tht_date='" . $_GET['tht_date']; $sql .= "' WHERE record='" . $_GET['record'] . "';"; - error_log("\"$sql\""); - $result = mysqli_query($connect, $sql) or die("SQL Error 1: " . mysqli_error($connect)); - error_log("result " . $result); + $result = mysqli_query($connect, $sql); + if (! $result) { + syslog(LOG_NOTICE, "db_inventory_yeasts: ".$sql." result: ".mysqli_error($connect)); + } else { + syslog(LOG_NOTICE, "db_inventory_yeasts: updated record ".$_GET['record']); + } echo $result; } else if (isset($_GET['delete'])) { // DELETE COMMAND $sql = "DELETE FROM `inventory_yeasts` WHERE record='".$_GET['record']."';"; - error_log("\"$sql\""); - $result = mysqli_query($connect, $sql) or die("SQL Error 1: " . mysqli_error($connect)); - error_log("result " . $result); + $result = mysqli_query($connect, $sql); + if (! $result) { + syslog(LOG_NOTICE, "db_inventory_yeasts: ".$sql." result: ".mysqli_error($connect)); + } else { + syslog(LOG_NOTICE, "db_inventory_yeasts: deleted record ".$_GET['record']); + } echo $result; } else { diff -r bb97e0de63cf -r 395833e20f88 www/inv_fermentables.php --- a/www/inv_fermentables.php Mon Aug 13 23:01:25 2018 +0200 +++ b/www/inv_fermentables.php Thu Aug 16 16:01:13 2018 +0200 @@ -66,12 +66,12 @@ acid_to_ph_57:
graintype: - +
- + Opmerkingen: @@ -101,4 +101,4 @@ + diff -r bb97e0de63cf -r 395833e20f88 www/inv_hops.php --- a/www/inv_hops.php Mon Aug 13 23:01:25 2018 +0200 +++ b/www/inv_hops.php Thu Aug 16 16:01:13 2018 +0200 @@ -84,10 +84,7 @@ - - - - + diff -r bb97e0de63cf -r 395833e20f88 www/js/inv_fermentables.js --- a/www/js/inv_fermentables.js Mon Aug 13 23:01:25 2018 +0200 +++ b/www/js/inv_fermentables.js Thu Aug 16 16:01:13 2018 +0200 @@ -72,8 +72,7 @@ { name: 'inventory', type: 'float' }, { name: 'cost', type: 'float' }, { name: 'production_date', type: 'string' }, - { name: 'tht_date', type: 'string' }, - { name: 'supplier_rec', type: 'float' } + { name: 'tht_date', type: 'string' } ], id: 'record', url: url, @@ -127,15 +126,16 @@ } }; var srcType = [ "Grain", "Sugar", "Extract", "Dry Extract", "Adjunct" ]; + var srcGraintype = [ "Base", "Crystal", "Special", "Roast", "Kilned", "No malt" ]; // initialize the input fields. $("#name").jqxInput({ theme: theme, width: 250, height: 23 }); - $("#type").jqxDropDownList({ theme: theme, source: srcType, width: 90, height: 23, dropDownHeight: 130 }); + $("#type").jqxDropDownList({ theme: theme, source: srcType, width: 100, height: 23, dropDownHeight: 156 }); $("#yield").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 70, height: 23, min: 0, decimalDigits: 1, spinButtons: true }); $("#color").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 70, height: 23, min: 0, decimalDigits: 1, spinButtons: true }); $("#add_after_boil").jqxCheckBox({ theme: theme, width: 120, height: 23 }); $("#origin").jqxInput({ theme: theme, width: 250, height: 23 }); $("#supplier").jqxInput({ theme: theme, width: 250, height: 23 }); - $("#notes").jqxInput({ theme: theme, width: 640, height: 48 }); + $("#notes").jqxInput({ theme: theme, width: 640, height: 100 }); $("#coarse_fine_diff").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 70, height: 23, min: 0, decimalDigits: 1, spinButtons: true }); $("#moisture").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 70, height: 23, min: 0, decimalDigits: 1, spinButtons: true }); $("#diastatic_power").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 70, height: 23, min: 0, decimalDigits: 1, spinButtons: true }); @@ -146,16 +146,13 @@ $("#always_on_stock").jqxCheckBox({ theme: theme, width: 120, height: 23 }); $("#di_ph").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 70, height: 23, min: 0, decimalDigits: 1, spinButtons: true }); $("#acid_to_ph_57").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 70, height: 23, min: 0, decimalDigits: 1, spinButtons: true }); - - $("#graintype").jqxInput({ theme: theme, width: 250, height: 23 }); + $("#graintype").jqxDropDownList({ theme: theme, source: srcGraintype, width: 100, height: 23, dropDownHeight: 185 }); $("#inventory").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 70, height: 23, min: 0, decimalDigits: 1, spinButtons: true }); $("#production_date").jqxDateTimeInput({ theme: theme, width: 100, height: 23, formatString: 'yyyy-MM-dd' }); $("#cost").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 70, height: 23, min: 0, decimalDigits: 2, spinButtons: true }); $("#tht_date").jqxDateTimeInput({ theme: theme, width: 100, height: 23, formatString: 'yyyy-MM-dd' }); - $("#supplier_rec").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 70, height: 23, min: 0, decimalDigits: 1, spinButtons: true }); - // supplier_rec var dataAdapter = new $.jqx.dataAdapter(source); var editrow = -1; // initialize jqxGrid @@ -175,7 +172,7 @@ // add new row. addButton.click(function (event) { editrow = -1; - $("#popupWindow").jqxWindow({ position: { x: 230, y: 10 } }); + $("#popupWindow").jqxWindow({ position: { x: 230, y: 30 } }); $("#name").val(''); $("#type").val('Grain'); $("#origin").val(''); @@ -196,7 +193,6 @@ $("#cost").val(''); $("#production_date").val(''); $("#tht_date").val(''); - $("#supplier_rec").val(''); $("#popupWindow").jqxWindow('open'); }); }, @@ -205,6 +201,7 @@ columns: [ { text: 'Vergistbaar product', datafield: 'name', width: 250 }, { text: 'Soort', datafield: 'type', width: 90 }, + { text: 'Mout type', datafield: 'graintype', width: 90 }, { text: 'Herkomst', datafield: 'origin', width: 150 }, { text: 'Producent', datafield: 'supplier', width: 150 }, { text: 'Kleur', datafield: 'color', width: 70, cellsalign: 'right' }, @@ -216,7 +213,7 @@ }, buttonclick: function (row) { // open the popup window when the user clicks a button. editrow = row; - $("#popupWindow").jqxWindow({ position: { x: 230, y: 10 } }); + $("#popupWindow").jqxWindow({ position: { x: 230, y: 30 } }); // get the clicked row's data and initialize the input fields. var dataRecord = $("#jqxgrid").jqxGrid('getrowdata', editrow); $("#name").val(dataRecord.name); @@ -242,7 +239,6 @@ $("#cost").val(dataRecord.cost); $("#production_date").val(dataRecord.production_date); $("#tht_date").val(dataRecord.tht_date); - $("#supplier_rec").val(dataRecord.supplier_rec); // show the popup window. $("#popupWindow").jqxWindow('open'); } @@ -299,7 +295,6 @@ cost: parseFloat($("#cost").jqxNumberInput('decimal')), production_date: $("#production_date").val(), tht_date: $("#tht_date").val(), - supplier_rec: parseFloat($("#supplier_rec").jqxNumberInput('decimal')) }; $('#jqxgrid').jqxGrid('updaterow', rowID, row); $("#popupWindow").jqxWindow('hide'); @@ -330,7 +325,6 @@ cost: parseFloat($("#cost").jqxNumberInput('decimal')), production_date: $("#production_date").val(), tht_date: $("#tht_date").val(), - supplier_rec: parseFloat($("#supplier_rec").jqxNumberInput('decimal')) }; $('#jqxgrid').jqxGrid('addrow', null, newrow); $("#popupWindow").jqxWindow('hide'); diff -r bb97e0de63cf -r 395833e20f88 www/js/inv_hops.js --- a/www/js/inv_hops.js Mon Aug 13 23:01:25 2018 +0200 +++ b/www/js/inv_hops.js Thu Aug 16 16:01:13 2018 +0200 @@ -157,7 +157,6 @@ height: 630, source: dataAdapter, theme: theme, - //altrows: true, showstatusbar: true, localization: getLocalization(), renderstatusbar: function (statusbar) { @@ -178,7 +177,7 @@ $("#cohumulone").val(''); $("#myrcene").val(''); $("#hsi").val(''); - $("#useat").val('Boil'); + //$("#useat").val('Boil'); $("#type").val('Bittering'); $("#form").val('Pellet'); $("#notes").val(''); @@ -189,7 +188,7 @@ $("#cost").val(''); $("#production_date").val(''); $("#tht_date").val(''); - $("#supplier_rec").val(''); + //$("#supplier_rec").val(''); $("#total_oil").val(''); $("#popupWindow").jqxWindow('open'); }); @@ -224,7 +223,7 @@ $("#cohumulone").val(dataRecord.cohumulone); $("#myrcene").val(dataRecord.myrcene); $("#hsi").val(dataRecord.hsi); - $("#useat").val(dataRecord.useat); + //$("#useat").val(dataRecord.useat); $("#type").val(dataRecord.type); $("#form").val(dataRecord.form); $("#notes").val(dataRecord.notes); @@ -235,7 +234,7 @@ $("#cost").val(dataRecord.cost); $("#production_date").val(dataRecord.production_date); $("#tht_date").val(dataRecord.tht_date); - $("#supplier_rec").val(dataRecord.supplier_rec); + //$("#supplier_rec").val(dataRecord.supplier_rec); $("#total_oil").val(dataRecord.total_oil); // show the popup window. $("#popupWindow").jqxWindow('open'); @@ -278,7 +277,7 @@ cohumulone: parseFloat($("#cohumulone").jqxNumberInput('decimal')), myrcene: parseFloat($("#myrcene").jqxNumberInput('decimal')), hsi: parseFloat($("#hsi").jqxNumberInput('decimal')), - useat: $("#useat").val(), + //useat: $("#useat").val(), type: $("#type").val(), form: $("#form").val(), notes: $("#notes").val(), @@ -289,7 +288,7 @@ cost: parseFloat($("#cost").jqxNumberInput('decimal')), production_date: $("#production_date").val(), tht_date: $("#tht_date").val(), - supplier_rec: parseFloat($("#supplier_rec").jqxNumberInput('decimal')), + //supplier_rec: parseFloat($("#supplier_rec").jqxNumberInput('decimal')), total_oil: parseFloat($("#total_oil").jqxNumberInput('decimal')) }; $('#jqxgrid').jqxGrid('updaterow', rowID, row); @@ -306,7 +305,7 @@ cohumulone: parseFloat($("#cohumulone").jqxNumberInput('decimal')), myrcene: parseFloat($("#myrcene").jqxNumberInput('decimal')), hsi: parseFloat($("#hsi").jqxNumberInput('decimal')), - useat: $("#useat").val(), + //useat: $("#useat").val(), type: $("#type").val(), form: $("#form").val(), notes: $("#notes").val(), @@ -317,7 +316,7 @@ cost: parseFloat($("#cost").jqxNumberInput('decimal')), production_date: $("#production_date").val(), tht_date: $("#tht_date").val(), - supplier_rec: parseFloat($("#supplier_rec").jqxNumberInput('decimal')), + //supplier_rec: parseFloat($("#supplier_rec").jqxNumberInput('decimal')), total_oil: parseFloat($("#total_oil").jqxNumberInput('decimal')) }; $('#jqxgrid').jqxGrid('addrow', null, newrow);