www/js/prod_edit.js

changeset 420
3df93a77cd1d
parent 419
99a7f2a6976e
child 422
7943afc0fcde
equal deleted inserted replaced
419:99a7f2a6976e 420:3df93a77cd1d
1868 $("#fermentableGrid").jqxGrid('setcellvalue', i, 'f_amount', dataRecord.bottle_priming_total / 1000); 1868 $("#fermentableGrid").jqxGrid('setcellvalue', i, 'f_amount', dataRecord.bottle_priming_total / 1000);
1869 } 1869 }
1870 } 1870 }
1871 $("#bottle_priming_amount").val(Math.round(dataRecord.bottle_priming_amount * 10) / 10); 1871 $("#bottle_priming_amount").val(Math.round(dataRecord.bottle_priming_amount * 10) / 10);
1872 $("#bottle_priming_total").val(dataRecord.bottle_priming_total); 1872 $("#bottle_priming_total").val(dataRecord.bottle_priming_total);
1873 $("#bottle_abv").val(Math.round((ABV + dataRecord.bottle_priming_amount * 0.47 / 7.907) * 10) / 10); 1873 var pabv = ABV + dataRecord.bottle_priming_amount * 0.47 / 7.907;
1874 var pvol = dataRecord.bottle_amount - (pabv * dataRecord.bottle_amount) / 100;
1875 var talc = dataRecord.bottle_amount - pvol;
1876 var tvol = pvol + dataRecord.bottle_priming_water;
1877 var babv = Math.round(talc / (tvol + talc) * 10000) / 100;
1878 //console.log("bottle pabv:"+pabv+" pvol:"+pvol+" wvol:"+dataRecord.bottle_priming_water+" tvol:"+tvol+" talc:"+talc+" abv:"+babv);
1879 $("#bottle_abv").val(babv);
1874 $("#bottle_pressure").val(GetPressure(dataRecord.bottle_carbonation, TSec, dataRecord.bottle_carbonation_temp)); 1880 $("#bottle_pressure").val(GetPressure(dataRecord.bottle_carbonation, TSec, dataRecord.bottle_carbonation_temp));
1875 1881
1876 // Kegs 1882 // Kegs
1877 var Pressure = CarbCO2ToPressure(dataRecord.keg_carbonation, dataRecord.keg_carbonation_temp); 1883 var Pressure = CarbCO2ToPressure(dataRecord.keg_carbonation, dataRecord.keg_carbonation_temp);
1878 if (Pressure < 0) 1884 if (Pressure < 0)
1890 dataRecord.keg_priming_amount = CarbCO2toS(dataRecord.keg_carbonation, TSec, SFactor); 1896 dataRecord.keg_priming_amount = CarbCO2toS(dataRecord.keg_carbonation, TSec, SFactor);
1891 dataRecord.keg_priming_total = Math.round(dataRecord.keg_amount * dataRecord.keg_priming_amount * 100) / 100; 1897 dataRecord.keg_priming_total = Math.round(dataRecord.keg_amount * dataRecord.keg_priming_amount * 100) / 100;
1892 $("#fermentableGrid").jqxGrid('setcellvalue', i, 'f_amount', dataRecord.keg_priming_total / 1000); 1898 $("#fermentableGrid").jqxGrid('setcellvalue', i, 'f_amount', dataRecord.keg_priming_total / 1000);
1893 } 1899 }
1894 } 1900 }
1895 } 1901 $("#keg_priming_amount").val(Math.round(dataRecord.keg_priming_amount * 10) / 10);
1896 $("#keg_priming_amount").val(Math.round(dataRecord.keg_priming_amount * 10) / 10); 1902 $("#keg_priming_total").val(dataRecord.keg_priming_total);
1897 $("#keg_priming_total").val(dataRecord.keg_priming_total); 1903 var pabv = ABV + dataRecord.keg_priming_amount * 0.47 / 7.907;
1898 $("#keg_abv").val(Math.round((ABV + dataRecord.keg_priming_amount * 0.47 / 7.907) * 10) / 10); 1904 var pvol = dataRecord.keg_amount - (pabv * dataRecord.keg_amount) / 100;
1905 var talc = dataRecord.keg_amount - pvol;
1906 var tvol = pvol + dataRecord.keg_priming_water;
1907 var kabv = Math.round(talc / (tvol + talc) * 10000) / 100;
1908 //console.log("kegs pabv:"+pabv+" pvol:"+pvol+" wvol:"+dataRecord.keg_priming_water+" tvol:"+tvol+" talc:"+talc+" abv:"+kabv);
1909 $("#keg_abv").val(kabv);
1910 } else {
1911 $("#keg_priming_amount").val(0);
1912 $("#keg_priming_total").val(0);
1913 $("#keg_abv").val(ABV);
1914 }
1899 } 1915 }
1900 1916
1901 function calcStage() { 1917 function calcStage() {
1902 1918
1903 var newstage = dataRecord.stage; 1919 var newstage = dataRecord.stage;
2053 $("#secondary_end_date").jqxDateTimeInput({ disabled: true }); 2069 $("#secondary_end_date").jqxDateTimeInput({ disabled: true });
2054 $("#tertiary_temp").jqxNumberInput({ spinButtons: false, readOnly: true, width: 90 }); 2070 $("#tertiary_temp").jqxNumberInput({ spinButtons: false, readOnly: true, width: 90 });
2055 $("#fg").jqxNumberInput({ spinButtons: false, readOnly: true, width: 90 }); 2071 $("#fg").jqxNumberInput({ spinButtons: false, readOnly: true, width: 90 });
2056 $("#final_brix").jqxNumberInput({ spinButtons: false, readOnly: true, width: 90 }); 2072 $("#final_brix").jqxNumberInput({ spinButtons: false, readOnly: true, width: 90 });
2057 $("#package_date").jqxDateTimeInput({ disabled: true }); 2073 $("#package_date").jqxDateTimeInput({ disabled: true });
2074 $("#package_volume").jqxNumberInput({ spinButtons: false, readOnly: true, width: 90 });
2075 $("#package_infuse_amount").jqxNumberInput({ spinButtons: false, readOnly: true, width: 90 });
2076 $("#package_infuse_abv").jqxNumberInput({ spinButtons: false, readOnly: true, width: 90 });
2077 $("#package_infuse_notes").jqxInput({ disabled: true });
2058 $("#bottle_amount").jqxNumberInput({ spinButtons: false, readOnly: true, width: 90 }); 2078 $("#bottle_amount").jqxNumberInput({ spinButtons: false, readOnly: true, width: 90 });
2079 $("#bottle_priming_water").jqxNumberInput({ spinButtons: false, readOnly: true, width: 90 });
2080 $("#keg_priming_water").jqxNumberInput({ spinButtons: false, readOnly: true, width: 90 });
2059 $("#keg_amount").jqxNumberInput({ spinButtons: false, readOnly: true, width: 90 }); 2081 $("#keg_amount").jqxNumberInput({ spinButtons: false, readOnly: true, width: 90 });
2060 $("#bottle_carbonation").jqxNumberInput({ spinButtons: false, readOnly: true, width: 90 }); 2082 $("#bottle_carbonation").jqxNumberInput({ spinButtons: false, readOnly: true, width: 90 });
2061 $("#keg_carbonation").jqxNumberInput({ spinButtons: false, readOnly: true, width: 90 }); 2083 $("#keg_carbonation").jqxNumberInput({ spinButtons: false, readOnly: true, width: 90 });
2062 $("#bottle_priming_sugar").jqxDropDownList({ disabled: true }); 2084 $("#bottle_priming_sugar").jqxDropDownList({ disabled: true });
2063 $("#keg_priming_sugar").jqxDropDownList({ disabled: true }); 2085 $("#keg_priming_sugar").jqxDropDownList({ disabled: true });
2439 dataRecord.keg_amount = Math.round((dataRecord.keg_amount + diff) * 1000) / 1000; 2461 dataRecord.keg_amount = Math.round((dataRecord.keg_amount + diff) * 1000) / 1000;
2440 $('#bottle_amount').val(parseFloat(dataRecord.bottle_amount)); 2462 $('#bottle_amount').val(parseFloat(dataRecord.bottle_amount));
2441 $('#keg_amount').val(parseFloat(dataRecord.keg_amount)); 2463 $('#keg_amount').val(parseFloat(dataRecord.keg_amount));
2442 calcCarbonation(); 2464 calcCarbonation();
2443 }); 2465 });
2466 $("#bottle_priming_water").on('change', function (event) {
2467 dataRecord.bottle_priming_water = parseFloat(event.args.value);
2468 calcCarbonation();
2469 });
2444 $('#keg_amount').on('change', function (event) { 2470 $('#keg_amount').on('change', function (event) {
2445 var vnew = parseFloat(event.args.value); 2471 var vnew = parseFloat(event.args.value);
2446 var vtot = dataRecord.package_volume + dataRecord.package_infuse_amount; 2472 var vtot = dataRecord.package_volume + dataRecord.package_infuse_amount;
2447 if (vnew > vtot) 2473 if (vnew > vtot)
2448 vnew = vtot; 2474 vnew = vtot;
2449 diff = dataRecord.keg_amount - vnew; 2475 diff = dataRecord.keg_amount - vnew;
2450 dataRecord.bottle_amount = Math.round((dataRecord.bottle_amount + diff) * 1000) / 1000; 2476 dataRecord.bottle_amount = Math.round((dataRecord.bottle_amount + diff) * 1000) / 1000;
2451 dataRecord.keg_amount = Math.round((dataRecord.keg_amount - diff) * 1000) / 1000; 2477 dataRecord.keg_amount = Math.round((dataRecord.keg_amount - diff) * 1000) / 1000;
2452 $('#bottle_amount').val(parseFloat(dataRecord.bottle_amount)); 2478 $('#bottle_amount').val(parseFloat(dataRecord.bottle_amount));
2453 $('#keg_amount').val(parseFloat(dataRecord.keg_amount)); 2479 $('#keg_amount').val(parseFloat(dataRecord.keg_amount));
2480 calcCarbonation();
2481 });
2482 $("#keg_priming_water").on('change', function (event) {
2483 dataRecord.keg_priming_water = parseFloat(event.args.value);
2454 calcCarbonation(); 2484 calcCarbonation();
2455 }); 2485 });
2456 $('#bottle_carbonation').on('change', function (event) { 2486 $('#bottle_carbonation').on('change', function (event) {
2457 dataRecord.bottle_carbonation = parseFloat(event.args.value); 2487 dataRecord.bottle_carbonation = parseFloat(event.args.value);
2458 calcCarbonation(); 2488 calcCarbonation();

mercurial