122 isModal: true, |
122 isModal: true, |
123 autoOpen: false, |
123 autoOpen: false, |
124 cancelButton: $('#MashReady'), |
124 cancelButton: $('#MashReady'), |
125 modalOpacity: 0.40 |
125 modalOpacity: 0.40 |
126 }); |
126 }); |
|
127 } |
|
128 |
|
129 |
|
130 |
|
131 function drop_endis(flag, item, index) { |
|
132 (flag) ? $(item).jqxDropDownList('disableAt', index) : $(item).jqxDropDownList('enableAt', index); |
|
133 } |
|
134 |
|
135 |
|
136 |
|
137 function block_fermentable(stage, added) { |
|
138 if (stage > 5 && added < 4) // After fermentation and added before packaging |
|
139 return true; |
|
140 if (stage > 3 && added < 3) // After primary and added before sec/tert |
|
141 return true; |
|
142 if (stage > 2 && added < 2) // After boil and added during mash or boil |
|
143 return true; |
|
144 return false; |
|
145 } |
|
146 |
|
147 |
|
148 |
|
149 function minimum_fermentable(stage, added) { |
|
150 if (stage > 5 && added < 4) |
|
151 return 4; |
|
152 if (stage > 3 && added < 3) |
|
153 return 3; |
|
154 if (stage > 2 && added < 2) |
|
155 return 2; |
|
156 return added; |
|
157 } |
|
158 |
|
159 |
|
160 |
|
161 function minimum_hop(stage, useat) |
|
162 { |
|
163 if (stage > 2 && useat < 5) |
|
164 return 5; |
|
165 return useat; |
|
166 } |
|
167 |
|
168 |
|
169 |
|
170 function block_hop(stage, useat) |
|
171 { |
|
172 if (stage > 2 && useat < 5) |
|
173 return true; |
|
174 return false; |
|
175 } |
|
176 |
|
177 |
|
178 |
|
179 function block_misc(stage, use_use) { |
|
180 if (stage > 5 && use_use < 5) |
|
181 return true; |
|
182 if (stage > 3 && use_use < 4) |
|
183 return true; |
|
184 if (stage > 2 && use_use < 3) |
|
185 return true; |
|
186 if (stage > 1 && use_use < 1) |
|
187 return true; |
|
188 return false; |
|
189 } |
|
190 |
|
191 |
|
192 |
|
193 function minimum_misc(stage, use_use) { |
|
194 if (stage > 5 && use_use < 5) |
|
195 return 5; |
|
196 if (stage > 3 && use_use < 4) |
|
197 return 4; |
|
198 if (stage > 2 && use_use < 3) |
|
199 return 3; |
|
200 if (stage > 1 && use_use < 1) |
|
201 return 1; |
|
202 return use_use; |
|
203 } |
|
204 |
|
205 |
|
206 |
|
207 function block_yeast(stage, use) { |
|
208 if (stage > 3 && use < 1) |
|
209 return true; |
|
210 if (stage > 4 && use < 2) |
|
211 return true; |
|
212 if (stage > 5 && use < 3) |
|
213 return true; |
|
214 if (stage > 6 && use < 4) |
|
215 return true; |
|
216 return false; |
|
217 } |
|
218 |
|
219 |
|
220 |
|
221 function minimum_yeast(stage, use) { |
|
222 if (stage > 3 && use < 1) |
|
223 return 1; |
|
224 if (stage > 4 && use < 2) |
|
225 return 2; |
|
226 if (stage > 5 && use < 3) |
|
227 return 3; |
|
228 if (stage > 6 && use < 4) |
|
229 return 4; |
|
230 return use; |
127 } |
231 } |
128 |
232 |
129 |
233 |
130 |
234 |
131 $(document).ready(function() { |
235 $(document).ready(function() { |
752 row['f_added'] = 1; // Boil |
856 row['f_added'] = 1; // Boil |
753 } else { |
857 } else { |
754 row['f_added'] = 0; // Mash |
858 row['f_added'] = 0; // Mash |
755 } |
859 } |
756 /* If stage > added moment, adjust the moment */ |
860 /* If stage > added moment, adjust the moment */ |
757 if (dataRecord.stage > 5 && row['f_added'] < 4) |
861 row['f_added'] = minimum_fermentable(dataRecord.stage, row['f_added']); |
758 row['f_added'] = 4; |
|
759 if (dataRecord.stage > 3 && row['f_added'] < 3) |
|
760 row['f_added'] = 3; |
|
761 if (dataRecord.stage > 2 && row['f_added'] < 2) |
|
762 row['f_added'] = 2; |
|
763 row['f_dissolved_protein'] = datarecord.dissolved_protein; |
862 row['f_dissolved_protein'] = datarecord.dissolved_protein; |
764 row['f_recommend_mash'] = datarecord.recommend_mash; |
863 row['f_recommend_mash'] = datarecord.recommend_mash; |
765 row['f_add_after_boil'] = datarecord.add_after_boil; |
864 row['f_add_after_boil'] = datarecord.add_after_boil; |
766 if (rowscount == 0) { |
865 if (rowscount == 0) { |
767 // The first fermentable |
866 // The first fermentable |
790 var rowscount, id, percent, amount, i, rowdata, |
889 var rowscount, id, percent, amount, i, rowdata, |
791 selectedrowindex = $('#fermentableGrid').jqxGrid('getselectedrowindex'); |
890 selectedrowindex = $('#fermentableGrid').jqxGrid('getselectedrowindex'); |
792 rowscount = $('#fermentableGrid').jqxGrid('getdatainformation').rowscount; |
891 rowscount = $('#fermentableGrid').jqxGrid('getdatainformation').rowscount; |
793 if (selectedrowindex >= 0 && selectedrowindex < rowscount) { |
892 if (selectedrowindex >= 0 && selectedrowindex < rowscount) { |
794 id = $('#fermentableGrid').jqxGrid('getrowid', selectedrowindex); |
893 id = $('#fermentableGrid').jqxGrid('getrowid', selectedrowindex); |
795 percent = $('#fermentableGrid').jqxGrid('getcellvalue', id, 'f_percentage'); |
894 added = $('#fermentableGrid').jqxGrid('getcellvalue', selectedrowindex, 'f_added'); |
796 amount = $('#fermentableGrid').jqxGrid('getcellvalue', id, 'f_amount'); |
895 if (block_fermentable(dataRecord.stage, added)) { |
797 $('#fermentableGrid').jqxGrid('deleterow', id); |
896 percent = mount = 0; |
|
897 alert('Ingredieënt is al verwerkt.'); |
|
898 } else { |
|
899 percent = $('#fermentableGrid').jqxGrid('getcellvalue', id, 'f_percentage'); |
|
900 amount = $('#fermentableGrid').jqxGrid('getcellvalue', id, 'f_amount'); |
|
901 $('#fermentableGrid').jqxGrid('deleterow', id); |
|
902 } |
798 } |
903 } |
799 rowscount = $('#fermentableGrid').jqxGrid('getdatainformation').rowscount; |
904 rowscount = $('#fermentableGrid').jqxGrid('getdatainformation').rowscount; |
800 if (rowscount > 1) { |
905 if (rowscount > 1) { |
801 if (to_100) { |
906 if (to_100) { |
802 for (i = 0; i < rowscount; i++) { |
907 for (i = 0; i < rowscount; i++) { |
838 { text: 'Opbrengst', datafield: 'f_yield', width: 90, align: 'right', cellsalign: 'right', cellsformat: 'p1' }, |
943 { text: 'Opbrengst', datafield: 'f_yield', width: 90, align: 'right', cellsalign: 'right', cellsformat: 'p1' }, |
839 { text: 'Gewicht Kg', datafield: 'f_amount', width: 120, align: 'right', cellsalign: 'right', cellsformat: 'f3' }, |
944 { text: 'Gewicht Kg', datafield: 'f_amount', width: 120, align: 'right', cellsalign: 'right', cellsformat: 'f3' }, |
840 { text: 'Voorraad Kg', datafield: 'f_inventory', width: 120, align: 'right', |
945 { text: 'Voorraad Kg', datafield: 'f_inventory', width: 120, align: 'right', |
841 cellsrenderer: function(row, columnfield, value, defaulthtml, columnproperties, rowdata) { |
946 cellsrenderer: function(row, columnfield, value, defaulthtml, columnproperties, rowdata) { |
842 var color = '#ffffff'; |
947 var color = '#ffffff'; |
843 if (((dataRecord.inventory_reduced <= 2) && (rowdata.f_added <= 1)) || // Mash or boil |
948 if (block_fermentable(dataRecord.inventory_reduced, rowdata.f_added) == false) { |
844 ((dataRecord.inventory_reduced <= 3) && (rowdata.f_added == 2)) || // Primary |
|
845 ((dataRecord.inventory_reduced <= 5) && (rowdata.f_added == 3)) || // Secondary or Tertiary |
|
846 ((dataRecord.inventory_reduced <= 6) && (rowdata.f_added == 4)) || // Bottle |
|
847 ((dataRecord.inventory_reduced <= 6) && (rowdata.f_added == 5))) { // Kegs |
|
848 if (value < rowdata.f_amount) |
949 if (value < rowdata.f_amount) |
849 color = '#ff4040'; |
950 color = '#ff4040'; |
850 return '<span style="margin: 4px; margin-top: 6px; float: right; color: ' + color + ';">' + fermentableAdapter.formatNumber(value, 'f3') + '</span>'; |
951 return '<span style="margin: 4px; margin-top: 6px; float: right; color: ' + color + ';">' + fermentableAdapter.formatNumber(value, 'f3') + '</span>'; |
851 } else { |
952 } else { |
852 return '<span></span>'; |
953 return '<span></span>'; |
876 }, buttonclick: function(row) { |
977 }, buttonclick: function(row) { |
877 fermentableRow = row; |
978 fermentableRow = row; |
878 fermentableData = $('#fermentableGrid').jqxGrid('getrowdata', fermentableRow); |
979 fermentableData = $('#fermentableGrid').jqxGrid('getrowdata', fermentableRow); |
879 if (fermentableData.f_added >= 4) { |
980 if (fermentableData.f_added >= 4) { |
880 alert('Wijzig dit in de Verpakken tab'); |
981 alert('Wijzig dit in de Verpakken tab'); |
881 } else if ((dataRecord.stage >= 3 && fermentableData.f_added <= 1) || (dataRecord.stage >= 4 && fermentableData.f_added <= 2) || (dataRecord.stage >= 6 && fermentableData.f_added <= 3)) { |
982 } else if (block_fermentable(dataRecord.stage, fermentableData.f_added)) { |
882 alert('Ingredieënt is al verwerkt.'); |
983 alert('Ingredieënt is al verwerkt.'); |
883 } else { |
984 } else { |
884 $('#wf_name').val(fermentableData.f_name); |
985 $('#wf_name').val(fermentableData.f_name); |
885 $('#wf_amount').val(fermentableData.f_amount); |
986 $('#wf_amount').val(fermentableData.f_amount); |
886 $('#wf_percentage').val(fermentableData.f_percentage); |
987 $('#wf_percentage').val(fermentableData.f_percentage); |
887 $('#wf_max_in_batch').val(fermentableData.f_max_in_batch); |
988 $('#wf_max_in_batch').val(fermentableData.f_max_in_batch); |
888 $('#wf_adjust_to_total_100').val(fermentableData.f_adjust_to_total_100); |
989 $('#wf_adjust_to_total_100').val(fermentableData.f_adjust_to_total_100); |
889 $('#wf_added').val(fermentableData.f_added); |
990 $('#wf_added').val(fermentableData.f_added); |
890 (dataRecord.stage >= 3) ? $('#wf_added').jqxDropDownList('disableAt', 0) : $('#wf_added').jqxDropDownList('enableAt', 0); |
991 drop_endis(dataRecord.stage >= 3, '#wf_added', 0); |
891 (dataRecord.stage >= 3) ? $('#wf_added').jqxDropDownList('disableAt', 1) : $('#wf_added').jqxDropDownList('enableAt', 1); |
992 drop_endis(dataRecord.stage >= 3, '#wf_added', 1); |
892 (dataRecord.stage >= 4) ? $('#wf_added').jqxDropDownList('disableAt', 2) : $('#wf_added').jqxDropDownList('enableAt', 2); |
993 drop_endis(dataRecord.stage >= 4, '#wf_added', 2); |
893 $('#wf_added').jqxDropDownList('disableAt', 4); |
994 $('#wf_added').jqxDropDownList('disableAt', 4); |
894 $('#wf_added').jqxDropDownList('disableAt', 5); |
995 $('#wf_added').jqxDropDownList('disableAt', 5); |
895 // show the popup window. |
996 // show the popup window. |
896 $('#popupFermentable').jqxWindow('open'); |
997 $('#popupFermentable').jqxWindow('open'); |
897 } |
998 } |
985 row['h_caryophyllene'] = datarecord.caryophyllene; |
1086 row['h_caryophyllene'] = datarecord.caryophyllene; |
986 row['h_cohumulone'] = datarecord.cohumulone; |
1087 row['h_cohumulone'] = datarecord.cohumulone; |
987 row['h_myrcene'] = datarecord.myrcene; |
1088 row['h_myrcene'] = datarecord.myrcene; |
988 row['h_total_oil'] = datarecord.total_oil; |
1089 row['h_total_oil'] = datarecord.total_oil; |
989 row['h_inventory'] = datarecord.inventory; |
1090 row['h_inventory'] = datarecord.inventory; |
|
1091 /* If stage > useat moment, adjust the moment */ |
|
1092 row['h_useat'] = minimum_hop(dataRecord.stage, row['h_useat']); |
990 $('#hopGrid').jqxGrid('addrow', null, row); |
1093 $('#hopGrid').jqxGrid('addrow', null, row); |
991 } |
1094 } |
992 $('#haddrowbutton').jqxDropDownList('clearSelection'); |
1095 $('#haddrowbutton').jqxDropDownList('clearSelection'); |
993 }); |
1096 }); |
994 |
1097 |
995 $('#hinstockbutton').jqxCheckBox({ theme: theme, height: 27, disabled: (dataRecord.stage > 3) }); |
1098 $('#hinstockbutton').jqxCheckBox({ theme: theme, height: 27, disabled: (dataRecord.stage > 5) }); |
996 $('#hinstockbutton').on('change', function(event) { |
1099 $('#hinstockbutton').on('change', function(event) { |
997 hopinstock = event.args.checked; |
1100 hopinstock = event.args.checked; |
998 hoplist.dataBind(); |
1101 hoplist.dataBind(); |
999 }); |
1102 }); |
1000 |
1103 |
1001 // delete selected hop. |
1104 // delete selected hop. |
1002 $('#hdeleterowbutton').jqxButton({ template: 'danger', theme: theme, height: 27, width: 150, disabled: (dataRecord.stage > 3) }); |
1105 $('#hdeleterowbutton').jqxButton({ template: 'danger', theme: theme, height: 27, width: 150, disabled: (dataRecord.stage > 5) }); |
1003 $('#hdeleterowbutton').on('click', function() { |
1106 $('#hdeleterowbutton').on('click', function() { |
1004 var rowscount, id, selectedrowindex = $('#hopGrid').jqxGrid('getselectedrowindex'); |
1107 var rowscount, id, selectedrowindex = $('#hopGrid').jqxGrid('getselectedrowindex'); |
1005 rowscount = $('#hopGrid').jqxGrid('getdatainformation').rowscount; |
1108 rowscount = $('#hopGrid').jqxGrid('getdatainformation').rowscount; |
1006 if (selectedrowindex >= 0 && selectedrowindex < rowscount) { |
1109 if (selectedrowindex >= 0 && selectedrowindex < rowscount) { |
1007 id = $('#hopGrid').jqxGrid('getrowid', selectedrowindex); |
1110 useat = $('#hopGrid').jqxGrid('getcellvalue', selectedrowindex, 'h_useat'); |
1008 $('#hopGrid').jqxGrid('deleterow', id); |
1111 if (block_hop(dataRecord.stage, useat)) { |
|
1112 alert('Ingredieënt is al verwerkt.'); |
|
1113 } else { |
|
1114 id = $('#hopGrid').jqxGrid('getrowid', selectedrowindex); |
|
1115 $('#hopGrid').jqxGrid('deleterow', id); |
|
1116 } |
1009 } |
1117 } |
1010 calcIBUs(); |
1118 calcIBUs(); |
1011 }); |
1119 }); |
1012 }, |
1120 }, |
1013 ready: function() { $('#jqxTabs').jqxTabs('next'); }, |
1121 ready: function() { $('#jqxTabs').jqxTabs('next'); }, |
1059 return '<span style="margin: 4px; margin-top: 6px; float: right;">' + amount + '</span>'; |
1167 return '<span style="margin: 4px; margin-top: 6px; float: right;">' + amount + '</span>'; |
1060 } |
1168 } |
1061 }, |
1169 }, |
1062 { text: 'Voorraad', datafield: 'h_inventory', width: 110, align: 'right', |
1170 { text: 'Voorraad', datafield: 'h_inventory', width: 110, align: 'right', |
1063 cellsrenderer: function(index, datafield, value, defaultvalue, column, rowdata) { |
1171 cellsrenderer: function(index, datafield, value, defaultvalue, column, rowdata) { |
1064 if (((dataRecord.inventory_reduced <= 2) && (rowdata.h_useat <= 4)) || // Mash, FW, Boil, Aroma, Whirlpool |
1172 if (block_hop(dataRecord.inventory_reduced, rowdata.h_useat) == false) { |
1065 ((dataRecord.inventory_reduced <= 6) && (rowdata.h_useat == 5))) { // Dry hop |
|
1066 var amount, color = '#ffffff'; |
1173 var amount, color = '#ffffff'; |
1067 if (value < rowdata.h_amount) |
1174 if (value < rowdata.h_amount) |
1068 color = '#ff4040'; |
1175 color = '#ff4040'; |
1069 amount = dataAdapter.formatNumber(value, 'f1') + ' kg'; |
1176 amount = dataAdapter.formatNumber(value, 'f1') + ' kg'; |
1070 if (value < 1) |
1177 if (value < 1) |
1077 }, |
1184 }, |
1078 { text: '', datafield: 'Edit', columntype: 'button', width: 100, align: 'center', |
1185 { text: '', datafield: 'Edit', columntype: 'button', width: 100, align: 'center', |
1079 cellsrenderer: function() { |
1186 cellsrenderer: function() { |
1080 return 'Wijzig'; |
1187 return 'Wijzig'; |
1081 }, buttonclick: function(row) { |
1188 }, buttonclick: function(row) { |
1082 if (dataRecord.stage > 3) { |
1189 hopRow = row; |
|
1190 hopData = $('#hopGrid').jqxGrid('getrowdata', hopRow); |
|
1191 if (block_hop(dataRecord.stage, hopData.h_useat)) { |
1083 alert('Ingredieënt is al verwerkt.'); |
1192 alert('Ingredieënt is al verwerkt.'); |
1084 } else { |
1193 } else { |
1085 console.log('edit button row ' + row); |
1194 console.log('edit button row ' + row); |
1086 hopRow = row; |
|
1087 hopData = $('#hopGrid').jqxGrid('getrowdata', hopRow); |
|
1088 $('#wh_name').val(hopData.h_name); |
1195 $('#wh_name').val(hopData.h_name); |
1089 $('#wh_amount').val(hopData.h_amount * 1000); |
1196 $('#wh_amount').val(hopData.h_amount * 1000); |
1090 var ibu = toIBU(hopData.h_useat, hopData.h_form, preboil_sg, parseFloat($('#batch_size').jqxNumberInput('decimal')), |
1197 var ibu = toIBU(hopData.h_useat, hopData.h_form, preboil_sg, parseFloat($('#batch_size').jqxNumberInput('decimal')), |
1091 parseFloat(hopData.h_amount), parseFloat(hopData.h_time), parseFloat(hopData.h_alpha), $('#ibu_method').val(), |
1198 parseFloat(hopData.h_amount), parseFloat(hopData.h_time), parseFloat(hopData.h_alpha), $('#ibu_method').val(), |
1092 dataRecord.brew_whirlpool9, dataRecord.brew_whirlpool7, dataRecord.brew_whirlpool6); |
1199 dataRecord.brew_whirlpool9, dataRecord.brew_whirlpool7, dataRecord.brew_whirlpool6); |
1094 if (hopData.h_useat == 5) // Dry hop |
1201 if (hopData.h_useat == 5) // Dry hop |
1095 $('#wh_time').val(hopData.h_time / 1440); |
1202 $('#wh_time').val(hopData.h_time / 1440); |
1096 else |
1203 else |
1097 $('#wh_time').val(hopData.h_time); |
1204 $('#wh_time').val(hopData.h_time); |
1098 $('#wh_useat').val(hopData.h_useat); |
1205 $('#wh_useat').val(hopData.h_useat); |
|
1206 for (i = 0; i < 5; i++) { |
|
1207 drop_endis(dataRecord.stage > 2, '#wh_useat', i); |
|
1208 } |
1099 // show the popup window. |
1209 // show the popup window. |
1100 $('#popupHop').jqxWindow('open'); |
1210 $('#popupHop').jqxWindow('open'); |
1101 } |
1211 } |
1102 } |
1212 } |
1103 } |
1213 } |
1230 datarecord = misclist.records[index]; |
1340 datarecord = misclist.records[index]; |
1231 row['m_name'] = datarecord.name; |
1341 row['m_name'] = datarecord.name; |
1232 row['m_amount'] = 0; |
1342 row['m_amount'] = 0; |
1233 row['m_cost'] = datarecord.cost; |
1343 row['m_cost'] = datarecord.cost; |
1234 row['m_type'] = datarecord.type; |
1344 row['m_type'] = datarecord.type; |
1235 row['m_use_use'] = datarecord.use_use; |
1345 row['m_use_use'] = minimum_misc(dataRecord.stage, datarecord.use_use); |
1236 row['m_time'] = 0; |
1346 row['m_time'] = 0; |
1237 row['m_amount_is_weight'] = datarecord.amount_is_weight; |
1347 row['m_amount_is_weight'] = datarecord.amount_is_weight; |
1238 row['m_inventory'] = datarecord.inventory; |
1348 row['m_inventory'] = datarecord.inventory; |
1239 $('#miscGrid').jqxGrid('addrow', null, row); |
1349 $('#miscGrid').jqxGrid('addrow', null, row); |
1240 } |
1350 } |
1241 }); |
1351 }); |
1242 $('#minstockbutton').jqxCheckBox({ theme: theme, height: 27, disabled: (dataRecord.stage > 3) }); |
1352 $('#minstockbutton').jqxCheckBox({ theme: theme, height: 27, disabled: (dataRecord.stage > 6) }); |
1243 $('#minstockbutton').on('change', function(event) { |
1353 $('#minstockbutton').on('change', function(event) { |
1244 miscinstock = event.args.checked; |
1354 miscinstock = event.args.checked; |
1245 misclist.dataBind(); |
1355 misclist.dataBind(); |
1246 }); |
1356 }); |
1247 // delete selected misc. |
1357 // delete selected misc. |
1248 $('#mdeleterowbutton').jqxButton({ template: 'danger', theme: theme, height: 27, width: 150, disabled: (dataRecord.stage > 3) }); |
1358 $('#mdeleterowbutton').jqxButton({ template: 'danger', theme: theme, height: 27, width: 150, disabled: (dataRecord.stage > 6) }); |
1249 $('#mdeleterowbutton').on('click', function() { |
1359 $('#mdeleterowbutton').on('click', function() { |
1250 var rowscount, type, id, selectedrowindex = $('#miscGrid').jqxGrid('getselectedrowindex'); |
1360 var rowscount, type, id, selectedrowindex = $('#miscGrid').jqxGrid('getselectedrowindex'); |
1251 rowscount = $('#miscGrid').jqxGrid('getdatainformation').rowscount; |
1361 rowscount = $('#miscGrid').jqxGrid('getdatainformation').rowscount; |
1252 type = $('#miscGrid').jqxGrid('getcellvalue', selectedrowindex, 'm_type'); |
1362 type = $('#miscGrid').jqxGrid('getcellvalue', selectedrowindex, 'm_type'); |
1253 if (selectedrowindex >= 0 && selectedrowindex < rowscount && type != 4) { // Water agent |
1363 use_use = $('#miscGrid').jqxGrid('getcellvalue', selectedrowindex, 'm_use_use'); |
|
1364 if (selectedrowindex >= 0 && selectedrowindex < rowscount && type == 4) { |
|
1365 alert('Brouwzouten verwijderen in de water tab.'); |
|
1366 } else if (block_misc(dataRecord.stage, use_use)) { |
|
1367 alert('Ingredieënt is al verwerkt.'); |
|
1368 } else { |
1254 id = $('#miscGrid').jqxGrid('getrowid', selectedrowindex); |
1369 id = $('#miscGrid').jqxGrid('getrowid', selectedrowindex); |
1255 $('#miscGrid').jqxGrid('deleterow', id); |
1370 $('#miscGrid').jqxGrid('deleterow', id); |
1256 } |
1371 } |
1257 }); |
1372 }); |
1258 }, |
1373 }, |
1286 } |
1401 } |
1287 }, |
1402 }, |
1288 { text: 'Voorraad', datafield: 'm_inventory', width: 110, align: 'right', |
1403 { text: 'Voorraad', datafield: 'm_inventory', width: 110, align: 'right', |
1289 cellsrenderer: function(index, datafield, value, defaultvalue, column, rowdata) { |
1404 cellsrenderer: function(index, datafield, value, defaultvalue, column, rowdata) { |
1290 var vstr, color, amount; |
1405 var vstr, color, amount; |
1291 if (((dataRecord.inventory_reduced <= 2) && (rowdata.m_use_use <= 2)) || // Starter, Mash, Boil |
1406 if (block_misc(dataRecord.inventory_reduced, rowdata.m_use_use) == false) { |
1292 ((dataRecord.inventory_reduced <= 3) && (rowdata.m_use_use == 3)) || // Primary |
|
1293 ((dataRecord.inventory_reduced <= 5) && (rowdata.m_use_use == 4)) || // Secondary, Teriary |
|
1294 ((dataRecord.inventory_reduced <= 6) && (rowdata.m_use_use == 5))) { // Bottle |
|
1295 vstr = rowdata.m_amount_is_weight ? 'gr' : 'ml'; |
1407 vstr = rowdata.m_amount_is_weight ? 'gr' : 'ml'; |
1296 color = '#ffffff'; |
1408 color = '#ffffff'; |
1297 if (value < rowdata.m_amount) |
1409 if (value < rowdata.m_amount) |
1298 color = '#ff4040'; |
1410 color = '#ff4040'; |
1299 amount = dataAdapter.formatNumber(value * 1000, 'f2') + ' ' + vstr; |
1411 amount = dataAdapter.formatNumber(value * 1000, 'f2') + ' ' + vstr; |
1307 cellsrenderer: function() { |
1419 cellsrenderer: function() { |
1308 return 'Wijzig'; |
1420 return 'Wijzig'; |
1309 }, buttonclick: function(row) { |
1421 }, buttonclick: function(row) { |
1310 miscRow = row; |
1422 miscRow = row; |
1311 miscData = $('#miscGrid').jqxGrid('getrowdata', miscRow); |
1423 miscData = $('#miscGrid').jqxGrid('getrowdata', miscRow); |
1312 if (dataRecord.stage > 3) { |
1424 if (block_misc(dataRecord.stage, miscData.m_use_use)) { |
1313 alert('Ingredieënt is al verwerkt.'); |
1425 alert('Ingredieënt is al verwerkt.'); |
1314 } else if (miscData.m_type == 4) { |
1426 } else if (miscData.m_type == 4) { |
1315 alert('Brouwzouten wijzigen in de water tab.'); |
1427 alert('Brouwzouten wijzigen in de water tab.'); |
1316 } else { |
1428 } else { |
1317 console.log('edit button row ' + row); |
1429 console.log('edit button row ' + row); |
1324 if ((miscData.m_use_use == 3) || (miscData.m_use_use == 4)) // Primary or Secondary |
1436 if ((miscData.m_use_use == 3) || (miscData.m_use_use == 4)) // Primary or Secondary |
1325 $('#wm_time').val(miscData.m_time / 1440); |
1437 $('#wm_time').val(miscData.m_time / 1440); |
1326 else |
1438 else |
1327 $('#wm_time').val(miscData.m_time); |
1439 $('#wm_time').val(miscData.m_time); |
1328 $('#wm_use_use').val(miscData.m_use_use); |
1440 $('#wm_use_use').val(miscData.m_use_use); |
|
1441 drop_endis(dataRecord.stage >= 2, '#wm_use_use', 0); |
|
1442 drop_endis(dataRecord.stage >= 3, '#wm_use_use', 1); |
|
1443 drop_endis(dataRecord.stage >= 3, '#wm_use_use', 2); |
|
1444 drop_endis(dataRecord.stage >= 4, '#wm_use_use', 3); |
|
1445 drop_endis(dataRecord.stage >= 5, '#wm_use_use', 4); |
1329 // show the popup window. |
1446 // show the popup window. |
1330 $('#popupMisc').jqxWindow('open'); |
1447 $('#popupMisc').jqxWindow('open'); |
1331 } |
1448 } |
1332 } |
1449 } |
1333 } |
1450 } |
1394 // add yeast from dropdownlist. |
1511 // add yeast from dropdownlist. |
1395 $('#yaddrowbutton').jqxDropDownList({ |
1512 $('#yaddrowbutton').jqxDropDownList({ |
1396 placeHolder: 'Kies gist:', |
1513 placeHolder: 'Kies gist:', |
1397 theme: theme, |
1514 theme: theme, |
1398 source: yeastlist, |
1515 source: yeastlist, |
1399 disabled: (dataRecord.stage > 3), |
1516 disabled: (dataRecord.stage > 6), |
1400 template: 'primary', |
1517 template: 'primary', |
1401 displayMember: 'name', |
1518 displayMember: 'name', |
1402 width: 150, |
1519 width: 150, |
1403 height: 27, |
1520 height: 27, |
1404 dropDownWidth: 500, |
1521 dropDownWidth: 500, |
1417 row['y_product_id'] = datarecord.product_id; |
1534 row['y_product_id'] = datarecord.product_id; |
1418 row['y_type'] = datarecord.type; |
1535 row['y_type'] = datarecord.type; |
1419 row['y_form'] = datarecord.form; |
1536 row['y_form'] = datarecord.form; |
1420 row['y_amount'] = 0; |
1537 row['y_amount'] = 0; |
1421 row['y_cost'] = datarecord.cost; |
1538 row['y_cost'] = datarecord.cost; |
1422 row['y_use'] = 0; |
1539 row['y_use'] = minimum_yeast(dataRecord.stage, 0); |
1423 row['y_min_temperature'] = datarecord.min_temperature; |
1540 row['y_min_temperature'] = datarecord.min_temperature; |
1424 row['y_max_temperature'] = datarecord.max_temperature; |
1541 row['y_max_temperature'] = datarecord.max_temperature; |
1425 row['y_attenuation'] = datarecord.attenuation; |
1542 row['y_attenuation'] = datarecord.attenuation; |
1426 row['y_flocculation'] = datarecord.flocculation; |
1543 row['y_flocculation'] = datarecord.flocculation; |
1427 row['y_cells'] = datarecord.cells; |
1544 row['y_cells'] = datarecord.cells; |
1442 } |
1559 } |
1443 calcViability(); |
1560 calcViability(); |
1444 calcYeast(); |
1561 calcYeast(); |
1445 $('#yaddrowbutton').jqxDropDownList('clearSelection'); |
1562 $('#yaddrowbutton').jqxDropDownList('clearSelection'); |
1446 }); |
1563 }); |
1447 $('#yinstockbutton').jqxCheckBox({ theme: theme, height: 27, disabled: (dataRecord.stage > 3) }); |
1564 $('#yinstockbutton').jqxCheckBox({ theme: theme, height: 27, disabled: (dataRecord.stage > 6) }); |
1448 $('#yinstockbutton').on('change', function(event) { |
1565 $('#yinstockbutton').on('change', function(event) { |
1449 yeastinstock = event.args.checked; |
1566 yeastinstock = event.args.checked; |
1450 yeastlist.dataBind(); |
1567 yeastlist.dataBind(); |
1451 }); |
1568 }); |
1452 // delete selected yeast. |
1569 // delete selected yeast. |
1453 $('#ydeleterowbutton').jqxButton({ template: 'danger', theme: theme, height: 27, width: 150, disabled: (dataRecord.stage > 3) }); |
1570 $('#ydeleterowbutton').jqxButton({ template: 'danger', theme: theme, height: 27, width: 150, disabled: (dataRecord.stage > 6) }); |
1454 $('#ydeleterowbutton').on('click', function() { |
1571 $('#ydeleterowbutton').on('click', function() { |
1455 var id, rowscount, selectedrowindex = $('#yeastGrid').jqxGrid('getselectedrowindex'); |
1572 var id, rowscount, selectedrowindex = $('#yeastGrid').jqxGrid('getselectedrowindex'); |
1456 rowscount = $('#yeastGrid').jqxGrid('getdatainformation').rowscount; |
1573 rowscount = $('#yeastGrid').jqxGrid('getdatainformation').rowscount; |
1457 if (selectedrowindex >= 0 && selectedrowindex < rowscount) { |
1574 if (selectedrowindex >= 0 && selectedrowindex < rowscount) { |
1458 id = $('#yeastGrid').jqxGrid('getrowid', selectedrowindex); |
1575 use = $('#yeastGrid').jqxGrid('getcellvalue', selectedrowindex, 'y_use'); |
1459 $('#yeastGrid').jqxGrid('deleterow', id); |
1576 if (block_yeast(dataRecord.stage, use)) { |
1460 calcViability(); |
1577 alert('Ingredieënt is al verwerkt.'); |
1461 calcYeast(); |
1578 } else { |
|
1579 id = $('#yeastGrid').jqxGrid('getrowid', selectedrowindex); |
|
1580 $('#yeastGrid').jqxGrid('deleterow', id); |
|
1581 calcViability(); |
|
1582 calcYeast(); |
|
1583 } |
1462 } |
1584 } |
1463 }); |
1585 }); |
1464 }, |
1586 }, |
1465 ready: function() { $('#jqxTabs').jqxTabs('next'); }, |
1587 ready: function() { $('#jqxTabs').jqxTabs('next'); }, |
1466 columns: [ |
1588 columns: [ |
1502 } |
1624 } |
1503 }, |
1625 }, |
1504 { text: 'Voorraad', datafield: 'y_inventory', width: 90, align: 'right', |
1626 { text: 'Voorraad', datafield: 'y_inventory', width: 90, align: 'right', |
1505 cellsrenderer: function(index, datafield, value, defaultvalue, column, rowdata) { |
1627 cellsrenderer: function(index, datafield, value, defaultvalue, column, rowdata) { |
1506 var color, amount; |
1628 var color, amount; |
1507 if (((dataRecord.inventory_reduced <= 3) && (rowdata.y_use == 0)) || // Primary |
1629 if (block_yeast(dataRecord.inventory_reduced, rowdata.y_use) == false) { |
1508 ((dataRecord.inventory_reduced <= 4) && (rowdata.y_use == 1)) || // Secondary |
|
1509 ((dataRecord.inventory_reduced <= 5) && (rowdata.y_use == 2)) || // Tertiary |
|
1510 ((dataRecord.inventory_reduced <= 6) && (rowdata.y_use == 3))) { // Bottle |
|
1511 color = '#ffffff'; |
1630 color = '#ffffff'; |
1512 if (value < rowdata.y_amount) |
1631 if (value < rowdata.y_amount) |
1513 color = '#ff4040'; |
1632 color = '#ff4040'; |
1514 amount = dataAdapter.formatNumber(value * 1000, 'f0') + ' ml'; |
1633 amount = dataAdapter.formatNumber(value * 1000, 'f0') + ' ml'; |
1515 if (rowdata.y_form == 0) // Liquid |
1634 if (rowdata.y_form == 0) // Liquid |
1526 cellsrenderer: function() { |
1645 cellsrenderer: function() { |
1527 return 'Wijzig'; |
1646 return 'Wijzig'; |
1528 }, buttonclick: function(row) { |
1647 }, buttonclick: function(row) { |
1529 yeastRow = row; |
1648 yeastRow = row; |
1530 yeastData = $('#yeastGrid').jqxGrid('getrowdata', yeastRow); |
1649 yeastData = $('#yeastGrid').jqxGrid('getrowdata', yeastRow); |
1531 if ((dataRecord.stage > 3 && yeastData.y_use == 0) || |
1650 if (block_yeast(dataRecord.stage, yeastData.y_use)) { |
1532 (dataRecord.stage > 4 && yeastData.y_use == 1) || |
|
1533 (dataRecord.stage > 5 && yeastData.y_use == 2) || |
|
1534 (dataRecord.stage > 6 && yeastData.y_use == 3)) { |
|
1535 alert('Ingredieënt is al verwerkt.'); |
1651 alert('Ingredieënt is al verwerkt.'); |
1536 } else { |
1652 } else { |
1537 if (yeastData.y_form == 0) { |
1653 if (yeastData.y_form == 0) { |
1538 $('#wy_pmpt_amount').html('Pak(ken):'); |
1654 $('#wy_pmpt_amount').html('Pak(ken):'); |
1539 $('#wy_amount').val(yeastData.y_amount); |
1655 $('#wy_amount').val(yeastData.y_amount); |
1549 } |
1665 } |
1550 $('#wy_name').val(yeastData.y_name); |
1666 $('#wy_name').val(yeastData.y_name); |
1551 $('#wy_laboratory').val(yeastData.y_laboratory); |
1667 $('#wy_laboratory').val(yeastData.y_laboratory); |
1552 $('#wy_product_id').val(yeastData.y_product_id); |
1668 $('#wy_product_id').val(yeastData.y_product_id); |
1553 $('#wy_use').val(yeastData.y_use); |
1669 $('#wy_use').val(yeastData.y_use); |
|
1670 drop_endis(dataRecord.stage > 3, '#wy_use', 0); |
|
1671 drop_endis(dataRecord.stage > 4, '#wy_use', 1); |
|
1672 drop_endis(dataRecord.stage > 5, '#wy_use', 2); |
1554 // show the popup window. |
1673 // show the popup window. |
1555 $('#popupYeast').jqxWindow('open'); |
1674 $('#popupYeast').jqxWindow('open'); |
1556 } |
1675 } |
1557 } |
1676 } |
1558 } |
1677 } |