# HG changeset patch # User Michiel Broek # Date 1549225583 -3600 # Node ID 9337b5ff8698aef7d51c857cac205a9a842fbbcb # Parent 4b8e5478d08fe03585d9e0ac84653ab252a9cd92 Added calcStage function that will be used to increase the brew process stage. diff -r 4b8e5478d08f -r 9337b5ff8698 www/includes/db_product.php --- a/www/includes/db_product.php Sun Feb 03 17:44:14 2019 +0100 +++ b/www/includes/db_product.php Sun Feb 03 21:26:23 2019 +0100 @@ -334,6 +334,7 @@ */ if (isset($_GET['record'])) { $query = "SELECT * FROM products WHERE record='" . $_GET['record'] . "';"; + syslog(LOG_NOTICE, "get products record " . $_GET['record']); } else { $query = "SELECT * FROM products ORDER BY birth,code;"; } @@ -593,6 +594,8 @@ $brews .= $brew; } $brews .= ']'; + if (isset($_GET['record'])) + syslog(LOG_NOTICE, "ready to sent"); header("Content-type: application/json"); echo $brews; } diff -r 4b8e5478d08f -r 9337b5ff8698 www/js/prod_edit.js --- a/www/js/prod_edit.js Sun Feb 03 17:44:14 2019 +0100 +++ b/www/js/prod_edit.js Sun Feb 03 21:26:23 2019 +0100 @@ -1087,6 +1087,87 @@ $("#keg_abv").val(Math.round((ABV + Amount * 0.47 / 7.907) * 10) / 10); } + function calcStage() { + + var newstage = dataRecord.stage; + + if (newstage < 2 && dataRecord.brew_date_start != '') + newstage = 2; // Brewday + if (newstage < 3 && dataRecord.brew_date_end != '') + newstage = 3; // Primary + if (newstage < 4 && dataRecord.primary_end_date != '') + newstage = 4; // Secondary + if (newstage < 5 && dataRecord.secondary_end_date != '') + newstage = 5; // Tertiary + if (newstage < 6 && dataRecord.package_date != '') + newstage = 6; // Package + if (newstage >= 6 && newstage < 10) { + var d = new Date(); + var date2 = dataRecord.package_date; + date2 = date2.split('-'); + // Now we convert the array to a Date object + date1 = new Date(d.getFullYear(), d.getMonth(), d.getDate()); + date2 = new Date(date2[0], date2[1]-1, date2[2]); + // We use the getTime() method and get the unixtime + date1_unixtime = parseInt(date1.getTime() / 1000); + date2_unixtime = parseInt(date2.getTime() / 1000); + // This is the calculated difference in seconds + var timeDifference = date1_unixtime - date2_unixtime; + var timeDifferenceInDays = timeDifference / 60 / 60 / 24; + console.log(date1+' '+date2+' days: '+timeDifferenceInDays); + if (newstage < 7 && timeDifferenceInDays < 14) // Carbonation period + newstage = 7; + else if (newstage < 8 && timeDifferenceInDays < 42) // Mature 6 weeks + newstage = 8; + else + newstage = 9; + } + if (newstage < 10 && dataRecord.taste_date != '') + newstage = 10; // Ready + + + console.log("calcStage() now: "+dataRecord.stage+" new: "+newstage); + + /* + * Set stage and enable or disable parts of the screens. + */ + $("#stage").val(StageData[dataRecord.stage].nl); + if (dataRecord.stage >= 10) { + $("#locked").jqxCheckBox({ disabled:false }); + } + + /* + * When the brew is in progress or done, block equipment select. + */ + if (dataRecord.stage > 1) + $("#equipmentSelect").jqxDropDownList({ disabled: true }); + if (dataRecord.stage > 0) { + $("#Delete").jqxButton({ disabled: true }); + } + if (dataRecord.stage < 3) { // Primary + $('#jqxTabs').jqxTabs('disableAt', 9); // Fermentation tab + // If recipe not complete, disable 8 too. + } else { + $('#jqxTabs').jqxTabs('enableAt', 9); + } + if (dataRecord.stage < 4) { // At least primary + $('#jqxTabs').jqxTabs('disableAt', 10); // Packaging tab + } else { + $('#jqxTabs').jqxTabs('enableAt', 10); + } + if (dataRecord.stage < 6) { // Not yet packaged + $("#inventory_reduced").jqxCheckBox({ disabled : true }); + } else { + if ($('#inventory_reduced').jqxCheckBox('checked')) + $("#inventory_reduced").jqxCheckBox({ disabled : true }); + } + if (dataRecord.stage < 8) { // Taste when at least Mature. + $('#jqxTabs').jqxTabs('disableAt', 11); // Tasting tab + } else { + $('#jqxTabs').jqxTabs('enableAt', 11); + } + } + function calcInit () { console.log("calcInit()"); @@ -1611,7 +1692,7 @@ $("#name").val(dataRecord.name); $("#code").val(dataRecord.code); $("#birth").val(dataRecord.birth); - $("#stage").val(dataRecord.stage); + $("#stage").val(StageData[dataRecord.stage].nl); $("#notes").val(dataRecord.notes); $("#inventory_reduced").val(dataRecord.inventory_reduced); $("#locked").val(dataRecord.locked); @@ -1786,39 +1867,7 @@ editMisc(dataRecord); editYeast(dataRecord); editMash(dataRecord); - - if (dataRecord.stage >= 10) { - $("#locked").jqxCheckBox({ disabled:false }); - } - // Enable or Disable settings depending on the stage. - if (dataRecord.stage > 1) - $("#equipmentSelect").jqxDropDownList({ disabled: true }); - if (dataRecord.stage > 0) { - $("#Delete").jqxButton({ disabled: true }); - } - if (dataRecord.stage < 3) { - $('#jqxTabs').jqxTabs('disableAt', 9); - // If recipe not complete, disable 8 too. - } else { - $('#jqxTabs').jqxTabs('enableAt', 9); - } - if (dataRecord.stage < 4) { // At least primary - $('#jqxTabs').jqxTabs('disableAt', 10); - } else { - $('#jqxTabs').jqxTabs('enableAt', 10); - } - if (dataRecord.stage < 6) { - $("#inventory_reduced").jqxCheckBox({ disabled : true }); - } else { - if ($('#inventory_reduced').jqxCheckBox('checked')) - $("#inventory_reduced").jqxCheckBox({ disabled : true }); - } - if (dataRecord.stage < 8) { // Taste when at least Mature. - $('#jqxTabs').jqxTabs('disableAt', 11); - } else { - $('#jqxTabs').jqxTabs('enableAt', 11); - } - + calcStage(); $('#jqxTabs').jqxTabs('select', 2); }, loadError: function (jqXHR, status, error) { @@ -3874,36 +3923,18 @@ // Tab 10, Fermentation // Note, fermentation temps changes must do calcCarbonation() - $("#brew_fermenter_sg2").jqxNumberInput({ inputMode: 'simple', readOnly: true, theme: theme, width: 70, height: 23, decimalDigits: 3 }); - $("#primary_start_temp").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 90, height: 23, min: 0, max: 40, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.5 }); - $("#primary_max_temp").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 90, height: 23, min: 0, max: 40, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.5 }); - $("#primary_end_temp").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 90, height: 23, min: 0, max: 40, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.5 }); - $("#primary_end_sg").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 90, height: 23, min: 0.990, max: 1.2, decimalDigits: 3, spinButtons: true, spinButtonsStep: 0.001 }); + $("#brew_fermenter_sg2").jqxNumberInput({ inputMode: 'simple', readOnly: true, theme: theme, width: 90, height: 23, decimalDigits: 3 }); + $("#primary_start_temp").jqxNumberInput( YeastT ); + $("#primary_max_temp").jqxNumberInput( YeastT ); + $("#primary_end_temp").jqxNumberInput( YeastT ); + $("#primary_end_sg").jqxNumberInput( SGopts ); $("#primary_svg").jqxNumberInput({ inputMode: 'simple', readOnly: true, theme: theme, width: 70, height: 23, decimalDigits: 1 }); $("#primary_end_date").jqxTooltip({ content: 'De eind datum van de hoofdvergisting en eventueel overhevelen.' }); - $("#primary_end_date").jqxDateTimeInput({ - theme: theme, - width: 150, - height: 23, - allowNullDate: true, - todayString: 'Vandaag', - clearString: 'Wissen', - showFooter: true, - formatString: 'yyyy-MM-dd' - }); - $("#secondary_temp").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 90, height: 23, min: 0, max: 40, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.5 }); + $("#primary_end_date").jqxDateTimeInput( Dateopts ); + $("#secondary_temp").jqxNumberInput( YeastT ); $("#secondary_end_date").jqxTooltip({ content: 'De eind datum van de navergisting en het begin van het lageren.' }); - $("#secondary_end_date").jqxDateTimeInput({ - theme: theme, - width: 150, - height: 23, - allowNullDate: true, - todayString: 'Vandaag', - clearString: 'Wissen', - showFooter: true, - formatString: 'yyyy-MM-dd' - }); - $("#tertiary_temp").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 90, height: 23, min: 0, max: 40, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.5 }); + $("#secondary_end_date").jqxDateTimeInput( Dateopts ); + $("#tertiary_temp").jqxNumberInput( YeastT ); $("#fg").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 90, height: 23, min: 0, decimalDigits: 3, spinButtons: true, spinButtonsStep: 0.001 }); $("#final_abv").jqxNumberInput({ inputMode: 'simple', readOnly: true, theme: theme, width: 70, height: 23, decimalDigits: 1 }); $("#final_svg").jqxNumberInput({ inputMode: 'simple', readOnly: true, theme: theme, width: 70, height: 23, decimalDigits: 1 }); @@ -3917,55 +3948,56 @@ // Tab 11, Packaging // TODO: high gravity packaging, extra water and recalc abv, color and ibu. $("#package_date").jqxTooltip({ content: 'De verpakkings datum van dit bier.' }); - $("#package_date").jqxDateTimeInput({ - theme: theme, - width: 150, - height: 23, - allowNullDate: true, - todayString: 'Vandaag', - clearString: 'Wissen', - showFooter: true, - formatString: 'yyyy-MM-dd' - }); + $("#package_date").jqxDateTimeInput( Dateopts ); $("#st_carb_min2").jqxTooltip({ content: 'Het minimum aanbevolen koolzuur volume voor deze bierstijl.'}); $("#st_carb_min2").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 1, readOnly: true }); $("#st_carb_max2").jqxTooltip({ content: 'Het maximum aamnevolen koolzuur volume voor deze bierstijl.'}); $("#st_carb_max2").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 1, readOnly: true }); $("#bottle_amount").jqxTooltip({ content: 'De totale hoeveelheid te bottelen bier.' }); - $("#bottle_amount").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 90, height: 23, min: 0, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.5 }); + $("#bottle_amount").jqxNumberInput( Spin1dec5 ); $("#keg_amount").jqxTooltip({ content: 'De totale hoeveelheid op fust te zetten bier.' }); - $("#keg_amount").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 90, height: 23, min: 0, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.5 }); + $("#keg_amount").jqxNumberInput( Spin1dec5 ); $("#bottle_carbonation").jqxTooltip({ content: 'Het gewenste CO2 volume in de flessen.' }); - $("#bottle_carbonation").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 90, height: 23, min: 0, max: 5, decimalDigits: 2, spinButtons: true, spinButtonsStep: 0.05 }); + $("#bottle_carbonation").jqxNumberInput( Spin2dec5 ); + $("#bottle_carbonation").jqxNumberInput({ max: 5 }); $("#keg_carbonation").jqxTooltip({ content: 'Het gewenste CO2 volume door de suiker in de fusten.' }); - $("#keg_carbonation").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 90, height: 23, min: 0, max: 5, decimalDigits: 2, spinButtons: true, spinButtonsStep: 0.05 }); - $("#bottle_priming_sugar").jqxDropDownList({ theme: theme, source: srcSugar, width: 175, height: 23, dropDownHeight: 150 }); - $("#keg_priming_sugar").jqxDropDownList({ theme: theme, source: srcSugar, width: 175, height: 23, dropDownHeight: 150 }); - $("#bottle_priming_amount").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 70, height: 23, decimalDigits: 1, readOnly: true }); - $("#keg_priming_amount").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 70, height: 23, decimalDigits: 1, readOnly: true }); - $("#bottle_priming_total").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 70, height: 23, decimalDigits: 1, readOnly: true }); - $("#keg_priming_total").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 70, height: 23, decimalDigits: 1, readOnly: true }); + $("#keg_carbonation").jqxNumberInput( Spin2dec5 ); + $("#keg_carbonation").jqxNumberInput({ max: 5 }); + $("#bottle_priming_sugar").jqxDropDownList({ + theme: theme, + source: PrimingSugarAdapter, + valueMember: 'id', + displayMember: 'nl', + width: 180, + height: 23, + autoDropDownHeight: true + }); + $("#keg_priming_sugar").jqxDropDownList({ + theme: theme, + source: PrimingSugarAdapter, + valueMember: 'id', + displayMember: 'nl', + width: 180, + height: 23, + autoDropDownHeight: true + }); + $("#bottle_priming_amount").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 90, height: 23, decimalDigits: 1, readOnly: true }); + $("#keg_priming_amount").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 90, height: 23, decimalDigits: 1, readOnly: true }); + $("#bottle_priming_total").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 90, height: 23, decimalDigits: 1, readOnly: true }); + $("#keg_priming_total").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 90, height: 23, decimalDigits: 1, readOnly: true }); $("#keg_forced_carb").jqxCheckBox({ theme: theme, width: 120, height: 23 }); - $("#keg_pressure").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 70, height: 23, decimalDigits: 1, readOnly: true }); - $("#bottle_abv").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 70, height: 23, decimalDigits: 1, readOnly: true }); - $("#keg_abv").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 70, height: 23, decimalDigits: 1, readOnly: true }); - $("#bottle_carbonation_temp").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 90, height: 23, min: 0.5, max: 40, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.5 }); - $("#keg_carbonation_temp").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 90, height: 23, min: 0.5, max: 40, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.5 }); + $("#keg_pressure").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 90, height: 23, decimalDigits: 1, readOnly: true }); + $("#bottle_abv").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 90, height: 23, decimalDigits: 1, readOnly: true }); + $("#keg_abv").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 90, height: 23, decimalDigits: 1, readOnly: true }); + $("#bottle_carbonation_temp").jqxNumberInput( YeastT ); + $("#keg_carbonation_temp").jqxNumberInput( YeastT ); // Tab 12, Tasting $("#taste_date").jqxTooltip({ content: 'De proef datum van dit bier.' }); - $("#taste_date").jqxDateTimeInput({ - theme: theme, - width: 150, - height: 23, - allowNullDate: true, - todayString: 'Vandaag', - clearString: 'Wissen', - showFooter: true, - formatString: 'yyyy-MM-dd' - }); + $("#taste_date").jqxDateTimeInput( Dateopts ); $("#taste_rate").jqxTooltip({ content: 'Het cijfer voor dit bier van 1 tot 10.' }); - $("#taste_rate").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: 1, max: 10, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.5 }); + $("#taste_rate").jqxNumberInput( Spin1dec5 ); + $("#taste_rate").jqxNumberInput({ max: 10 }); $("#taste_color").jqxTooltip({ content: 'De kleur van het bier.' }); $("#taste_color").jqxInput({ theme: theme, width: 320, height: 23 }); $("#taste_transparency").jqxTooltip({ content: 'De helderheid van het bier.' });