www/js/recipes.js

changeset 51
7224109adfe1
parent 50
6d94167c2697
child 52
b1f2a893572f
equal deleted inserted replaced
50:6d94167c2697 51:7224109adfe1
45 $(document).ready(function () { 45 $(document).ready(function () {
46 var url = "includes/db_recipes.php"; 46 var url = "includes/db_recipes.php";
47 // tooltips 47 // tooltips
48 $("#name").jqxTooltip({ content: 'De naam voor dit recept.' }); 48 $("#name").jqxTooltip({ content: 'De naam voor dit recept.' });
49 $("#notes").jqxTooltip({ content: 'De uitgebreide opmerkingen over dit recept.' }); 49 $("#notes").jqxTooltip({ content: 'De uitgebreide opmerkingen over dit recept.' });
50 $("#style_name").jqxTooltip({ content: 'De bierstijl naam voor dit recept.'}); 50 $("#st_name").jqxTooltip({ content: 'De bierstijl naam voor dit recept.'});
51 $("#type").jqxTooltip({ content: 'Het brouw type van dit recept.' }); 51 $("#type").jqxTooltip({ content: 'Het brouw type van dit recept.' });
52 // prepare the data 52 // prepare the data
53 var source = { 53 var source = {
54 datatype: "json", 54 datatype: "json",
55 cache: false, 55 cache: false,
56 datafields: [ 56 datafields: [
57 { name: 'record', type: 'number' }, 57 { name: 'record', type: 'number' },
58 { name: 'style_name', type: 'string' }, 58 { name: 'st_name', type: 'string' },
59 { name: 'style_letter', type: 'string' }, 59 { name: 'st_letter', type: 'string' },
60 { name: 'style_guide', type: 'string' }, 60 { name: 'st_guide', type: 'string' },
61 { name: 'st_og_min', type: 'float' },
62 { name: 'st_og_max', type: 'float' },
61 { name: 'name', type: 'string' }, 63 { name: 'name', type: 'string' },
62 { name: 'notes', type: 'string' }, 64 { name: 'notes', type: 'string' },
63 { name: 'type', type: 'number' }, 65 { name: 'type', type: 'number' },
64 { name: 'batch_size', type: 'float' }, 66 { name: 'batch_size', type: 'float' },
65 { name: 'boil_time', type: 'float' }, 67 { name: 'boil_time', type: 'float' },
68 { name: 'est_fg', type: 'float' }, 70 { name: 'est_fg', type: 'float' },
69 { name: 'est_color', type: 'float' }, 71 { name: 'est_color', type: 'float' },
70 { name: 'color_method', type: 'string' }, 72 { name: 'color_method', type: 'string' },
71 { name: 'est_ibu', type: 'float' }, 73 { name: 'est_ibu', type: 'float' },
72 { name: 'ibu_method', type: 'string' }, 74 { name: 'ibu_method', type: 'string' },
73 { name: 'json_fermentables', type: 'string' }, 75 { name: 'mash_sparge_temp', type: 'float' },
74 { name: 'json_hops', type: 'string' }, 76 { name: 'mash_ph', type: 'float' },
75 { name: 'json_miscs', type: 'string' }, 77 { name: 'mash_name', type: 'string' },
76 { name: 'json_yeasts', type: 'string' }, 78 { name: 'fermentables', type: 'string' },
77 { name: 'json_waters', type: 'string' }, 79 { name: 'hops', type: 'string' },
78 { name: 'json_mash', type: 'string' } 80 { name: 'miscs', type: 'string' },
81 { name: 'yeasts', type: 'string' },
82 { name: 'waters', type: 'array' },
83 { name: 'mashs', type: 'string' }
79 ], 84 ],
80 id: 'record', 85 id: 'record',
81 url: url, 86 url: url,
82 deleterow: function (rowid, commit) { 87 deleterow: function (rowid, commit) {
83 // synchronize with the server - send delete command 88 // synchronize with the server - send delete command
127 } 132 }
128 }); 133 });
129 } 134 }
130 }; 135 };
131 var dataAdapter = new $.jqx.dataAdapter(source); 136 var dataAdapter = new $.jqx.dataAdapter(source);
132 // Inline steps editor 137
133 /* var editsteps = function (data) { 138 // Inline waters editor
134 var generaterow = function () { 139 var editWater = function (data) {
135 var row = {}; 140 // var generaterow = function () {
136 row["step_name"] = "Stap 1"; 141 // var row = {};
137 row["step_type"] = "Infusion"; 142 // row["w_name"] = "Water 1";
138 row["step_temp"] = 62.0; 143 // row["step_type"] = "Infusion";
139 row['step_time'] = 20.0; 144 // row["w_amount"] = 22.0;
140 row['ramp_time'] = 1.0; 145 // row['step_time'] = 20.0;
141 row['end_temp'] = 62.0; 146 // row['ramp_time'] = 1.0;
142 return row; 147 // row['end_temp'] = 62.0;
143 } 148 // return row;
144 var stepSource = { 149 // }
145 localdata: data.steps, 150 var waterSource = {
151 localdata: data.waters,
146 datatype: "local", 152 datatype: "local",
147 datafields: [ 153 datafields: [
148 { name: 'step_name', type: 'string' }, 154 { name: 'w_name', type: 'string' },
149 { name: 'step_type', type: 'string' }, 155 { name: 'w_amount', type: 'float' },
150 { name: 'step_temp', type: 'float' }, 156 { name: 'w_calcium', type: 'float' },
151 { name: 'step_time', type: 'float' }, 157 { name: 'w_bicarbonate', type: 'float' },
152 { name: 'ramp_time', type: 'float' }, 158 { name: 'w_sulfate', type: 'float' },
153 { name: 'end_temp', type: 'float' } 159 { name: 'w_chloride', type: 'float' },
160 { name: 'w_sodium', type: 'float' },
161 { name: 'w_magnesium', type: 'float' },
162 { name: 'w_ph', type: 'float' },
163 { name: 'w_total_alkalinity', type: 'float' },
164 { name: 'w_cost', type: 'float' },
165 { name: 'w_default_water', type: 'bool' }
154 ], 166 ],
155 addrow: function (rowid, rowdata, position, commit) { 167 addrow: function (rowid, rowdata, position, commit) {
156 commit(true); 168 commit(true);
157 }, 169 },
158 deleterow: function (rowid, commit) { 170 deleterow: function (rowid, commit) {
159 commit(true); 171 commit(true);
160 } 172 }
161 }; 173 };
162 var stepAdapter = new $.jqx.dataAdapter(stepSource); 174 var waterAdapter = new $.jqx.dataAdapter(waterSource);
163 $("#grid").jqxGrid({ 175 $("#waterGrid").jqxGrid({
164 width: 640, 176 width: 960,
165 height: 330, 177 height: 200,
166 source: stepAdapter, 178 source: waterAdapter,
167 theme: theme, 179 theme: theme,
168 selectionmode: 'singlerow', 180 selectionmode: 'singlerow',
169 editmode: 'selectedrow', 181 editmode: 'selectedrow',
170 editable: true, 182 editable: true,
183 showstatusbar: true,
184 statusbarheight: 50,
185 showaggregates: true,
171 showtoolbar: true, 186 showtoolbar: true,
172 rendertoolbar: function (toolbar) { 187 rendertoolbar: function (toolbar) {
173 var me = this; 188 var me = this;
174 var container = $("<div style='margin: 5px;'></div>"); 189 var container = $("<div style='margin: 5px;'></div>");
175 toolbar.append(container); 190 toolbar.append(container);
176 container.append('<input style="margin-left: 100px;" id="addrowbutton" type="button" value="Nieuwe stap" />'); 191 container.append('<input style="margin-left: 100px;" id="addrowbutton" type="button" value="Nieuwe stap" />');
177 container.append('<input style="margin-left: 140px;" id="deleterowbutton" type="button" value="Verwijder stap" />'); 192 container.append('<input style="margin-left: 140px;" id="deleterowbutton" type="button" value="Verwijder stap" />');
178 $("#addrowbutton").jqxButton({ theme: theme, width: 150 }); 193 $("#addrowbutton").jqxButton({ theme: theme, width: 150 });
179 $("#deleterowbutton").jqxButton({ theme: theme, width: 150 }); 194 $("#deleterowbutton").jqxButton({ theme: theme, width: 150 });
180 // create new row. 195 // create new row. Dropdown uit water inventory.
181 $("#addrowbutton").on('click', function () { 196 // $("#addrowbutton").on('click', function () {
182 var datarow = generaterow(); 197 // var datarow = generaterow();
183 var commit = $("#grid").jqxGrid('addrow', null, datarow); 198 // var commit = $("#waterGrid").jqxGrid('addrow', null, datarow);
184 }); 199 // });
185 // delete row. 200 // delete row.
186 $("#deleterowbutton").on('click', function () { 201 // Overgebleven waters in volume verhogen met het verwijderde water.
187 var selectedrowindex = $("#grid").jqxGrid('getselectedrowindex'); 202 // $("#deleterowbutton").on('click', function () {
188 var rowscount = $("#grid").jqxGrid('getdatainformation').rowscount; 203 // var selectedrowindex = $("#grid").jqxGrid('getselectedrowindex');
189 if (selectedrowindex >= 0 && selectedrowindex < rowscount) { 204 // var rowscount = $("#grid").jqxGrid('getdatainformation').rowscount;
190 var id = $("#grid").jqxGrid('getrowid', selectedrowindex); 205 // if (selectedrowindex >= 0 && selectedrowindex < rowscount) {
191 var commit = $("#grid").jqxGrid('deleterow', id); 206 // var id = $("#grid").jqxGrid('getrowid', selectedrowindex);
192 } 207 // var commit = $("#grid").jqxGrid('deleterow', id);
193 }); 208 // }
209 // });
194 }, 210 },
195 columns: [ 211 columns: [
196 { text: 'Stap naam', datafield: 'step_name' }, 212 { text: 'Water bron', editable: false, datafield: 'w_name' },
197 { text: 'Stap type', datafield: 'step_type', width: 100, columntype: 'dropdownlist', 213 { text: 'Volume', datafield: 'w_amount', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'f1',
198 createeditor: function (row, cellvalue, editor, celltext, cellwidth, cellheight) { 214 columntype: 'numberinput',
199 var dataSource = [ "Infusion", "Temperature", "Decoction" ]; 215 aggregates: ['sum'],
200 editor.jqxDropDownList({ source: dataSource, dropDownHeight: 95 });
201 }
202 },
203 { text: 'Temperatuur', datafield: 'step_temp', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'f1',
204 validation: function (cell, value) { 216 validation: function (cell, value) {
205 if (value < 35 || value > 80) { 217 if (value < 0 || value > 100000000000 ) {
206 return { result: false, message: "De temperatuur moet tussen 35 en 80 zijn." }; 218 return { result: false, message: "Volume moet 0-~ zijn" };
207 } 219 }
208 return true; 220 return true;
209 } 221 }
210 }, 222 },
211 { text: 'Eind', datafield: 'end_temp', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'f1', 223 // TODO: validator test max is hoeveelheid maischwater. Dan water verdelen voor totaal.
212 validation: function (cell, value) { 224 { text: 'Ca', editable: false, datafield: 'w_calcium', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'f1' },
213 if (value < 35 || value > 80) { 225 { text: 'Mg', editable: false, datafield: 'w_magnesium', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'f1' },
214 return { result: false, message: "De temperatuur moet tussen 35 en 80 zijn." }; 226 { text: 'Na', editable: false, datafield: 'w_sodium', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'f1' },
215 } 227 { text: 'Tot Alk', editable: false, datafield: 'w_total_alkalinity', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'f1' },
216 return true; 228 { text: 'CaSO4', editable: false, datafield: 'w_sulfate', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'f1' },
217 } 229 { text: 'Cl', editable: false, datafield: 'w_chloride', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'f1' },
218 }, 230 { text: 'pH', editable: false, datafield: 'w_ph', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'f1' }
219 { text: 'Tijd', datafield: 'step_time', width: 70, align: 'right', cellsalign: 'right',
220 validation: function (cell, value) {
221 if (value < 1 || value > 360) {
222 return { result: false, message: "De tijd moet tussen 1 en 360 zijn." };
223 }
224 return true;
225 }
226 },
227 { text: 'Stap', datafield: 'ramp_time', width: 70, align: 'right', cellsalign: 'right',
228 validation: function (cell, value) {
229 if (value < 1 || value > 60) {
230 return { result: false, message: "De tijd moet tussen 1 en 60 zijn." };
231 }
232 return true;
233 }
234 }
235 ] 231 ]
236 }); 232 });
237 $("#grid").on('cellendedit', function (event) { 233 // $("#grid").on('cellendedit', function (event) {
238 $('#grid').jqxGrid('sortby', 'step_temp', 'asc'); 234 // $('#grid').jqxGrid('sortby', 'step_temp', 'asc');
239 }); 235 // });
240 }; 236 }; // editWater = function (data) {
241 */ 237
242 // initialize the input fields. 238 // initialize the input fields.
243 var srcType = [ "All Grain", "Partial Mash", "Extract" ]; 239 var srcType = [ "All Grain", "Partial Mash", "Extract" ];
244 var srcColor = [ "Morey", "Mosher", "Daniels" ]; 240 var srcColor = [ "Morey", "Mosher", "Daniels" ];
245 var srcIBU = [ "Tinseth", "Rager", "Garetz", "Daniels", "Mosher", "Noonan" ]; 241 var srcIBU = [ "Tinseth", "Rager", "Garetz", "Daniels", "Mosher", "Noonan" ];
246 $("#name").jqxInput({ theme: theme, width: 640, height: 23 }); 242 $("#name").jqxInput({ theme: theme, width: 640, height: 23 });
247 $("#notes").jqxInput({ theme: theme, width: 960, height: 200 }); 243 $("#notes").jqxInput({ theme: theme, width: 960, height: 200 });
248 $("#style_name").jqxInput({ theme: theme, width: 250, height: 23 }); 244 $("#st_name").jqxInput({ theme: theme, width: 250, height: 23 });
249 $("#style_letter").jqxInput({ theme: theme, width: 100, height: 23 }); 245 $("#st_letter").jqxInput({ theme: theme, width: 100, height: 23 });
250 $("#style_guide").jqxInput({ theme: theme, width: 250, height: 23 }); 246 $("#st_guide").jqxInput({ theme: theme, width: 250, height: 23 });
251 $("#type").jqxDropDownList({ theme: theme, source: srcType, width: 125, height: 23, dropDownHeight: 95 }); 247 $("#type").jqxDropDownList({ theme: theme, source: srcType, width: 125, height: 23, dropDownHeight: 95 });
252 $("#batch_size").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: 4, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.1, symbol: 'L', symbolPosition: 'right' }); 248 $("#batch_size").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: 4, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.1, symbol: 'L', symbolPosition: 'right' });
253 $("#boil_time").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', template: "success", theme: theme, width: 100, height: 23, min: 4, max: 360, decimalDigits: 0, spinButtons: true }); 249 $("#boil_time").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', template: "success", theme: theme, width: 100, height: 23, min: 4, max: 360, decimalDigits: 0, spinButtons: true });
254 $("#efficiency").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: 40, max: 100, decimalDigits: 0, spinButtons: true, symbol: '%', symbolPosition: 'right' }); 250 $("#efficiency").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: 40, max: 100, decimalDigits: 0, spinButtons: true, symbol: '%', symbolPosition: 'right' });
255 $("#est_og").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: 1, max: 1.9, decimalDigits: 3, spinButtons: true, spinButtonsStep: 0.001 }); 251 $("#est_og").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: 1, max: 1.9, decimalDigits: 3, spinButtons: true, spinButtonsStep: 0.001 });
252 $("#st_og_min").jqxNumberInput({ disabled: true, inputMode: 'simple', width: 50, height: 23, decimalDigits: 3, readOnly: true });
253 $("#st_og_max").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 3, readOnly: true });
256 $("#est_fg").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 100, height: 23, min: 0.980, max: 1.040, decimalDigits: 3, readOnly: true }); 254 $("#est_fg").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 100, height: 23, min: 0.980, max: 1.040, decimalDigits: 3, readOnly: true });
257 $("#est_color").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: 1, max: 200, decimalDigits: 0, spinButtons: true }); 255 $("#est_color").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: 1, max: 200, decimalDigits: 0, spinButtons: true });
258 $("#color_method").jqxDropDownList({ theme: theme, source: srcColor, width: 125, height: 23, dropDownHeight: 95 }); 256 $("#color_method").jqxDropDownList({ theme: theme, source: srcColor, width: 125, height: 23, dropDownHeight: 95 });
259 $("#est_ibu").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: 0, max: 200, decimalDigits: 0, spinButtons: true }); 257 $("#est_ibu").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: 0, max: 200, decimalDigits: 0, spinButtons: true });
260 $("#ibu_method").jqxDropDownList({ theme: theme, source: srcIBU, width: 125, height: 23, dropDownHeight: 180 }); 258 $("#ibu_method").jqxDropDownList({ theme: theme, source: srcIBU, width: 125, height: 23, dropDownHeight: 180 });
259 $("#mash_name").jqxInput({ theme: theme, width: 320, height: 23 });
260 $("#mash_ph").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: 4, max: 8, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.1 });
261 var editrow = -1; 261 var editrow = -1;
262 // initialize jqxGrid 262 // initialize jqxGrid
263 $("#jqxgrid").jqxGrid({ 263 $("#jqxgrid").jqxGrid({
264 width: 1280, 264 width: 1280,
265 height: 630, 265 height: 630,
278 addButton.click(function (event) { 278 addButton.click(function (event) {
279 editrow = -1; 279 editrow = -1;
280 $("#popupWindow").jqxWindow({ position: { x: 40, y: 20 } }); 280 $("#popupWindow").jqxWindow({ position: { x: 40, y: 20 } });
281 $("#name").val(''); 281 $("#name").val('');
282 $("#notes").val(''); 282 $("#notes").val('');
283 $("#style_name").val(''); 283 $("#st_name").val('');
284 $("#style_letter").val(''); 284 $("#st_letter").val('');
285 $("#style_guide").val(''); 285 $("#st_guide").val('');
286 $("#type").val('All Grain'); 286 $("#type").val('All Grain');
287 $("#batch_size").val(20); 287 $("#batch_size").val(20);
288 $("#boil_time").val(90); 288 $("#boil_time").val(90);
289 $("#efficiency").val(75); 289 $("#efficiency").val(75);
290 $("#est_og").val(1.062); 290 $("#est_og").val(1.062);
291 $("#est_fg").val(1.000); 291 $("#est_fg").val(1.000);
292 $("#est_color").val(0); 292 $("#est_color").val(0);
293 $("#color_method").val('Morey'); 293 $("#color_method").val('Morey');
294 $("#est_ibu").val(0); 294 $("#est_ibu").val(0);
295 $("#ibu_method").val('Tinseth'); 295 $("#ibu_method").val('Tinseth');
296 // editsteps(''); 296 editWater('');
297 $("#popupWindow").jqxWindow('open'); 297 $("#popupWindow").jqxWindow('open');
298 }); 298 });
299 }, 299 },
300 filterable: true, 300 filterable: true,
301 filtermode: 'excel', 301 filtermode: 'excel',
302 columns: [ 302 columns: [
303 { text: 'Stijlgids', datafield: 'style_guide', width: 120 }, 303 { text: 'Stijlgids', datafield: 'st_guide', width: 120 },
304 { text: 'Letter', datafield: 'style_letter', width: 60 }, 304 { text: 'Letter', datafield: 'st_letter', width: 60 },
305 { text: 'Stijl', datafield: 'style_name', width: 150 }, 305 { text: 'Stijl', datafield: 'st_name', width: 150 },
306 { text: 'Naam', datafield: 'name' }, 306 { text: 'Naam', datafield: 'name' },
307 { text: 'OG', datafield: 'est_og', width: 60, align: 'right', cellsalign: 'right', cellsformat: 'f3' }, 307 { text: 'OG', datafield: 'est_og', width: 60, align: 'right', cellsalign: 'right', cellsformat: 'f3' },
308 { text: 'EBC', datafield: 'est_color', width: 60, align: 'right', cellsalign: 'right', cellsformat: 'f0' }, 308 { text: 'EBC', datafield: 'est_color', width: 60, align: 'right', cellsalign: 'right', cellsformat: 'f0' },
309 { text: 'IBU', datafield: 'est_ibu', width: 60, align: 'right', cellsalign: 'right', cellsformat: 'f0' }, 309 { text: 'IBU', datafield: 'est_ibu', width: 60, align: 'right', cellsalign: 'right', cellsformat: 'f0' },
310 { text: 'Wijzig', datafield: 'Edit', width: 120, align: 'center', columntype: 'button', cellsrenderer: function () { 310 { text: 'Wijzig', datafield: 'Edit', width: 120, align: 'center', columntype: 'button', cellsrenderer: function () {
315 $("#popupWindow").jqxWindow({ position: { x: 40, y: 20 } }); 315 $("#popupWindow").jqxWindow({ position: { x: 40, y: 20 } });
316 // get the clicked row's data and initialize the input fields. 316 // get the clicked row's data and initialize the input fields.
317 var dataRecord = $("#jqxgrid").jqxGrid('getrowdata', editrow); 317 var dataRecord = $("#jqxgrid").jqxGrid('getrowdata', editrow);
318 $("#name").val(dataRecord.name); 318 $("#name").val(dataRecord.name);
319 $("#notes").val(dataRecord.notes); 319 $("#notes").val(dataRecord.notes);
320 $("#style_name").val(dataRecord.style_name); 320 $("#st_name").val(dataRecord.st_name);
321 $("#style_letter").val(dataRecord.style_letter); 321 $("#st_letter").val(dataRecord.st_letter);
322 $("#style_guide").val(dataRecord.style_guide); 322 $("#st_guide").val(dataRecord.st_guide);
323 $("#type").val(dataRecord.type); 323 $("#type").val(dataRecord.type);
324 $("#batch_size").val(dataRecord.batch_size); 324 $("#batch_size").val(dataRecord.batch_size);
325 $("#boil_time").val(dataRecord.boil_time); 325 $("#boil_time").val(dataRecord.boil_time);
326 $("#efficiency").val(dataRecord.efficiency); 326 $("#efficiency").val(dataRecord.efficiency);
327 $("#est_og").val(dataRecord.est_og); 327 $("#est_og").val(dataRecord.est_og);
328 $("#st_og_min").val(dataRecord.st_og_min);
329 $("#st_og_max").val(dataRecord.st_og_max);
328 $("#est_fg").val(dataRecord.est_fg); 330 $("#est_fg").val(dataRecord.est_fg);
329 $("#est_color").val(dataRecord.est_color); 331 $("#est_color").val(dataRecord.est_color);
330 $("#color_method").val(dataRecord.color_method); 332 $("#color_method").val(dataRecord.color_method);
331 $("#est_ibu").val(dataRecord.est_ibu); 333 $("#est_ibu").val(dataRecord.est_ibu);
332 $("#ibu_method").val(dataRecord.ibu_method); 334 $("#ibu_method").val(dataRecord.ibu_method);
335 $("#mash_name").val(dataRecord.mash_name);
336 $("#mash_ph").val(dataRecord.mash_ph);
337 editWater(dataRecord);
333 // editsteps(dataRecord); 338 // editsteps(dataRecord);
334 // show the popup window. 339 // show the popup window.
335 $("#popupWindow").jqxWindow('open'); 340 $("#popupWindow").jqxWindow('open');
336 } 341 }
337 } 342 }
338 ], 343 ],
339 groups: ['style_guide','style_letter' ] 344 groups: ['st_guide','st_letter' ]
340 }); 345 });
341 346
342 // initialize the popup window and buttons. 347 // initialize the popup window and buttons.
343 $("#popupWindow").jqxWindow({ 348 $("#popupWindow").jqxWindow({
344 width: 1200, 349 width: 1200,
383 var rowID = $('#jqxgrid').jqxGrid('getrowid', editrow); 388 var rowID = $('#jqxgrid').jqxGrid('getrowid', editrow);
384 var row = { 389 var row = {
385 record: rowID, 390 record: rowID,
386 name: $("#name").val(), 391 name: $("#name").val(),
387 notes: $("#notes").val(), 392 notes: $("#notes").val(),
388 style_name: $('#style_name').val(), 393 st_name: $('#st_name').val(),
389 style_letter: $('#style_letter').val(), 394 st_letter: $('#st_letter').val(),
390 style_guide: $('#style_guide').val(), 395 st_guide: $('#st_guide').val(),
391 type: $("#type").val(), 396 type: $("#type").val(),
392 batch_size: parseFloat($("#batch_size").jqxNumberInput('decimal')), 397 batch_size: parseFloat($("#batch_size").jqxNumberInput('decimal')),
393 boil_time: parseFloat($("#boil_time").jqxNumberInput('decimal')), 398 boil_time: parseFloat($("#boil_time").jqxNumberInput('decimal')),
394 efficiency: parseFloat($("#efficiency").jqxNumberInput('decimal')), 399 efficiency: parseFloat($("#efficiency").jqxNumberInput('decimal')),
395 est_og: parseFloat($("#est_og").jqxNumberInput('decimal')), 400 est_og: parseFloat($("#est_og").jqxNumberInput('decimal')),
396 est_fg: parseFloat($("#est_fg").jqxNumberInput('decimal')), 401 est_fg: parseFloat($("#est_fg").jqxNumberInput('decimal')),
397 est_color: parseFloat($("#est_color").jqxNumberInput('decimal')), 402 est_color: parseFloat($("#est_color").jqxNumberInput('decimal')),
398 color_method: $("#color_method").val(), 403 color_method: $("#color_method").val(),
399 est_ibu: parseFloat($("#est_ibu").jqxNumberInput('decimal')), 404 est_ibu: parseFloat($("#est_ibu").jqxNumberInput('decimal')),
400 ibu_method: $("#ibu_method").val() 405 ibu_method: $("#ibu_method").val(),
406 mash_name: $("#mash_name").val(),
407 mash_ph: parseFloat($("#mash_ph").jqxNumberInput('decimal'))
401 // steps: steprows 408 // steps: steprows
402 }; 409 };
403 $('#jqxgrid').jqxGrid('updaterow', rowID, row); 410 $('#jqxgrid').jqxGrid('updaterow', rowID, row);
404 $("#popupWindow").jqxWindow('hide'); 411 $("#popupWindow").jqxWindow('hide');
405 } else { 412 } else {
406 // Insert a record 413 // Insert a record
407 var newrow = { 414 var newrow = {
408 record: -1, 415 record: -1,
409 name: $("#name").val(), 416 name: $("#name").val(),
410 notes: $("#notes").val(), 417 notes: $("#notes").val(),
411 style_name: $('#style_name').val(), 418 st_name: $('#st_name').val(),
412 style_letter: $('#style_letter').val(), 419 st_letter: $('#st_letter').val(),
413 style_guide: $('#style_guide').val(), 420 st_guide: $('#st_guide').val(),
414 type: $("#type").val(), 421 type: $("#type").val(),
415 batch_size: parseFloat($("#batch_size").jqxNumberInput('decimal')), 422 batch_size: parseFloat($("#batch_size").jqxNumberInput('decimal')),
416 boil_time: parseFloat($("#boil_time").jqxNumberInput('decimal')), 423 boil_time: parseFloat($("#boil_time").jqxNumberInput('decimal')),
417 efficiency: parseFloat($("#efficiency").jqxNumberInput('decimal')), 424 efficiency: parseFloat($("#efficiency").jqxNumberInput('decimal')),
418 est_og: parseFloat($("#est_og").jqxNumberInput('decimal')), 425 est_og: parseFloat($("#est_og").jqxNumberInput('decimal')),
419 est_fg: parseFloat($("#est_fg").jqxNumberInput('decimal')), 426 est_fg: parseFloat($("#est_fg").jqxNumberInput('decimal')),
420 est_color: parseFloat($("#est_color").jqxNumberInput('decimal')), 427 est_color: parseFloat($("#est_color").jqxNumberInput('decimal')),
421 color_method: $("#color_method").val(), 428 color_method: $("#color_method").val(),
422 est_ibu: parseFloat($("#est_ibu").jqxNumberInput('decimal')), 429 est_ibu: parseFloat($("#est_ibu").jqxNumberInput('decimal')),
423 ibu_method: $("#ibu_method").val() 430 ibu_method: $("#ibu_method").val(),
431 mash_name: $("#mash_name").val(),
432 mash_ph: parseFloat($("#mash_ph").jqxNumberInput('decimal'))
424 // steps: steprows 433 // steps: steprows
425 }; 434 };
426 $('#jqxgrid').jqxGrid('addrow', null, newrow); 435 $('#jqxgrid').jqxGrid('addrow', null, newrow);
427 $("#popupWindow").jqxWindow('hide'); 436 $("#popupWindow").jqxWindow('hide');
428 } 437 }

mercurial