# HG changeset patch # User Michiel Broek # Date 1548618024 -3600 # Node ID 318aab3714971771a118966de125d2ba2cd44d0d # Parent fda7286871f2d778bdc091cb00d93f6112c29d5f Profile style is using indexes. Profile styles and fermentation switched to POST. Standard edit screens. diff -r fda7286871f2 -r 318aab371497 README.design --- a/README.design Sun Jan 27 17:39:53 2019 +0100 +++ b/README.design Sun Jan 27 20:40:24 2019 +0100 @@ -40,9 +40,10 @@ inventory_suppliers Ok. Ok. Ok. Ok. Ok. Ok. inventory_water Ok. Ok. Ok. Ok. Ok. Ok. inventory_yeasts Ok. Ok. Ok. Ok. Ok. Ok. +profile_fermentation Ok. Ok. Ok. Ok. Ok. Ok. profile_mash Ok. Ok. Ok. Ok. Ok. Ok. -profile_profiles Ok. Ok. Ok. -profile_styles Ok. Ok. +profile_setup Ok. Ok. Ok. +profile_styles Ok. Ok. Ok. Ok. Ok. Ok. profile_water Ok. Ok. Ok. Ok. Ok. Ok. recipes products diff -r fda7286871f2 -r 318aab371497 www/import/from_brouwhulp.php --- a/www/import/from_brouwhulp.php Sun Jan 27 17:39:53 2019 +0100 +++ b/www/import/from_brouwhulp.php Sun Jan 27 20:40:24 2019 +0100 @@ -515,7 +515,22 @@ $sql .= "', style_letter='" . mysqli_real_escape_string($db, $style->STYLE_LETTER); if ($style->STYLE_GUIDE) $sql .= "', style_guide='" . mysqli_real_escape_string($db, $style->STYLE_GUIDE); - $sql .= "', type='" . $style->TYPE; + + if ($style->TYPE == 'Lager') + $sql .= "', type='0"; + else if ($style->TYPE == 'Ale') + $sql .= "', type='1"; + else if ($style->TYPE == 'Mead') + $sql .= "', type='2"; + else if ($style->TYPE == 'Wheat') + $sql .= "', type='3"; + else if ($style->TYPE == 'Mixed') + $sql .= "', type='4"; + else if ($style->TYPE == 'Cider') + $sql .= "', type='5"; + else + echo "Unknown TYPE " . $style->TYPE . PHP_EOL; + $sql .= "', og_min='" . floatval($style->OG_MIN); $sql .= "', og_max='" . floatval($style->OG_MAX); $sql .= "', fg_min='" . floatval($style->FG_MIN); @@ -631,8 +646,21 @@ $sql .= "', st_category='" . mysqli_real_escape_string($db, $recipe->STYLE->CATEGORY); if ($recipe->STYLE->CATEGORY_NUMBER) $sql .= "', st_category_number='" . floatval($recipe->STYLE->CATEGORY_NUMBER); - if ($recipe->STYLE->TYPE) - $sql .= "', st_type='" . mysqli_real_escape_string($db, $recipe->STYLE->TYPE); + if ($recipe->STYLE->TYPE == 'Lager') + $sql .= "', st_type='0"; + else if ($recipe->STYLE->TYPE == 'Ale') + $sql .= "', st_type='1"; + else if ($recipe->STYLE->TYPE == 'Mead') + $sql .= "', st_type='2"; + else if ($recipe->STYLE->TYPE == 'Wheat') + $sql .= "', st_type='3"; + else if ($recipe->STYLE->TYPE == 'Mixed') + $sql .= "', st_type='4"; + else if ($recipe->STYLE->TYPE == 'Cider') + $sql .= "', st_type='5"; + else + echo "Unknown TYPE " . $recipe->STYLE->TYPE . PHP_EOL; + if ($recipe->STYLE->OG_MIN) $sql .= "', st_og_min='" . floatval($recipe->STYLE->OG_MIN); if ($recipe->STYLE->OG_MAX) diff -r fda7286871f2 -r 318aab371497 www/includes/db_profile_fermentation.php --- a/www/includes/db_profile_fermentation.php Sun Jan 27 17:39:53 2019 +0100 +++ b/www/includes/db_profile_fermentation.php Sun Jan 27 20:40:24 2019 +0100 @@ -14,55 +14,61 @@ $replacements = array("\\\\", "\\/", "\\\"", "\\n", "\\r", "\\t", "\\f", "\\b"); $rescapers = array("'"); $rreplacements = array("\\'"); -$disallowed = array('visibleindex','uniqueid','boundindex','uid','undefined'); -if (isset($_GET['insert']) || isset($_GET['update'])) { - if (isset($_GET['insert'])) { +if (isset($_POST['insert']) || isset($_POST['update'])) { + if (isset($_POST['insert'])) { $sql = "INSERT INTO `profile_fermentation` SET "; } - if (isset($_GET['update'])) { + if (isset($_POST['update'])) { $sql = "UPDATE `profile_fermentation` SET "; } - if (isset($_GET['uuid']) && (strlen($_GET['uuid']) == 36)) { - $sql .= "uuid='" . $_GET['uuid']; + if (isset($_POST['uuid']) && (strlen($_POST['uuid']) == 36)) { + $sql .= "uuid='" . $_POST['uuid']; } else { $uuid = str_replace("\n", "", file_get_contents('/proc/sys/kernel/random/uuid')); $sql .= "uuid='" . $uuid; } - $sql .= "', name='" . mysqli_real_escape_string($connect, $_GET['name']); - $sql .= "', inittemp_lo='" . floatval($_GET['inittemp_lo']); - $sql .= "', inittemp_hi='" . floatval($_GET['inittemp_hi']); - ($_GET['fridgemode'] == 'true') ? $sql .= "', fridgemode='1" : $sql .= "', fridgemode='0"; - $array = $_GET['steps']; + $sql .= "', name='" . mysqli_real_escape_string($connect, $_POST['name']); + $sql .= "', inittemp_lo='" . floatval($_POST['inittemp_lo']); + $sql .= "', inittemp_hi='" . floatval($_POST['inittemp_hi']); + ($_POST['fridgemode'] == 'true') ? $sql .= "', fridgemode='1" : $sql .= "', fridgemode='0"; + $array = $_POST['steps']; // Don't believe given duration and number of steps, recalculate. $duration = 0; $totalsteps = 0; + $steps = '['; foreach($array as $key => $item) { + if ($totalsteps > 0) + $steps.= ','; $totalsteps++; $duration += $item['steptime'] + $item['resttime']; - foreach ($disallowed as $disallowed_key) { - unset($array[$key]["$disallowed_key"]); - } + $steps .= '{"name":"' . str_replace($rescapers,$rreplacements,$item['name']); + $steps .= '","steptime":' . $item['steptime']; + $steps .= ',"resttime":' . $item['resttime']; + $steps .= ',"target_lo":' . $item['target_lo']; + $steps .= ',"target_hi":' . $item['target_hi']; + $steps .= ',"fridgemode":' . $item['fridgemode'] . '}'; } + $steps .= ']'; $sql .= "', totalsteps='" . $totalsteps; $sql .= "', duration='" . $duration; -// syslog(LOG_NOTICE, "steps=: ". str_replace($rescapers,$rreplacements,json_encode($array))); + syslog(LOG_NOTICE, $steps); $sql .= "', steps='" . str_replace($rescapers,$rreplacements,json_encode($array)); - if (isset($_GET['insert'])) { + if (isset($_POST['insert'])) { $sql .= "';"; } - if (isset($_GET['update'])) { - $sql .= "' WHERE record='" . $_GET['record'] . "';"; + if (isset($_POST['update'])) { + $sql .= "' WHERE record='" . $_POST['record'] . "';"; } syslog(LOG_NOTICE, $sql); $result = mysqli_query($connect, $sql); if (! $result) { syslog(LOG_NOTICE, "db_profile_fermentation: ".$sql." result: ".mysqli_error($connect)); } else { - if (isset($_GET['update'])) { - syslog(LOG_NOTICE, "db_profile_fermentation: updated record ".$_GET['record']); + if (isset($_POST['update'])) { + syslog(LOG_NOTICE, "db_profile_fermentation: updated record ".$_POST['record']); } else { $lastid = mysqli_insert_id($connect); syslog(LOG_NOTICE, "db_profile_fermentation: inserted record ".$lastid); @@ -70,14 +76,14 @@ } echo $result; -} else if (isset($_GET['delete'])) { +} else if (isset($_POST['delete'])) { // DELETE COMMAND - $sql = "DELETE FROM `profile_fermentation` WHERE record='".$_GET['record']."';"; + $sql = "DELETE FROM `profile_fermentation` WHERE record='".$_POST['record']."';"; $result = mysqli_query($connect, $sql); if (! $result) { syslog(LOG_NOTICE, "db_profile_fermentation: ".$sql." result: ".mysqli_error($connect)); } else { - syslog(LOG_NOTICE, "db_profile_fermentation: deleted record ".$_GET['record']); + syslog(LOG_NOTICE, "db_profile_fermentation: deleted record ".$_POST['record']); } echo $result; @@ -105,7 +111,7 @@ $profiles .= '}'; } $profiles .= ']'; - syslog(LOG_NOTICE, $profiles); +// syslog(LOG_NOTICE, $profiles); header("Content-type: application/json"); echo $profiles; } diff -r fda7286871f2 -r 318aab371497 www/includes/db_profile_styles.php --- a/www/includes/db_profile_styles.php Sun Jan 27 17:39:53 2019 +0100 +++ b/www/includes/db_profile_styles.php Sun Jan 27 20:40:24 2019 +0100 @@ -10,87 +10,70 @@ } mysqli_set_charset($connect, "utf8" ); -// get data and store in a json array -$query = "SELECT * FROM profile_styles ORDER BY style_guide,style_letter,name"; -if (isset($_GET['insert'])) { - // INSERT COMMAND - $sql = "INSERT INTO `profile_styles` SET name='" . mysqli_real_escape_string($connect, $_GET['name']); - $sql .= "', category='" . mysqli_real_escape_string($connect, $_GET['category']); - $sql .= "', category_number='" . $_GET['category_number']; - $sql .= "', style_letter='" . mysqli_real_escape_string($connect, $_GET['style_letter']); - $sql .= "', style_guide='" . mysqli_real_escape_string($connect, $_GET['style_guide']); - $sql .= "', type='" . $_GET['type']; - $sql .= "', og_min='" . $_GET['og_min']; - $sql .= "', og_max='" . $_GET['og_max']; - $sql .= "', fg_min='" . $_GET['fg_min']; - $sql .= "', fg_max='" . $_GET['fg_max']; - $sql .= "', ibu_min='" . $_GET['ibu_min']; - $sql .= "', ibu_max='" . $_GET['ibu_max']; - $sql .= "', color_min='" . $_GET['color_min']; - $sql .= "', color_max='" . $_GET['color_max']; - $sql .= "', carb_min='" . $_GET['carb_min']; - $sql .= "', carb_max='" . $_GET['carb_max']; - $sql .= "', abv_min='" . $_GET['abv_min']; - $sql .= "', abv_max='" . $_GET['abv_max']; - $sql .= "', notes='" . mysqli_real_escape_string($connect, $_GET['notes']); - $sql .= "', profile='" . mysqli_real_escape_string($connect, $_GET['profile']); - $sql .= "', ingredients='" . mysqli_real_escape_string($connect, $_GET['ingredients']); - $sql .= "', examples='" . mysqli_real_escape_string($connect, $_GET['examples']); - $sql .= "';"; +if (isset($_POST['insert']) || isset($_POST['update'])) { + if (isset($_POST['insert'])) { + $sql = "INSERT INTO `profile_styles` SET "; + } + if (isset($_POST['update'])) { + $sql = "UPDATE `profile_styles` SET "; + } + + $sql .= "name='" . mysqli_real_escape_string($connect, $_POST['name']); + $sql .= "', category='" . mysqli_real_escape_string($connect, $_POST['category']); + $sql .= "', category_number='" . $_POST['category_number']; + $sql .= "', style_letter='" . mysqli_real_escape_string($connect, $_POST['style_letter']); + $sql .= "', style_guide='" . mysqli_real_escape_string($connect, $_POST['style_guide']); + $sql .= "', type='" . $_POST['type']; + $sql .= "', og_min='" . $_POST['og_min']; + $sql .= "', og_max='" . $_POST['og_max']; + $sql .= "', fg_min='" . $_POST['fg_min']; + $sql .= "', fg_max='" . $_POST['fg_max']; + $sql .= "', ibu_min='" . $_POST['ibu_min']; + $sql .= "', ibu_max='" . $_POST['ibu_max']; + $sql .= "', color_min='" . $_POST['color_min']; + $sql .= "', color_max='" . $_POST['color_max']; + $sql .= "', carb_min='" . $_POST['carb_min']; + $sql .= "', carb_max='" . $_POST['carb_max']; + $sql .= "', abv_min='" . $_POST['abv_min']; + $sql .= "', abv_max='" . $_POST['abv_max']; + $sql .= "', notes='" . mysqli_real_escape_string($connect, $_POST['notes']); + $sql .= "', profile='" . mysqli_real_escape_string($connect, $_POST['profile']); + $sql .= "', ingredients='" . mysqli_real_escape_string($connect, $_POST['ingredients']); + $sql .= "', examples='" . mysqli_real_escape_string($connect, $_POST['examples']); + if (isset($_POST['insert'])) { + $sql .= "';"; + } + if (isset($_POST['update'])) { + $sql .= "' WHERE record='" . $_POST['record'] . "';"; + } + $result = mysqli_query($connect, $sql); if (! $result) { syslog(LOG_NOTICE, "db_profile_styles: ".$sql." result: ".mysqli_error($connect)); } else { - syslog(LOG_NOTICE, "db_profile_styles: inserted ".$_GET['name']); + if (isset($_POST['update'])) { + syslog(LOG_NOTICE, "db_profile_styles: updated record ".$_POST['record']); + } else { + $lastid = mysqli_insert_id($connect); + syslog(LOG_NOTICE, "db_profile_styles: inserted record ".$lastid); + } } echo $result; -} else if (isset($_GET['update'])) { - // UPDATE COMMAND - $sql = "UPDATE `profile_styles` SET name='" . mysqli_real_escape_string($connect, $_GET['name']); - $sql .= "', category='" . mysqli_real_escape_string($connect, $_GET['category']); - $sql .= "', category_number='" . $_GET['category_number']; - $sql .= "', style_letter='" . mysqli_real_escape_string($connect, $_GET['style_letter']); - $sql .= "', style_guide='" . mysqli_real_escape_string($connect, $_GET['style_guide']); - $sql .= "', type='" . $_GET['type']; - $sql .= "', og_min='" . $_GET['og_min']; - $sql .= "', og_max='" . $_GET['og_max']; - $sql .= "', fg_min='" . $_GET['fg_min']; - $sql .= "', fg_max='" . $_GET['fg_max']; - $sql .= "', ibu_min='" . $_GET['ibu_min']; - $sql .= "', ibu_max='" . $_GET['ibu_max']; - $sql .= "', color_min='" . $_GET['color_min']; - $sql .= "', color_max='" . $_GET['color_max']; - $sql .= "', carb_min='" . $_GET['carb_min']; - $sql .= "', carb_max='" . $_GET['carb_max']; - $sql .= "', abv_min='" . $_GET['abv_min']; - $sql .= "', abv_max='" . $_GET['abv_max']; - $sql .= "', notes='" . mysqli_real_escape_string($connect, $_GET['notes']); - $sql .= "', profile='" . mysqli_real_escape_string($connect, $_GET['profile']); - $sql .= "', ingredients='" . mysqli_real_escape_string($connect, $_GET['ingredients']); - $sql .= "', examples='" . mysqli_real_escape_string($connect, $_GET['examples']); - $sql .= "' WHERE record='" . $_GET['record'] . "';"; +} else if (isset($_POST['delete'])) { + // DELETE COMMAND + $sql = "DELETE FROM `profile_styles` WHERE record='".$_POST['record']."';"; $result = mysqli_query($connect, $sql); if (! $result) { syslog(LOG_NOTICE, "db_profile_styles: ".$sql." result: ".mysqli_error($connect)); } else { - syslog(LOG_NOTICE, "db_profile_styles: updated record ".$_GET['record']); - } - echo $result; - -} else if (isset($_GET['delete'])) { - // DELETE COMMAND - $sql = "DELETE FROM `profile_styles` WHERE record='".$_GET['record']."';"; - $result = mysqli_query($connect, $sql); - if (! $result) { - syslog(LOG_NOTICE, "db_profile_styles: ".$sql." result: ".mysqli_error($connect)); - } else { - syslog(LOG_NOTICE, "db_profile_styles: deleted record ".$_GET['record']); + syslog(LOG_NOTICE, "db_profile_styles: deleted record ".$_POST['record']); } echo $result; } else { // SELECT COMMAND + $query = "SELECT * FROM profile_styles ORDER BY style_guide,style_letter,name"; $result = mysqli_query($connect, $query) or die("SQL Error 1: " . mysqli_error($connect)); while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { $styles[] = array( diff -r fda7286871f2 -r 318aab371497 www/js/global.js --- a/www/js/global.js Sun Jan 27 17:39:53 2019 +0100 +++ b/www/js/global.js Sun Jan 27 20:40:24 2019 +0100 @@ -345,6 +345,9 @@ // options for editors +var SGopts = { + inputMode: 'simple', spinMode: 'simple', theme: theme, width: 110, height: 23, min: 1.000, max: 1.199, decimalDigits: 3, spinButtons: true, spinButtonsStep: 0.001 +}; var Spin1dec1 = { inputMode: 'simple', spinMode: 'simple', theme: theme, width: 110, height: 23, min: 0, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.1 }; diff -r fda7286871f2 -r 318aab371497 www/js/profile_fermentation.js --- a/www/js/profile_fermentation.js Sun Jan 27 17:39:53 2019 +0100 +++ b/www/js/profile_fermentation.js Sun Jan 27 20:40:24 2019 +0100 @@ -50,8 +50,6 @@ $("#name").jqxTooltip({ content: 'De naam voor dit vergisting profiel.' }); $("#inittemp_lo").jqxTooltip({ content: 'De minimale begin temperatuur van dit profiel.' }); $("#inittemp_hi").jqxTooltip({ content: 'De maximale begin temperatuur van dit profiel.' }); -// $("#fridgemode").jqxTooltip({ content: 'Wanneer deze actief is dan wordt geregeld als koelkast op de lucht temperatuur sensor in plaats van op de bier sensor.' }); - $("#grid").jqxTooltip({ content: 'De maisch stappen in dit profiel.'}); // prepare the data var source = { datatype: "json", @@ -77,6 +75,7 @@ url: url, cache: false, data: data, + type: "POST", success: function (data, status, xhr) { // delete command is executed. commit(true); @@ -93,6 +92,7 @@ url: url, cache: false, data: data, + type: "POST", success: function (data, status, xhr) { commit(true); }, @@ -108,6 +108,7 @@ url: url, cache: false, data: data, + type: "POST", success: function (data, status, xhr) { // update command is executed. commit(true); @@ -166,8 +167,8 @@ toolbar.append(container); container.append(''); container.append(''); - $("#addrowbutton").jqxButton({ theme: theme, width: 150 }); - $("#deleterowbutton").jqxButton({ theme: theme, width: 150 }); + $("#addrowbutton").jqxButton({ template: "primary", theme: theme, width: 150 }); + $("#deleterowbutton").jqxButton({ template: "danger", theme: theme, width: 150 }); // create new row. $("#addrowbutton").on('click', function () { var datarow = generaterow(); @@ -185,7 +186,7 @@ }, columns: [ { text: 'Stap naam', datafield: 'name' }, - { text: 'Min temperatuur', datafield: 'target_lo', width: 100, align: 'right', cellsalign: 'right', cellsformat: 'f1', + { text: 'Min. °C', datafield: 'target_lo', width: 100, align: 'right', cellsalign: 'right', cellsformat: 'f1', validation: function (cell, value) { if (value < 0 || value > 40) { return { result: false, message: "De temperatuur moet tussen 0 en 40 zijn." }; @@ -193,7 +194,7 @@ return true; } }, - { text: 'Max temperatuur', datafield: 'target_hi', width: 100, align: 'right', cellsalign: 'right', cellsformat: 'f1', + { text: 'Max. °C', datafield: 'target_hi', width: 100, align: 'right', cellsalign: 'right', cellsformat: 'f1', validation: function (cell, value) { if (value < 0 || value > 40) { return { result: false, message: "De temperatuur moet tussen 0 en 40 zijn." }; @@ -220,15 +221,14 @@ } ] }); -// $("#grid").on('cellendedit', function (event) { -// $('#grid').jqxGrid('sortby', 'step_temp', 'asc'); -// }); }; // initialize the input fields. $("#name").jqxInput({ theme: theme, width: 640, height: 23 }); - $("#inittemp_lo").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 110, height: 23, min: 0, max: 40, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.1 }); - $("#inittemp_hi").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 110, height: 23, min: 0, max: 40, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.1 }); + $("#inittemp_lo").jqxNumberInput( Spin1dec5 ); + $("#inittemp_lo").jqxNumberInput({ max: 40 }); + $("#inittemp_hi").jqxNumberInput( Spin1dec5 ); + $("#inittemp_hi").jqxNumberInput({ max: 40 }); $("#fridgemode").jqxCheckBox({ theme: theme, height: 23, enableContainerClick: false }); var editrow = -1; @@ -245,28 +245,26 @@ var addButton = $("
Nieuw
"); container.append(addButton); statusbar.append(container); - addButton.jqxButton({ theme: theme, width: 120, height: 20 }); + addButton.jqxButton({ theme: theme, width: 90, height: 20 }); // add new row. addButton.click(function (event) { editrow = -1; - $("#popupWindow").jqxWindow({ position: { x: 110, y: 40 } }); - $("#name").val(''); + $("#name").val('Nieuw vergist profiel'); dataRecord.uuid = ''; - $("#inittemp_lo").val('20.0'); - $("#inittemp_hi").val('20.0'); - $("#fridgemode").val('0'); + $("#inittemp_lo").val(20.0); + $("#inittemp_hi").val(20.0); + $("#fridgemode").val(0); dataRecord.totalsteps = 0; dataRecord.duration = 0; editsteps(''); $("#popupWindow").jqxWindow('open'); }); }, - filterable: true, - filtermode: 'excel', + filterable: false, columns: [ { text: 'Vergisting profiel', datafield: 'name' }, - { text: 'Min. temperatuur', datafield: 'inittemp_lo', width: 150, align: 'right', cellsalign: 'right', cellsformat: 'f1' }, - { text: 'Max. temperatuur', datafield: 'inittemp_hi', width: 150, align: 'right', cellsalign: 'right', cellsformat: 'f1' }, + { text: 'Min. start °C', datafield: 'inittemp_lo', width: 150, align: 'right', cellsalign: 'right', cellsformat: 'f1' }, + { text: 'Max. start °C', datafield: 'inittemp_hi', width: 150, align: 'right', cellsalign: 'right', cellsformat: 'f1' }, { text: 'Stappen', datafield: 'totalsteps', width: 80, align: 'right', cellsalign: 'right' }, { text: 'Tijdsduur', datafield: 'duration', width: 150, align: 'right', cellsalign: 'right', cellsrenderer: function (row, columnfield, value, defaulthtml, columnproperties) { @@ -284,12 +282,10 @@ return ""+show+""; } }, - { text: 'Wijzig', datafield: 'Edit', width: 120, align: 'center', columntype: 'button', cellsrenderer: function () { + { text: 'Wijzig', datafield: 'Edit', width: 100, align: 'center', columntype: 'button', cellsrenderer: function () { return "Wijzig"; }, buttonclick: function (row) { - // open the popup window when the user clicks a button. editrow = row; - $("#popupWindow").jqxWindow({ position: { x: 110, y: 40 } }); // get the clicked row's data and initialize the input fields. dataRecord = $("#jqxgrid").jqxGrid('getrowdata', editrow); $("#name").val(dataRecord.name); @@ -307,6 +303,7 @@ $("#popupWindow").jqxWindow({ width: 1050, height: 550, + position: { x: 110, y: 30 }, resizable: false, theme: theme, isModal: true, diff -r fda7286871f2 -r 318aab371497 www/js/profile_styles.js --- a/www/js/profile_styles.js Sun Jan 27 17:39:53 2019 +0100 +++ b/www/js/profile_styles.js Sun Jan 27 20:40:24 2019 +0100 @@ -1,5 +1,5 @@ /***************************************************************************** - * Copyright (C) 2014-2018 + * Copyright (C) 2014-2019 * * Michiel Broek * @@ -33,8 +33,8 @@ okButton: $('#delOk'), cancelButton: $('#delCancel'), initContent: function () { - $('#delOk').jqxButton({ width: '65px', theme: theme }); - $('#delCancel').jqxButton({ width: '65px', theme: theme }); + $('#delOk').jqxButton({ template: "danger", width: '65px', theme: theme }); + $('#delCancel').jqxButton({ template: "success", width: '65px', theme: theme }); $('#delCancel').focus(); } }); @@ -43,7 +43,10 @@ $(document).ready(function () { + + var dataRecord = {}; var url = "includes/db_profile_styles.php"; + // prepare the data var source = { datatype: "json", @@ -55,7 +58,7 @@ { name: 'category_number', type: 'number' }, { name: 'style_letter', type: 'string' }, { name: 'style_guide', type: 'string' }, - { name: 'type', type: 'string' }, + { name: 'type', type: 'int' }, { name: 'og_min', type: 'float' }, { name: 'og_max', type: 'float' }, { name: 'fg_min', type: 'float' }, @@ -83,6 +86,7 @@ url: url, cache: false, data: data, + type: "POST", success: function (data, status, xhr) { // delete command is executed. commit(true); @@ -99,6 +103,7 @@ url: url, cache: false, data: data, + type: "POST", success: function (data, status, xhr) { commit(true); }, @@ -114,6 +119,7 @@ url: url, cache: false, data: data, + type: "POST", success: function (data, status, xhr) { // update command is executed. commit(true); @@ -126,29 +132,45 @@ }; var srcType = [ "Lager", "Ale", "Mead", "Wheat", "Mixed", "Cider" ]; // initialize the input fields. - $("#name").jqxInput({ theme: theme, width: 250, height: 23 }); - $("#category").jqxInput({ theme: theme, width: 250, height: 23 }); - $("#category_number").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 70, height: 23, min: 0, max: 1000, decimalDigits: 0, spinButtons: true }); + $("#name").jqxInput({ theme: theme, width: 320, height: 23 }); + $("#category").jqxInput({ theme: theme, width: 320, height: 23 }); + $("#category_number").jqxNumberInput( PosInt ); $("#style_letter").jqxInput({ theme: theme, width: 250, height: 23 }); - $("#style_guide").jqxInput({ theme: theme, width: 250, height: 23 }); - $("#type").jqxDropDownList({ theme: theme, source: srcType, width: 90, height: 23, dropDownHeight: 185 }); - $("#og_min").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 70, height: 23, min: 1.000, max: 1.200, decimalDigits: 3, spinButtons: true, spinButtonsStep: 0.001 }); - $("#og_max").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 70, height: 23, min: 1.000, max: 1.200, decimalDigits: 3, spinButtons: true, spinButtonsStep: 0.001 }); - $("#fg_min").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 70, height: 23, min: 0.990, max: 1.100, decimalDigits: 3, spinButtons: true, spinButtonsStep: 0.001 }); - $("#fg_max").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 70, height: 23, min: 1.000, max: 1.100, decimalDigits: 3, spinButtons: true, spinButtonsStep: 0.001 }); - $("#ibu_min").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 70, height: 23, min: 0, max: 200, decimalDigits: 0, spinButtons: true }); - $("#ibu_max").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 70, height: 23, min: 0, max: 200, decimalDigits: 0, spinButtons: true }); - $("#color_min").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 70, height: 23, min: 1, max: 200, decimalDigits: 0, spinButtons: true }); - $("#color_max").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 70, height: 23, min: 1, max: 200, decimalDigits: 0, spinButtons: true }); - $("#carb_min").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 70, height: 23, min: 0, max: 5, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.1 }); - $("#carb_max").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 70, height: 23, min: 0, max: 5, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.1 }); - $("#abv_min").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 70, height: 23, min: 0, max: 20, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.1 }); - $("#abv_max").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 70, height: 23, min: 0, max: 20, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.1 }); + $("#style_guide").jqxInput({ theme: theme, width: 320, height: 23 }); + $("#type").jqxDropDownList({ + theme: theme, + source: StyleTypeAdapter, + valueMember: 'id', + displayMember: 'nl', + width: 180, + height: 23, + autoDropDownHeight: true + }); + $("#og_min").jqxNumberInput( SGopts ); + $("#og_max").jqxNumberInput( SGopts ); + $("#fg_min").jqxNumberInput( SGopts ); + $("#fg_max").jqxNumberInput( SGopts ); + $("#ibu_min").jqxNumberInput( PosInt ); + $("#ibu_min").jqxNumberInput({ max: 200 }); + $("#ibu_max").jqxNumberInput( PosInt ); + $("#ibu_max").jqxNumberInput({ max: 200 }); + $("#color_min").jqxNumberInput( PosInt ); + $("#color_min").jqxNumberInput({ max: 200 }); + $("#color_max").jqxNumberInput( PosInt ); + $("#color_max").jqxNumberInput({ max: 200 }); + $("#carb_min").jqxNumberInput( Spin1dec1 ); + $("#carb_min").jqxNumberInput({ max: 5 }); + $("#carb_max").jqxNumberInput( Spin1dec1 ); + $("#carb_max").jqxNumberInput({ max: 5 }); + $("#abv_min").jqxNumberInput( Spin1dec1 ); + $("#abv_min").jqxNumberInput({ max: 20 }); + $("#abv_max").jqxNumberInput( Spin1dec1 ); + $("#abv_max").jqxNumberInput({ max: 20 }); + $("#notes").jqxInput({ theme: theme, width: 800, height: 100 }); + $("#profile").jqxInput({ theme: theme, width: 800, height: 48 }); + $("#ingredients").jqxInput({ theme: theme, width: 800, height: 23 }); + $("#examples").jqxInput({ theme: theme, width: 800, height: 48 }); - $("#notes").jqxInput({ theme: theme, width: 640, height: 100 }); - $("#profile").jqxInput({ theme: theme, width: 640, height: 48 }); - $("#ingredients").jqxInput({ theme: theme, width: 640, height: 23 }); - $("#examples").jqxInput({ theme: theme, width: 640, height: 48 }); var dataAdapter = new $.jqx.dataAdapter(source); var editrow = -1; // initialize jqxGrid @@ -164,29 +186,28 @@ var addButton = $("
Nieuw
"); container.append(addButton); statusbar.append(container); - addButton.jqxButton({ theme: theme, width: 120, height: 20 }); + addButton.jqxButton({ theme: theme, width: 90, height: 20 }); // add new row. addButton.click(function (event) { editrow = -1; - $("#popupWindow").jqxWindow({ position: { x: 130, y: 20 } }); - $("#name").val(''); + $("#name").val('Nieuwe stijl'); $("#category").val(''); $("#category_number").val(''); $("#style_letter").val(''); - $("#style_guide").val(''); - $("#type").val(''); - $("#og_min").val(''); - $("#og_max").val(''); - $("#fg_min").val(''); - $("#fg_max").val(''); - $("#ibu_min").val(''); - $("#ibu_max").val(''); - $("#color_min").val(''); - $("#color_max").val(''); - $("#carb_min").val(''); - $("#carb_max").val(''); - $("#abv_min").val(''); - $("#abv_max").val(''); + $("#style_guide").val('BKG 2015'); + $("#type").val(0); + $("#og_min").val(1.030); + $("#og_max").val(1.050); + $("#fg_min").val(1.005); + $("#fg_max").val(1.010); + $("#ibu_min").val(20); + $("#ibu_max").val(30); + $("#color_min").val(52); + $("#color_max").val(79); + $("#carb_min").val(2.0); + $("#carb_max").val(2.5); + $("#abv_min").val(4.0); + $("#abv_max").val(5.0); $("#notes").val(''); $("#profile").val(''); $("#ingredients").val(''); @@ -198,25 +219,24 @@ filtermode: 'excel', columns: [ { text: 'Groep', datafield: 'style_letter', width: 30 }, - { text: 'Style Name', datafield: 'name' }, - { text: 'OG', datafield: 'og_min', width: 60, align: 'right', cellsalign: 'right', cellsformat: 'f3' }, - { text: 'OG', datafield: 'og_max', width: 60, align: 'right', cellsalign: 'right', cellsformat: 'f3' }, - { text: 'FG', datafield: 'fg_min', width: 60, align: 'right', cellsalign: 'right', cellsformat: 'f3' }, - { text: 'FG', datafield: 'fg_max', width: 60, align: 'right', cellsalign: 'right', cellsformat: 'f3' }, - { text: 'IBU', datafield: 'ibu_min', width: 60, align: 'right', cellsalign: 'right', cellsformat: 'f0' }, - { text: 'IBU', datafield: 'ibu_max', width: 60, align: 'right', cellsalign: 'right', cellsformat: 'f0' }, - { text: 'EBC', datafield: 'color_min', width: 60, align: 'right', cellsalign: 'right', cellsformat: 'f0' }, - { text: 'EBC', datafield: 'color_max', width: 60, align: 'right', cellsalign: 'right', cellsformat: 'f0' }, - { text: 'Co2', datafield: 'carb_min', width: 60, align: 'right', cellsalign: 'right', cellsformat: 'f1' }, - { text: 'Co2', datafield: 'carb_max', width: 60, align: 'right', cellsalign: 'right', cellsformat: 'f1' }, - { text: 'ABV', datafield: 'abv_min', width: 60, align: 'right', cellsalign: 'right', cellsformat: 'f1' }, - { text: 'ABV', datafield: 'abv_max', width: 60, align: 'right', cellsalign: 'right', cellsformat: 'f1' }, - { text: 'Wijzig', datafield: 'Edit', width: 120, align: 'center', columntype: 'button', cellsrenderer: function () { + { text: 'Style Name', menu: false, datafield: 'name' }, + { text: 'OG', menu: false, datafield: 'og_min', width: 60, align: 'right', cellsalign: 'right', cellsformat: 'f3' }, + { text: 'OG', menu: false, datafield: 'og_max', width: 60, align: 'right', cellsalign: 'right', cellsformat: 'f3' }, + { text: 'FG', menu: false, datafield: 'fg_min', width: 60, align: 'right', cellsalign: 'right', cellsformat: 'f3' }, + { text: 'FG', menu: false, datafield: 'fg_max', width: 60, align: 'right', cellsalign: 'right', cellsformat: 'f3' }, + { text: 'IBU', menu: false, datafield: 'ibu_min', width: 60, align: 'right', cellsalign: 'right', cellsformat: 'f0' }, + { text: 'IBU', menu: false, datafield: 'ibu_max', width: 60, align: 'right', cellsalign: 'right', cellsformat: 'f0' }, + { text: 'EBC', menu: false, datafield: 'color_min', width: 60, align: 'right', cellsalign: 'right', cellsformat: 'f0' }, + { text: 'EBC', menu: false, datafield: 'color_max', width: 60, align: 'right', cellsalign: 'right', cellsformat: 'f0' }, + { text: 'Co2', menu: false, datafield: 'carb_min', width: 60, align: 'right', cellsalign: 'right', cellsformat: 'f1' }, + { text: 'Co2', menu: false, datafield: 'carb_max', width: 60, align: 'right', cellsalign: 'right', cellsformat: 'f1' }, + { text: 'ABV', menu: false, datafield: 'abv_min', width: 60, align: 'right', cellsalign: 'right', cellsformat: 'f1' }, + { text: 'ABV', menu: false, datafield: 'abv_max', width: 60, align: 'right', cellsalign: 'right', cellsformat: 'f1' }, + { text: 'Wijzig', menu: false, datafield: 'Edit', width: 100, align: 'center', columntype: 'button', cellsrenderer: function () { return "Wijzig"; }, buttonclick: function (row) { // open the popup window when the user clicks a button. editrow = row; - $("#popupWindow").jqxWindow({ position: { x: 130, y: 20 } }); // get the clicked row's data and initialize the input fields. var dataRecord = $("#jqxgrid").jqxGrid('getrowdata', editrow); $("#name").val(dataRecord.name); @@ -249,12 +269,19 @@ }); // initialize the popup window and buttons. $("#popupWindow").jqxWindow({ - width: 960, resizable: false, theme: theme, isModal: true, autoOpen: false, cancelButton: $("#Cancel"), modalOpacity: 0.40 + width: 1050, + position: { x: 110, y: 30 }, + resizable: false, + theme: theme, + isModal: true, + autoOpen: false, + cancelButton: $("#Cancel"), + modalOpacity: 0.40 }); $("#popupWindow").on('open', function () { $("#name").jqxInput('selectAll'); }); - $("#Delete").jqxButton({ theme: theme }); + $("#Delete").jqxButton({ template: "danger", width: '90px', theme: theme }); $("#Delete").click(function () { if (editrow >= 0) { // Open a popup to confirm this action. @@ -266,69 +293,46 @@ } $("#popupWindow").jqxWindow('hide'); }); - $("#Cancel").jqxButton({ theme: theme }); - $("#Save").jqxButton({ theme: theme }); + $("#Cancel").jqxButton({ template: "primary", width: '90px', theme: theme }); + $("#Save").jqxButton({ template: "success", width: '90px', theme: theme }); // update the edited row when the user clicks the 'Save' button. $("#Save").click(function () { + var rowID = -1; if (editrow >= 0) { - var rowID = $('#jqxgrid').jqxGrid('getrowid', editrow); - var row = { - record: rowID, - name: $("#name").val(), - category: $("#category").val(), - category_number: parseFloat($("#category_number").jqxNumberInput('decimal')), - style_letter: $("#style_letter").val(), - style_guide: $("#style_guide").val(), - type: $("#type").val(), - og_min: parseFloat($("#og_min").jqxNumberInput('decimal')), - og_max: parseFloat($("#og_max").jqxNumberInput('decimal')), - fg_min: parseFloat($("#fg_min").jqxNumberInput('decimal')), - fg_max: parseFloat($("#fg_max").jqxNumberInput('decimal')), - ibu_min: parseFloat($("#ibu_min").jqxNumberInput('decimal')), - ibu_max: parseFloat($("#ibu_max").jqxNumberInput('decimal')), - color_min: parseFloat($("#color_min").jqxNumberInput('decimal')), - color_max: parseFloat($("#color_max").jqxNumberInput('decimal')), - carb_min: parseFloat($("#carb_min").jqxNumberInput('decimal')), - carb_max: parseFloat($("#carb_max").jqxNumberInput('decimal')), - abv_min: parseFloat($("#abv_min").jqxNumberInput('decimal')), - abv_max: parseFloat($("#abv_max").jqxNumberInput('decimal')), - notes: $("#notes").val(), - profile: $("#profile").val(), - ingredients: $("#ingredients").val(), - examples: $("#examples").val() - }; + rowID = $('#jqxgrid').jqxGrid('getrowid', editrow); + } + var row = { + record: rowID, + name: $("#name").val(), + category: $("#category").val(), + category_number: parseFloat($("#category_number").jqxNumberInput('decimal')), + style_letter: $("#style_letter").val(), + style_guide: $("#style_guide").val(), + type: $("#type").val(), + og_min: parseFloat($("#og_min").jqxNumberInput('decimal')), + og_max: parseFloat($("#og_max").jqxNumberInput('decimal')), + fg_min: parseFloat($("#fg_min").jqxNumberInput('decimal')), + fg_max: parseFloat($("#fg_max").jqxNumberInput('decimal')), + ibu_min: parseFloat($("#ibu_min").jqxNumberInput('decimal')), + ibu_max: parseFloat($("#ibu_max").jqxNumberInput('decimal')), + color_min: parseFloat($("#color_min").jqxNumberInput('decimal')), + color_max: parseFloat($("#color_max").jqxNumberInput('decimal')), + carb_min: parseFloat($("#carb_min").jqxNumberInput('decimal')), + carb_max: parseFloat($("#carb_max").jqxNumberInput('decimal')), + abv_min: parseFloat($("#abv_min").jqxNumberInput('decimal')), + abv_max: parseFloat($("#abv_max").jqxNumberInput('decimal')), + notes: $("#notes").val(), + profile: $("#profile").val(), + ingredients: $("#ingredients").val(), + examples: $("#examples").val() + }; + if (editrow >= 0) { $('#jqxgrid').jqxGrid('updaterow', rowID, row); - $("#popupWindow").jqxWindow('hide'); } else { - // Insert a record - var newrow = { - record: -1, - name: $("#name").val(), - category: $("#category").val(), - category_number: parseFloat($("#category_number").jqxNumberInput('decimal')), - style_letter: $("#style_letter").val(), - style_guide: $("#style_guide").val(), - type: $("#type").val(), - og_min: parseFloat($("#og_min").jqxNumberInput('decimal')), - og_max: parseFloat($("#og_max").jqxNumberInput('decimal')), - fg_min: parseFloat($("#fg_min").jqxNumberInput('decimal')), - fg_max: parseFloat($("#fg_max").jqxNumberInput('decimal')), - ibu_min: parseFloat($("#ibu_min").jqxNumberInput('decimal')), - ibu_max: parseFloat($("#ibu_max").jqxNumberInput('decimal')), - color_min: parseFloat($("#color_min").jqxNumberInput('decimal')), - color_max: parseFloat($("#color_max").jqxNumberInput('decimal')), - carb_min: parseFloat($("#carb_min").jqxNumberInput('decimal')), - carb_max: parseFloat($("#carb_max").jqxNumberInput('decimal')), - abv_min: parseFloat($("#abv_min").jqxNumberInput('decimal')), - abv_max: parseFloat($("#abv_max").jqxNumberInput('decimal')), - notes: $("#notes").val(), - profile: $("#profile").val(), - ingredients: $("#ingredients").val(), - examples: $("#examples").val() - }; - $('#jqxgrid').jqxGrid('addrow', null, newrow); - $("#popupWindow").jqxWindow('hide'); + $('#jqxgrid').jqxGrid('addrow', null, row); } + $("#popupWindow").jqxWindow('hide'); + location.reload( true ); // reload ourself. }); createDelElements(); }); diff -r fda7286871f2 -r 318aab371497 www/profile_fermentation.php --- a/www/profile_fermentation.php Sun Jan 27 17:39:53 2019 +0100 +++ b/www/profile_fermentation.php Sun Jan 27 20:40:24 2019 +0100 @@ -13,15 +13,15 @@