# HG changeset patch # User Michiel Broek # Date 1566828087 -7200 # Node ID 046ff5fdc96ca7b9ff964cb471831a5cd4327fa8 # Parent 53fafe4747424466507996ca51ebf6d152b55876 Implemented products.secondary_end_sg field. The missing values are updated by the crontask. diff -r 53fafe474742 -r 046ff5fdc96c www/crontasks.php --- a/www/crontasks.php Sun Aug 25 14:04:25 2019 +0200 +++ b/www/crontasks.php Mon Aug 26 16:01:27 2019 +0200 @@ -91,3 +91,15 @@ } } + +/* + * Check and update secondary_end_sg + */ +$query = "UPDATE products SET secondary_end_sg=fg WHERE stage > 5 AND secondary_end_sg='0';"; +$result = mysqli_query($connect, $query); +$changed = mysqli_affected_rows($connect); +if ($changed > 0) { + syslog(LOG_NOTICE, "Updated ".$changed." products with new secondary_end_sg value"); +} + + diff -r 53fafe474742 -r 046ff5fdc96c www/import/from_brouwhulp.php --- a/www/import/from_brouwhulp.php Sun Aug 25 14:04:25 2019 +0200 +++ b/www/import/from_brouwhulp.php Mon Aug 26 16:01:27 2019 +0200 @@ -1685,6 +1685,7 @@ $sdate = new DateTime($brewdate); $sdate->modify("+".floatval($recipe->SECONDARY_AGE)." days"); $sql .= "', secondary_temp='" . floatval($recipe->SECONDARY_TEMP); + $sql .= "', secondary_end_sg='" . floatval($recipe->FG); $sql .= "', secondary_end_date='" . $sdate->format("Y-m-d"); $stage = 5; // Tertiary diff -r 53fafe474742 -r 046ff5fdc96c www/includes/db_product.php --- a/www/includes/db_product.php Sun Aug 25 14:04:25 2019 +0200 +++ b/www/includes/db_product.php Mon Aug 26 16:01:27 2019 +0200 @@ -116,6 +116,7 @@ $sql .= "', primary_end_date='" . $_POST['primary_end_date'] ."'"; $sql .= ", primary_end_sg='" . $_POST['primary_end_sg']; $sql .= "', secondary_temp='" . $_POST['secondary_temp']; + $sql .= "', secondary_end_sg='" . $_POST['secondary_end_sg']; if ($_POST['secondary_end_date'] == '') $sql .= "', secondary_end_date=NULL"; else @@ -711,6 +712,7 @@ $brew .= ',"primary_end_sg":' . floatval($row['primary_end_sg']); $brew .= ',"primary_end_date":"' . $row['primary_end_date']; $brew .= '","secondary_temp":' . floatval($row['secondary_temp']); + $brew .= ',"secondary_end_sg":' . floatval($row['secondary_end_sg']); $brew .= ',"secondary_end_date":"' . $row['secondary_end_date']; $brew .= '","tertiary_temp":' . floatval($row['tertiary_temp']); $brew .= ',"package_date":"' . $row['package_date']; diff -r 53fafe474742 -r 046ff5fdc96c www/js/prod_edit.js --- a/www/js/prod_edit.js Sun Aug 25 14:04:25 2019 +0200 +++ b/www/js/prod_edit.js Mon Aug 26 16:01:27 2019 +0200 @@ -1764,16 +1764,23 @@ } function calcFermentation(){ -if(dataRecord.brew_fermenter_sg<1.020)return; -var obrix=sg_to_brix(dataRecord.brew_fermenter_sg); -if ((dataRecord.primary_end_sg>0.990)&&(dataRecord.primary_end_sg0.990)&&(dataRecord.fg0.990)&&(dataRecord.primary_end_sg0.990)&&(dataRecord.secondary_end_sg0.990)&&(dataRecord.fg= 6) { // Packaged $("#secondary_temp").jqxNumberInput({ spinButtons: false, readOnly: true, width: 90 }); + $("#secondary_end_sg").jqxNumberInput({ spinButtons: false, readOnly: true, width: 90 }); $("#secondary_end_date").jqxDateTimeInput({ disabled: true }); $("#tertiary_temp").jqxNumberInput({ spinButtons: false, readOnly: true, width: 90 }); $("#fg").jqxNumberInput({ spinButtons: false, readOnly: true, width: 90 }); @@ -2528,6 +2536,17 @@ calcFermentation(); } }); + $("#secondary_end_sg").on('change',function (event){dataRecord.secondary_end_sg=parseFloat(event.args.value);calcFermentation();}); + $("#secondary_end_brix").on('change', function (event) { + if(dataRecord.brew_fermenter_sg>=1.020){ + OBrix=sg_to_brix(dataRecord.brew_fermenter_sg); + FBrix=parseFloat(event.args.value); +var FG=Round(1.0031-0.002318474*OBrix-0.000007775*(OBrix*OBrix)-0.000000034*Math.pow(OBrix,3)+0.00574*(FBrix)+0.00003344*(FBrix*FBrix)+0.000000086*Math.pow(FBrix,3),4); + //console.log("OBrix:"+OBrix+" FBrix:"+FBrix+" FG:"+FG); + if(FBrix>0.05){$("#secondary_end_sg").val(FG);dataRecord.secondary_end_sg=FG;} + calcFermentation(); + } + }); $("#final_brix").on('change',function (event){ if(dataRecord.brew_fermenter_sg>=1.020){ OBrix=sg_to_brix(dataRecord.brew_fermenter_sg); @@ -2739,6 +2758,7 @@ primary_end_sg: parseFloat($("#primary_end_sg").jqxNumberInput('decimal')), primary_end_date: $("#primary_end_date").val(), secondary_temp: parseFloat($("#secondary_temp").jqxNumberInput('decimal')), + secondary_end_sg: parseFloat($("#secondary_end_sg").jqxNumberInput('decimal')), secondary_end_date: $("#secondary_end_date").val(), tertiary_temp: parseFloat($("#tertiary_temp").jqxNumberInput('decimal')), package_date: $("#package_date").val(), @@ -2967,6 +2987,7 @@ { name: 'primary_end_sg', type: 'float' }, { name: 'primary_end_date', type: 'string' }, { name: 'secondary_temp', type: 'float' }, + { name: 'secondary_end_sg', type: 'float' }, { name: 'secondary_end_date', type: 'string' }, { name: 'tertiary_temp', type: 'float' }, { name: 'package_date', type: 'string' }, @@ -3178,6 +3199,7 @@ $("#primary_end_sg").val(dataRecord.primary_end_sg); $("#primary_end_date").val(dataRecord.primary_end_date); $("#secondary_temp").val(dataRecord.secondary_temp); + $("#secondary_end_sg").val(dataRecord.secondary_end_sg); $("#secondary_end_date").val(dataRecord.secondary_end_date); $("#tertiary_temp").val(dataRecord.tertiary_temp); $("#package_date").val(dataRecord.package_date); @@ -5774,6 +5796,12 @@ $("#primary_end_date").jqxDateTimeInput( Dateopts ); $('#primary_end_date').on('close', function (event) { calcStage(); }); $("#secondary_temp").jqxNumberInput( YeastT ); + $("#secondary_end_sg").jqxTooltip({ content: 'Het gemeten SG aan het eind van de navergisting.' }); + $("#secondary_end_sg").jqxNumberInput( SGopts ); + $("#secondary_end_brix").jqxTooltip({ content: 'Hulpfinctie: de afgelezen °Brix RI waarde met een refractometer.' }); + $("#secondary_end_brix").jqxNumberInput( Spin1dec ); + $("#secondary_svg").jqxTooltip({ content: 'De schijnbare vergisting graad behaald na de nagisting.' }); + $("#secondary_svg").jqxNumberInput( Show1dec ); $("#secondary_end_date").jqxTooltip({ content: 'De eind datum van de navergisting en het begin van het lageren.' }); $("#secondary_end_date").jqxDateTimeInput( Dateopts ); $('#secondary_end_date').on('close', function (event) { calcStage(); }); diff -r 53fafe474742 -r 046ff5fdc96c www/prod_duplicate.php --- a/www/prod_duplicate.php Sun Aug 25 14:04:25 2019 +0200 +++ b/www/prod_duplicate.php Mon Aug 26 16:01:27 2019 +0200 @@ -97,6 +97,7 @@ $sql .= "', primary_end_date=NULL"; $sql .= ", primary_end_sg='0"; $sql .= "', secondary_temp='0"; +$sql .= "', secondary_end_sg='0"; $sql .= "', secondary_end_date=NULL"; $sql .= ", tertiary_temp='0"; $sql .= "', package_date=NULL"; diff -r 53fafe474742 -r 046ff5fdc96c www/prod_edit.php --- a/www/prod_edit.php Sun Aug 25 14:04:25 2019 +0200 +++ b/www/prod_edit.php Mon Aug 26 16:01:27 2019 +0200 @@ -683,8 +683,16 @@
+ Eind nagisting SG: +
+ Afgelezen °Brix RI: +
+ + Eind nagisting/start lageren: -
+
+ Schijnbare vergistingsgraad %: +

@@ -697,9 +705,6 @@
-   - - Het verwachte eind SG:
@@ -716,7 +721,7 @@
-
+
diff -r 53fafe474742 -r 046ff5fdc96c www/prod_print.php --- a/www/prod_print.php Sun Aug 25 14:04:25 2019 +0200 +++ b/www/prod_print.php Mon Aug 26 16:01:27 2019 +0200 @@ -834,46 +834,50 @@ $this->Cell(45,5,'Hoofdvergisting start temp.',0,0,'L',true); $this->Cell(45,5,sprintf("%.1f",$row['primary_start_temp']).DEG.'C',0,0,'L',true); $this->Cell($vul,5,'',0,0,'L',false); - $this->Cell(45,5,'Navergisting tempertuur',0,0,'L',true); - $this->Cell(45,5,sprintf("%.1f", $row['secondary_temp']).DEG.'C',0,0,'L',true); - $this->Ln(); - - $this->SetX($this->TableX); $this->Cell(45,5,'Hoofdvergisting piek temp.',0,0,'L',true); $this->Cell(45,5,sprintf("%.1f",$row['primary_max_temp']).DEG.'C',0,0,'L',true); - $this->Cell($vul,5,'',0,0,'L',false); - $this->Cell(45,5,'Navergisting einde',0,0,'L',true); - $this->Cell(45,5,$row['secondary_end_date'],0,0,'L',true); $this->Ln(); $this->SetX($this->TableX); $this->Cell(45,5,'Hoofdvergisting eind temp.',0,0,'L',true); $this->Cell(45,5,sprintf("%.1f",$row['primary_end_temp']).DEG.'C',0,0,'L',true); - $this->Cell($vul,5,'',0,0,'L',false); - $this->Cell(45,5,'Lageren temperatuur',0,0,'L',true); - $this->Cell(45,5,sprintf("%.1f",$row['tertiary_temp']).DEG.'C',0,0,'L',true); + $this->Cell($vul,5,'',0,0,'L',false); + $this->Cell(45,5,'Hoofdvergisting densiteit',0,0,'L',true); + $this->Cell(45,5,sprintf("%.3f",floatval($row['primary_end_sg'])).' SG',0,0,'L',true); $this->Ln(); $this->SetX($this->TableX); - $this->Cell(45,5,'Hoofdvergisting densiteit',0,0,'L',true); - $this->Cell(45,5,density_str(floatval($row['primary_end_sg'])),0,0,'L',true); - $this->Cell($vul,5,'',0,0,'L',false); - $this->Cell(45,5,'Lageren densiteit',0,0,'L',true); - $this->Cell(45,5,density_str(floatval($row['fg'])),0,0,'L',true); - $this->Ln(); + $this->Cell(45,5,'Hoofdvergisting einde',0,0,'L',true); + $this->Cell(45,5,$row['primary_end_date'],0,0,'L',true); + $this->Ln(); + + $this->SetX($this->TableX); + $this->Cell(45,5,'Navergisting tempertuur',0,0,'L',true); + $this->Cell(45,5,sprintf("%.1f", $row['secondary_temp']).DEG.'C',0,0,'L',true); + $this->Cell($vul,5,'',0,0,'L',false); + $this->Cell(45,5,'Nagisten densiteit',0,0,'L',true); + $this->Cell(45,5,sprintf("%.3f",floatval($row['secondary_end_sg'])).' SG',0,0,'L',true); + $this->Ln(); $this->SetX($this->TableX); - $this->Cell(45,5,'Hoofdvergisting einde',0,0,'L',true); - $this->Cell(45,5,$row['primary_end_date'],0,0,'L',true); - $this->Cell($vul,5,'',0,0,'L',false); + $this->Cell(45,5,'Nagisten einde',0,0,'L',true); + $this->Cell(45,5,$row['secondary_end_date'],0,0,'L',true); + $this->Ln(); + + $this->SetX($this->TableX); + $this->Cell(45,5,'Lageren temperatuur',0,0,'L',true); + $this->Cell(45,5,sprintf("%.1f",$row['tertiary_temp']).DEG.'C',0,0,'L',true); + $this->Cell($vul,5,'',0,0,'L',false); + $this->Cell(45,5,'Lageren densiteit',0,0,'L',true); + $this->Cell(45,5,sprintf("%.3f",floatval($row['fg'])).' SG',0,0,'L',true); + $this->Ln(); + + $this->SetX($this->TableX); $this->Cell(45,5,'Lageren einde',0,0,'L',true); $this->Cell(45,5,$row['package_date'],0,0,'L',true); - $this->Ln(); - + $this->Cell($vul,5,'',0,0,'L',false); $svg = 100 * (floatval($row['brew_fermenter_sg']) - floatval($row['fg'])) / (floatval($row['brew_fermenter_sg']) - 1); - $this->SetX($this->TableX); - $this->Cell($vul+90,5,'',0,0,'L',false); - $this->Cell(45,5,'Schijnbare vergistingsgraad',0,0,'L',true); + $this->Cell(45,5,'Schijnbare vergistingsgraad',0,0,'L',true); $this->Cell(45,5,sprintf("%.1f",$svg).'%',0,0,'L',true); $this->Ln(); } diff -r 53fafe474742 -r 046ff5fdc96c www/rec_toproduct.php --- a/www/rec_toproduct.php Sun Aug 25 14:04:25 2019 +0200 +++ b/www/rec_toproduct.php Mon Aug 26 16:01:27 2019 +0200 @@ -56,7 +56,7 @@ $sql .= "', brew_fermenter_extrawater='0', brew_fermenter_tcloss='0.5', brew_fermenter_sg='0"; $sql .= "', brew_fermenter_ibu='0', brew_fermenter_color='0', brew_date_end=NULL, og='0', fg='0"; $sql .= "', primary_start_temp='0', primary_max_temp='0', primary_end_temp='0', primary_end_date=NULL, primary_end_sg='0"; -$sql .= "', secondary_temp='0', secondary_end_date=NULL, tertiary_temp='0"; +$sql .= "', secondary_temp='0', secondary_end_sg='0', secondary_end_date=NULL, tertiary_temp='0"; $sql .= "', package_date=NULL, package_volume='0', package_infuse_amount='0', package_infuse_abv='0', package_infuse_notes='"; $sql .= "', package_abv='0', package_ph='0"; $sql .= "', bottle_amount='0', bottle_carbonation='0', bottle_priming_water='0', bottle_priming_amount='0', bottle_carbonation_temp='23";