944 return "<div style='margin: 4px;' class='jqx-right-align'>" + dataAdapter.formatNumber(gram, "f1") + " gr</div>"; |
944 return "<div style='margin: 4px;' class='jqx-right-align'>" + dataAdapter.formatNumber(gram, "f1") + " gr</div>"; |
945 }, |
945 }, |
946 validation: function (cell, value) { |
946 validation: function (cell, value) { |
947 var maxhops = parseFloat($("#batch_size").jqxNumberInput('decimal')) * 200; |
947 var maxhops = parseFloat($("#batch_size").jqxNumberInput('decimal')) * 200; |
948 if (value < 0 || value > maxhops ) { |
948 if (value < 0 || value > maxhops ) { |
949 return { result: false, message: "Volume moet 0-"+maxhops+" zijn" }; |
949 return { result: false, message: "Gewicht moet 0-"+maxhops+" gram zijn" }; |
950 } |
950 } |
951 return true; |
951 return true; |
952 } |
952 } |
953 }, |
953 }, |
954 /* { text: 'Gewicht Kg', datafield: 'h_amount', width: 120, align: 'right', cellsalign: 'right', cellsformat: 'f4', |
954 { datafield: 'h_amount', hidden: true }, // We need to declare this column |
955 columntype: 'numberinput', |
|
956 initeditor: function (row, cellvalue, editor, celltext, pressedChar) { |
|
957 editor.jqxNumberInput({ decimalDigits: 4, min: 0, spinButtons: false }); |
|
958 }, |
|
959 validation: function (cell, value) { |
|
960 if (value < 0 || value > 100000000000 ) { |
|
961 return { result: false, message: "Volume moet 0-~ zijn" }; |
|
962 } |
|
963 return true; |
|
964 } |
|
965 }, */ |
|
966 { text: 'Gebruik', width: 110, align: 'center', cellsalign: 'center', datafield: 'h_useat', columntype: 'dropdownlist', |
955 { text: 'Gebruik', width: 110, align: 'center', cellsalign: 'center', datafield: 'h_useat', columntype: 'dropdownlist', |
967 createeditor: function (row, column, editor) { |
956 createeditor: function (row, column, editor) { |
968 var srcUse = [ "Boil", "Dry Hop", "Mash", "First Wort", "Aroma" ]; |
957 var srcUse = [ "Boil", "Dry Hop", "Mash", "First Wort", "Aroma" ]; |
969 editor.jqxDropDownList({ autoDropDownHeight: true, source: srcUse }); |
958 editor.jqxDropDownList({ autoDropDownHeight: true, source: srcUse }); |
970 }, |
959 }, |
977 } |
966 } |
978 }, |
967 }, |
979 { text: 'Tijd', datafield: 'h_time', width: 70, align: 'right', cellsalign: 'right', cellsformat: 'f0', |
968 { text: 'Tijd', datafield: 'h_time', width: 70, align: 'right', cellsalign: 'right', cellsformat: 'f0', |
980 columntype: 'numberinput', |
969 columntype: 'numberinput', |
981 initeditor: function (row, cellvalue, editor, celltext, pressedChar) { |
970 initeditor: function (row, cellvalue, editor, celltext, pressedChar) { |
982 editor.jqxNumberInput({ decimalDigits: 0, digits: 3, min: 0 }); |
971 editor.jqxNumberInput({ decimalDigits: 0, digits: 3, min: 0, max: parseFloat(dataRecord.boil_time) }); |
983 }, |
972 }, |
984 cellvaluechanging: function (row, column, columntype, oldvalue, newvalue) { |
973 cellvaluechanging: function (row, column, columntype, oldvalue, newvalue) { |
985 var use = $("#hopGrid").jqxGrid('getcellvalue', row, "h_useat"); |
974 var use = $("#hopGrid").jqxGrid('getcellvalue', row, "h_useat"); |
986 if (use != "Boil") |
975 if (use != "Boil") |
987 return oldvalue; |
976 return oldvalue; |
988 }, |
977 }, |
989 validation: function (cell, value) { |
978 validation: function (cell, value) { |
990 var high = parseFloat($("#boil_time").jqxNumberInput('decimal')); |
979 var high = parseFloat(dataRecord.boil_time); |
991 if (value < 0 || value > high ) { |
980 if (value < 0 || value > high ) { |
992 return { result: false, message: "De tijd moet 0-"+high+" zijn" }; |
981 return { result: false, message: "De tijd moet 0-"+high+" zijn" }; |
993 } |
982 } |
994 return true; |
983 return true; |
995 } |
984 } |
1120 $('#jqxTabs').jqxTabs('next'); |
1109 $('#jqxTabs').jqxTabs('next'); |
1121 }, |
1110 }, |
1122 columns: [ |
1111 columns: [ |
1123 { text: 'Ingredient', editable: false, datafield: 'm_name' }, |
1112 { text: 'Ingredient', editable: false, datafield: 'm_name' }, |
1124 { text: 'Type', editable: false, width: 120, align: 'center', cellsalign: 'center', datafield: 'm_type' }, |
1113 { text: 'Type', editable: false, width: 120, align: 'center', cellsalign: 'center', datafield: 'm_type' }, |
1125 { text: 'Gebruik', editable: false, width: 90, align: 'center', cellsalign: 'center', datafield: 'm_use_use' }, |
1114 { text: 'Gebruik', width: 110, align: 'center', cellsalign: 'center', datafield: 'm_use_use', columntype: 'dropdownlist', |
1126 { text: 'Gewicht', datafield: 'm_amount', width: 110, align: 'right', cellsalign: 'right', cellsformat: 'f5', |
1115 createeditor: function (row, column, editor) { |
|
1116 var srcUseUse = [ "Mash", "Boil", "Primary", "Secondary", "Bottling" ]; |
|
1117 editor.jqxDropDownList({ autoDropDownHeight: true, source: srcUseUse }); |
|
1118 } |
|
1119 }, |
|
1120 { datafield: 'm_amount_is_weight', hidden: true }, // We need to declare this column |
|
1121 { datafield: 'm_amount', hidden: true }, // We need to declare this column |
|
1122 { text: 'Hoeveelheid', datafield: 'grammen', width: 120, align: 'right', cellsalign: 'right', cellsformat: 'f2', |
1127 columntype: 'numberinput', |
1123 columntype: 'numberinput', |
|
1124 cellsrenderer: function (index, datafield, value, defaultvalue, column, rowdata) { |
|
1125 var gram = rowdata.m_amount * 1000; |
|
1126 var vstr = rowdata.m_amount_is_weight ? "gr":"ml"; |
|
1127 return "<div style='margin: 4px;' class='jqx-right-align'>"+dataAdapter.formatNumber(gram,"f2")+" "+vstr+"</div>"; |
|
1128 }, |
1128 validation: function (cell, value) { |
1129 validation: function (cell, value) { |
1129 if (value < 0 || value > 100000000000 ) { |
1130 var high = parseFloat(dataRecord.boil_size) * 1000; |
1130 return { result: false, message: "Volume moet 0-~ zijn" }; |
1131 if (value < 0 || value > high) { |
|
1132 return { result: false, message: "Hoeveelheid moet tussen 0 en "+high+" zijn" }; |
1131 } |
1133 } |
1132 return true; |
1134 return true; |
1133 } |
1135 }, |
|
1136 initeditor: function (row, cellvalue, editor) { |
|
1137 editor.jqxNumberInput({ inputMode: 'simple', min: 0, decimalDigits: 2, spinButtons: false }); |
|
1138 } |
1134 }, |
1139 }, |
1135 { text: 'Tijd', datafield: 'm_time', width: 70, align: 'right', cellsalign: 'right', cellsformat: 'f0', |
1140 { datafield: 'm_time' }, |
|
1141 { text: 'Tijd', datafield: 'time', width: 70, align: 'right', cellsalign: 'right', cellsformat: 'f0', |
1136 columntype: 'numberinput', |
1142 columntype: 'numberinput', |
|
1143 cellsrenderer: function (index, datafield, value, defaultvalue, column, rowdata) { |
|
1144 if (rowdata.m_use_use == 'Boil') { |
|
1145 var tijd = rowdata.m_time; |
|
1146 return "<div style='margin: 4px;' class='jqx-right-align'>"+dataAdapter.formatNumber(tijd, "f0")+" m</div>"; |
|
1147 } else if (rowdata.m_use_use == 'Secondary') { |
|
1148 var tijd = Math.round(rowdata.m_time / 1440); |
|
1149 return "<div style='margin: 4px;' class='jqx-right-align'>"+dataAdapter.formatNumber(tijd, "f0")+" d</div>"; |
|
1150 } else { |
|
1151 var tijd = 0; |
|
1152 return "<div style='margin: 4px;' class='jqx-right-align'> </div>"; |
|
1153 } |
|
1154 }, |
|
1155 initeditor: function (row, cellvalue, editor, celltext, pressedChar) { |
|
1156 editor.jqxNumberInput({ decimalDigits: 0, digits: 3, min: 0, max: parseFloat(dataRecord.boil_time) }); |
|
1157 }, |
|
1158 cellvaluechanging: function (row, column, columntype, oldvalue, newvalue) { |
|
1159 var use = $("#miscGrid").jqxGrid('getcellvalue', row, "m_use_use"); |
|
1160 if (use != "Boil") |
|
1161 return oldvalue; |
|
1162 }, |
1137 validation: function (cell, value) { |
1163 validation: function (cell, value) { |
1138 if (value < 0 || value > 100000000000 ) { |
1164 var high = parseFloat(dataRecord.boil_time); |
1139 return { result: false, message: "De tijd moet 0-~ zijn" }; |
1165 if (value < 0 || value > high ) { |
|
1166 return { result: false, message: "De tijd moet 0-"+high+" zijn" }; |
1140 } |
1167 } |
1141 return true; |
1168 return true; |
1142 } |
1169 } |
1143 } |
1170 } |
1144 ] |
1171 ] |
1145 }) |
1172 }); |
|
1173 $("#miscGrid").on('cellendedit', function (event) { |
|
1174 var args = event.args; |
|
1175 console.log("Event Type: cellendedit, Column: " + args.datafield + ", Row: " + (args.rowindex) + ", Value: " + args.value); |
|
1176 if (args.datafield == 'grammen') { |
|
1177 $("#miscGrid").jqxGrid('setcellvalue', args.rowindex, 'm_amount', parseFloat(args.value / 1000)); |
|
1178 } else if (args.datafield == 'time') { |
|
1179 var use_use = $("#miscGrid").jqxGrid('getcellvalue', args.rowindex, 'm_use_use'); |
|
1180 console.log("use: "+use_use); |
|
1181 if (use_use == 'Secondary') |
|
1182 $("#miscGrid").jqxGrid('setcellvalue', args.rowindex, 'm_time', parseFloat(args.value * 1440)); |
|
1183 else |
|
1184 $("#miscGrid").jqxGrid('setcellvalue', args.rowindex, 'm_time', parseFloat(args.value)); |
|
1185 } else { |
|
1186 $("#miscGrid").jqxGrid('setcellvalue', args.rowindex, args.datafield, args.value); |
|
1187 } |
|
1188 }); |
1146 }; |
1189 }; |
1147 |
1190 |
1148 // Inline yeasts editor |
1191 // Inline yeasts editor |
1149 var editYeast = function (data) { |
1192 var editYeast = function (data) { |
1150 var yeastSource = { |
1193 var yeastSource = { |
1267 { text: 'Code', editable: false, width: 90, datafield: 'y_product_id' }, |
1315 { text: 'Code', editable: false, width: 90, datafield: 'y_product_id' }, |
1268 { text: 'Soort', editable: false, width: 80, align: 'center', cellsalign: 'center', datafield: 'y_form' }, |
1316 { text: 'Soort', editable: false, width: 80, align: 'center', cellsalign: 'center', datafield: 'y_form' }, |
1269 { text: 'Min.', editable: false, width: 70, align: 'right', cellsalign: 'right', datafield: 'y_min_temperature' }, |
1317 { text: 'Min.', editable: false, width: 70, align: 'right', cellsalign: 'right', datafield: 'y_min_temperature' }, |
1270 { text: 'Max.', editable: false, width: 70, align: 'right', cellsalign: 'right', datafield: 'y_max_temperature' }, |
1318 { text: 'Max.', editable: false, width: 70, align: 'right', cellsalign: 'right', datafield: 'y_max_temperature' }, |
1271 { text: 'Attn.', editable: false, width: 70, align: 'right', cellsalign: 'right', datafield: 'y_attenuation', cellsformat: 'f1' }, |
1319 { text: 'Attn.', editable: false, width: 70, align: 'right', cellsalign: 'right', datafield: 'y_attenuation', cellsformat: 'f1' }, |
1272 { text: 'Voor', editable: false, width: 80, align: 'center', cellsalign: 'center', datafield: 'y_use' }, |
1320 { text: 'Voor', width: 100, align: 'center', cellsalign: 'center', datafield: 'y_use', columntype: 'dropdownlist', |
1273 { text: 'Hoeveel', datafield: 'y_amount', width: 110, align: 'right', cellsalign: 'right', cellsformat: 'f5', |
1321 createeditor: function (row, column, editor) { |
1274 columntype: 'numberinput', |
1322 var srcYUse = [ "Primary", "Secondary", "Bottle" ]; |
|
1323 editor.jqxDropDownList({ autoDropDownHeight: true, source: srcYUse }); |
|
1324 } |
|
1325 }, |
|
1326 { datafield: 'y_amount', width: 90 }, |
|
1327 { text: 'Hoeveel', datafield: 'amount', width: 110, align: 'right', cellsalign: 'right', columntype: 'numberinput', |
|
1328 cellsrenderer: function (index, datafield, value, defaultvalue, column, rowdata) { |
|
1329 if (rowdata.y_form == 'Liquid') { |
|
1330 var hoeveel = rowdata.y_amount * 17; |
|
1331 return "<div style='margin: 4px;' class='jqx-right-align'>"+dataAdapter.formatNumber(hoeveel, "f0")+" pk</div>"; |
|
1332 } else if (rowdata.y_form == 'Dry') { |
|
1333 var hoeveel = rowdata.y_amount * 1000; |
|
1334 return "<div style='margin: 4px;' class='jqx-right-align'>"+dataAdapter.formatNumber(hoeveel, "f1")+" gr</div>"; |
|
1335 } else { |
|
1336 var hoeveel = rowdata.y_amount * 1000; |
|
1337 return "<div style='margin: 4px;' class='jqx-right-align'>"+dataAdapter.formatNumber(hoeveel, "f0")+" ml</div>"; |
|
1338 } |
|
1339 }, |
|
1340 initeditor: function (row, cellvalue, editor, celltext, pressedChar) { |
|
1341 var form = $("#yeastGrid").jqxGrid('getcellvalue', args.rowindex, 'y_form'); |
|
1342 if (form == 'Liquid') { |
|
1343 editor.jqxNumberInput({ decimalDigits: 0, min: 0 }); |
|
1344 } else { |
|
1345 editor.jqxNumberInput({ decimalDigits: 1, min: 0 }); |
|
1346 } |
|
1347 }, |
1275 validation: function (cell, value) { |
1348 validation: function (cell, value) { |
1276 if (value < 0 || value > 100000000000 ) { |
1349 if (value < 0 || value > 100000000000 ) { |
1277 return { result: false, message: "Volume moet 0-~ zijn" }; |
1350 return { result: false, message: "Volume moet 0-~ zijn" }; |
1278 } |
1351 } |
1279 return true; |
1352 return true; |
1280 } |
1353 } |
1281 } |
1354 } |
1282 ] |
1355 ] |
1283 }) |
1356 }); |
|
1357 $("#yeastGrid").on('cellendedit', function (event) { |
|
1358 var args = event.args; |
|
1359 console.log("Event Type: cellendedit, Column: " + args.datafield + ", Row: " + (args.rowindex) + ", Value: " + args.value); |
|
1360 if (args.datafield == 'amount') { |
|
1361 var form = $("#yeastGrid").jqxGrid('getcellvalue', args.rowindex, 'y_form'); |
|
1362 if (form == 'Liquid') |
|
1363 $("#yeastGrid").jqxGrid('setcellvalue', args.rowindex, 'y_amount', parseFloat(args.value * 0.0588)); |
|
1364 else |
|
1365 $("#yeastGrid").jqxGrid('setcellvalue', args.rowindex, 'y_amount', parseFloat(args.value / 1000)); |
|
1366 } else { |
|
1367 $("#yeastGrid").jqxGrid('setcellvalue', args.rowindex, args.datafield, args.value); |
|
1368 } |
|
1369 }); |
1284 }; |
1370 }; |
1285 |
1371 |
1286 // Inline waters editor |
1372 // Inline waters editor |
1287 var editWater = function (data) { |
1373 var editWater = function (data) { |
1288 var waterSource = { |
1374 var waterSource = { |