946 }, |
946 }, |
947 ready: function() { |
947 ready: function() { |
948 $('#jqxTabs').jqxTabs('next'); |
948 $('#jqxTabs').jqxTabs('next'); |
949 }, |
949 }, |
950 columns: [ |
950 columns: [ |
951 { text: 'Hop', editable: false, datafield: 'h_name' }, |
951 { text: 'Hop', editable: false, datafield: 'h_name', |
|
952 cellsrenderer: function (row, columnfield, value, defaulthtml, columnproperties) { |
|
953 var rowData = $("#hopGrid").jqxGrid('getrowdata', row); |
|
954 return "<span style='margin: 3px; margin-top: 6px; float: "+ |
|
955 columnproperties.cellsalign+"'>" +rowData.h_origin+" / "+rowData.h_name+"</span>"; |
|
956 }, |
|
957 }, |
952 { text: 'Type', editable: false, width: 90, align: 'center', cellsalign: 'center', datafield: 'h_type' }, |
958 { text: 'Type', editable: false, width: 90, align: 'center', cellsalign: 'center', datafield: 'h_type' }, |
953 { text: 'Vorm', editable: false, width: 90, align: 'center', cellsalign: 'center', datafield: 'h_form' }, |
959 { text: 'Vorm', editable: false, width: 90, align: 'center', cellsalign: 'center', datafield: 'h_form' }, |
954 { text: 'Alpha', editable: false, datafield: 'h_alpha', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'p1' }, |
960 { text: 'Alpha', editable: false, datafield: 'h_alpha', width: 80, align: 'right', cellsalign: 'right', cellsformat: 'p1' }, |
955 { text: 'Amount', hidden: true, datafield: 'h_amount' }, |
961 { text: 'Amount', hidden: true, datafield: 'h_amount' }, |
956 { text: 'Gewicht gr', datafield: 'h_weight', width: 120, align: 'right', cellsalign: 'right', |
962 { text: 'Gewicht gr', datafield: 'h_weight', width: 120, align: 'right', cellsalign: 'right', |
1050 { name: 'm_amount', type: 'float' }, |
1056 { name: 'm_amount', type: 'float' }, |
1051 { name: 'm_cost', type: 'float' }, |
1057 { name: 'm_cost', type: 'float' }, |
1052 { name: 'm_type', type: 'string' }, |
1058 { name: 'm_type', type: 'string' }, |
1053 { name: 'm_use_use', type: 'string' }, |
1059 { name: 'm_use_use', type: 'string' }, |
1054 { name: 'm_time', type: 'float' }, |
1060 { name: 'm_time', type: 'float' }, |
1055 { name: 'm_amount_is_weight', type: 'bool' } |
1061 { name: 'm_amount_is_weight', type: 'bool' }, |
|
1062 { name: 'm_weight', type: 'float' } |
1056 ], |
1063 ], |
1057 addrow: function (rowid, rowdata, position, commit) { |
1064 addrow: function (rowid, rowdata, position, commit) { |
1058 commit(true); |
1065 commit(true); |
1059 }, |
1066 }, |
1060 deleterow: function (rowid, commit) { |
1067 deleterow: function (rowid, commit) { |
1061 commit(true); |
1068 commit(true); |
1062 } |
1069 } |
1063 }; |
1070 }; |
1064 var miscAdapter = new $.jqx.dataAdapter(miscSource); |
1071 var miscAdapter = new $.jqx.dataAdapter(miscSource, { |
|
1072 beforeLoadComplete: function (records) { |
|
1073 var data = new Array(); |
|
1074 for (var i = 0; i < records.length; i++) { |
|
1075 var row = records[i]; |
|
1076 row.m_weight = row.m_amount * 1000; |
|
1077 data.push(row); |
|
1078 } |
|
1079 return data; |
|
1080 }, |
|
1081 loadError: function(jqXHR, status, error) { |
|
1082 $('#err').text(status + ' ' + error); |
|
1083 }, |
|
1084 }); |
1065 // dropdownlist datasource from inventory_miscs |
1085 // dropdownlist datasource from inventory_miscs |
1066 var miscUrl = "getmiscsources.php"; |
1086 var miscUrl = "getmiscsources.php"; |
1067 var miscInvSource = { |
1087 var miscInvSource = { |
1068 datatype: "json", |
1088 datatype: "json", |
1069 datafields: [ |
1089 datafields: [ |
1144 editor.jqxDropDownList({ autoDropDownHeight: true, source: srcUseUse }); |
1165 editor.jqxDropDownList({ autoDropDownHeight: true, source: srcUseUse }); |
1145 } |
1166 } |
1146 }, |
1167 }, |
1147 { datafield: 'm_amount_is_weight', hidden: true }, // We need to declare this column |
1168 { datafield: 'm_amount_is_weight', hidden: true }, // We need to declare this column |
1148 { datafield: 'm_amount', hidden: true }, // We need to declare this column |
1169 { datafield: 'm_amount', hidden: true }, // We need to declare this column |
1149 { text: 'Hoeveelheid', datafield: 'grammen', width: 120, align: 'right', cellsalign: 'right', cellsformat: 'f2', |
1170 { text: 'Hoeveelheid', datafield: 'm_weight', width: 120, align: 'right', cellsalign: 'right', cellsformat: 'f2', |
1150 columntype: 'numberinput', |
1171 columntype: 'numberinput', |
1151 cellsrenderer: function (index, datafield, value, defaultvalue, column, rowdata) { |
1172 cellsrenderer: function (index, datafield, value, defaultvalue, column, rowdata) { |
1152 var gram = rowdata.m_amount * 1000; |
|
1153 var vstr = rowdata.m_amount_is_weight ? "gr":"ml"; |
1173 var vstr = rowdata.m_amount_is_weight ? "gr":"ml"; |
1154 return "<div style='margin: 4px;' class='jqx-right-align'>"+dataAdapter.formatNumber(gram,"f2")+" "+vstr+"</div>"; |
1174 return "<div style='margin: 4px;' class='jqx-right-align'>"+dataAdapter.formatNumber(value,"f2")+" "+vstr+"</div>"; |
1155 }, |
1175 }, |
1156 validation: function (cell, value) { |
1176 validation: function (cell, value) { |
1157 var high = parseFloat(dataRecord.boil_size) * 1000; |
1177 var high = parseFloat(dataRecord.boil_size) * 1000; |
1158 if (value < 0 || value > high) { |
1178 if (value < 0 || value > high) { |
1159 return { result: false, message: "Hoeveelheid moet tussen 0 en "+high+" zijn" }; |
1179 return { result: false, message: "Hoeveelheid moet tussen 0 en "+high+" zijn" }; |
1160 } |
1180 } |
1161 return true; |
1181 return true; |
1162 }, |
1182 }, |
1163 initeditor: function (row, cellvalue, editor) { |
1183 initeditor: function (row, cellvalue, editor) { |
1164 editor.jqxNumberInput({ inputMode: 'simple', min: 0, decimalDigits: 2, spinButtons: false }); |
1184 editor.jqxNumberInput({ |
|
1185 inputMode: 'simple', min: 0, max: parseFloat(dataRecord.boil_size) * 1000, |
|
1186 decimalDigits: 2, spinButtons: false |
|
1187 }); |
1165 } |
1188 } |
1166 }, |
1189 }, |
1167 { datafield: 'm_time' }, |
1190 { text: 'Tijd', datafield: 'm_time', width: 70, align: 'right', cellsalign: 'right', cellsformat: 'f0', |
1168 { text: 'Tijd', datafield: 'time', width: 70, align: 'right', cellsalign: 'right', cellsformat: 'f0', |
|
1169 columntype: 'numberinput', |
1191 columntype: 'numberinput', |
1170 cellsrenderer: function (index, datafield, value, defaultvalue, column, rowdata) { |
1192 cellsrenderer: function (index, datafield, value, defaultvalue, column, rowdata) { |
1171 if (rowdata.m_use_use == 'Boil') { |
1193 if (rowdata.m_use_use == 'Boil') { |
1172 var tijd = rowdata.m_time; |
1194 return "<div style='margin: 4px;' class='jqx-right-align'>"+dataAdapter.formatNumber(value, "f0")+" m</div>"; |
1173 return "<div style='margin: 4px;' class='jqx-right-align'>"+dataAdapter.formatNumber(tijd, "f0")+" m</div>"; |
|
1174 } else if (rowdata.m_use_use == 'Secondary') { |
1195 } else if (rowdata.m_use_use == 'Secondary') { |
1175 var tijd = Math.round(rowdata.m_time / 1440); |
1196 return "<div style='margin: 4px;' class='jqx-right-align'>"+dataAdapter.formatNumber(value, "f0")+" d</div>"; |
1176 return "<div style='margin: 4px;' class='jqx-right-align'>"+dataAdapter.formatNumber(tijd, "f0")+" d</div>"; |
|
1177 } else { |
1197 } else { |
1178 var tijd = 0; |
1198 var tijd = 0; |
1179 return "<div style='margin: 4px;' class='jqx-right-align'> </div>"; |
1199 return "<div style='margin: 4px;' class='jqx-right-align'> </div>"; |
1180 } |
1200 } |
1181 }, |
1201 }, |
1182 initeditor: function (row, cellvalue, editor, celltext, pressedChar) { |
1202 initeditor: function (row, cellvalue, editor, celltext, pressedChar) { |
1183 editor.jqxNumberInput({ decimalDigits: 0, digits: 3, min: 0, max: parseFloat(dataRecord.boil_time) }); |
1203 editor.jqxNumberInput({ decimalDigits: 0, digits: 3, min: 0, max: parseFloat(dataRecord.boil_time) }); |
1184 }, |
1204 }, |
1185 cellvaluechanging: function (row, column, columntype, oldvalue, newvalue) { |
1205 cellvaluechanging: function (row, column, columntype, oldvalue, newvalue) { |
1186 var use = $("#miscGrid").jqxGrid('getcellvalue', row, "m_use_use"); |
1206 var use = $("#miscGrid").jqxGrid('getcellvalue', row, "m_use_use"); |
1187 if (use != "Boil") |
1207 if ((use != "Boil") && (use != "Secondary")) |
1188 return oldvalue; |
1208 return oldvalue; |
1189 }, |
1209 }, |
1190 validation: function (cell, value) { |
1210 validation: function (cell, value) { |
1191 var high = parseFloat(dataRecord.boil_time); |
1211 var high = parseFloat(dataRecord.boil_time); |
1192 if (value < 0 || value > high ) { |
1212 if (value < 0 || value > high ) { |
1198 ] |
1218 ] |
1199 }); |
1219 }); |
1200 $("#miscGrid").on('cellendedit', function (event) { |
1220 $("#miscGrid").on('cellendedit', function (event) { |
1201 var args = event.args; |
1221 var args = event.args; |
1202 console.log("Event Type: cellendedit, Column: " + args.datafield + ", Row: " + (args.rowindex) + ", Value: " + args.value); |
1222 console.log("Event Type: cellendedit, Column: " + args.datafield + ", Row: " + (args.rowindex) + ", Value: " + args.value); |
1203 if (args.datafield == 'grammen') { |
1223 $("#miscGrid").jqxGrid('setcellvalue', args.rowindex, args.datafield, args.value); |
1204 $("#miscGrid").jqxGrid('setcellvalue', args.rowindex, 'm_amount', parseFloat(args.value / 1000)); |
1224 if (args.datafield == 'm_weight') { |
1205 } else if (args.datafield == 'time') { |
1225 $("#miscGrid").jqxGrid('setcellvalue', args.rowindex, 'm_amount', parseFloat(args.value) / 1000); |
1206 var use_use = $("#miscGrid").jqxGrid('getcellvalue', args.rowindex, 'm_use_use'); |
|
1207 console.log("use: "+use_use); |
|
1208 if (use_use == 'Secondary') |
|
1209 $("#miscGrid").jqxGrid('setcellvalue', args.rowindex, 'm_time', parseFloat(args.value * 1440)); |
|
1210 else |
|
1211 $("#miscGrid").jqxGrid('setcellvalue', args.rowindex, 'm_time', parseFloat(args.value)); |
|
1212 } else { |
|
1213 $("#miscGrid").jqxGrid('setcellvalue', args.rowindex, args.datafield, args.value); |
|
1214 } |
1226 } |
1215 }); |
1227 }); |
1216 }; |
1228 }; |
1217 |
1229 |
1218 // Inline yeasts editor |
1230 // Inline yeasts editor |