48 |
48 |
49 // $("#jqxNotification").jqxNotification({ width: "auto", position: "top-right", opacity: 0.9, |
49 // $("#jqxNotification").jqxNotification({ width: "auto", position: "top-right", opacity: 0.9, |
50 // autoOpen: false, closeOnClick: true, autoClose: true, template: "info", blink: false, |
50 // autoOpen: false, closeOnClick: true, autoClose: true, template: "info", blink: false, |
51 // icon: { width: 25, height: 25, url: '../../images/smiley.png', padding: 5 } |
51 // icon: { width: 25, height: 25, url: '../../images/smiley.png', padding: 5 } |
52 // }); |
52 // }); |
|
53 |
|
54 function calcFermentables (resize) { |
|
55 console.log("calcFermentables(" + resize + ")"); |
|
56 // recalc grid percentages. |
|
57 var t_amount = 0; |
|
58 var rows = $('#fermentableGrid').jqxGrid('getboundrows'); |
|
59 for (var i = 0; i < rows.length; i++) { |
|
60 var row = rows[i]; |
|
61 t_amount += row.f_amount; |
|
62 console.log ("loop: " + i + " kg:" + row.f_amount + " pct:" + row.f_percentage + " adjust:" + row.f_adjust_to_total_100); |
|
63 } |
|
64 console.log("total:" + t_amount); |
|
65 for (var i = 0; i < rows.length; i++) { |
|
66 var row = rows[i]; |
|
67 row.f_percentage = (row.f_amount / t_amount) * 100.0; |
|
68 } |
|
69 // if resize == true resize the malts bill. |
|
70 // if recalc grid malts |
|
71 $('#est_og').val(0); |
|
72 }; |
|
73 |
|
74 function calcInit () { |
|
75 console.log("calc.init()"); |
|
76 $('#est_og').on('change', function (event) { calcFermentables(true); }); |
|
77 $('#efficiency').on('change', function (event) { calcFermentables(true); }); |
|
78 $('#batch_size').on('change', function (event) { calcFermentables(true); }); |
|
79 $('#boil_time').on('change', function (event) { calcFermentables(true); }); |
|
80 $('#fermentableGrid').on('change', function (event) { calcFermentables(false); }); |
|
81 }; |
|
82 |
|
83 // Styles dropdown list |
|
84 var stylesUrl = "includes/db_profile_styles.php"; |
|
85 var stylesSource = { |
|
86 datatype: "json", |
|
87 datafields: [ |
|
88 { name: 'record', type: 'number' }, |
|
89 { name: 'name', type: 'string' }, |
|
90 { name: 'category', type: 'string' }, |
|
91 { name: 'category_number', type: 'number' }, |
|
92 { name: 'style_letter', type: 'string' }, |
|
93 { name: 'style_guide', type: 'string' }, |
|
94 { name: 'type', type: 'string' }, |
|
95 { name: 'og_min', type: 'float' }, |
|
96 { name: 'og_max', type: 'float' }, |
|
97 { name: 'fg_min', type: 'float' }, |
|
98 { name: 'fg_max', type: 'float' }, |
|
99 { name: 'ibu_min', type: 'float' }, |
|
100 { name: 'ibu_max', type: 'float' }, |
|
101 { name: 'color_min', type: 'float' }, |
|
102 { name: 'color_max', type: 'float' }, |
|
103 { name: 'carb_min', type: 'float' }, |
|
104 { name: 'carb_max', type: 'float' }, |
|
105 { name: 'abv_min', type: 'float' }, |
|
106 { name: 'abv_max', type: 'float' }, |
|
107 { name: 'notes', type: 'string' }, |
|
108 { name: 'profile', type: 'string' }, |
|
109 { name: 'ingredients', type: 'string' }, |
|
110 { name: 'examples', type: 'string' } |
|
111 ], |
|
112 url: stylesUrl, |
|
113 async: true |
|
114 }; |
|
115 var styleslist = new $.jqx.dataAdapter(stylesSource); |
|
116 $("#styleSelect").jqxDropDownList({ |
|
117 placeHolder: "Kies bierstijl:", |
|
118 theme: theme, |
|
119 source: styleslist, |
|
120 displayMember: "name", |
|
121 width: 150, |
|
122 height: 27, |
|
123 dropDownVerticalAlignment: 'top', |
|
124 dropDownWidth: 500, |
|
125 dropDownHeight: 380, |
|
126 renderer: function (index, label, value) { |
|
127 var datarecord = styleslist.records[index]; |
|
128 return datarecord.style_guide + " " + datarecord.style_letter+ " " + datarecord.name; |
|
129 } |
|
130 }); |
|
131 $("#styleSelect").on('select', function (event) { |
|
132 if (event.args) { |
|
133 var index = event.args.index; |
|
134 var datarecord = styleslist.records[index]; |
|
135 $("#st_name").val(datarecord.name); |
|
136 $("#st_category").val(datarecord.category); |
|
137 $("#st_category_number").val(datarecord.category_number); |
|
138 $("#st_letter").val(datarecord.style_letter); |
|
139 $("#st_guide").val(datarecord.style_guide); |
|
140 $("#st_type").val(datarecord.type); |
|
141 $("#st_og_min").val(datarecord.og_min); |
|
142 $("#st_og_max").val(datarecord.og_max); |
|
143 $("#st_fg_min").val(datarecord.fg_min); |
|
144 $("#st_fg_max").val(datarecord.fg_max); |
|
145 $("#st_ibu_min").val(datarecord.ibu_min); |
|
146 $("#st_ibu_max").val(datarecord.ibu_max); |
|
147 $("#st_color_min").val(datarecord.color_min); |
|
148 $("#st_color_max").val(datarecord.color_max); |
|
149 $("#st_carb_min").val(datarecord.carb_min); |
|
150 $("#st_carb_max").val(datarecord.carb_max); |
|
151 $("#st_abv_min").val(datarecord.abv_min); |
|
152 $("#st_abv_max").val(datarecord.abv_max); |
|
153 } |
|
154 }); |
53 |
155 |
54 var dataReecord = {}; |
156 var dataReecord = {}; |
55 var url = "includes/db_recipes.php"; |
157 var url = "includes/db_recipes.php"; |
56 // tooltips |
158 // tooltips |
57 $("#name").jqxTooltip({ content: 'De naam voor dit recept.' }); |
159 $("#name").jqxTooltip({ content: 'De naam voor dit recept.' }); |
346 }, |
450 }, |
347 columns: [ |
451 columns: [ |
348 { text: 'Mout/suiker', editable: false, datafield: 'f_name', |
452 { text: 'Mout/suiker', editable: false, datafield: 'f_name', |
349 cellsrenderer: function (row, columnfield, value, defaulthtml, columnproperties) { |
453 cellsrenderer: function (row, columnfield, value, defaulthtml, columnproperties) { |
350 var rowData = $("#fermentableGrid").jqxGrid('getrowdata', row); |
454 var rowData = $("#fermentableGrid").jqxGrid('getrowdata', row); |
351 return rowData.f_name + " (" + rowData.f_color + " EBC)"; |
455 return "<span style='margin: 3px; margin-top: 6px; float: "+columnproperties.cellsalign+"'>" +rowData.f_name + " (" + rowData.f_color + " EBC)</span>"; |
352 } |
456 } |
353 }, |
457 }, |
354 { text: 'Type', editable: false, width: 100, datafield: 'f_type' }, |
458 { text: 'Type', editable: false, width: 100, datafield: 'f_type' }, |
|
459 { text: 'Moment', editable: false, width: 100, datafield: 'f_added' }, |
355 { text: 'Opbrengst', editable: false, datafield: 'f_yield', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'p1' }, |
460 { text: 'Opbrengst', editable: false, datafield: 'f_yield', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'p1' }, |
356 { text: 'Gewicht', datafield: 'f_amount', width: 110, align: 'right', cellsalign: 'right', cellsformat: 'f3', |
461 { text: 'Gewicht', datafield: 'f_amount', width: 110, align: 'right', cellsalign: 'right', cellsformat: 'f3', |
357 columntype: 'numberinput', |
462 columntype: 'numberinput', |
358 validation: function (cell, value) { |
463 validation: function (cell, value) { |
359 // Maximum weight is the batch_size, just a simple check. |
464 // Maximum weight is the batch_size, just a simple check. |
1171 st_letter: $('#st_letter').val(), |
1279 st_letter: $('#st_letter').val(), |
1172 st_guide: $('#st_guide').val(), |
1280 st_guide: $('#st_guide').val(), |
1173 st_type: $('#st_type').val(), |
1281 st_type: $('#st_type').val(), |
1174 st_category: $('#st_category').val(), |
1282 st_category: $('#st_category').val(), |
1175 st_category_number: parseFloat($("#st_category_number").jqxNumberInput('decimal')), |
1283 st_category_number: parseFloat($("#st_category_number").jqxNumberInput('decimal')), |
1176 st_og_min: dataRecord.st_og_min, |
1284 st_og_min: parseFloat($("#st_og_min").jqxNumberInput('decimal')), |
1177 st_og_max: dataRecord.st_og_max, |
1285 st_og_max: parseFloat($("#st_og_max").jqxNumberInput('decimal')), |
1178 st_fg_min: dataRecord.st_fg_min, |
1286 st_fg_min: parseFloat($("#st_fg_min").jqxNumberInput('decimal')), |
1179 st_fg_max: dataRecord.st_fg_max, |
1287 st_fg_max: parseFloat($("#st_fg_max").jqxNumberInput('decimal')), |
1180 st_ibu_min: dataRecord.st_ibu_min, |
1288 st_ibu_min: parseFloat($("#st_ibu_min").jqxNumberInput('decimal')), |
1181 st_ibu_max: dataRecord.st_ibu_max, |
1289 st_ibu_max: parseFloat($("#st_ibu_max").jqxNumberInput('decimal')), |
1182 st_color_min: dataRecord.st_color_min, |
1290 st_color_min: parseFloat($("#st_color_min").jqxNumberInput('decimal')), |
1183 st_color_max: dataRecord.st_color_max, |
1291 st_color_max: parseFloat($("#st_color_max").jqxNumberInput('decimal')), |
1184 st_carb_min: dataRecord.st_carb_min, |
1292 st_carb_min: parseFloat($("#st_carb_min").jqxNumberInput('decimal')), |
1185 st_carb_max: dataRecord.st_carb_max, |
1293 st_carb_max: parseFloat($("#st_carb_max").jqxNumberInput('decimal')), |
1186 st_abv_min: dataRecord.st_abv_min, |
1294 st_abv_min: parseFloat($("#st_abv_min").jqxNumberInput('decimal')), |
1187 st_abv_max: dataRecord.st_abv_max, |
1295 st_abv_max: parseFloat($("#st_abv_max").jqxNumberInput('decimal')), |
1188 type: $("#type").val(), |
1296 type: $("#type").val(), |
1189 batch_size: parseFloat($("#batch_size").jqxNumberInput('decimal')), |
1297 batch_size: parseFloat($("#batch_size").jqxNumberInput('decimal')), |
1190 boil_time: parseFloat($("#boil_time").jqxNumberInput('decimal')), |
1298 boil_time: parseFloat($("#boil_time").jqxNumberInput('decimal')), |
1191 efficiency: parseFloat($("#efficiency").jqxNumberInput('decimal')), |
1299 efficiency: parseFloat($("#efficiency").jqxNumberInput('decimal')), |
1192 est_og: parseFloat($("#est_og").jqxNumberInput('decimal')), |
1300 est_og: parseFloat($("#est_og").jqxNumberInput('decimal')), |