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 container.append(addButton); |
230 addButton.jqxButton({ theme: theme, width: 90, height: 20 }); |
230 statusbar.append(container); |
231 // add new row. |
231 addButton.jqxButton({ theme: theme, width: 90, height: 20 }); |
232 addButton.click(function (event) { |
232 // add new row. |
233 editrow = -1; |
233 addButton.click(function(event) { |
234 $("#popupWindow").jqxWindow({ position: { x: 110, y: 30 } }); |
234 editrow = -1; |
235 $("#name").val('Nieuwe brouwset'); |
235 $('#popupWindow').jqxWindow({ position: { x: 110, y: 30 } }); |
236 $("#boil_size").val(18); |
236 $('#name').val('Nieuwe brouwset'); |
237 $("#batch_size").val(15.3); |
237 $('#boil_size').val(18); |
238 $("#tun_volume").val(20); |
238 $('#batch_size').val(15.3); |
239 $("#tun_weight").val(2); |
239 $('#tun_volume').val(20); |
240 $("#tun_specific_heat").val(0.11); |
240 $('#tun_weight').val(2); |
241 $("#tun_material").val(0); |
241 $('#tun_specific_heat').val(0.11); |
242 $("#tun_height").val(20); |
242 $('#tun_material').val(0); |
243 $("#top_up_water").val(0); |
243 $('#tun_height').val(20); |
244 $("#trub_chiller_loss").val(0.5); |
244 $('#top_up_water').val(0); |
245 $("#evap_rate").val(1.8); |
245 $('#trub_chiller_loss').val(0.5); |
246 $("#boil_time").val(90); |
246 $('#evap_rate').val(1.8); |
247 $("#calc_boil_volume").val(1); |
247 $('#boil_time').val(90); |
248 $("#top_up_kettle").val(0); |
248 $('#calc_boil_volume').val(1); |
249 $("#hop_utilization").val(100); |
249 $('#top_up_kettle').val(0); |
250 $("#notes").val(''); |
250 $('#hop_utilization').val(100); |
251 $("#lauter_volume").val(20); |
251 $('#notes').val(''); |
252 $("#lauter_height").val(20); |
252 $('#lauter_volume').val(20); |
253 $("#lauter_deadspace").val(0.5); |
253 $('#lauter_height').val(20); |
254 $("#kettle_volume").val(20); |
254 $('#lauter_deadspace').val(0.5); |
255 $("#kettle_height").val(20); |
255 $('#kettle_volume').val(20); |
256 $("#mash_volume").val(18); |
256 $('#kettle_height').val(20); |
257 $("#mash_max").val(6); |
257 $('#mash_volume').val(18); |
258 $("#efficiency").val(75); |
258 $('#mash_max').val(6); |
259 $("#popupWindow").jqxWindow('open'); |
259 $('#efficiency').val(75); |
260 }); |
260 $('#popupWindow').jqxWindow('open'); |
261 }, |
261 }); |
262 filterable: false, |
262 }, |
263 ready: function() { |
263 filterable: false, |
264 $('#boil_size').on('change', function (event) { calcBatchVolume(); }); |
264 ready: function() { |
265 $('#evap_rate').on('change', function (event) { calcBatchVolume(); }); |
265 $('#boil_size').on('change', function(event) { calcBatchVolume(); }); |
266 $('#boil_time').on('change', function (event) { calcBatchVolume(); }); |
266 $('#evap_rate').on('change', function(event) { calcBatchVolume(); }); |
267 $('#top_up_kettle').on('change', function (event) { calcBatchVolume(); }); |
267 $('#boil_time').on('change', function(event) { calcBatchVolume(); }); |
268 $("#calc_boil_volume").on('change', function (event) { calcBatchVolume(); }); |
268 $('#top_up_kettle').on('change', function(event) { calcBatchVolume(); }); |
269 $('#tun_material').on('change', function (event) { |
269 $('#calc_boil_volume').on('change', function(event) { calcBatchVolume(); }); |
270 dataRecord.tun_specific_heat = MaterialData[event.args.index].sh; |
270 $('#tun_material').on('change', function(event) { |
271 $("#tun_specific_heat").val(dataRecord.tun_specific_heat); |
271 dataRecord.tun_specific_heat = MaterialData[event.args.index].sh; |
272 }); |
272 $('#tun_specific_heat').val(dataRecord.tun_specific_heat); |
273 }, |
273 }); |
274 columns: [ |
274 }, |
275 { text: 'Installatie naam', datafield: 'name', width: 200 }, |
275 columns: [ |
276 { text: 'Kook volume', datafield: 'boil_size', width: 110, align: 'right', cellsalign: 'right', cellsformat: 'f1' }, |
276 { text: 'Installatie naam', datafield: 'name', width: 200 }, |
277 { text: 'Batch volume', datafield: 'batch_size', width: 110, align: 'right', cellsalign: 'right', cellsformat: 'f1' }, |
277 { text: 'Kook volume', datafield: 'boil_size', width: 110, align: 'right', cellsalign: 'right', cellsformat: 'f1' }, |
278 { text: 'Opmerkingen', datafield: 'notes' }, |
278 { text: 'Batch volume', datafield: 'batch_size', width: 110, align: 'right', cellsalign: 'right', cellsformat: 'f1' }, |
279 { text: '', datafield: 'Edit', width: 100, align: 'center', columntype: 'button', cellsrenderer: function () { |
279 { text: 'Opmerkingen', datafield: 'notes' }, |
280 return "Wijzig"; |
280 { text: '', datafield: 'Edit', width: 100, align: 'center', columntype: 'button', cellsrenderer: function() { |
281 }, buttonclick: function (row) { |
281 return 'Wijzig'; |
282 // open the popup window when the user clicks a button. |
282 }, buttonclick: function(row) { |
283 editrow = row; |
283 // open the popup window when the user clicks a button. |
284 $("#popupWindow").jqxWindow({ position: { x: 110, y: 30 } }); |
284 editrow = row; |
285 // get the clicked row's data and initialize the input fields. |
285 $('#popupWindow').jqxWindow({ position: { x: 110, y: 30 } }); |
286 dataRecord = $("#jqxgrid").jqxGrid('getrowdata', editrow); |
286 // get the clicked row's data and initialize the input fields. |
287 $("#name").val(dataRecord.name); |
287 dataRecord = $('#jqxgrid').jqxGrid('getrowdata', editrow); |
288 $("#boil_size").val(dataRecord.boil_size); |
288 $('#name').val(dataRecord.name); |
289 $("#batch_size").val(dataRecord.batch_size); |
289 $('#boil_size').val(dataRecord.boil_size); |
290 $("#tun_volume").val(dataRecord.tun_volume); |
290 $('#batch_size').val(dataRecord.batch_size); |
291 $("#tun_weight").val(dataRecord.tun_weight); |
291 $('#tun_volume').val(dataRecord.tun_volume); |
292 $("#tun_specific_heat").val(dataRecord.tun_specific_heat); |
292 $('#tun_weight').val(dataRecord.tun_weight); |
293 $("#tun_material").val(dataRecord.tun_material); |
293 $('#tun_specific_heat').val(dataRecord.tun_specific_heat); |
294 $("#tun_height").val(dataRecord.tun_height); |
294 $('#tun_material').val(dataRecord.tun_material); |
295 $("#top_up_water").val(dataRecord.top_up_water); |
295 $('#tun_height').val(dataRecord.tun_height); |
296 $("#trub_chiller_loss").val(dataRecord.trub_chiller_loss); |
296 $('#top_up_water').val(dataRecord.top_up_water); |
297 $("#evap_rate").val(dataRecord.evap_rate); |
297 $('#trub_chiller_loss').val(dataRecord.trub_chiller_loss); |
298 $("#boil_time").val(dataRecord.boil_time); |
298 $('#evap_rate').val(dataRecord.evap_rate); |
299 $("#calc_boil_volume").val(dataRecord.calc_boil_volume); |
299 $('#boil_time').val(dataRecord.boil_time); |
300 $("#top_up_kettle").val(dataRecord.top_up_kettle); |
300 $('#calc_boil_volume').val(dataRecord.calc_boil_volume); |
301 $("#hop_utilization").val(dataRecord.hop_utilization); |
301 $('#top_up_kettle').val(dataRecord.top_up_kettle); |
302 $("#notes").val(dataRecord.notes); |
302 $('#hop_utilization').val(dataRecord.hop_utilization); |
303 $("#lauter_volume").val(dataRecord.lauter_volume); |
303 $('#notes').val(dataRecord.notes); |
304 $("#lauter_height").val(dataRecord.lauter_height); |
304 $('#lauter_volume').val(dataRecord.lauter_volume); |
305 $("#lauter_deadspace").val(dataRecord.lauter_deadspace); |
305 $('#lauter_height').val(dataRecord.lauter_height); |
306 $("#kettle_volume").val(dataRecord.kettle_volume); |
306 $('#lauter_deadspace').val(dataRecord.lauter_deadspace); |
307 $("#kettle_height").val(dataRecord.kettle_height); |
307 $('#kettle_volume').val(dataRecord.kettle_volume); |
308 $("#mash_volume").val(dataRecord.mash_volume); |
308 $('#kettle_height').val(dataRecord.kettle_height); |
309 $("#mash_max").val(dataRecord.mash_max); |
309 $('#mash_volume').val(dataRecord.mash_volume); |
310 $("#efficiency").val(dataRecord.efficiency); |
310 $('#mash_max').val(dataRecord.mash_max); |
311 // show the popup window. |
311 $('#efficiency').val(dataRecord.efficiency); |
312 $("#popupWindow").jqxWindow('open'); |
312 // show the popup window. |
313 } |
313 $('#popupWindow').jqxWindow('open'); |
314 } |
314 } |
315 ] |
315 } |
316 }); |
316 ] |
317 // initialize the popup window and buttons. |
317 }); |
318 $("#popupWindow").jqxWindow({ |
318 // initialize the popup window and buttons. |
319 width: 1050, |
319 $('#popupWindow').jqxWindow({ |
320 height: 600, |
320 width: 1050, |
321 resizable: false, |
321 height: 600, |
322 theme: theme, |
322 resizable: false, |
323 isModal: true, |
323 theme: theme, |
324 autoOpen: false, |
324 isModal: true, |
325 cancelButton: $("#Cancel"), |
325 autoOpen: false, |
326 modalOpacity: 0.40 |
326 cancelButton: $('#Cancel'), |
327 }); |
327 modalOpacity: 0.40 |
328 $("#popupWindow").on('open', function () { |
328 }); |
329 $("#name").jqxInput('selectAll'); |
329 $('#popupWindow').on('open', function() { |
330 }); |
330 $('#name').jqxInput('selectAll'); |
331 $("#Delete").jqxButton({ template: "danger", width: '90px', theme: theme }); |
331 }); |
332 $("#Delete").click(function () { |
332 $('#Delete').jqxButton({ template: 'danger', width: '90px', theme: theme }); |
333 if (editrow >= 0) { |
333 $('#Delete').click(function() { |
334 // Open a popup to confirm this action. |
334 if (editrow >= 0) { |
335 $('#eventWindow').jqxWindow('open'); |
335 // Open a popup to confirm this action. |
336 $("#delOk").click(function () { |
336 $('#eventWindow').jqxWindow('open'); |
337 var rowID = $('#jqxgrid').jqxGrid('getrowid', editrow); |
337 $('#delOk').click(function() { |
338 $("#jqxgrid").jqxGrid('deleterow', rowID); |
338 var rowID = $('#jqxgrid').jqxGrid('getrowid', editrow); |
339 }); |
339 $('#jqxgrid').jqxGrid('deleterow', rowID); |
340 } |
340 }); |
341 $("#popupWindow").jqxWindow('hide'); |
341 } |
342 }); |
342 $('#popupWindow').jqxWindow('hide'); |
343 $("#Cancel").jqxButton({ template: "primary", width: '90px', theme: theme }); |
343 }); |
344 $("#Save").jqxButton({ template: "success", width: '90px', theme: theme }); |
344 $('#Cancel').jqxButton({ template: 'primary', width: '90px', theme: theme }); |
345 // update the edited row when the user clicks the 'Save' button. |
345 $('#Save').jqxButton({ template: 'success', width: '90px', theme: theme }); |
346 $("#Save").click(function () { |
346 // update the edited row when the user clicks the 'Save' button. |
347 var row, rowID = -1; |
347 $('#Save').click(function() { |
348 if (editrow >= 0) { |
348 var row, rowID = -1; |
349 rowID = $('#jqxgrid').jqxGrid('getrowid', editrow); |
349 if (editrow >= 0) { |
350 } |
350 rowID = $('#jqxgrid').jqxGrid('getrowid', editrow); |
351 row = { |
351 } |
352 record: rowID, |
352 row = { |
353 name: $("#name").val(), |
353 record: rowID, |
354 boil_size: parseFloat($("#boil_size").jqxNumberInput('decimal')), |
354 name: $('#name').val(), |
355 batch_size: parseFloat($("#batch_size").jqxNumberInput('decimal')), |
355 boil_size: parseFloat($('#boil_size').jqxNumberInput('decimal')), |
356 tun_volume: parseFloat($("#tun_volume").jqxNumberInput('decimal')), |
356 batch_size: parseFloat($('#batch_size').jqxNumberInput('decimal')), |
357 tun_weight: parseFloat($("#tun_weight").jqxNumberInput('decimal')), |
357 tun_volume: parseFloat($('#tun_volume').jqxNumberInput('decimal')), |
358 tun_specific_heat: parseFloat($("#tun_specific_heat").jqxNumberInput('decimal')), |
358 tun_weight: parseFloat($('#tun_weight').jqxNumberInput('decimal')), |
359 tun_material: $("#tun_material").val(), |
359 tun_specific_heat: parseFloat($('#tun_specific_heat').jqxNumberInput('decimal')), |
360 tun_height: parseFloat($("#tun_height").jqxNumberInput('decimal')), |
360 tun_material: $('#tun_material').val(), |
361 top_up_water: parseFloat($("#top_up_water").jqxNumberInput('decimal')), |
361 tun_height: parseFloat($('#tun_height').jqxNumberInput('decimal')), |
362 trub_chiller_loss: parseFloat($("#trub_chiller_loss").jqxNumberInput('decimal')), |
362 top_up_water: parseFloat($('#top_up_water').jqxNumberInput('decimal')), |
363 evap_rate: parseFloat($("#evap_rate").jqxNumberInput('decimal')), |
363 trub_chiller_loss: parseFloat($('#trub_chiller_loss').jqxNumberInput('decimal')), |
364 boil_time: parseFloat($("#boil_time").jqxNumberInput('decimal')), |
364 evap_rate: parseFloat($('#evap_rate').jqxNumberInput('decimal')), |
365 calc_boil_volume: $("#calc_boil_volume").val(), |
365 boil_time: parseFloat($('#boil_time').jqxNumberInput('decimal')), |
366 top_up_kettle: parseFloat($("#top_up_kettle").jqxNumberInput('decimal')), |
366 calc_boil_volume: $('#calc_boil_volume').val(), |
367 hop_utilization: parseFloat($("#hop_utilization").jqxNumberInput('decimal')), |
367 top_up_kettle: parseFloat($('#top_up_kettle').jqxNumberInput('decimal')), |
368 notes: $("#notes").val(), |
368 hop_utilization: parseFloat($('#hop_utilization').jqxNumberInput('decimal')), |
369 lauter_volume: parseFloat($("#lauter_volume").jqxNumberInput('decimal')), |
369 notes: $('#notes').val(), |
370 lauter_height: parseFloat($("#lauter_height").jqxNumberInput('decimal')), |
370 lauter_volume: parseFloat($('#lauter_volume').jqxNumberInput('decimal')), |
371 lauter_deadspace: parseFloat($("#lauter_deadspace").jqxNumberInput('decimal')), |
371 lauter_height: parseFloat($('#lauter_height').jqxNumberInput('decimal')), |
372 kettle_volume: parseFloat($("#kettle_volume").jqxNumberInput('decimal')), |
372 lauter_deadspace: parseFloat($('#lauter_deadspace').jqxNumberInput('decimal')), |
373 kettle_height: parseFloat($("#kettle_height").jqxNumberInput('decimal')), |
373 kettle_volume: parseFloat($('#kettle_volume').jqxNumberInput('decimal')), |
374 mash_volume: parseFloat($("#mash_volume").jqxNumberInput('decimal')), |
374 kettle_height: parseFloat($('#kettle_height').jqxNumberInput('decimal')), |
375 mash_max: parseFloat($("#mash_max").jqxNumberInput('decimal')), |
375 mash_volume: parseFloat($('#mash_volume').jqxNumberInput('decimal')), |
376 efficiency: parseFloat($("#efficiency").jqxNumberInput('decimal')) |
376 mash_max: parseFloat($('#mash_max').jqxNumberInput('decimal')), |
377 }; |
377 efficiency: parseFloat($('#efficiency').jqxNumberInput('decimal')) |
378 if (editrow >= 0) { |
378 }; |
379 $('#jqxgrid').jqxGrid('updaterow', rowID, row); |
379 if (editrow >= 0) { |
380 } else { |
380 $('#jqxgrid').jqxGrid('updaterow', rowID, row); |
381 $('#jqxgrid').jqxGrid('addrow', null, row); |
381 } else { |
382 } |
382 $('#jqxgrid').jqxGrid('addrow', null, row); |
383 $("#popupWindow").jqxWindow('hide'); |
383 } |
384 }); |
384 $('#popupWindow').jqxWindow('hide'); |
385 createDelElements(); |
385 }); |
|
386 createDelElements(); |
386 }); |
387 }); |
387 |
388 |