www/js/inv_waters.js

Sun, 23 May 2021 16:41:35 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Sun, 23 May 2021 16:41:35 +0200
changeset 752
f68e3bbc1ada
parent 702
f0896a6f9b64
child 767
08c0343b622b
permissions
-rw-r--r--

Fermentables, hops, miscs and yeast now have tests against the added moment with the brewing stage. Added to inventory edit rows, delete rows, and pick choices for the moment to add or edit. Some more popups to explain certain blocks.

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 *
701
3ce3df681be0 Changed inventory and profile databases filtering.
Michiel Broek <mbroek@mbse.eu>
parents: 662
diff changeset
6 * This file is part of Brewery Management System
21
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 },
701
3ce3df681be0 Changed inventory and profile databases filtering.
Michiel Broek <mbroek@mbse.eu>
parents: 662
diff changeset
100 error: function(jqXHR, textStatus, errorThrown) { commit(false); }
528
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
101 });
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 addrow: function(rowid, rowdata, position, commit) {
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
104 var data = 'insert=true&' + $.param(rowdata);
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
105 $.ajax({
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
106 dataType: 'json',
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
107 url: url,
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
108 cache: false,
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
109 data: data,
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
110 type: 'POST',
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
111 success: function(data, status, xhr) {
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
112 commit(true);
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
113 location.reload(true);
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
114 },
701
3ce3df681be0 Changed inventory and profile databases filtering.
Michiel Broek <mbroek@mbse.eu>
parents: 662
diff changeset
115 error: function(jqXHR, textStatus, errorThrown) { commit(false); }
528
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 },
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
118 updaterow: function(rowid, rowdata, commit) {
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
119 var data = 'update=true&' + $.param(rowdata);
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
120 $.ajax({
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
121 dataType: 'json',
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
122 url: url,
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
123 cache: false,
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
124 data: data,
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
125 type: 'POST',
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
126 success: function(data, status, xhr) {
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
127 commit(true);
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
128 location.reload(true);
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
129 },
701
3ce3df681be0 Changed inventory and profile databases filtering.
Michiel Broek <mbroek@mbse.eu>
parents: 662
diff changeset
130 error: function(jqXHR, textStatus, errorThrown) { commit(false); }
528
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
131 });
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
132 }
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 dataAdapter = new $.jqx.dataAdapter(source),
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
135 editrow = -1;
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 // initialize the input fields.
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
138 $('#name').jqxInput({ theme: theme, width: 640, height: 23 });
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
139 $('#notes').jqxInput({ theme: theme, width: 640, height: 100 });
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
140 $('#unlimited_stock').jqxCheckBox({ theme: theme, width: 120, height: 23 });
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
141 $('#calcium').jqxNumberInput(Spin1dec);
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
142 $('#bicarbonate').jqxNumberInput(Spin1dec);
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
143 $('#sulfate').jqxNumberInput(Spin1dec);
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
144 $('#chloride').jqxNumberInput(Spin1dec);
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
145 $('#sodium').jqxNumberInput(Spin1dec);
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
146 $('#magnesium').jqxNumberInput(Spin1dec);
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
147 $('#ph').jqxNumberInput(Spin2pH);
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
148 $('#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
149 $('#balance').jqxNumberInput(Show2dec);
528
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
150 $('#inventory').jqxNumberInput(Spin1dec);
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
151 $('#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
152
528
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
153 // initialize jqxGrid
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
154 $('#jqxgrid').jqxGrid({
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
155 width: 1280,
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
156 height: 630,
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
157 source: dataAdapter,
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
158 theme: theme,
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
159 showstatusbar: true,
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
160 renderstatusbar: function(statusbar) {
702
f0896a6f9b64 Add total count in the statusbar for inventory and profile databases.
Michiel Broek <mbroek@mbse.eu>
parents: 701
diff changeset
161 var rowCount = $("#jqxgrid").jqxGrid('getrows').length;
f0896a6f9b64 Add total count in the statusbar for inventory and profile databases.
Michiel Broek <mbroek@mbse.eu>
parents: 701
diff changeset
162 statusbar.append('<div style="float: left; margin: 8px; color: orange !important;">Aantal items: ' + rowCount + '</div>');
528
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
163 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
164 addButton = $('<div style="float: right; margin-right: 15px;"><img style="position: relative; margin-top: 2px;" ' +
701
3ce3df681be0 Changed inventory and profile databases filtering.
Michiel Broek <mbroek@mbse.eu>
parents: 662
diff changeset
165 'src="images/add.png"/><span style="margin-left: 4px; position: relative; top: -4px;">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
166 expButton = $('<div style="float: right; margin-right: 50px;"><img style="position: relative; margin-top: 2px;" ' +
701
3ce3df681be0 Changed inventory and profile databases filtering.
Michiel Broek <mbroek@mbse.eu>
parents: 662
diff changeset
167 'src="images/database.png"/><span style="margin-left: 4px; position: relative; top: -10px;">Export</span></div>');
528
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
168 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
169 container.append(expButton);
528
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
170 statusbar.append(container);
701
3ce3df681be0 Changed inventory and profile databases filtering.
Michiel Broek <mbroek@mbse.eu>
parents: 662
diff changeset
171 addButton.jqxButton({ theme: theme, width: 90, height: 17 });
3ce3df681be0 Changed inventory and profile databases filtering.
Michiel Broek <mbroek@mbse.eu>
parents: 662
diff changeset
172 expButton.jqxButton({ theme: theme, width: 90, height: 17 });
528
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
173 // add new row.
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
174 addButton.click(function(event) {
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
175 editrow = -1;
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
176 $('#popupWindow').jqxWindow({ position: { x: 110, y: 30 } });
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
177 $('#name').val('Nieuw brouwwater');
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
178 $('#unlimited_stock').val(0);
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
179 $('#calcium').val(0);
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
180 $('#bicarbonate').val(0);
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
181 $('#sulfate').val(0);
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
182 $('#chloride').val(0);
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
183 $('#sodium').val(0);
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
184 $('#magnesium').val(0);
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
185 $('#ph').val(7);
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
186 $('#notes').val('');
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
187 $('#total_alkalinity').val(0);
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
188 $('#inventory').val(0);
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
189 $('#cost').val(0);
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
190 $('#popupWindow').jqxWindow('open');
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
191 });
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
192 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
193 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
194 });
528
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
195 },
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
196 filterable: false,
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
197 columns: [
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
198 { text: 'Water leverancier', datafield: 'name', width: 225 },
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
199 { text: 'Opmerkingen', datafield: 'notes' },
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
200 { text: 'Onbeperkt', datafield: 'unlimited_stock', columntype: 'checkbox', width: 80 },
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
201 { 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
202 cellsrenderer: function(index, datafield, value, defaultvalue, column, rowdata) {
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
203 var amount = '';
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
204 if (value > 0 && rowdata.unlimited_stock == 0)
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
205 amount = dataAdapter.formatNumber(value, 'f1') + ' L';
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
206 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
207 }
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
208 },
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
209 { text: '', datafield: 'Edit', width: 100, align: 'center', columntype: 'button',
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
210 cellsrenderer: function() {
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
211 return 'Wijzig';
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
212 }, buttonclick: function(row) {
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
213 // 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
214 editrow = row;
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
215 $('#popupWindow').jqxWindow({ position: { x: 110, y: 30 } });
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
216 // 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
217 dataRecord = $('#jqxgrid').jqxGrid('getrowdata', editrow);
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
218 $('#name').val(dataRecord.name);
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
219 $('#unlimited_stock').val(dataRecord.unlimited_stock);
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
220 $('#calcium').val(dataRecord.calcium);
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
221 $('#bicarbonate').val(dataRecord.bicarbonate);
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
222 $('#sulfate').val(dataRecord.sulfate);
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
223 $('#chloride').val(dataRecord.chloride);
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
224 $('#sodium').val(dataRecord.sodium);
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
225 $('#magnesium').val(dataRecord.magnesium);
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
226 $('#ph').val(dataRecord.ph);
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
227 $('#notes').val(dataRecord.notes);
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
228 $('#total_alkalinity').val(dataRecord.total_alkalinity);
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
229 $('#inventory').val(dataRecord.inventory);
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
230 $('#cost').val(dataRecord.cost);
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
231 // 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
232 calcBalance();
528
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
233 $('#popupWindow').jqxWindow('open');
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
234 }
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
235 }
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
236 ]
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
237 });
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
238
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
239 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
240 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
241 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
242 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
243 $('#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
244 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
245 $('#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
246 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
247 $('#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
248 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
249 $('#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
250 }
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
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 $('#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
253 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
254 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
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 $('#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
257 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
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 $('#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
261 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
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 });
528
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
264 $('#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
265 dataRecord.total_alkalinity = parseFloat(event.args.value);
528
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
266 dataRecord.bicarbonate = parseFloat(event.args.value) * 1.22;
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
267 $('#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
268 calcBalance();
528
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
269 });
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
270 $('#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
271 dataRecord.bicarbonate = parseFloat(event.args.value);
528
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
272 dataRecord.total_alkalinity = parseFloat(event.args.value) * 50 / 61;
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
273 $('#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
274 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
275 });
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
276 $('#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
277 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
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 $('#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
281 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
282 calcBalance();
528
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
283 });
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
284
528
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
285 // initialize the popup window and buttons.
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
286 $('#popupWindow').jqxWindow({
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
287 width: 1050,
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
288 height: 550,
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
289 resizable: false,
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
290 theme: theme,
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
291 isModal: true,
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
292 autoOpen: false,
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
293 cancelButton: $('#Cancel'),
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
294 modalOpacity: 0.40
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
295 });
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
296 $('#popupWindow').on('open', function() {
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
297 $('#name').jqxInput('selectAll');
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
298 });
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
299 $('#Delete').jqxButton({ template: 'danger', width: '90px', theme: theme });
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
300 $('#Delete').click(function() {
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
301 if (editrow >= 0) {
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
302 // Open a popup to confirm this action.
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
303 $('#eventWindow').jqxWindow('open');
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
304 $('#delOk').click(function() {
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
305 var rowID = $('#jqxgrid').jqxGrid('getrowid', editrow);
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
306 $('#jqxgrid').jqxGrid('deleterow', rowID);
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
307 });
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
308 }
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
309 $('#popupWindow').jqxWindow('hide');
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
310 });
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
311 $('#Cancel').jqxButton({ template: 'primary', width: '90px', theme: theme });
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
312 $('#Save').jqxButton({ template: 'success', width: '90px', theme: theme });
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
313 // 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
314 $('#Save').click(function() {
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
315 var row, rowID = -1;
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
316 if (editrow >= 0) {
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
317 rowID = $('#jqxgrid').jqxGrid('getrowid', editrow);
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
318 }
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
319 row = {
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
320 record: rowID,
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
321 name: $('#name').val(),
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
322 unlimited_stock: $('#unlimited_stock').val(),
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
323 calcium: parseFloat($('#calcium').jqxNumberInput('decimal')),
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
324 bicarbonate: parseFloat($('#bicarbonate').jqxNumberInput('decimal')),
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
325 sulfate: parseFloat($('#sulfate').jqxNumberInput('decimal')),
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
326 chloride: parseFloat($('#chloride').jqxNumberInput('decimal')),
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
327 sodium: parseFloat($('#sodium').jqxNumberInput('decimal')),
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
328 magnesium: parseFloat($('#magnesium').jqxNumberInput('decimal')),
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
329 ph: parseFloat($('#ph').jqxNumberInput('decimal')),
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
330 notes: $('#notes').val(),
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
331 total_alkalinity: parseFloat($('#total_alkalinity').jqxNumberInput('decimal')),
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
332 inventory: parseFloat($('#inventory').jqxNumberInput('decimal')),
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
333 cost: parseFloat($('#cost').jqxNumberInput('decimal'))
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
334 };
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
335 if (editrow >= 0) {
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
336 $('#jqxgrid').jqxGrid('updaterow', rowID, row);
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
337 } else {
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
338 $('#jqxgrid').jqxGrid('addrow', null, row);
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
339 }
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
340 $('#popupWindow').jqxWindow('hide');
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
341 });
202272a28052 Code cleanup and manual compress
Michiel Broek <mbroek@mbse.eu>
parents: 488
diff changeset
342 createDelElements();
21
acb2d8098f19 Added inventory miscs and water sources.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
343 });
acb2d8098f19 Added inventory miscs and water sources.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
344

mercurial