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 $(document).ready(function () { |
24 $(document).ready(function() { |
25 |
25 |
26 var dataRecord = {}, |
26 var dataRecord = {}, |
27 // dropdownlist datasource from inventory_waters, must load sync |
27 waterInvSource = { |
28 waterUrl = "getwatersources.php", |
28 datatype: 'json', |
29 waterInvSource = { |
29 datafields: [{ name: 'name', type: 'string' }], |
30 datatype: "json", |
30 url: 'getwatersources.php', |
31 datafields: [ |
31 async: false |
32 { name: 'name', type: 'string' }, |
32 }, |
33 ], |
33 waterlist = new $.jqx.dataAdapter(waterInvSource); |
34 url: waterUrl, |
34 url = 'includes/db_setup.php', |
35 async: false |
35 source = { |
36 }, |
36 datatype: 'json', |
37 waterlist = new $.jqx.dataAdapter(waterInvSource); |
37 cache: false, |
38 url = "includes/db_setup.php", |
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 ], |
|
52 url: url |
|
53 }, |
|
54 dataAdapter = new $.jqx.dataAdapter(source, { |
|
55 loadComplete: function() { |
|
56 var records = dataAdapter.records; |
|
57 dataRecord = records[0]; |
|
58 $('#brewery_name').val(dataRecord.brewery_name); |
|
59 $('#factor_mashhop').val(dataRecord.factor_mashhop); |
|
60 $('#factor_fwh').val(dataRecord.factor_fwh); |
|
61 $('#factor_pellet').val(dataRecord.factor_pellet); |
|
62 $('#factor_plug').val(dataRecord.factor_plug); |
|
63 $('#factor_wethop').val(dataRecord.factor_wethop); |
|
64 $('#factor_cryohop').val(dataRecord.factor_cryohop); |
|
65 $('#color_method').val(dataRecord.color_method); |
|
66 $('#ibu_method').val(dataRecord.ibu_method); |
|
67 $('#brix_correction').val(dataRecord.brix_correction); |
|
68 $('#grain_absorbtion').val(dataRecord.grain_absorbtion); |
|
69 }, |
|
70 loadError: function(jqXHR, status, error) { |
|
71 }, |
|
72 }); |
39 |
73 |
40 // Prepare the data |
74 dataAdapter.dataBind(); |
41 source = { |
|
42 datatype: "json", |
|
43 cache: false, |
|
44 datafields: [ |
|
45 { name: 'brewery_name', type: 'string' }, |
|
46 { name: 'factor_mashhop', type: 'number' }, |
|
47 { name: 'factor_fwh', type: 'number' }, |
|
48 { name: 'factor_pellet', type: 'number' }, |
|
49 { name: 'factor_plug', type: 'number' }, |
|
50 { name: 'factor_wethop', type: 'number' }, |
|
51 { name: 'factor_cryohop', type: 'number' }, |
|
52 { name: 'ibu_method', type: 'int' }, |
|
53 { name: 'color_method', type: 'int' }, |
|
54 { name: 'brix_correction', type: 'float' }, |
|
55 { name: 'grain_absorbtion', type: 'float' }, |
|
56 { name: 'default_water', type: 'string' } |
|
57 ], |
|
58 url: url |
|
59 }, |
|
60 |
75 |
61 // Load data and select one record. |
76 // Tooltips |
62 dataAdapter = new $.jqx.dataAdapter(source, { |
77 $('#brewery_name').jqxTooltip({ content: 'De naam voor deze brouwerij.' }); |
63 loadComplete: function () { |
78 $('#factor_mashhop').jqxTooltip({ content: 'Het efficientie percentage voor hop tijdens de maisch.' }); |
64 var records = dataAdapter.records; |
79 $('#factor_fwh').jqxTooltip({ content: 'Het efficientie percentage voor First Wort Hop.' }); |
65 dataRecord = records[0]; |
80 $('#factor_pellet').jqxTooltip({ content: 'Het efficientie percentage bij gebruik van hop pellets.' }); |
66 $("#brewery_name").val(dataRecord.brewery_name); |
81 $('#factor_plug').jqxTooltip({ content: 'Het efficientie percentage bij gebruik van hop plugs.' }); |
67 $("#factor_mashhop").val(dataRecord.factor_mashhop); |
82 $('#factor_wethop').jqxTooltip({ content: 'Het efficientie percentage bij gebruik van nat geplukte hop.' }); |
68 $("#factor_fwh").val(dataRecord.factor_fwh); |
83 $('#factor_cryohop').jqxTooltip({ content: 'Het efficientie percentage bij gebruik van Cryo Hop®.' }); |
69 $("#factor_pellet").val(dataRecord.factor_pellet); |
84 $('#brix_correction').jqxTooltip({ content: 'Omzettingsfactor voor Plato naar Brix' }); |
70 $("#factor_plug").val(dataRecord.factor_plug); |
85 $('#grain_absorbtion').jqxTooltip({ content: 'Absorbtie van water door graan (L/Kg)' }); |
71 $("#factor_wethop").val(dataRecord.factor_wethop); |
|
72 $("#factor_cryohop").val(dataRecord.factor_cryohop); |
|
73 $("#color_method").val(dataRecord.color_method); |
|
74 $("#ibu_method").val(dataRecord.ibu_method); |
|
75 $("#brix_correction").val(dataRecord.brix_correction); |
|
76 $("#grain_absorbtion").val(dataRecord.grain_absorbtion); |
|
77 }, |
|
78 loadError: function (jqXHR, status, error) { |
|
79 }, |
|
80 }); |
|
81 |
86 |
82 dataAdapter.dataBind(); |
87 // Editers |
|
88 $('#brewery_name').jqxInput({ theme: theme, width: 640, height: 23 }); |
|
89 $('#factor_fwh').jqxNumberInput({ inputMode: 'simple', theme: theme, width: 110, height: 23, min: -50, max: 50, |
|
90 decimalDigits: 0, spinButtons: true, symbol: '%', symbolPosition: 'right' }); |
|
91 $('#factor_mashhop').jqxNumberInput({ inputMode: 'simple', theme: theme, width: 110, height: 23, min: -50, max: 50, |
|
92 decimalDigits: 0, spinButtons: true, symbol: '%', symbolPosition: 'right' }); |
|
93 $('#factor_pellet').jqxNumberInput({ inputMode: 'simple', theme: theme, width: 110, height: 23, min: 0, max: 20, |
|
94 decimalDigits: 0, spinButtons: true, symbol: '%', symbolPosition: 'right' }); |
|
95 $('#factor_plug').jqxNumberInput({ inputMode: 'simple', theme: theme, width: 110, height: 23, min: 0, max: 20, |
|
96 decimalDigits: 0, spinButtons: true, symbol: '%', symbolPosition: 'right' }); |
|
97 $('#factor_wethop').jqxNumberInput({ inputMode: 'simple', theme: theme, width: 110, height: 23, min: -98, max: -20, |
|
98 decimalDigits: 0, spinButtons: true, symbol: '%', symbolPosition: 'right' }); |
|
99 $('#factor_cryohop').jqxNumberInput({ inputMode: 'simple', theme: theme, width: 110, height: 23, min: -20, max: 150, |
|
100 decimalDigits: 0, spinButtons: true, symbol: '%', symbolPosition: 'right' }); |
|
101 $('#brix_correction').jqxNumberInput({ inputMode: 'simple', theme: theme, width: 110, height: 23, min: 1.00, max: 1.05, decimalDigits: 2, spinButtons: true }); |
|
102 $('#grain_absorbtion').jqxNumberInput({ inputMode: 'simple', theme: theme, width: 110, height: 23, min: 0.5, max: 1.1, decimalDigits: 2, spinButtons: true }); |
|
103 $('#color_method').jqxDropDownList({ |
|
104 theme: theme, |
|
105 source: ColorMethodAdapter, |
|
106 valueMember: 'id', |
|
107 displayMember: 'nl', |
|
108 width: 180, |
|
109 autoDropDownHeight: true |
|
110 }); |
|
111 $('#ibu_method').jqxDropDownList({ |
|
112 theme: theme, |
|
113 source: IBUmethodAdapter, |
|
114 valueMember: 'id', |
|
115 displayMember: 'nl', |
|
116 width: 180, |
|
117 autoDropDownHeight: true |
|
118 }); |
|
119 $('#default_water').jqxDropDownList({ |
|
120 placeHolder: 'Kies water:', |
|
121 theme: theme, |
|
122 source: waterlist, |
|
123 valueMember: 'name', |
|
124 displayMember: 'name', |
|
125 width: 250, |
|
126 dropDownHorizontalAlignment: 'right', |
|
127 dropDownWidth: 300, |
|
128 autoDropDownHeight: true |
|
129 }); |
|
130 $('#default_water').jqxDropDownList('selectItem', dataRecord.default_water); |
83 |
131 |
84 // Tooltips |
132 $('#Save').jqxButton({ template: 'success', width: '90px', theme: theme }); |
85 $("#brewery_name").jqxTooltip({ content: 'De naam voor deze brouwerij.' }); |
133 $('#Save').click(function() { |
86 $("#factor_mashhop").jqxTooltip({ content: 'Het efficientie percentage voor hop tijdens de maisch.' }); |
134 var data, |
87 $("#factor_fwh").jqxTooltip({ content: 'Het efficientie percentage voor First Wort Hop.' }); |
135 row = { |
88 $("#factor_pellet").jqxTooltip({ content: 'Het efficientie percentage bij gebruik van hop pellets.' }); |
136 record: 1, |
89 $("#factor_plug").jqxTooltip({ content: 'Het efficientie percentage bij gebruik van hop plugs.' }); |
137 brewery_name: $('#brewery_name').val(), |
90 $("#factor_wethop").jqxTooltip({ content: 'Het efficientie percentage bij gebruik van nat geplukte hop.' }); |
138 factor_mashhop: $('#factor_mashhop').val(), |
91 $("#factor_cryohop").jqxTooltip({ content: 'Het efficientie percentage bij gebruik van Cryo Hop®.' }); |
139 factor_fwh: $('#factor_fwh').val(), |
92 $("#brix_correction").jqxTooltip({ content: 'Omzettingsfactor voor Plato naar Brix' }); |
140 factor_pellet: $('#factor_pellet').val(), |
93 $("#grain_absorbtion").jqxTooltip({ content: 'Absorbtie van water door graan (L/Kg)' }); |
141 factor_plug: $('#factor_plug').val(), |
94 |
142 factor_wethop: $('#factor_wethop').val(), |
95 // Editers |
143 factor_cryohop: $('#factor_cryohop').val(), |
96 $("#brewery_name").jqxInput({ theme: theme, width: 640, height: 23 }); |
144 color_method: $('#color_method').val(), |
97 $("#factor_fwh").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 110, height: 23, min: -50, max: 50, decimalDigits: 0, spinButtons: true, symbol: '%', symbolPosition: 'right' }); |
145 ibu_method: $('#ibu_method').val(), |
98 $("#factor_mashhop").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 110, height: 23, min: -50, max: 50, decimalDigits: 0, spinButtons: true, symbol: '%', symbolPosition: 'right' }); |
146 brix_correction: parseFloat($('#brix_correction').jqxNumberInput('decimal')), |
99 $("#factor_pellet").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 110, height: 23, min: 0, max: 20, decimalDigits: 0, spinButtons: true, symbol: '%', symbolPosition: 'right' }); |
147 grain_absorbtion: parseFloat($('#grain_absorbtion').jqxNumberInput('decimal')), |
100 $("#factor_plug").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 110, height: 23, min: 0, max: 20, decimalDigits: 0, spinButtons: true, symbol: '%', symbolPosition: 'right' }); |
148 default_water: $('#default_water').val() |
101 $("#factor_wethop").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 110, height: 23, min: -98, max: -20, decimalDigits: 0, spinButtons: true, symbol: '%', symbolPosition: 'right' }); |
149 }; |
102 $("#factor_cryohop").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 110, height: 23, min: -20, max: 150, decimalDigits: 0, spinButtons: true, symbol: '%', symbolPosition: 'right' }); |
150 data = 'update=true&' + $.param(row); |
103 $("#brix_correction").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 110, height: 23, min: 1.00, max: 1.05, decimalDigits: 2, spinButtons: true }); |
151 $.ajax({ |
104 $("#grain_absorbtion").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 110, height: 23, min: 0.5, max: 1.1, decimalDigits: 2, spinButtons: true }); |
152 dataType: 'json', |
105 $("#color_method").jqxDropDownList({ |
153 url: url, |
106 theme: theme, |
154 cache: false, |
107 source: ColorMethodAdapter, |
155 data: data, |
108 valueMember: 'id', |
156 type: 'POST', |
109 displayMember: 'nl', |
157 success: function(data, status, xhr) { |
110 width: 180, |
158 }, |
111 autoDropDownHeight: true |
159 error: function(jqXHR, textStatus, errorThrown) { |
112 }); |
160 } |
113 $("#ibu_method").jqxDropDownList({ |
161 }); |
114 theme: theme, |
162 }); |
115 source: IBUmethodAdapter, |
|
116 valueMember: 'id', |
|
117 displayMember: 'nl', |
|
118 width: 180, |
|
119 autoDropDownHeight: true |
|
120 }); |
|
121 $('#default_water').jqxDropDownList({ |
|
122 placeHolder: "Kies water:", |
|
123 theme: theme, |
|
124 source: waterlist, |
|
125 valueMember: "name", |
|
126 displayMember: "name", |
|
127 width: 250, |
|
128 dropDownHorizontalAlignment: 'right', |
|
129 dropDownWidth: 300, |
|
130 autoDropDownHeight: true |
|
131 }); |
|
132 $('#default_water').jqxDropDownList( 'selectItem', dataRecord.default_water ); |
|
133 |
|
134 $("#Save").jqxButton({ template: "success", width: '90px', theme: theme }); |
|
135 $("#Save").click(function () { |
|
136 var data, |
|
137 row = { |
|
138 record: 1, |
|
139 brewery_name: $("#brewery_name").val(), |
|
140 factor_mashhop: $("#factor_mashhop").val(), |
|
141 factor_fwh: $("#factor_fwh").val(), |
|
142 factor_pellet: $("#factor_pellet").val(), |
|
143 factor_plug: $("#factor_plug").val(), |
|
144 factor_wethop: $("#factor_wethop").val(), |
|
145 factor_cryohop: $("#factor_cryohop").val(), |
|
146 color_method: $("#color_method").val(), |
|
147 ibu_method: $("#ibu_method").val(), |
|
148 brix_correction: parseFloat($("#brix_correction").jqxNumberInput('decimal')), |
|
149 grain_absorbtion: parseFloat($("#grain_absorbtion").jqxNumberInput('decimal')), |
|
150 default_water: $("#default_water").val() |
|
151 }; |
|
152 data = "update=true&" + $.param(row); |
|
153 $.ajax({ |
|
154 dataType: 'json', |
|
155 url: url, |
|
156 cache: false, |
|
157 data: data, |
|
158 type: "POST", |
|
159 success: function (data, status, xhr) { |
|
160 // update command is executed. |
|
161 //window.location.href = my_return; |
|
162 }, |
|
163 error: function(jqXHR, textStatus, errorThrown) { |
|
164 } |
|
165 }); |
|
166 }); |
|
167 }); |
163 }); |