1 /***************************************************************************** |
|
2 * Copyright (C) 2019-2020 |
|
3 * |
|
4 * Michiel Broek <mbroek at mbse dot eu> |
|
5 * |
|
6 * This file is part of BMS |
|
7 * |
|
8 * This is free software; you can redistribute it and/or modify it |
|
9 * under the terms of the GNU General Public License as published by the |
|
10 * Free Software Foundation; either version 2, or (at your option) any |
|
11 * later version. |
|
12 * |
|
13 * BrewCloud is distributed in the hope that it will be useful, but |
|
14 * WITHOUT ANY WARRANTY; without even the implied warranty of |
|
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
16 * General Public License for more details. |
|
17 * |
|
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 |
|
20 * Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. |
|
21 *****************************************************************************/ |
|
22 |
|
23 |
|
24 $(document).ready(function() { |
|
25 |
|
26 var dataRecord = {}, |
|
27 waterInvSource = { |
|
28 datatype: 'json', |
|
29 datafields: [{ name: 'name', type: 'string' }], |
|
30 url: 'getwatersources.php', |
|
31 async: false |
|
32 }, |
|
33 waterlist = new $.jqx.dataAdapter(waterInvSource); |
|
34 url = 'includes/db_setup.php', |
|
35 source = { |
|
36 datatype: 'json', |
|
37 cache: false, |
|
38 datafields: [ |
|
39 { name: 'brewery_name', type: 'string' }, |
|
40 { name: 'factor_mashhop', type: 'number' }, |
|
41 { name: 'factor_fwh', type: 'number' }, |
|
42 { name: 'factor_pellet', type: 'number' }, |
|
43 { name: 'factor_plug', type: 'number' }, |
|
44 { name: 'factor_wethop', type: 'number' }, |
|
45 { name: 'factor_cryohop', type: 'number' }, |
|
46 { name: 'ibu_method', type: 'int' }, |
|
47 { name: 'color_method', type: 'int' }, |
|
48 { name: 'brix_correction', type: 'float' }, |
|
49 { name: 'grain_absorbtion', type: 'float' }, |
|
50 { name: 'default_water', type: 'string' }, |
|
51 { name: 'my_yeastlab', type: 'string' } |
|
52 ], |
|
53 url: url |
|
54 }, |
|
55 dataAdapter = new $.jqx.dataAdapter(source, { |
|
56 loadComplete: function() { |
|
57 var records = dataAdapter.records; |
|
58 dataRecord = records[0]; |
|
59 $('#brewery_name').val(dataRecord.brewery_name); |
|
60 $('#factor_mashhop').val(dataRecord.factor_mashhop); |
|
61 $('#factor_fwh').val(dataRecord.factor_fwh); |
|
62 $('#factor_pellet').val(dataRecord.factor_pellet); |
|
63 $('#factor_plug').val(dataRecord.factor_plug); |
|
64 $('#factor_wethop').val(dataRecord.factor_wethop); |
|
65 $('#factor_cryohop').val(dataRecord.factor_cryohop); |
|
66 $('#color_method').val(dataRecord.color_method); |
|
67 $('#ibu_method').val(dataRecord.ibu_method); |
|
68 $('#brix_correction').val(dataRecord.brix_correction); |
|
69 $('#grain_absorbtion').val(dataRecord.grain_absorbtion); |
|
70 $('#default_water').jqxDropDownList('selectItem', dataRecord.default_water); |
|
71 $('#my_yeastlab').jqxDropDownList('selectItem', dataRecord.my_yeastlab); |
|
72 }, |
|
73 loadError: function(jqXHR, status, error) { |
|
74 }, |
|
75 }); |
|
76 |
|
77 // Tooltips |
|
78 $('#brewery_name').jqxTooltip({ content: 'De naam voor deze brouwerij.' }); |
|
79 $('#factor_mashhop').jqxTooltip({ content: 'Het efficientie percentage voor hop tijdens de maisch.' }); |
|
80 $('#factor_fwh').jqxTooltip({ content: 'Het efficientie percentage voor First Wort Hop.' }); |
|
81 $('#factor_pellet').jqxTooltip({ content: 'Het efficientie percentage bij gebruik van hop pellets.' }); |
|
82 $('#factor_plug').jqxTooltip({ content: 'Het efficientie percentage bij gebruik van hop plugs.' }); |
|
83 $('#factor_wethop').jqxTooltip({ content: 'Het efficientie percentage bij gebruik van nat geplukte hop.' }); |
|
84 $('#factor_cryohop').jqxTooltip({ content: 'Het efficientie percentage bij gebruik van Cryo Hop®.' }); |
|
85 $('#brix_correction').jqxTooltip({ content: 'Omzettingsfactor voor Plato naar Brix' }); |
|
86 $('#grain_absorbtion').jqxTooltip({ content: 'Absorbtie van water door graan (L/Kg)' }); |
|
87 |
|
88 // Editers |
|
89 $('#brewery_name').jqxInput({ theme: theme, width: 640, height: 23 }); |
|
90 $('#factor_fwh').jqxNumberInput({ inputMode: 'simple', theme: theme, width: 110, height: 23, min: -50, max: 50, |
|
91 decimalDigits: 0, spinButtons: true, symbol: '%', symbolPosition: 'right' }); |
|
92 $('#factor_mashhop').jqxNumberInput({ inputMode: 'simple', theme: theme, width: 110, height: 23, min: -50, max: 50, |
|
93 decimalDigits: 0, spinButtons: true, symbol: '%', symbolPosition: 'right' }); |
|
94 $('#factor_pellet').jqxNumberInput({ inputMode: 'simple', theme: theme, width: 110, height: 23, min: 0, max: 20, |
|
95 decimalDigits: 0, spinButtons: true, symbol: '%', symbolPosition: 'right' }); |
|
96 $('#factor_plug').jqxNumberInput({ inputMode: 'simple', theme: theme, width: 110, height: 23, min: 0, max: 20, |
|
97 decimalDigits: 0, spinButtons: true, symbol: '%', symbolPosition: 'right' }); |
|
98 $('#factor_wethop').jqxNumberInput({ inputMode: 'simple', theme: theme, width: 110, height: 23, min: -98, max: -20, |
|
99 decimalDigits: 0, spinButtons: true, symbol: '%', symbolPosition: 'right' }); |
|
100 $('#factor_cryohop').jqxNumberInput({ inputMode: 'simple', theme: theme, width: 110, height: 23, min: -20, max: 150, |
|
101 decimalDigits: 0, spinButtons: true, symbol: '%', symbolPosition: 'right' }); |
|
102 $('#brix_correction').jqxNumberInput({ inputMode: 'simple', theme: theme, width: 110, height: 23, min: 1.00, max: 1.09, decimalDigits: 2, spinButtons: true }); |
|
103 $('#grain_absorbtion').jqxNumberInput({ inputMode: 'simple', theme: theme, width: 110, height: 23, min: 0.5, max: 1.1, decimalDigits: 2, spinButtons: true }); |
|
104 $('#color_method').jqxDropDownList({ |
|
105 theme: theme, |
|
106 source: ColorMethodAdapter, |
|
107 valueMember: 'id', |
|
108 displayMember: 'nl', |
|
109 width: 180, |
|
110 autoDropDownHeight: true |
|
111 }); |
|
112 $('#ibu_method').jqxDropDownList({ |
|
113 theme: theme, |
|
114 source: IBUmethodAdapter, |
|
115 valueMember: 'id', |
|
116 displayMember: 'nl', |
|
117 width: 180, |
|
118 autoDropDownHeight: true |
|
119 }); |
|
120 $('#default_water').jqxDropDownList({ |
|
121 placeHolder: 'Kies water:', |
|
122 theme: theme, |
|
123 source: waterlist, |
|
124 valueMember: 'name', |
|
125 displayMember: 'name', |
|
126 width: 250, |
|
127 dropDownHorizontalAlignment: 'right', |
|
128 dropDownWidth: 300, |
|
129 autoDropDownHeight: true |
|
130 }); |
|
131 $('#my_yeastlab').jqxDropDownList({ |
|
132 placeHolder: 'Mijn gist laboratorium:', |
|
133 theme: theme, |
|
134 source: yeastlablist, |
|
135 valueMember: 'laboratory', |
|
136 displayMember: 'laboratory', |
|
137 width: 250, |
|
138 dropDownHorizontalAlignment: 'right', |
|
139 dropDownWidth: 300, |
|
140 autoDropDownHeight: true |
|
141 }); |
|
142 dataAdapter.dataBind(); |
|
143 |
|
144 $('#Save').jqxButton({ template: 'success', width: '90px', theme: theme }); |
|
145 $('#Save').click(function() { |
|
146 var data, |
|
147 row = { |
|
148 record: 1, |
|
149 brewery_name: $('#brewery_name').val(), |
|
150 factor_mashhop: $('#factor_mashhop').val(), |
|
151 factor_fwh: $('#factor_fwh').val(), |
|
152 factor_pellet: $('#factor_pellet').val(), |
|
153 factor_plug: $('#factor_plug').val(), |
|
154 factor_wethop: $('#factor_wethop').val(), |
|
155 factor_cryohop: $('#factor_cryohop').val(), |
|
156 color_method: $('#color_method').val(), |
|
157 ibu_method: $('#ibu_method').val(), |
|
158 brix_correction: parseFloat($('#brix_correction').jqxNumberInput('decimal')), |
|
159 grain_absorbtion: parseFloat($('#grain_absorbtion').jqxNumberInput('decimal')), |
|
160 default_water: $('#default_water').val(), |
|
161 my_yeastlab: $('#my_yeastlab').val() |
|
162 }; |
|
163 data = 'update=true&' + $.param(row); |
|
164 $.ajax({ |
|
165 dataType: 'json', |
|
166 url: url, |
|
167 cache: false, |
|
168 data: data, |
|
169 type: 'POST', |
|
170 success: function(data) { |
|
171 if (data.error) { |
|
172 console.log('update: ' + data.msg); |
|
173 alert('Fout: ' + data.msg); |
|
174 } else { |
|
175 console.log('update: success'); |
|
176 } |
|
177 }, |
|
178 error: function(jqXHR, textStatus, errorThrown) { |
|
179 } |
|
180 }); |
|
181 }); |
|
182 }); |
|