www/js/rec_edit.js

changeset 396
804800d8e885
parent 392
544d7d0183b2
child 406
0ad967f2d6ee
equal deleted inserted replaced
395:463d64cce768 396:804800d8e885
1807 { name: 'f_acid_to_ph_57', type: 'float' }, 1807 { name: 'f_acid_to_ph_57', type: 'float' },
1808 { name: 'f_inventory', type: 'float' }, 1808 { name: 'f_inventory', type: 'float' },
1809 { name: 'f_avail', type: 'int' } 1809 { name: 'f_avail', type: 'int' }
1810 ], 1810 ],
1811 addrow: function (rowid, rowdata, position, commit) { 1811 addrow: function (rowid, rowdata, position, commit) {
1812 console.log("fermentable addrow "+rowid);
1812 commit(true); 1813 commit(true);
1813 }, 1814 },
1814 deleterow: function (rowid, commit) { 1815 deleterow: function (rowid, commit) {
1816 console.log("fermentable deleterow "+rowid);
1817 commit(true);
1818 },
1819 updaterow: function (rowid, rowdata, commit) {
1820 console.log("fermentable updaterow "+rowid);
1815 commit(true); 1821 commit(true);
1816 } 1822 }
1817 }; 1823 };
1818 var fermentableAdapter = new $.jqx.dataAdapter(fermentableSource); 1824 var fermentableAdapter = new $.jqx.dataAdapter(fermentableSource);
1819 $("#fermentableGrid").jqxGrid({ 1825 $("#fermentableGrid").jqxGrid({
1820 width: 1240, 1826 width: 1240,
1821 height: 470, 1827 height: 470,
1822 source: fermentableAdapter, 1828 source: fermentableAdapter,
1823 theme: theme, 1829 theme: theme,
1824 sortmode: "many",
1825 selectionmode: 'singlerow', 1830 selectionmode: 'singlerow',
1826 showtoolbar: true, 1831 showtoolbar: true,
1827 rendertoolbar: function (toolbar) { 1832 rendertoolbar: function (toolbar) {
1828 var me = this; 1833 var me = this;
1829 var container = $("<div style='overflow: hidden; position: relative; margin: 5px;'></div>"); 1834 var container = $("<div style='overflow: hidden; position: relative; margin: 5px;'></div>");
1938 calcFermentables(); 1943 calcFermentables();
1939 calcIBUs(); 1944 calcIBUs();
1940 }); 1945 });
1941 }, 1946 },
1942 ready: function() { 1947 ready: function() {
1943 var datainformation = $('#fermentableGrid').jqxGrid('getdatainformation');
1944 if (datainformation.rowscount) {
1945 $("#fermentableGrid").jqxGrid('sortby', 'f_added', 'asc');
1946 $("#fermentableGrid").jqxGrid('sortby', 'f_amount', 'desc');
1947 }
1948 calcFermentables(); 1948 calcFermentables();
1949 $('#jqxTabs').jqxTabs('next'); 1949 $('#jqxTabs').jqxTabs('next');
1950 }, 1950 },
1951 columns: [ 1951 columns: [
1952 { text: 'Vergistbaar ingredi&euml;nt', datafield: 'f_name', 1952 { text: 'Vergistbaar ingredi&euml;nt', datafield: 'f_name',
2032 { name: 'h_total_oil', type: 'float' }, 2032 { name: 'h_total_oil', type: 'float' },
2033 { name: 'h_inventory', type: 'float' }, 2033 { name: 'h_inventory', type: 'float' },
2034 { name: 'h_avail', type: 'int' } 2034 { name: 'h_avail', type: 'int' }
2035 ], 2035 ],
2036 addrow: function (rowid, rowdata, position, commit) { 2036 addrow: function (rowid, rowdata, position, commit) {
2037 console.log("hop addrow "+rowid);
2037 commit(true); 2038 commit(true);
2038 }, 2039 },
2039 deleterow: function (rowid, commit) { 2040 deleterow: function (rowid, commit) {
2041 console.log("hop deleterow "+rowid);
2040 commit(true); 2042 commit(true);
2041 } 2043 },
2044 updaterow: function (rowid, rowdata, commit) {
2045 console.log("hop updaterow "+rowid);
2046 commit(true);
2047 }
2042 }; 2048 };
2043 var hopAdapter = new $.jqx.dataAdapter(hopSource); 2049 var hopAdapter = new $.jqx.dataAdapter(hopSource);
2044 $("#hopGrid").jqxGrid({ 2050 $("#hopGrid").jqxGrid({
2045 width: 1240, 2051 width: 1240,
2046 height: 560, 2052 height: 560,
2047 source: hopAdapter, 2053 source: hopAdapter,
2048 theme: theme, 2054 theme: theme,
2049 sortmode: "many",
2050 selectionmode: 'singlerow', 2055 selectionmode: 'singlerow',
2051 showtoolbar: true, 2056 showtoolbar: true,
2052 rendertoolbar: function (toolbar) { 2057 rendertoolbar: function (toolbar) {
2053 var me = this; 2058 var me = this;
2054 var container = $("<div style='overflow: hidden; position: relative; margin: 5px;'></div>"); 2059 var container = $("<div style='overflow: hidden; position: relative; margin: 5px;'></div>");
2117 } 2122 }
2118 calcIBUs(); 2123 calcIBUs();
2119 }); 2124 });
2120 }, 2125 },
2121 ready: function() { 2126 ready: function() {
2122 var datainformation = $('#hopGrid').jqxGrid('getdatainformation');
2123 if (datainformation.rowscount) {
2124 $("#hopGrid").jqxGrid('sortby', 'h_useat', 'asc');
2125 $("#hopGrid").jqxGrid('sortby', 'h_time', 'desc');
2126 $("#hopGrid").jqxGrid('sortby', 'h_amount', 'desc');
2127 }
2128 calcIBUs(); 2127 calcIBUs();
2129 $('#jqxTabs').jqxTabs('next'); 2128 $('#jqxTabs').jqxTabs('next');
2130 }, 2129 },
2131 columns: [ 2130 columns: [
2132 { text: 'Hop', datafield: 'h_name', 2131 { text: 'Hop', datafield: 'h_name',
2230 { name: 'm_amount_is_weight', type: 'int' }, 2229 { name: 'm_amount_is_weight', type: 'int' },
2231 { name: 'm_inventory', type: 'float' }, 2230 { name: 'm_inventory', type: 'float' },
2232 { name: 'm_avail', type: 'int' } 2231 { name: 'm_avail', type: 'int' }
2233 ], 2232 ],
2234 addrow: function (rowid, rowdata, position, commit) { 2233 addrow: function (rowid, rowdata, position, commit) {
2234 console.log("misc addrow "+rowid);
2235 commit(true); 2235 commit(true);
2236 }, 2236 },
2237 deleterow: function (rowid, commit) { 2237 deleterow: function (rowid, commit) {
2238 console.log("misc deleterow "+rowid);
2238 commit(true); 2239 commit(true);
2239 } 2240 },
2241 updaterow: function (rowid, rowdata, commit) {
2242 console.log("misc updaterow "+rowid);
2243 commit(true);
2244 }
2240 }; 2245 };
2241 var miscAdapter = new $.jqx.dataAdapter(miscSource, { 2246 var miscAdapter = new $.jqx.dataAdapter(miscSource, {
2242 beforeLoadComplete: function (records) { 2247 beforeLoadComplete: function (records) {
2243 var data = new Array(); 2248 var data = new Array();
2244 for (var i = 0; i < records.length; i++) { 2249 for (var i = 0; i < records.length; i++) {
2301 $("#miscGrid").jqxGrid({ 2306 $("#miscGrid").jqxGrid({
2302 width: 1240, 2307 width: 1240,
2303 height: 575, 2308 height: 575,
2304 source: miscAdapter, 2309 source: miscAdapter,
2305 theme: theme, 2310 theme: theme,
2306 sortmode: "many",
2307 selectionmode: 'singlerow', 2311 selectionmode: 'singlerow',
2308 showtoolbar: true, 2312 showtoolbar: true,
2309 rendertoolbar: function (toolbar) { 2313 rendertoolbar: function (toolbar) {
2310 var me = this; 2314 var me = this;
2311 var container = $("<div style='overflow: hidden; position: relative; margin: 5px;'></div>"); 2315 var container = $("<div style='overflow: hidden; position: relative; margin: 5px;'></div>");
2358 var commit = $("#miscGrid").jqxGrid('deleterow', id); 2362 var commit = $("#miscGrid").jqxGrid('deleterow', id);
2359 } 2363 }
2360 }); 2364 });
2361 }, 2365 },
2362 ready: function() { 2366 ready: function() {
2363 var datainformation = $('#miscGrid').jqxGrid('getdatainformation');
2364 if (datainformation.rowscount) {
2365 $("#miscGrid").jqxGrid('sortby', 'm_use_use', 'asc');
2366 $("#miscGrid").jqxGrid('sortby', 'm_type', 'asc');
2367 }
2368 $('#jqxTabs').jqxTabs('next'); 2367 $('#jqxTabs').jqxTabs('next');
2369 }, 2368 },
2370 columns: [ 2369 columns: [
2371 { text: 'Ingredient', datafield: 'm_name' }, 2370 { text: 'Ingredient', datafield: 'm_name' },
2372 { text: 'Type', width: 140, datafield: 'm_type', 2371 { text: 'Type', width: 140, datafield: 'm_type',
2409 { text: '', datafield: 'Edit', columntype: 'button', width: 100, align: 'center', cellsrenderer: function () { 2408 { text: '', datafield: 'Edit', columntype: 'button', width: 100, align: 'center', cellsrenderer: function () {
2410 return "Wijzig"; 2409 return "Wijzig";
2411 }, buttonclick: function (row) { 2410 }, buttonclick: function (row) {
2412 miscRow = row; 2411 miscRow = row;
2413 miscData = $("#miscGrid").jqxGrid('getrowdata', miscRow); 2412 miscData = $("#miscGrid").jqxGrid('getrowdata', miscRow);
2414 if (miscData.m_amount_is_weight) 2413 if (miscData.m_type == 4) {
2415 $("#wm_pmpt_amount").html("Gewicht gram:"); 2414 alert("Brouwzouten wijzigen in de water tab.");
2416 else 2415 } else {
2417 $("#wm_pmpt_amount").html("Volume ml:"); 2416 if (miscData.m_amount_is_weight)
2418 $("#wm_name").val(miscData.m_name); 2417 $("#wm_pmpt_amount").html("Gewicht gram:");
2419 $("#wm_amount").val(miscData.m_amount * 1000); 2418 else
2420 if ((miscData.m_use_use == 3) || (miscData.m_use_use == 4)) // Primary or Secondary 2419 $("#wm_pmpt_amount").html("Volume ml:");
2421 $("#wm_time").val(miscData.m_time / 1440); 2420 $("#wm_name").val(miscData.m_name);
2422 else 2421 $("#wm_amount").val(miscData.m_amount * 1000);
2423 $("#wm_time").val(miscData.m_time); 2422 if ((miscData.m_use_use == 3) || (miscData.m_use_use == 4)) // Primary or Secondary
2424 $("#wm_use_use").val(miscData.m_use_use); 2423 $("#wm_time").val(miscData.m_time / 1440);
2425 // show the popup window. 2424 else
2426 if (miscData.m_type != 4) 2425 $("#wm_time").val(miscData.m_time);
2426 $("#wm_use_use").val(miscData.m_use_use);
2427 // show the popup window.
2427 $("#popupMisc").jqxWindow('open'); 2428 $("#popupMisc").jqxWindow('open');
2429 }
2428 } 2430 }
2429 } 2431 }
2430 ] 2432 ]
2431 }); 2433 });
2432 }; 2434 };
2455 { name: 'y_tolerance', type: 'float' }, 2457 { name: 'y_tolerance', type: 'float' },
2456 { name: 'y_inventory', type: 'float' }, 2458 { name: 'y_inventory', type: 'float' },
2457 { name: 'y_avail', type: 'int' } 2459 { name: 'y_avail', type: 'int' }
2458 ], 2460 ],
2459 addrow: function (rowid, rowdata, position, commit) { 2461 addrow: function (rowid, rowdata, position, commit) {
2462 console.log("yeast addrow "+rowid);
2460 commit(true); 2463 commit(true);
2461 }, 2464 },
2462 deleterow: function (rowid, commit) { 2465 deleterow: function (rowid, commit) {
2466 console.log("yeast deleterow "+rowid);
2463 commit(true); 2467 commit(true);
2464 } 2468 },
2469 updaterow: function (rowid, rowdata, commit) {
2470 console.log("yeast updaterow "+rowid);
2471 commit(true);
2472 }
2465 }; 2473 };
2466 var yeastAdapter = new $.jqx.dataAdapter(yeastSource); 2474 var yeastAdapter = new $.jqx.dataAdapter(yeastSource);
2467 $("#yeastGrid").jqxGrid({ 2475 $("#yeastGrid").jqxGrid({
2468 width: 1240, 2476 width: 1240,
2469 height: 350, 2477 height: 350,
2470 source: yeastAdapter, 2478 source: yeastAdapter,
2471 theme: theme, 2479 theme: theme,
2472 sortmode: "many",
2473 selectionmode: 'singlerow', 2480 selectionmode: 'singlerow',
2474 showtoolbar: true, 2481 showtoolbar: true,
2475 rendertoolbar: function (toolbar) { 2482 rendertoolbar: function (toolbar) {
2476 var me = this; 2483 var me = this;
2477 var container = $("<div style='overflow: hidden; position: relative; margin: 5px;'></div>"); 2484 var container = $("<div style='overflow: hidden; position: relative; margin: 5px;'></div>");
2535 var commit = $("#yeastGrid").jqxGrid('deleterow', id); 2542 var commit = $("#yeastGrid").jqxGrid('deleterow', id);
2536 } 2543 }
2537 }); 2544 });
2538 }, 2545 },
2539 ready: function() { 2546 ready: function() {
2540 var datainformation = $('#yeastGrid').jqxGrid('getdatainformation');
2541 if (datainformation.rowscount) {
2542 $("#yeastGrid").jqxGrid('sortby', 'y_use', 'asc');
2543 }
2544 calcFermentables(); 2547 calcFermentables();
2545 $('#jqxTabs').jqxTabs('next'); 2548 $('#jqxTabs').jqxTabs('next');
2546 }, 2549 },
2547 columns: [ 2550 columns: [
2548 { text: 'Gist', datafield: 'y_name' }, 2551 { text: 'Gist', datafield: 'y_name' },
2931 cancelButton: $("#FermentableReady"), 2934 cancelButton: $("#FermentableReady"),
2932 modalOpacity: 0.40 2935 modalOpacity: 0.40
2933 }); 2936 });
2934 $("#FermentableReady").jqxButton({ template: "success", width: '90px', theme: theme }); 2937 $("#FermentableReady").jqxButton({ template: "success", width: '90px', theme: theme });
2935 $("#FermentableReady").click(function () { 2938 $("#FermentableReady").click(function () {
2939 var rowID = $("#fermentableGrid").jqxGrid('getrowid', fermentableRow);
2940 console.log("FermentableReady row:"+fermentableRow+" ID:"+rowID);
2941 var row = {
2942 f_name: fermentableData.f_name,
2943 f_origin: fermentableData.f_origin,
2944 f_supplier: fermentableData.f_supplier,
2945 f_amount: fermentableData.f_amount,
2946 f_cost: fermentableData.f_cost,
2947 f_type: fermentableData.f_type,
2948 f_yield: fermentableData.f_yield,
2949 f_color: fermentableData.f_color,
2950 f_coarse_fine_diff: fermentableData.f_coarse_fine_diff,
2951 f_moisture: fermentableData.f_moisture,
2952 f_diastatic_power: fermentableData.f_diastatic_power,
2953 f_protein: fermentableData.f_protein,
2954 f_max_in_batch: fermentableData.f_max_in_batch,
2955 f_graintype: fermentableData.f_graintype,
2956 f_added: fermentableData.f_added,
2957 f_dissolved_protein: fermentableData.f_dissolved_protein,
2958 f_recommend_mash: fermentableData.f_recommend_mash,
2959 f_add_after_boil: fermentableData.f_add_after_boil,
2960 f_adjust_to_total_100: fermentableData.f_adjust_to_total_100,
2961 f_percentage: fermentableData.f_percentage,
2962 f_di_ph: fermentableData.f_di_ph,
2963 f_acid_to_ph_57: fermentableData.f_acid_to_ph_57,
2964 f_inventory: fermentableData.f_inventory,
2965 f_avail: fermentableData.f_avail
2966 };
2967 $("#fermentableGrid").jqxGrid('updaterow', rowID, row);
2936 // Recalc percentages 2968 // Recalc percentages
2937 calcFermentables(); 2969 calcFermentables();
2938 calcIBUs(); 2970 calcIBUs();
2939 calcMash(); 2971 calcMash();
2940 // Waters: yes there is impact. 2972 // Waters: yes there is impact.
2961 }); 2993 });
2962 $("#wf_select").on('select', function (event) { 2994 $("#wf_select").on('select', function (event) {
2963 if (event.args) { 2995 if (event.args) {
2964 var index = event.args.index; 2996 var index = event.args.index;
2965 var datarecord = fermentablelist.records[index]; 2997 var datarecord = fermentablelist.records[index];
2966 var rowdata = $("#fermentableGrid").jqxGrid('getrowdata', fermentableRow);
2967 $("#wf_name").val(datarecord.name); 2998 $("#wf_name").val(datarecord.name);
2968 rowdata.f_name = datarecord.name; 2999 fermentableData.f_name = datarecord.name;
2969 rowdata.f_origin = datarecord.origin; 3000 fermentableData.f_origin = datarecord.origin;
2970 rowdata.f_supplier = datarecord.supplier; 3001 fermentableData.f_supplier = datarecord.supplier;
2971 rowdata.f_type = datarecord.type; 3002 fermentableData.f_type = datarecord.type;
2972 rowdata.f_cost = datarecord.cost; 3003 fermentableData.f_cost = datarecord.cost;
2973 rowdata.f_yield = datarecord.yield; 3004 fermentableData.f_yield = datarecord.yield;
2974 rowdata.f_color = datarecord.color; 3005 fermentableData.f_color = datarecord.color;
2975 rowdata.f_coarse_fine_diff = datarecord.coarse_fine_diff; 3006 fermentableData.f_coarse_fine_diff = datarecord.coarse_fine_diff;
2976 rowdata.f_moisture = datarecord.moisture; 3007 fermentableData.f_moisture = datarecord.moisture;
2977 rowdata.f_diastatic_power = datarecord.diastatic_power; 3008 fermentableData.f_diastatic_power = datarecord.diastatic_power;
2978 rowdata.f_protein = datarecord.protein; 3009 fermentableData.f_protein = datarecord.protein;
2979 rowdata.f_max_in_batch = datarecord.max_in_batch; 3010 fermentableData.f_max_in_batch = datarecord.max_in_batch;
2980 rowdata.f_graintype = datarecord.graintype; 3011 fermentableData.f_graintype = datarecord.graintype;
2981 rowdata.f_dissolved_protein = datarecord.dissolved_protein; 3012 fermentableData.f_dissolved_protein = datarecord.dissolved_protein;
2982 rowdata.f_recommend_mash = datarecord.recommend_mash; 3013 fermentableData.f_recommend_mash = datarecord.recommend_mash;
2983 rowdata.f_add_after_boil = datarecord.add_after_boil; 3014 fermentableData.f_add_after_boil = datarecord.add_after_boil;
2984 rowdata.f_di_ph = datarecord.di_ph; 3015 fermentableData.f_di_ph = datarecord.di_ph;
2985 rowdata.f_acid_to_ph_57 = datarecord.acid_to_ph_57; 3016 fermentableData.f_acid_to_ph_57 = datarecord.acid_to_ph_57;
2986 rowdata.f_inventory = datarecord.inventory; 3017 fermentableData.f_inventory = datarecord.inventory;
2987 } 3018 }
2988 }); 3019 });
2989 $("#wf_amount").jqxNumberInput( Spin3dec ); 3020 $("#wf_amount").jqxNumberInput( Spin3dec );
2990 $('#wf_amount').on('change', function (event) { 3021 $('#wf_amount').on('change', function (event) {
2991 console.log("amount changed: "+event.args.value); 3022 console.log("amount changed: "+event.args.value);
2992 $("#fermentableGrid").jqxGrid('setcellvalue', fermentableRow, 'f_amount', event.args.value); 3023 $("#fermentableGrid").jqxGrid('setcellvalue', fermentableRow, 'f_amount', event.args.value);
3024 fermentableData.f_amount = event.args.value;
2993 if (! to_100) { 3025 if (! to_100) {
2994 // Recalculate percentages 3026 // Recalculate percentages
2995 console.log("adjust percentages"); 3027 console.log("adjust percentages");
2996 var rowscount = $("#fermentableGrid").jqxGrid('getdatainformation').rowscount; 3028 var rowscount = $("#fermentableGrid").jqxGrid('getdatainformation').rowscount;
2997 if (rowscount > 1) { 3029 if (rowscount > 1) {
3017 $("#wf_percentage").jqxNumberInput( Perc1dec ); 3049 $("#wf_percentage").jqxNumberInput( Perc1dec );
3018 $("#wf_percentage").on('change', function (event) { 3050 $("#wf_percentage").on('change', function (event) {
3019 var oldvalue = Math.round(fermentableData.f_percentage * 10) / 10.0; 3051 var oldvalue = Math.round(fermentableData.f_percentage * 10) / 10.0;
3020 var newvalue = event.args.value; 3052 var newvalue = event.args.value;
3021 console.log("percentage changed: "+newvalue+" old: "+oldvalue); 3053 console.log("percentage changed: "+newvalue+" old: "+oldvalue);
3054 fermentableData.f_percent = newvalue;
3022 var rowscount = $("#fermentableGrid").jqxGrid('getdatainformation').rowscount; 3055 var rowscount = $("#fermentableGrid").jqxGrid('getdatainformation').rowscount;
3023 if ((oldvalue != newvalue) && (rowscount > 1)) { 3056 if ((oldvalue != newvalue) && (rowscount > 1)) {
3024 var rowdata = $("#fermentableGrid").jqxGrid('getrowdata', fermentableRow); 3057 var rowdata = $("#fermentableGrid").jqxGrid('getrowdata', fermentableRow);
3025 if (rowdata.f_adjust_to_total_100) { 3058 if (rowdata.f_adjust_to_total_100) {
3026 $("#wf_percentage").val(oldvalue); 3059 $("#wf_percentage").val(oldvalue);
3184 cancelButton: $("#HopReady"), 3217 cancelButton: $("#HopReady"),
3185 modalOpacity: 0.40 3218 modalOpacity: 0.40
3186 }); 3219 });
3187 $("#HopReady").jqxButton({ template: "success", width: '90px', theme: theme }); 3220 $("#HopReady").jqxButton({ template: "success", width: '90px', theme: theme });
3188 $("#HopReady").click(function () { 3221 $("#HopReady").click(function () {
3222 var rowID = $("#hopGrid").jqxGrid('getrowid', hopRow);
3223 console.log("HopReady row:"+hopRow+" ID:"+rowID);
3224 var row = {
3225 h_name: $("#wh_name").val(),
3226 h_origin: hopData.h_origin,
3227 h_amount: parseFloat($("#wh_amount").jqxNumberInput('decimal')) / 1000,
3228 h_cost: hopData.h_cost,
3229 h_type: hopData.h_type,
3230 h_form: hopData.h_form,
3231 h_useat: $("#wh_useat").val(),
3232 h_time: hopData.h_time,
3233 h_alpha: hopData.h_alpha,
3234 h_beta: hopData.h_beta,
3235 h_hsi: hopData.h_hsi,
3236 h_humulene: hopData.h_humulene,
3237 h_caryophyllene: hopData.h_caryophyllene,
3238 h_cohumulone: hopData.h_cohumulone,
3239 h_myrcene: hopData.h_myrcene,
3240 h_total_oil: hopData.h_total_oil,
3241 h_inventory: hopData.h_inventory,
3242 h_avail: hopData.h_avail
3243 };
3244 $("#hopGrid").jqxGrid('updaterow', rowID, row);
3189 calcIBUs(); 3245 calcIBUs();
3190 }); 3246 });
3191 $("#wh_name").jqxInput({ theme: theme, width: 320, height: 23 }); 3247 $("#wh_name").jqxInput({ theme: theme, width: 320, height: 23 });
3192 $("#wh_instock").jqxCheckBox({ theme: theme, height: 23 }); 3248 $("#wh_instock").jqxCheckBox({ theme: theme, height: 23 });
3193 $("#wh_instock").on('change', function (event) { 3249 $("#wh_instock").on('change', function (event) {
3210 }); 3266 });
3211 $("#wh_select").on('select', function (event) { 3267 $("#wh_select").on('select', function (event) {
3212 if (event.args) { 3268 if (event.args) {
3213 var index = event.args.index; 3269 var index = event.args.index;
3214 var datarecord = hoplist.records[index]; 3270 var datarecord = hoplist.records[index];
3215 var rowdata = $("#hopGrid").jqxGrid('getrowdata', hopRow);
3216 $("#wh_name").val(datarecord.name); 3271 $("#wh_name").val(datarecord.name);
3217 rowdata.h_name = datarecord.name; 3272 hopData.h_name = datarecord.name;
3218 rowdata.h_origin = datarecord.origin; 3273 hopData.h_origin = datarecord.origin;
3219 rowdata.h_cost = datarecord.cost; 3274 hopData.h_cost = datarecord.cost;
3220 rowdata.h_type = datarecord.type; 3275 hopData.h_type = datarecord.type;
3221 rowdata.h_form = datarecord.form; 3276 hopData.h_form = datarecord.form;
3222 rowdata.h_alpha = datarecord.alpha; 3277 hopData.h_alpha = datarecord.alpha;
3223 rowdata.h_beta = datarecord.beta; 3278 hopData.h_beta = datarecord.beta;
3224 rowdata.h_hsi = datarecord.hsi; 3279 hopData.h_hsi = datarecord.hsi;
3225 rowdata.h_humulene = datarecord.humulene; 3280 hopData.h_humulene = datarecord.humulene;
3226 rowdata.h_caryophyllene = datarecord.caryophyllene; 3281 hopData.h_caryophyllene = datarecord.caryophyllene;
3227 rowdata.h_cohumulone = datarecord.cohumulone; 3282 hopData.h_cohumulone = datarecord.cohumulone;
3228 rowdata.h_myrcene = datarecord.myrcene; 3283 hopData.h_myrcene = datarecord.myrcene;
3229 rowdata.h_total_oil = datarecord.total_oil; 3284 hopData.h_total_oil = datarecord.total_oil;
3230 rowdata.h_inventory = datarecord.inventory; 3285 hopData.h_inventory = datarecord.inventory;
3231 } 3286 }
3232 }); 3287 });
3233 $("#wh_amount").jqxNumberInput( Spin1dec ); 3288 $("#wh_amount").jqxNumberInput( Spin1dec );
3234 $('#wh_amount').on('change', function (event) { 3289 $('#wh_amount').on('change', function (event) {
3235 console.log("amount changed: "+event.args.value); 3290 console.log("amount changed: "+event.args.value+" time:"+hopData.h_time+" alpha:"+hopData.h_alpha);
3236 var amount = parseFloat(event.args.value) / 1000; 3291 var amount = parseFloat(event.args.value) / 1000;
3237 var rowdata = $("#hopGrid").jqxGrid('getrowdata', hopRow); 3292
3238 3293 var ibu = toIBU(hopData.h_useat, hopData.h_form, preboil_sg,
3239 var ibu = toIBU(rowdata.h_useat, rowdata.h_form, preboil_sg,
3240 parseFloat($("#batch_size").jqxNumberInput('decimal')), 3294 parseFloat($("#batch_size").jqxNumberInput('decimal')),
3241 amount, parseFloat(rowdata.h_time), 3295 amount, parseFloat(hopData.h_time),
3242 parseFloat(rowdata.h_alpha), $("#ibu_method").val() 3296 parseFloat(hopData.h_alpha), $("#ibu_method").val()
3243 ); 3297 );
3244 rowdata.h_amount = amount; 3298 hopData.h_amount = amount;
3245 var ibu = toIBU(rowdata.h_useat, rowdata.h_form, preboil_sg, parseFloat($("#batch_size").jqxNumberInput('decimal')),
3246 parseFloat(rowdata.h_amount), parseFloat(rowdata.h_time), parseFloat(rowdata.h_alpha), $("#ibu_method").val());
3247 $("#wh_ibu").val(ibu); 3299 $("#wh_ibu").val(ibu);
3248 calcIBUs();
3249 }); 3300 });
3250 $("#wh_ibu").jqxNumberInput( Show1dec ); 3301 $("#wh_ibu").jqxNumberInput( Show1dec );
3251 $("#wh_time").jqxNumberInput( PosInt ); 3302 $("#wh_time").jqxNumberInput( PosInt );
3252 $("#wh_time").on('change', function (event) { 3303 $("#wh_time").on('change', function (event) {
3253 console.log("time changed: "+event.args.value);
3254 var rowdata = $("#hopGrid").jqxGrid('getrowdata', hopRow);
3255 var newtime = parseFloat(event.args.value); 3304 var newtime = parseFloat(event.args.value);
3256 // Check limits and correct 3305 // Check limits and correct
3257 if (rowdata.h_useat == 2) { // Boil 3306 if (hopData.h_useat == 2) { // Boil
3258 if (newtime > parseFloat($("#boil_time").jqxNumberInput('decimal'))) { 3307 if (newtime > parseFloat($("#boil_time").jqxNumberInput('decimal'))) {
3259 newtime = parseFloat($("#boil_time").jqxNumberInput('decimal')); 3308 newtime = parseFloat($("#boil_time").jqxNumberInput('decimal'));
3260 $("#wh_time").val(newtime); 3309 $("#wh_time").val(newtime);
3261 } 3310 }
3262 rowdata.h_time = newtime; 3311 hopData.h_time = newtime;
3263 } else if (rowdata.h_useat == 4) { // Whirlpool 3312 } else if (hopData.h_useat == 4) { // Whirlpool
3264 if (newtime > 120) { 3313 if (newtime > 120) {
3265 newtime = 120; 3314 newtime = 120;
3266 $("#wh_time").val(newtime); 3315 $("#wh_time").val(newtime);
3267 } 3316 }
3268 rowdata.h_time = newtime; 3317 hopData.h_time = newtime;
3269 } else if (rowdata.h_useat == 5) { // Dry hop 3318 } else if (hopData.h_useat == 5) { // Dry hop
3270 if (newtime > 21) { 3319 if (newtime > 21) {
3271 newtime = 21; 3320 newtime = 21;
3272 $("#wh_time").val(newtime); 3321 $("#wh_time").val(newtime);
3273 } 3322 }
3274 rowdata.h_time = newtime * 1440; 3323 hopData.h_time = newtime * 1440;
3275 } 3324 }
3276 var ibu = toIBU(rowdata.h_useat, rowdata.h_form, preboil_sg, parseFloat($("#batch_size").jqxNumberInput('decimal')), 3325 var ibu = toIBU(hopData.h_useat, hopData.h_form, preboil_sg, parseFloat($("#batch_size").jqxNumberInput('decimal')),
3277 parseFloat(rowdata.h_amount), parseFloat(rowdata.h_time), parseFloat(rowdata.h_alpha), $("#ibu_method").val()); 3326 parseFloat(hopData.h_amount), parseFloat(hopData.h_time), parseFloat(hopData.h_alpha), $("#ibu_method").val());
3278 $("#wh_ibu").val(ibu); 3327 $("#wh_ibu").val(ibu);
3279 calcIBUs();
3280 }); 3328 });
3281 $("#wh_useat").jqxDropDownList({ 3329 $("#wh_useat").jqxDropDownList({
3282 theme: theme, 3330 theme: theme,
3283 source: HopUseAdapter, 3331 source: HopUseAdapter,
3284 valueMember: 'id', 3332 valueMember: 'id',
3289 dropDownVerticalAlignment: 'top' 3337 dropDownVerticalAlignment: 'top'
3290 }); 3338 });
3291 $("#wh_useat").on('select', function (event) { 3339 $("#wh_useat").on('select', function (event) {
3292 if (event.args) { 3340 if (event.args) {
3293 var index = event.args.index; 3341 var index = event.args.index;
3294 var rowdata = $("#hopGrid").jqxGrid('getrowdata', hopRow); 3342 hopData.h_useat = index;
3295 rowdata.h_useat = index;
3296 if ((index == 0) || (index == 1)) { // Mashhop or First wort hop 3343 if ((index == 0) || (index == 1)) { // Mashhop or First wort hop
3297 rowdata.h_time = parseFloat(dataRecord.boil_time); 3344 hopData.h_time = parseFloat(dataRecord.boil_time);
3298 $("#wh_time").jqxNumberInput({ spinButtons: false, readOnly: true, width: 90 }); 3345 $("#wh_time").jqxNumberInput({ spinButtons: false, readOnly: true, width: 90 });
3299 $("#wh_time").val(rowdata.h_time); 3346 $("#wh_time").val(hopData.h_time);
3300 } else if (index == 3) { // Aroma 3347 } else if (index == 3) { // Aroma
3301 rowdata.h_time = 0; 3348 hopData.h_time = 0;
3302 $("#wh_time").jqxNumberInput({ spinButtons: false, readOnly: true, width: 90 }); 3349 $("#wh_time").jqxNumberInput({ spinButtons: false, readOnly: true, width: 90 });
3303 $("#wh_time").val(0); 3350 $("#wh_time").val(0);
3304 } else { // Boil, Whirlpool or Dry hop 3351 } else { // Boil, Whirlpool or Dry hop
3305 $("#wh_time").jqxNumberInput({ spinButtons: true, readOnly: false, width: 110 }); 3352 $("#wh_time").jqxNumberInput({ spinButtons: true, readOnly: false, width: 110 });
3306 } 3353 }
3322 autoOpen: false, 3369 autoOpen: false,
3323 cancelButton: $("#MiscReady"), 3370 cancelButton: $("#MiscReady"),
3324 modalOpacity: 0.40 3371 modalOpacity: 0.40
3325 }); 3372 });
3326 $("#MiscReady").jqxButton({ template: "success", width: '90px', theme: theme }); 3373 $("#MiscReady").jqxButton({ template: "success", width: '90px', theme: theme });
3374 $("#MiscReady").click(function () {
3375 var rowID = $("#miscGrid").jqxGrid('getrowid', miscRow);
3376 console.log("MiscReady row:"+miscRow+" ID:"+rowID);
3377 var row = {
3378 m_name: miscData.m_name,
3379 m_amount: miscData.m_amount,
3380 m_cost: miscData.m_cost,
3381 m_type: miscData.m_type,
3382 m_use_use: miscData.m_use_use,
3383 m_time: miscData.m_time,
3384 m_amount_is_weight: miscData.m_amount_is_weight,
3385 m_inventory: miscData.m_inventory,
3386 m_avail: miscData.m_avail
3387 };
3388 $("#miscGrid").jqxGrid('updaterow', rowID, row);
3389 });
3327 $("#wm_name").jqxInput({ theme: theme, width: 320, height: 23 }); 3390 $("#wm_name").jqxInput({ theme: theme, width: 320, height: 23 });
3328 $("#wm_instock").jqxCheckBox({ theme: theme, height: 23 }); 3391 $("#wm_instock").jqxCheckBox({ theme: theme, height: 23 });
3329 $("#wm_instock").on('change', function (event) { 3392 $("#wm_instock").on('change', function (event) {
3330 miscinstock = event.args.checked; 3393 miscinstock = event.args.checked;
3331 misclist.dataBind(); 3394 misclist.dataBind();
3342 }); 3405 });
3343 $("#wm_select").on('select', function (event) { 3406 $("#wm_select").on('select', function (event) {
3344 if (event.args) { 3407 if (event.args) {
3345 var index = event.args.index; 3408 var index = event.args.index;
3346 var datarecord = misclist.records[index]; 3409 var datarecord = misclist.records[index];
3347 var rowdata = $("#miscGrid").jqxGrid('getrowdata', miscRow);
3348 $("#wm_name").val(datarecord.name); 3410 $("#wm_name").val(datarecord.name);
3349 rowdata.m_name = datarecord.name; 3411 miscData.m_name = datarecord.name;
3350 rowdata.m_cost = datarecord.cost; 3412 miscData.m_cost = datarecord.cost;
3351 rowdata.m_type = datarecord.type; 3413 miscData.m_type = datarecord.type;
3352 rowdata.m_use_use = datarecord.use_use; 3414 miscData.m_use_use = datarecord.use_use;
3353 rowdata.m_amount_is_weight = datarecord.amount_is_weight; 3415 miscData.m_amount_is_weight = datarecord.amount_is_weight;
3354 rowdata.m_inventory = datarecord.inventory; 3416 miscData.m_inventory = datarecord.inventory;
3355 } 3417 }
3356 }); 3418 });
3357 $("#wm_amount").jqxNumberInput( Spin1dec ); 3419 $("#wm_amount").jqxNumberInput( Spin1dec );
3358 $('#wm_amount').on('change', function (event) { 3420 $('#wm_amount').on('change', function (event) {
3359 console.log("amount changed: "+event.args.value); 3421 console.log("amount changed: "+event.args.value);
3360 var amount = parseFloat(event.args.value) / 1000; 3422 miscData.m_amount = parseFloat(event.args.value) / 1000;
3361 var rowdata = $("#miscGrid").jqxGrid('getrowdata', miscRow);
3362 rowdata.m_amount = amount;
3363 }); 3423 });
3364 $("#wm_time").jqxNumberInput( PosInt ); 3424 $("#wm_time").jqxNumberInput( PosInt );
3365 $("#wm_time").on('change', function (event) { 3425 $("#wm_time").on('change', function (event) {
3366 console.log("time changed: "+event.args.value); 3426 console.log("time changed: "+event.args.value);
3367 var rowdata = $("#miscGrid").jqxGrid('getrowdata', miscRow);
3368 var newtime = parseFloat(event.args.value); 3427 var newtime = parseFloat(event.args.value);
3369 3428
3370 if (rowdata.m_use_use == 2) { // Boil 3429 if (miscData.m_use_use == 2) { // Boil
3371 if (newtime > parseFloat($("#boil_time").jqxNumberInput('decimal'))) { 3430 if (newtime > parseFloat($("#boil_time").jqxNumberInput('decimal'))) {
3372 newtime = parseFloat($("#boil_time").jqxNumberInput('decimal')); 3431 newtime = parseFloat($("#boil_time").jqxNumberInput('decimal'));
3373 $("#wm_time").val(newtime); 3432 $("#wm_time").val(newtime);
3374 } 3433 }
3375 rowdata.m_time = newtime; 3434 miscData.m_time = newtime;
3376 } else if ((rowdata.m_use_use == 3) || (rowdata.m_use_use == 4)) { // Primary or Secondary 3435 } else if ((miscData.m_use_use == 3) || (miscData.m_use_use == 4)) { // Primary or Secondary
3377 if (newtime > 21) { 3436 if (newtime > 21) {
3378 newtime = 21; 3437 newtime = 21;
3379 $("#wm_time").val(newtime); 3438 $("#wm_time").val(newtime);
3380 } 3439 }
3381 rowdata.m_time = newtime * 1440; 3440 miscData.m_time = newtime * 1440;
3382 } 3441 }
3383 }); 3442 });
3384 $("#wm_use_use").jqxDropDownList({ 3443 $("#wm_use_use").jqxDropDownList({
3385 theme: theme, 3444 theme: theme,
3386 source: MiscUseAdapter, 3445 source: MiscUseAdapter,
3392 dropDownVerticalAlignment: 'top' 3451 dropDownVerticalAlignment: 'top'
3393 }); 3452 });
3394 $("#wm_use_use").on('select', function (event) { 3453 $("#wm_use_use").on('select', function (event) {
3395 if (event.args) { 3454 if (event.args) {
3396 var index = event.args.index; 3455 var index = event.args.index;
3397 var rowdata = $("#miscGrid").jqxGrid('getrowdata', miscRow); 3456 miscData.m_use_use = index;
3398 rowdata.m_use_use = index;
3399 if ((index == 2) || (index == 3) || (index == 4)) { // Boil, Primary or Secondary 3457 if ((index == 2) || (index == 3) || (index == 4)) { // Boil, Primary or Secondary
3400 $("#wm_time").jqxNumberInput({ spinButtons: true, readOnly: false, width: 110 }); 3458 $("#wm_time").jqxNumberInput({ spinButtons: true, readOnly: false, width: 110 });
3401 } else { 3459 } else {
3402 rowdata.m_time = 0; 3460 miscData.m_time = 0;
3403 $("#wm_time").jqxNumberInput({ spinButtons: false, readOnly: true, width: 90 }); 3461 $("#wm_time").jqxNumberInput({ spinButtons: false, readOnly: true, width: 90 });
3404 $("#wm_time").val(0); 3462 $("#wm_time").val(0);
3405 } 3463 }
3406 } 3464 }
3407 }); 3465 });
3422 cancelButton: $("#YeastReady"), 3480 cancelButton: $("#YeastReady"),
3423 modalOpacity: 0.40 3481 modalOpacity: 0.40
3424 }); 3482 });
3425 $("#YeastReady").jqxButton({ template: "success", width: '90px', theme: theme }); 3483 $("#YeastReady").jqxButton({ template: "success", width: '90px', theme: theme });
3426 $("#YeastReady").click(function () { 3484 $("#YeastReady").click(function () {
3485 var rowID = $("#yeastGrid").jqxGrid('getrowid', yeastRow);
3486 console.log("YeastReady row:"+yeastRow+" ID:"+rowID);
3487 var row = {
3488 y_name: yeastData.y_name,
3489 y_laboratory: yeastData.y_laboratory,
3490 y_product_id: yeastData.y_product_id,
3491 y_amount: yeastData.y_amount,
3492 y_cost: yeastData.y_cost,
3493 y_type: yeastData.y_type,
3494 y_form: yeastData.y_form,
3495 y_flocculation: yeastData.y_flocculation,
3496 y_min_temperature: yeastData.y_min_temperature,
3497 y_max_temperature: yeastData.y_max_temperature,
3498 y_attenuation: yeastData.y_attenuation,
3499 y_use: yeastData.y_use,
3500 y_cells: yeastData.y_cells,
3501 y_tolerance: yeastData.y_tolerance,
3502 y_inventory: yeastData.y_inventory,
3503 y_avail: yeastData.y_avail
3504 };
3505 $("#yeastGrid").jqxGrid('updaterow', rowID, row);
3427 calcFermentables(); 3506 calcFermentables();
3428 }); 3507 });
3429 $("#wy_name").jqxInput({ theme: theme, width: 320, height: 23 }); 3508 $("#wy_name").jqxInput({ theme: theme, width: 320, height: 23 });
3430 $("#wy_laboratory").jqxInput({ theme: theme, width: 320, height: 23 }); 3509 $("#wy_laboratory").jqxInput({ theme: theme, width: 320, height: 23 });
3431 $("#wy_product_id").jqxInput({ theme: theme, width: 320, height: 23 }); 3510 $("#wy_product_id").jqxInput({ theme: theme, width: 320, height: 23 });
3450 }); 3529 });
3451 $("#wy_select").on('select', function (event) { 3530 $("#wy_select").on('select', function (event) {
3452 if (event.args) { 3531 if (event.args) {
3453 var index = event.args.index; 3532 var index = event.args.index;
3454 var datarecord = yeastlist.records[index]; 3533 var datarecord = yeastlist.records[index];
3455 var rowdata = $("#yeastGrid").jqxGrid('getrowdata', yeastRow);
3456 $("#wy_name").val(datarecord.name); 3534 $("#wy_name").val(datarecord.name);
3457 $("#wy_laboratory").val(datarecord.laboratory); 3535 $("#wy_laboratory").val(datarecord.laboratory);
3458 $("#wy_product_id").val(datarecord.product_id); 3536 $("#wy_product_id").val(datarecord.product_id);
3459 rowdata.y_name = datarecord.name; 3537 yeastData.y_name = datarecord.name;
3460 rowdata.y_cost = datarecord.cost; 3538 yeastData.y_cost = datarecord.cost;
3461 rowdata.y_type = datarecord.type; 3539 yeastData.y_type = datarecord.type;
3462 rowdata.y_form = datarecord.form; 3540 yeastData.y_form = datarecord.form;
3463 rowdata.y_laboratory = datarecord.laboratory; 3541 yeastData.y_laboratory = datarecord.laboratory;
3464 rowdata.y_product_id = datarecord.product_id; 3542 yeastData.y_product_id = datarecord.product_id;
3465 rowdata.y_min_temperature = datarecord.min_temperature; 3543 yeastData.y_min_temperature = datarecord.min_temperature;
3466 rowdata.y_max_temperature = datarecord.max_temperature; 3544 yeastData.y_max_temperature = datarecord.max_temperature;
3467 rowdata.y_flocculation = datarecord.flocculation; 3545 yeastData.y_flocculation = datarecord.flocculation;
3468 rowdata.y_attenuation = datarecord.attenuation; 3546 yeastData.y_attenuation = datarecord.attenuation;
3469 rowdata.y_cells = datarecord.cells; 3547 yeastData.y_cells = datarecord.cells;
3470 rowdata.y_inventory = datarecord.inventory; 3548 yeastData.y_inventory = datarecord.inventory;
3471 if (rowdata.y_form == 0) { 3549 if (yeastData.y_form == 0) {
3472 $("#wy_pmpt_amount").html("Pak(ken):"); 3550 $("#wy_pmpt_amount").html("Pak(ken):");
3473 } else if (rowdata.y_form == 1) { 3551 } else if (yeastData.y_form == 1) {
3474 $("#wy_pmpt_amount").html("Gewicht gram:"); 3552 $("#wy_pmpt_amount").html("Gewicht gram:");
3475 } else { 3553 } else {
3476 $("#wy_pmpt_amount").html("Volume ml:"); 3554 $("#wy_pmpt_amount").html("Volume ml:");
3477 } 3555 }
3478 calcFermentables(); 3556 calcFermentables();
3479 } 3557 }
3480 }); 3558 });
3481 $("#wy_amount").jqxNumberInput( Spin1dec ); 3559 $("#wy_amount").jqxNumberInput( Spin1dec );
3482 $('#wy_amount').on('change', function (event) { 3560 $('#wy_amount').on('change', function (event) {
3483 console.log("amount changed: "+event.args.value); 3561 console.log("amount changed: "+event.args.value);
3484 var rowdata = $("#yeastGrid").jqxGrid('getrowdata', yeastRow); 3562 if (yeastData.y_form == 0) // Liquid
3485 if (rowdata.y_form == 0) // Liquid
3486 var amount = parseFloat(event.args.value); 3563 var amount = parseFloat(event.args.value);
3487 else 3564 else
3488 var amount = parseFloat(event.args.value) / 1000; 3565 var amount = parseFloat(event.args.value) / 1000;
3489 rowdata.y_amount = amount; 3566 yeastData.y_amount = amount;
3490 calcFermentables(); 3567 calcFermentables();
3491 }); 3568 });
3492 $("#wy_use").jqxDropDownList({ 3569 $("#wy_use").jqxDropDownList({
3493 theme: theme, 3570 theme: theme,
3494 source: YeastUseAdapter, 3571 source: YeastUseAdapter,
3500 dropDownVerticalAlignment: 'top' 3577 dropDownVerticalAlignment: 'top'
3501 }); 3578 });
3502 $("#wy_use").on('select', function (event) { 3579 $("#wy_use").on('select', function (event) {
3503 if (event.args) { 3580 if (event.args) {
3504 var index = event.args.index; 3581 var index = event.args.index;
3505 var rowdata = $("#yeastGrid").jqxGrid('getrowdata', yeastRow); 3582 yeastData.y_use = index;
3506 rowdata.y_use = index;
3507 calcFermentabes(); 3583 calcFermentabes();
3508 } 3584 }
3509 }); 3585 });
3510 3586
3511 // Tab 6, Maischen 3587 // Tab 6, Maischen
3570 cancelButton: $("#MashReady"), 3646 cancelButton: $("#MashReady"),
3571 modalOpacity: 0.40 3647 modalOpacity: 0.40
3572 }); 3648 });
3573 $("#MashReady").jqxButton({ template: "success", width: '90px', theme: theme }); 3649 $("#MashReady").jqxButton({ template: "success", width: '90px', theme: theme });
3574 $("#MashReady").click(function () { 3650 $("#MashReady").click(function () {
3575 $("#mashGrid").jqxGrid('sortby', 'step_temp', 'asc');
3576 calcMash(); 3651 calcMash();
3577 }); 3652 });
3578 $("#wstep_name").jqxInput({ theme: theme, width: 320, height: 23 }); 3653 $("#wstep_name").jqxInput({ theme: theme, width: 320, height: 23 });
3579 $("#wstep_name").on('change', function (event) { 3654 $("#wstep_name").on('change', function (event) {
3580 var rowdata = $("#mashGrid").jqxGrid('getrowdata', mashRow); 3655 var rowdata = $("#mashGrid").jqxGrid('getrowdata', mashRow);

mercurial