346 }, |
346 }, |
347 |
347 |
348 // Load data and select one record. |
348 // Load data and select one record. |
349 dataAdapter = new $.jqx.dataAdapter(source, { |
349 dataAdapter = new $.jqx.dataAdapter(source, { |
350 loadComplete: function() { |
350 loadComplete: function() { |
351 console.log('main data begin load'); |
|
352 var records = dataAdapter.records; |
351 var records = dataAdapter.records; |
353 dataRecord = records[0]; |
352 dataRecord = records[0]; |
354 // Hidden record uuid |
353 // Hidden record uuid |
355 $('#name').val(dataRecord.name); |
354 $('#name').val(dataRecord.name); |
356 $('#code').val(dataRecord.code); |
355 $('#code').val(dataRecord.code); |
575 editMisc(dataRecord); |
574 editMisc(dataRecord); |
576 editYeast(dataRecord); |
575 editYeast(dataRecord); |
577 editMash(dataRecord); |
576 editMash(dataRecord); |
578 calcStage(); |
577 calcStage(); |
579 $('#jqxTabs').jqxTabs('select', 2); |
578 $('#jqxTabs').jqxTabs('select', 2); |
580 console.log('main data ready'); |
|
581 data_loaded = 1; |
579 data_loaded = 1; |
582 }, |
580 }, |
583 loadError: function(jqXHR, status, error) { |
581 loadError: function(jqXHR, status, error) { |
584 console.log('main data load error: ' + status + ' ' + error); |
582 console.log('main data load error: ' + status + ' ' + error); |
585 } |
583 } |
735 } |
733 } |
736 calcFermentables(); |
734 calcFermentables(); |
737 calcIBUs(); |
735 calcIBUs(); |
738 }); |
736 }); |
739 }, |
737 }, |
740 ready: function() { console.log('ready fermentables'); $('#jqxTabs').jqxTabs('next'); }, |
738 ready: function() { calcFermentables(); $('#jqxTabs').jqxTabs('next'); }, |
741 columns: [ |
739 columns: [ |
742 { text: 'Vergistbaar ingrediënt', datafield: 'f_name', |
740 { text: 'Vergistbaar ingrediënt', datafield: 'f_name', |
743 cellsrenderer: function(index, datafield, value, defaultvalue, column, rowdata) { |
741 cellsrenderer: function(index, datafield, value, defaultvalue, column, rowdata) { |
744 return '<span style="margin: 3px; margin-top: 6px; float: left;">' + rowdata.f_supplier + ' / ' + |
742 return '<span style="margin: 3px; margin-top: 6px; float: left;">' + rowdata.f_supplier + ' / ' + |
745 rowdata.f_name + ' (' + rowdata.f_color + ' EBC)</span>'; |
743 rowdata.f_name + ' (' + rowdata.f_color + ' EBC)</span>'; |
924 $('#hopGrid').jqxGrid('deleterow', id); |
922 $('#hopGrid').jqxGrid('deleterow', id); |
925 } |
923 } |
926 calcIBUs(); |
924 calcIBUs(); |
927 }); |
925 }); |
928 }, |
926 }, |
929 ready: function() { console.log('ready hops'); $('#jqxTabs').jqxTabs('next'); }, |
927 ready: function() { $('#jqxTabs').jqxTabs('next'); }, |
930 columns: [ |
928 columns: [ |
931 { text: 'Hop', datafield: 'h_name', |
929 { text: 'Hop', datafield: 'h_name', |
932 cellsrenderer: function(index, datafield, value, defaultvalue, column, rowdata) { |
930 cellsrenderer: function(index, datafield, value, defaultvalue, column, rowdata) { |
933 return '<span style="margin: 3px; margin-top: 6px; float: left;">' + rowdata.h_origin + ' / ' + rowdata.h_name + '</span>'; |
931 return '<span style="margin: 3px; margin-top: 6px; float: left;">' + rowdata.h_origin + ' / ' + rowdata.h_name + '</span>'; |
934 }, |
932 }, |
1170 id = $('#miscGrid').jqxGrid('getrowid', selectedrowindex); |
1168 id = $('#miscGrid').jqxGrid('getrowid', selectedrowindex); |
1171 $('#miscGrid').jqxGrid('deleterow', id); |
1169 $('#miscGrid').jqxGrid('deleterow', id); |
1172 } |
1170 } |
1173 }); |
1171 }); |
1174 }, |
1172 }, |
1175 ready: function() { console.log('ready miscs'); $('#jqxTabs').jqxTabs('next'); }, |
1173 ready: function() { $('#jqxTabs').jqxTabs('next'); }, |
1176 columns: [ |
1174 columns: [ |
1177 { text: 'Ingredient', datafield: 'm_name' }, |
1175 { text: 'Ingredient', datafield: 'm_name' }, |
1178 { text: 'Type', width: 140, datafield: 'm_type', |
1176 { text: 'Type', width: 140, datafield: 'm_type', |
1179 cellsrenderer: function(index, datafield, value, defaultvalue, column, rowdata) { |
1177 cellsrenderer: function(index, datafield, value, defaultvalue, column, rowdata) { |
1180 return '<span style="margin: 3px; margin-top: 6px; float: left;">' + MiscTypeData[value].nl + '</span>'; |
1178 return '<span style="margin: 3px; margin-top: 6px; float: left;">' + MiscTypeData[value].nl + '</span>'; |
1368 calcViability(); |
1366 calcViability(); |
1369 calcYeast(); |
1367 calcYeast(); |
1370 } |
1368 } |
1371 }); |
1369 }); |
1372 }, |
1370 }, |
1373 ready: function() { console.log('ready yeasts'); $('#jqxTabs').jqxTabs('next'); }, |
1371 ready: function() { $('#jqxTabs').jqxTabs('next'); }, |
1374 columns: [ |
1372 columns: [ |
1375 { text: 'Gist', datafield: 'y_name' }, |
1373 { text: 'Gist', datafield: 'y_name' }, |
1376 { text: 'Laboratorium', width: 150, datafield: 'y_laboratory' }, |
1374 { text: 'Laboratorium', width: 150, datafield: 'y_laboratory' }, |
1377 { text: 'Code', width: 90, datafield: 'y_product_id' }, |
1375 { text: 'Code', width: 90, datafield: 'y_product_id' }, |
1378 { text: 'Soort', width: 100, datafield: 'y_form', |
1376 { text: 'Soort', width: 100, datafield: 'y_form', |
1606 $('#jqxLoader').jqxLoader({ width: 250, height: 150, isModal: true, text: 'Laden product ...', theme: theme }); |
1604 $('#jqxLoader').jqxLoader({ width: 250, height: 150, isModal: true, text: 'Laden product ...', theme: theme }); |
1607 $('#jqxLoader').jqxLoader('open'); |
1605 $('#jqxLoader').jqxLoader('open'); |
1608 |
1606 |
1609 /* Moved to before all functions */ |
1607 /* Moved to before all functions */ |
1610 dataAdapter.dataBind(); |
1608 dataAdapter.dataBind(); |
1611 console.log('dataAdapter.dataBind() ready'); |
|
1612 |
1609 |
1613 /* |
1610 /* |
1614 * Generic functions |
1611 * Generic functions |
1615 */ |
1612 */ |
1616 function calcViability() { |
1613 function calcViability() { |
2444 } |
2441 } |
2445 }; |
2442 }; |
2446 |
2443 |
2447 function whirlpoolHops() { |
2444 function whirlpoolHops() { |
2448 var row, i, time, rowscount; |
2445 var row, i, time, rowscount; |
2449 console.log('whirlpoolHops()'); |
|
2450 if (!(rowscount = $('#hopGrid').jqxGrid('getdatainformation').rowscount)) |
2446 if (!(rowscount = $('#hopGrid').jqxGrid('getdatainformation').rowscount)) |
2451 return; |
2447 return; |
2452 if (rowscount == 0) |
2448 if (rowscount == 0) |
2453 return; |
2449 return; |
2454 for (i = 0; i < rowscount; i++) { |
2450 for (i = 0; i < rowscount; i++) { |
3975 dataRecord.keg_amount = Round(dataRecord.keg_amount + ((dataRecord.keg_amount / told) * diff), 3); |
3971 dataRecord.keg_amount = Round(dataRecord.keg_amount + ((dataRecord.keg_amount / told) * diff), 3); |
3976 } else { |
3972 } else { |
3977 dataRecord.bottle_amount = tnew; |
3973 dataRecord.bottle_amount = tnew; |
3978 dataRecord.keg_amount = 0; |
3974 dataRecord.keg_amount = 0; |
3979 } |
3975 } |
3980 //console.log('diff:' + diff + ' old:' + told + ' bottle:' + dataRecord.bottle_amount + ' keg:' + dataRecord.keg_amount); |
|
3981 $('#bottle_amount').val(parseFloat(dataRecord.bottle_amount)); |
3976 $('#bottle_amount').val(parseFloat(dataRecord.bottle_amount)); |
3982 $('#keg_amount').val(parseFloat(dataRecord.keg_amount)); |
3977 $('#keg_amount').val(parseFloat(dataRecord.keg_amount)); |
3983 calcCarbonation(); |
3978 calcCarbonation(); |
3984 }); |
3979 }); |
3985 $('#package_infuse_amount').on('change', function(event) { |
3980 $('#package_infuse_amount').on('change', function(event) { |
3992 dataRecord.keg_amount = Round(dataRecord.keg_amount + ((dataRecord.keg_amount / told) * diff), 3); |
3987 dataRecord.keg_amount = Round(dataRecord.keg_amount + ((dataRecord.keg_amount / told) * diff), 3); |
3993 } else { |
3988 } else { |
3994 dataRecord.bottle_amount = tnew; |
3989 dataRecord.bottle_amount = tnew; |
3995 dataRecord.keg_amount = 0; |
3990 dataRecord.keg_amount = 0; |
3996 } |
3991 } |
3997 //console.log('diff:' + diff + ' old:' + told + ' bottle:' + dataRecord.bottle_amount + ' keg:' + dataRecord.keg_amount); |
|
3998 $('#bottle_amount').val(parseFloat(dataRecord.bottle_amount)); |
3992 $('#bottle_amount').val(parseFloat(dataRecord.bottle_amount)); |
3999 $('#keg_amount').val(parseFloat(dataRecord.keg_amount)); |
3993 $('#keg_amount').val(parseFloat(dataRecord.keg_amount)); |
4000 calcCarbonation(); |
3994 calcCarbonation(); |
4001 }); |
3995 }); |
4002 $('#package_infuse_abv').on('change', function(event) { |
3996 $('#package_infuse_abv').on('change', function(event) { |
4487 console.log('saveRecord() ' + textStatus); |
4481 console.log('saveRecord() ' + textStatus); |
4488 } |
4482 } |
4489 }); |
4483 }); |
4490 }; |
4484 }; |
4491 |
4485 |
4492 console.log('start init input fields and selectors'); |
|
4493 |
|
4494 // initialize the input fields. |
4486 // initialize the input fields. |
4495 // Tab 1, Algemeen |
4487 // Tab 1, Algemeen |
4496 $('#name').jqxTooltip({ content: 'De naam voor dit product.' }); |
4488 $('#name').jqxTooltip({ content: 'De naam voor dit product.' }); |
4497 $('#code').jqxTooltip({ content: 'Product code nummer.' }); |
4489 $('#code').jqxTooltip({ content: 'Product code nummer.' }); |
4498 $('#birth').jqxTooltip({ content: 'De ontwerp datum van dit product.' }); |
4490 $('#birth').jqxTooltip({ content: 'De ontwerp datum van dit product.' }); |
5021 hopData.h_time = newtime * 1440; |
5013 hopData.h_time = newtime * 1440; |
5022 } |
5014 } |
5023 ibu = toIBU(hopData.h_useat, hopData.h_form, preboil_sg, parseFloat($('#batch_size').jqxNumberInput('decimal')), |
5015 ibu = toIBU(hopData.h_useat, hopData.h_form, preboil_sg, parseFloat($('#batch_size').jqxNumberInput('decimal')), |
5024 parseFloat(hopData.h_amount), parseFloat(hopData.h_time), parseFloat(hopData.h_alpha), $('#ibu_method').val(), |
5016 parseFloat(hopData.h_amount), parseFloat(hopData.h_time), parseFloat(hopData.h_alpha), $('#ibu_method').val(), |
5025 dataRecord.brew_whirlpool9, dataRecord.brew_whirlpool7, dataRecord.brew_whirlpool6); |
5017 dataRecord.brew_whirlpool9, dataRecord.brew_whirlpool7, dataRecord.brew_whirlpool6); |
5026 // console.log("time changed: "+newtime+" final:"+hopData.h_time+" ibu:"+ibu); |
|
5027 $('#wh_ibu').val(ibu); |
5018 $('#wh_ibu').val(ibu); |
5028 }); |
5019 }); |
5029 $('#wh_useat').jqxDropDownList({ |
5020 $('#wh_useat').jqxDropDownList({ |
5030 theme: theme, |
5021 theme: theme, |
5031 source: HopUseAdapter, |
5022 source: HopUseAdapter, |