www/js/rec_edit.js

changeset 98
92d6bc8a4cdd
parent 97
22c277be7e7e
child 99
f433193f7bb6
equal deleted inserted replaced
97:22c277be7e7e 98:92d6bc8a4cdd
50 var psugar = 0; // Percentage real sugars 50 var psugar = 0; // Percentage real sugars
51 var pcara = 0; // Percentage cara/crystal malts 51 var pcara = 0; // Percentage cara/crystal malts
52 52
53 console.log("record:" + my_record + " return:" + my_return + " theme:" + theme); 53 console.log("record:" + my_record + " return:" + my_return + " theme:" + theme);
54 54
55 // $("#jqxNotification").jqxNotification({ width: "auto", position: "top-right", opacity: 0.9,
56 // autoOpen: false, closeOnClick: true, autoClose: true, template: "info", blink: false,
57 // icon: { width: 25, height: 25, url: '../../images/smiley.png', padding: 5 }
58 // });
59
60 function calcFermentables() { 55 function calcFermentables() {
61 console.log("calcFermentables()"); 56 console.log("calcFermentables()");
62 sugarsf = 0; // Sugar weight 57 sugarsf = 0;
63 sugarsm = 0; 58 sugarsm = 0;
64 psugar = 0; // Percentage real sugars 59 psugar = 0;
65 pcara = 0; // Percentage cara/crystal malts 60 pcara = 0;
61 var colorw = 0; // Colors working
66 62
67 var rows = $('#fermentableGrid').jqxGrid('getboundrows'); 63 var rows = $('#fermentableGrid').jqxGrid('getboundrows');
68 for (var i = 0; i < rows.length; i++) { 64 for (var i = 0; i < rows.length; i++) {
69 var row = rows[i]; 65 var row = rows[i];
70 if (row.f_type == "Sugar") 66 if (row.f_type == "Sugar")
75 if (row.f_added == "Mash") { 71 if (row.f_added == "Mash") {
76 d = parseFloat($("#efficiency").jqxNumberInput('decimal')) / 100 * d; 72 d = parseFloat($("#efficiency").jqxNumberInput('decimal')) / 100 * d;
77 sugarsm += d; 73 sugarsm += d;
78 } 74 }
79 sugarsf += d; 75 sugarsf += d;
80 // colorw here too 76 colorw += row.f_amount * ebc_to_srm(row.f_color) / parseFloat($("#batch_size").jqxNumberInput('decimal')) * 8.34436;
81 } 77 }
82 $('#est_og').val(estimate_sg(sugarsf, parseFloat($("#batch_size").jqxNumberInput('decimal')))); 78 $('#est_og').val(estimate_sg(sugarsf, parseFloat($("#batch_size").jqxNumberInput('decimal'))));
83 preboil_sg = estimate_sg(sugarsm, parseFloat($("#boil_size").jqxNumberInput('decimal'))); 79 preboil_sg = estimate_sg(sugarsm, parseFloat($("#boil_size").jqxNumberInput('decimal')));
80 $('#est_color').val(kw_to_ebc($("#color_method").val(), colorw));
81 };
82
83 function calcIBUs() {
84 console.log("calcIBUs()");
85
86 var total_ibus = 0;
87 var rows = $('#hopGrid').jqxGrid('getboundrows');
88 for (var i = 0; i < rows.length; i++) {
89 var row = rows[i];
90
91 total_ibus += toIBU(row.h_useat,
92 row.h_form,
93 preboil_sg,
94 parseFloat($("#batch_size").jqxNumberInput('decimal')),
95 parseFloat(row.h_amount),
96 parseFloat(row.h_time),
97 parseFloat(row.h_alpha),
98 $("#ibu_method").val()
99 );
100 }
101 console.log("IBUs: " + total_ibus);
102 $('#est_ibu').val(total_ibus);
103 $('#hopGrid').jqxGrid('render');
84 }; 104 };
85 105
86 function calcInit () { 106 function calcInit () {
87 console.log("calc.init()"); 107 console.log("calc.init()");
88 // $('#est_og').on('change', function (event) { calcFermentables(); }); 108 // $('#est_og').on('change', function (event) { calcFermentables(); });
89 $('#efficiency').on('change', function (event) { calcFermentables(); }); 109 $('#color_method').on('change', function (event) { calcFermentables(); });
90 $('#batch_size').on('change', function (event) { calcFermentables(); }); 110 $('#ibu_method').on('change', function (event) {
91 $('#boil_time').on('change', function (event) { calcFermentables(); }); 111 calcFermentables();
92 $('#fermentableGrid').on('change', function (event) { calcFermentables(); }); 112 calcIBUs();
113 });
114 // $('#efficiency').on('change', function (event) { calcFermentables(); });
115 // $('#batch_size').on('change', function (event) { calcFermentables(); });
116 // $('#boil_time').on('change', function (event) { calcFermentables(); });
117 // $('#fermentableGrid').on('change', function (event) { calcFermentables(); });
93 }; 118 };
94 119
95 // Styles dropdown list 120 // Styles dropdown list
96 var stylesUrl = "includes/db_profile_styles.php"; 121 var stylesUrl = "includes/db_profile_styles.php";
97 var stylesSource = { 122 var stylesSource = {
640 var commit = $("#hopGrid").jqxGrid('deleterow', id); 665 var commit = $("#hopGrid").jqxGrid('deleterow', id);
641 } 666 }
642 }); 667 });
643 }, 668 },
644 ready: function() { 669 ready: function() {
670 calcIBUs();
645 $('#jqxTabs').jqxTabs('next'); 671 $('#jqxTabs').jqxTabs('next');
646 }, 672 },
647 columns: [ 673 columns: [
648 { text: 'Hop', editable: false, datafield: 'h_name' }, 674 { text: 'Hop', editable: false, datafield: 'h_name' },
649 { text: 'Type', editable: false, width: 90, align: 'center', cellsalign: 'center', datafield: 'h_type' }, 675 { text: 'Type', editable: false, width: 90, align: 'center', cellsalign: 'center', datafield: 'h_type' },
670 }, 696 },
671 { text: 'IBU', editable: false, datafield: 'ibu', width: 80, align: 'right', 697 { text: 'IBU', editable: false, datafield: 'ibu', width: 80, align: 'right',
672 cellsrenderer: function (index, datafield, value, defaultvalue, column, rowdata) { 698 cellsrenderer: function (index, datafield, value, defaultvalue, column, rowdata) {
673 var ibu = toIBU(rowdata.h_useat, 699 var ibu = toIBU(rowdata.h_useat,
674 rowdata.h_form, 700 rowdata.h_form,
675 parseFloat($("#est_og").jqxNumberInput('decimal')), 701 preboil_sg,
702 /*parseFloat($("#est_og").jqxNumberInput('decimal')),*/
676 parseFloat($("#batch_size").jqxNumberInput('decimal')), 703 parseFloat($("#batch_size").jqxNumberInput('decimal')),
677 parseFloat(rowdata.h_amount), 704 parseFloat(rowdata.h_amount),
678 parseFloat(rowdata.h_time), 705 parseFloat(rowdata.h_time),
679 parseFloat(rowdata.h_alpha), 706 parseFloat(rowdata.h_alpha),
680 $("#ibu_method").val() 707 $("#ibu_method").val()
681 ); 708 );
682 return "<div style='margin: 4px;' class='jqx-right-align'>" + dataAdapter.formatNumber(ibu, "f1") + "</div>"; 709 return "<div style='margin: 4px;' class='jqx-right-align'>" + dataAdapter.formatNumber(ibu, "f1") + "</div>";
683 } 710 }
684 } 711 }
685 ] 712 ]
686 }) 713 });
714 $("#hopGrid").on('cellendedit', function (event) {
715 //calcIBUs();
716 //$('#hopGrid').jqxGrid('sortby', 'f_amount', 'desc');
717 });
687 }; 718 };
688 719
689 // Inline miscs editor 720 // Inline miscs editor
690 var editMisc = function (data) { 721 var editMisc = function (data) {
691 var miscSource = { 722 var miscSource = {
1157 var commit = $("#mashGrid").jqxGrid('deleterow', id); 1188 var commit = $("#mashGrid").jqxGrid('deleterow', id);
1158 } 1189 }
1159 }); 1190 });
1160 }, 1191 },
1161 ready: function() { 1192 ready: function() {
1193 calcInit();
1162 $('#jqxTabs').jqxTabs('first'); 1194 $('#jqxTabs').jqxTabs('first');
1163 }, 1195 },
1164 columns: [ 1196 columns: [
1165 { text: 'Stap naam', datafield: 'step_name' }, 1197 { text: 'Stap naam', datafield: 'step_name' },
1166 { text: 'Stap type', datafield: 'step_type', width: 110, columntype: 'dropdownlist', 1198 { text: 'Stap type', datafield: 'step_type', width: 110, columntype: 'dropdownlist',
1217 }; 1249 };
1218 1250
1219 // initialize the input fields. 1251 // initialize the input fields.
1220 var srcType = [ "All Grain", "Partial Mash", "Extract" ]; 1252 var srcType = [ "All Grain", "Partial Mash", "Extract" ];
1221 var srcColor = [ "Morey", "Mosher", "Daniels" ]; 1253 var srcColor = [ "Morey", "Mosher", "Daniels" ];
1222 var srcIBU = [ "Tinseth", "Rager", "Garetz", "Daniels", "Mosher", "Noonan" ]; 1254 //var srcIBU = [ "Tinseth", "Rager", "Garetz", "Daniels", "Mosher", "Noonan" ];
1255 var srcIBU = [ "Tinseth", "Rager", "Daniels" ]; // Only these are supported at this time.
1223 $("#name").jqxInput({ theme: theme, width: 640, height: 23 }); 1256 $("#name").jqxInput({ theme: theme, width: 640, height: 23 });
1224 $("#notes").jqxInput({ theme: theme, width: 960, height: 200 }); 1257 $("#notes").jqxInput({ theme: theme, width: 960, height: 200 });
1225 $("#st_name").jqxInput({ theme: theme, width: 250, height: 23 }); 1258 $("#st_name").jqxInput({ theme: theme, width: 250, height: 23 });
1226 $("#st_letter").jqxInput({ theme: theme, width: 100, height: 23 }); 1259 $("#st_letter").jqxInput({ theme: theme, width: 100, height: 23 });
1227 $("#st_guide").jqxInput({ theme: theme, width: 250, height: 23 }); 1260 $("#st_guide").jqxInput({ theme: theme, width: 250, height: 23 });
1252 $("#color_method").jqxDropDownList({ theme: theme, source: srcColor, width: 125, height: 23, dropDownHeight: 95 }); 1285 $("#color_method").jqxDropDownList({ theme: theme, source: srcColor, width: 125, height: 23, dropDownHeight: 95 });
1253 1286
1254 $("#est_ibu").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 0, readOnly: true }); 1287 $("#est_ibu").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 0, readOnly: true });
1255 $("#st_ibu_min").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 0, readOnly: true }); 1288 $("#st_ibu_min").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 0, readOnly: true });
1256 $("#st_ibu_max").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 0, readOnly: true }); 1289 $("#st_ibu_max").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 0, readOnly: true });
1257 $("#ibu_method").jqxDropDownList({ theme: theme, source: srcIBU, width: 125, height: 23, dropDownHeight: 180 }); 1290 $("#ibu_method").jqxDropDownList({ theme: theme, source: srcIBU, width: 125, height: 23, dropDownHeight: 95, dropDownVerticalAlignment: 'top' });
1258 1291
1259 $("#est_carb").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 1, readOnly: true }); 1292 $("#est_carb").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 1, readOnly: true });
1260 $("#st_carb_min").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 1, readOnly: true }); 1293 $("#st_carb_min").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 1, readOnly: true });
1261 $("#st_carb_max").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 1, readOnly: true }); 1294 $("#st_carb_max").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 1, readOnly: true });
1262 1295
1270 width: 1280, 1303 width: 1280,
1271 height: 630, 1304 height: 630,
1272 autoHeight: false, 1305 autoHeight: false,
1273 position: 'top' 1306 position: 'top'
1274 }); 1307 });
1275
1276 calcInit();
1277 1308
1278 $("#Print").jqxButton({ template: "info", width: '80px', theme: theme }); 1309 $("#Print").jqxButton({ template: "info", width: '80px', theme: theme });
1279 $("#Print").click(function () { 1310 $("#Print").click(function () {
1280 // Open print in a new tab. 1311 // Open print in a new tab.
1281 var url="rec_print.php?record=" + my_record; 1312 var url="rec_print.php?record=" + my_record;

mercurial