www/js/prod_edit.js

changeset 822
bd20a8329b1b
parent 821
293ec25995db
child 823
506246d65043
equal deleted inserted replaced
821:293ec25995db 822:bd20a8329b1b
43 resizable: false, 43 resizable: false,
44 isModal: true, 44 isModal: true,
45 modalOpacity: 0.4, 45 modalOpacity: 0.4,
46 autoOpen: false, 46 autoOpen: false,
47 cancelButton: $('#pitchrateReady') 47 cancelButton: $('#pitchrateReady')
48 });
49
50 $('#popupHop').jqxWindow({
51 width: 800,
52 height: 300,
53 position: { x: 230, y: 100 },
54 resizable: false,
55 theme: theme,
56 isModal: true,
57 autoOpen: false,
58 cancelButton: $('#HopReady'),
59 modalOpacity: 0.40
60 });
61
62 $('#popupMisc').jqxWindow({
63 width: 800,
64 height: 275,
65 position: { x: 230, y: 100 },
66 resizable: false,
67 theme: theme,
68 isModal: true,
69 autoOpen: false,
70 cancelButton: $('#MiscReady'),
71 modalOpacity: 0.40
72 }); 48 });
73 49
74 $('#popupYeast').jqxWindow({ 50 $('#popupYeast').jqxWindow({
75 width: 800, 51 width: 800,
76 height: 300, 52 height: 300,
932 { name: 'm_time', type: 'float' }, 908 { name: 'm_time', type: 'float' },
933 { name: 'm_amount_is_weight', type: 'int' }, 909 { name: 'm_amount_is_weight', type: 'int' },
934 { name: 'm_inventory', type: 'float' }, 910 { name: 'm_inventory', type: 'float' },
935 { name: 'm_avail', type: 'int' } 911 { name: 'm_avail', type: 'int' }
936 ], 912 ],
937 addrow: function(rowid, rowdata, position, commit) { commit(true); },
938 deleterow: function(rowid, commit) { commit(true); },
939 updaterow: function(rowid, rowdata, commit) { commit(true); }
940 }, 913 },
941 miscAdapter = new $.jqx.dataAdapter(miscSource, { 914 miscAdapter = new $.jqx.dataAdapter(miscSource, {
942 beforeLoadComplete: function(records) { 915 beforeLoadComplete: function(records) {
943 var row, i, data = new Array(); 916 var row, i, data = new Array();
944 for (i = 0; i < records.length; i++) { 917 for (i = 0; i < records.length; i++) {
945 row = records[i]; 918 row = records[i];
946 data.push(row); 919 data.push(row);
947 // Initial set water agent values. 920 // Initial set water agent values.
948 switch (row.m_name) { 921 if (row.m_use_use == 1) { // Mash
949 case 'CaCl2': 922 switch (row.m_name) {
950 $('#wa_cacl2').val(row.m_amount * 1000); 923 case 'CaCl2':
951 break; 924 $('#wa_cacl2').val(row.m_amount * 1000);
952 case 'CaSO4': 925 break;
953 $('#wa_caso4').val(row.m_amount * 1000); 926 case 'CaSO4':
954 break; 927 $('#wa_caso4').val(row.m_amount * 1000);
955 case 'MgSO4': 928 break;
956 $('#wa_mgso4').val(row.m_amount * 1000); 929 case 'MgSO4':
957 break; 930 $('#wa_mgso4').val(row.m_amount * 1000);
958 case 'NaCl': 931 break;
959 $('#wa_nacl').val(row.m_amount * 1000); 932 case 'NaCl':
960 break; 933 $('#wa_nacl').val(row.m_amount * 1000);
961 case 'MgCl2': 934 break;
962 $('#wa_mgcl2').val(row.m_amount * 1000); 935 case 'MgCl2':
963 break; 936 $('#wa_mgcl2').val(row.m_amount * 1000);
964 case 'NaHCO3': 937 break;
965 $('#wa_nahco3').val(row.m_amount * 1000); 938 case 'NaHCO3':
966 break; 939 $('#wa_nahco3').val(row.m_amount * 1000);
967 case 'CaCO3': 940 break;
968 $('#wa_caco3').val(row.m_amount * 1000); 941 case 'CaCO3':
969 break; 942 $('#wa_caco3').val(row.m_amount * 1000);
970 case 'Melkzuur': 943 break;
971 $('#wa_acid_name').val(0); 944 case 'Melkzuur':
972 $('#wa_acid').val(row.m_amount * 1000); 945 $('#wa_acid_name').val(AcidTypeData[0].nl);
973 $('#wa_acid_perc').val(AcidTypeData[0].AcidPrc); // TODO: this ignores changed percentages. 946 $('#wa_acid').val(row.m_amount * 1000);
974 last_acid = 'Melkzuur'; 947 $('#wa_acid_perc').val(AcidTypeData[0].AcidPrc);
975 break; 948 last_acid = 'Melkzuur';
976 case 'Zoutzuur': 949 break;
977 $('#wa_acid_name').val(1); 950 case 'Zoutzuur':
978 $('#wa_acid').val(row.m_amount * 1000); 951 $('#wa_acid_name').val(AcidTypeData[1].nl);
979 $('#wa_acid_perc').val(AcidTypeData[1].AcidPrc); 952 $('#wa_acid').val(row.m_amount * 1000);
980 last_acid = 'Zoutzuur'; 953 $('#wa_acid_perc').val(AcidTypeData[1].AcidPrc);
981 break; 954 last_acid = 'Zoutzuur';
982 case 'Fosforzuur': 955 break;
983 $('#wa_acid_name').val(2); 956 case 'Fosforzuur':
984 $('#wa_acid').val(row.m_amount * 1000); 957 $('#wa_acid_name').val(AcidTypeData[2].nl);
985 $('#wa_acid_perc').val(AcidTypeData[2].AcidPrc); 958 $('#wa_acid').val(row.m_amount * 1000);
986 last_acid = 'Fosforzuur'; 959 $('#wa_acid_perc').val(AcidTypeData[2].AcidPrc);
987 break; 960 last_acid = 'Fosforzuur';
988 case 'Zwavelzuur': 961 break;
989 $('#wa_acid_name').val(3); 962 case 'Zwavelzuur':
990 $('#wa_acid').val(row.m_amount * 1000); 963 $('#wa_acid_name').val(AcidTypeData[3].nl);
991 $('#wa_acid_perc').val(AcidTypeData[3].AcidPrc); 964 $('#wa_acid').val(row.m_amount * 1000);
992 last_acid = 'Zwavelzuur'; 965 $('#wa_acid_perc').val(AcidTypeData[3].AcidPrc);
993 break; 966 last_acid = 'Zwavelzuur';
967 break;
968 }
969 }
970 if (row.m_use_use == 6) { // Sparge
971 switch (row.m_name) {
972 case 'CaCl2':
973 // $('#ss_cacl2').val(row.m_amount * 1000);
974 break;
975 case 'CaSO4':
976 // $('#ss_caso4').val(row.m_amount * 1000);
977 break;
978 case 'MgSO4':
979 // $('#ss_mgso4').val(row.m_amount * 1000);
980 break;
981 case 'NaCl':
982 // $('#ss_nacl').val(row.m_amount * 1000);
983 break;
984 case 'MgCl2':
985 // $('#ss_mgcl2').val(row.m_amount * 1000);
986 break;
987 }
994 } 988 }
995 } 989 }
996 return data; 990 return data;
997 }, 991 },
998 loadError: function(jqXHR, status, error) { console.log('miscs load error ' + status + ' ' + error); }, 992 loadError: function(jqXHR, status, error) { console.log('miscs load error ' + status + ' ' + error); },
1000 $('#miscGrid').jqxGrid({ 994 $('#miscGrid').jqxGrid({
1001 width: 1240, 995 width: 1240,
1002 height: 575, 996 height: 575,
1003 source: miscAdapter, 997 source: miscAdapter,
1004 theme: theme, 998 theme: theme,
1005 selectionmode: 'singlerow', 999 editable: false,
1006 showtoolbar: true,
1007 rendertoolbar: function(toolbar) {
1008 var container = $("<div style='overflow: hidden; position: relative; margin: 5px;'></div>");
1009 toolbar.append(container);
1010 container.append('<div style="float: left; margin-left: 165px;" id="maddrowbutton"></div>');
1011 container.append('<div style="float: left; margin-left: 10px; margin-top: 5px;">In voorraad:</div>');
1012 container.append('<div style="float: left; margin-left: 10px;" id="minstockbutton"></div>');
1013 container.append('<input style="float: left; margin-left: 400px;" id="mdeleterowbutton" type="button" value="Verwijder ingredient" />');
1014 // add misc from dropdownlist.
1015 $('#maddrowbutton').jqxDropDownList({
1016 placeHolder: 'Kies ingredi&euml;nt:',
1017 theme: theme,
1018 template: 'primary',
1019 source: misclist,
1020 disabled: (dataRecord.stage > 6),
1021 displayMember: 'name',
1022 width: 150,
1023 height: 27,
1024 dropDownWidth: 500,
1025 dropDownHeight: 500
1026 });
1027 $('#maddrowbutton').on('select', function(event) {
1028 if (event.args) {
1029 var datarecord, row = {}, index = event.args.index;
1030 datarecord = misclist.records[index];
1031 row['m_name'] = datarecord.name;
1032 row['m_amount'] = 0;
1033 row['m_cost'] = datarecord.cost;
1034 row['m_type'] = datarecord.type;
1035 row['m_use_use'] = minimum_misc(dataRecord.stage, datarecord.use_use);
1036 row['m_time'] = 0;
1037 row['m_amount_is_weight'] = datarecord.amount_is_weight;
1038 row['m_inventory'] = datarecord.inventory;
1039 $('#miscGrid').jqxGrid('addrow', null, row);
1040 }
1041 });
1042 $('#minstockbutton').jqxCheckBox({ theme: theme, height: 27, disabled: (dataRecord.stage > 6) });
1043 $('#minstockbutton').on('change', function(event) {
1044 miscinstock = event.args.checked;
1045 misclist.dataBind();
1046 });
1047 // delete selected misc.
1048 $('#mdeleterowbutton').jqxButton({ template: 'danger', theme: theme, height: 27, width: 150, disabled: (dataRecord.stage > 6) });
1049 $('#mdeleterowbutton').on('click', function() {
1050 var rowscount, type, id, selectedrowindex = $('#miscGrid').jqxGrid('getselectedrowindex');
1051 rowscount = $('#miscGrid').jqxGrid('getdatainformation').rowscount;
1052 type = $('#miscGrid').jqxGrid('getcellvalue', selectedrowindex, 'm_type');
1053 use_use = $('#miscGrid').jqxGrid('getcellvalue', selectedrowindex, 'm_use_use');
1054 if (selectedrowindex >= 0 && selectedrowindex < rowscount && type == 4) {
1055 alert('Brouwzouten verwijderen in de water tab.');
1056 } else if (block_misc(dataRecord.stage, use_use)) {
1057 alert('Ingredieënt is al verwerkt.');
1058 } else {
1059 id = $('#miscGrid').jqxGrid('getrowid', selectedrowindex);
1060 $('#miscGrid').jqxGrid('deleterow', id);
1061 }
1062 });
1063 },
1064 ready: function() { $('#jqxTabs').jqxTabs('next'); }, 1000 ready: function() { $('#jqxTabs').jqxTabs('next'); },
1065 columns: [ 1001 columns: [
1066 { text: 'Ingredient', datafield: 'm_name' }, 1002 { text: 'Ingredient', datafield: 'm_name' },
1067 { text: 'Type', width: 140, datafield: 'm_type', 1003 { text: 'Type', width: 140, datafield: 'm_type',
1068 cellsrenderer: function(index, datafield, value, defaultvalue, column, rowdata) { 1004 cellsrenderer: function(index, datafield, value, defaultvalue, column, rowdata) {
1097 color = (value < rowdata.m_amount) ? '#ff4040':'#ffffff', 1033 color = (value < rowdata.m_amount) ? '#ff4040':'#ffffff',
1098 amount = dataAdapter.formatNumber(value * 1000, 'f2') + ' ' + vstr; 1034 amount = dataAdapter.formatNumber(value * 1000, 'f2') + ' ' + vstr;
1099 return '<span style="margin: 4px; margin-top: 6px; float: right; color: ' + color + ';">' + amount + '</span>'; 1035 return '<span style="margin: 4px; margin-top: 6px; float: right; color: ' + color + ';">' + amount + '</span>';
1100 } else { 1036 } else {
1101 return '<span></span>'; 1037 return '<span></span>';
1102 }
1103 }
1104 },
1105 { text: '', datafield: 'Edit', columntype: 'button', width: 100, align: 'center',
1106 cellsrenderer: function() {
1107 return 'Wijzig';
1108 }, buttonclick: function(row) {
1109 miscRow = row;
1110 miscData = $('#miscGrid').jqxGrid('getrowdata', miscRow);
1111 if (block_misc(dataRecord.stage, miscData.m_use_use)) {
1112 alert('Ingredieënt is al verwerkt.');
1113 } else if (miscData.m_type == 4) {
1114 alert('Brouwzouten wijzigen in de water tab.');
1115 } else {
1116 console.log('edit button row ' + row);
1117 if (miscData.m_amount_is_weight)
1118 $('#wm_pmpt_amount').html('Gewicht gram:');
1119 else
1120 $('#wm_pmpt_amount').html('Volume ml:');
1121 $('#wm_name').val(miscData.m_name);
1122 $('#wm_amount').val(miscData.m_amount * 1000);
1123 if ((miscData.m_use_use == 3) || (miscData.m_use_use == 4)) // Primary or Secondary
1124 $('#wm_time').val(miscData.m_time / 1440);
1125 else
1126 $('#wm_time').val(miscData.m_time);
1127 $('#wm_use_use').val(miscData.m_use_use);
1128 drop_endis(dataRecord.stage >= 2, '#wm_use_use', 0);
1129 drop_endis(dataRecord.stage >= 3, '#wm_use_use', 1);
1130 drop_endis(dataRecord.stage >= 3, '#wm_use_use', 2);
1131 drop_endis(dataRecord.stage >= 4, '#wm_use_use', 3);
1132 drop_endis(dataRecord.stage >= 5, '#wm_use_use', 4);
1133 // show the popup window.
1134 $('#popupMisc').jqxWindow('open');
1135 } 1038 }
1136 } 1039 }
1137 } 1040 }
1138 ] 1041 ]
1139 }); 1042 });
1819 fermentableInit = 0; 1722 fermentableInit = 0;
1820 $('#ferm_lintner').val(Math.round(parseFloat(lintner / mashkg))); 1723 $('#ferm_lintner').val(Math.round(parseFloat(lintner / mashkg)));
1821 $('#mash_kg').val(mashkg); 1724 $('#mash_kg').val(mashkg);
1822 console.log('calcFermentables() supplies:' + ok_fermentables + ' moutsuiker:' + Round(sugarsm, 3) + '/' + Round(sugarsf, 3)); 1725 console.log('calcFermentables() supplies:' + ok_fermentables + ' moutsuiker:' + Round(sugarsm, 3) + '/' + Round(sugarsf, 3));
1823 to_100 = my_100; 1726 to_100 = my_100;
1824 if (to_100) {
1825 $('#wf_amount').jqxNumberInput({ width: 90, readOnly: true, spinButtons: false });
1826 } else {
1827 $('#wf_amount').jqxNumberInput({ width: 110, readOnly: false, spinButtons: true });
1828 }
1829 1727
1830 if (mvol > 0) { 1728 if (mvol > 0) {
1831 v = s / sugardensity + mvol; 1729 v = s / sugardensity + mvol;
1832 s = 1000 * s / (v * 10); //deg. Plato 1730 s = 1000 * s / (v * 10); //deg. Plato
1833 est_mash_sg = Round(plato_to_sg(s), 5); 1731 est_mash_sg = Round(plato_to_sg(s), 5);
4175 $('#ferm_lintner').jqxProgressBar({ 4073 $('#ferm_lintner').jqxProgressBar({
4176 width: 300, height: 23, theme: theme, showText: true, max: 200, animationDuration: 0, 4074 width: 300, height: 23, theme: theme, showText: true, max: 200, animationDuration: 0,
4177 colorRanges: [{ stop: 30, color: '#FF0000' },{ stop: 40, color: '#EB7331' },{ stop: 200, color: '#008C00' }], 4075 colorRanges: [{ stop: 30, color: '#FF0000' },{ stop: 40, color: '#EB7331' },{ stop: 200, color: '#008C00' }],
4178 renderText: function(text) { return (parseInt(text) * 2) + ' lintner'; } 4076 renderText: function(text) { return (parseInt(text) * 2) + ' lintner'; }
4179 }); 4077 });
4180 $('#FermentableReady').jqxButton({ template: 'success', width: '90px', theme: theme });
4181 $('#FermentableReady').click(function() {
4182 var row, rowID = $('#fermentableGrid').jqxGrid('getrowid', fermentableRow);
4183 console.log('FermentableReady row:' + fermentableRow + ' ID:' + rowID);
4184 row = {
4185 f_name: fermentableData.f_name,
4186 f_origin: fermentableData.f_origin,
4187 f_supplier: fermentableData.f_supplier,
4188 f_amount: fermentableData.f_amount,
4189 f_cost: fermentableData.f_cost,
4190 f_type: fermentableData.f_type,
4191 f_yield: fermentableData.f_yield,
4192 f_color: fermentableData.f_color,
4193 f_coarse_fine_diff: fermentableData.f_coarse_fine_diff,
4194 f_moisture: fermentableData.f_moisture,
4195 f_diastatic_power: fermentableData.f_diastatic_power,
4196 f_protein: fermentableData.f_protein,
4197 f_max_in_batch: fermentableData.f_max_in_batch,
4198 f_graintype: fermentableData.f_graintype,
4199 f_added: fermentableData.f_added,
4200 f_dissolved_protein: fermentableData.f_dissolved_protein,
4201 f_recommend_mash: fermentableData.f_recommend_mash,
4202 f_add_after_boil: fermentableData.f_add_after_boil,
4203 f_adjust_to_total_100: fermentableData.f_adjust_to_total_100,
4204 f_percentage: fermentableData.f_percentage,
4205 f_di_ph: fermentableData.f_di_ph,
4206 f_acid_to_ph_57: fermentableData.f_acid_to_ph_57,
4207 f_inventory: fermentableData.f_inventory,
4208 f_avail: fermentableData.f_avail
4209 };
4210 $('#fermentableGrid').jqxGrid('updaterow', rowID, row);
4211 calcPercentages();
4212 calcFermentables();
4213 calcIBUs();
4214 calcMash();
4215 // Waters: yes there is impact.
4216 });
4217 4078
4218 // Tab 4, Hops 4079 // Tab 4, Hops
4219 $('#est_ibu2').jqxTooltip({ content: 'De bitterheid in IBU. Dit wordt automatisch berekend.' }); 4080 $('#est_ibu2').jqxTooltip({ content: 'De bitterheid in IBU. Dit wordt automatisch berekend.' });
4220 $('#est_ibu2').jqxNumberInput(Smal0dec); 4081 $('#est_ibu2').jqxNumberInput(Smal0dec);
4221 $('#hop_flavour').jqxProgressBar({ 4082 $('#hop_flavour').jqxProgressBar({
4262 return 'Veel'; 4123 return 'Veel';
4263 else 4124 else
4264 return 'Zeer veel'; 4125 return 'Zeer veel';
4265 } 4126 }
4266 }); 4127 });
4267 $('#HopReady').jqxButton({ template: 'success', width: '90px', theme: theme });
4268 $('#HopReady').click(function() {
4269 var row, rowID = $('#hopGrid').jqxGrid('getrowid', hopRow);
4270 row = {
4271 h_name: $('#wh_name').val(),
4272 h_origin: hopData.h_origin,
4273 h_amount: parseFloat($('#wh_amount').jqxNumberInput('decimal')) / 1000,
4274 h_cost: hopData.h_cost,
4275 h_type: hopData.h_type,
4276 h_form: hopData.h_form,
4277 h_useat: $('#wh_useat').val(),
4278 h_time: hopData.h_time,
4279 h_alpha: hopData.h_alpha,
4280 h_beta: hopData.h_beta,
4281 h_hsi: hopData.h_hsi,
4282 h_humulene: hopData.h_humulene,
4283 h_caryophyllene: hopData.h_caryophyllene,
4284 h_cohumulone: hopData.h_cohumulone,
4285 h_myrcene: hopData.h_myrcene,
4286 h_total_oil: hopData.h_total_oil,
4287 h_inventory: hopData.h_inventory,
4288 h_avail: hopData.h_avail
4289 };
4290 $('#hopGrid').jqxGrid('updaterow', rowID, row);
4291 calcIBUs();
4292 });
4293 $('#wh_name').jqxInput({ theme: theme, width: 320, height: 23 });
4294 $('#wh_instock').jqxCheckBox({ theme: theme, height: 23 });
4295 $('#wh_instock').on('change', function(event) {
4296 hopinstock = event.args.checked;
4297 hoplist.dataBind();
4298 });
4299 $('#wh_select').jqxDropDownList({
4300 placeHolder: 'Kies hop:',
4301 theme: theme,
4302 source: hoplist,
4303 displayMember: 'name',
4304 width: 150,
4305 height: 23,
4306 dropDownWidth: 500,
4307 dropDownHeight: 500,
4308 renderer: function(index, label, value) {
4309 var datarecord = hoplist.records[index];
4310 return datarecord.origin + ' - ' + datarecord.name + ' / ' + HopFormData[datarecord.form].nl + ' (' + datarecord.alpha + ' % &alpha;)';
4311 }
4312 });
4313 $('#wh_select').on('select', function(event) {
4314 if (event.args) {
4315 var datarecord, index = event.args.index;
4316 datarecord = hoplist.records[index];
4317 $('#wh_name').val(datarecord.name);
4318 hopData.h_name = datarecord.name;
4319 hopData.h_origin = datarecord.origin;
4320 hopData.h_cost = datarecord.cost;
4321 hopData.h_type = datarecord.type;
4322 hopData.h_form = datarecord.form;
4323 hopData.h_alpha = datarecord.alpha;
4324 hopData.h_beta = datarecord.beta;
4325 hopData.h_hsi = datarecord.hsi;
4326 hopData.h_humulene = datarecord.humulene;
4327 hopData.h_caryophyllene = datarecord.caryophyllene;
4328 hopData.h_cohumulone = datarecord.cohumulone;
4329 hopData.h_myrcene = datarecord.myrcene;
4330 hopData.h_total_oil = datarecord.total_oil;
4331 hopData.h_inventory = datarecord.inventory;
4332 }
4333 });
4334 $('#wh_amount').jqxNumberInput(Spin1dec);
4335 $('#wh_amount').on('change', function(event) {
4336 console.log('amount changed: ' + event.args.value + ' time:' + hopData.h_time + ' alpha:' + hopData.h_alpha);
4337 var ibu, amount = parseFloat(event.args.value) / 1000;
4338 ibu = toIBU(hopData.h_useat, hopData.h_form, preboil_sg, parseFloat($('#batch_size').jqxNumberInput('decimal')),
4339 amount, parseFloat(hopData.h_time), parseFloat(hopData.h_alpha), $('#ibu_method').val(),
4340 dataRecord.brew_whirlpool9, dataRecord.brew_whirlpool7, dataRecord.brew_whirlpool6
4341 );
4342 hopData.h_amount = amount;
4343 $('#wh_ibu').val(ibu);
4344 });
4345 $('#wh_ibu').jqxNumberInput(Show1dec);
4346 $('#wh_time').jqxNumberInput(PosInt);
4347 $('#wh_time').on('change', function(event) {
4348 var ibu, newtime = parseFloat(event.args.value);
4349 // Check limits and correct
4350 if (hopData.h_useat == 2) { // Boil
4351 if (newtime > parseFloat($('#boil_time').jqxNumberInput('decimal'))) {
4352 newtime = parseFloat($('#boil_time').jqxNumberInput('decimal'));
4353 $('#wh_time').val(newtime);
4354 }
4355 hopData.h_time = newtime;
4356 } else if (hopData.h_useat == 5) { // Dry hop
4357 if (newtime > 21) {
4358 newtime = 21;
4359 $('#wh_time').val(newtime);
4360 }
4361 hopData.h_time = newtime * 1440;
4362 }
4363 ibu = toIBU(hopData.h_useat, hopData.h_form, preboil_sg, parseFloat($('#batch_size').jqxNumberInput('decimal')),
4364 parseFloat(hopData.h_amount), parseFloat(hopData.h_time), parseFloat(hopData.h_alpha), $('#ibu_method').val(),
4365 dataRecord.brew_whirlpool9, dataRecord.brew_whirlpool7, dataRecord.brew_whirlpool6);
4366 $('#wh_ibu').val(ibu);
4367 });
4368 $('#wh_useat').jqxDropDownList({
4369 theme: theme,
4370 source: HopUseAdapter,
4371 valueMember: 'id',
4372 displayMember: 'nl',
4373 width: 180,
4374 height: 23,
4375 autoDropDownHeight: true,
4376 dropDownVerticalAlignment: 'top'
4377 });
4378 $('#wh_useat').on('select', function(event) {
4379 if (event.args) {
4380 var index = event.args.index;
4381 hopData.h_useat = index;
4382 if ((index == 0) || (index == 1)) { // Mashhop or First wort hop
4383 hopData.h_time = parseFloat(dataRecord.boil_time);
4384 $('#wh_time').jqxNumberInput({ spinButtons: false, readOnly: true, width: 90 });
4385 $('#wh_time').val(hopData.h_time);
4386 } else if (index == 3) { // Aroma
4387 hopData.h_time = 0;
4388 $('#wh_time').jqxNumberInput({ spinButtons: false, readOnly: true, width: 90 });
4389 $('#wh_time').val(0);
4390 } else if (index == 4) { // Whirlpool
4391 hopData.h_time = (parseFloat(dataRecord.brew_whirlpool9) + parseFloat(dataRecord.brew_whirlpool7) + parseFloat(dataRecord.brew_whirlpool6));
4392 $('#wh_time').jqxNumberInput({ spinButtons: false, readOnly: true, width: 90 });
4393 $('#wh_time').val(hopData.h_time);
4394 } else { // Boil, Dry hop
4395 $('#wh_time').jqxNumberInput({ spinButtons: true, readOnly: false, width: 110 });
4396 }
4397 if (index == 5) // Dry hop
4398 $('#wh_pmpt_time').html('Tijd in dagen');
4399 else
4400 $('#wh_pmpt_time').html('Tijd in minuten');
4401 }
4402 });
4403 4128
4404 // Tab 5, Miscs 4129 // Tab 5, Miscs
4405 $('#MiscReady').jqxButton({ template: 'success', width: '90px', theme: theme });
4406 $('#MiscReady').click(function() {
4407 var row, rowID = $('#miscGrid').jqxGrid('getrowid', miscRow);
4408 console.log('MiscReady row:' + miscRow + ' ID:' + rowID);
4409 row = {
4410 m_name: miscData.m_name,
4411 m_amount: miscData.m_amount,
4412 m_cost: miscData.m_cost,
4413 m_type: miscData.m_type,
4414 m_use_use: miscData.m_use_use,
4415 m_time: miscData.m_time,
4416 m_amount_is_weight: miscData.m_amount_is_weight,
4417 m_inventory: miscData.m_inventory,
4418 m_avail: miscData.m_avail
4419 };
4420 $('#miscGrid').jqxGrid('updaterow', rowID, row);
4421 calcMiscs();
4422 });
4423 $('#wm_name').jqxInput({ theme: theme, width: 320, height: 23 });
4424 $('#wm_instock').jqxCheckBox({ theme: theme, height: 23 });
4425 $('#wm_instock').on('change', function(event) {
4426 miscinstock = event.args.checked;
4427 misclist.dataBind();
4428 });
4429 $('#wm_select').jqxDropDownList({
4430 placeHolder: 'Kies ingredi&euml;nt:',
4431 theme: theme,
4432 source: misclist,
4433 displayMember: 'name',
4434 width: 150,
4435 height: 23,
4436 dropDownWidth: 500,
4437 dropDownHeight: 500
4438 });
4439 $('#wm_select').on('select', function(event) {
4440 if (event.args) {
4441 var datarecord, index = event.args.index;
4442 datarecord = misclist.records[index];
4443 $('#wm_name').val(datarecord.name);
4444 miscData.m_name = datarecord.name;
4445 miscData.m_cost = datarecord.cost;
4446 miscData.m_type = datarecord.type;
4447 miscData.m_use_use = datarecord.use_use;
4448 miscData.m_amount_is_weight = datarecord.amount_is_weight;
4449 miscData.m_inventory = datarecord.inventory;
4450 }
4451 });
4452 $('#wm_amount').jqxNumberInput(Spin2dec);
4453 $('#wm_amount').on('change', function(event) {
4454 console.log('amount changed: ' + event.args.value);
4455 miscData.m_amount = parseFloat(event.args.value) / 1000;
4456 });
4457 $('#wm_time').jqxNumberInput(PosInt);
4458 $('#wm_time').on('change', function(event) {
4459 var newtime = parseFloat(event.args.value);
4460
4461 if (miscData.m_use_use == 2) { // Boil
4462 if (newtime > parseFloat($('#boil_time').jqxNumberInput('decimal'))) {
4463 newtime = parseFloat($('#boil_time').jqxNumberInput('decimal'));
4464 $('#wm_time').val(newtime);
4465 }
4466 miscData.m_time = newtime;
4467 } else if ((miscData.m_use_use == 3) || (miscData.m_use_use == 4)) { // Primary or Secondary
4468 if (newtime > 21) {
4469 newtime = 21;
4470 $('#wm_time').val(newtime);
4471 }
4472 miscData.m_time = newtime * 1440;
4473 }
4474 });
4475 $('#wm_use_use').jqxDropDownList({
4476 theme: theme,
4477 source: MiscUseAdapter,
4478 valueMember: 'id',
4479 displayMember: 'nl',
4480 width: 180,
4481 height: 23,
4482 autoDropDownHeight: true,
4483 dropDownVerticalAlignment: 'top'
4484 });
4485 $('#wm_use_use').on('select', function(event) {
4486 if (event.args) {
4487 var index = event.args.index;
4488 miscData.m_use_use = index;
4489 if ((index == 2) || (index == 3) || (index == 4)) { // Boil, Primary or Secondary
4490 $('#wm_time').jqxNumberInput({ spinButtons: true, readOnly: false, width: 110 });
4491 } else {
4492 $('#wm_time').jqxNumberInput({ spinButtons: false, readOnly: true, width: 90 });
4493 $('#wm_time').val(0);
4494 miscData.m_time = 0;
4495 }
4496 }
4497 });
4498 4130
4499 // Tab 6, Yeasts 4131 // Tab 6, Yeasts
4500 $('#est_fg2').jqxTooltip({ content: 'Het verwachte eind SG. Dit wordt automatisch berekend.' }); 4132 $('#est_fg2').jqxTooltip({ content: 'Het verwachte eind SG. Dit wordt automatisch berekend.' });
4501 $('#est_abv2').jqxTooltip({ content: 'Verwacht alcohol volume %. Dit wordt automatisch berekend.' }); 4133 $('#est_abv2').jqxTooltip({ content: 'Verwacht alcohol volume %. Dit wordt automatisch berekend.' });
4502 $('#yeast_grams').jqxTooltip({ content: 'De gewenste totale hoeveelheid droge gist voor dit bier.' }); 4134 $('#yeast_grams').jqxTooltip({ content: 'De gewenste totale hoeveelheid droge gist voor dit bier.' });

mercurial