www/js/prod_edit.js

changeset 237
9337b5ff8698
parent 236
4b8e5478d08f
child 240
a85c1d4c4d12
equal deleted inserted replaced
236:4b8e5478d08f 237:9337b5ff8698
1083 $("#keg_priming_amount").val(Math.round(dataRecord.keg_priming_amount * 10) / 10); 1083 $("#keg_priming_amount").val(Math.round(dataRecord.keg_priming_amount * 10) / 10);
1084 $("#keg_priming_total").val(Math.round(dataRecord.keg_amount * dataRecord.keg_priming_amount * 10) / 10); 1084 $("#keg_priming_total").val(Math.round(dataRecord.keg_amount * dataRecord.keg_priming_amount * 10) / 10);
1085 } 1085 }
1086 1086
1087 $("#keg_abv").val(Math.round((ABV + Amount * 0.47 / 7.907) * 10) / 10); 1087 $("#keg_abv").val(Math.round((ABV + Amount * 0.47 / 7.907) * 10) / 10);
1088 }
1089
1090 function calcStage() {
1091
1092 var newstage = dataRecord.stage;
1093
1094 if (newstage < 2 && dataRecord.brew_date_start != '')
1095 newstage = 2; // Brewday
1096 if (newstage < 3 && dataRecord.brew_date_end != '')
1097 newstage = 3; // Primary
1098 if (newstage < 4 && dataRecord.primary_end_date != '')
1099 newstage = 4; // Secondary
1100 if (newstage < 5 && dataRecord.secondary_end_date != '')
1101 newstage = 5; // Tertiary
1102 if (newstage < 6 && dataRecord.package_date != '')
1103 newstage = 6; // Package
1104 if (newstage >= 6 && newstage < 10) {
1105 var d = new Date();
1106 var date2 = dataRecord.package_date;
1107 date2 = date2.split('-');
1108 // Now we convert the array to a Date object
1109 date1 = new Date(d.getFullYear(), d.getMonth(), d.getDate());
1110 date2 = new Date(date2[0], date2[1]-1, date2[2]);
1111 // We use the getTime() method and get the unixtime
1112 date1_unixtime = parseInt(date1.getTime() / 1000);
1113 date2_unixtime = parseInt(date2.getTime() / 1000);
1114 // This is the calculated difference in seconds
1115 var timeDifference = date1_unixtime - date2_unixtime;
1116 var timeDifferenceInDays = timeDifference / 60 / 60 / 24;
1117 console.log(date1+' '+date2+' days: '+timeDifferenceInDays);
1118 if (newstage < 7 && timeDifferenceInDays < 14) // Carbonation period
1119 newstage = 7;
1120 else if (newstage < 8 && timeDifferenceInDays < 42) // Mature 6 weeks
1121 newstage = 8;
1122 else
1123 newstage = 9;
1124 }
1125 if (newstage < 10 && dataRecord.taste_date != '')
1126 newstage = 10; // Ready
1127
1128
1129 console.log("calcStage() now: "+dataRecord.stage+" new: "+newstage);
1130
1131 /*
1132 * Set stage and enable or disable parts of the screens.
1133 */
1134 $("#stage").val(StageData[dataRecord.stage].nl);
1135 if (dataRecord.stage >= 10) {
1136 $("#locked").jqxCheckBox({ disabled:false });
1137 }
1138
1139 /*
1140 * When the brew is in progress or done, block equipment select.
1141 */
1142 if (dataRecord.stage > 1)
1143 $("#equipmentSelect").jqxDropDownList({ disabled: true });
1144 if (dataRecord.stage > 0) {
1145 $("#Delete").jqxButton({ disabled: true });
1146 }
1147 if (dataRecord.stage < 3) { // Primary
1148 $('#jqxTabs').jqxTabs('disableAt', 9); // Fermentation tab
1149 // If recipe not complete, disable 8 too.
1150 } else {
1151 $('#jqxTabs').jqxTabs('enableAt', 9);
1152 }
1153 if (dataRecord.stage < 4) { // At least primary
1154 $('#jqxTabs').jqxTabs('disableAt', 10); // Packaging tab
1155 } else {
1156 $('#jqxTabs').jqxTabs('enableAt', 10);
1157 }
1158 if (dataRecord.stage < 6) { // Not yet packaged
1159 $("#inventory_reduced").jqxCheckBox({ disabled : true });
1160 } else {
1161 if ($('#inventory_reduced').jqxCheckBox('checked'))
1162 $("#inventory_reduced").jqxCheckBox({ disabled : true });
1163 }
1164 if (dataRecord.stage < 8) { // Taste when at least Mature.
1165 $('#jqxTabs').jqxTabs('disableAt', 11); // Tasting tab
1166 } else {
1167 $('#jqxTabs').jqxTabs('enableAt', 11);
1168 }
1088 } 1169 }
1089 1170
1090 function calcInit () { 1171 function calcInit () {
1091 console.log("calcInit()"); 1172 console.log("calcInit()");
1092 1173
1609 dataRecord = records[0]; 1690 dataRecord = records[0];
1610 // Hidden record uuid 1691 // Hidden record uuid
1611 $("#name").val(dataRecord.name); 1692 $("#name").val(dataRecord.name);
1612 $("#code").val(dataRecord.code); 1693 $("#code").val(dataRecord.code);
1613 $("#birth").val(dataRecord.birth); 1694 $("#birth").val(dataRecord.birth);
1614 $("#stage").val(dataRecord.stage); 1695 $("#stage").val(StageData[dataRecord.stage].nl);
1615 $("#notes").val(dataRecord.notes); 1696 $("#notes").val(dataRecord.notes);
1616 $("#inventory_reduced").val(dataRecord.inventory_reduced); 1697 $("#inventory_reduced").val(dataRecord.inventory_reduced);
1617 $("#locked").val(dataRecord.locked); 1698 $("#locked").val(dataRecord.locked);
1618 $("#eq_name").val(dataRecord.eq_name); 1699 $("#eq_name").val(dataRecord.eq_name);
1619 $("#eq_notes").val(dataRecord.eq_notes); 1700 $("#eq_notes").val(dataRecord.eq_notes);
1784 editFermentable(dataRecord); 1865 editFermentable(dataRecord);
1785 editHop(dataRecord); 1866 editHop(dataRecord);
1786 editMisc(dataRecord); 1867 editMisc(dataRecord);
1787 editYeast(dataRecord); 1868 editYeast(dataRecord);
1788 editMash(dataRecord); 1869 editMash(dataRecord);
1789 1870 calcStage();
1790 if (dataRecord.stage >= 10) {
1791 $("#locked").jqxCheckBox({ disabled:false });
1792 }
1793 // Enable or Disable settings depending on the stage.
1794 if (dataRecord.stage > 1)
1795 $("#equipmentSelect").jqxDropDownList({ disabled: true });
1796 if (dataRecord.stage > 0) {
1797 $("#Delete").jqxButton({ disabled: true });
1798 }
1799 if (dataRecord.stage < 3) {
1800 $('#jqxTabs').jqxTabs('disableAt', 9);
1801 // If recipe not complete, disable 8 too.
1802 } else {
1803 $('#jqxTabs').jqxTabs('enableAt', 9);
1804 }
1805 if (dataRecord.stage < 4) { // At least primary
1806 $('#jqxTabs').jqxTabs('disableAt', 10);
1807 } else {
1808 $('#jqxTabs').jqxTabs('enableAt', 10);
1809 }
1810 if (dataRecord.stage < 6) {
1811 $("#inventory_reduced").jqxCheckBox({ disabled : true });
1812 } else {
1813 if ($('#inventory_reduced').jqxCheckBox('checked'))
1814 $("#inventory_reduced").jqxCheckBox({ disabled : true });
1815 }
1816 if (dataRecord.stage < 8) { // Taste when at least Mature.
1817 $('#jqxTabs').jqxTabs('disableAt', 11);
1818 } else {
1819 $('#jqxTabs').jqxTabs('enableAt', 11);
1820 }
1821
1822 $('#jqxTabs').jqxTabs('select', 2); 1871 $('#jqxTabs').jqxTabs('select', 2);
1823 }, 1872 },
1824 loadError: function (jqXHR, status, error) { 1873 loadError: function (jqXHR, status, error) {
1825 }, 1874 },
1826 beforeLoadComplete: function (records) { 1875 beforeLoadComplete: function (records) {
3872 window.open(url); 3921 window.open(url);
3873 }); 3922 });
3874 3923
3875 // Tab 10, Fermentation 3924 // Tab 10, Fermentation
3876 // Note, fermentation temps changes must do calcCarbonation() 3925 // Note, fermentation temps changes must do calcCarbonation()
3877 $("#brew_fermenter_sg2").jqxNumberInput({ inputMode: 'simple', readOnly: true, theme: theme, width: 70, height: 23, decimalDigits: 3 }); 3926 $("#brew_fermenter_sg2").jqxNumberInput({ inputMode: 'simple', readOnly: true, theme: theme, width: 90, height: 23, decimalDigits: 3 });
3878 $("#primary_start_temp").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 90, height: 23, min: 0, max: 40, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.5 }); 3927 $("#primary_start_temp").jqxNumberInput( YeastT );
3879 $("#primary_max_temp").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 90, height: 23, min: 0, max: 40, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.5 }); 3928 $("#primary_max_temp").jqxNumberInput( YeastT );
3880 $("#primary_end_temp").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 90, height: 23, min: 0, max: 40, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.5 }); 3929 $("#primary_end_temp").jqxNumberInput( YeastT );
3881 $("#primary_end_sg").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 90, height: 23, min: 0.990, max: 1.2, decimalDigits: 3, spinButtons: true, spinButtonsStep: 0.001 }); 3930 $("#primary_end_sg").jqxNumberInput( SGopts );
3882 $("#primary_svg").jqxNumberInput({ inputMode: 'simple', readOnly: true, theme: theme, width: 70, height: 23, decimalDigits: 1 }); 3931 $("#primary_svg").jqxNumberInput({ inputMode: 'simple', readOnly: true, theme: theme, width: 70, height: 23, decimalDigits: 1 });
3883 $("#primary_end_date").jqxTooltip({ content: 'De eind datum van de hoofdvergisting en eventueel overhevelen.' }); 3932 $("#primary_end_date").jqxTooltip({ content: 'De eind datum van de hoofdvergisting en eventueel overhevelen.' });
3884 $("#primary_end_date").jqxDateTimeInput({ 3933 $("#primary_end_date").jqxDateTimeInput( Dateopts );
3885 theme: theme, 3934 $("#secondary_temp").jqxNumberInput( YeastT );
3886 width: 150,
3887 height: 23,
3888 allowNullDate: true,
3889 todayString: 'Vandaag',
3890 clearString: 'Wissen',
3891 showFooter: true,
3892 formatString: 'yyyy-MM-dd'
3893 });
3894 $("#secondary_temp").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 90, height: 23, min: 0, max: 40, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.5 });
3895 $("#secondary_end_date").jqxTooltip({ content: 'De eind datum van de navergisting en het begin van het lageren.' }); 3935 $("#secondary_end_date").jqxTooltip({ content: 'De eind datum van de navergisting en het begin van het lageren.' });
3896 $("#secondary_end_date").jqxDateTimeInput({ 3936 $("#secondary_end_date").jqxDateTimeInput( Dateopts );
3897 theme: theme, 3937 $("#tertiary_temp").jqxNumberInput( YeastT );
3898 width: 150,
3899 height: 23,
3900 allowNullDate: true,
3901 todayString: 'Vandaag',
3902 clearString: 'Wissen',
3903 showFooter: true,
3904 formatString: 'yyyy-MM-dd'
3905 });
3906 $("#tertiary_temp").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 90, height: 23, min: 0, max: 40, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.5 });
3907 $("#fg").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 90, height: 23, min: 0, decimalDigits: 3, spinButtons: true, spinButtonsStep: 0.001 }); 3938 $("#fg").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 90, height: 23, min: 0, decimalDigits: 3, spinButtons: true, spinButtonsStep: 0.001 });
3908 $("#final_abv").jqxNumberInput({ inputMode: 'simple', readOnly: true, theme: theme, width: 70, height: 23, decimalDigits: 1 }); 3939 $("#final_abv").jqxNumberInput({ inputMode: 'simple', readOnly: true, theme: theme, width: 70, height: 23, decimalDigits: 1 });
3909 $("#final_svg").jqxNumberInput({ inputMode: 'simple', readOnly: true, theme: theme, width: 70, height: 23, decimalDigits: 1 }); 3940 $("#final_svg").jqxNumberInput({ inputMode: 'simple', readOnly: true, theme: theme, width: 70, height: 23, decimalDigits: 1 });
3910 $("#FLog").jqxButton({ template: "info", width: '150px', theme: theme }); 3941 $("#FLog").jqxButton({ template: "info", width: '150px', theme: theme });
3911 $("#FLog").click(function () { 3942 $("#FLog").click(function () {
3915 }); 3946 });
3916 3947
3917 // Tab 11, Packaging 3948 // Tab 11, Packaging
3918 // TODO: high gravity packaging, extra water and recalc abv, color and ibu. 3949 // TODO: high gravity packaging, extra water and recalc abv, color and ibu.
3919 $("#package_date").jqxTooltip({ content: 'De verpakkings datum van dit bier.' }); 3950 $("#package_date").jqxTooltip({ content: 'De verpakkings datum van dit bier.' });
3920 $("#package_date").jqxDateTimeInput({ 3951 $("#package_date").jqxDateTimeInput( Dateopts );
3921 theme: theme,
3922 width: 150,
3923 height: 23,
3924 allowNullDate: true,
3925 todayString: 'Vandaag',
3926 clearString: 'Wissen',
3927 showFooter: true,
3928 formatString: 'yyyy-MM-dd'
3929 });
3930 $("#st_carb_min2").jqxTooltip({ content: 'Het minimum aanbevolen koolzuur volume voor deze bierstijl.'}); 3952 $("#st_carb_min2").jqxTooltip({ content: 'Het minimum aanbevolen koolzuur volume voor deze bierstijl.'});
3931 $("#st_carb_min2").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 1, readOnly: true }); 3953 $("#st_carb_min2").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 1, readOnly: true });
3932 $("#st_carb_max2").jqxTooltip({ content: 'Het maximum aamnevolen koolzuur volume voor deze bierstijl.'}); 3954 $("#st_carb_max2").jqxTooltip({ content: 'Het maximum aamnevolen koolzuur volume voor deze bierstijl.'});
3933 $("#st_carb_max2").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 1, readOnly: true }); 3955 $("#st_carb_max2").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 50, height: 23, decimalDigits: 1, readOnly: true });
3934 $("#bottle_amount").jqxTooltip({ content: 'De totale hoeveelheid te bottelen bier.' }); 3956 $("#bottle_amount").jqxTooltip({ content: 'De totale hoeveelheid te bottelen bier.' });
3935 $("#bottle_amount").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 90, height: 23, min: 0, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.5 }); 3957 $("#bottle_amount").jqxNumberInput( Spin1dec5 );
3936 $("#keg_amount").jqxTooltip({ content: 'De totale hoeveelheid op fust te zetten bier.' }); 3958 $("#keg_amount").jqxTooltip({ content: 'De totale hoeveelheid op fust te zetten bier.' });
3937 $("#keg_amount").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 90, height: 23, min: 0, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.5 }); 3959 $("#keg_amount").jqxNumberInput( Spin1dec5 );
3938 $("#bottle_carbonation").jqxTooltip({ content: 'Het gewenste CO2 volume in de flessen.' }); 3960 $("#bottle_carbonation").jqxTooltip({ content: 'Het gewenste CO2 volume in de flessen.' });
3939 $("#bottle_carbonation").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 90, height: 23, min: 0, max: 5, decimalDigits: 2, spinButtons: true, spinButtonsStep: 0.05 }); 3961 $("#bottle_carbonation").jqxNumberInput( Spin2dec5 );
3962 $("#bottle_carbonation").jqxNumberInput({ max: 5 });
3940 $("#keg_carbonation").jqxTooltip({ content: 'Het gewenste CO2 volume door de suiker in de fusten.' }); 3963 $("#keg_carbonation").jqxTooltip({ content: 'Het gewenste CO2 volume door de suiker in de fusten.' });
3941 $("#keg_carbonation").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 90, height: 23, min: 0, max: 5, decimalDigits: 2, spinButtons: true, spinButtonsStep: 0.05 }); 3964 $("#keg_carbonation").jqxNumberInput( Spin2dec5 );
3942 $("#bottle_priming_sugar").jqxDropDownList({ theme: theme, source: srcSugar, width: 175, height: 23, dropDownHeight: 150 }); 3965 $("#keg_carbonation").jqxNumberInput({ max: 5 });
3943 $("#keg_priming_sugar").jqxDropDownList({ theme: theme, source: srcSugar, width: 175, height: 23, dropDownHeight: 150 }); 3966 $("#bottle_priming_sugar").jqxDropDownList({
3944 $("#bottle_priming_amount").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 70, height: 23, decimalDigits: 1, readOnly: true }); 3967 theme: theme,
3945 $("#keg_priming_amount").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 70, height: 23, decimalDigits: 1, readOnly: true }); 3968 source: PrimingSugarAdapter,
3946 $("#bottle_priming_total").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 70, height: 23, decimalDigits: 1, readOnly: true }); 3969 valueMember: 'id',
3947 $("#keg_priming_total").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 70, height: 23, decimalDigits: 1, readOnly: true }); 3970 displayMember: 'nl',
3971 width: 180,
3972 height: 23,
3973 autoDropDownHeight: true
3974 });
3975 $("#keg_priming_sugar").jqxDropDownList({
3976 theme: theme,
3977 source: PrimingSugarAdapter,
3978 valueMember: 'id',
3979 displayMember: 'nl',
3980 width: 180,
3981 height: 23,
3982 autoDropDownHeight: true
3983 });
3984 $("#bottle_priming_amount").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 90, height: 23, decimalDigits: 1, readOnly: true });
3985 $("#keg_priming_amount").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 90, height: 23, decimalDigits: 1, readOnly: true });
3986 $("#bottle_priming_total").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 90, height: 23, decimalDigits: 1, readOnly: true });
3987 $("#keg_priming_total").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 90, height: 23, decimalDigits: 1, readOnly: true });
3948 $("#keg_forced_carb").jqxCheckBox({ theme: theme, width: 120, height: 23 }); 3988 $("#keg_forced_carb").jqxCheckBox({ theme: theme, width: 120, height: 23 });
3949 $("#keg_pressure").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 70, height: 23, decimalDigits: 1, readOnly: true }); 3989 $("#keg_pressure").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 90, height: 23, decimalDigits: 1, readOnly: true });
3950 $("#bottle_abv").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 70, height: 23, decimalDigits: 1, readOnly: true }); 3990 $("#bottle_abv").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 90, height: 23, decimalDigits: 1, readOnly: true });
3951 $("#keg_abv").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 70, height: 23, decimalDigits: 1, readOnly: true }); 3991 $("#keg_abv").jqxNumberInput({ inputMode: 'simple', theme: theme, width: 90, height: 23, decimalDigits: 1, readOnly: true });
3952 $("#bottle_carbonation_temp").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 90, height: 23, min: 0.5, max: 40, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.5 }); 3992 $("#bottle_carbonation_temp").jqxNumberInput( YeastT );
3953 $("#keg_carbonation_temp").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 90, height: 23, min: 0.5, max: 40, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.5 }); 3993 $("#keg_carbonation_temp").jqxNumberInput( YeastT );
3954 3994
3955 // Tab 12, Tasting 3995 // Tab 12, Tasting
3956 $("#taste_date").jqxTooltip({ content: 'De proef datum van dit bier.' }); 3996 $("#taste_date").jqxTooltip({ content: 'De proef datum van dit bier.' });
3957 $("#taste_date").jqxDateTimeInput({ 3997 $("#taste_date").jqxDateTimeInput( Dateopts );
3958 theme: theme,
3959 width: 150,
3960 height: 23,
3961 allowNullDate: true,
3962 todayString: 'Vandaag',
3963 clearString: 'Wissen',
3964 showFooter: true,
3965 formatString: 'yyyy-MM-dd'
3966 });
3967 $("#taste_rate").jqxTooltip({ content: 'Het cijfer voor dit bier van 1 tot 10.' }); 3998 $("#taste_rate").jqxTooltip({ content: 'Het cijfer voor dit bier van 1 tot 10.' });
3968 $("#taste_rate").jqxNumberInput({ inputMode: 'simple', spinMode: 'simple', theme: theme, width: 100, height: 23, min: 1, max: 10, decimalDigits: 1, spinButtons: true, spinButtonsStep: 0.5 }); 3999 $("#taste_rate").jqxNumberInput( Spin1dec5 );
4000 $("#taste_rate").jqxNumberInput({ max: 10 });
3969 $("#taste_color").jqxTooltip({ content: 'De kleur van het bier.' }); 4001 $("#taste_color").jqxTooltip({ content: 'De kleur van het bier.' });
3970 $("#taste_color").jqxInput({ theme: theme, width: 320, height: 23 }); 4002 $("#taste_color").jqxInput({ theme: theme, width: 320, height: 23 });
3971 $("#taste_transparency").jqxTooltip({ content: 'De helderheid van het bier.' }); 4003 $("#taste_transparency").jqxTooltip({ content: 'De helderheid van het bier.' });
3972 $("#taste_transparency").jqxInput({ theme: theme, width: 320, height: 23 }); 4004 $("#taste_transparency").jqxInput({ theme: theme, width: 320, height: 23 });
3973 $("#taste_head").jqxTooltip({ content: 'Het schuim op het bier.' }); 4005 $("#taste_head").jqxTooltip({ content: 'Het schuim op het bier.' });

mercurial