42 } |
42 } |
43 |
43 |
44 |
44 |
45 $(document).ready(function () { |
45 $(document).ready(function () { |
46 |
46 |
|
47 var preboil_sg = 0; |
|
48 var psugar = 0; // Percentage real sugars |
|
49 var pcara = 0; // Percentage cara/crystal malts |
|
50 |
47 console.log("record:" + my_record + " return:" + my_return + " theme:" + theme); |
51 console.log("record:" + my_record + " return:" + my_return + " theme:" + theme); |
48 |
52 |
49 // $("#jqxNotification").jqxNotification({ width: "auto", position: "top-right", opacity: 0.9, |
53 // $("#jqxNotification").jqxNotification({ width: "auto", position: "top-right", opacity: 0.9, |
50 // autoOpen: false, closeOnClick: true, autoClose: true, template: "info", blink: false, |
54 // autoOpen: false, closeOnClick: true, autoClose: true, template: "info", blink: false, |
51 // icon: { width: 25, height: 25, url: '../../images/smiley.png', padding: 5 } |
55 // icon: { width: 25, height: 25, url: '../../images/smiley.png', padding: 5 } |
52 // }); |
56 // }); |
53 |
57 |
54 function calcFermentables (resize) { |
58 function calcFermentables() { |
55 console.log("calcFermentables(" + resize + ")"); |
59 console.log("calcFermentables()"); |
56 // recalc grid percentages. |
60 |
57 var t_amount = 0; |
61 // var rows = $('#fermentableGrid').jqxGrid('getrows'); |
|
62 |
58 var rows = $('#fermentableGrid').jqxGrid('getboundrows'); |
63 var rows = $('#fermentableGrid').jqxGrid('getboundrows'); |
|
64 var sugars = 0; // Sugar weight |
|
65 psugar = 0; // Percentage real sugars |
|
66 pcara = 0; // Percentage cara/crystal malts |
59 for (var i = 0; i < rows.length; i++) { |
67 for (var i = 0; i < rows.length; i++) { |
60 var row = rows[i]; |
68 var row = rows[i]; |
61 t_amount += row.f_amount; |
69 if (row.f_type == "Sugar") |
62 console.log ("loop: " + i + " kg:" + row.f_amount + " pct:" + row.f_percentage + " adjust:" + row.f_adjust_to_total_100); |
70 psugar += row.f_percentage; |
|
71 if (row.f_type == "Crystal") |
|
72 pcara += row.f_percentage; |
|
73 var d = row.f_amount * (row.f_yield / 100) * (1 - row.f_moisture / 100); |
|
74 if (row.f_added == "Mash") |
|
75 d = parseFloat($("#efficiency").jqxNumberInput('decimal')) / 100 * d; |
|
76 sugars += d; |
|
77 // console.log("suikers: " + sugars + " suiker%:" + psugar + " cara%: " + pcara); |
|
78 // colorw here too |
63 } |
79 } |
64 console.log("total:" + t_amount); |
80 $('#est_og').val(estimate_sg(sugars, parseFloat($("#batch_size").jqxNumberInput('decimal')))); |
65 for (var i = 0; i < rows.length; i++) { |
81 preboil_sg = estimate_sg(sugars, parseFloat($("#boil_size").jqxNumberInput('decimal'))); |
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 }; |
82 }; |
73 |
83 |
74 function calcInit () { |
84 function calcInit () { |
75 console.log("calc.init()"); |
85 console.log("calc.init()"); |
76 // $('#est_og').on('change', function (event) { calcFermentables(true); }); |
86 // $('#est_og').on('change', function (event) { calcFermentables(); }); |
77 $('#efficiency').on('change', function (event) { calcFermentables(true); }); |
87 $('#efficiency').on('change', function (event) { calcFermentables(); }); |
78 $('#batch_size').on('change', function (event) { calcFermentables(true); }); |
88 $('#batch_size').on('change', function (event) { calcFermentables(); }); |
79 $('#boil_time').on('change', function (event) { calcFermentables(true); }); |
89 $('#boil_time').on('change', function (event) { calcFermentables(); }); |
80 $('#fermentableGrid').on('change', function (event) { calcFermentables(false); }); |
90 $('#fermentableGrid').on('change', function (event) { calcFermentables(); }); |
|
91 // calcFermentables(); |
81 }; |
92 }; |
82 |
93 |
83 // Styles dropdown list |
94 // Styles dropdown list |
84 var stylesUrl = "includes/db_profile_styles.php"; |
95 var stylesUrl = "includes/db_profile_styles.php"; |
85 var stylesSource = { |
96 var stylesSource = { |
229 { name: 'ibu_method', type: 'string' }, |
240 { name: 'ibu_method', type: 'string' }, |
230 { name: 'est_carb', type: 'float' }, |
241 { name: 'est_carb', type: 'float' }, |
231 { name: 'mash_sparge_temp', type: 'float' }, |
242 { name: 'mash_sparge_temp', type: 'float' }, |
232 { name: 'mash_ph', type: 'float' }, |
243 { name: 'mash_ph', type: 'float' }, |
233 { name: 'mash_name', type: 'string' }, |
244 { name: 'mash_name', type: 'string' }, |
234 { name: 'fermentables', type: 'string' }, |
245 { name: 'fermentables', type: 'array' }, |
235 { name: 'hops', type: 'string' }, |
246 { name: 'hops', type: 'string' }, |
236 { name: 'miscs', type: 'string' }, |
247 { name: 'miscs', type: 'string' }, |
237 { name: 'yeasts', type: 'string' }, |
248 { name: 'yeasts', type: 'string' }, |
238 { name: 'waters', type: 'array' }, |
249 { name: 'waters', type: 'array' }, |
239 { name: 'mashs', type: 'string' } |
250 { name: 'mashs', type: 'string' } |
452 var id = $("#fermentableGrid").jqxGrid('getrowid', selectedrowindex); |
464 var id = $("#fermentableGrid").jqxGrid('getrowid', selectedrowindex); |
453 var commit = $("#fermentableGrid").jqxGrid('deleterow', id); |
465 var commit = $("#fermentableGrid").jqxGrid('deleterow', id); |
454 } |
466 } |
455 }); |
467 }); |
456 }, |
468 }, |
|
469 ready: function() { |
|
470 calcFermentables(); |
|
471 $('#jqxTabs').jqxTabs('next'); |
|
472 }, |
457 columns: [ |
473 columns: [ |
458 { text: 'Mout/suiker', editable: false, datafield: 'f_name', |
474 { text: 'Mout/suiker', editable: false, datafield: 'f_name', |
459 cellsrenderer: function (row, columnfield, value, defaulthtml, columnproperties) { |
475 cellsrenderer: function (row, columnfield, value, defaulthtml, columnproperties) { |
460 var rowData = $("#fermentableGrid").jqxGrid('getrowdata', row); |
476 var rowData = $("#fermentableGrid").jqxGrid('getrowdata', row); |
461 return "<span style='margin: 3px; margin-top: 6px; float: "+columnproperties.cellsalign+"'>" +rowData.f_name + " (" + rowData.f_color + " EBC)</span>"; |
477 return "<span style='margin: 3px; margin-top: 6px; float: "+columnproperties.cellsalign+"'>" +rowData.f_name + " (" + rowData.f_color + " EBC)</span>"; |
622 var id = $("#hopGrid").jqxGrid('getrowid', selectedrowindex); |
638 var id = $("#hopGrid").jqxGrid('getrowid', selectedrowindex); |
623 var commit = $("#hopGrid").jqxGrid('deleterow', id); |
639 var commit = $("#hopGrid").jqxGrid('deleterow', id); |
624 } |
640 } |
625 }); |
641 }); |
626 }, |
642 }, |
|
643 ready: function() { |
|
644 $('#jqxTabs').jqxTabs('next'); |
|
645 }, |
627 columns: [ |
646 columns: [ |
628 { text: 'Hop', editable: false, datafield: 'h_name' }, |
647 { text: 'Hop', editable: false, datafield: 'h_name' }, |
629 { text: 'Type', editable: false, width: 90, align: 'center', cellsalign: 'center', datafield: 'h_type' }, |
648 { text: 'Type', editable: false, width: 90, align: 'center', cellsalign: 'center', datafield: 'h_type' }, |
630 { text: 'Vorm', editable: false, width: 90, align: 'center', cellsalign: 'center', datafield: 'h_form' }, |
649 { text: 'Vorm', editable: false, width: 90, align: 'center', cellsalign: 'center', datafield: 'h_form' }, |
631 { text: 'Alpha', datafield: 'h_alpha', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'p1' }, |
650 { text: 'Alpha', datafield: 'h_alpha', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'p1' }, |
757 var id = $("#miscGrid").jqxGrid('getrowid', selectedrowindex); |
776 var id = $("#miscGrid").jqxGrid('getrowid', selectedrowindex); |
758 var commit = $("#miscGrid").jqxGrid('deleterow', id); |
777 var commit = $("#miscGrid").jqxGrid('deleterow', id); |
759 } |
778 } |
760 }); |
779 }); |
761 }, |
780 }, |
|
781 ready: function() { |
|
782 $('#jqxTabs').jqxTabs('next'); |
|
783 }, |
762 columns: [ |
784 columns: [ |
763 { text: 'Ingredient', editable: false, datafield: 'm_name' }, |
785 { text: 'Ingredient', editable: false, datafield: 'm_name' }, |
764 { text: 'Type', editable: false, width: 120, align: 'center', cellsalign: 'center', datafield: 'm_type' }, |
786 { text: 'Type', editable: false, width: 120, align: 'center', cellsalign: 'center', datafield: 'm_type' }, |
765 { text: 'Gebruik', editable: false, width: 90, align: 'center', cellsalign: 'center', datafield: 'm_use_use' }, |
787 { text: 'Gebruik', editable: false, width: 90, align: 'center', cellsalign: 'center', datafield: 'm_use_use' }, |
766 { text: 'Gewicht', datafield: 'm_amount', width: 110, align: 'right', cellsalign: 'right', cellsformat: 'f5', |
788 { text: 'Gewicht', datafield: 'm_amount', width: 110, align: 'right', cellsalign: 'right', cellsformat: 'f5', |
895 var id = $("#yeastGrid").jqxGrid('getrowid', selectedrowindex); |
917 var id = $("#yeastGrid").jqxGrid('getrowid', selectedrowindex); |
896 var commit = $("#yeastGrid").jqxGrid('deleterow', id); |
918 var commit = $("#yeastGrid").jqxGrid('deleterow', id); |
897 } |
919 } |
898 }); |
920 }); |
899 }, |
921 }, |
|
922 ready: function() { |
|
923 $('#jqxTabs').jqxTabs('next'); |
|
924 }, |
900 columns: [ |
925 columns: [ |
901 { text: 'Gist', editable: false, datafield: 'y_name' }, |
926 { text: 'Gist', editable: false, datafield: 'y_name' }, |
902 { text: 'Laboratorium', editable: false, width: 150, datafield: 'y_laboratory' }, |
927 { text: 'Laboratorium', editable: false, width: 150, datafield: 'y_laboratory' }, |
903 { text: 'Code', editable: false, width: 90, datafield: 'y_product_id' }, |
928 { text: 'Code', editable: false, width: 90, datafield: 'y_product_id' }, |
904 { text: 'Soort', editable: false, width: 80, align: 'center', cellsalign: 'center', datafield: 'y_form' }, |
929 { text: 'Soort', editable: false, width: 80, align: 'center', cellsalign: 'center', datafield: 'y_form' }, |
1024 var id = $("#waterGrid").jqxGrid('getrowid', selectedrowindex); |
1049 var id = $("#waterGrid").jqxGrid('getrowid', selectedrowindex); |
1025 var commit = $("#waterGrid").jqxGrid('deleterow', id); |
1050 var commit = $("#waterGrid").jqxGrid('deleterow', id); |
1026 } |
1051 } |
1027 }); |
1052 }); |
1028 }, |
1053 }, |
|
1054 ready: function() { |
|
1055 $('#jqxTabs').jqxTabs('next'); |
|
1056 }, |
1029 columns: [ |
1057 columns: [ |
1030 { text: 'Water bron', editable: false, datafield: 'w_name' }, |
1058 { text: 'Water bron', editable: false, datafield: 'w_name' }, |
1031 { text: 'Volume', datafield: 'w_amount', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'f1', |
1059 { text: 'Volume', datafield: 'w_amount', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'f1', |
1032 columntype: 'numberinput', |
1060 columntype: 'numberinput', |
1033 validation: function (cell, value) { |
1061 validation: function (cell, value) { |
1127 var id = $("#mashGrid").jqxGrid('getrowid', selectedrowindex); |
1155 var id = $("#mashGrid").jqxGrid('getrowid', selectedrowindex); |
1128 var commit = $("#mashGrid").jqxGrid('deleterow', id); |
1156 var commit = $("#mashGrid").jqxGrid('deleterow', id); |
1129 } |
1157 } |
1130 }); |
1158 }); |
1131 }, |
1159 }, |
|
1160 ready: function() { |
|
1161 $('#jqxTabs').jqxTabs('first'); |
|
1162 }, |
1132 columns: [ |
1163 columns: [ |
1133 { text: 'Stap naam', datafield: 'step_name' }, |
1164 { text: 'Stap naam', datafield: 'step_name' }, |
1134 { text: 'Stap type', datafield: 'step_type', width: 110, columntype: 'dropdownlist', |
1165 { text: 'Stap type', datafield: 'step_type', width: 110, columntype: 'dropdownlist', |
1135 createeditor: function (row, cellvalue, editor, celltext, cellwidth, cellheight) { |
1166 createeditor: function (row, cellvalue, editor, celltext, cellwidth, cellheight) { |
1136 var dataSource = [ "Infusion", "Temperature", "Decoction" ]; |
1167 var dataSource = [ "Infusion", "Temperature", "Decoction" ]; |