143 }); |
143 }); |
144 } |
144 } |
145 }; |
145 }; |
146 var dataAdapter = new $.jqx.dataAdapter(source); |
146 var dataAdapter = new $.jqx.dataAdapter(source); |
147 |
147 |
|
148 // Inline fermentables editor |
|
149 var editFermentable = function (data) { |
|
150 var fermentableSource = { |
|
151 localdata: data.fermentables, |
|
152 datatype: "local", |
|
153 datafields: [ |
|
154 { name: 'f_name', type: 'string' }, |
|
155 { name: 'f_origin', type: 'string' }, |
|
156 { name: 'f_supplier', type: 'string' }, |
|
157 { name: 'f_amount', type: 'float' }, |
|
158 { name: 'f_cost', type: 'float' }, |
|
159 { name: 'f_type', type: 'string' }, |
|
160 { name: 'f_yield', type: 'float' }, |
|
161 { name: 'f_color', type: 'float' }, |
|
162 { name: 'f_coarse_fine_diff', type: 'float' }, |
|
163 { name: 'f_moisture', type: 'float' }, |
|
164 { name: 'f_diastatic_power', type: 'float' }, |
|
165 { name: 'f_protein', type: 'float' }, |
|
166 { name: 'f_max_in_batch', type: 'float' }, |
|
167 { name: 'f_graintype', type: 'string' }, |
|
168 { name: 'f_added', type: 'string' }, |
|
169 { name: 'f_dissolved_protein', type: 'float' }, |
|
170 { name: 'f_recommend_mash', type: 'bool' }, |
|
171 { name: 'f_add_after_boil', type: 'bool' }, |
|
172 { name: 'f_adjust_to_total_100', type: 'bool' }, |
|
173 { name: 'f_di_ph', type: 'float' } |
|
174 ], |
|
175 addrow: function (rowid, rowdata, position, commit) { |
|
176 commit(true); |
|
177 }, |
|
178 deleterow: function (rowid, commit) { |
|
179 commit(true); |
|
180 } |
|
181 }; |
|
182 var fermentableAdapter = new $.jqx.dataAdapter(fermentableSource); |
|
183 // dropdownlist datasource from inventory_fermentables |
|
184 var fermentableUrl = "getfermentablesources.php"; |
|
185 var fermentableInvSource = { |
|
186 datatype: "json", |
|
187 datafields: [ |
|
188 { name: 'record', type: 'number' }, |
|
189 { name: 'name', type: 'string' }, |
|
190 { name: 'cost', type: 'float' }, |
|
191 { name: 'type', type: 'string' }, |
|
192 { name: 'yield', type: 'float' }, |
|
193 { name: 'color', type: 'float' }, |
|
194 { name: 'coarse_fine_diff', type: 'float' }, |
|
195 { name: 'moisture', type: 'float' }, |
|
196 { name: 'diastatic_power', type: 'float' }, |
|
197 { name: 'protein', type: 'float' }, |
|
198 { name: 'max_in_batch', type: 'float' }, |
|
199 { name: 'graintype', type: 'string' }, |
|
200 { name: 'added', type: 'string' }, |
|
201 { name: 'dissolved_protein', type: 'float' }, |
|
202 { name: 'adjust_to_total_100', type: 'bool' }, |
|
203 { name: 'di_ph', type: 'float' } |
|
204 ], |
|
205 url: fermentableUrl, |
|
206 async: true |
|
207 }; |
|
208 var fermentablelist = new $.jqx.dataAdapter(fermentableInvSource); |
|
209 |
|
210 $("#fermentableGrid").jqxGrid({ |
|
211 width: 960, |
|
212 height: 400, |
|
213 source: fermentableAdapter, |
|
214 theme: theme, |
|
215 selectionmode: 'singlerow', |
|
216 editmode: 'selectedrow', |
|
217 editable: true, |
|
218 localization: getLocalization(), |
|
219 showtoolbar: true, |
|
220 rendertoolbar: function (toolbar) { |
|
221 var me = this; |
|
222 var container = $("<div style='overflow: hidden; position: relative; margin: 5px;'></div>"); |
|
223 toolbar.append(container); |
|
224 container.append('<div style="float: left; margin-left: 165px;" id="addrowbutton"></div>'); |
|
225 container.append('<input style="float: left; margin-left: 230px;" id="deleterowbutton" type="button" value="Verwijder mout" />'); |
|
226 // add fermentable from dropdownlist. |
|
227 $("#addrowbutton").jqxDropDownList({ |
|
228 placeHolder: "Kies mout:", |
|
229 theme: theme, |
|
230 source: fermentablelist, |
|
231 displayMember: "name", |
|
232 width: 150, |
|
233 height: 27, |
|
234 dropDownWidth: 300 |
|
235 }); |
|
236 $("#addrowbutton").on('select', function (event) { |
|
237 if (event.args) { |
|
238 var index = event.args.index; |
|
239 var datarecord = fermentablelist.records[index]; |
|
240 var row = {}; |
|
241 row["f_name"] = datarecord.name; |
|
242 row["f_amount"] = 0; |
|
243 row["f_cost"] = datarecord.cost; |
|
244 var commit = $("#fermentableGrid").jqxGrid('addrow', null, row); |
|
245 } |
|
246 }); |
|
247 |
|
248 // delete selected fermentable. |
|
249 // Precentage aanpassen basis mout. |
|
250 $("#deleterowbutton").jqxButton({ theme: theme, height: 27, width: 150 }); |
|
251 $("#deleterowbutton").on('click', function () { |
|
252 var selectedrowindex = $("#fermentableGrid").jqxGrid('getselectedrowindex'); |
|
253 var rowscount = $("#fermentableGrid").jqxGrid('getdatainformation').rowscount; |
|
254 if (selectedrowindex >= 0 && selectedrowindex < rowscount) { |
|
255 var id = $("#fermentableGrid").jqxGrid('getrowid', selectedrowindex); |
|
256 var commit = $("#fermentableGrid").jqxGrid('deleterow', id); |
|
257 } |
|
258 }); |
|
259 }, |
|
260 columns: [ |
|
261 { text: 'Mout/suiker', editable: false, datafield: 'f_name' }, |
|
262 { text: 'Type', editable: false, width: 100, datafield: 'f_type' }, |
|
263 { text: 'Gewicht', datafield: 'f_amount', width: 110, align: 'right', cellsalign: 'right', cellsformat: 'f3', |
|
264 columntype: 'numberinput', |
|
265 validation: function (cell, value) { |
|
266 if (value < 0 || value > 100000000000 ) { |
|
267 return { result: false, message: "Volume moet 0-~ zijn" }; |
|
268 } |
|
269 return true; |
|
270 } |
|
271 } |
|
272 ] |
|
273 }) |
|
274 }; |
|
275 |
|
276 // Inline hops editor |
|
277 |
|
278 // Inline miscs editor |
|
279 |
|
280 // Inline yeasts editor |
|
281 |
148 // Inline waters editor |
282 // Inline waters editor |
149 var editWater = function (data) { |
283 var editWater = function (data) { |
150 var waterSource = { |
284 var waterSource = { |
151 localdata: data.waters, |
285 localdata: data.waters, |
152 datatype: "local", |
286 datatype: "local", |
271 { text: 'Cl', editable: false, datafield: 'w_chloride', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'f1' }, |
406 { text: 'Cl', editable: false, datafield: 'w_chloride', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'f1' }, |
272 { text: 'pH', editable: false, datafield: 'w_ph', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'f1' } |
407 { text: 'pH', editable: false, datafield: 'w_ph', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'f1' } |
273 ] |
408 ] |
274 }); |
409 }); |
275 }; // editWater = function (data) { |
410 }; // editWater = function (data) { |
|
411 |
|
412 // inline mash editor |
276 |
413 |
277 // initialize the input fields. |
414 // initialize the input fields. |
278 var srcType = [ "All Grain", "Partial Mash", "Extract" ]; |
415 var srcType = [ "All Grain", "Partial Mash", "Extract" ]; |
279 var srcColor = [ "Morey", "Mosher", "Daniels" ]; |
416 var srcColor = [ "Morey", "Mosher", "Daniels" ]; |
280 var srcIBU = [ "Tinseth", "Rager", "Garetz", "Daniels", "Mosher", "Noonan" ]; |
417 var srcIBU = [ "Tinseth", "Rager", "Garetz", "Daniels", "Mosher", "Noonan" ]; |