326 }, |
326 }, |
327 |
327 |
328 // Load data and select one record. |
328 // Load data and select one record. |
329 dataAdapter = new $.jqx.dataAdapter(source, { |
329 dataAdapter = new $.jqx.dataAdapter(source, { |
330 loadComplete: function() { |
330 loadComplete: function() { |
|
331 console.log('main data begin load'); |
331 var records = dataAdapter.records; |
332 var records = dataAdapter.records; |
332 dataRecord = records[0]; |
333 dataRecord = records[0]; |
|
334 console.log('main data ' + records.length + ' records'); |
333 // Hidden record uuid |
335 // Hidden record uuid |
334 $('#name').val(dataRecord.name); |
336 $('#name').val(dataRecord.name); |
335 $('#code').val(dataRecord.code); |
337 $('#code').val(dataRecord.code); |
336 $('#birth').val(dataRecord.birth); |
338 $('#birth').val(dataRecord.birth); |
337 $('#stage').val(StageData[dataRecord.stage].nl); |
339 $('#stage').val(StageData[dataRecord.stage].nl); |
547 $('#divide_batch').val('n.v.t.'); |
549 $('#divide_batch').val('n.v.t.'); |
548 // hidden divide_size |
550 // hidden divide_size |
549 // hidden divide_factor |
551 // hidden divide_factor |
550 // hidden divide_parts |
552 // hidden divide_parts |
551 // hidden divide_part |
553 // hidden divide_part |
|
554 console.log('set editFermentable'); |
552 editFermentable(dataRecord); |
555 editFermentable(dataRecord); |
|
556 console.log('set editHop'); |
553 editHop(dataRecord); |
557 editHop(dataRecord); |
|
558 console.log('set editMisc'); |
554 editMisc(dataRecord); |
559 editMisc(dataRecord); |
|
560 console.log('set editYeast'); |
555 editYeast(dataRecord); |
561 editYeast(dataRecord); |
|
562 console.log('set editMash'); |
556 editMash(dataRecord); |
563 editMash(dataRecord); |
557 console.log('main data loaded'); |
564 console.log('main data loaded'); |
558 calcStage(); |
565 calcStage(); |
559 $('#jqxTabs').jqxTabs('select', 2); |
566 $('#jqxTabs').jqxTabs('select', 2); |
|
567 console.log('main data ready'); |
560 }, |
568 }, |
561 loadError: function(jqXHR, status, error) { |
569 loadError: function(jqXHR, status, error) { |
562 console.log('main data load error: ' + status + ' ' + error); |
570 console.log('main data load error: ' + status + ' ' + error); |
563 } |
571 } |
564 }); |
572 }); |
567 var editFermentable = function(data) { |
575 var editFermentable = function(data) { |
568 var fermentableSource = { |
576 var fermentableSource = { |
569 localdata: data.fermentables, |
577 localdata: data.fermentables, |
570 datatype: 'local', |
578 datatype: 'local', |
571 cache: false, |
579 cache: false, |
572 async: false, |
580 async: true, |
573 datafields: [ |
581 datafields: [ |
574 { name: 'f_name', type: 'string' }, |
582 { name: 'f_name', type: 'string' }, |
575 { name: 'f_origin', type: 'string' }, |
583 { name: 'f_origin', type: 'string' }, |
576 { name: 'f_supplier', type: 'string' }, |
584 { name: 'f_supplier', type: 'string' }, |
577 { name: 'f_amount', type: 'float' }, |
585 { name: 'f_amount', type: 'float' }, |
722 } |
730 } |
723 calcFermentables(); |
731 calcFermentables(); |
724 calcIBUs(); |
732 calcIBUs(); |
725 }); |
733 }); |
726 }, |
734 }, |
727 ready: function() { $('#jqxTabs').jqxTabs('next'); }, |
735 ready: function() { console.log('ready fermentables'); $('#jqxTabs').jqxTabs('next'); }, |
728 columns: [ |
736 columns: [ |
729 { text: 'Vergistbaar ingrediënt', datafield: 'f_name', |
737 { text: 'Vergistbaar ingrediënt', datafield: 'f_name', |
730 cellsrenderer: function(index, datafield, value, defaultvalue, column, rowdata) { |
738 cellsrenderer: function(index, datafield, value, defaultvalue, column, rowdata) { |
731 return '<span style="margin: 3px; margin-top: 6px; float: left;">' + rowdata.f_supplier + ' / ' + |
739 return '<span style="margin: 3px; margin-top: 6px; float: left;">' + rowdata.f_supplier + ' / ' + |
732 rowdata.f_name + ' (' + rowdata.f_color + ' EBC)</span>'; |
740 rowdata.f_name + ' (' + rowdata.f_color + ' EBC)</span>'; |
808 var editHop = function(data) { |
816 var editHop = function(data) { |
809 var hopSource = { |
817 var hopSource = { |
810 localdata: data.hops, |
818 localdata: data.hops, |
811 datatype: 'local', |
819 datatype: 'local', |
812 cache: false, |
820 cache: false, |
813 async: false, |
821 async: true, |
814 datafields: [ |
822 datafields: [ |
815 { name: 'h_name', type: 'string' }, |
823 { name: 'h_name', type: 'string' }, |
816 { name: 'h_origin', type: 'string' }, |
824 { name: 'h_origin', type: 'string' }, |
817 { name: 'h_amount', type: 'float' }, |
825 { name: 'h_amount', type: 'float' }, |
818 { name: 'h_cost', type: 'float' }, |
826 { name: 'h_cost', type: 'float' }, |
829 { name: 'h_myrcene', type: 'float' }, |
837 { name: 'h_myrcene', type: 'float' }, |
830 { name: 'h_total_oil', type: 'float' }, |
838 { name: 'h_total_oil', type: 'float' }, |
831 { name: 'h_inventory', type: 'float' }, |
839 { name: 'h_inventory', type: 'float' }, |
832 { name: 'h_avail', type: 'int' } |
840 { name: 'h_avail', type: 'int' } |
833 ], |
841 ], |
834 addrow: function(rowid, rowdata, position, commit) { |
842 addrow: function(rowid, rowdata, position, commit) { commit(true); }, |
835 commit(true); |
843 deleterow: function(rowid, commit) { commit(true); }, |
836 }, |
844 updaterow: function(rowid, rowdata, commit) { commit(true); } |
837 deleterow: function(rowid, commit) { |
|
838 commit(true); |
|
839 }, |
|
840 updaterow: function(rowid, rowdata, commit) { |
|
841 commit(true); |
|
842 } |
|
843 }, |
845 }, |
844 hopAdapter = new $.jqx.dataAdapter(hopSource); |
846 hopAdapter = new $.jqx.dataAdapter(hopSource); |
845 |
847 |
846 $('#hopGrid').jqxGrid({ |
848 $('#hopGrid').jqxGrid({ |
847 width: 1240, |
849 width: 1240, |
917 $('#hopGrid').jqxGrid('deleterow', id); |
919 $('#hopGrid').jqxGrid('deleterow', id); |
918 } |
920 } |
919 calcIBUs(); |
921 calcIBUs(); |
920 }); |
922 }); |
921 }, |
923 }, |
922 ready: function() { $('#jqxTabs').jqxTabs('next'); }, |
924 ready: function() { console.log('ready hops'); $('#jqxTabs').jqxTabs('next'); }, |
923 columns: [ |
925 columns: [ |
924 { text: 'Hop', datafield: 'h_name', |
926 { text: 'Hop', datafield: 'h_name', |
925 cellsrenderer: function(index, datafield, value, defaultvalue, column, rowdata) { |
927 cellsrenderer: function(index, datafield, value, defaultvalue, column, rowdata) { |
926 return '<span style="margin: 3px; margin-top: 6px; float: left;">' + rowdata.h_origin + ' / ' + rowdata.h_name + '</span>'; |
928 return '<span style="margin: 3px; margin-top: 6px; float: left;">' + rowdata.h_origin + ' / ' + rowdata.h_name + '</span>'; |
927 }, |
929 }, |
1030 { name: 'm_time', type: 'float' }, |
1032 { name: 'm_time', type: 'float' }, |
1031 { name: 'm_amount_is_weight', type: 'int' }, |
1033 { name: 'm_amount_is_weight', type: 'int' }, |
1032 { name: 'm_inventory', type: 'float' }, |
1034 { name: 'm_inventory', type: 'float' }, |
1033 { name: 'm_avail', type: 'int' } |
1035 { name: 'm_avail', type: 'int' } |
1034 ], |
1036 ], |
1035 addrow: function(rowid, rowdata, position, commit) { |
1037 addrow: function(rowid, rowdata, position, commit) { commit(true); }, |
1036 commit(true); |
1038 deleterow: function(rowid, commit) { commit(true); }, |
1037 }, |
1039 updaterow: function(rowid, rowdata, commit) { commit(true); } |
1038 deleterow: function(rowid, commit) { |
|
1039 commit(true); |
|
1040 }, |
|
1041 updaterow: function(rowid, rowdata, commit) { |
|
1042 commit(true); |
|
1043 } |
|
1044 }, |
1040 }, |
1045 miscAdapter = new $.jqx.dataAdapter(miscSource, { |
1041 miscAdapter = new $.jqx.dataAdapter(miscSource, { |
1046 beforeLoadComplete: function(records) { |
1042 beforeLoadComplete: function(records) { |
1047 var row, i, data = new Array(); |
1043 var row, i, data = new Array(); |
1048 for (i = 0; i < records.length; i++) { |
1044 for (i = 0; i < records.length; i++) { |
1061 break; |
1057 break; |
1062 case 'NaCl': |
1058 case 'NaCl': |
1063 $('#wa_nacl').val(row.m_amount * 1000); |
1059 $('#wa_nacl').val(row.m_amount * 1000); |
1064 break; |
1060 break; |
1065 case 'Melkzuur': |
1061 case 'Melkzuur': |
|
1062 console.log('setting the #wa_acid_name'); |
1066 $('#wa_acid_name').val(0); |
1063 $('#wa_acid_name').val(0); |
1067 $('#wa_acid').val(row.m_amount * 1000); |
1064 $('#wa_acid').val(row.m_amount * 1000); |
1068 $('#wa_acid_perc').val(80); |
1065 $('#wa_acid_perc').val(80); |
1069 last_acid = 'Melkzuur'; |
1066 last_acid = 'Melkzuur'; |
1070 break; |
1067 break; |
1171 id = $('#miscGrid').jqxGrid('getrowid', selectedrowindex); |
1166 id = $('#miscGrid').jqxGrid('getrowid', selectedrowindex); |
1172 $('#miscGrid').jqxGrid('deleterow', id); |
1167 $('#miscGrid').jqxGrid('deleterow', id); |
1173 } |
1168 } |
1174 }); |
1169 }); |
1175 }, |
1170 }, |
1176 ready: function() { $('#jqxTabs').jqxTabs('next'); }, |
1171 ready: function() { console.log('ready miscs'); $('#jqxTabs').jqxTabs('next'); }, |
1177 columns: [ |
1172 columns: [ |
1178 { text: 'Ingredient', datafield: 'm_name' }, |
1173 { text: 'Ingredient', datafield: 'm_name' }, |
1179 { text: 'Type', width: 140, datafield: 'm_type', |
1174 { text: 'Type', width: 140, datafield: 'm_type', |
1180 cellsrenderer: function(index, datafield, value, defaultvalue, column, rowdata) { |
1175 cellsrenderer: function(index, datafield, value, defaultvalue, column, rowdata) { |
1181 return '<span style="margin: 3px; margin-top: 6px; float: left;">' + MiscTypeData[value].nl + '</span>'; |
1176 return '<span style="margin: 3px; margin-top: 6px; float: left;">' + MiscTypeData[value].nl + '</span>'; |
1282 { name: 'y_pitch_temperature', type: 'float' }, |
1277 { name: 'y_pitch_temperature', type: 'float' }, |
1283 { name: 'y_pofpos', type: 'int' }, |
1278 { name: 'y_pofpos', type: 'int' }, |
1284 { name: 'y_zymocide', type: 'int' }, |
1279 { name: 'y_zymocide', type: 'int' }, |
1285 { name: 'y_avail', type: 'int' } |
1280 { name: 'y_avail', type: 'int' } |
1286 ], |
1281 ], |
1287 addrow: function(rowid, rowdata, position, commit) { |
1282 addrow: function(rowid, rowdata, position, commit) { commit(true); }, |
1288 console.log('yeast addrow ' + rowid); |
1283 deleterow: function(rowid, commit) { commit(true); }, |
1289 commit(true); |
1284 updaterow: function(rowid, rowdata, commit) { commit(true); } |
1290 }, |
|
1291 deleterow: function(rowid, commit) { |
|
1292 console.log('yeast deleterow ' + rowid); |
|
1293 commit(true); |
|
1294 }, |
|
1295 updaterow: function(rowid, rowdata, commit) { |
|
1296 console.log('yeast updaterow ' + rowid); |
|
1297 commit(true); |
|
1298 } |
|
1299 }, |
1285 }, |
1300 yeastAdapter = new $.jqx.dataAdapter(yeastSource); |
1286 yeastAdapter = new $.jqx.dataAdapter(yeastSource); |
1301 |
1287 |
1302 $('#yeastGrid').jqxGrid({ |
1288 $('#yeastGrid').jqxGrid({ |
1303 width: 1240, |
1289 width: 1240, |
1378 calcViability(); |
1364 calcViability(); |
1379 calcYeast(); |
1365 calcYeast(); |
1380 } |
1366 } |
1381 }); |
1367 }); |
1382 }, |
1368 }, |
1383 ready: function() { $('#jqxTabs').jqxTabs('next'); }, |
1369 ready: function() { console.log('ready yeasts'); $('#jqxTabs').jqxTabs('next'); }, |
1384 columns: [ |
1370 columns: [ |
1385 { text: 'Gist', datafield: 'y_name' }, |
1371 { text: 'Gist', datafield: 'y_name' }, |
1386 { text: 'Laboratorium', width: 150, datafield: 'y_laboratory' }, |
1372 { text: 'Laboratorium', width: 150, datafield: 'y_laboratory' }, |
1387 { text: 'Code', width: 90, datafield: 'y_product_id' }, |
1373 { text: 'Code', width: 90, datafield: 'y_product_id' }, |
1388 { text: 'Soort', width: 100, datafield: 'y_form', |
1374 { text: 'Soort', width: 100, datafield: 'y_form', |
1554 } |
1540 } |
1555 }); |
1541 }); |
1556 }, |
1542 }, |
1557 ready: function() { |
1543 ready: function() { |
1558 /* Calculate the whole recipe */ |
1544 /* Calculate the whole recipe */ |
|
1545 console.log('ready mashs, start calculations'); |
1559 calcFermentables(); |
1546 calcFermentables(); |
1560 whirlpoolHops(); |
1547 whirlpoolHops(); |
1561 calcIBUs(); |
1548 calcIBUs(); |
1562 calcMiscs(); |
1549 calcMiscs(); |
1563 showStarter(); |
1550 showStarter(); |
1564 calcYeast(); |
1551 calcYeast(); |
1565 calcInit(); |
1552 calcInit(); |
1566 calcMash(); |
1553 calcMash(); |
|
1554 console.log('calculations ready'); |
1567 $('#jqxLoader').jqxLoader('close'); |
1555 $('#jqxLoader').jqxLoader('close'); |
1568 $('#jqxTabs').jqxTabs('first'); |
1556 $('#jqxTabs').jqxTabs('first'); |
1569 }, |
1557 }, |
1570 columns: [ |
1558 columns: [ |
1571 { text: 'Stap naam', datafield: 'step_name' }, |
1559 { text: 'Stap naam', datafield: 'step_name' }, |