www/js/inv_equipments.js

branch
stable
changeset 665
4d01937ae7af
parent 645
3b1510050c9b
child 691
9c21125f584e
equal deleted inserted replaced
521:9d1aa6f3a4da 665:4d01937ae7af
1 /***************************************************************************** 1 /*****************************************************************************
2 * Copyright (C) 2014-2019 2 * Copyright (C) 2014-2020
3 * 3 *
4 * Michiel Broek <mbroek at mbse dot eu> 4 * Michiel Broek <mbroek at mbse dot eu>
5 * 5 *
6 * This file is part of BrewCloud 6 * This file is part of BrewCloud
7 * 7 *
8 * This is free software; you can redistribute it and/or modify it 8 * This is free software; you can redistribute it and/or modify it
12 * 12 *
13 * BrewCloud is distributed in the hope that it will be useful, but 13 * BrewCloud is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of 14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details. 16 * General Public License for more details.
17 * 17 *
18 * You should have received a copy of the GNU General Public License 18 * You should have received a copy of the GNU General Public License
19 * along with ThermFerm; see the file COPYING. If not, write to the Free 19 * along with ThermFerm; see the file COPYING. If not, write to the Free
20 * Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. 20 * Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
21 *****************************************************************************/ 21 *****************************************************************************/
22 22
23 23
24 function createDelElements() { 24 function createDelElements() {
25 $('#eventWindow').jqxWindow({ 25 $('#eventWindow').jqxWindow({
26 theme: theme, 26 theme: theme,
27 position: { x: 490, y: 210 }, 27 position: { x: 490, y: 210 },
28 width: 300, 28 width: 300,
29 height: 175, 29 height: 175,
30 resizable: false, 30 resizable: false,
31 isModal: true, 31 isModal: true,
32 modalOpacity: 0.4, 32 modalOpacity: 0.4,
33 okButton: $('#delOk'), 33 okButton: $('#delOk'),
34 cancelButton: $('#delCancel'), 34 cancelButton: $('#delCancel'),
35 initContent: function () { 35 initContent: function() {
36 $('#delOk').jqxButton({ template: "danger", width: '65px', theme: theme }); 36 $('#delOk').jqxButton({ template: 'danger', width: '65px', theme: theme });
37 $('#delCancel').jqxButton({ template: "success", width: '65px', theme: theme }); 37 $('#delCancel').jqxButton({ template: 'success', width: '65px', theme: theme });
38 $('#delCancel').focus(); 38 $('#delCancel').focus();
39 } 39 }
40 }); 40 });
41 $('#eventWindow').jqxWindow('hide'); 41 $('#eventWindow').jqxWindow('hide');
42 } 42 }
43 43
44 44
45 $(document).ready(function () { 45 $(document).ready(function() {
46 46
47 function calcBatchVolume() { 47 function calcBatchVolume() {
48 var calc = $("#calc_boil_volume").val(), 48 var calc = $('#calc_boil_volume').val(),
49 boil_size = parseFloat($("#boil_size").jqxNumberInput('decimal')), 49 boil_size = parseFloat($('#boil_size').jqxNumberInput('decimal')),
50 evap_rate = parseFloat($("#evap_rate").jqxNumberInput('decimal')), 50 evap_rate = parseFloat($('#evap_rate').jqxNumberInput('decimal')),
51 boil_time = parseFloat($("#boil_time").jqxNumberInput('decimal')), 51 boil_time = parseFloat($('#boil_time').jqxNumberInput('decimal')),
52 top_up = parseFloat($("#top_up_kettle").jqxNumberInput('decimal')), 52 top_up = parseFloat($('#top_up_kettle').jqxNumberInput('decimal')),
53 batch; 53 batch;
54 54
55 if (calc) { // If checked, calculate the batch size. 55 if (calc) { // If checked, calculate the batch size.
56 batch = boil_size - (evap_rate * boil_time / 60) + top_up; 56 batch = boil_size - (evap_rate * boil_time / 60) + top_up;
57 $("#batch_size").val(batch); 57 $('#batch_size').val(batch);
58 } 58 }
59 } 59 }
60 60
61 // tooltips 61 // tooltips
62 $("#name").jqxTooltip({ content: 'The unique name of this brew equipment.' }); 62 $('#name').jqxTooltip({ content: 'The unique name of this brew equipment.' });
63 $("#notes").jqxTooltip({ content: 'Some notes about the equipment.' }); 63 $('#notes').jqxTooltip({ content: 'Some notes about the equipment.' });
64 $("#tun_volume").jqxTooltip({ content: 'Mash TUN volume.' }); 64 $('#tun_volume').jqxTooltip({ content: 'Mash TUN volume.' });
65 $("#tun_height").jqxTooltip({ content: 'Mash TUN height in cm.' }); 65 $('#tun_height').jqxTooltip({ content: 'Mash TUN height in cm.' });
66 $("#tun_weight").jqxTooltip({ content: 'Mash TUN weight in Kg.' }); 66 $('#tun_weight').jqxTooltip({ content: 'Mash TUN weight in Kg.' });
67 $("#tun_material").jqxTooltip({ content: 'Mash TUN material. Needed to calculate the right strike temperature.' }); 67 $('#tun_material').jqxTooltip({ content: 'Mash TUN material. Needed to calculate the right strike temperature.' });
68 $("#mash_volume").jqxTooltip({ content: 'Liters maisch water voor de eerste maisch stap.' }); 68 $('#mash_volume').jqxTooltip({ content: 'Liters maisch water voor de eerste maisch stap.' });
69 $("#mash_max").jqxTooltip({ content: 'Maximale moutstort voor deze installatie in Kg.' }); 69 $('#mash_max').jqxTooltip({ content: 'Maximale moutstort voor deze installatie in Kg.' });
70 $("#lauter_volume").jqxTooltip({ content: 'Total lauter volume.' }); 70 $('#lauter_volume').jqxTooltip({ content: 'Total lauter volume.' });
71 $("#lauter_height").jqxTooltip({ content: 'Height of the lauter TUN in cm.' }); 71 $('#lauter_height').jqxTooltip({ content: 'Height of the lauter TUN in cm.' });
72 $("#lauter_deadspace").jqxTooltip({ content: 'Volume loss in the lauter TUN.' }); 72 $('#lauter_deadspace').jqxTooltip({ content: 'Volume loss in the lauter TUN.' });
73 $("#efficiency").jqxTooltip({ content: 'Average efficiency.' }); 73 $('#efficiency').jqxTooltip({ content: 'Average efficiency.' });
74 $("#kettle_volume").jqxTooltip({ content: 'Boil kettle volume in liters.' }); 74 $('#kettle_volume').jqxTooltip({ content: 'Boil kettle volume in liters.' });
75 $("#kettle_height").jqxTooltip({ content: 'Boil kettle height in cm.' }); 75 $('#kettle_height').jqxTooltip({ content: 'Boil kettle height in cm.' });
76 $("#boil_size").jqxTooltip({ content: 'Normal boil volume in liters' }); 76 $('#boil_size').jqxTooltip({ content: 'Normal boil volume in liters' });
77 $("#evap_rate").jqxTooltip({ content: 'Evaporation in liters per hour.' }); 77 $('#evap_rate').jqxTooltip({ content: 'Evaporation in liters per hour.' });
78 $("#boil_time").jqxTooltip({ content: 'Normal boil time in minutes.' }); 78 $('#boil_time').jqxTooltip({ content: 'Normal boil time in minutes.' });
79 $("#top_up_kettle").jqxTooltip({ content: 'Extra water added to the boil.' }); 79 $('#top_up_kettle').jqxTooltip({ content: 'Extra water added to the boil.' });
80 $("#hop_utilization").jqxTooltip({ content: '100% for smaller installations, higher for large breweries.' }); 80 $('#hop_utilization').jqxTooltip({ content: '100% for smaller installations, higher for large breweries.' });
81 $("#batch_size").jqxTooltip({ content: 'Calculated batch size, liters at end of the boil.' }); 81 $('#batch_size').jqxTooltip({ content: 'Calculated batch size, liters at end of the boil.' });
82 $("#trub_chiller_loss").jqxTooltip({ content: 'Standard loss in liters during transfer to the fermenter.' }); 82 $('#trub_chiller_loss').jqxTooltip({ content: 'Standard loss in liters during transfer to the fermenter.' });
83 83
84 var dataRecord = {}, 84 var dataRecord = {},
85 url = 'includes/db_inventory_equipments.php', 85 url = 'includes/db_inventory_equipments.php',
86 // prepare the data 86 // prepare the data
87 source = { 87 source = {
88 datatype: "json", 88 datatype: 'json',
89 cache: false, 89 cache: false,
90 datafields: [ 90 datafields: [
91 { name: 'record', type: 'number' }, 91 { name: 'record', type: 'number' },
92 { name: 'name', type: 'string' }, 92 { name: 'name', type: 'string' },
93 { name: 'boil_size', type: 'float' }, 93 { name: 'boil_size', type: 'float' },
94 { name: 'batch_size', type: 'float' }, 94 { name: 'batch_size', type: 'float' },
95 { name: 'tun_volume', type: 'float' }, 95 { name: 'tun_volume', type: 'float' },
96 { name: 'tun_weight', type: 'float' }, 96 { name: 'tun_weight', type: 'float' },
97 { name: 'tun_specific_heat', type: 'float' }, 97 { name: 'tun_specific_heat', type: 'float' },
98 { name: 'tun_material', type: 'int' }, 98 { name: 'tun_material', type: 'int' },
99 { name: 'tun_height', type: 'float' }, 99 { name: 'tun_height', type: 'float' },
100 { name: 'top_up_water', type: 'float' }, 100 { name: 'top_up_water', type: 'float' },
101 { name: 'trub_chiller_loss', type: 'float' }, 101 { name: 'trub_chiller_loss', type: 'float' },
102 { name: 'evap_rate', type: 'float' }, 102 { name: 'evap_rate', type: 'float' },
103 { name: 'boil_time', type: 'float' }, 103 { name: 'boil_time', type: 'float' },
104 { name: 'calc_boil_volume', type: 'int' }, 104 { name: 'calc_boil_volume', type: 'int' },
105 { name: 'top_up_kettle', type: 'float' }, 105 { name: 'top_up_kettle', type: 'float' },
106 { name: 'hop_utilization', type: 'float' }, 106 { name: 'hop_utilization', type: 'float' },
107 { name: 'notes', type: 'string' }, 107 { name: 'notes', type: 'string' },
108 { name: 'lauter_volume', type: 'float' }, 108 { name: 'lauter_volume', type: 'float' },
109 { name: 'lauter_height', type: 'float' }, 109 { name: 'lauter_height', type: 'float' },
110 { name: 'lauter_deadspace', type: 'float' }, 110 { name: 'lauter_deadspace', type: 'float' },
111 { name: 'kettle_volume', type: 'float' }, 111 { name: 'kettle_volume', type: 'float' },
112 { name: 'kettle_height', type: 'float' }, 112 { name: 'kettle_height', type: 'float' },
113 { name: 'mash_volume', type: 'float' }, 113 { name: 'mash_volume', type: 'float' },
114 { name: 'mash_max', type: 'float' }, 114 { name: 'mash_max', type: 'float' },
115 { name: 'efficiency', type: 'float' } 115 { name: 'efficiency', type: 'float' }
116 ], 116 ],
117 id: 'record', 117 id: 'record',
118 url: url, 118 url: url,
119 deleterow: function (rowid, commit) { 119 deleterow: function(rowid, commit) {
120 // synchronize with the server - send delete command 120 // synchronize with the server - send delete command
121 var data = "delete=true&" + $.param({ record: rowid }); 121 var data = 'delete=true&' + $.param({ record: rowid });
122 $.ajax({ 122 $.ajax({
123 dataType: 'json', 123 dataType: 'json',
124 url: url, 124 url: url,
125 cache: false, 125 cache: false,
126 data: data, 126 data: data,
127 type: "POST", 127 type: 'POST',
128 success: function (data, status, xhr) { 128 success: function(data, status, xhr) {
129 commit(true); 129 commit(true);
130 location.reload( true ); 130 location.reload(true);
131 }, 131 },
132 error: function (jqXHR, textStatus, errorThrown) { 132 error: function(jqXHR, textStatus, errorThrown) {
133 commit(false); 133 commit(false);
134 } 134 }
135 }); 135 });
136 }, 136 },
137 addrow: function (rowid, rowdata, position, commit) { 137 addrow: function(rowid, rowdata, position, commit) {
138 var data = "insert=true&" + $.param(rowdata); 138 var data = 'insert=true&' + $.param(rowdata);
139 $.ajax({ 139 $.ajax({
140 dataType: 'json', 140 dataType: 'json',
141 url: url, 141 url: url,
142 cache: false, 142 cache: false,
143 data: data, 143 data: data,
144 type: "POST", 144 type: 'POST',
145 success: function (data, status, xhr) { 145 success: function(data, status, xhr) {
146 commit(true); 146 commit(true);
147 location.reload( true ); 147 location.reload(true);
148 }, 148 },
149 error: function(jqXHR, textStatus, errorThrown) { 149 error: function(jqXHR, textStatus, errorThrown) {
150 commit(false); 150 commit(false);
151 } 151 }
152 }); 152 });
153 }, 153 },
154 updaterow: function (rowid, rowdata, commit) { 154 updaterow: function(rowid, rowdata, commit) {
155 var data = "update=true&" + $.param(rowdata); 155 var data = 'update=true&' + $.param(rowdata);
156 $.ajax({ 156 $.ajax({
157 dataType: 'json', 157 dataType: 'json',
158 url: url, 158 url: url,
159 cache: false, 159 cache: false,
160 data: data, 160 data: data,
161 type: "POST", 161 type: 'POST',
162 success: function (data, status, xhr) { 162 success: function(data, status, xhr) {
163 commit(true); 163 commit(true);
164 location.reload( true ); 164 location.reload(true);
165 }, 165 },
166 error: function(jqXHR, textStatus, errorThrown) { 166 error: function(jqXHR, textStatus, errorThrown) {
167 commit(false); 167 commit(false);
168 } 168 }
169 }); 169 });
170 } 170 }
171 }, 171 },
172 dataAdapter = new $.jqx.dataAdapter(source), 172 dataAdapter = new $.jqx.dataAdapter(source),
173 editrow = -1; 173 editrow = -1;
174 174
175 // initialize the input fields. 175 // initialize the input fields.
176 $("#name").jqxInput({ theme: theme, width: 250, height: 23 }); 176 $('#name').jqxInput({ theme: theme, width: 250, height: 23 });
177 $("#notes").jqxInput({ theme: theme, width: 640, height: 100 }); 177 $('#notes').jqxInput({ theme: theme, width: 640, height: 100 });
178 $("#boil_size").jqxNumberInput( Spin1dec ); 178 $('#boil_size').jqxNumberInput(Spin1dec);
179 $("#batch_size").jqxNumberInput( Spin2dec ); 179 $('#batch_size').jqxNumberInput(Spin2dec);
180 $("#batch_size").jqxNumberInput({ spinButtonsStep: 0.5 }); 180 $('#batch_size').jqxNumberInput({ spinButtonsStep: 0.5 });
181 $("#tun_volume").jqxNumberInput( Spin1dec ); 181 $('#tun_volume').jqxNumberInput(Spin1dec);
182 $("#tun_weight").jqxNumberInput( Spin2dec ); 182 $('#tun_weight').jqxNumberInput(Spin2dec);
183 $("#tun_specific_heat").jqxNumberInput({ inputMode: 'simple', readOnly: true, theme: theme, width: 70, height: 23, decimalDigits: 3 }); 183 $('#tun_specific_heat').jqxNumberInput({ inputMode: 'simple', readOnly: true, theme: theme, width: 70, height: 23, decimalDigits: 3 });
184 $("#tun_material").jqxDropDownList({ 184 $('#tun_material').jqxDropDownList({
185 theme: theme, 185 theme: theme,
186 source: MaterialAdapter, 186 source: MaterialAdapter,
187 valueMember: 'id', 187 valueMember: 'id',
188 displayMember: 'nl', 188 displayMember: 'nl',
189 width: 180, 189 width: 180,
190 height: 23, 190 height: 23,
191 autoDropDownHeight: true 191 autoDropDownHeight: true
192 }); 192 });
193 $("#tun_height").jqxNumberInput( Spin1dec ); 193 $('#tun_height').jqxNumberInput(Spin1dec);
194 $("#top_up_water").jqxNumberInput( Spin1dec ); 194 $('#top_up_water').jqxNumberInput(Spin1dec);
195 $("#trub_chiller_loss").jqxNumberInput( Spin1dec ); 195 $('#trub_chiller_loss').jqxNumberInput(Spin1dec);
196 $("#evap_rate").jqxNumberInput( Spin2dec ); 196 $('#evap_rate').jqxNumberInput(Spin2dec);
197 $("#boil_time").jqxNumberInput( PosInt ); 197 $('#boil_time').jqxNumberInput(PosInt);
198 $("#boil_time").jqxNumberInput({ max: 1440 }); 198 $('#boil_time').jqxNumberInput({ max: 1440 });
199 $("#calc_boil_volume").jqxCheckBox({ theme: theme, width: 120, height: 23 }); 199 $('#calc_boil_volume').jqxCheckBox({ theme: theme, width: 120, height: 23 });
200 $("#calc_boil_volume").on('checked', function (event) { 200 $('#calc_boil_volume').on('checked', function(event) {
201 $("#batch_size").jqxNumberInput({ readOnly: true, width: 90, spinButtons: false }); 201 $('#batch_size').jqxNumberInput({ readOnly: true, width: 90, spinButtons: false });
202 }); 202 });
203 $("#calc_boil_volume").on('unchecked', function (event) { 203 $('#calc_boil_volume').on('unchecked', function(event) {
204 $("#batch_size").jqxNumberInput({ readOnly: false, width: 110, spinButtons: true }); 204 $('#batch_size').jqxNumberInput({ readOnly: false, width: 110, spinButtons: true });
205 }); 205 });
206 $("#top_up_kettle").jqxNumberInput( Spin1dec ); 206 $('#top_up_kettle').jqxNumberInput(Spin1dec);
207 $("#hop_utilization").jqxNumberInput( Perc0 ); 207 $('#hop_utilization').jqxNumberInput(Perc0);
208 $("#hop_utilization").jqxNumberInput({ Max: 200 }); 208 $('#hop_utilization').jqxNumberInput({ Max: 200 });
209 $("#lauter_volume").jqxNumberInput( Spin1dec ); 209 $('#lauter_volume').jqxNumberInput(Spin1dec);
210 $("#lauter_height").jqxNumberInput( Spin1dec ); 210 $('#lauter_height').jqxNumberInput(Spin1dec);
211 $("#lauter_deadspace").jqxNumberInput( Spin1dec ); 211 $('#lauter_deadspace').jqxNumberInput(Spin1dec);
212 $("#kettle_volume").jqxNumberInput( Spin1dec ); 212 $('#kettle_volume').jqxNumberInput(Spin1dec);
213 $("#kettle_height").jqxNumberInput( Spin1dec ); 213 $('#kettle_height').jqxNumberInput(Spin1dec);
214 $("#mash_volume").jqxNumberInput( Spin1dec ); 214 $('#mash_volume').jqxNumberInput(Spin1dec);
215 $("#mash_max").jqxNumberInput( Spin1dec ); 215 $('#mash_max').jqxNumberInput(Spin1dec);
216 $("#efficiency").jqxNumberInput( Perc1dec ); 216 $('#efficiency').jqxNumberInput(Perc1dec);
217 217
218 // initialize jqxGrid 218 // initialize jqxGrid
219 $("#jqxgrid").jqxGrid({ 219 $('#jqxgrid').jqxGrid({
220 width: 1280, 220 width: 1280,
221 height: 630, 221 height: 630,
222 source: dataAdapter, 222 source: dataAdapter,
223 theme: theme, 223 theme: theme,
224 showstatusbar: true, 224 showstatusbar: true,
225 renderstatusbar: function (statusbar) { 225 renderstatusbar: function(statusbar) {
226 var addButton, container = $("<div style='overflow: hidden; position: relative; margin: 5px;'></div>"); 226 var addButton, container = $('<div style="overflow: hidden; position: relative; margin: 5px;"></div>');
227 addButton = $("<div style='float: right; margin-right: 15px;'><img style='position: relative; margin-top: 2px;' src='images/add.png'/><span style='margin-left: 4px; position: relative; top: -3px;'>Nieuw</span></div>"); 227 addButton = $('<div style="float: right; margin-right: 15px;"><img style="position: relative; margin-top: 2px;" ' +
228 container.append(addButton); 228 'src="images/add.png"/><span style="margin-left: 4px; position: relative; top: -3px;">Nieuw</span></div>');
229 statusbar.append(container); 229 expButton = $('<div style="float: right; margin-right: 50px;"><img style="position: relative; margin-top: 2px;" ' +
230 addButton.jqxButton({ theme: theme, width: 90, height: 20 }); 230 'src="images/database.png"/><span style="margin-left: 4px; position: relative; top: -3px;">Export</span></div>');
231 // add new row. 231 container.append(addButton);
232 addButton.click(function (event) { 232 container.append(expButton);
233 editrow = -1; 233 statusbar.append(container);
234 $("#popupWindow").jqxWindow({ position: { x: 110, y: 30 } }); 234 addButton.jqxButton({ theme: theme, width: 90, height: 20 });
235 $("#name").val('Nieuwe brouwset'); 235 expButton.jqxButton({ theme: theme, width: 90, height: 20 });
236 $("#boil_size").val(18); 236 // add new row.
237 $("#batch_size").val(15.3); 237 addButton.click(function(event) {
238 $("#tun_volume").val(20); 238 editrow = -1;
239 $("#tun_weight").val(2); 239 $('#popupWindow').jqxWindow({ position: { x: 110, y: 30 } });
240 $("#tun_specific_heat").val(0.11); 240 $('#name').val('Nieuwe brouwset');
241 $("#tun_material").val(0); 241 $('#boil_size').val(18);
242 $("#tun_height").val(20); 242 $('#batch_size').val(15.3);
243 $("#top_up_water").val(0); 243 $('#tun_volume').val(20);
244 $("#trub_chiller_loss").val(0.5); 244 $('#tun_weight').val(2);
245 $("#evap_rate").val(1.8); 245 $('#tun_specific_heat').val(0.11);
246 $("#boil_time").val(90); 246 $('#tun_material').val(0);
247 $("#calc_boil_volume").val(1); 247 $('#tun_height').val(20);
248 $("#top_up_kettle").val(0); 248 $('#top_up_water').val(0);
249 $("#hop_utilization").val(100); 249 $('#trub_chiller_loss').val(0.5);
250 $("#notes").val(''); 250 $('#evap_rate').val(1.8);
251 $("#lauter_volume").val(20); 251 $('#boil_time').val(90);
252 $("#lauter_height").val(20); 252 $('#calc_boil_volume').val(1);
253 $("#lauter_deadspace").val(0.5); 253 $('#top_up_kettle').val(0);
254 $("#kettle_volume").val(20); 254 $('#hop_utilization').val(100);
255 $("#kettle_height").val(20); 255 $('#notes').val('');
256 $("#mash_volume").val(18); 256 $('#lauter_volume').val(20);
257 $("#mash_max").val(6); 257 $('#lauter_height').val(20);
258 $("#efficiency").val(75); 258 $('#lauter_deadspace').val(0.5);
259 $("#popupWindow").jqxWindow('open'); 259 $('#kettle_volume').val(20);
260 }); 260 $('#kettle_height').val(20);
261 }, 261 $('#mash_volume').val(18);
262 filterable: false, 262 $('#mash_max').val(6);
263 ready: function() { 263 $('#efficiency').val(75);
264 $('#boil_size').on('change', function (event) { calcBatchVolume(); }); 264 $('#popupWindow').jqxWindow('open');
265 $('#evap_rate').on('change', function (event) { calcBatchVolume(); }); 265 });
266 $('#boil_time').on('change', function (event) { calcBatchVolume(); }); 266 expButton.click(function(event) {
267 $('#top_up_kettle').on('change', function (event) { calcBatchVolume(); }); 267 window.open('export_equipments.php');
268 $("#calc_boil_volume").on('change', function (event) { calcBatchVolume(); }); 268 });
269 $('#tun_material').on('change', function (event) { 269 },
270 dataRecord.tun_specific_heat = MaterialData[event.args.index].sh; 270 filterable: false,
271 $("#tun_specific_heat").val(dataRecord.tun_specific_heat); 271 ready: function() {
272 }); 272 $('#boil_size').on('change', function(event) { calcBatchVolume(); });
273 }, 273 $('#evap_rate').on('change', function(event) { calcBatchVolume(); });
274 columns: [ 274 $('#boil_time').on('change', function(event) { calcBatchVolume(); });
275 { text: 'Installatie naam', datafield: 'name', width: 200 }, 275 $('#top_up_kettle').on('change', function(event) { calcBatchVolume(); });
276 { text: 'Kook volume', datafield: 'boil_size', width: 110, align: 'right', cellsalign: 'right', cellsformat: 'f1' }, 276 $('#calc_boil_volume').on('change', function(event) { calcBatchVolume(); });
277 { text: 'Batch volume', datafield: 'batch_size', width: 110, align: 'right', cellsalign: 'right', cellsformat: 'f1' }, 277 $('#tun_material').on('select', function(event) {
278 { text: 'Opmerkingen', datafield: 'notes' }, 278 dataRecord.tun_specific_heat = MaterialData[event.args.index].sh;
279 { text: '', datafield: 'Edit', width: 100, align: 'center', columntype: 'button', cellsrenderer: function () { 279 $('#tun_specific_heat').val(dataRecord.tun_specific_heat);
280 return "Wijzig"; 280 });
281 }, buttonclick: function (row) { 281 },
282 // open the popup window when the user clicks a button. 282 columns: [
283 editrow = row; 283 { text: 'Installatie naam', datafield: 'name', width: 200 },
284 $("#popupWindow").jqxWindow({ position: { x: 110, y: 30 } }); 284 { text: 'Kook volume', datafield: 'boil_size', width: 110, align: 'right', cellsalign: 'right', cellsformat: 'f1' },
285 // get the clicked row's data and initialize the input fields. 285 { text: 'Batch volume', datafield: 'batch_size', width: 110, align: 'right', cellsalign: 'right', cellsformat: 'f1' },
286 dataRecord = $("#jqxgrid").jqxGrid('getrowdata', editrow); 286 { text: 'Opmerkingen', datafield: 'notes' },
287 $("#name").val(dataRecord.name); 287 { text: '', datafield: 'Edit', width: 100, align: 'center', columntype: 'button', cellsrenderer: function() {
288 $("#boil_size").val(dataRecord.boil_size); 288 return 'Wijzig';
289 $("#batch_size").val(dataRecord.batch_size); 289 }, buttonclick: function(row) {
290 $("#tun_volume").val(dataRecord.tun_volume); 290 // open the popup window when the user clicks a button.
291 $("#tun_weight").val(dataRecord.tun_weight); 291 editrow = row;
292 $("#tun_specific_heat").val(dataRecord.tun_specific_heat); 292 $('#popupWindow').jqxWindow({ position: { x: 110, y: 30 } });
293 $("#tun_material").val(dataRecord.tun_material); 293 // get the clicked row's data and initialize the input fields.
294 $("#tun_height").val(dataRecord.tun_height); 294 dataRecord = $('#jqxgrid').jqxGrid('getrowdata', editrow);
295 $("#top_up_water").val(dataRecord.top_up_water); 295 $('#name').val(dataRecord.name);
296 $("#trub_chiller_loss").val(dataRecord.trub_chiller_loss); 296 $('#boil_size').val(dataRecord.boil_size);
297 $("#evap_rate").val(dataRecord.evap_rate); 297 $('#batch_size').val(dataRecord.batch_size);
298 $("#boil_time").val(dataRecord.boil_time); 298 $('#tun_volume').val(dataRecord.tun_volume);
299 $("#calc_boil_volume").val(dataRecord.calc_boil_volume); 299 $('#tun_weight').val(dataRecord.tun_weight);
300 $("#top_up_kettle").val(dataRecord.top_up_kettle); 300 $('#tun_specific_heat').val(dataRecord.tun_specific_heat);
301 $("#hop_utilization").val(dataRecord.hop_utilization); 301 $('#tun_material').val(dataRecord.tun_material);
302 $("#notes").val(dataRecord.notes); 302 $('#tun_height').val(dataRecord.tun_height);
303 $("#lauter_volume").val(dataRecord.lauter_volume); 303 $('#top_up_water').val(dataRecord.top_up_water);
304 $("#lauter_height").val(dataRecord.lauter_height); 304 $('#trub_chiller_loss').val(dataRecord.trub_chiller_loss);
305 $("#lauter_deadspace").val(dataRecord.lauter_deadspace); 305 $('#evap_rate').val(dataRecord.evap_rate);
306 $("#kettle_volume").val(dataRecord.kettle_volume); 306 $('#boil_time').val(dataRecord.boil_time);
307 $("#kettle_height").val(dataRecord.kettle_height); 307 $('#calc_boil_volume').val(dataRecord.calc_boil_volume);
308 $("#mash_volume").val(dataRecord.mash_volume); 308 $('#top_up_kettle').val(dataRecord.top_up_kettle);
309 $("#mash_max").val(dataRecord.mash_max); 309 $('#hop_utilization').val(dataRecord.hop_utilization);
310 $("#efficiency").val(dataRecord.efficiency); 310 $('#notes').val(dataRecord.notes);
311 // show the popup window. 311 $('#lauter_volume').val(dataRecord.lauter_volume);
312 $("#popupWindow").jqxWindow('open'); 312 $('#lauter_height').val(dataRecord.lauter_height);
313 } 313 $('#lauter_deadspace').val(dataRecord.lauter_deadspace);
314 } 314 $('#kettle_volume').val(dataRecord.kettle_volume);
315 ] 315 $('#kettle_height').val(dataRecord.kettle_height);
316 }); 316 $('#mash_volume').val(dataRecord.mash_volume);
317 // initialize the popup window and buttons. 317 $('#mash_max').val(dataRecord.mash_max);
318 $("#popupWindow").jqxWindow({ 318 $('#efficiency').val(dataRecord.efficiency);
319 width: 1050, 319 // show the popup window.
320 height: 600, 320 $('#popupWindow').jqxWindow('open');
321 resizable: false, 321 }
322 theme: theme, 322 }
323 isModal: true, 323 ]
324 autoOpen: false, 324 });
325 cancelButton: $("#Cancel"), 325 // initialize the popup window and buttons.
326 modalOpacity: 0.40 326 $('#popupWindow').jqxWindow({
327 }); 327 width: 1050,
328 $("#popupWindow").on('open', function () { 328 height: 600,
329 $("#name").jqxInput('selectAll'); 329 resizable: false,
330 }); 330 theme: theme,
331 $("#Delete").jqxButton({ template: "danger", width: '90px', theme: theme }); 331 isModal: true,
332 $("#Delete").click(function () { 332 autoOpen: false,
333 if (editrow >= 0) { 333 cancelButton: $('#Cancel'),
334 // Open a popup to confirm this action. 334 modalOpacity: 0.40
335 $('#eventWindow').jqxWindow('open'); 335 });
336 $("#delOk").click(function () { 336 $('#popupWindow').on('open', function() {
337 var rowID = $('#jqxgrid').jqxGrid('getrowid', editrow); 337 $('#name').jqxInput('selectAll');
338 $("#jqxgrid").jqxGrid('deleterow', rowID); 338 });
339 }); 339 $('#Delete').jqxButton({ template: 'danger', width: '90px', theme: theme });
340 } 340 $('#Delete').click(function() {
341 $("#popupWindow").jqxWindow('hide'); 341 if (editrow >= 0) {
342 }); 342 // Open a popup to confirm this action.
343 $("#Cancel").jqxButton({ template: "primary", width: '90px', theme: theme }); 343 $('#eventWindow').jqxWindow('open');
344 $("#Save").jqxButton({ template: "success", width: '90px', theme: theme }); 344 $('#delOk').click(function() {
345 // update the edited row when the user clicks the 'Save' button. 345 var rowID = $('#jqxgrid').jqxGrid('getrowid', editrow);
346 $("#Save").click(function () { 346 $('#jqxgrid').jqxGrid('deleterow', rowID);
347 var row, rowID = -1; 347 });
348 if (editrow >= 0) { 348 }
349 rowID = $('#jqxgrid').jqxGrid('getrowid', editrow); 349 $('#popupWindow').jqxWindow('hide');
350 } 350 });
351 row = { 351 $('#Cancel').jqxButton({ template: 'primary', width: '90px', theme: theme });
352 record: rowID, 352 $('#Save').jqxButton({ template: 'success', width: '90px', theme: theme });
353 name: $("#name").val(), 353 // update the edited row when the user clicks the 'Save' button.
354 boil_size: parseFloat($("#boil_size").jqxNumberInput('decimal')), 354 $('#Save').click(function() {
355 batch_size: parseFloat($("#batch_size").jqxNumberInput('decimal')), 355 var row, rowID = -1;
356 tun_volume: parseFloat($("#tun_volume").jqxNumberInput('decimal')), 356 if (editrow >= 0) {
357 tun_weight: parseFloat($("#tun_weight").jqxNumberInput('decimal')), 357 rowID = $('#jqxgrid').jqxGrid('getrowid', editrow);
358 tun_specific_heat: parseFloat($("#tun_specific_heat").jqxNumberInput('decimal')), 358 }
359 tun_material: $("#tun_material").val(), 359 row = {
360 tun_height: parseFloat($("#tun_height").jqxNumberInput('decimal')), 360 record: rowID,
361 top_up_water: parseFloat($("#top_up_water").jqxNumberInput('decimal')), 361 name: $('#name').val(),
362 trub_chiller_loss: parseFloat($("#trub_chiller_loss").jqxNumberInput('decimal')), 362 boil_size: parseFloat($('#boil_size').jqxNumberInput('decimal')),
363 evap_rate: parseFloat($("#evap_rate").jqxNumberInput('decimal')), 363 batch_size: parseFloat($('#batch_size').jqxNumberInput('decimal')),
364 boil_time: parseFloat($("#boil_time").jqxNumberInput('decimal')), 364 tun_volume: parseFloat($('#tun_volume').jqxNumberInput('decimal')),
365 calc_boil_volume: $("#calc_boil_volume").val(), 365 tun_weight: parseFloat($('#tun_weight').jqxNumberInput('decimal')),
366 top_up_kettle: parseFloat($("#top_up_kettle").jqxNumberInput('decimal')), 366 tun_specific_heat: parseFloat($('#tun_specific_heat').jqxNumberInput('decimal')),
367 hop_utilization: parseFloat($("#hop_utilization").jqxNumberInput('decimal')), 367 tun_material: $('#tun_material').val(),
368 notes: $("#notes").val(), 368 tun_height: parseFloat($('#tun_height').jqxNumberInput('decimal')),
369 lauter_volume: parseFloat($("#lauter_volume").jqxNumberInput('decimal')), 369 top_up_water: parseFloat($('#top_up_water').jqxNumberInput('decimal')),
370 lauter_height: parseFloat($("#lauter_height").jqxNumberInput('decimal')), 370 trub_chiller_loss: parseFloat($('#trub_chiller_loss').jqxNumberInput('decimal')),
371 lauter_deadspace: parseFloat($("#lauter_deadspace").jqxNumberInput('decimal')), 371 evap_rate: parseFloat($('#evap_rate').jqxNumberInput('decimal')),
372 kettle_volume: parseFloat($("#kettle_volume").jqxNumberInput('decimal')), 372 boil_time: parseFloat($('#boil_time').jqxNumberInput('decimal')),
373 kettle_height: parseFloat($("#kettle_height").jqxNumberInput('decimal')), 373 calc_boil_volume: $('#calc_boil_volume').val(),
374 mash_volume: parseFloat($("#mash_volume").jqxNumberInput('decimal')), 374 top_up_kettle: parseFloat($('#top_up_kettle').jqxNumberInput('decimal')),
375 mash_max: parseFloat($("#mash_max").jqxNumberInput('decimal')), 375 hop_utilization: parseFloat($('#hop_utilization').jqxNumberInput('decimal')),
376 efficiency: parseFloat($("#efficiency").jqxNumberInput('decimal')) 376 notes: $('#notes').val(),
377 }; 377 lauter_volume: parseFloat($('#lauter_volume').jqxNumberInput('decimal')),
378 if (editrow >= 0) { 378 lauter_height: parseFloat($('#lauter_height').jqxNumberInput('decimal')),
379 $('#jqxgrid').jqxGrid('updaterow', rowID, row); 379 lauter_deadspace: parseFloat($('#lauter_deadspace').jqxNumberInput('decimal')),
380 } else { 380 kettle_volume: parseFloat($('#kettle_volume').jqxNumberInput('decimal')),
381 $('#jqxgrid').jqxGrid('addrow', null, row); 381 kettle_height: parseFloat($('#kettle_height').jqxNumberInput('decimal')),
382 } 382 mash_volume: parseFloat($('#mash_volume').jqxNumberInput('decimal')),
383 $("#popupWindow").jqxWindow('hide'); 383 mash_max: parseFloat($('#mash_max').jqxNumberInput('decimal')),
384 }); 384 efficiency: parseFloat($('#efficiency').jqxNumberInput('decimal'))
385 createDelElements(); 385 };
386 if (editrow >= 0) {
387 $('#jqxgrid').jqxGrid('updaterow', rowID, row);
388 } else {
389 $('#jqxgrid').jqxGrid('addrow', null, row);
390 }
391 $('#popupWindow').jqxWindow('hide');
392 });
393 createDelElements();
386 }); 394 });
387 395

mercurial