www/js/inv_equipments.js

changeset 209
dc30801e6961
parent 149
ff45488d480e
child 245
3649c3d31d15
equal deleted inserted replaced
208:578c78abf058 209:dc30801e6961
1 /***************************************************************************** 1 /*****************************************************************************
2 * Copyright (C) 2014-2018 2 * Copyright (C) 2014-2019
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 *
41 $('#eventWindow').jqxWindow('hide'); 41 $('#eventWindow').jqxWindow('hide');
42 } 42 }
43 43
44 44
45 $(document).ready(function () { 45 $(document).ready(function () {
46
47 var dataRecord = {};
46 48
47 function calcBatchVolume() { 49 function calcBatchVolume() {
48 var calc = $("#calc_boil_volume").val(); 50 var calc = $("#calc_boil_volume").val();
49 var boil_size = parseFloat($("#boil_size").jqxNumberInput('decimal')); 51 var boil_size = parseFloat($("#boil_size").jqxNumberInput('decimal'));
50 var evap_rate = parseFloat($("#evap_rate").jqxNumberInput('decimal')); 52 var evap_rate = parseFloat($("#evap_rate").jqxNumberInput('decimal'));
91 { name: 'boil_size', type: 'float' }, 93 { name: 'boil_size', type: 'float' },
92 { name: 'batch_size', type: 'float' }, 94 { name: 'batch_size', type: 'float' },
93 { name: 'tun_volume', type: 'float' }, 95 { name: 'tun_volume', type: 'float' },
94 { name: 'tun_weight', type: 'float' }, 96 { name: 'tun_weight', type: 'float' },
95 { name: 'tun_specific_heat', type: 'float' }, 97 { name: 'tun_specific_heat', type: 'float' },
96 { name: 'tun_material', type: 'string' }, 98 { name: 'tun_material', type: 'int' },
97 { name: 'tun_height', type: 'float' }, 99 { name: 'tun_height', type: 'float' },
98 { name: 'top_up_water', type: 'float' }, 100 { name: 'top_up_water', type: 'float' },
99 { name: 'trub_chiller_loss', type: 'float' }, 101 { name: 'trub_chiller_loss', type: 'float' },
100 { name: 'evap_rate', type: 'float' }, 102 { name: 'evap_rate', type: 'float' },
101 { name: 'boil_time', type: 'float' }, 103 { name: 'boil_time', type: 'float' },
102 { name: 'calc_boil_volume', type: 'bool' }, 104 { name: 'calc_boil_volume', type: 'int' },
103 { name: 'top_up_kettle', type: 'float' }, 105 { name: 'top_up_kettle', type: 'float' },
104 { name: 'hop_utilization', type: 'float' }, 106 { name: 'hop_utilization', type: 'float' },
105 { name: 'notes', type: 'string' }, 107 { name: 'notes', type: 'string' },
106 { name: 'lauter_volume', type: 'float' }, 108 { name: 'lauter_volume', type: 'float' },
107 { name: 'lauter_height', type: 'float' }, 109 { name: 'lauter_height', type: 'float' },
120 $.ajax({ 122 $.ajax({
121 dataType: 'json', 123 dataType: 'json',
122 url: url, 124 url: url,
123 cache: false, 125 cache: false,
124 data: data, 126 data: data,
127 type: "POST",
125 success: function (data, status, xhr) { 128 success: function (data, status, xhr) {
126 // delete command is executed. 129 // delete command is executed.
127 commit(true); 130 commit(true);
128 }, 131 },
129 error: function (jqXHR, textStatus, errorThrown) { 132 error: function (jqXHR, textStatus, errorThrown) {
136 $.ajax({ 139 $.ajax({
137 dataType: 'json', 140 dataType: 'json',
138 url: url, 141 url: url,
139 cache: false, 142 cache: false,
140 data: data, 143 data: data,
144 type: "POST",
141 success: function (data, status, xhr) { 145 success: function (data, status, xhr) {
142 commit(true); 146 commit(true);
143 }, 147 },
144 error: function(jqXHR, textStatus, errorThrown) { 148 error: function(jqXHR, textStatus, errorThrown) {
145 commit(false); 149 commit(false);
151 $.ajax({ 155 $.ajax({
152 dataType: 'json', 156 dataType: 'json',
153 url: url, 157 url: url,
154 cache: false, 158 cache: false,
155 data: data, 159 data: data,
160 type: "POST",
156 success: function (data, status, xhr) { 161 success: function (data, status, xhr) {
157 // update command is executed. 162 // update command is executed.
158 commit(true); 163 commit(true);
159 }, 164 },
160 error: function(jqXHR, textStatus, errorThrown) { 165 error: function(jqXHR, textStatus, errorThrown) {
163 }); 168 });
164 } 169 }
165 }; 170 };
166 171
167 // initialize the input fields. 172 // initialize the input fields.
168 var srcMaterial= [ "RVS", "Aluminium", "Kunststof", "Koper" ];
169
170 $("#name").jqxInput({ theme: theme, width: 250, height: 23 }); 173 $("#name").jqxInput({ theme: theme, width: 250, height: 23 });
171 $("#boil_size").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 110, height: 23, min: 0, max: 200000, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.5 }); 174 $("#notes").jqxInput({ theme: theme, width: 640, height: 100 });
172 $("#batch_size").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 110, height: 23, min: 0, max: 200000, decimalDigits: 2, spinButtons: true, spinButtonsStep: 0.5 }); 175 $("#boil_size").jqxNumberInput( Spin1dec5 );
173 $("#tun_volume").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 110, height: 23, min: 0, max: 200000, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.5 }); 176 $("#batch_size").jqxNumberInput( Spin2dec1 );
174 $("#tun_weight").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 110, height: 23, min: 0, decimalDigits: 2, spinButtons: true }); 177 $("#batch_size").jqxNumberInput({ spinButtonsStep: 0.5 });
178 $("#tun_volume").jqxNumberInput( Spin1dec5 );
179 $("#tun_weight").jqxNumberInput( Spin2dec1 );
175 $("#tun_specific_heat").jqxNumberInput({ inputMode: 'simple', readOnly: true, theme: theme, width: 70, height: 23, decimalDigits: 3 }); 180 $("#tun_specific_heat").jqxNumberInput({ inputMode: 'simple', readOnly: true, theme: theme, width: 70, height: 23, decimalDigits: 3 });
176 $("#tun_material").jqxDropDownList({ theme: theme, source: srcMaterial, selectedIndex: 0, width: 110, height: 23, dropDownHeight: 130 }); 181 $("#tun_material").jqxDropDownList({
177 $("#tun_height").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 110, height: 23, min: 0, decimalDigits: 1, spinButtons: true }); 182 theme: theme,
178 $("#top_up_water").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 110, height: 23, min: 0, max: 20000, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.1 }); 183 source: MaterialAdapter,
179 $("#trub_chiller_loss").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 110, height: 23, min: 0, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.1 }); 184 valueMember: 'id',
180 $("#evap_rate").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 110, height: 23, min: 0, max: 40000, decimalDigits: 2, spinButtons: true, spinButtonsStep: 0.05 }); 185 displayMember: 'nl',
181 $("#boil_time").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 110, height: 23, min: 0, max: 1440, decimalDigits: 0, spinButtons: true }); 186 // selectedIndex: 0,
187 width: 180,
188 height: 23,
189 autoDropDownHeight: true
190 });
191 $("#tun_height").jqxNumberInput( Spin1dec1 );
192 $("#top_up_water").jqxNumberInput( Spin1dec1 );
193 $("#trub_chiller_loss").jqxNumberInput( Spin1dec1 );
194 $("#evap_rate").jqxNumberInput( Spin2dec1 );
195 $("#boil_time").jqxNumberInput( PosInt );
196 $("#boil_time").jqxNumberInput({ max: 1440 });
182 $("#calc_boil_volume").jqxCheckBox({ theme: theme, width: 120, height: 23 }); 197 $("#calc_boil_volume").jqxCheckBox({ theme: theme, width: 120, height: 23 });
183 $("#calc_boil_volume").on('checked', function (event) { 198 $("#calc_boil_volume").on('checked', function (event) {
184 $("#batch_size").jqxNumberInput({ readOnly: true, width: 90, spinButtons: false }); 199 $("#batch_size").jqxNumberInput({ readOnly: true, width: 90, spinButtons: false });
185 }); 200 });
186 $("#calc_boil_volume").on('unchecked', function (event) { 201 $("#calc_boil_volume").on('unchecked', function (event) {
187 $("#batch_size").jqxNumberInput({ readOnly: false, width: 110, spinButtons: true }); 202 $("#batch_size").jqxNumberInput({ readOnly: false, width: 110, spinButtons: true });
188 }); 203 });
189 $("#top_up_kettle").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 110, height: 23, min: 0, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.1 }); 204 $("#top_up_kettle").jqxNumberInput( Spin1dec1 );
190 $("#hop_utilization").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 90, height: 23, min: 0, decimalDigits: 0, spinButtons: true }); 205 $("#hop_utilization").jqxNumberInput( Perc0 );
191 $("#notes").jqxInput({ theme: theme, width: 640, height: 100 }); 206 $("#hop_utilization").jqxNumberInput({ Max: 200 });
192 $("#lauter_volume").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 110, height: 23, min: 0, max: 200000, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.5 }); 207 $("#lauter_volume").jqxNumberInput( Spin1dec5 );
193 $("#lauter_height").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 110, height: 23, min: 0, decimalDigits: 1, spinButtons: true }); 208 $("#lauter_height").jqxNumberInput( Spin1dec1 );
194 $("#lauter_deadspace").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 110, height: 23, min: 0, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.1 }); 209 $("#lauter_deadspace").jqxNumberInput( Spin1dec1 );
195 $("#kettle_volume").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 110, height: 23, min: 0, max: 200000, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.5 }); 210 $("#kettle_volume").jqxNumberInput( Spin1dec5 );
196 $("#kettle_height").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 110, height: 23, min: 0, decimalDigits: 1, spinButtons: true }); 211 $("#kettle_height").jqxNumberInput( Spin1dec1 );
197 $("#mash_volume").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 110, height: 23, min: 0, max: 200000, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.5 }); 212 $("#mash_volume").jqxNumberInput( Spin1dec5 );
198 $("#mash_max").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 110, height: 23, min: 0, max: 200000, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.5 }); 213 $("#mash_max").jqxNumberInput( Spin1dec5 );
199 $("#efficiency").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 110, height: 23, min: 0, decimalDigits: 1, spinButtons: true }); 214 $("#efficiency").jqxNumberInput( Perc1dec5 );
215
200 var dataAdapter = new $.jqx.dataAdapter(source); 216 var dataAdapter = new $.jqx.dataAdapter(source);
201 var editrow = -1; 217 var editrow = -1;
202 // initialize jqxGrid 218 // initialize jqxGrid
203 $("#jqxgrid").jqxGrid({ 219 $("#jqxgrid").jqxGrid({
204 width: 1280, 220 width: 1280,
210 renderstatusbar: function (statusbar) { 226 renderstatusbar: function (statusbar) {
211 var container = $("<div style='overflow: hidden; position: relative; margin: 5px;'></div>"); 227 var container = $("<div style='overflow: hidden; position: relative; margin: 5px;'></div>");
212 var 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>"); 228 var 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>");
213 container.append(addButton); 229 container.append(addButton);
214 statusbar.append(container); 230 statusbar.append(container);
215 addButton.jqxButton({ theme: theme, width: 120, height: 20 }); 231 addButton.jqxButton({ theme: theme, width: 90, height: 20 });
216 // add new row. 232 // add new row.
217 addButton.click(function (event) { 233 addButton.click(function (event) {
218 editrow = -1; 234 editrow = -1;
219 $("#popupWindow").jqxWindow({ position: { x: 180, y: 30 } }); 235 $("#popupWindow").jqxWindow({ position: { x: 110, y: 30 } });
220 $("#name").val(''); 236 $("#name").val('Nieuwe brouwset');
221 $("#boil_size").val('18'); 237 $("#boil_size").val(18);
222 $("#batch_size").val('15.3'); 238 $("#batch_size").val(15.3);
223 $("#tun_volume").val('20'); 239 $("#tun_volume").val(20);
224 $("#tun_weight").val('2'); 240 $("#tun_weight").val(2);
225 $("#tun_specific_heat").val('0.11'); 241 $("#tun_specific_heat").val(0.11);
226 $("#tun_material").val('RVS'); 242 $("#tun_material").val(0);
227 $("#tun_height").val('20'); 243 $("#tun_height").val(20);
228 $("#top_up_water").val('0'); 244 $("#top_up_water").val(0);
229 $("#trub_chiller_loss").val('0.5'); 245 $("#trub_chiller_loss").val(0.5);
230 $("#evap_rate").val('1.8'); 246 $("#evap_rate").val(1.8);
231 $("#boil_time").val('90'); 247 $("#boil_time").val(90);
232 $("#calc_boil_volume").val(true); 248 $("#calc_boil_volume").val(1);
233 $("#top_up_kettle").val('0'); 249 $("#top_up_kettle").val(0);
234 $("#hop_utilization").val('100'); 250 $("#hop_utilization").val(100);
235 $("#notes").val(''); 251 $("#notes").val('');
236 $("#lauter_volume").val('20'); 252 $("#lauter_volume").val(20);
237 $("#lauter_height").val('20'); 253 $("#lauter_height").val(20);
238 $("#lauter_deadspace").val('0.5'); 254 $("#lauter_deadspace").val(0.5);
239 $("#kettle_volume").val('20'); 255 $("#kettle_volume").val(20);
240 $("#kettle_height").val('20'); 256 $("#kettle_height").val(20);
241 $("#mash_volume").val('18'); 257 $("#mash_volume").val(18);
242 $("#mash_max").val('6'); 258 $("#mash_max").val(6);
243 $("#efficiency").val('75'); 259 $("#efficiency").val(75);
244 $("#popupWindow").jqxWindow('open'); 260 $("#popupWindow").jqxWindow('open');
245 }); 261 });
246 }, 262 },
247 filterable: true, 263 filterable: false,
248 filtermode: 'excel',
249 ready: function() { 264 ready: function() {
250 $('#boil_size').on('change', function (event) { calcBatchVolume(); }); 265 $('#boil_size').on('change', function (event) { calcBatchVolume(); });
251 $('#evap_rate').on('change', function (event) { calcBatchVolume(); }); 266 $('#evap_rate').on('change', function (event) { calcBatchVolume(); });
252 $('#boil_time').on('change', function (event) { calcBatchVolume(); }); 267 $('#boil_time').on('change', function (event) { calcBatchVolume(); });
253 $('#top_up_kettle').on('change', function (event) { calcBatchVolume(); }); 268 $('#top_up_kettle').on('change', function (event) { calcBatchVolume(); });
254 $("#calc_boil_volume").on('change', function (event) { calcBatchVolume(); }); 269 $("#calc_boil_volume").on('change', function (event) { calcBatchVolume(); });
255 $('#tun_material').on('change', function (event) { 270 $('#tun_material').on('change', function (event) {
256 switch ($('#tun_material').val()) { 271 dataRecord.tun_specific_heat = MaterialData[event.args.index].sh;
257 case 'RVS': $("#tun_specific_heat").val('0.11'); 272 $("#tun_specific_heat").val(dataRecord.tun_specific_heat);
258 break;
259 case 'Aluminium': $("#tun_specific_heat").val('0.22');
260 break;
261 case 'Kunststof': $("#tun_specific_heat").val('0.46');
262 break;
263 case 'Koper': $("#tun_specific_heat").val('0.092');
264 break;
265 }
266 }); 273 });
267 }, 274 },
268 columns: [ 275 columns: [
269 { text: 'Installatie naam', datafield: 'name', width: 200 }, 276 { text: 'Installatie naam', datafield: 'name', width: 200 },
270 { text: 'Kook volume', datafield: 'boil_size', width: 100, align: 'right', cellsalign: 'right', cellsformat: 'f1' }, 277 { text: 'Kook volume', datafield: 'boil_size', width: 110, align: 'right', cellsalign: 'right', cellsformat: 'f1' },
271 { text: 'Batch volume', datafield: 'batch_size', width: 100, align: 'right', cellsalign: 'right', cellsformat: 'f1' }, 278 { text: 'Batch volume', datafield: 'batch_size', width: 110, align: 'right', cellsalign: 'right', cellsformat: 'f1' },
272 { text: 'Opmerkingen', datafield: 'notes' }, 279 { text: 'Opmerkingen', datafield: 'notes' },
273 { text: 'Wijzig', datafield: 'Edit', width: 120, align: 'center', columntype: 'button', cellsrenderer: function () { 280 { text: 'Wijzig', datafield: 'Edit', width: 100, align: 'center', columntype: 'button', cellsrenderer: function () {
274 return "Wijzig"; 281 return "Wijzig";
275 }, buttonclick: function (row) { 282 }, buttonclick: function (row) {
276 // open the popup window when the user clicks a button. 283 // open the popup window when the user clicks a button.
277 editrow = row; 284 editrow = row;
278 $("#popupWindow").jqxWindow({ position: { x: 180, y: 30 } }); 285 $("#popupWindow").jqxWindow({ position: { x: 110, y: 30 } });
279 // get the clicked row's data and initialize the input fields. 286 // get the clicked row's data and initialize the input fields.
280 var dataRecord = $("#jqxgrid").jqxGrid('getrowdata', editrow); 287 dataRecord = $("#jqxgrid").jqxGrid('getrowdata', editrow);
281 $("#name").val(dataRecord.name); 288 $("#name").val(dataRecord.name);
282 $("#boil_size").val(dataRecord.boil_size); 289 $("#boil_size").val(dataRecord.boil_size);
283 $("#batch_size").val(dataRecord.batch_size); 290 $("#batch_size").val(dataRecord.batch_size);
284 $("#tun_volume").val(dataRecord.tun_volume); 291 $("#tun_volume").val(dataRecord.tun_volume);
285 $("#tun_weight").val(dataRecord.tun_weight); 292 $("#tun_weight").val(dataRecord.tun_weight);
308 } 315 }
309 ] 316 ]
310 }); 317 });
311 // initialize the popup window and buttons. 318 // initialize the popup window and buttons.
312 $("#popupWindow").jqxWindow({ 319 $("#popupWindow").jqxWindow({
313 width: 900, resizable: false, theme: theme, isModal: true, autoOpen: false, cancelButton: $("#Cancel"), modalOpacity: 0.40 320 width: 1050,
321 height: 600,
322 resizable: false,
323 theme: theme,
324 isModal: true,
325 autoOpen: false,
326 cancelButton: $("#Cancel"),
327 modalOpacity: 0.40
314 }); 328 });
315 $("#popupWindow").on('open', function () { 329 $("#popupWindow").on('open', function () {
316 $("#name").jqxInput('selectAll'); 330 $("#name").jqxInput('selectAll');
317 }); 331 });
318 $("#Delete").jqxButton({ template: "danger", width: '80px', theme: theme }); 332 $("#Delete").jqxButton({ template: "danger", width: '90px', theme: theme });
319 $("#Delete").click(function () { 333 $("#Delete").click(function () {
320 if (editrow >= 0) { 334 if (editrow >= 0) {
321 // Open a popup to confirm this action. 335 // Open a popup to confirm this action.
322 $('#eventWindow').jqxWindow('open'); 336 $('#eventWindow').jqxWindow('open');
323 $("#delOk").click(function () { 337 $("#delOk").click(function () {
325 $("#jqxgrid").jqxGrid('deleterow', rowID); 339 $("#jqxgrid").jqxGrid('deleterow', rowID);
326 }); 340 });
327 } 341 }
328 $("#popupWindow").jqxWindow('hide'); 342 $("#popupWindow").jqxWindow('hide');
329 }); 343 });
330 $("#Cancel").jqxButton({ template: "primary", width: '80px', theme: theme }); 344 $("#Cancel").jqxButton({ template: "primary", width: '90px', theme: theme });
331 $("#Save").jqxButton({ template: "success", width: '90px', theme: theme }); 345 $("#Save").jqxButton({ template: "success", width: '90px', theme: theme });
332 // update the edited row when the user clicks the 'Save' button. 346 // update the edited row when the user clicks the 'Save' button.
333 $("#Save").click(function () { 347 $("#Save").click(function () {
334 var rowID = -1; 348 var rowID = -1;
335 if (editrow >= 0) { 349 if (editrow >= 0) {
366 $('#jqxgrid').jqxGrid('updaterow', rowID, row); 380 $('#jqxgrid').jqxGrid('updaterow', rowID, row);
367 } else { 381 } else {
368 $('#jqxgrid').jqxGrid('addrow', null, row); 382 $('#jqxgrid').jqxGrid('addrow', null, row);
369 } 383 }
370 $("#popupWindow").jqxWindow('hide'); 384 $("#popupWindow").jqxWindow('hide');
385 location.reload( true ); // reload ourself.
371 }); 386 });
372 createDelElements(); 387 createDelElements();
373 }); 388 });
374 389

mercurial