www/js/prod_edit.js

changeset 318
882d4da1f236
parent 317
454851b335ad
child 322
167f3144210d
equal deleted inserted replaced
317:454851b335ad 318:882d4da1f236
882 }; 882 };
883 883
884 884
885 885
886 function calcMashEfficiency() { 886 function calcMashEfficiency() {
887 // console.log("calcMashEfficiency()"); 887 if (parseFloat($("#brew_mash_sg").jqxNumberInput('decimal')) < 1.002)
888 return;
888 var c = sg_to_plato(est_mash_sg); 889 var c = sg_to_plato(est_mash_sg);
889 var m = sg_to_plato(parseFloat($("#brew_mash_sg").jqxNumberInput('decimal'))); 890 var m = sg_to_plato(parseFloat($("#brew_mash_sg").jqxNumberInput('decimal')));
890 // console.log("c "+ c + " m " + m + " in " + parseFloat($("#brew_mash_sg").jqxNumberInput('decimal'))); 891 //console.log("calcMashEfficiency() c "+ c + " m " + m + " in " + parseFloat($("#brew_mash_sg").jqxNumberInput('decimal')));
891 if (c > 0.5) 892 if (c > 0.5)
892 $("#brew_mash_efficiency").val(100 * m / c); 893 $("#brew_mash_efficiency").val(100 * m / c);
893 else 894 else
894 $("#brew_mash_efficiency").val(0); 895 $("#brew_mash_efficiency").val(0);
895 }; 896 };
905 if (row.f_added == 0) { // Mash 906 if (row.f_added == 0) { // Mash
906 m += row.f_amount * (row.f_yield / 100) * (1 - row.f_moisture / 100); 907 m += row.f_amount * (row.f_yield / 100) * (1 - row.f_moisture / 100);
907 } 908 }
908 } 909 }
909 var tot = sg_to_plato(dataRecord.brew_preboil_sg) * (dataRecord.brew_preboil_volume / 1.04) * dataRecord.brew_preboil_sg * 10 / 1000; 910 var tot = sg_to_plato(dataRecord.brew_preboil_sg) * (dataRecord.brew_preboil_volume / 1.04) * dataRecord.brew_preboil_sg * 10 / 1000;
911 var result = 0;
910 if (m > 0) 912 if (m > 0)
911 var result = Math.round((tot / m * 100) * 10) / 10; 913 result = Math.round((tot / m * 100) * 10) / 10;
912 else
913 var result = 0;
914 if (result < 0) 914 if (result < 0)
915 result = 0; 915 result = 0;
916 //console.log("calcEfficiencyBeforeBoil(): "+result); 916 //console.log("calcEfficiencyBeforeBoil(): "+result);
917 $("#brew_preboil_efficiency").val(result); 917 $("#brew_preboil_efficiency").val(result);
918 } 918 }
932 b += row.f_amount * (row.f_yield / 100) * (1 - row.f_moisture / 100); 932 b += row.f_amount * (row.f_yield / 100) * (1 - row.f_moisture / 100);
933 } 933 }
934 } 934 }
935 var tot = sg_to_plato(dataRecord.brew_aboil_sg) * (dataRecord.brew_aboil_volume / 1.04) * dataRecord.brew_aboil_sg * 10 / 1000; 935 var tot = sg_to_plato(dataRecord.brew_aboil_sg) * (dataRecord.brew_aboil_volume / 1.04) * dataRecord.brew_aboil_sg * 10 / 1000;
936 tot -= b; // total sugars in wort minus added sugars. 936 tot -= b; // total sugars in wort minus added sugars.
937 var result = 0;
937 if (m > 0) 938 if (m > 0)
938 var result = Math.round((tot / m * 100) * 10) / 10; 939 result = Math.round((tot / m * 100) * 10) / 10;
939 else
940 var result = 0;
941 if (result < 0) 940 if (result < 0)
942 result = 0; 941 result = 0;
943 //console.log("calcEfficiencyAfterBoil(): "+result); 942 //console.log("calcEfficiencyAfterBoil(): "+result);
944 dataRecord.brew_aboil_efficiency = result; 943 dataRecord.brew_aboil_efficiency = result;
945 $("#brew_aboil_efficiency").val(result); 944 $("#brew_aboil_efficiency").val(result);
1715 /* parseFloat$("#brew_date_start").val()) returns the year if it is a valid mysql style date. */ 1714 /* parseFloat$("#brew_date_start").val()) returns the year if it is a valid mysql style date. */
1716 if (newstage == 0 && dataRecord.est_og > 1.005 && dataRecord.est_color > 3 && dataRecord.est_ibu > 3) 1715 if (newstage == 0 && dataRecord.est_og > 1.005 && dataRecord.est_color > 3 && dataRecord.est_ibu > 3)
1717 newstage = 1; 1716 newstage = 1;
1718 if (newstage == 1 && parseFloat($("#brew_date_start").val()) > 2000) 1717 if (newstage == 1 && parseFloat($("#brew_date_start").val()) > 2000)
1719 newstage = 2; // Brewday 1718 newstage = 2; // Brewday
1719 if (newstage == 2 && ($("#brew_date_start").val() == ''))
1720 newstage = 1; // No brewday
1720 if (newstage == 2 && parseFloat($("#brew_date_end").val()) > 2000) 1721 if (newstage == 2 && parseFloat($("#brew_date_end").val()) > 2000)
1721 newstage = 3; // Primary 1722 newstage = 3; // Primary
1722 if (newstage == 3 && parseFloat($("#primary_end_date").val()) > 2000) 1723 if (newstage == 3 && parseFloat($("#primary_end_date").val()) > 2000)
1723 newstage = 4; // Secondary 1724 newstage = 4; // Secondary
1724 if (newstage == 4 && parseFloat($("#secondary_end_date").val()) > 2000) 1725 if (newstage == 4 && parseFloat($("#secondary_end_date").val()) > 2000)
1749 } 1750 }
1750 } 1751 }
1751 if (newstage == 9 && parseFloat($("#taste_date").val()) > 2000) 1752 if (newstage == 9 && parseFloat($("#taste_date").val()) > 2000)
1752 newstage = 10; // Ready 1753 newstage = 10; // Ready
1753 1754
1754 if (newstage > dataRecord.stage) { 1755 if (newstage != dataRecord.stage) {
1755 console.log("calcStage() old: "+dataRecord.stage+" new: "+newstage); 1756 console.log("calcStage() old: "+dataRecord.stage+" new: "+newstage);
1756 dataRecord.stage = newstage; 1757 dataRecord.stage = newstage;
1757 } 1758 }
1758 1759
1759 /* 1760 /*

mercurial