2029 { name: 'y_product_id', type: 'string' }, |
2029 { name: 'y_product_id', type: 'string' }, |
2030 { name: 'y_amount', type: 'float' }, |
2030 { name: 'y_amount', type: 'float' }, |
2031 { name: 'y_cost', type: 'float' }, |
2031 { name: 'y_cost', type: 'float' }, |
2032 { name: 'y_type', type: 'int' }, |
2032 { name: 'y_type', type: 'int' }, |
2033 { name: 'y_form', type: 'int' }, |
2033 { name: 'y_form', type: 'int' }, |
2034 { name: 'y_time', type: 'float' }, |
2034 { name: 'y_flocculation', type: 'int' }, |
2035 { name: 'y_min_temperature', type: 'float' }, |
2035 { name: 'y_min_temperature', type: 'float' }, |
2036 { name: 'y_max_temperature', type: 'float' }, |
2036 { name: 'y_max_temperature', type: 'float' }, |
2037 { name: 'y_attenuation', type: 'float' }, |
2037 { name: 'y_attenuation', type: 'float' }, |
2038 { name: 'y_amount_is_weight', type: 'int' }, |
|
2039 { name: 'y_use', type: 'int' }, |
2038 { name: 'y_use', type: 'int' }, |
2040 { name: 'y_weight', type: 'float' } |
2039 { name: 'y_cells', type: 'float' }, |
|
2040 { name: 'y_inventory', type: 'float' }, |
|
2041 { name: 'y_avail', type: 'int' } |
2041 ], |
2042 ], |
2042 addrow: function (rowid, rowdata, position, commit) { |
2043 addrow: function (rowid, rowdata, position, commit) { |
2043 commit(true); |
2044 commit(true); |
2044 }, |
2045 }, |
2045 deleterow: function (rowid, commit) { |
2046 deleterow: function (rowid, commit) { |
2046 commit(true); |
2047 commit(true); |
2047 } |
2048 } |
2048 }; |
2049 }; |
2049 var yeastAdapter = new $.jqx.dataAdapter(yeastSource, { |
2050 var yeastAdapter = new $.jqx.dataAdapter(yeastSource); |
2050 beforeLoadComplete: function (records) { |
|
2051 var data = new Array(); |
|
2052 for (var i = 0; i < records.length; i++) { |
|
2053 var row = records[i]; |
|
2054 if (row.y_form == 'Liquid') |
|
2055 row.y_weight = Math.round(row.y_amount * 17); |
|
2056 else |
|
2057 row.y_weight = row.y_amount * 1000; |
|
2058 data.push(row); |
|
2059 } |
|
2060 return data; |
|
2061 }, |
|
2062 loadError: function(jqXHR, status, error) { |
|
2063 $('#err').text(status + ' ' + error); |
|
2064 }, |
|
2065 }); |
|
2066 $("#yeastGrid").jqxGrid({ |
2051 $("#yeastGrid").jqxGrid({ |
2067 width: 1050, |
2052 width: 1240, |
2068 height: 300, |
2053 height: 525, |
2069 source: yeastAdapter, |
2054 source: yeastAdapter, |
2070 theme: theme, |
2055 theme: theme, |
2071 selectionmode: 'singlerow', |
2056 selectionmode: 'singlerow', |
2072 editmode: 'selectedcell', |
|
2073 editable: true, |
|
2074 localization: getLocalization(), |
2057 localization: getLocalization(), |
2075 showtoolbar: true, |
2058 showtoolbar: true, |
2076 rendertoolbar: function (toolbar) { |
2059 rendertoolbar: function (toolbar) { |
2077 var me = this; |
2060 var me = this; |
2078 var container = $("<div style='overflow: hidden; position: relative; margin: 5px;'></div>"); |
2061 var container = $("<div style='overflow: hidden; position: relative; margin: 5px;'></div>"); |
2079 toolbar.append(container); |
2062 toolbar.append(container); |
2080 container.append('<div style="float: left; margin-left: 165px;" id="yaddrowbutton"></div>'); |
2063 container.append('<div style="float: left; margin-left: 165px;" id="yaddrowbutton"></div>'); |
2081 container.append('<div style="float: left; margin-left: 10px; margin-top: 5px;">In voorraad:</div>'); |
2064 container.append('<div style="float: left; margin-left: 10px; margin-top: 5px;">In voorraad:</div>'); |
2082 container.append('<div style="float: left; margin-left: 10px;" id="yinstockbutton"></div>'); |
2065 container.append('<div style="float: left; margin-left: 10px;" id="yinstockbutton"></div>'); |
2083 container.append('<input style="float: left; margin-left: 230px;" id="ydeleterowbutton" type="button" value="Verwijder gist" />'); |
2066 container.append('<input style="float: left; margin-left: 400px;" id="ydeleterowbutton" type="button" value="Verwijder gist" />'); |
2084 // add yeast from dropdownlist. |
2067 // add yeast from dropdownlist. |
2085 $("#yaddrowbutton").jqxDropDownList({ |
2068 $("#yaddrowbutton").jqxDropDownList({ |
2086 placeHolder: "Kies gist:", |
2069 placeHolder: "Kies gist:", |
2087 theme: theme, |
2070 theme: theme, |
|
2071 template: "primary", |
2088 source: yeastlist, |
2072 source: yeastlist, |
2089 displayMember: "name", |
2073 displayMember: "name", |
2090 width: 150, |
2074 width: 150, |
2091 height: 27, |
2075 height: 27, |
2092 dropDownWidth: 500, |
2076 dropDownWidth: 500, |
2107 row["y_type"] = datarecord.type; |
2091 row["y_type"] = datarecord.type; |
2108 row["y_form"] = datarecord.form; |
2092 row["y_form"] = datarecord.form; |
2109 row["y_amount"] = 0; |
2093 row["y_amount"] = 0; |
2110 row["y_cost"] = datarecord.cost; |
2094 row["y_cost"] = datarecord.cost; |
2111 row["y_use"] = 0; |
2095 row["y_use"] = 0; |
2112 row["y_time"] = 0; |
|
2113 if (datarecord.form == 1) { |
|
2114 row["y_amount_is_weight"] = 1; |
|
2115 } else { |
|
2116 row["y_amount_is_weight"] = 0; |
|
2117 } |
|
2118 row["y_min_temperature"] = datarecord.min_temperature; |
2096 row["y_min_temperature"] = datarecord.min_temperature; |
2119 row["y_max_temperature"] = datarecord.max_temperature; |
2097 row["y_max_temperature"] = datarecord.max_temperature; |
2120 row["y_attenuation"] = datarecord.attenuation; |
2098 row["y_attenuation"] = datarecord.attenuation; |
2121 row["y_weight"] = 0; |
2099 row["y_flocculation"] = datarecord.flocculation; |
|
2100 row["y_cells"] = datarecord.cells; |
|
2101 row["y_inventory"] = datarecord.inventory; |
2122 var commit = $("#yeastGrid").jqxGrid('addrow', null, row); |
2102 var commit = $("#yeastGrid").jqxGrid('addrow', null, row); |
2123 } |
2103 } |
2124 }); |
2104 }); |
2125 $("#yinstockbutton").jqxCheckBox({ theme: theme, height: 27 }); |
2105 $("#yinstockbutton").jqxCheckBox({ theme: theme, height: 27 }); |
2126 $("#yinstockbutton").on('change', function (event) { |
2106 $("#yinstockbutton").on('change', function (event) { |
2127 yeastinstock = event.args.checked; |
2107 yeastinstock = event.args.checked; |
2128 yeastlist.dataBind(); |
2108 yeastlist.dataBind(); |
2129 }); |
2109 }); |
2130 // delete selected yeast. |
2110 // delete selected yeast. |
2131 $("#ydeleterowbutton").jqxButton({ theme: theme, height: 27, width: 150 }); |
2111 $("#ydeleterowbutton").jqxButton({ template: "danger", theme: theme, height: 27, width: 150 }); |
2132 $("#ydeleterowbutton").on('click', function () { |
2112 $("#ydeleterowbutton").on('click', function () { |
2133 var selectedrowindex = $("#yeastGrid").jqxGrid('getselectedrowindex'); |
2113 var selectedrowindex = $("#yeastGrid").jqxGrid('getselectedrowindex'); |
2134 var rowscount = $("#yeastGrid").jqxGrid('getdatainformation').rowscount; |
2114 var rowscount = $("#yeastGrid").jqxGrid('getdatainformation').rowscount; |
2135 if (selectedrowindex >= 0 && selectedrowindex < rowscount) { |
2115 if (selectedrowindex >= 0 && selectedrowindex < rowscount) { |
2136 var id = $("#yeastGrid").jqxGrid('getrowid', selectedrowindex); |
2116 var id = $("#yeastGrid").jqxGrid('getrowid', selectedrowindex); |
2141 ready: function() { |
2121 ready: function() { |
2142 calcSVG(); |
2122 calcSVG(); |
2143 $('#jqxTabs').jqxTabs('next'); |
2123 $('#jqxTabs').jqxTabs('next'); |
2144 }, |
2124 }, |
2145 columns: [ |
2125 columns: [ |
2146 { text: 'Gist', editable: false, datafield: 'y_name' }, |
2126 { text: 'Gist', datafield: 'y_name' }, |
2147 { text: 'Laboratorium', editable: false, width: 150, datafield: 'y_laboratory' }, |
2127 { text: 'Laboratorium', width: 150, datafield: 'y_laboratory' }, |
2148 { text: 'Code', editable: false, width: 90, datafield: 'y_product_id' }, |
2128 { text: 'Code', width: 90, datafield: 'y_product_id' }, |
2149 { text: 'Soort', editable: false, width: 80, align: 'center', cellsalign: 'center', datafield: 'y_form' }, |
2129 { text: 'Soort', width: 100, datafield: 'y_form', |
2150 { text: 'Min.', editable: false, width: 70, align: 'right', cellsalign: 'right', datafield: 'y_min_temperature' }, |
2130 cellsrenderer: function (index, datafield, value, defaultvalue, column, rowdata) { |
2151 { text: 'Max.', editable: false, width: 70, align: 'right', cellsalign: 'right', datafield: 'y_max_temperature' }, |
2131 return "<div style='margin: 4px;'>" + YeastFormData[value].nl + "</div>"; |
2152 { text: 'Attn.', editable: false, width: 70, align: 'right', cellsalign: 'right', datafield: 'y_attenuation', cellsformat: 'f1' }, |
|
2153 { text: 'Voor', width: 100, align: 'center', cellsalign: 'center', datafield: 'y_use', columntype: 'dropdownlist', |
|
2154 createeditor: function (row, column, editor) { |
|
2155 var srcYUse = [ "Primary", "Secondary", "Bottle" ]; |
|
2156 editor.jqxDropDownList({ autoDropDownHeight: true, source: srcYUse }); |
|
2157 } |
2132 } |
2158 }, |
2133 }, |
2159 { datafield: 'y_amount', width: 90 }, |
2134 { text: 'Min. °C', width: 70, align: 'right', cellsalign: 'right', datafield: 'y_min_temperature' }, |
2160 { text: 'Hoeveel', datafield: 'y_weight', width: 110, align: 'right', cellsalign: 'right', |
2135 { text: 'Max. °C', width: 70, align: 'right', cellsalign: 'right', datafield: 'y_max_temperature' }, |
2161 cellsformat: 'f1', columntype: 'numberinput', |
2136 { text: 'Attn. %', width: 70, align: 'right', cellsalign: 'right', datafield: 'y_attenuation', cellsformat: 'f1' }, |
|
2137 { text: 'Voor', width: 120, datafield: 'y_use', |
2162 cellsrenderer: function (index, datafield, value, defaultvalue, column, rowdata) { |
2138 cellsrenderer: function (index, datafield, value, defaultvalue, column, rowdata) { |
2163 if (rowdata.y_form == 'Liquid') { |
2139 return "<div style='margin: 4px;'>" + YeastUseData[value].nl + "</div>"; |
|
2140 } |
|
2141 }, |
|
2142 { text: 'Hoeveel', datafield: 'y_amount', width: 100, align: 'right', |
|
2143 cellsrenderer: function (index, datafield, value, defaultvalue, column, rowdata) { |
|
2144 if (rowdata.y_form == 0) { // Liquid |
2164 return "<div style='margin: 4px;' class='jqx-right-align'>"+dataAdapter.formatNumber(value, "f0")+" pk</div>"; |
2145 return "<div style='margin: 4px;' class='jqx-right-align'>"+dataAdapter.formatNumber(value, "f0")+" pk</div>"; |
2165 } else if (rowdata.y_form == 'Dry') { |
2146 } else if (rowdata.y_form == 1) { // Dry |
2166 return "<div style='margin: 4px;' class='jqx-right-align'>"+dataAdapter.formatNumber(value, "f1")+" gr</div>"; |
2147 return "<div style='margin: 4px;' class='jqx-right-align'>"+dataAdapter.formatNumber(value*1000, "f1")+" gr</div>"; |
2167 } else { |
2148 } else { |
2168 return "<div style='margin: 4px;' class='jqx-right-align'>"+dataAdapter.formatNumber(value, "f0")+" ml</div>"; |
2149 return "<div style='margin: 4px;' class='jqx-right-align'>"+dataAdapter.formatNumber(value*1000, "f0")+" ml</div>"; |
2169 } |
2150 } |
2170 }, |
2151 } |
2171 initeditor: function (row, cellvalue, editor, celltext, pressedChar) { |
2152 }, |
2172 var form = $("#yeastGrid").jqxGrid('getcellvalue', args.rowindex, 'y_form'); |
2153 { text: 'Voorraad', datafield: 'y_inventory', width: 100, align: 'right', |
2173 if (form == 'Dry') { |
2154 cellsrenderer: function (index, datafield, value, defaultvalue, column, rowdata) { |
2174 editor.jqxNumberInput({ decimalDigits: 1, min: 0, spinButtons: false }); |
2155 if (rowdata.y_form == 0) { // Liquid |
|
2156 return "<div style='margin: 4px;' class='jqx-right-align'>"+dataAdapter.formatNumber(value, "f0")+" pk</div>"; |
|
2157 } else if (rowdata.y_form == 1) { // Dry |
|
2158 return "<div style='margin: 4px;' class='jqx-right-align'>"+dataAdapter.formatNumber(value*1000, "f1")+" gr</div>"; |
2175 } else { |
2159 } else { |
2176 editor.jqxNumberInput({ decimalDigits: 0, min: 0, spinButtons: false }); |
2160 return "<div style='margin: 4px;' class='jqx-right-align'>"+dataAdapter.formatNumber(value*1000, "f0")+" ml</div>"; |
2177 } |
2161 } |
2178 }, |
2162 } |
2179 validation: function (cell, value) { |
2163 }, |
2180 if (value < 0 || value > 100000000000 ) { |
2164 { text: 'Wijzig', datafield: 'Edit', columntype: 'button', width: 100, align: 'center', cellsrenderer: function () { |
2181 return { result: false, message: "Hoeveelheid moet 0-~ zijn" }; |
2165 return "Wijzig"; |
2182 } |
2166 }, buttonclick: function (row) { |
2183 return true; |
2167 yeastRow = row; |
2184 } |
2168 yeastData = $("#yeastGrid").jqxGrid('getrowdata', yeastRow); |
2185 } |
2169 if (yeastData.y_form == 0) { |
|
2170 $("#wy_pmpt_amount").html("Pak(ken):"); |
|
2171 $("#wy_amount").val(yeastData.y_amount); |
|
2172 $("#wy_amount").jqxNumberInput({ decimalDigits: 0, spinButtonsStep: 1 }); |
|
2173 } else if (yeastData.y_form == 1) { |
|
2174 $("#wy_pmpt_amount").html("Gewicht gram:"); |
|
2175 $("#wy_amount").val(yeastData.y_amount * 1000); |
|
2176 $("#wy_amount").jqxNumberInput({ decimalDigits: 1, spinButtonsStep: 0.5 }); |
|
2177 } else { |
|
2178 $("#wy_pmpt_amount").html("Volume ml:"); |
|
2179 $("#wy_amount").val(yeastData.y_amount * 1000); |
|
2180 $("#wy_amount").jqxNumberInput({ decimalDigits: 0, spinButtonsStep: 1 }); |
|
2181 } |
|
2182 $("#wy_name").val(yeastData.y_name); |
|
2183 $("#wy_laboratory").val(yeastData.y_laboratory); |
|
2184 $("#wy_product_id").val(yeastData.y_product_id); |
|
2185 $("#wy_use").val(yeastData.y_use); |
|
2186 // show the popup window. |
|
2187 $("#popupYeast").jqxWindow('open'); |
|
2188 } |
|
2189 } |
2186 ] |
2190 ] |
2187 }); |
2191 }); |
2188 $("#yeastGrid").on('cellendedit', function (event) { |
2192 // $("#yeastGrid").jqxGrid('setcellvalue', args.rowindex, 'y_amount', parseFloat(args.value * 0.0588)); |
2189 var args = event.args; |
|
2190 console.log("Event Type: cellendedit, Column: " + args.datafield + ", Row: " + (args.rowindex) + ", Value: " + args.value); |
|
2191 $("#yeastGrid").jqxGrid('setcellvalue', args.rowindex, args.datafield, args.value); |
|
2192 if (args.datafield == 'y_weight') { |
|
2193 var form = $("#yeastGrid").jqxGrid('getcellvalue', args.rowindex, 'y_form'); |
|
2194 if (form == 'Liquid') |
|
2195 $("#yeastGrid").jqxGrid('setcellvalue', args.rowindex, 'y_amount', parseFloat(args.value * 0.0588)); |
|
2196 else |
|
2197 $("#yeastGrid").jqxGrid('setcellvalue', args.rowindex, 'y_amount', parseFloat(args.value / 1000)); |
|
2198 } |
|
2199 }); |
|
2200 }; |
2193 }; |
2201 |
2194 |
2202 // inline mash editor |
2195 // inline mash editor |
2203 var editMash = function (data) { |
2196 var editMash = function (data) { |
2204 var generaterow = function () { |
2197 var generaterow = function () { |
2877 } |
2870 } |
2878 } |
2871 } |
2879 }); |
2872 }); |
2880 |
2873 |
2881 // Tab 5, Gist |
2874 // Tab 5, Gist |
|
2875 $("#popupYeast").jqxWindow({ |
|
2876 width: 800, |
|
2877 height: 300, |
|
2878 position: { x: 230, y: 100 }, |
|
2879 resizable: false, |
|
2880 theme: theme, |
|
2881 isModal: true, |
|
2882 autoOpen: false, |
|
2883 cancelButton: $("#YeastReady"), |
|
2884 modalOpacity: 0.40 |
|
2885 }); |
|
2886 $("#YeastReady").jqxButton({ template: "success", width: '90px', theme: theme }); |
|
2887 $("#YeastReady").click(function () { |
|
2888 $("#yeastGrid").jqxGrid('sortby', 'y_use', 'asc'); |
|
2889 }); |
|
2890 $("#wy_name").jqxInput({ theme: theme, width: 320, height: 23 }); |
|
2891 $("#wy_laboratory").jqxInput({ theme: theme, width: 320, height: 23 }); |
|
2892 $("#wy_product_id").jqxInput({ theme: theme, width: 320, height: 23 }); |
|
2893 $("#wy_instock").jqxCheckBox({ theme: theme, height: 23 }); |
|
2894 $("#wy_instock").on('change', function (event) { |
|
2895 yeastinstock = event.args.checked; |
|
2896 yeastlist.dataBind(); |
|
2897 }); |
|
2898 $("#wy_select").jqxDropDownList({ |
|
2899 placeHolder: "Kies gist:", |
|
2900 theme: theme, |
|
2901 source: yeastlist, |
|
2902 displayMember: "name", |
|
2903 width: 150, |
|
2904 height: 23, |
|
2905 dropDownWidth: 500, |
|
2906 dropDownHeight: 500, |
|
2907 renderer: function (index, label, value) { |
|
2908 var datarecord = yeastlist.records[index]; |
|
2909 return datarecord.laboratory+" "+datarecord.product_id+" "+datarecord.name; |
|
2910 } |
|
2911 }); |
|
2912 $("#wy_select").on('select', function (event) { |
|
2913 if (event.args) { |
|
2914 var index = event.args.index; |
|
2915 var datarecord = yeastlist.records[index]; |
|
2916 var rowdata = $("#yeastGrid").jqxGrid('getrowdata', yeastRow); |
|
2917 $("#wy_name").val(datarecord.name); |
|
2918 $("#wy_laboratory").val(datarecord.laboratory); |
|
2919 $("#wy_product_id").val(datarecord.product_id); |
|
2920 rowdata.y_name = datarecord.name; |
|
2921 rowdata.y_cost = datarecord.cost; |
|
2922 rowdata.y_type = datarecord.type; |
|
2923 rowdata.y_form = datarecord.form; |
|
2924 rowdata.y_laboratory = datarecord.laboratory; |
|
2925 rowdata.y_product_id = datarecord.product_id; |
|
2926 rowdata.y_min_temperature = datarecord.min_temperature; |
|
2927 rowdata.y_max_temperature = datarecord.max_temperature; |
|
2928 rowdata.y_flocculation = datarecord.flocculation; |
|
2929 rowdata.y_attenuation = datarecord.attenuation; |
|
2930 rowdata.y_cells = datarecord.cells; |
|
2931 rowdata.y_inventory = datarecord.inventory; |
|
2932 if (rowdata.y_form == 0) { |
|
2933 $("#wy_pmpt_amount").html("Pak(ken):"); |
|
2934 } else if (rowdata.y_form == 1) { |
|
2935 $("#wy_pmpt_amount").html("Gewicht gram:"); |
|
2936 } else { |
|
2937 $("#wy_pmpt_amount").html("Volume ml:"); |
|
2938 } |
|
2939 } |
|
2940 }); |
|
2941 $("#wy_amount").jqxNumberInput( Spin1dec5 ); |
|
2942 $('#wy_amount').on('change', function (event) { |
|
2943 console.log("amount changed: "+event.args.value); |
|
2944 var rowdata = $("#yeastGrid").jqxGrid('getrowdata', yeastRow); |
|
2945 if (rowdata.y_form == 0) // Liquid |
|
2946 var amount = parseFloat(event.args.value); |
|
2947 else |
|
2948 var amount = parseFloat(event.args.value) / 1000; |
|
2949 rowdata.y_amount = amount; |
|
2950 }); |
|
2951 $("#wy_use").jqxDropDownList({ |
|
2952 theme: theme, |
|
2953 source: YeastUseAdapter, |
|
2954 valueMember: 'id', |
|
2955 displayMember: 'nl', |
|
2956 width: 180, |
|
2957 height: 23, |
|
2958 autoDropDownHeight: true, |
|
2959 dropDownVerticalAlignment: 'top' |
|
2960 }); |
|
2961 $("#wy_use").on('select', function (event) { |
|
2962 if (event.args) { |
|
2963 var index = event.args.index; |
|
2964 var rowdata = $("#yeastGrid").jqxGrid('getrowdata', yeastRow); |
|
2965 rowdata.y_use = index; |
|
2966 } |
|
2967 }); |
2882 |
2968 |
2883 // Tab 6, Maischen |
2969 // Tab 6, Maischen |
2884 $("#mash_name").jqxInput({ theme: theme, width: 320, height: 23 }); |
2970 $("#mash_name").jqxInput({ theme: theme, width: 320, height: 23 }); |
2885 |
2971 |
2886 // Tab 7, Water |
2972 // Tab 7, Water |