583 if (brewstage > 0) { |
795 if (brewstage > 0) { |
584 $("#Delete").jqxButton({ disabled: true }); |
796 $("#Delete").jqxButton({ disabled: true }); |
585 $("#birth").jqxDateTimeInput({ disabled: true }); |
797 $("#birth").jqxDateTimeInput({ disabled: true }); |
586 } |
798 } |
587 if (brewstage < 3) { |
799 if (brewstage < 3) { |
588 $("#brew_log").jqxButton({ disabled: true }); |
800 // $("#brew_log").jqxButton({ disabled: true }); |
589 $("#ferment_log").jqxButton({ disabled: true }); |
801 // $("#ferment_log").jqxButton({ disabled: true }); |
590 } else { |
802 } else { |
591 if (! dataRecord.log_brew) |
803 // if (! dataRecord.log_brew) |
592 $("#brew_log").jqxButton({ disabled: true }); |
804 // $("#brew_log").jqxButton({ disabled: true }); |
593 if (! dataRecord.log_fermentation) |
805 // if (! dataRecord.log_fermentation) |
594 $("#ferment_log").jqxButton({ disabled: true }); |
806 // $("#ferment_log").jqxButton({ disabled: true }); |
595 } |
807 } |
596 if (brewstage < 6) |
808 if (brewstage < 6) |
597 $("#inventory_reduced").jqxCheckBox({ disabled : true }); |
809 $("#inventory_reduced").jqxCheckBox({ disabled : true }); |
598 else if ($('#inventory_reduced').jqxCheckBox('checked')) |
810 else if ($('#inventory_reduced').jqxCheckBox('checked')) |
599 $("#inventory_reduced").jqxCheckBox({ disabled : true }); |
811 $("#inventory_reduced").jqxCheckBox({ disabled : true }); |
600 |
812 |
601 calcFermentables(); |
813 $('#jqxTabs').jqxTabs('select', 2); |
602 calcIBUs(); |
|
603 calcSGendMash(); |
|
604 calcMashEfficiency(); |
|
605 }, |
814 }, |
606 loadError: function (jqXHR, status, error) { |
815 loadError: function (jqXHR, status, error) { |
607 } |
816 }, |
|
817 beforeLoadComplete: function (records) { |
|
818 $('#jqxLoader').jqxLoader('open'); |
|
819 } |
608 }); |
820 }); |
609 dataAdapter.dataBind(); |
821 dataAdapter.dataBind(); |
610 |
822 |
|
823 // Inline fermentables editor |
|
824 var editFermentable = function (data) { |
|
825 var fermentableSource = { |
|
826 localdata: data.fermentables, |
|
827 datatype: "local", |
|
828 datafields: [ |
|
829 { name: 'f_name', type: 'string' }, |
|
830 { name: 'f_origin', type: 'string' }, |
|
831 { name: 'f_supplier', type: 'string' }, |
|
832 { name: 'f_amount', type: 'float' }, |
|
833 { name: 'f_cost', type: 'float' }, |
|
834 { name: 'f_type', type: 'string' }, |
|
835 { name: 'f_yield', type: 'float' }, |
|
836 { name: 'f_color', type: 'float' }, |
|
837 { name: 'f_coarse_fine_diff', type: 'float' }, |
|
838 { name: 'f_moisture', type: 'float' }, |
|
839 { name: 'f_diastatic_power', type: 'float' }, |
|
840 { name: 'f_protein', type: 'float' }, |
|
841 { name: 'f_max_in_batch', type: 'float' }, |
|
842 { name: 'f_graintype', type: 'string' }, |
|
843 { name: 'f_added', type: 'string' }, |
|
844 { name: 'f_dissolved_protein', type: 'float' }, |
|
845 { name: 'f_recommend_mash', type: 'bool' }, |
|
846 { name: 'f_add_after_boil', type: 'bool' }, |
|
847 { name: 'f_adjust_to_total_100', type: 'bool' }, |
|
848 { name: 'f_percentage', type: 'float' }, |
|
849 { name: 'f_di_ph', type: 'float' } |
|
850 ], |
|
851 addrow: function (rowid, rowdata, position, commit) { |
|
852 commit(true); |
|
853 }, |
|
854 deleterow: function (rowid, commit) { |
|
855 commit(true); |
|
856 } |
|
857 }; |
|
858 var fermentableAdapter = new $.jqx.dataAdapter(fermentableSource); |
|
859 $("#fermentableGrid").jqxGrid({ |
|
860 width: 1150, |
|
861 height: 400, |
|
862 source: fermentableAdapter, |
|
863 theme: theme, |
|
864 selectionmode: 'singlerow', |
|
865 editmode: 'selectedcell', |
|
866 editable: true, |
|
867 localization: getLocalization(), |
|
868 showtoolbar: true, |
|
869 rendertoolbar: function (toolbar) { |
|
870 var me = this; |
|
871 var container = $("<div style='overflow: hidden; position: relative; margin: 5px;'></div>"); |
|
872 toolbar.append(container); |
|
873 container.append('<div style="float: left; margin-left: 165px;" id="faddrowbutton"></div>'); |
|
874 container.append('<div style="float: left; margin-left: 10px; margin-top: 5px;">In voorraad:</div>'); |
|
875 container.append('<div style="float: left; margin-left: 10px;" id="finstockbutton"></div>'); |
|
876 container.append('<input style="float: left; margin-left: 400px;" id="fdeleterowbutton" type="button" value="Verwijder mout" />'); |
|
877 // add fermentable from dropdownlist. |
|
878 $("#faddrowbutton").jqxDropDownList({ |
|
879 placeHolder: "Kies mout:", |
|
880 theme: theme, |
|
881 source: fermentablelist, |
|
882 displayMember: "name", |
|
883 width: 150, |
|
884 height: 27, |
|
885 dropDownWidth: 500, |
|
886 dropDownHeight: 500, |
|
887 renderer: function (index, label, value) { |
|
888 var datarecord = fermentablelist.records[index]; |
|
889 return datarecord.supplier+ " / " + datarecord.name + " (" + datarecord.color + " EBC)"; |
|
890 } |
|
891 }); |
|
892 $("#faddrowbutton").on('select', function (event) { |
|
893 if (event.args) { |
|
894 var rowscount = $("#fermentableGrid").jqxGrid('getdatainformation').rowscount; |
|
895 var index = event.args.index; |
|
896 var datarecord = fermentablelist.records[index]; |
|
897 var row = {}; |
|
898 row["f_name"] = datarecord.name; |
|
899 row["f_origin"] = datarecord.origin; |
|
900 row["f_supplier"] = datarecord.supplier; |
|
901 row["f_amount"] = 0; |
|
902 row["f_cost"] = datarecord.cost; |
|
903 row["f_type"] = datarecord.type; |
|
904 row["f_yield"] = datarecord.yield; |
|
905 row["f_color"] = datarecord.color; |
|
906 row["f_coarse_fine_diff"] = datarecord.coarse_fine_diff; |
|
907 row["f_moisture"] = datarecord.moisture; |
|
908 row["f_diastatic_power"] = datarecord.diastatic_power; |
|
909 row["f_protein"] = datarecord.protein; |
|
910 row["f_max_in_batch"] = datarecord.max_in_batch; |
|
911 row["f_graintype"] = datarecord.graintype; |
|
912 if (datarecord.add_after_boil) { |
|
913 row["f_added"] = "Primary"; |
|
914 } else if ((datarecord.type == "Sugar") || (datarecord.type == "Adjunct")) { |
|
915 row["f_added"] = "Boil"; |
|
916 } else { |
|
917 row["f_added"] = "Mash"; |
|
918 } |
|
919 row["f_dissolved_protein"] = 0; |
|
920 row["f_recommend_mash"] = datarecord.recommend_mash; |
|
921 row["f_add_after_boil"] = datarecord.add_after_boil; |
|
922 if (rowscount == 0) { |
|
923 // The first fermentable |
|
924 row["f_adjust_to_total_100"] = 1; |
|
925 row["f_percentage"] = 100; |
|
926 } else { |
|
927 row["f_adjust_to_total_100"] = 0; |
|
928 row["f_percentage"] = 0; |
|
929 } |
|
930 row["f_di_ph"] = datarecord.di_ph; |
|
931 var commit = $("#fermentableGrid").jqxGrid('addrow', null, row); |
|
932 } |
|
933 }); |
|
934 |
|
935 $("#finstockbutton").jqxCheckBox({ theme: theme, height: 27 }); |
|
936 $("#finstockbutton").on('change', function (event) { |
|
937 fermentableinstock = event.args.checked; |
|
938 fermentablelist.dataBind(); |
|
939 }); |
|
940 |
|
941 // delete selected fermentable. |
|
942 $("#fdeleterowbutton").jqxButton({ theme: theme, height: 27, width: 150 }); |
|
943 $("#fdeleterowbutton").on('click', function () { |
|
944 var selectedrowindex = $("#fermentableGrid").jqxGrid('getselectedrowindex'); |
|
945 var rowscount = $("#fermentableGrid").jqxGrid('getdatainformation').rowscount; |
|
946 if (selectedrowindex >= 0 && selectedrowindex < rowscount) { |
|
947 var id = $("#fermentableGrid").jqxGrid('getrowid', selectedrowindex); |
|
948 var percent = $('#fermentableGrid').jqxGrid('getcellvalue', id, "f_percentage"); |
|
949 var amount = $('#fermentableGrid').jqxGrid('getcellvalue', id, "f_amount"); |
|
950 var commit = $("#fermentableGrid").jqxGrid('deleterow', id); |
|
951 } |
|
952 rowscount = $("#fermentableGrid").jqxGrid('getdatainformation').rowscount; |
|
953 if (rowscount > 1) { |
|
954 if (to_100) { |
|
955 for (var i = 0; i < rowscount; i++) { |
|
956 var rowdata = $("#fermentableGrid").jqxGrid('getrowdata', i); |
|
957 if (rowdata.f_adjust_to_total_100) { |
|
958 rowdata.f_percentage += percent; |
|
959 rowdata.f_amount += amount; |
|
960 } |
|
961 } |
|
962 } else { |
|
963 var tw = 0; |
|
964 for (i = 0; i < rowscount; i++) { |
|
965 var rowdata = $("#fermentableGrid").jqxGrid('getrowdata', i); |
|
966 tw += rowdata.f_amount; |
|
967 }; |
|
968 for (i = 0; i < rowscount; i++) { |
|
969 var rowdata = $("#fermentableGrid").jqxGrid('getrowdata', i); |
|
970 var percentage = Math.round(rowdata.f_amount / tw * 1000) / 10.0; |
|
971 $("#fermentableGrid").jqxGrid('setcellvalue', i, "f_percentage", percentage); |
|
972 }; |
|
973 } |
|
974 } else { |
|
975 $("#fermentableGrid").jqxGrid('setcellvalue', 0, "f_percentage", 100); |
|
976 } |
|
977 calcFermentables(); |
|
978 calcSVG(); |
|
979 calcABV(); |
|
980 calcIBUs(); |
|
981 }); |
|
982 }, |
|
983 ready: function() { |
|
984 calcFermentables(); |
|
985 $('#jqxTabs').jqxTabs('next'); |
|
986 }, |
|
987 columns: [ |
|
988 { text: 'Vergistbaar ingrediënt', editable: false, datafield: 'f_name', |
|
989 cellsrenderer: function (row, columnfield, value, defaulthtml, columnproperties) { |
|
990 var rowData = $("#fermentableGrid").jqxGrid('getrowdata', row); |
|
991 return "<span style='margin: 3px; margin-top: 6px; float: "+ |
|
992 columnproperties.cellsalign+"'>" +rowData.f_supplier+" / "+rowData.f_name+" ("+rowData.f_color+" EBC)</span>"; |
|
993 } |
|
994 }, |
|
995 { text: 'Type', editable: false, align: 'center', cellsalign: 'center', width: 100, datafield: 'f_type' }, |
|
996 { text: 'Moment', width: 110, align: 'center', cellsalign: 'center', datafield: 'f_added', columntype: 'dropdownlist', |
|
997 createeditor: function (row, column, editor) { |
|
998 var srcAdded = [ "Mash", "Boil", "Fermentation", "Lagering", "Bottle" ]; |
|
999 editor.jqxDropDownList({ autoDropDownHeight: true, source: srcAdded }); |
|
1000 } |
|
1001 }, |
|
1002 { text: 'Opbrengst', editable: false, datafield: 'f_yield', width: 90, align: 'right', cellsalign: 'right', cellsformat: 'p1' }, |
|
1003 { text: 'Gewicht Kg', datafield: 'f_amount', width: 120, align: 'right', cellsalign: 'right', cellsformat: 'f3', |
|
1004 columntype: 'numberinput', |
|
1005 validation: function (cell, value) { |
|
1006 // Maximum weight is the batch_size, just a simple check. |
|
1007 var maxmout = parseFloat($("#batch_size").jqxNumberInput('decimal')); |
|
1008 if (value < 0 || value > maxmout) { |
|
1009 return { result: false, message: "Gewicht moet 0-"+maxmout+" zijn" }; |
|
1010 } |
|
1011 return true; |
|
1012 }, |
|
1013 initeditor: function (row, cellvalue, editor) { |
|
1014 editor.jqxNumberInput({ inputMode: 'simple', min: 0, decimalDigits: 3, spinButtons: false }); |
|
1015 }, |
|
1016 cellvaluechanging: function (row, column, columntype, oldvalue, newvalue) { |
|
1017 if (to_100) { |
|
1018 return oldvalue; // When using percentages, don't allow edited results. |
|
1019 } |
|
1020 } |
|
1021 }, |
|
1022 { text: 'Percentage', datafield: 'f_percentage', width: 110, align: 'right', cellsalign: 'right', cellsformat: 'p1', |
|
1023 columntype: 'numberinput', |
|
1024 validation: function (cell, value) { |
|
1025 if (value < 0 || value > 100) { |
|
1026 return { result: false, message: "Percentage moet 0-100 zijn" }; |
|
1027 } |
|
1028 return true; |
|
1029 }, |
|
1030 initeditor: function (row, cellvalue, editor) { |
|
1031 editor.jqxNumberInput({ decimalDigits: 1, min: 0, max: 100, spinButtons: false }); |
|
1032 }, |
|
1033 cellvaluechanging: function (row, column, columntype, oldvalue, newvalue) { |
|
1034 oldvalue = Math.round(oldvalue * 10) / 10.0; |
|
1035 var rowscount = $("#fermentableGrid").jqxGrid('getdatainformation').rowscount; |
|
1036 if ((oldvalue != newvalue) && (rowscount > 1)) { |
|
1037 var rowdata = $("#fermentableGrid").jqxGrid('getrowdata', row); |
|
1038 if (rowdata.f_adjust_to_total_100) { |
|
1039 return oldvalue; |
|
1040 } |
|
1041 var diff = newvalue - oldvalue; |
|
1042 var tw = 0; // total weight |
|
1043 for (i = 0; i < rowscount; i++) { |
|
1044 var rowdata = $("#fermentableGrid").jqxGrid('getrowdata', i); |
|
1045 tw += rowdata.f_amount; |
|
1046 } |
|
1047 if (to_100) { |
|
1048 // Adjust this row and the 100% row. |
|
1049 var rowdata = $("#fermentableGrid").jqxGrid('getrowdata', row); |
|
1050 rowdata.f_amount += tw * diff / 100; |
|
1051 for (i = 0; i < rowscount; i++) { |
|
1052 var rowdata = $("#fermentableGrid").jqxGrid('getrowdata', i); |
|
1053 if (rowdata.f_adjust_to_total_100) { |
|
1054 rowdata.f_percentage -= diff; |
|
1055 rowdata.f_amount -= tw * diff / 100; |
|
1056 } |
|
1057 } |
|
1058 } else { |
|
1059 // Adjust all the rows. |
|
1060 var nw = tw * diff / 100; |
|
1061 for (i = 0; i < rowscount; i++) { |
|
1062 var rowdata = $("#fermentableGrid").jqxGrid('getrowdata', i); |
|
1063 if (i == row) { |
|
1064 rowdata.f_amount += nw; |
|
1065 } else { |
|
1066 rowdata.f_amount -= nw / (rowscount - 1); |
|
1067 rowdata.f_percentage = Math.round((rowdata.f_amount / tw) * 1000) / 10.0; |
|
1068 } |
|
1069 } |
|
1070 } |
|
1071 } |
|
1072 } |
|
1073 }, |
|
1074 { text: '100%', align: 'center', datafield: 'f_adjust_to_total_100', columntype: 'checkbox', width: 80, |
|
1075 cellvaluechanging: function (row, column, columntype, oldvalue, newvalue) { |
|
1076 if (to_100) { |
|
1077 var rowscount = $("#fermentableGrid").jqxGrid('getdatainformation').rowscount; |
|
1078 for (i = 0; i < rowscount; i++) { |
|
1079 if (i != row) { |
|
1080 var rowdata = $("#fermentableGrid").jqxGrid('getrowdata', i); |
|
1081 rowdata.f_adjust_to_total_100 = false; |
|
1082 } |
|
1083 } |
|
1084 } |
|
1085 } |
|
1086 } |
|
1087 ] |
|
1088 }); |
|
1089 $("#fermentableGrid").on('cellendedit', function (event) { |
|
1090 var args = event.args; |
|
1091 console.log("Event Type: cellendedit, Column: " + args.datafield + ", Row: " + (args.rowindex) + ", Value: " + args.value); |
|
1092 // Make sure the grid itself is updated. |
|
1093 $("#fermentableGrid").jqxGrid('setcellvalue', args.rowindex, args.datafield, args.value); |
|
1094 if ((args.datafield == 'f_amount') && (! to_100)) { |
|
1095 // If one of the amounts is changed, recalculate the percentages. |
|
1096 console.log("adjust percentages"); |
|
1097 var rowscount = $("#fermentableGrid").jqxGrid('getdatainformation').rowscount; |
|
1098 if (rowscount > 1) { |
|
1099 var tw = 0; |
|
1100 for (i = 0; i < rowscount; i++) { |
|
1101 var rowdata = $("#fermentableGrid").jqxGrid('getrowdata', i); |
|
1102 tw += rowdata.f_amount; |
|
1103 }; |
|
1104 for (i = 0; i < rowscount; i++) { |
|
1105 var rowdata = $("#fermentableGrid").jqxGrid('getrowdata', i); |
|
1106 var percentage = Math.round(rowdata.f_amount / tw * 1000) / 10.0; |
|
1107 $("#fermentableGrid").jqxGrid('setcellvalue', i, "f_percentage", percentage); |
|
1108 }; |
|
1109 } else { |
|
1110 $("#fermentableGrid").jqxGrid('setcellvalue', 0, "f_percentage", 100); |
|
1111 } |
|
1112 }; |
|
1113 $('#fermentableGrid').jqxGrid('sortby', 'f_amount', 'desc'); // TODO: not reliable |
|
1114 calcFermentables(); |
|
1115 calcSVG(); |
|
1116 calcABV(); |
|
1117 calcIBUs(); // Depends on gravity, so recalculate. |
|
1118 }); |
|
1119 }; |
|
1120 |
|
1121 // Inline hops editor |
|
1122 var editHop = function (data) { |
|
1123 var hopSource = { |
|
1124 localdata: data.hops, |
|
1125 datatype: "local", |
|
1126 cache: false, |
|
1127 datafields: [ |
|
1128 { name: 'h_name', type: 'string' }, |
|
1129 { name: 'h_origin', type: 'string' }, |
|
1130 { name: 'h_amount', type: 'float' }, |
|
1131 { name: 'h_cost', type: 'float' }, |
|
1132 { name: 'h_type', type: 'string' }, |
|
1133 { name: 'h_form', type: 'string' }, |
|
1134 { name: 'h_useat', type: 'string' }, |
|
1135 { name: 'h_time', type: 'float' }, |
|
1136 { name: 'h_alpha', type: 'float' }, |
|
1137 { name: 'h_beta', type: 'float' }, |
|
1138 { name: 'h_hsi', type: 'float' }, |
|
1139 { name: 'h_humulene', type: 'float' }, |
|
1140 { name: 'h_carophyllene', type: 'float' }, |
|
1141 { name: 'h_cohumulone', type: 'float' }, |
|
1142 { name: 'h_myrcene', type: 'float' }, |
|
1143 { name: 'h_total_oil', type: 'float' }, |
|
1144 { name: 'h_weight', type: 'float' } |
|
1145 ], |
|
1146 addrow: function (rowid, rowdata, position, commit) { |
|
1147 commit(true); |
|
1148 }, |
|
1149 deleterow: function (rowid, commit) { |
|
1150 commit(true); |
|
1151 } |
|
1152 }; |
|
1153 var hopAdapter = new $.jqx.dataAdapter(hopSource, { |
|
1154 beforeLoadComplete: function (records) { |
|
1155 var data = new Array(); |
|
1156 for (var i = 0; i < records.length; i++) { |
|
1157 var row = records[i]; |
|
1158 row.h_weight = row.h_amount * 1000; |
|
1159 data.push(row); |
|
1160 } |
|
1161 return data; |
|
1162 }, |
|
1163 loadError: function(jqXHR, status, error) { |
|
1164 $('#err').text(status + ' ' + error); |
|
1165 }, |
|
1166 }); |
|
1167 $("#hopGrid").jqxGrid({ |
|
1168 width: 1050, |
|
1169 height: 400, |
|
1170 source: hopAdapter, |
|
1171 theme: theme, |
|
1172 selectionmode: 'singlerow', |
|
1173 editmode: 'selectedcell', |
|
1174 editable: true, |
|
1175 localization: getLocalization(), |
|
1176 showtoolbar: true, |
|
1177 rendertoolbar: function (toolbar) { |
|
1178 var me = this; |
|
1179 var container = $("<div style='overflow: hidden; position: relative; margin: 5px;'></div>"); |
|
1180 toolbar.append(container); |
|
1181 container.append('<div style="float: left; margin-left: 165px;" id="haddrowbutton"></div>'); |
|
1182 container.append('<div style="float: left; margin-left: 10px; margin-top: 5px;">In voorraad:</div>'); |
|
1183 container.append('<div style="float: left; margin-left: 10px;" id="hinstockbutton"></div>'); |
|
1184 container.append('<input style="float: left; margin-left: 280px;" id="hdeleterowbutton" type="button" value="Verwijder hop" />'); |
|
1185 // add hop from dropdownlist. |
|
1186 $("#haddrowbutton").jqxDropDownList({ |
|
1187 placeHolder: "Kies hop:", |
|
1188 theme: theme, |
|
1189 source: hoplist, |
|
1190 displayMember: "name", |
|
1191 width: 150, |
|
1192 height: 27, |
|
1193 dropDownWidth: 500, |
|
1194 dropDownHeight: 500, |
|
1195 renderer: function (index, label, value) { |
|
1196 var datarecord = hoplist.records[index]; |
|
1197 return datarecord.origin+ " / " + datarecord.name + " (" + datarecord.alpha + "% α)"; |
|
1198 } |
|
1199 }); |
|
1200 $("#haddrowbutton").on('select', function (event) { |
|
1201 if (event.args) { |
|
1202 var index = event.args.index; |
|
1203 var datarecord = hoplist.records[index]; |
|
1204 var row = {}; |
|
1205 row["h_name"] = datarecord.name; |
|
1206 row["h_origin"] = datarecord.origin; |
|
1207 row["h_amount"] = 0; |
|
1208 row["h_cost"] = datarecord.cost; |
|
1209 row["h_type"] = datarecord.type; |
|
1210 row["h_form"] = datarecord.form; |
|
1211 row["h_useat"] = datarecord.useat; |
|
1212 row["h_time"] = 0; |
|
1213 row["h_alpha"] = datarecord.alpha; |
|
1214 row["h_beta"] = datarecord.beta; |
|
1215 row["h_hsi"] = datarecord.hsi; |
|
1216 row["h_humulene"] = datarecord.humulene; |
|
1217 row["h_carophyllene"] = datarecord.carophyllene; |
|
1218 row["h_cohumulone"] = datarecord.cohumulone; |
|
1219 row["h_myrcene"] = datarecord.myrcene; |
|
1220 row["h_total_oil"] = datarecord.total_oil; |
|
1221 row["h_weight"] = 0; |
|
1222 var commit = $("#hopGrid").jqxGrid('addrow', null, row); |
|
1223 } |
|
1224 }); |
|
1225 |
|
1226 $("#hinstockbutton").jqxCheckBox({ theme: theme, height: 27 }); |
|
1227 $("#hinstockbutton").on('change', function (event) { |
|
1228 hopinstock = event.args.checked; |
|
1229 hoplist.dataBind(); |
|
1230 }); |
|
1231 |
|
1232 // delete selected hop. |
|
1233 $("#hdeleterowbutton").jqxButton({ theme: theme, height: 27, width: 150 }); |
|
1234 $("#hdeleterowbutton").on('click', function () { |
|
1235 var selectedrowindex = $("#hopGrid").jqxGrid('getselectedrowindex'); |
|
1236 var rowscount = $("#hopGrid").jqxGrid('getdatainformation').rowscount; |
|
1237 if (selectedrowindex >= 0 && selectedrowindex < rowscount) { |
|
1238 var id = $("#hopGrid").jqxGrid('getrowid', selectedrowindex); |
|
1239 var commit = $("#hopGrid").jqxGrid('deleterow', id); |
|
1240 } |
|
1241 }); |
|
1242 }, |
|
1243 ready: function() { |
|
1244 $('#jqxTabs').jqxTabs('next'); |
|
1245 }, |
|
1246 columns: [ |
|
1247 { text: 'Hop', editable: false, datafield: 'h_name', |
|
1248 cellsrenderer: function (row, columnfield, value, defaulthtml, columnproperties) { |
|
1249 var rowData = $("#hopGrid").jqxGrid('getrowdata', row); |
|
1250 return "<span style='margin: 3px; margin-top: 6px; float: "+ |
|
1251 columnproperties.cellsalign+"'>" +rowData.h_origin+" / "+rowData.h_name+"</span>"; |
|
1252 }, |
|
1253 }, |
|
1254 { text: 'Type', editable: false, width: 90, align: 'center', cellsalign: 'center', datafield: 'h_type' }, |
|
1255 { text: 'Vorm', editable: false, width: 90, align: 'center', cellsalign: 'center', datafield: 'h_form' }, |
|
1256 { text: 'Alpha', editable: false, datafield: 'h_alpha', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'p1' }, |
|
1257 { text: 'Amount', hidden: true, datafield: 'h_amount' }, |
|
1258 { text: 'Gewicht gr', datafield: 'h_weight', width: 120, align: 'right', cellsalign: 'right', cellsformat: 'f1', |
|
1259 columntype: 'numberinput', |
|
1260 cellsrenderer: function (index, datafield, value, defaultvalue, column, rowdata) { |
|
1261 return "<div style='margin: 4px;' class='jqx-right-align'>" + dataAdapter.formatNumber(value, "f1") + " gr</div>"; |
|
1262 }, |
|
1263 initeditor: function (row, cellvalue, editor, celltext, pressedChar) { |
|
1264 editor.jqxNumberInput({ |
|
1265 inputMode: 'simple', decimalDigits: 1, min: 0, max: parseFloat(dataRecord.batch_size * 200), |
|
1266 spinButtons: false |
|
1267 }); |
|
1268 }, |
|
1269 validation: function (cell, value) { |
|
1270 var maxhops = parseFloat(dataRecord.batch_size) * 200; |
|
1271 if (value < 0 || value > maxhops ) { |
|
1272 return { result: false, message: "Gewicht moet tussen 0 en "+maxhops+" gram zijn" }; |
|
1273 } |
|
1274 return true; |
|
1275 } |
|
1276 }, |
|
1277 { text: 'Gebruik', width: 110, align: 'center', cellsalign: 'center', datafield: 'h_useat', columntype: 'dropdownlist', |
|
1278 createeditor: function (row, column, editor) { |
|
1279 var srcUse = [ "Boil", "Dry Hop", "Mash", "First Wort", "Aroma" ]; |
|
1280 editor.jqxDropDownList({ autoDropDownHeight: true, source: srcUse }); |
|
1281 }, |
|
1282 cellvaluechanging: function (row, column, columntype, oldvalue, newvalue) { |
|
1283 if ((newvalue == "Mash") || (newvalue == "First Wort")) { |
|
1284 $("#hopGrid").jqxGrid('setcellvalue', row, "h_time", parseFloat(dataRecord.boil_time)); |
|
1285 } else if (newvalue == "Aroma") { |
|
1286 $("#hopGrid").jqxGrid('setcellvalue', row, "h_time", 0); |
|
1287 } |
|
1288 } |
|
1289 }, |
|
1290 { text: 'Tijd', datafield: 'h_time', width: 70, align: 'right', cellsalign: 'right', cellsformat: 'f0', |
|
1291 columntype: 'numberinput', |
|
1292 cellsrenderer: function (index, datafield, value, defaultvalue, column, rowdata) { |
|
1293 if ((rowdata.h_useat == "Boil") || (rowdata.h_useat == "Dry Hop") || (rowdata.h_useat == "Dry hop")) |
|
1294 return "<div style='margin: 4px;' class='jqx-right-align'>"+dataAdapter.formatNumber(value, "f0")+"</div>"; |
|
1295 else |
|
1296 return "<div style='margin: 4px;' class='jqx-right-align'> </div>"; |
|
1297 }, |
|
1298 initeditor: function (row, cellvalue, editor, celltext, pressedChar) { |
|
1299 editor.jqxNumberInput({ decimalDigits: 0, digits: 3, min: 0, max: parseFloat(dataRecord.boil_time) }); |
|
1300 }, |
|
1301 cellvaluechanging: function (row, column, columntype, oldvalue, newvalue) { |
|
1302 var use = $("#hopGrid").jqxGrid('getcellvalue', row, "h_useat"); |
|
1303 if ((use == "Mash") || (use == "First Wort") || (use == "First wort") || (use == "Aroma")) |
|
1304 return oldvalue; |
|
1305 }, |
|
1306 validation: function (cell, value) { |
|
1307 var high = parseFloat(dataRecord.boil_time); |
|
1308 if (value < 0 || value > high ) { |
|
1309 return { result: false, message: "De tijd moet 0-"+high+" zijn" }; |
|
1310 } |
|
1311 return true; |
|
1312 } |
|
1313 }, |
|
1314 { text: 'IBU', editable: false, datafield: 'ibu', width: 80, align: 'right', |
|
1315 cellsrenderer: function (index, datafield, value, defaultvalue, column, rowdata) { |
|
1316 var ibu = toIBU(rowdata.h_useat, |
|
1317 rowdata.h_form, |
|
1318 preboil_sg, |
|
1319 parseFloat($("#batch_size").jqxNumberInput('decimal')), |
|
1320 parseFloat(rowdata.h_amount), |
|
1321 parseFloat(rowdata.h_time), |
|
1322 parseFloat(rowdata.h_alpha), |
|
1323 $("#ibu_method").val() |
|
1324 ); |
|
1325 calcIBUs(); |
|
1326 return "<div style='margin: 4px;' class='jqx-right-align'>" + dataAdapter.formatNumber(ibu, "f1") + "</div>"; |
|
1327 } |
|
1328 } |
|
1329 ] |
|
1330 }); |
|
1331 $("#hopGrid").on('cellendedit', function (event) { |
|
1332 var args = event.args; |
|
1333 console.log("Event Type: cellendedit, Column: " + args.datafield + ", Row: " + (args.rowindex) + ", Value: " + args.value); |
|
1334 $("#hopGrid").jqxGrid('setcellvalue', args.rowindex, args.datafield, args.value); |
|
1335 if (args.datafield == 'h_weight') |
|
1336 $("#hopGrid").jqxGrid('setcellvalue', args.rowindex, 'h_amount', args.value / 1000); |
|
1337 //$('#hopGrid').jqxGrid('sortby', 'f_amount', 'desc'); |
|
1338 }); |
|
1339 }; |
|
1340 |
|
1341 // Inline miscs editor |
|
1342 var editMisc = function (data) { |
|
1343 var miscSource = { |
|
1344 localdata: data.miscs, |
|
1345 datatype: "local", |
|
1346 cache: false, |
|
1347 datafields: [ |
|
1348 { name: 'm_name', type: 'string' }, |
|
1349 { name: 'm_amount', type: 'float' }, |
|
1350 { name: 'm_cost', type: 'float' }, |
|
1351 { name: 'm_type', type: 'string' }, |
|
1352 { name: 'm_use_use', type: 'string' }, |
|
1353 { name: 'm_time', type: 'float' }, |
|
1354 { name: 'm_amount_is_weight', type: 'bool' }, |
|
1355 { name: 'm_weight', type: 'float' } |
|
1356 ], |
|
1357 addrow: function (rowid, rowdata, position, commit) { |
|
1358 commit(true); |
|
1359 }, |
|
1360 deleterow: function (rowid, commit) { |
|
1361 commit(true); |
|
1362 } |
|
1363 }; |
|
1364 var miscAdapter = new $.jqx.dataAdapter(miscSource, { |
|
1365 beforeLoadComplete: function (records) { |
|
1366 var data = new Array(); |
|
1367 for (var i = 0; i < records.length; i++) { |
|
1368 var row = records[i]; |
|
1369 row.m_weight = row.m_amount * 1000; |
|
1370 data.push(row); |
|
1371 // Initial set water agent values. |
|
1372 switch (row.m_name) { |
|
1373 case 'CaCl2': $("#wa_cacl2").val(row.m_weight); |
|
1374 break; |
|
1375 case 'CaSO4': $("#wa_caso4").val(row.m_weight); |
|
1376 break; |
|
1377 case 'MgSO4': $("#wa_mgso4").val(row.m_weight); |
|
1378 break; |
|
1379 case 'NaCl': $("#wa_nacl").val(row.m_weight); |
|
1380 break; |
|
1381 case 'Melkzuur': $("#wa_acid_name").val('Melkzuur'); |
|
1382 $("#wa_acid").val(row.m_weight); |
|
1383 $("#wa_acid_perc").val(80); |
|
1384 last_acid = 'Melkzuur'; |
|
1385 break; |
|
1386 case 'Zoutzuur': $("#wa_acid_name").val('Zoutzuur'); |
|
1387 $("#wa_acid").val(row.m_weight); |
|
1388 $("#wa_acid_perc").val(80); |
|
1389 last_acid = 'Zoutzuur'; |
|
1390 break; |
|
1391 case 'Fosforzuur': $("#wa_acid_name").val('Fosforzuur'); |
|
1392 $("#wa_acid").val(row.m_weight); |
|
1393 $("#wa_acid_perc").val(80); |
|
1394 last_acid = 'Fosforzuur'; |
|
1395 break; |
|
1396 case 'Zwavelzuur': $("#wa_acid_name").val('Zwavelzuur'); |
|
1397 $("#wa_acid").val(row.m_weight); |
|
1398 $("#wa_acid_perc").val(80); |
|
1399 last_acid = 'Zwavelzuur'; |
|
1400 break; |
|
1401 case 'NaHCO3': $("#wa_base_name").val('NaHCO3'); |
|
1402 $("#wa_base").val(row.m_weight); |
|
1403 last_base = 'NaHCO3'; |
|
1404 break; |
|
1405 case 'Na2CO3': $("#wa_base_name").val('Na2CO3'); |
|
1406 $("#wa_base").val(row.m_weight); |
|
1407 last_base = 'Na2CO3'; |
|
1408 break; |
|
1409 case 'CaCO3': $("#wa_base_name").val('CaCO3'); |
|
1410 $("#wa_base").val(row.m_weight); |
|
1411 last_base = 'CaCO3'; |
|
1412 break; |
|
1413 case 'Ca(OH)2': $("#wa_base_name").val('Ca(OH)2'); |
|
1414 $("#wa_base").val(row.m_weight); |
|
1415 last_base = 'Ca(OH)2'; |
|
1416 break; |
|
1417 } |
|
1418 } |
|
1419 return data; |
|
1420 }, |
|
1421 loadError: function(jqXHR, status, error) { |
|
1422 $('#err').text(status + ' ' + error); |
|
1423 }, |
|
1424 }); |
|
1425 $("#miscGrid").jqxGrid({ |
|
1426 width: 960, |
|
1427 height: 400, |
|
1428 source: miscAdapter, |
|
1429 theme: theme, |
|
1430 selectionmode: 'singlerow', |
|
1431 editmode: 'selectedcell', |
|
1432 editable: true, |
|
1433 localization: getLocalization(), |
|
1434 showtoolbar: true, |
|
1435 rendertoolbar: function (toolbar) { |
|
1436 var me = this; |
|
1437 var container = $("<div style='overflow: hidden; position: relative; margin: 5px;'></div>"); |
|
1438 toolbar.append(container); |
|
1439 container.append('<div style="float: left; margin-left: 165px;" id="maddrowbutton"></div>'); |
|
1440 container.append('<div style="float: left; margin-left: 10px; margin-top: 5px;">In voorraad:</div>'); |
|
1441 container.append('<div style="float: left; margin-left: 10px;" id="minstockbutton"></div>'); |
|
1442 container.append('<input style="float: left; margin-left: 200px;" id="mdeleterowbutton" type="button" value="Verwijder ingredient" />'); |
|
1443 // add misc from dropdownlist. |
|
1444 $("#maddrowbutton").jqxDropDownList({ |
|
1445 placeHolder: "Kies ingredient:", |
|
1446 theme: theme, |
|
1447 source: misclist, |
|
1448 displayMember: "name", |
|
1449 width: 150, |
|
1450 height: 27, |
|
1451 dropDownWidth: 500, |
|
1452 dropDownHeight: 500 |
|
1453 }); |
|
1454 $("#maddrowbutton").on('select', function (event) { |
|
1455 if (event.args) { |
|
1456 var index = event.args.index; |
|
1457 var datarecord = misclist.records[index]; |
|
1458 var row = {}; |
|
1459 row["m_name"] = datarecord.name; |
|
1460 row["m_amount"] = 0; |
|
1461 row["m_cost"] = datarecord.cost; |
|
1462 row["m_type"] = datarecord.type; |
|
1463 row["m_use_use"] = datarecord.use_use; |
|
1464 row["m_time"] = 0; |
|
1465 row["m_weight"] = 0; |
|
1466 row["m_amount_is_weight"] = datarecord.amount_is_weight; |
|
1467 var commit = $("#miscGrid").jqxGrid('addrow', null, row); |
|
1468 } |
|
1469 }); |
|
1470 $("#minstockbutton").jqxCheckBox({ theme: theme, height: 27 }); |
|
1471 $("#minstockbutton").on('change', function (event) { |
|
1472 miscinstock = event.args.checked; |
|
1473 misclist.dataBind(); |
|
1474 }); |
|
1475 // delete selected misc. |
|
1476 $("#mdeleterowbutton").jqxButton({ theme: theme, height: 27, width: 150 }); |
|
1477 $("#mdeleterowbutton").on('click', function () { |
|
1478 var selectedrowindex = $("#miscGrid").jqxGrid('getselectedrowindex'); |
|
1479 var rowscount = $("#miscGrid").jqxGrid('getdatainformation').rowscount; |
|
1480 var type = $("#miscGrid").jqxGrid('getcellvalue', selectedrowindex, "m_type"); |
|
1481 if (selectedrowindex >= 0 && selectedrowindex < rowscount && type != "Water agent") { |
|
1482 var id = $("#miscGrid").jqxGrid('getrowid', selectedrowindex); |
|
1483 var commit = $("#miscGrid").jqxGrid('deleterow', id); |
|
1484 } |
|
1485 }); |
|
1486 }, |
|
1487 ready: function() { |
|
1488 $('#jqxTabs').jqxTabs('next'); |
|
1489 }, |
|
1490 columns: [ |
|
1491 { text: 'Ingredient', editable: false, datafield: 'm_name' }, |
|
1492 { text: 'Type', editable: false, width: 120, align: 'center', cellsalign: 'center', datafield: 'm_type' }, |
|
1493 { text: 'Gebruik', width: 110, align: 'center', cellsalign: 'center', datafield: 'm_use_use', columntype: 'dropdownlist', |
|
1494 createeditor: function (row, column, editor) { |
|
1495 var srcUseUse = [ "Mash", "Boil", "Primary", "Secondary", "Bottling" ]; |
|
1496 editor.jqxDropDownList({ autoDropDownHeight: true, source: srcUseUse }); |
|
1497 }, |
|
1498 cellvaluechanging: function (row, column, columntype, oldvalue, newvalue) { |
|
1499 var type = $("#miscGrid").jqxGrid('getcellvalue', row, "m_type"); |
|
1500 if (type == "Water agent") |
|
1501 return oldvalue; |
|
1502 } |
|
1503 }, |
|
1504 { datafield: 'm_amount_is_weight', hidden: true }, // We need to declare this column |
|
1505 { datafield: 'm_amount', hidden: true }, // We need to declare this column |
|
1506 { text: 'Hoeveelheid', datafield: 'm_weight', width: 120, align: 'right', cellsalign: 'right', cellsformat: 'f2', |
|
1507 columntype: 'numberinput', |
|
1508 cellsrenderer: function (index, datafield, value, defaultvalue, column, rowdata) { |
|
1509 var vstr = rowdata.m_amount_is_weight ? "gr":"ml"; |
|
1510 return "<div style='margin: 4px;' class='jqx-right-align'>"+dataAdapter.formatNumber(value,"f2")+" "+vstr+"</div>"; |
|
1511 }, |
|
1512 validation: function (cell, value) { |
|
1513 var high = parseFloat(dataRecord.boil_size) * 1000; |
|
1514 if (value < 0 || value > high) { |
|
1515 return { result: false, message: "Hoeveelheid moet tussen 0 en "+high+" zijn" }; |
|
1516 } |
|
1517 return true; |
|
1518 }, |
|
1519 initeditor: function (row, cellvalue, editor) { |
|
1520 editor.jqxNumberInput({ |
|
1521 inputMode: 'simple', min: 0, max: parseFloat(dataRecord.boil_size) * 1000, |
|
1522 decimalDigits: 2, spinButtons: false |
|
1523 }); |
|
1524 }, |
|
1525 cellvaluechanging: function (row, column, columntype, oldvalue, newvalue) { |
|
1526 var type = $("#miscGrid").jqxGrid('getcellvalue', row, "m_type"); |
|
1527 if (type == "Water agent") |
|
1528 return oldvalue; |
|
1529 } |
|
1530 }, |
|
1531 { text: 'Tijd', datafield: 'm_time', width: 70, align: 'right', cellsalign: 'right', cellsformat: 'f0', |
|
1532 columntype: 'numberinput', |
|
1533 cellsrenderer: function (index, datafield, value, defaultvalue, column, rowdata) { |
|
1534 if (rowdata.m_use_use == 'Boil') { |
|
1535 return "<div style='margin: 4px;' class='jqx-right-align'>"+dataAdapter.formatNumber(value, "f0")+" m</div>"; |
|
1536 } else if (rowdata.m_use_use == 'Secondary') { |
|
1537 return "<div style='margin: 4px;' class='jqx-right-align'>"+dataAdapter.formatNumber(value, "f0")+" d</div>"; |
|
1538 } else { |
|
1539 var tijd = 0; |
|
1540 return "<div style='margin: 4px;' class='jqx-right-align'> </div>"; |
|
1541 } |
|
1542 }, |
|
1543 initeditor: function (row, cellvalue, editor, celltext, pressedChar) { |
|
1544 editor.jqxNumberInput({ decimalDigits: 0, digits: 3, min: 0, max: parseFloat(dataRecord.boil_time) }); |
|
1545 }, |
|
1546 cellvaluechanging: function (row, column, columntype, oldvalue, newvalue) { |
|
1547 var use = $("#miscGrid").jqxGrid('getcellvalue', row, "m_use_use"); |
|
1548 if ((use != "Boil") && (use != "Secondary")) |
|
1549 return oldvalue; |
|
1550 }, |
|
1551 validation: function (cell, value) { |
|
1552 var high = parseFloat(dataRecord.boil_time); |
|
1553 if (value < 0 || value > high ) { |
|
1554 return { result: false, message: "De tijd moet 0-"+high+" zijn" }; |
|
1555 } |
|
1556 return true; |
|
1557 } |
|
1558 } |
|
1559 ] |
|
1560 }); |
|
1561 $("#miscGrid").on('cellendedit', function (event) { |
|
1562 var args = event.args; |
|
1563 console.log("Event Type: cellendedit, Column: " + args.datafield + ", Row: " + (args.rowindex) + ", Value: " + args.value); |
|
1564 $("#miscGrid").jqxGrid('setcellvalue', args.rowindex, args.datafield, args.value); |
|
1565 if (args.datafield == 'm_weight') { |
|
1566 $("#miscGrid").jqxGrid('setcellvalue', args.rowindex, 'm_amount', parseFloat(args.value) / 1000); |
|
1567 } |
|
1568 }); |
|
1569 }; |
|
1570 |
|
1571 // Inline yeasts editor |
|
1572 var editYeast = function (data) { |
|
1573 var yeastSource = { |
|
1574 localdata: data.yeasts, |
|
1575 datatype: "local", |
|
1576 cache: false, |
|
1577 datafields: [ |
|
1578 { name: 'y_name', type: 'string' }, |
|
1579 { name: 'y_laboratory', type: 'string' }, |
|
1580 { name: 'y_product_id', type: 'string' }, |
|
1581 { name: 'y_amount', type: 'float' }, |
|
1582 { name: 'y_cost', type: 'float' }, |
|
1583 { name: 'y_type', type: 'string' }, |
|
1584 { name: 'y_form', type: 'string' }, |
|
1585 { name: 'y_time', type: 'float' }, |
|
1586 { name: 'y_min_temperature', type: 'float' }, |
|
1587 { name: 'y_max_temperature', type: 'float' }, |
|
1588 { name: 'y_attenuation', type: 'float' }, |
|
1589 { name: 'y_amount_is_weight', type: 'bool' }, |
|
1590 { name: 'y_use', type: 'string' }, |
|
1591 { name: 'y_weight', type: 'float' } |
|
1592 ], |
|
1593 addrow: function (rowid, rowdata, position, commit) { |
|
1594 commit(true); |
|
1595 }, |
|
1596 deleterow: function (rowid, commit) { |
|
1597 commit(true); |
|
1598 } |
|
1599 }; |
|
1600 var yeastAdapter = new $.jqx.dataAdapter(yeastSource, { |
|
1601 beforeLoadComplete: function (records) { |
|
1602 var data = new Array(); |
|
1603 for (var i = 0; i < records.length; i++) { |
|
1604 var row = records[i]; |
|
1605 if (row.y_form == 'Liquid') |
|
1606 row.y_weight = Math.round(row.y_amount * 17); |
|
1607 else |
|
1608 row.y_weight = row.y_amount * 1000; |
|
1609 data.push(row); |
|
1610 } |
|
1611 return data; |
|
1612 }, |
|
1613 loadError: function(jqXHR, status, error) { |
|
1614 $('#err').text(status + ' ' + error); |
|
1615 }, |
|
1616 }); |
|
1617 $("#yeastGrid").jqxGrid({ |
|
1618 width: 1050, |
|
1619 height: 300, |
|
1620 source: yeastAdapter, |
|
1621 theme: theme, |
|
1622 selectionmode: 'singlerow', |
|
1623 editmode: 'selectedcell', |
|
1624 editable: true, |
|
1625 localization: getLocalization(), |
|
1626 showtoolbar: true, |
|
1627 rendertoolbar: function (toolbar) { |
|
1628 var me = this; |
|
1629 var container = $("<div style='overflow: hidden; position: relative; margin: 5px;'></div>"); |
|
1630 toolbar.append(container); |
|
1631 container.append('<div style="float: left; margin-left: 165px;" id="yaddrowbutton"></div>'); |
|
1632 container.append('<div style="float: left; margin-left: 10px; margin-top: 5px;">In voorraad:</div>'); |
|
1633 container.append('<div style="float: left; margin-left: 10px;" id="yinstockbutton"></div>'); |
|
1634 container.append('<input style="float: left; margin-left: 230px;" id="ydeleterowbutton" type="button" value="Verwijder gist" />'); |
|
1635 // add yeast from dropdownlist. |
|
1636 $("#yaddrowbutton").jqxDropDownList({ |
|
1637 placeHolder: "Kies gist:", |
|
1638 theme: theme, |
|
1639 source: yeastlist, |
|
1640 displayMember: "name", |
|
1641 width: 150, |
|
1642 height: 27, |
|
1643 dropDownWidth: 500, |
|
1644 dropDownHeight: 500, |
|
1645 renderer: function (index, label, value) { |
|
1646 var datarecord = yeastlist.records[index]; |
|
1647 return datarecord.laboratory+" "+datarecord.product_id+" "+datarecord.name; |
|
1648 } |
|
1649 }); |
|
1650 $("#yaddrowbutton").on('select', function (event) { |
|
1651 if (event.args) { |
|
1652 var index = event.args.index; |
|
1653 var datarecord = yeastlist.records[index]; |
|
1654 var row = {}; |
|
1655 row["y_name"] = datarecord.name; |
|
1656 row["y_laboratory"] = datarecord.laboratory; |
|
1657 row["y_product_id"] = datarecord.product_id; |
|
1658 row["y_type"] = datarecord.type; |
|
1659 row["y_form"] = datarecord.form; |
|
1660 row["y_amount"] = 0; |
|
1661 row["y_cost"] = datarecord.cost; |
|
1662 row["y_use"] = "Primary"; |
|
1663 row["y_time"] = 0; |
|
1664 if (datarecord.form == "Dry") { |
|
1665 row["y_amount_is_weight"] = 1; |
|
1666 } else { |
|
1667 row["y_amount_is_weight"] = 0; |
|
1668 } |
|
1669 row["y_min_temperature"] = datarecord.min_temperature; |
|
1670 row["y_max_temperature"] = datarecord.max_temperature; |
|
1671 row["y_attenuation"] = datarecord.attenuation; |
|
1672 row["y_weight"] = 0; |
|
1673 var commit = $("#yeastGrid").jqxGrid('addrow', null, row); |
|
1674 } |
|
1675 }); |
|
1676 $("#yinstockbutton").jqxCheckBox({ theme: theme, height: 27 }); |
|
1677 $("#yinstockbutton").on('change', function (event) { |
|
1678 yeastinstock = event.args.checked; |
|
1679 yeastlist.dataBind(); |
|
1680 }); |
|
1681 // delete selected yeast. |
|
1682 $("#ydeleterowbutton").jqxButton({ theme: theme, height: 27, width: 150 }); |
|
1683 $("#ydeleterowbutton").on('click', function () { |
|
1684 var selectedrowindex = $("#yeastGrid").jqxGrid('getselectedrowindex'); |
|
1685 var rowscount = $("#yeastGrid").jqxGrid('getdatainformation').rowscount; |
|
1686 if (selectedrowindex >= 0 && selectedrowindex < rowscount) { |
|
1687 var id = $("#yeastGrid").jqxGrid('getrowid', selectedrowindex); |
|
1688 var commit = $("#yeastGrid").jqxGrid('deleterow', id); |
|
1689 } |
|
1690 }); |
|
1691 }, |
|
1692 ready: function() { |
|
1693 // calcSVG(); |
|
1694 $('#jqxTabs').jqxTabs('next'); |
|
1695 }, |
|
1696 columns: [ |
|
1697 { text: 'Gist', editable: false, datafield: 'y_name' }, |
|
1698 { text: 'Laboratorium', editable: false, width: 150, datafield: 'y_laboratory' }, |
|
1699 { text: 'Code', editable: false, width: 90, datafield: 'y_product_id' }, |
|
1700 { text: 'Soort', editable: false, width: 80, align: 'center', cellsalign: 'center', datafield: 'y_form' }, |
|
1701 { text: 'Min.', editable: false, width: 70, align: 'right', cellsalign: 'right', datafield: 'y_min_temperature' }, |
|
1702 { text: 'Max.', editable: false, width: 70, align: 'right', cellsalign: 'right', datafield: 'y_max_temperature' }, |
|
1703 { text: 'Attn.', editable: false, width: 70, align: 'right', cellsalign: 'right', datafield: 'y_attenuation', cellsformat: 'f1' }, |
|
1704 { text: 'Voor', width: 100, align: 'center', cellsalign: 'center', datafield: 'y_use', columntype: 'dropdownlist', |
|
1705 createeditor: function (row, column, editor) { |
|
1706 var srcYUse = [ "Primary", "Secondary", "Bottle" ]; |
|
1707 editor.jqxDropDownList({ autoDropDownHeight: true, source: srcYUse }); |
|
1708 } |
|
1709 }, |
|
1710 { datafield: 'y_amount', width: 90 }, |
|
1711 { text: 'Hoeveel', datafield: 'y_weight', width: 110, align: 'right', cellsalign: 'right', |
|
1712 cellsformat: 'f1', columntype: 'numberinput', |
|
1713 cellsrenderer: function (index, datafield, value, defaultvalue, column, rowdata) { |
|
1714 if (rowdata.y_form == 'Liquid') { |
|
1715 return "<div style='margin: 4px;' class='jqx-right-align'>"+dataAdapter.formatNumber(value, "f0")+" pk</div>"; |
|
1716 } else if (rowdata.y_form == 'Dry') { |
|
1717 return "<div style='margin: 4px;' class='jqx-right-align'>"+dataAdapter.formatNumber(value, "f1")+" gr</div>"; |
|
1718 } else { |
|
1719 return "<div style='margin: 4px;' class='jqx-right-align'>"+dataAdapter.formatNumber(value, "f0")+" ml</div>"; |
|
1720 } |
|
1721 }, |
|
1722 initeditor: function (row, cellvalue, editor, celltext, pressedChar) { |
|
1723 var form = $("#yeastGrid").jqxGrid('getcellvalue', args.rowindex, 'y_form'); |
|
1724 if (form == 'Dry') { |
|
1725 editor.jqxNumberInput({ decimalDigits: 1, min: 0, spinButtons: false }); |
|
1726 } else { |
|
1727 editor.jqxNumberInput({ decimalDigits: 0, min: 0, spinButtons: false }); |
|
1728 } |
|
1729 }, |
|
1730 validation: function (cell, value) { |
|
1731 if (value < 0 || value > 100000000000 ) { |
|
1732 return { result: false, message: "Hoeveelheid moet 0-~ zijn" }; |
|
1733 } |
|
1734 return true; |
|
1735 } |
|
1736 } |
|
1737 ] |
|
1738 }); |
|
1739 $("#yeastGrid").on('cellendedit', function (event) { |
|
1740 var args = event.args; |
|
1741 console.log("Event Type: cellendedit, Column: " + args.datafield + ", Row: " + (args.rowindex) + ", Value: " + args.value); |
|
1742 $("#yeastGrid").jqxGrid('setcellvalue', args.rowindex, args.datafield, args.value); |
|
1743 if (args.datafield == 'y_weight') { |
|
1744 var form = $("#yeastGrid").jqxGrid('getcellvalue', args.rowindex, 'y_form'); |
|
1745 if (form == 'Liquid') |
|
1746 $("#yeastGrid").jqxGrid('setcellvalue', args.rowindex, 'y_amount', parseFloat(args.value * 0.0588)); |
|
1747 else |
|
1748 $("#yeastGrid").jqxGrid('setcellvalue', args.rowindex, 'y_amount', parseFloat(args.value / 1000)); |
|
1749 } |
|
1750 }); |
|
1751 }; |
|
1752 |
|
1753 // inline mash editor |
|
1754 var editMash = function (data) { |
|
1755 var generaterow = function () { |
|
1756 var row = {}; |
|
1757 row["step_name"] = "Stap 1"; |
|
1758 row["step_type"] = "Infusion"; |
|
1759 row["step_infuse_amount"] = 15; |
|
1760 row["step_temp"] = 62.0; |
|
1761 row['step_time'] = 20.0; |
|
1762 row['ramp_time'] = 1.0; |
|
1763 row['end_temp'] = 62.0; |
|
1764 return row; |
|
1765 } |
|
1766 var mashSource = { |
|
1767 localdata: data.mashs, |
|
1768 datatype: "local", |
|
1769 cache: false, |
|
1770 datafields: [ |
|
1771 { name: 'step_name', type: 'string' }, |
|
1772 { name: 'step_type', type: 'string' }, |
|
1773 { name: 'step_infuse_amount', type: 'float' }, |
|
1774 { name: 'step_temp', type: 'float' }, |
|
1775 { name: 'step_time', type: 'float' }, |
|
1776 { name: 'ramp_time', type: 'float' }, |
|
1777 { name: 'end_temp', type: 'float' } |
|
1778 ], |
|
1779 addrow: function (rowid, rowdata, position, commit) { |
|
1780 commit(true); |
|
1781 }, |
|
1782 deleterow: function (rowid, commit) { |
|
1783 commit(true); |
|
1784 } |
|
1785 }; |
|
1786 var mashAdapter = new $.jqx.dataAdapter(mashSource, { |
|
1787 beforeLoadComplete: function (records) { |
|
1788 mash_infuse = 0; |
|
1789 var data = new Array(); |
|
1790 for (var i = 0; i < records.length; i++) { |
|
1791 var row = records[i]; |
|
1792 if (row.step_type == 'Infusion') |
|
1793 mash_infuse += parseFloat(row.step_infuse_amount); |
|
1794 } |
|
1795 }, |
|
1796 }); |
|
1797 $("#mashGrid").jqxGrid({ |
|
1798 width: 960, |
|
1799 height: 400, |
|
1800 source: mashAdapter, |
|
1801 theme: theme, |
|
1802 selectionmode: 'singlerow', |
|
1803 editmode: 'selectedcell', |
|
1804 editable: true, |
|
1805 localization: getLocalization(), |
|
1806 showtoolbar: true, |
|
1807 rendertoolbar: function (toolbar) { |
|
1808 var me = this; |
|
1809 var container = $("<div style='overflow: hidden; position: relative; margin: 5px;'></div>"); |
|
1810 toolbar.append(container); |
|
1811 container.append('<input style="float: left; margin-left: 165px;" id="saddrowbutton" type="button" value="Nieuwe stap" />'); |
|
1812 container.append('<input style="float: left; margin-left: 230px;" id="sdeleterowbutton" type="button" value="Verwijder stap" />'); |
|
1813 $("#saddrowbutton").jqxButton({ theme: theme, height: 27, width: 150 }); |
|
1814 $("#saddrowbutton").on('click', function () { |
|
1815 var datarow = generaterow(); |
|
1816 var commit = $("#mashGrid").jqxGrid('addrow', null, datarow); |
|
1817 }); |
|
1818 // delete selected yeast. |
|
1819 $("#sdeleterowbutton").jqxButton({ theme: theme, height: 27, width: 150 }); |
|
1820 $("#sdeleterowbutton").on('click', function () { |
|
1821 var selectedrowindex = $("#mashGrid").jqxGrid('getselectedrowindex'); |
|
1822 var rowscount = $("#mashGrid").jqxGrid('getdatainformation').rowscount; |
|
1823 if (selectedrowindex >= 0 && selectedrowindex < rowscount) { |
|
1824 var id = $("#mashGrid").jqxGrid('getrowid', selectedrowindex); |
|
1825 var commit = $("#mashGrid").jqxGrid('deleterow', id); |
|
1826 } |
|
1827 }); |
|
1828 }, |
|
1829 ready: function() { |
|
1830 var fg = estimate_fg(psugar, pcara, 0, 0, 0, svg, parseFloat(parseFloat($("#est_og").jqxNumberInput('decimal')))); |
|
1831 dataRecord.est_fg = fg; |
|
1832 $('#est_fg').val(fg); |
|
1833 calcInit(); |
|
1834 $('#jqxLoader').jqxLoader('close'); |
|
1835 $('#jqxTabs').jqxTabs('first'); |
|
1836 }, |
|
1837 columns: [ |
|
1838 { text: 'Stap naam', datafield: 'step_name' }, |
|
1839 { text: 'Stap type', datafield: 'step_type', width: 110, columntype: 'dropdownlist', |
|
1840 createeditor: function (row, cellvalue, editor, celltext, cellwidth, cellheight) { |
|
1841 var dataSource = [ "Infusion", "Temperature", "Decoction" ]; |
|
1842 editor.jqxDropDownList({ source: dataSource, dropDownHeight: 105 }); |
|
1843 } |
|
1844 }, |
|
1845 { text: 'Temperatuur', datafield: 'step_temp', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'f1', |
|
1846 validation: function (cell, value) { |
|
1847 if (value < 35 || value > 80) { |
|
1848 return { result: false, message: "De temperatuur moet tussen 35 en 80 zijn." }; |
|
1849 } |
|
1850 return true; |
|
1851 } |
|
1852 }, |
|
1853 { text: 'Eind', datafield: 'end_temp', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'f1', |
|
1854 validation: function (cell, value) { |
|
1855 if (value < 35 || value > 80) { |
|
1856 return { result: false, message: "De temperatuur moet tussen 35 en 80 zijn." }; |
|
1857 } |
|
1858 return true; |
|
1859 } |
|
1860 }, |
|
1861 { text: 'Tijd', datafield: 'step_time', width: 70, align: 'right', cellsalign: 'right', |
|
1862 validation: function (cell, value) { |
|
1863 if (value < 1 || value > 360) { |
|
1864 return { result: false, message: "De tijd moet tussen 1 en 360 zijn." }; |
|
1865 } |
|
1866 return true; |
|
1867 } |
|
1868 }, |
|
1869 { text: 'Stap', datafield: 'ramp_time', width: 70, align: 'right', cellsalign: 'right', |
|
1870 validation: function (cell, value) { |
|
1871 if (value < 1 || value > 60) { |
|
1872 return { result: false, message: "De tijd moet tussen 1 en 60 zijn." }; |
|
1873 } |
|
1874 return true; |
|
1875 } |
|
1876 }, |
|
1877 { text: 'Infuse', datafield: 'step_infuse_amount', width: 70, align: 'right', cellsalign: 'right', |
|
1878 validation: function (cell, value) { |
|
1879 if (value < 0 || value > 60) { |
|
1880 return { result: false, message: "De waarde moet tussen 0 en 60 zijn." }; |
|
1881 } |
|
1882 return true; |
|
1883 } |
|
1884 } |
|
1885 ] |
|
1886 }); |
|
1887 $("#mashGrid").on('cellendedit', function (event) { |
|
1888 $('#mashGrid').jqxGrid('sortby', 'step_temp', 'asc'); |
|
1889 }); |
|
1890 }; |
|
1891 |
611 // initialize the input fields. |
1892 // initialize the input fields. |
|
1893 var srcType = [ "All Grain", "Partial Mash", "Extract" ]; |
|
1894 var srcColor = [ "Morey", "Mosher", "Daniels" ]; |
|
1895 var srcIBU = [ "Tinseth", "Rager", "Daniels" ]; // Only these are supported at this time. |
|
1896 var srcBase = [ "NaHCO3", "Na2CO3", "CaCO3", "Ca(OH)2" ]; |
|
1897 var srcAcid = [ "Melkzuur", "Zoutzuur", "Fosforzuur", "Zwavelzuur" ]; |
612 var srcMaterial= [ "RVS", "Aluminium", "Kunststof", "Koper" ]; |
1898 var srcMaterial= [ "RVS", "Aluminium", "Kunststof", "Koper" ]; |
613 var srcAeration= [ 'None', 'Air', 'Oxygen' ]; |
1899 var srcAeration= [ 'None', 'Air', 'Oxygen' ]; |
614 var srcCooling= [ '-', 'Emersion chiller', 'Counterflow chiller', 'Au bain marie', 'Natural' ]; |
1900 var srcCooling= [ '-', 'Emersion chiller', 'Counterflow chiller', 'Au bain marie', 'Natural' ]; |
615 // '-', 'Dompelkoeler', 'Tegenstroomkoeler', 'Au bain marie', 'Laten afkoelen' |
1901 // '-', 'Dompelkoeler', 'Tegenstroomkoeler', 'Au bain marie', 'Laten afkoelen' |
616 $("#pname").jqxInput({ theme: theme, width: 640, height: 23 }); |
1902 $("#name").jqxInput({ theme: theme, width: 640, height: 23 }); |
617 $("#code").jqxInput({ theme: theme, width: 100, height: 23 }); |
1903 $("#code").jqxInput({ theme: theme, width: 100, height: 23 }); |
618 $("#birth").jqxDateTimeInput({ theme: theme, width: 150, height: 23, formatString: 'yyyy-MM-dd' }); |
1904 $("#birth").jqxDateTimeInput({ theme: theme, width: 150, height: 23, formatString: 'yyyy-MM-dd' }); |
619 $("#stage").jqxInput({ theme: theme, width: 100, height: 23 }); |
1905 $("#stage").jqxInput({ theme: theme, width: 100, height: 23 }); |
620 $("#pnotes").jqxInput({ theme: theme, width: 960, height: 200 }); |
1906 $("#notes").jqxInput({ theme: theme, width: 960, height: 200 }); |
621 $("#log_brew").jqxCheckBox({ theme: theme, width: 120, height: 23, disabled : true }); |
1907 $("#log_brew").jqxCheckBox({ theme: theme, width: 120, height: 23, disabled : true }); |
622 $("#log_fermentation").jqxCheckBox({ theme: theme, width: 120, height: 23, disabled : true }); |
1908 $("#log_fermentation").jqxCheckBox({ theme: theme, width: 120, height: 23, disabled : true }); |
623 $("#inventory_reduced").jqxCheckBox({ theme: theme, width: 120, height: 23 }); |
1909 $("#inventory_reduced").jqxCheckBox({ theme: theme, width: 120, height: 23 }); |
624 $('#inventory_reduced').on('checked', function (event) { |
1910 $('#inventory_reduced').on('checked', function (event) { |
625 // Call a script to do the work and block this. |
1911 // Call a script to do the work and block this. |
626 // Note that this script must set this flag too, so if the user doesn't Save it is still set. |
1912 // Note that this script must set this flag too, so if the user doesn't Save it is still set. |
627 // Call the script with the uuid. |
1913 // Call the script with the uuid. |
628 $("#inventory_reduced").jqxCheckBox({ disabled : true }); |
1914 $("#inventory_reduced").jqxCheckBox({ disabled : true }); |
629 }); |
1915 }); |
630 $("#plocked").jqxCheckBox({ theme: theme, width: 120, height: 23, disabled : true }); |
1916 $("#locked").jqxCheckBox({ theme: theme, width: 120, height: 23, disabled : true }); |
631 $('#plocked').on('checked', function (event) { |
1917 $('#locked').on('checked', function (event) { |
632 if (brewstage >= 10) { |
1918 if (brewstage >= 10) { |
633 $("#stage").val('Closed'); |
1919 $("#stage").val('Closed'); |
634 brewstage = 11; |
1920 brewstage = 11; |
635 } |
1921 } |
636 }); |
1922 }); |
637 $('#plocked').on('unchecked', function (event) { |
1923 $('#locked').on('unchecked', function (event) { |
638 if (brewstage >= 10) { |
1924 if (brewstage >= 10) { |
639 $("#stage").val('Ready'); |
1925 $("#stage").val('Ready'); |
640 brewstage = 10; |
1926 brewstage = 10; |
641 } |
1927 } |
642 }); |
1928 }); |
693 $("#brew_date_end").jqxDateTimeInput({ theme: theme, width: 230, height: 23, formatString: 'yyyy-MM-dd HH:mm:ss', showTimeButton: true }); |
1979 $("#brew_date_end").jqxDateTimeInput({ theme: theme, width: 230, height: 23, formatString: 'yyyy-MM-dd HH:mm:ss', showTimeButton: true }); |
694 // Vergisting |
1980 // Vergisting |
695 // Packaging |
1981 // Packaging |
696 // Tasting |
1982 // Tasting |
697 |
1983 |
698 // Recipe |
1984 $("#batch_size").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: 4, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.1, symbol: 'L', symbolPosition: 'right' }); |
|
1985 $("#boil_size").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 100, height: 23, decimalDigits: 2, readOnly: true, symbol: 'L', symbolPosition: 'right' }); |
|
1986 $("#boil_time").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: 4, max: 360, decimalDigits: 0, spinButtons: true }); |
|
1987 $("#efficiency").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: 40, max: 100, decimalDigits: 0, spinButtons: true, symbol: '%', symbolPosition: 'right' }); |
699 $("#est_og").jqxNumberInput({ inputMode: 'simple', readOnly: true, theme: theme, width: 70, height: 23, decimalDigits: 3 }); |
1988 $("#est_og").jqxNumberInput({ inputMode: 'simple', readOnly: true, theme: theme, width: 70, height: 23, decimalDigits: 3 }); |
700 $("#est_ibu").jqxNumberInput({ inputMode: 'simple', readOnly: true, theme: theme, width: 70, height: 23, decimalDigits: 0 }); |
1989 $("#est_og2").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 100, height: 23, decimalDigits: 3, readOnly: true }); |
701 $("#est_color").jqxNumberInput({ inputMode: 'simple', readOnly: true, theme: theme, width: 70, height: 23, decimalDigits: 0 }); |
1990 $("#st_og_min").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 3, readOnly: true }); |
|
1991 $("#st_og_max").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 3, readOnly: true }); |
|
1992 |
|
1993 $("#est_fg").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 100, height: 23, decimalDigits: 3, readOnly: true }); |
|
1994 $("#st_fg_min").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 3, readOnly: true }); |
|
1995 $("#st_fg_max").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 3, readOnly: true }); |
|
1996 |
|
1997 $("#est_abv").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 1, readOnly: true }); |
|
1998 $("#st_abv_min").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 1, readOnly: true }); |
|
1999 $("#st_abv_max").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 1, readOnly: true }); |
|
2000 |
|
2001 $("#est_color").jqxNumberInput({ inputMode: 'simple', theme: theme, symbol: ' EBC', symbolPosition: 'right', width: 100, height: 23, decimalDigits: 0, readOnly: true }); |
|
2002 $("#est_color2").jqxNumberInput({ inputMode: 'simple', theme: theme, symbol: ' EBC', symbolPosition: 'right', width: 100, height: 23, decimalDigits: 0, readOnly: true }); |
|
2003 $("#st_color_min").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 0, readOnly: true }); |
|
2004 $("#st_color_max").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 0, readOnly: true }); |
|
2005 $("#color_method").jqxDropDownList({ theme: theme, source: srcColor, width: 125, height: 23, dropDownHeight: 95 }); |
|
2006 |
|
2007 $("#est_ibu").jqxNumberInput({ inputMode: 'simple', theme: theme, symbol: ' IBU', symbolPosition: 'right', width: 100, height: 23, decimalDigits: 0, readOnly: true }); |
|
2008 $("#est_ibu2").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 0, readOnly: true }); |
|
2009 $("#st_ibu_min").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 0, readOnly: true }); |
|
2010 $("#st_ibu_max").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 0, readOnly: true }); |
|
2011 $("#ibu_method").jqxDropDownList({ theme: theme, source: srcIBU, width: 125, height: 23, dropDownHeight: 95, dropDownVerticalAlignment: 'top' }); |
|
2012 |
|
2013 $("#est_carb").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 1, readOnly: true }); |
|
2014 $("#st_carb_min").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 1, readOnly: true }); |
|
2015 $("#st_carb_max").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 1, readOnly: true }); |
|
2016 |
|
2017 $("#mash_name").jqxInput({ theme: theme, width: 320, height: 23 }); |
|
2018 $("#mash_ph").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: 4, max: 8, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.1 }); |
|
2019 $("#tgt_mash_ph").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 100, height: 23, decimalDigits: 1, readOnly: true }); |
|
2020 $("#sparge_temp").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: 70, max: 98, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.5 }); |
|
2021 |
702 $("#est_mash_sg").jqxNumberInput({ inputMode: 'simple', readOnly: true, theme: theme, width: 70, height: 23, decimalDigits: 3 }); |
2022 $("#est_mash_sg").jqxNumberInput({ inputMode: 'simple', readOnly: true, theme: theme, width: 70, height: 23, decimalDigits: 3 }); |
|
2023 |
|
2024 // Several gauges |
|
2025 $("#hop_flavour").jqxProgressBar({ width: 300, height: 23, theme: theme, showText: true }); |
|
2026 $("#hop_aroma").jqxProgressBar({ width: 300, height: 23, theme: theme, showText: true }); |
|
2027 $("#perc_malts").jqxProgressBar({ width: 300, height: 23, theme: theme, showText: true }); |
|
2028 $("#perc_sugars").jqxProgressBar({ width: 300, height: 23, theme: theme, showText: true }); |
|
2029 $("#perc_cara").jqxProgressBar({ width: 300, height: 23, theme: theme, showText: true }); |
|
2030 |
|
2031 // Water treatment |
|
2032 $("#w1_name").jqxDropDownList({ |
|
2033 placeHolder: "Kies hoofd water:", |
|
2034 theme: theme, |
|
2035 source: waterlist, |
|
2036 displayMember: "name", |
|
2037 width: 250, |
|
2038 height: 27, |
|
2039 dropDownWidth: 400, |
|
2040 dropDownHeight: 400 |
|
2041 }); |
|
2042 $("#w1_name").on('select', function (event) { |
|
2043 if (event.args) { |
|
2044 var index = event.args.index; |
|
2045 var datarecord = waterlist.records[index]; |
|
2046 dataRecord.w1_name = datarecord.name; |
|
2047 $("#w1_calcium").val(datarecord.calcium); |
|
2048 dataRecord.w1_calcium = datarecord.calcium; |
|
2049 $("#w1_sulfate").val(datarecord.sulfate); |
|
2050 dataRecord.w1_sulfate = datarecord.sulfate; |
|
2051 $("#w1_chloride").val(datarecord.chloride); |
|
2052 dataRecord.w1_chloride = datarecord.chloride; |
|
2053 $("#w1_sodium").val(datarecord.sodium); |
|
2054 dataRecord.w1_sodium = datarecord.sodium; |
|
2055 $("#w1_magnesium").val(datarecord.magnesium); |
|
2056 dataRecord.w1_magnesium = datarecord.magnesium; |
|
2057 $("#w1_total_alkalinity").val(datarecord.total_alkalinity); |
|
2058 dataRecord.w1_total_alkalinity = datarecord.total_alkalinity; |
|
2059 $("#w1_ph").val(datarecord.ph); |
|
2060 dataRecord.w1_ph = datarecord.ph; |
|
2061 $("#w1_cost").val(datarecord.cost); |
|
2062 dataRecord.w1_cost = datarecord.cost; |
|
2063 calcWater(); |
|
2064 } |
|
2065 }); |
|
2066 $("#w1_amount").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true }); |
|
2067 $("#w1_calcium").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true }); |
|
2068 $("#w1_magnesium").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true }); |
|
2069 $("#w1_sodium").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true }); |
|
2070 $("#w1_total_alkalinity").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true }); |
|
2071 $("#w1_chloride").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true }); |
|
2072 $("#w1_sulfate").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true }); |
|
2073 $("#w1_ph").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true }); |
|
2074 |
|
2075 $("#w2_name").jqxDropDownList({ |
|
2076 placeHolder: "Kies meng water:", |
|
2077 theme: theme, |
|
2078 source: waterlist, |
|
2079 displayMember: "name", |
|
2080 width: 250, |
|
2081 height: 27, |
|
2082 dropDownWidth: 400, |
|
2083 dropDownHeight: 400 |
|
2084 }); |
|
2085 $("#w2_name").on('select', function (event) { |
|
2086 if (event.args) { |
|
2087 var index = event.args.index; |
|
2088 var datarecord = waterlist.records[index]; |
|
2089 dataRecord.w2_name = datarecord.name; |
|
2090 $("#w2_calcium").val(datarecord.calcium); |
|
2091 dataRecord.w2_calcium = datarecord.calcium; |
|
2092 $("#w2_sulfate").val(datarecord.sulfate); |
|
2093 dataRecord.w2_sulfate = datarecord.sulfate; |
|
2094 $("#w2_chloride").val(datarecord.chloride); |
|
2095 dataRecord.w2_chloride = datarecord.chloride; |
|
2096 $("#w2_sodium").val(datarecord.sodium); |
|
2097 dataRecord.w2_sodium = datarecord.sodium; |
|
2098 $("#w2_magnesium").val(datarecord.magnesium); |
|
2099 dataRecord.w2_magnesium = datarecord.magnesium; |
|
2100 $("#w2_total_alkalinity").val(datarecord.total_alkalinity); |
|
2101 dataRecord.w2_total_alkalinity = datarecord.total_alkalinity; |
|
2102 $("#w2_ph").val(datarecord.ph); |
|
2103 dataRecord.w2_ph = datarecord.ph; |
|
2104 $("#w2_cost").val(datarecord.cost); |
|
2105 dataRecord.w2_cost = datarecord.cost; |
|
2106 $("#w2_amount").jqxNumberInput({ max: 100000, readOnly: false }); // Set high max to enable the spinbuttons. |
|
2107 calcWater(); |
|
2108 } |
|
2109 }); |
|
2110 $("#w2_amount").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 94, height: 23, min: 0, max: 0, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.5, readOnly: true }); |
|
2111 $("#w2_calcium").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true }); |
|
2112 $("#w2_magnesium").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true }); |
|
2113 $("#w2_sodium").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true }); |
|
2114 $("#w2_total_alkalinity").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true }); |
|
2115 $("#w2_chloride").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true }); |
|
2116 $("#w2_sulfate").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true }); |
|
2117 $("#w2_ph").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true }); |
|
2118 |
|
2119 $("#wg_amount").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true }); |
|
2120 $("#wg_calcium").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true }); |
|
2121 $("#wg_magnesium").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true }); |
|
2122 $("#wg_sodium").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true }); |
|
2123 $("#wg_total_alkalinity").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true }); |
|
2124 $("#wg_chloride").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true }); |
|
2125 $("#wg_sulfate").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true }); |
|
2126 $("#wg_ph").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true }); |
|
2127 $("#wb_calcium").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true }); |
|
2128 $("#wb_magnesium").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true }); |
|
2129 $("#wb_sodium").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true }); |
|
2130 $("#wb_total_alkalinity").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true }); |
|
2131 $("#wb_chloride").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true }); |
|
2132 $("#wb_sulfate").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true }); |
|
2133 $("#wb_ph").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true }); |
|
2134 |
|
2135 $("#pr_name").jqxDropDownList({ |
|
2136 placeHolder: "Kies doel profiel:", |
|
2137 theme: theme, |
|
2138 source: waterprofiles, |
|
2139 displayMember: "name", |
|
2140 width: 250, |
|
2141 height: 27, |
|
2142 dropDownWidth: 400, |
|
2143 dropDownHeight: 300 |
|
2144 }); |
|
2145 $("#pr_name").on('select', function (event) { |
|
2146 if (event.args) { |
|
2147 var index = event.args.index; |
|
2148 var datarecord = waterprofiles.records[index]; |
|
2149 $("#pr_calcium").val(datarecord.calcium); |
|
2150 $("#pr_sulfate").val(datarecord.sulfate); |
|
2151 $("#pr_chloride").val(datarecord.chloride); |
|
2152 $("#pr_sodium").val(datarecord.sodium); |
|
2153 $("#pr_magnesium").val(datarecord.magnesium); |
|
2154 $("#pr_total_alkalinity").val(datarecord.total_alkalinity); |
|
2155 } |
|
2156 }); |
|
2157 $("#pr_calcium").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true }); |
|
2158 $("#pr_magnesium").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true }); |
|
2159 $("#pr_sodium").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true }); |
|
2160 $("#pr_total_alkalinity").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true }); |
|
2161 $("#pr_chloride").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true }); |
|
2162 $("#pr_sulfate").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 74, height: 23, decimalDigits: 1, readOnly: true }); |
|
2163 $("#wa_cacl2").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: 0, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.1, symbol: ' gr', symbolPosition: 'right' }); |
|
2164 $("#wa_caso4").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: 0, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.1, symbol: ' gr', symbolPosition: 'right' }); |
|
2165 $("#wa_mgso4").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: 0, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.1, symbol: ' gr', symbolPosition: 'right' }); |
|
2166 $("#wa_nacl").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: 0, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.1, symbol: ' gr', symbolPosition: 'right' }); |
|
2167 |
|
2168 $("#calc_acid").jqxCheckBox({ theme: theme, width: 120, height: 23 }); |
|
2169 $("#wa_base_name").jqxDropDownList({ theme: theme, source: srcBase, width: 125, height: 23, dropDownHeight: 128 }); |
|
2170 $("#wa_base").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: 0, decimalDigits: 2, spinButtons: true, spinButtonsStep: 0.05, symbol: ' gr', symbolPosition: 'right' }); |
|
2171 $("#wa_acid_name").jqxDropDownList({ theme: theme, source: srcAcid, width: 125, height: 23, dropDownHeight: 128 }) |
|
2172 $("#wa_acid").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: 0, decimalDigits: 2, spinButtons: true, spinButtonsStep: 0.05, symbol: ' ml', symbolPosition: 'right' }); |
|
2173 $("#wa_acid_perc").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 80, height: 23, min: 0, max: 100, decimalDigits: 0, spinButtons: true, symbol: '%', symbolPosition: 'right' }); |
|
2174 |
|
2175 $("#sparge_volume").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.1 }); |
|
2176 $("#sparge_ph").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.1 }); |
|
2177 $("#sparge_acid_amount").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 100, height: 23, decimalDigits: 5, readOnly: true }); |
703 |
2178 |
704 $('#jqxTabs').jqxTabs({ |
2179 $('#jqxTabs').jqxTabs({ |
705 theme: theme, |
2180 theme: theme, |
706 width: 1280, |
2181 width: 1280, |
707 height: 630, |
2182 height: 630, |
708 autoHeight: false, |
2183 autoHeight: false, |
709 position: 'top' |
2184 position: 'top' |
710 }); |
2185 }); |
711 |
2186 |
712 // Buttons sidebar |
|
713 $("#rec_edit").jqxButton({ template: "primary", width: '140px', theme: theme }); |
|
714 $("#brew_log").jqxButton({ template: "primary", width: '140px', theme: theme }); |
|
715 $("#ferment_log").jqxButton({ template: "primary", width: '140px', theme: theme }); |
|
716 |
|
717 // Buttons below |
2187 // Buttons below |
718 $("#Delete").jqxButton({ template: "danger", width: '80px', theme: theme }); |
2188 $("#Delete").jqxButton({ template: "danger", width: '80px', theme: theme }); |
719 $("#Delete").click(function () { |
2189 $("#Delete").click(function () { |
720 // Open a popup to confirm this action. |
2190 // Open a popup to confirm this action. |
721 $('#eventWindow').jqxWindow('open'); |
2191 $('#eventWindow').jqxWindow('open'); |
722 $("#delOk").click(function () { |
2192 $("#delOk").click(function () { |
723 var data = "delete=true&" + $.param({ uuid: dataRecord.puuid }); |
2193 var data = "delete=true&" + $.param({ uuid: dataRecord.uuid }); |
724 $.ajax({ |
2194 $.ajax({ |
725 dataType: 'json', |
2195 dataType: 'json', |
726 url: url, |
2196 url: url, |
727 cache: false, |
2197 cache: false, |
728 data: data, |
2198 data: data, |