www/js/inv_waters.js

Wed, 06 May 2020 14:14:14 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Wed, 06 May 2020 14:14:14 +0200
changeset 667
1246550451ca
parent 662
4bb005694ce7
child 701
3ce3df681be0
permissions
-rw-r--r--

Removed the last compressed css file. Reworked all mash steps, implemented deconction steps. Added calculations for infuse amounts and decoctions amounts. The mash steps are now manually sorted in the editor grids to have full control over the steps order. Display errors in red in the grid. Updated beerxml export, the product checklist and print output of the products and recipes for all these mash steps changes.

21
acb2d8098f19 Added inventory miscs and water sources.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1 /*****************************************************************************
662
4bb005694ce7 Version 0.3.32 Inventory water and profile water edit screens updated and added ion balance fields. Moved acid specs to global.js. In prod_edit and rec_edit changed the water calculations, eliminated the double percentage calculation. The pH values in the water tab have now 2 decimal digits. The mash pH field is only shown in auto calculate mode. The calculated acid addition results are now a bit better and compare with several famous spreadsheets.
Michiel Broek <mbroek@mbse.eu>
parents: 563
diff changeset
2 * Copyright (C) 2014-2020
21
acb2d8098f19 Added inventory miscs and water sources.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3 *
acb2d8098f19 Added inventory miscs and water sources.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4 * Michiel Broek <mbroek at mbse dot eu>
acb2d8098f19 Added inventory miscs and water sources.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5 *
acb2d8098f19 Added inventory miscs and water sources.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6 * This file is part of BrewCloud
acb2d8098f19 Added inventory miscs and water sources.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7 *
acb2d8098f19 Added inventory miscs and water sources.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8 * This is free software; you can redistribute it and/or modify it
acb2d8098f19 Added inventory miscs and water sources.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9 * under the terms of the GNU General Public License as published by the
acb2d8098f19 Added inventory miscs and water sources.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10 * Free Software Foundation; either version 2, or (at your option) any
acb2d8098f19 Added inventory miscs and water sources.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11 * later version.
acb2d8098f19 Added inventory miscs and water sources.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12 *
acb2d8098f19 Added inventory miscs and water sources.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13 * BrewCloud is distributed in the hope that it will be useful, but
acb2d8098f19 Added inventory miscs and water sources.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
acb2d8098f19 Added inventory miscs and water sources.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
acb2d8098f19 Added inventory miscs and water sources.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
16 * General Public License for more details.
acb2d8098f19 Added inventory miscs and water sources.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
17 *
acb2d8098f19 Added inventory miscs and water sources.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
18 * You should have received a copy of the GNU General Public License
acb2d8098f19 Added inventory miscs and water sources.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
19 * along with ThermFerm; see the file COPYING. If not, write to the Free
acb2d8098f19 Added inventory miscs and water sources.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
20 * Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
acb2d8098f19 Added inventory miscs and water sources.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
21 *****************************************************************************/
acb2d8098f19 Added inventory miscs and water sources.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
22
acb2d8098f19 Added inventory miscs and water sources.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
23
acb2d8098f19 Added inventory miscs and water sources.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
24 function createDelElements() {
528
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
25 $('#eventWindow').jqxWindow({
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
26 theme: theme,
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
27 position: { x: 490, y: 210 },
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
28 width: 300,
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
29 height: 175,
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
30 resizable: false,
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
31 isModal: true,
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
32 modalOpacity: 0.4,
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
33 okButton: $('#delOk'),
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
34 cancelButton: $('#delCancel'),
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
35 initContent: function() {
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
36 $('#delOk').jqxButton({ template: 'danger', width: '65px', theme: theme });
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
37 $('#delCancel').jqxButton({ template: 'success', width: '65px', theme: theme });
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
38 $('#delCancel').focus();
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
39 }
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
40 });
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
41 $('#eventWindow').jqxWindow('hide');
21
acb2d8098f19 Added inventory miscs and water sources.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
42 }
acb2d8098f19 Added inventory miscs and water sources.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
43
acb2d8098f19 Added inventory miscs and water sources.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
44
528
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
45 $(document).ready(function() {
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
46
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
47 // tooltips
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
48 $('#name').jqxTooltip({ content: 'De unieke naam van dit brouwwater.' });
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
49 $('#notes').jqxTooltip({ content: 'Extra opmerkingen over dit water.' });
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
50 $('#unlimited_stock').jqxTooltip({ content: 'Onbeperkte voorraad zoals kraanwater en bronnen.' });
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
51 $('#calcium').jqxTooltip({ content: 'Calcium (Ca).' });
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
52 $('#bicarbonate').jqxTooltip({ content: 'Bicarbonaat (HCO3). Berekend meteen de Totale alkaliteit.' });
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
53 $('#sulfate').jqxTooltip({ content: 'Calcium Sulfaat (CaSO4).' });
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
54 $('#chloride').jqxTooltip({ content: 'Chloride (Cl).' });
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
55 $('#sodium').jqxTooltip({ content: 'Natrium, oftewel keukenzout (Na). In berekeningen ook vaak als Sodium.' });
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
56 $('#magnesium').jqxTooltip({ content: 'Magnesium (Mg).' });
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
57 $('#ph').jqxTooltip({ content: 'De zuurgraad (pH).' });
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
58 $('#total_alkalinity').jqxTooltip({ content: 'Totale alkaliniteit. Berekend meteen de Bicarbonaat.' });
662
4bb005694ce7 Version 0.3.32 Inventory water and profile water edit screens updated and added ion balance fields. Moved acid specs to global.js. In prod_edit and rec_edit changed the water calculations, eliminated the double percentage calculation. The pH values in the water tab have now 2 decimal digits. The mash pH field is only shown in auto calculate mode. The calculated acid addition results are now a bit better and compare with several famous spreadsheets.
Michiel Broek <mbroek@mbse.eu>
parents: 563
diff changeset
59 $('#balance').jqxTooltip({ content: 'De ionen balans van het water. Ideaal minder dan 0.1 verschil tussen kationen en anionen. Meer dan 0.5 is een fout in het waterraport.' });
528
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
60 $('#inventory').jqxTooltip({ content: 'Voorraad in liters.' });
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
61 $('#cost').jqxTooltip({ content: 'Kostprijs per liter. 5 cijfers achter de comma zodat het kraanwater er ook in kan.' });
205
08488ac3bbb1 Inventory waters: use POST instead of GET. Redesigned web editor page. Total Alkalinity and Bicarbonate update eachother with calculated values.
Michiel Broek <mbroek@mbse.eu>
parents: 99
diff changeset
62
528
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
63 var dataRecord = {},
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
64 url = 'includes/db_inventory_water.php',
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
65 // prepare the data
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
66 source = {
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
67 datatype: 'json',
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
68 cache: false,
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
69 datafields: [
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
70 { name: 'record', type: 'number' },
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
71 { name: 'name', type: 'string' },
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
72 { name: 'unlimited_stock', type: 'int' },
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
73 { name: 'calcium', type: 'float' },
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
74 { name: 'bicarbonate', type: 'float' },
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
75 { name: 'sulfate', type: 'float' },
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
76 { name: 'chloride', type: 'float' },
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
77 { name: 'sodium', type: 'float' },
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
78 { name: 'magnesium', type: 'float' },
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
79 { name: 'ph', type: 'float' },
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
80 { name: 'notes', type: 'string' },
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
81 { name: 'total_alkalinity', type: 'float' },
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
82 { name: 'inventory', type: 'float' },
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
83 { name: 'cost', type: 'float' }
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
84 ],
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
85 id: 'record',
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
86 url: url,
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
87 deleterow: function(rowid, commit) {
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
88 // synchronize with the server - send delete command
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
89 var data = 'delete=true&' + $.param({ record: rowid });
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
90 $.ajax({
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
91 dataType: 'json',
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
92 url: url,
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
93 cache: false,
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
94 data: data,
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
95 type: 'POST',
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
96 success: function(data, status, xhr) {
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
97 commit(true);
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
98 location.reload(true);
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
99 },
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
100 error: function(jqXHR, textStatus, errorThrown) {
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
101 commit(false);
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
102 }
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
103 });
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
104 },
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
105 addrow: function(rowid, rowdata, position, commit) {
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
106 var data = 'insert=true&' + $.param(rowdata);
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
107 $.ajax({
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
108 dataType: 'json',
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
109 url: url,
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
110 cache: false,
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
111 data: data,
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
112 type: 'POST',
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
113 success: function(data, status, xhr) {
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
114 commit(true);
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
115 location.reload(true);
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
116 },
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
117 error: function(jqXHR, textStatus, errorThrown) {
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
118 commit(false);
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
119 }
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
120 });
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
121 },
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
122 updaterow: function(rowid, rowdata, commit) {
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
123 var data = 'update=true&' + $.param(rowdata);
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
124 $.ajax({
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
125 dataType: 'json',
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
126 url: url,
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
127 cache: false,
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
128 data: data,
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
129 type: 'POST',
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
130 success: function(data, status, xhr) {
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
131 commit(true);
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
132 location.reload(true);
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
133 },
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
134 error: function(jqXHR, textStatus, errorThrown) {
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
135 commit(false);
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
136 }
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
137 });
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
138 }
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
139 },
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
140 dataAdapter = new $.jqx.dataAdapter(source),
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
141 editrow = -1;
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
142
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
143 // initialize the input fields.
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
144 $('#name').jqxInput({ theme: theme, width: 640, height: 23 });
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
145 $('#notes').jqxInput({ theme: theme, width: 640, height: 100 });
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
146 $('#unlimited_stock').jqxCheckBox({ theme: theme, width: 120, height: 23 });
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
147 $('#calcium').jqxNumberInput(Spin1dec);
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
148 $('#bicarbonate').jqxNumberInput(Spin1dec);
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
149 $('#sulfate').jqxNumberInput(Spin1dec);
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
150 $('#chloride').jqxNumberInput(Spin1dec);
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
151 $('#sodium').jqxNumberInput(Spin1dec);
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
152 $('#magnesium').jqxNumberInput(Spin1dec);
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
153 $('#ph').jqxNumberInput(Spin2pH);
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
154 $('#total_alkalinity').jqxNumberInput(Spin1dec);
662
4bb005694ce7 Version 0.3.32 Inventory water and profile water edit screens updated and added ion balance fields. Moved acid specs to global.js. In prod_edit and rec_edit changed the water calculations, eliminated the double percentage calculation. The pH values in the water tab have now 2 decimal digits. The mash pH field is only shown in auto calculate mode. The calculated acid addition results are now a bit better and compare with several famous spreadsheets.
Michiel Broek <mbroek@mbse.eu>
parents: 563
diff changeset
155 $('#balance').jqxNumberInput(Show2dec);
528
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
156 $('#inventory').jqxNumberInput(Spin1dec);
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
157 $('#cost').jqxNumberInput({inputMode: 'simple', theme: theme, width: 110, height: 23, min: 0, decimalDigits: 5, spinButtons: true });
488
77f1617b6994 Fixed inventory databases race conditions
Michiel Broek <mbroek@mbse.eu>
parents: 287
diff changeset
158
528
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
159 // initialize jqxGrid
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
160 $('#jqxgrid').jqxGrid({
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
161 width: 1280,
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
162 height: 630,
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
163 source: dataAdapter,
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
164 theme: theme,
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
165 showstatusbar: true,
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
166 renderstatusbar: function(statusbar) {
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
167 var addButton, container = $('<div style="overflow: hidden; position: relative; margin: 5px;"></div>');
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
168 addButton = $('<div style="float: right; margin-right: 15px;"><img style="position: relative; margin-top: 2px;" ' +
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
169 'src="images/add.png"/><span style="margin-left: 4px; position: relative; top: -3px;">Nieuw</span></div>');
563
acdd54144838 Added export inventory and profiles in beerxml format. Small fixes in beerxml recipe and product export.
Michiel Broek <mbroek@mbse.eu>
parents: 528
diff changeset
170 expButton = $('<div style="float: right; margin-right: 50px;"><img style="position: relative; margin-top: 2px;" ' +
acdd54144838 Added export inventory and profiles in beerxml format. Small fixes in beerxml recipe and product export.
Michiel Broek <mbroek@mbse.eu>
parents: 528
diff changeset
171 'src="images/database.png"/><span style="margin-left: 4px; position: relative; top: -3px;">Export</span></div>');
528
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
172 container.append(addButton);
563
acdd54144838 Added export inventory and profiles in beerxml format. Small fixes in beerxml recipe and product export.
Michiel Broek <mbroek@mbse.eu>
parents: 528
diff changeset
173 container.append(expButton);
528
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
174 statusbar.append(container);
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
175 addButton.jqxButton({ theme: theme, width: 90, height: 20 });
563
acdd54144838 Added export inventory and profiles in beerxml format. Small fixes in beerxml recipe and product export.
Michiel Broek <mbroek@mbse.eu>
parents: 528
diff changeset
176 expButton.jqxButton({ theme: theme, width: 90, height: 20 });
528
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
177 // add new row.
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
178 addButton.click(function(event) {
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
179 editrow = -1;
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
180 $('#popupWindow').jqxWindow({ position: { x: 110, y: 30 } });
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
181 $('#name').val('Nieuw brouwwater');
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
182 $('#unlimited_stock').val(0);
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
183 $('#calcium').val(0);
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
184 $('#bicarbonate').val(0);
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
185 $('#sulfate').val(0);
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
186 $('#chloride').val(0);
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
187 $('#sodium').val(0);
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
188 $('#magnesium').val(0);
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
189 $('#ph').val(7);
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
190 $('#notes').val('');
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
191 $('#total_alkalinity').val(0);
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
192 $('#inventory').val(0);
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
193 $('#cost').val(0);
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
194 $('#popupWindow').jqxWindow('open');
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
195 });
563
acdd54144838 Added export inventory and profiles in beerxml format. Small fixes in beerxml recipe and product export.
Michiel Broek <mbroek@mbse.eu>
parents: 528
diff changeset
196 expButton.click(function(event) {
acdd54144838 Added export inventory and profiles in beerxml format. Small fixes in beerxml recipe and product export.
Michiel Broek <mbroek@mbse.eu>
parents: 528
diff changeset
197 window.open('export_waters.php');
acdd54144838 Added export inventory and profiles in beerxml format. Small fixes in beerxml recipe and product export.
Michiel Broek <mbroek@mbse.eu>
parents: 528
diff changeset
198 });
528
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
199 },
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
200 filterable: false,
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
201 columns: [
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
202 { text: 'Water leverancier', datafield: 'name', width: 225 },
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
203 { text: 'Opmerkingen', datafield: 'notes' },
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
204 { text: 'Onbeperkt', datafield: 'unlimited_stock', columntype: 'checkbox', width: 80 },
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
205 { text: 'Voorraad', datafield: 'inventory', width: 100, align: 'right', cellsalign: 'right', cellsformat: 'f1',
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
206 cellsrenderer: function(index, datafield, value, defaultvalue, column, rowdata) {
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
207 var amount = '';
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
208 if (value > 0 && rowdata.unlimited_stock == 0)
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
209 amount = dataAdapter.formatNumber(value, 'f1') + ' L';
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
210 return '<span style="margin: 3px; margin-top: 6px; float: right;">' + amount + '</span>';
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
211 }
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
212 },
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
213 { text: '', datafield: 'Edit', width: 100, align: 'center', columntype: 'button',
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
214 cellsrenderer: function() {
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
215 return 'Wijzig';
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
216 }, buttonclick: function(row) {
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
217 // open the popup window when the user clicks a button.
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
218 editrow = row;
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
219 $('#popupWindow').jqxWindow({ position: { x: 110, y: 30 } });
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
220 // get the clicked row's data and initialize the input fields.
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
221 dataRecord = $('#jqxgrid').jqxGrid('getrowdata', editrow);
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
222 $('#name').val(dataRecord.name);
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
223 $('#unlimited_stock').val(dataRecord.unlimited_stock);
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
224 $('#calcium').val(dataRecord.calcium);
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
225 $('#bicarbonate').val(dataRecord.bicarbonate);
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
226 $('#sulfate').val(dataRecord.sulfate);
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
227 $('#chloride').val(dataRecord.chloride);
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
228 $('#sodium').val(dataRecord.sodium);
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
229 $('#magnesium').val(dataRecord.magnesium);
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
230 $('#ph').val(dataRecord.ph);
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
231 $('#notes').val(dataRecord.notes);
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
232 $('#total_alkalinity').val(dataRecord.total_alkalinity);
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
233 $('#inventory').val(dataRecord.inventory);
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
234 $('#cost').val(dataRecord.cost);
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
235 // show the popup window.
662
4bb005694ce7 Version 0.3.32 Inventory water and profile water edit screens updated and added ion balance fields. Moved acid specs to global.js. In prod_edit and rec_edit changed the water calculations, eliminated the double percentage calculation. The pH values in the water tab have now 2 decimal digits. The mash pH field is only shown in auto calculate mode. The calculated acid addition results are now a bit better and compare with several famous spreadsheets.
Michiel Broek <mbroek@mbse.eu>
parents: 563
diff changeset
236 calcBalance();
528
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
237 $('#popupWindow').jqxWindow('open');
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
238 }
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
239 }
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
240 ]
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
241 });
205
08488ac3bbb1 Inventory waters: use POST instead of GET. Redesigned web editor page. Total Alkalinity and Bicarbonate update eachother with calculated values.
Michiel Broek <mbroek@mbse.eu>
parents: 99
diff changeset
242
662
4bb005694ce7 Version 0.3.32 Inventory water and profile water edit screens updated and added ion balance fields. Moved acid specs to global.js. In prod_edit and rec_edit changed the water calculations, eliminated the double percentage calculation. The pH values in the water tab have now 2 decimal digits. The mash pH field is only shown in auto calculate mode. The calculated acid addition results are now a bit better and compare with several famous spreadsheets.
Michiel Broek <mbroek@mbse.eu>
parents: 563
diff changeset
243 function calcBalance() {
4bb005694ce7 Version 0.3.32 Inventory water and profile water edit screens updated and added ion balance fields. Moved acid specs to global.js. In prod_edit and rec_edit changed the water calculations, eliminated the double percentage calculation. The pH values in the water tab have now 2 decimal digits. The mash pH field is only shown in auto calculate mode. The calculated acid addition results are now a bit better and compare with several famous spreadsheets.
Michiel Broek <mbroek@mbse.eu>
parents: 563
diff changeset
244 var cations = (dataRecord.calcium / 20.039) + (dataRecord.magnesium / 12.1525) + (dataRecord.sodium / 22.989);
4bb005694ce7 Version 0.3.32 Inventory water and profile water edit screens updated and added ion balance fields. Moved acid specs to global.js. In prod_edit and rec_edit changed the water calculations, eliminated the double percentage calculation. The pH values in the water tab have now 2 decimal digits. The mash pH field is only shown in auto calculate mode. The calculated acid addition results are now a bit better and compare with several famous spreadsheets.
Michiel Broek <mbroek@mbse.eu>
parents: 563
diff changeset
245 var anions = (dataRecord.bicarbonate / 61.016) + (dataRecord.sulfate / 48.031) + (dataRecord.chloride / 35.4527);
4bb005694ce7 Version 0.3.32 Inventory water and profile water edit screens updated and added ion balance fields. Moved acid specs to global.js. In prod_edit and rec_edit changed the water calculations, eliminated the double percentage calculation. The pH values in the water tab have now 2 decimal digits. The mash pH field is only shown in auto calculate mode. The calculated acid addition results are now a bit better and compare with several famous spreadsheets.
Michiel Broek <mbroek@mbse.eu>
parents: 563
diff changeset
246 var balance = Round(cations - anions, 2);
4bb005694ce7 Version 0.3.32 Inventory water and profile water edit screens updated and added ion balance fields. Moved acid specs to global.js. In prod_edit and rec_edit changed the water calculations, eliminated the double percentage calculation. The pH values in the water tab have now 2 decimal digits. The mash pH field is only shown in auto calculate mode. The calculated acid addition results are now a bit better and compare with several famous spreadsheets.
Michiel Broek <mbroek@mbse.eu>
parents: 563
diff changeset
247 $('#balance').val(balance);
4bb005694ce7 Version 0.3.32 Inventory water and profile water edit screens updated and added ion balance fields. Moved acid specs to global.js. In prod_edit and rec_edit changed the water calculations, eliminated the double percentage calculation. The pH values in the water tab have now 2 decimal digits. The mash pH field is only shown in auto calculate mode. The calculated acid addition results are now a bit better and compare with several famous spreadsheets.
Michiel Broek <mbroek@mbse.eu>
parents: 563
diff changeset
248 if (balance <= 0.1 && balance >= -0.1)
4bb005694ce7 Version 0.3.32 Inventory water and profile water edit screens updated and added ion balance fields. Moved acid specs to global.js. In prod_edit and rec_edit changed the water calculations, eliminated the double percentage calculation. The pH values in the water tab have now 2 decimal digits. The mash pH field is only shown in auto calculate mode. The calculated acid addition results are now a bit better and compare with several famous spreadsheets.
Michiel Broek <mbroek@mbse.eu>
parents: 563
diff changeset
249 $('#wr_balance').html("<img src='images/dialog-ok-apply.png'>");
4bb005694ce7 Version 0.3.32 Inventory water and profile water edit screens updated and added ion balance fields. Moved acid specs to global.js. In prod_edit and rec_edit changed the water calculations, eliminated the double percentage calculation. The pH values in the water tab have now 2 decimal digits. The mash pH field is only shown in auto calculate mode. The calculated acid addition results are now a bit better and compare with several famous spreadsheets.
Michiel Broek <mbroek@mbse.eu>
parents: 563
diff changeset
250 else if (balance <= 0.5 && balance >= -0.5)
4bb005694ce7 Version 0.3.32 Inventory water and profile water edit screens updated and added ion balance fields. Moved acid specs to global.js. In prod_edit and rec_edit changed the water calculations, eliminated the double percentage calculation. The pH values in the water tab have now 2 decimal digits. The mash pH field is only shown in auto calculate mode. The calculated acid addition results are now a bit better and compare with several famous spreadsheets.
Michiel Broek <mbroek@mbse.eu>
parents: 563
diff changeset
251 $('#wr_balance').html("<img src='images/dialog-ok.png'>");
4bb005694ce7 Version 0.3.32 Inventory water and profile water edit screens updated and added ion balance fields. Moved acid specs to global.js. In prod_edit and rec_edit changed the water calculations, eliminated the double percentage calculation. The pH values in the water tab have now 2 decimal digits. The mash pH field is only shown in auto calculate mode. The calculated acid addition results are now a bit better and compare with several famous spreadsheets.
Michiel Broek <mbroek@mbse.eu>
parents: 563
diff changeset
252 else
4bb005694ce7 Version 0.3.32 Inventory water and profile water edit screens updated and added ion balance fields. Moved acid specs to global.js. In prod_edit and rec_edit changed the water calculations, eliminated the double percentage calculation. The pH values in the water tab have now 2 decimal digits. The mash pH field is only shown in auto calculate mode. The calculated acid addition results are now a bit better and compare with several famous spreadsheets.
Michiel Broek <mbroek@mbse.eu>
parents: 563
diff changeset
253 $('#wr_balance').html("<img src='images/dialog-error.png'>");
4bb005694ce7 Version 0.3.32 Inventory water and profile water edit screens updated and added ion balance fields. Moved acid specs to global.js. In prod_edit and rec_edit changed the water calculations, eliminated the double percentage calculation. The pH values in the water tab have now 2 decimal digits. The mash pH field is only shown in auto calculate mode. The calculated acid addition results are now a bit better and compare with several famous spreadsheets.
Michiel Broek <mbroek@mbse.eu>
parents: 563
diff changeset
254 }
4bb005694ce7 Version 0.3.32 Inventory water and profile water edit screens updated and added ion balance fields. Moved acid specs to global.js. In prod_edit and rec_edit changed the water calculations, eliminated the double percentage calculation. The pH values in the water tab have now 2 decimal digits. The mash pH field is only shown in auto calculate mode. The calculated acid addition results are now a bit better and compare with several famous spreadsheets.
Michiel Broek <mbroek@mbse.eu>
parents: 563
diff changeset
255
4bb005694ce7 Version 0.3.32 Inventory water and profile water edit screens updated and added ion balance fields. Moved acid specs to global.js. In prod_edit and rec_edit changed the water calculations, eliminated the double percentage calculation. The pH values in the water tab have now 2 decimal digits. The mash pH field is only shown in auto calculate mode. The calculated acid addition results are now a bit better and compare with several famous spreadsheets.
Michiel Broek <mbroek@mbse.eu>
parents: 563
diff changeset
256 $('#calcium').on('change', function(event) {
4bb005694ce7 Version 0.3.32 Inventory water and profile water edit screens updated and added ion balance fields. Moved acid specs to global.js. In prod_edit and rec_edit changed the water calculations, eliminated the double percentage calculation. The pH values in the water tab have now 2 decimal digits. The mash pH field is only shown in auto calculate mode. The calculated acid addition results are now a bit better and compare with several famous spreadsheets.
Michiel Broek <mbroek@mbse.eu>
parents: 563
diff changeset
257 dataRecord.calcium = parseFloat(event.args.value);
4bb005694ce7 Version 0.3.32 Inventory water and profile water edit screens updated and added ion balance fields. Moved acid specs to global.js. In prod_edit and rec_edit changed the water calculations, eliminated the double percentage calculation. The pH values in the water tab have now 2 decimal digits. The mash pH field is only shown in auto calculate mode. The calculated acid addition results are now a bit better and compare with several famous spreadsheets.
Michiel Broek <mbroek@mbse.eu>
parents: 563
diff changeset
258 calcBalance();
4bb005694ce7 Version 0.3.32 Inventory water and profile water edit screens updated and added ion balance fields. Moved acid specs to global.js. In prod_edit and rec_edit changed the water calculations, eliminated the double percentage calculation. The pH values in the water tab have now 2 decimal digits. The mash pH field is only shown in auto calculate mode. The calculated acid addition results are now a bit better and compare with several famous spreadsheets.
Michiel Broek <mbroek@mbse.eu>
parents: 563
diff changeset
259 });
4bb005694ce7 Version 0.3.32 Inventory water and profile water edit screens updated and added ion balance fields. Moved acid specs to global.js. In prod_edit and rec_edit changed the water calculations, eliminated the double percentage calculation. The pH values in the water tab have now 2 decimal digits. The mash pH field is only shown in auto calculate mode. The calculated acid addition results are now a bit better and compare with several famous spreadsheets.
Michiel Broek <mbroek@mbse.eu>
parents: 563
diff changeset
260 $('#magnesium').on('change', function(event) {
4bb005694ce7 Version 0.3.32 Inventory water and profile water edit screens updated and added ion balance fields. Moved acid specs to global.js. In prod_edit and rec_edit changed the water calculations, eliminated the double percentage calculation. The pH values in the water tab have now 2 decimal digits. The mash pH field is only shown in auto calculate mode. The calculated acid addition results are now a bit better and compare with several famous spreadsheets.
Michiel Broek <mbroek@mbse.eu>
parents: 563
diff changeset
261 dataRecord.magnesium = parseFloat(event.args.value);
4bb005694ce7 Version 0.3.32 Inventory water and profile water edit screens updated and added ion balance fields. Moved acid specs to global.js. In prod_edit and rec_edit changed the water calculations, eliminated the double percentage calculation. The pH values in the water tab have now 2 decimal digits. The mash pH field is only shown in auto calculate mode. The calculated acid addition results are now a bit better and compare with several famous spreadsheets.
Michiel Broek <mbroek@mbse.eu>
parents: 563
diff changeset
262 calcBalance();
4bb005694ce7 Version 0.3.32 Inventory water and profile water edit screens updated and added ion balance fields. Moved acid specs to global.js. In prod_edit and rec_edit changed the water calculations, eliminated the double percentage calculation. The pH values in the water tab have now 2 decimal digits. The mash pH field is only shown in auto calculate mode. The calculated acid addition results are now a bit better and compare with several famous spreadsheets.
Michiel Broek <mbroek@mbse.eu>
parents: 563
diff changeset
263 });
4bb005694ce7 Version 0.3.32 Inventory water and profile water edit screens updated and added ion balance fields. Moved acid specs to global.js. In prod_edit and rec_edit changed the water calculations, eliminated the double percentage calculation. The pH values in the water tab have now 2 decimal digits. The mash pH field is only shown in auto calculate mode. The calculated acid addition results are now a bit better and compare with several famous spreadsheets.
Michiel Broek <mbroek@mbse.eu>
parents: 563
diff changeset
264 $('#sodium').on('change', function(event) {
4bb005694ce7 Version 0.3.32 Inventory water and profile water edit screens updated and added ion balance fields. Moved acid specs to global.js. In prod_edit and rec_edit changed the water calculations, eliminated the double percentage calculation. The pH values in the water tab have now 2 decimal digits. The mash pH field is only shown in auto calculate mode. The calculated acid addition results are now a bit better and compare with several famous spreadsheets.
Michiel Broek <mbroek@mbse.eu>
parents: 563
diff changeset
265 dataRecord.sodium = parseFloat(event.args.value);
4bb005694ce7 Version 0.3.32 Inventory water and profile water edit screens updated and added ion balance fields. Moved acid specs to global.js. In prod_edit and rec_edit changed the water calculations, eliminated the double percentage calculation. The pH values in the water tab have now 2 decimal digits. The mash pH field is only shown in auto calculate mode. The calculated acid addition results are now a bit better and compare with several famous spreadsheets.
Michiel Broek <mbroek@mbse.eu>
parents: 563
diff changeset
266 calcBalance();
4bb005694ce7 Version 0.3.32 Inventory water and profile water edit screens updated and added ion balance fields. Moved acid specs to global.js. In prod_edit and rec_edit changed the water calculations, eliminated the double percentage calculation. The pH values in the water tab have now 2 decimal digits. The mash pH field is only shown in auto calculate mode. The calculated acid addition results are now a bit better and compare with several famous spreadsheets.
Michiel Broek <mbroek@mbse.eu>
parents: 563
diff changeset
267 });
528
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
268 $('#total_alkalinity').on('change', function(event) {
662
4bb005694ce7 Version 0.3.32 Inventory water and profile water edit screens updated and added ion balance fields. Moved acid specs to global.js. In prod_edit and rec_edit changed the water calculations, eliminated the double percentage calculation. The pH values in the water tab have now 2 decimal digits. The mash pH field is only shown in auto calculate mode. The calculated acid addition results are now a bit better and compare with several famous spreadsheets.
Michiel Broek <mbroek@mbse.eu>
parents: 563
diff changeset
269 dataRecord.total_alkalinity = parseFloat(event.args.value);
528
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
270 dataRecord.bicarbonate = parseFloat(event.args.value) * 1.22;
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
271 $('#bicarbonate').val(dataRecord.bicarbonate);
662
4bb005694ce7 Version 0.3.32 Inventory water and profile water edit screens updated and added ion balance fields. Moved acid specs to global.js. In prod_edit and rec_edit changed the water calculations, eliminated the double percentage calculation. The pH values in the water tab have now 2 decimal digits. The mash pH field is only shown in auto calculate mode. The calculated acid addition results are now a bit better and compare with several famous spreadsheets.
Michiel Broek <mbroek@mbse.eu>
parents: 563
diff changeset
272 calcBalance();
528
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
273 });
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
274 $('#bicarbonate').on('change', function(event) {
662
4bb005694ce7 Version 0.3.32 Inventory water and profile water edit screens updated and added ion balance fields. Moved acid specs to global.js. In prod_edit and rec_edit changed the water calculations, eliminated the double percentage calculation. The pH values in the water tab have now 2 decimal digits. The mash pH field is only shown in auto calculate mode. The calculated acid addition results are now a bit better and compare with several famous spreadsheets.
Michiel Broek <mbroek@mbse.eu>
parents: 563
diff changeset
275 dataRecord.bicarbonate = parseFloat(event.args.value);
528
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
276 dataRecord.total_alkalinity = parseFloat(event.args.value) * 50 / 61;
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
277 $('#total_alkalinity').val(dataRecord.total_alkalinity);
662
4bb005694ce7 Version 0.3.32 Inventory water and profile water edit screens updated and added ion balance fields. Moved acid specs to global.js. In prod_edit and rec_edit changed the water calculations, eliminated the double percentage calculation. The pH values in the water tab have now 2 decimal digits. The mash pH field is only shown in auto calculate mode. The calculated acid addition results are now a bit better and compare with several famous spreadsheets.
Michiel Broek <mbroek@mbse.eu>
parents: 563
diff changeset
278 calcBalance();
4bb005694ce7 Version 0.3.32 Inventory water and profile water edit screens updated and added ion balance fields. Moved acid specs to global.js. In prod_edit and rec_edit changed the water calculations, eliminated the double percentage calculation. The pH values in the water tab have now 2 decimal digits. The mash pH field is only shown in auto calculate mode. The calculated acid addition results are now a bit better and compare with several famous spreadsheets.
Michiel Broek <mbroek@mbse.eu>
parents: 563
diff changeset
279 });
4bb005694ce7 Version 0.3.32 Inventory water and profile water edit screens updated and added ion balance fields. Moved acid specs to global.js. In prod_edit and rec_edit changed the water calculations, eliminated the double percentage calculation. The pH values in the water tab have now 2 decimal digits. The mash pH field is only shown in auto calculate mode. The calculated acid addition results are now a bit better and compare with several famous spreadsheets.
Michiel Broek <mbroek@mbse.eu>
parents: 563
diff changeset
280 $('#sulfate').on('change', function(event) {
4bb005694ce7 Version 0.3.32 Inventory water and profile water edit screens updated and added ion balance fields. Moved acid specs to global.js. In prod_edit and rec_edit changed the water calculations, eliminated the double percentage calculation. The pH values in the water tab have now 2 decimal digits. The mash pH field is only shown in auto calculate mode. The calculated acid addition results are now a bit better and compare with several famous spreadsheets.
Michiel Broek <mbroek@mbse.eu>
parents: 563
diff changeset
281 dataRecord.sulfate = parseFloat(event.args.value);
4bb005694ce7 Version 0.3.32 Inventory water and profile water edit screens updated and added ion balance fields. Moved acid specs to global.js. In prod_edit and rec_edit changed the water calculations, eliminated the double percentage calculation. The pH values in the water tab have now 2 decimal digits. The mash pH field is only shown in auto calculate mode. The calculated acid addition results are now a bit better and compare with several famous spreadsheets.
Michiel Broek <mbroek@mbse.eu>
parents: 563
diff changeset
282 calcBalance();
4bb005694ce7 Version 0.3.32 Inventory water and profile water edit screens updated and added ion balance fields. Moved acid specs to global.js. In prod_edit and rec_edit changed the water calculations, eliminated the double percentage calculation. The pH values in the water tab have now 2 decimal digits. The mash pH field is only shown in auto calculate mode. The calculated acid addition results are now a bit better and compare with several famous spreadsheets.
Michiel Broek <mbroek@mbse.eu>
parents: 563
diff changeset
283 });
4bb005694ce7 Version 0.3.32 Inventory water and profile water edit screens updated and added ion balance fields. Moved acid specs to global.js. In prod_edit and rec_edit changed the water calculations, eliminated the double percentage calculation. The pH values in the water tab have now 2 decimal digits. The mash pH field is only shown in auto calculate mode. The calculated acid addition results are now a bit better and compare with several famous spreadsheets.
Michiel Broek <mbroek@mbse.eu>
parents: 563
diff changeset
284 $('#chloride').on('change', function(event) {
4bb005694ce7 Version 0.3.32 Inventory water and profile water edit screens updated and added ion balance fields. Moved acid specs to global.js. In prod_edit and rec_edit changed the water calculations, eliminated the double percentage calculation. The pH values in the water tab have now 2 decimal digits. The mash pH field is only shown in auto calculate mode. The calculated acid addition results are now a bit better and compare with several famous spreadsheets.
Michiel Broek <mbroek@mbse.eu>
parents: 563
diff changeset
285 dataRecord.chloride = parseFloat(event.args.value);
4bb005694ce7 Version 0.3.32 Inventory water and profile water edit screens updated and added ion balance fields. Moved acid specs to global.js. In prod_edit and rec_edit changed the water calculations, eliminated the double percentage calculation. The pH values in the water tab have now 2 decimal digits. The mash pH field is only shown in auto calculate mode. The calculated acid addition results are now a bit better and compare with several famous spreadsheets.
Michiel Broek <mbroek@mbse.eu>
parents: 563
diff changeset
286 calcBalance();
528
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
287 });
205
08488ac3bbb1 Inventory waters: use POST instead of GET. Redesigned web editor page. Total Alkalinity and Bicarbonate update eachother with calculated values.
Michiel Broek <mbroek@mbse.eu>
parents: 99
diff changeset
288
528
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
289 // initialize the popup window and buttons.
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
290 $('#popupWindow').jqxWindow({
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
291 width: 1050,
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
292 height: 550,
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
293 resizable: false,
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
294 theme: theme,
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
295 isModal: true,
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
296 autoOpen: false,
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
297 cancelButton: $('#Cancel'),
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
298 modalOpacity: 0.40
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
299 });
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
300 $('#popupWindow').on('open', function() {
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
301 $('#name').jqxInput('selectAll');
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
302 });
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
303 $('#Delete').jqxButton({ template: 'danger', width: '90px', theme: theme });
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
304 $('#Delete').click(function() {
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
305 if (editrow >= 0) {
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
306 // Open a popup to confirm this action.
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
307 $('#eventWindow').jqxWindow('open');
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
308 $('#delOk').click(function() {
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
309 var rowID = $('#jqxgrid').jqxGrid('getrowid', editrow);
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
310 $('#jqxgrid').jqxGrid('deleterow', rowID);
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
311 });
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
312 }
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
313 $('#popupWindow').jqxWindow('hide');
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
314 });
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
315 $('#Cancel').jqxButton({ template: 'primary', width: '90px', theme: theme });
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
316 $('#Save').jqxButton({ template: 'success', width: '90px', theme: theme });
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
317 // update the edited row when the user clicks the 'Save' button.
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
318 $('#Save').click(function() {
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
319 var row, rowID = -1;
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
320 if (editrow >= 0) {
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
321 rowID = $('#jqxgrid').jqxGrid('getrowid', editrow);
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
322 }
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
323 row = {
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
324 record: rowID,
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
325 name: $('#name').val(),
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
326 unlimited_stock: $('#unlimited_stock').val(),
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
327 calcium: parseFloat($('#calcium').jqxNumberInput('decimal')),
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
328 bicarbonate: parseFloat($('#bicarbonate').jqxNumberInput('decimal')),
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
329 sulfate: parseFloat($('#sulfate').jqxNumberInput('decimal')),
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
330 chloride: parseFloat($('#chloride').jqxNumberInput('decimal')),
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
331 sodium: parseFloat($('#sodium').jqxNumberInput('decimal')),
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
332 magnesium: parseFloat($('#magnesium').jqxNumberInput('decimal')),
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
333 ph: parseFloat($('#ph').jqxNumberInput('decimal')),
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
334 notes: $('#notes').val(),
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
335 total_alkalinity: parseFloat($('#total_alkalinity').jqxNumberInput('decimal')),
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
336 inventory: parseFloat($('#inventory').jqxNumberInput('decimal')),
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
337 cost: parseFloat($('#cost').jqxNumberInput('decimal'))
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
338 };
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
339 if (editrow >= 0) {
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
340 $('#jqxgrid').jqxGrid('updaterow', rowID, row);
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
341 } else {
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
342 $('#jqxgrid').jqxGrid('addrow', null, row);
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
343 }
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
344 $('#popupWindow').jqxWindow('hide');
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
345 });
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
346 createDelElements();
21
acb2d8098f19 Added inventory miscs and water sources.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
347 });
acb2d8098f19 Added inventory miscs and water sources.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
348

mercurial