# HG changeset patch # User Michiel Broek # Date 1624044388 -7200 # Node ID 5095105866655ef7037808b7897a88ecbbcf2d90 # Parent 30abc8024afebac0e5d58c071781567c3e34d87a Added a empty second water source to the dropdown for water 2. When the empty water is selected, all volumes are reset to a single water source. Don't show the second water in the printed recipe and checklist if there is only one water source. diff -r 30abc8024afe -r 509510586665 www/js/global.js --- a/www/js/global.js Fri Jun 18 15:26:55 2021 +0200 +++ b/www/js/global.js Fri Jun 18 21:26:28 2021 +0200 @@ -738,6 +738,33 @@ console.log(status + ' ' + error); }, }), +water2list = new $.jqx.dataAdapter(waterInvSource, { + beforeLoadComplete: function(records) { + var data, i, row, none = {}; + data = new Array(); + none['name'] = 'Geen mengwater'; /* Put empty water on top */ + none['unlimited_stock'] = 0; + none['calcium'] = 0; + none['sulfate'] = 0; + none['chloride'] = 0; + none['sodium'] = 0; + none['magnesium'] = 0; + none['ph'] = 0; + none['total_alkalinity'] = 0; + none['inventory'] = 0; + none['cost'] = 0; + data.push(none); + for (i = 0; i < records.length; i++) { + row = records[i]; + if (row.inventory || row.unlimited_stock || ! waterinstock) + data.push(row); + } + return data; + }, + loadError: function(jqXHR, status, error) { + console.log(status + ' ' + error); + }, +}), // dropdownlist datasource from profile_water waterProfileSource = { diff -r 30abc8024afe -r 509510586665 www/js/prod_edit.js --- a/www/js/prod_edit.js Fri Jun 18 15:26:55 2021 +0200 +++ b/www/js/prod_edit.js Fri Jun 18 21:26:28 2021 +0200 @@ -6051,7 +6051,7 @@ $('#w2_name').jqxDropDownList({ placeHolder: 'Kies meng water:', theme: theme, - source: waterlist, + source: water2list, displayMember: 'name', width: 250, height: 27, @@ -6061,7 +6061,13 @@ $('#w2_name').on('select', function(event) { if (event.args) { var datarecord, index = event.args.index; - datarecord = waterlist.records[index]; + datarecord = water2list.records[index]; + if (index == 0) { + dataRecord.w2_amount = 0; + $('#w2_amount').val(0); + dataRecord.w1_amount = mash_infuse; + $('#w1_amount').val(mash_infuse); + } dataRecord.w2_name = datarecord.name; $('#w2_calcium').val(datarecord.calcium); dataRecord.w2_calcium = datarecord.calcium; diff -r 30abc8024afe -r 509510586665 www/prod_checklist.php --- a/www/prod_checklist.php Fri Jun 18 15:26:55 2021 +0200 +++ b/www/prod_checklist.php Fri Jun 18 21:26:28 2021 +0200 @@ -128,7 +128,7 @@ $this->Checkline(sprintf("%.1f",floatval($row['w1_amount'] * $factor)).' liter water '.$row['w1_name']); $mashwater += floatval($row['w1_amount'] * $factor); } - if ($row['w2_name']) { + if ($row['w2_name'] && floatval($row['w2_amount'])) { $this->Checkline(sprintf("%.1f",floatval($row['w2_amount'] * $factor)).' liter water '.$row['w2_name']); $mashwater += floatval($row['w2_amount'] * $factor); } diff -r 30abc8024afe -r 509510586665 www/prod_print.php --- a/www/prod_print.php Fri Jun 18 15:26:55 2021 +0200 +++ b/www/prod_print.php Fri Jun 18 21:26:28 2021 +0200 @@ -558,27 +558,29 @@ $this->Cell(15,5,sprintf("%.1f", $row['w1_chloride']),0,0,'R',true); $this->Cell(15,5,sprintf("%.1f", $row['w1_sulfate']),0,0,'R',true); $this->Cell(15,5,sprintf("%.1f", $row['w1_ph']),0,0,'R',true); - $this->Ln(); - $this->Cell($vul,5,$row['w2_name'],0,0,'L',true); - $this->Cell(20,5,sprintf("%.1f", $row['w2_amount']).' L',0,0,'R',true); - $this->Cell(15,5,sprintf("%.1f", $row['w2_calcium']),0,0,'R',true); - $this->Cell(15,5,sprintf("%.1f", $row['w2_magnesium']),0,0,'R',true); - $this->Cell(15,5,sprintf("%.1f", $row['w2_sodium']),0,0,'R',true); - $this->Cell(15,5,sprintf("%.1f", $row['w2_total_alkalinity']),0,0,'R',true); - $this->Cell(15,5,sprintf("%.1f", $row['w2_chloride']),0,0,'R',true); - $this->Cell(15,5,sprintf("%.1f", $row['w2_sulfate']),0,0,'R',true); - $this->Cell(15,5,sprintf("%.1f", $row['w2_ph']),0,0,'R',true); - $this->Ln(); - $this->Cell($vul,5,'Gemengd water',0,0,'L',true); - $this->Cell(20,5,sprintf("%.1f", $row['wg_amount']).' L',0,0,'R',true); - $this->Cell(15,5,sprintf("%.1f", $row['wg_calcium']),0,0,'R',true); - $this->Cell(15,5,sprintf("%.1f", $row['wg_magnesium']),0,0,'R',true); - $this->Cell(15,5,sprintf("%.1f", $row['wg_sodium']),0,0,'R',true); - $this->Cell(15,5,sprintf("%.1f", $row['wg_total_alkalinity']),0,0,'R',true); - $this->Cell(15,5,sprintf("%.1f", $row['wg_chloride']),0,0,'R',true); - $this->Cell(15,5,sprintf("%.1f", $row['wg_sulfate']),0,0,'R',true); - $this->Cell(15,5,sprintf("%.1f", $row['wg_ph']),0,0,'R',true); - $this->Ln(); + $this->Ln(); + if ($row['w2_name'] && floatval($row['w2_amount'])) { + $this->Cell($vul,5,$row['w2_name'],0,0,'L',true); + $this->Cell(20,5,sprintf("%.1f", $row['w2_amount']).' L',0,0,'R',true); + $this->Cell(15,5,sprintf("%.1f", $row['w2_calcium']),0,0,'R',true); + $this->Cell(15,5,sprintf("%.1f", $row['w2_magnesium']),0,0,'R',true); + $this->Cell(15,5,sprintf("%.1f", $row['w2_sodium']),0,0,'R',true); + $this->Cell(15,5,sprintf("%.1f", $row['w2_total_alkalinity']),0,0,'R',true); + $this->Cell(15,5,sprintf("%.1f", $row['w2_chloride']),0,0,'R',true); + $this->Cell(15,5,sprintf("%.1f", $row['w2_sulfate']),0,0,'R',true); + $this->Cell(15,5,sprintf("%.1f", $row['w2_ph']),0,0,'R',true); + $this->Ln(); + $this->Cell($vul,5,'Gemengd water',0,0,'L',true); + $this->Cell(20,5,sprintf("%.1f", $row['wg_amount']).' L',0,0,'R',true); + $this->Cell(15,5,sprintf("%.1f", $row['wg_calcium']),0,0,'R',true); + $this->Cell(15,5,sprintf("%.1f", $row['wg_magnesium']),0,0,'R',true); + $this->Cell(15,5,sprintf("%.1f", $row['wg_sodium']),0,0,'R',true); + $this->Cell(15,5,sprintf("%.1f", $row['wg_total_alkalinity']),0,0,'R',true); + $this->Cell(15,5,sprintf("%.1f", $row['wg_chloride']),0,0,'R',true); + $this->Cell(15,5,sprintf("%.1f", $row['wg_sulfate']),0,0,'R',true); + $this->Cell(15,5,sprintf("%.1f", $row['wg_ph']),0,0,'R',true); + $this->Ln(); + } $this->Cell($vul,5,'Behandeld water',0,0,'L',true); $this->Cell(20,5,'',0,0,'R',true); $this->Cell(15,5,sprintf("%.1f", $row['wb_calcium']),0,0,'R',true);