841 { name: 'h_caryophyllene', type: 'float' }, |
841 { name: 'h_caryophyllene', type: 'float' }, |
842 { name: 'h_cohumulone', type: 'float' }, |
842 { name: 'h_cohumulone', type: 'float' }, |
843 { name: 'h_myrcene', type: 'float' }, |
843 { name: 'h_myrcene', type: 'float' }, |
844 { name: 'h_total_oil', type: 'float' }, |
844 { name: 'h_total_oil', type: 'float' }, |
845 { name: 'h_inventory', type: 'float' }, |
845 { name: 'h_inventory', type: 'float' }, |
846 { name: 'h_avail', type: 'int' } |
846 { name: 'h_avail', type: 'int' }, |
|
847 { name: 'h_utilisation', type: 'float' }, |
|
848 { name: 'h_bu_factor', type: 'float' } |
847 ], |
849 ], |
848 addrow: function(rowid, rowdata, position, commit) { commit(true); }, |
|
849 deleterow: function(rowid, commit) { commit(true); }, |
|
850 updaterow: function(rowid, rowdata, commit) { commit(true); } |
|
851 }, |
850 }, |
852 hopAdapter = new $.jqx.dataAdapter(hopSource); |
851 hopAdapter = new $.jqx.dataAdapter(hopSource); |
853 |
852 |
854 $('#hopGrid').jqxGrid({ |
853 $('#hopGrid').jqxGrid({ |
855 width: 1240, |
854 width: 1240, |
856 height: 560, |
855 height: 560, |
857 source: hopAdapter, |
856 source: hopAdapter, |
858 theme: theme, |
857 theme: theme, |
859 selectionmode: 'singlerow', |
858 editable: false, |
860 showtoolbar: true, |
|
861 rendertoolbar: function(toolbar) { |
|
862 var container = $("<div style='overflow: hidden; position: relative; margin: 5px;'></div>"); |
|
863 toolbar.append(container); |
|
864 container.append('<div style="float: left; margin-left: 165px;" id="haddrowbutton"></div>'); |
|
865 container.append('<div style="float: left; margin-left: 10px; margin-top: 5px;">In voorraad:</div>'); |
|
866 container.append('<div style="float: left; margin-left: 10px;" id="hinstockbutton"></div>'); |
|
867 container.append('<input style="float: left; margin-left: 400px;" id="hdeleterowbutton" type="button" value="Verwijder hop" />'); |
|
868 // add hop from dropdownlist. |
|
869 $('#haddrowbutton').jqxDropDownList({ |
|
870 placeHolder: 'Kies hop:', |
|
871 theme: theme, |
|
872 template: 'primary', |
|
873 source: hoplist, |
|
874 disabled: (dataRecord.stage > 5), |
|
875 displayMember: 'name', |
|
876 width: 150, |
|
877 height: 27, |
|
878 dropDownWidth: 500, |
|
879 dropDownHeight: 500, |
|
880 renderer: function(index, label, value) { |
|
881 var datarecord = hoplist.records[index]; |
|
882 return datarecord.origin + ' - ' + datarecord.name + ' / ' + HopFormData[datarecord.form].nl + ' (' + datarecord.alpha + '% α) (' + |
|
883 Round(datarecord.inventory * 1000.0, 1) + ' gr)'; |
|
884 } |
|
885 }); |
|
886 $('#haddrowbutton').on('select', function(event) { |
|
887 if (event.args) { |
|
888 var datarecord, row = {}, index = event.args.index; |
|
889 datarecord = hoplist.records[index]; |
|
890 row['h_name'] = datarecord.name; |
|
891 row['h_origin'] = datarecord.origin; |
|
892 row['h_amount'] = 0; |
|
893 row['h_cost'] = datarecord.cost; |
|
894 row['h_type'] = datarecord.type; |
|
895 row['h_form'] = datarecord.form; |
|
896 row['h_useat'] = 2; // Boil |
|
897 row['h_time'] = 0; |
|
898 row['h_alpha'] = datarecord.alpha; |
|
899 row['h_beta'] = datarecord.beta; |
|
900 row['h_hsi'] = datarecord.hsi; |
|
901 row['h_humulene'] = datarecord.humulene; |
|
902 row['h_caryophyllene'] = datarecord.caryophyllene; |
|
903 row['h_cohumulone'] = datarecord.cohumulone; |
|
904 row['h_myrcene'] = datarecord.myrcene; |
|
905 row['h_total_oil'] = datarecord.total_oil; |
|
906 row['h_inventory'] = datarecord.inventory; |
|
907 /* If stage > useat moment, adjust the moment */ |
|
908 row['h_useat'] = minimum_hop(dataRecord.stage, row['h_useat']); |
|
909 $('#hopGrid').jqxGrid('addrow', null, row); |
|
910 } |
|
911 $('#haddrowbutton').jqxDropDownList('clearSelection'); |
|
912 }); |
|
913 |
|
914 $('#hinstockbutton').jqxCheckBox({ theme: theme, height: 27, disabled: (dataRecord.stage > 5) }); |
|
915 $('#hinstockbutton').on('change', function(event) { |
|
916 hopinstock = event.args.checked; |
|
917 hoplist.dataBind(); |
|
918 }); |
|
919 |
|
920 // delete selected hop. |
|
921 $('#hdeleterowbutton').jqxButton({ template: 'danger', theme: theme, height: 27, width: 150, disabled: (dataRecord.stage > 5) }); |
|
922 $('#hdeleterowbutton').on('click', function() { |
|
923 var rowscount, id, selectedrowindex = $('#hopGrid').jqxGrid('getselectedrowindex'); |
|
924 rowscount = $('#hopGrid').jqxGrid('getdatainformation').rowscount; |
|
925 if (selectedrowindex >= 0 && selectedrowindex < rowscount) { |
|
926 useat = $('#hopGrid').jqxGrid('getcellvalue', selectedrowindex, 'h_useat'); |
|
927 if (block_hop(dataRecord.stage, useat)) { |
|
928 alert('Ingredieënt is al verwerkt.'); |
|
929 } else { |
|
930 id = $('#hopGrid').jqxGrid('getrowid', selectedrowindex); |
|
931 $('#hopGrid').jqxGrid('deleterow', id); |
|
932 } |
|
933 } |
|
934 calcIBUs(); |
|
935 }); |
|
936 }, |
|
937 ready: function() { $('#jqxTabs').jqxTabs('next'); }, |
859 ready: function() { $('#jqxTabs').jqxTabs('next'); }, |
938 columns: [ |
860 columns: [ |
939 { text: 'Hop', datafield: 'h_name', |
861 { text: 'Hop', datafield: 'h_name' }, |
940 cellsrenderer: function(index, datafield, value, defaultvalue, column, rowdata) { |
862 { text: 'Origin', width: 180, datafield: 'h_origin' }, |
941 return '<span style="margin: 3px; margin-top: 6px; float: left;">' + rowdata.h_origin + ' / ' + rowdata.h_name + '</span>'; |
|
942 }, |
|
943 }, |
|
944 { text: 'Type', width: 90, datafield: 'h_type', |
863 { text: 'Type', width: 90, datafield: 'h_type', |
945 cellsrenderer: function(index, datafield, value, defaultvalue, column, rowdata) { |
864 cellsrenderer: function(index, datafield, value, defaultvalue, column, rowdata) { |
946 return '<span style="margin: 4px; margin-top: 6px; float: left;">' + HopTypeData[value].nl + '</span>'; |
865 return '<span style="margin: 4px; margin-top: 6px; float: left;">' + HopTypeData[value].nl + '</span>'; |
947 } |
866 } |
948 }, |
867 }, |
949 { text: 'Vorm', width: 90, datafield: 'h_form', |
868 { text: 'Vorm', width: 110, datafield: 'h_form', |
950 cellsrenderer: function(index, datafield, value, defaultvalue, column, rowdata) { |
869 cellsrenderer: function(index, datafield, value, defaultvalue, column, rowdata) { |
951 return '<span style="margin: 4px; margin-top: 6px; float: left;">' + HopFormData[value].nl + '</span>'; |
870 return '<span style="margin: 4px; margin-top: 6px; float: left;">' + HopFormData[value].nl + '</span>'; |
952 } |
871 } |
953 }, |
872 }, |
954 { text: 'Alpha', datafield: 'h_alpha', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'p1' }, |
873 { text: 'Alpha', datafield: 'h_alpha', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'p1' }, |
968 } |
887 } |
969 }, |
888 }, |
970 { text: 'IBU', datafield: 'ibu', width: 80, align: 'right', |
889 { text: 'IBU', datafield: 'ibu', width: 80, align: 'right', |
971 cellsrenderer: function(index, datafield, value, defaultvalue, column, rowdata) { |
890 cellsrenderer: function(index, datafield, value, defaultvalue, column, rowdata) { |
972 var ibu = toIBU(rowdata.h_useat, rowdata.h_form, preboil_sg, parseFloat(dataRecord.batch_size), |
891 var ibu = toIBU(rowdata.h_useat, rowdata.h_form, preboil_sg, parseFloat(dataRecord.batch_size), |
973 parseFloat(rowdata.h_amount), parseFloat(rowdata.h_time), parseFloat(rowdata.h_alpha), $('#ibu_method').val(), |
892 parseFloat(rowdata.h_amount), parseFloat(rowdata.h_time), parseFloat(rowdata.h_alpha), dataRecord.ibu_method, |
974 dataRecord.brew_whirlpool9, dataRecord.brew_whirlpool7, dataRecord.brew_whirlpool6); |
893 dataRecord.brew_whirlpool9, dataRecord.brew_whirlpool7, dataRecord.brew_whirlpool6); |
975 return '<span style="margin: 4px; margin-top: 6px; float: right;">' + dataAdapter.formatNumber(ibu, 'f1') + '</span>'; |
894 return '<span style="margin: 4px; margin-top: 6px; float: right;">' + dataAdapter.formatNumber(ibu, 'f1') + '</span>'; |
976 } |
895 } |
977 }, |
896 }, |
978 { text: 'Gewicht', datafield: 'h_amount', width: 110, align: 'right', |
897 { text: 'Gewicht', datafield: 'h_amount', width: 110, align: 'right', |
991 if (value < 1) |
910 if (value < 1) |
992 amount = dataAdapter.formatNumber(value * 1000, 'f1') + ' gr'; |
911 amount = dataAdapter.formatNumber(value * 1000, 'f1') + ' gr'; |
993 return '<span style="margin: 4px; margin-top: 6px; float: right; color: ' + color + ';">' + amount + '</span>'; |
912 return '<span style="margin: 4px; margin-top: 6px; float: right; color: ' + color + ';">' + amount + '</span>'; |
994 } else { |
913 } else { |
995 return '<span></span>'; |
914 return '<span></span>'; |
996 } |
|
997 } |
|
998 }, |
|
999 { text: '', datafield: 'Edit', columntype: 'button', width: 100, align: 'center', |
|
1000 cellsrenderer: function() { |
|
1001 return 'Wijzig'; |
|
1002 }, buttonclick: function(row) { |
|
1003 hopRow = row; |
|
1004 hopData = $('#hopGrid').jqxGrid('getrowdata', hopRow); |
|
1005 if (block_hop(dataRecord.stage, hopData.h_useat)) { |
|
1006 alert('Ingredieënt is al verwerkt.'); |
|
1007 } else { |
|
1008 console.log('edit button row ' + row); |
|
1009 $('#wh_name').val(hopData.h_name); |
|
1010 $('#wh_amount').val(hopData.h_amount * 1000); |
|
1011 var ibu = toIBU(hopData.h_useat, hopData.h_form, preboil_sg, parseFloat($('#batch_size').jqxNumberInput('decimal')), |
|
1012 parseFloat(hopData.h_amount), parseFloat(hopData.h_time), parseFloat(hopData.h_alpha), $('#ibu_method').val(), |
|
1013 dataRecord.brew_whirlpool9, dataRecord.brew_whirlpool7, dataRecord.brew_whirlpool6); |
|
1014 $('#wh_ibu').val(ibu); |
|
1015 if (hopData.h_useat == 5) // Dry hop |
|
1016 $('#wh_time').val(hopData.h_time / 1440); |
|
1017 else |
|
1018 $('#wh_time').val(hopData.h_time); |
|
1019 $('#wh_useat').val(hopData.h_useat); |
|
1020 for (i = 0; i < 5; i++) { |
|
1021 drop_endis(dataRecord.stage > 2, '#wh_useat', i); |
|
1022 } |
|
1023 // show the popup window. |
|
1024 $('#popupHop').jqxWindow('open'); |
|
1025 } |
915 } |
1026 } |
916 } |
1027 } |
917 } |
1028 ] |
918 ] |
1029 }); |
919 }); |