Save data before printing or export to beerxml

Mon, 11 Feb 2019 21:25:29 +0100

author
Michiel Broek <mbroek@mbse.eu>
date
Mon, 11 Feb 2019 21:25:29 +0100
changeset 271
af0270694d1e
parent 270
cf4b4b63eb36
child 272
0c2ea1c2b858

Save data before printing or export to beerxml

www/js/prod_edit.js file | annotate | diff | comparison | revisions
www/js/rec_edit.js file | annotate | diff | comparison | revisions
--- a/www/js/prod_edit.js	Mon Feb 11 20:56:17 2019 +0100
+++ b/www/js/prod_edit.js	Mon Feb 11 21:25:29 2019 +0100
@@ -1759,6 +1759,198 @@
 		}
 	});
 
+	function saveRecord() {
+		console.log("saveRecord()");
+
+		console.log(dataRecord.uuid);
+		var fermentablerow = $('#fermentableGrid').jqxGrid('getrows');
+		var hoprow = $('#hopGrid').jqxGrid('getrows');
+		var miscrow = $('#miscGrid').jqxGrid('getrows');
+		var yeastrow = $('#yeastGrid').jqxGrid('getrows');
+		var mashrow = $('#mashGrid').jqxGrid('getrows');
+		var row = {
+			record: my_record,
+			uuid: dataRecord.uuid,
+			name: $("#name").val(),
+			code: $("#code").val(),
+			birth: $("#birth").val(),
+			stage: dataRecord.stage,
+			notes: $("#notes").val(),
+			log_brew: dataRecord.log_brew,
+			log_fermentation: dataRecord.log_fermentation,
+			inventory_reduced: dataRecord.inventory_reduced,
+			locked: dataRecord.locked,
+			eq_name: $("#eq_name").val(),
+			eq_boil_size: parseFloat($("#eq_boil_size").jqxNumberInput('decimal')),
+			eq_batch_size: parseFloat($("#eq_batch_size").jqxNumberInput('decimal')),
+			eq_tun_volume: parseFloat($("#eq_tun_volume").jqxNumberInput('decimal')),
+			eq_tun_weight: dataRecord.eq_tun_weight,
+			eq_tun_specific_heat: dataRecord.eq_tun_specific_heat,
+			eq_tun_material: dataRecord.eq_tun_material,
+			eq_tun_height: dataRecord.eq_tun_height,
+			eq_top_up_water: parseFloat($("#eq_top_up_water").jqxNumberInput('decimal')),
+			eq_trub_chiller_loss: parseFloat($("#eq_trub_chiller_loss").jqxNumberInput('decimal')),
+			eq_evap_rate: parseFloat($("#eq_evap_rate").jqxNumberInput('decimal')),
+			eq_boil_time: parseFloat($("#eq_boil_time").jqxNumberInput('decimal')),
+			eq_calc_boil_volume: dataRecord.eq_calc_boil_volume,
+			eq_top_up_kettle: parseFloat($("#eq_top_up_kettle").jqxNumberInput('decimal')),
+			eq_hop_utilization: parseFloat($("#eq_hop_utilization").jqxNumberInput('decimal')),
+			eq_notes: $("#eq_notes").val(),
+			eq_lauter_volume: parseFloat($("#eq_lauter_volume").jqxNumberInput('decimal')),
+			eq_lauter_height: dataRecord.eq_lauter_height,
+			eq_lauter_deadspace: parseFloat($("#eq_lauter_deadspace").jqxNumberInput('decimal')),
+			eq_kettle_volume: parseFloat($("#eq_kettle_volume").jqxNumberInput('decimal')),
+			eq_kettle_height: dataRecord.eq_kettle_height,
+			eq_mash_volume: parseFloat($("#eq_mash_volume").jqxNumberInput('decimal')),
+			eq_mash_max: parseFloat($("#eq_mash_max").jqxNumberInput('decimal')),
+			eq_efficiency: parseFloat($("#eq_efficiency").jqxNumberInput('decimal')),
+			brew_date_start: $("#brew_date_start").val(),
+			brew_mash_ph: parseFloat($("#brew_mash_ph").jqxNumberInput('decimal')),
+			brew_mash_sg: parseFloat($("#brew_mash_sg").jqxNumberInput('decimal')),
+			brew_sparge_temperature: parseFloat($("#brew_sparge_temperature").jqxNumberInput('decimal')),
+			brew_sparge_volume: parseFloat($("#brew_sparge_volume").jqxNumberInput('decimal')),
+			brew_sparge_ph: parseFloat($("#brew_sparge_ph").jqxNumberInput('decimal')),
+			brew_preboil_volume: parseFloat($("#brew_preboil_volume").jqxNumberInput('decimal')),
+			brew_preboil_sg: parseFloat($("#brew_preboil_sg").jqxNumberInput('decimal')),
+			brew_preboil_ph: parseFloat($("#brew_preboil_ph").jqxNumberInput('decimal')),
+			brew_aboil_volume: parseFloat($("#brew_aboil_volume").jqxNumberInput('decimal')),
+			brew_aboil_sg: parseFloat($("#brew_aboil_sg").jqxNumberInput('decimal')),
+			brew_aboil_ph: parseFloat($("#brew_aboil_ph").jqxNumberInput('decimal')),
+			brew_aboil_efficiency: parseFloat($("#brew_aboil_efficiency").jqxNumberInput('decimal')),
+			brew_cooling_method: $("#brew_cooling_method").val(),
+			brew_cooling_time: parseFloat($("#brew_cooling_time").jqxNumberInput('decimal')),
+			brew_cooling_to: parseFloat($("#brew_cooling_to").jqxNumberInput('decimal')),
+			brew_whirlpool9: parseFloat($("#brew_whirlpool9").jqxNumberInput('decimal')),
+			brew_whirlpool7: parseFloat($("#brew_whirlpool7").jqxNumberInput('decimal')),
+			brew_whirlpool6: parseFloat($("#brew_whirlpool6").jqxNumberInput('decimal')),
+			brew_whirlpool2: parseFloat($("#brew_whirlpool2").jqxNumberInput('decimal')),
+			brew_fermenter_volume: parseFloat($("#brew_fermenter_volume").jqxNumberInput('decimal')),
+			brew_fermenter_extrawater: parseFloat($("#brew_fermenter_extrawater").jqxNumberInput('decimal')),
+			brew_fermenter_tcloss: parseFloat($("#brew_fermenter_tcloss").jqxNumberInput('decimal')),
+			brew_aeration_time: parseFloat($("#brew_aeration_time").jqxNumberInput('decimal')),
+			brew_aeration_speed: parseFloat($("#brew_aeration_speed").jqxNumberInput('decimal')),
+			brew_aeration_type: $("#brew_aeration_type").val(),
+			brew_fermenter_sg: parseFloat($("#brew_fermenter_sg").jqxNumberInput('decimal')),
+			brew_fermenter_ibu: parseFloat($("#brew_fermenter_ibu").jqxNumberInput('decimal')),
+			brew_fermenter_color: parseFloat($("#brew_fermenter_color").jqxNumberInput('decimal')),
+			brew_date_end: $("#brew_date_end").val(),
+			og: dataRecord.og,
+			fg: parseFloat($("#fg").jqxNumberInput('decimal')),
+			primary_start_temp: parseFloat($("#primary_start_temp").jqxNumberInput('decimal')),
+			primary_max_temp: parseFloat($("#primary_max_temp").jqxNumberInput('decimal')),
+			primary_end_temp: parseFloat($("#primary_end_temp").jqxNumberInput('decimal')),
+			primary_end_sg: parseFloat($("#primary_end_sg").jqxNumberInput('decimal')),
+			primary_end_date: $("#primary_end_date").val(),
+			secondary_temp: parseFloat($("#secondary_temp").jqxNumberInput('decimal')),
+			secondary_end_date: $("#secondary_end_date").val(),
+			tertiary_temp: parseFloat($("#tertiary_temp").jqxNumberInput('decimal')),
+			package_date: $("#package_date").val(),
+			bottle_amount: parseFloat($("#bottle_amount").jqxNumberInput('decimal')),
+			bottle_carbonation: parseFloat($("#bottle_carbonation").jqxNumberInput('decimal')),
+			bottle_priming_sugar: $("#bottle_priming_sugar").val(),
+			bottle_priming_amount: parseFloat($("#bottle_priming_amount").jqxNumberInput('decimal')),
+			bottle_carbonation_temp: parseFloat($("#bottle_carbonation_temp").jqxNumberInput('decimal')),
+			keg_amount: parseFloat($("#keg_amount").jqxNumberInput('decimal')),
+			keg_carbonation: parseFloat($("#keg_carbonation").jqxNumberInput('decimal')),
+			keg_priming_sugar: $("#keg_priming_sugar").val(),
+			keg_priming_amount: parseFloat($("#keg_priming_amount").jqxNumberInput('decimal')),
+			keg_carbonation_temp: parseFloat($("#keg_carbonation_temp").jqxNumberInput('decimal')),
+			keg_forced_carb: dataRecord.keg_forced_carb,
+			keg_pressure: parseFloat($("#keg_pressure").jqxNumberInput('decimal')),
+			taste_notes: $("#taste_notes").val(),
+			taste_rate: parseFloat($("#taste_rate").jqxNumberInput('decimal')),
+			taste_date: $("#taste_date").val(),
+			taste_color: $("#taste_color").val(),
+			taste_transparency: $("#taste_transparency").val(),
+			taste_head: $("#taste_head").val(),
+			taste_aroma: $("#taste_aroma").val(),
+			taste_taste: $("#taste_taste").val(),
+			taste_mouthfeel: $("#taste_mouthfeel").val(),
+			taste_aftertaste: $("#taste_aftertaste").val(),
+			st_name: $('#st_name').val(),
+			st_letter: $('#st_letter').val(),
+			st_guide: $('#st_guide').val(),
+			st_type: dataRecord.st_type,
+			st_category: $('#st_category').val(),
+			st_category_number: parseFloat($("#st_category_number").jqxNumberInput('decimal')),
+			st_og_min: parseFloat($("#st_og_min").jqxNumberInput('decimal')),
+			st_og_max: parseFloat($("#st_og_max").jqxNumberInput('decimal')),
+			st_fg_min: parseFloat($("#st_fg_min").jqxNumberInput('decimal')),
+			st_fg_max: parseFloat($("#st_fg_max").jqxNumberInput('decimal')),
+			st_ibu_min: parseFloat($("#st_ibu_min").jqxNumberInput('decimal')),
+			st_ibu_max: parseFloat($("#st_ibu_max").jqxNumberInput('decimal')),
+			st_color_min: parseFloat($("#st_color_min").jqxNumberInput('decimal')),
+			st_color_max: parseFloat($("#st_color_max").jqxNumberInput('decimal')),
+			st_carb_min: parseFloat($("#st_carb_min").jqxNumberInput('decimal')),
+			st_carb_max: parseFloat($("#st_carb_max").jqxNumberInput('decimal')),
+			st_abv_min: parseFloat($("#st_abv_min").jqxNumberInput('decimal')),
+			st_abv_max: parseFloat($("#st_abv_max").jqxNumberInput('decimal')),
+			type: $("#type").val(),
+			batch_size: parseFloat($("#batch_size").jqxNumberInput('decimal')),
+			boil_size: parseFloat($("#boil_size").jqxNumberInput('decimal')),
+			boil_time: parseFloat($("#boil_time").jqxNumberInput('decimal')),
+			efficiency: parseFloat($("#efficiency").jqxNumberInput('decimal')),
+			est_og: parseFloat($("#est_og").jqxNumberInput('decimal')),
+			est_fg: parseFloat($("#est_fg").jqxNumberInput('decimal')),
+			est_abv: parseFloat($("#est_abv").jqxNumberInput('decimal')),
+			est_color: parseFloat($("#est_color").jqxNumberInput('decimal')),
+			color_method: $("#color_method").val(),
+			est_ibu: parseFloat($("#est_ibu").jqxNumberInput('decimal')),
+			ibu_method: $("#ibu_method").val(),
+			est_carb: parseFloat($("#est_carb").jqxNumberInput('decimal')),
+			mash_name: $("#mash_name").val(),
+			mash_ph: parseFloat($("#mash_ph").jqxNumberInput('decimal')),
+			sparge_temp: parseFloat($("#sparge_temp").jqxNumberInput('decimal')),
+			sparge_ph: parseFloat($("#sparge_ph").jqxNumberInput('decimal')),
+			sparge_volume: parseFloat($("#sparge_volume").jqxNumberInput('decimal')),
+			sparge_source: $("#sparge_source").val(),
+			sparge_acid_type: $("#sparge_acid_type").val(),
+			sparge_acid_perc: parseFloat($("#sparge_acid_perc").jqxNumberInput('decimal')),
+			sparge_acid_amount: dataRecord.sparge_acid_amount,
+			calc_acid: dataRecord.calc_acid,
+			w1_name: $("#w1_name").val(),
+			w1_amount: parseFloat($("#w1_amount").jqxNumberInput('decimal')),
+			w1_calcium: parseFloat($("#w1_calcium").jqxNumberInput('decimal')),
+			w1_sulfate: parseFloat($("#w1_sulfate").jqxNumberInput('decimal')),
+			w1_chloride: parseFloat($("#w1_chloride").jqxNumberInput('decimal')),
+			w1_sodium: parseFloat($("#w1_sodium").jqxNumberInput('decimal')),
+			w1_magnesium: parseFloat($("#w1_magnesium").jqxNumberInput('decimal')),
+			w1_total_alkalinity: parseFloat($("#w1_total_alkalinity").jqxNumberInput('decimal')),
+			w1_ph: parseFloat($("#w1_ph").jqxNumberInput('decimal')),
+			w1_cost: dataRecord.w1_cost,
+			w2_name: $("#w2_name").val(),
+			w2_amount: parseFloat($("#w2_amount").jqxNumberInput('decimal')),
+			w2_calcium: parseFloat($("#w2_calcium").jqxNumberInput('decimal')),
+			w2_sulfate: parseFloat($("#w2_sulfate").jqxNumberInput('decimal')),
+			w2_chloride: parseFloat($("#w2_chloride").jqxNumberInput('decimal')),
+			w2_sodium: parseFloat($("#w2_sodium").jqxNumberInput('decimal')),
+			w2_magnesium: parseFloat($("#w2_magnesium").jqxNumberInput('decimal')),
+			w2_total_alkalinity: parseFloat($("#w2_total_alkalinity").jqxNumberInput('decimal')),
+			w2_ph: parseFloat($("#w2_ph").jqxNumberInput('decimal')),
+			w2_cost: dataRecord.w2_cost,
+			wa_acid_name: $("#wa_acid_name").val(),
+			wa_acid_perc: parseFloat($("#wa_acid_perc").jqxNumberInput('decimal')),
+			wa_base_name: $("#wa_base_name").val(),
+			fermentables: fermentablerow,
+			hops: hoprow,
+			miscs: miscrow,
+			yeasts: yeastrow,
+			mashs: mashrow
+		};
+		var data = "update=true&" + $.param(row);
+		$.ajax({
+			dataType: 'json',
+			url: url,
+			cache: false,
+			data: data,
+			type: "POST",
+			success: function (data, status, xhr) {
+			},
+			error: function(jqXHR, textStatus, errorThrown) {
+			}
+		});
+	};
+
 	var dataRecord = {};
 	var url = "includes/db_product.php";
 
@@ -4390,6 +4582,7 @@
 	// Buttons below
 	$("#Print").jqxButton({ template: "info", width: '80px', theme: theme });
 	$("#Print").click(function () {
+		saveRecord();
 		// Open print in a new tab.
 		var url="prod_print.php?record=" + my_record;
 		window.open(url);
@@ -4397,7 +4590,7 @@
 
 	$("#Export").jqxButton({ template: "info", width: '80px', theme: theme });
 	$("#Export").click(function () {
-		// Open print in a new tab.
+		saveRecord();
 		var url="prod_export.php?record=" + my_record;
 		window.open(url);
 	});
@@ -4429,197 +4622,10 @@
 		window.location.href = my_return;
 	});
 
-	$("#Save").jqxButton({ template: "success", width: '90px', theme: theme });
+	$("#Save").jqxButton({ template: "success", width: '80px', theme: theme });
 	$("#Save").click(function () {
-		console.log(dataRecord.uuid);
-		var fermentablerow = $('#fermentableGrid').jqxGrid('getrows');
-		var hoprow = $('#hopGrid').jqxGrid('getrows');
-		var miscrow = $('#miscGrid').jqxGrid('getrows');
-		var yeastrow = $('#yeastGrid').jqxGrid('getrows');
-		var mashrow = $('#mashGrid').jqxGrid('getrows');
-		var row = {
-			record: my_record,
-			uuid: dataRecord.uuid,
-			name: $("#name").val(),
-			code: $("#code").val(),
-			birth: $("#birth").val(),
-			stage: dataRecord.stage,
-			notes: $("#notes").val(),
-			log_brew: dataRecord.log_brew,
-			log_fermentation: dataRecord.log_fermentation,
-			inventory_reduced: dataRecord.inventory_reduced,
-			locked: dataRecord.locked,
-			eq_name: $("#eq_name").val(),
-			eq_boil_size: parseFloat($("#eq_boil_size").jqxNumberInput('decimal')),
-			eq_batch_size: parseFloat($("#eq_batch_size").jqxNumberInput('decimal')),
-			eq_tun_volume: parseFloat($("#eq_tun_volume").jqxNumberInput('decimal')),
-			eq_tun_weight: dataRecord.eq_tun_weight,
-			eq_tun_specific_heat: dataRecord.eq_tun_specific_heat,
-			eq_tun_material: dataRecord.eq_tun_material,
-			eq_tun_height: dataRecord.eq_tun_height,
-			eq_top_up_water: parseFloat($("#eq_top_up_water").jqxNumberInput('decimal')),
-			eq_trub_chiller_loss: parseFloat($("#eq_trub_chiller_loss").jqxNumberInput('decimal')),
-			eq_evap_rate: parseFloat($("#eq_evap_rate").jqxNumberInput('decimal')),
-			eq_boil_time: parseFloat($("#eq_boil_time").jqxNumberInput('decimal')),
-			eq_calc_boil_volume: dataRecord.eq_calc_boil_volume,
-			eq_top_up_kettle: parseFloat($("#eq_top_up_kettle").jqxNumberInput('decimal')),
-			eq_hop_utilization: parseFloat($("#eq_hop_utilization").jqxNumberInput('decimal')),
-			eq_notes: $("#eq_notes").val(),
-			eq_lauter_volume: parseFloat($("#eq_lauter_volume").jqxNumberInput('decimal')),
-			eq_lauter_height: dataRecord.eq_lauter_height,
-			eq_lauter_deadspace: parseFloat($("#eq_lauter_deadspace").jqxNumberInput('decimal')),
-			eq_kettle_volume: parseFloat($("#eq_kettle_volume").jqxNumberInput('decimal')),
-			eq_kettle_height: dataRecord.eq_kettle_height,
-			eq_mash_volume: parseFloat($("#eq_mash_volume").jqxNumberInput('decimal')),
-			eq_mash_max: parseFloat($("#eq_mash_max").jqxNumberInput('decimal')),
-			eq_efficiency: parseFloat($("#eq_efficiency").jqxNumberInput('decimal')),
-			brew_date_start: $("#brew_date_start").val(),
-			brew_mash_ph: parseFloat($("#brew_mash_ph").jqxNumberInput('decimal')),
-			brew_mash_sg: parseFloat($("#brew_mash_sg").jqxNumberInput('decimal')),
-			brew_sparge_temperature: parseFloat($("#brew_sparge_temperature").jqxNumberInput('decimal')),
-			brew_sparge_volume: parseFloat($("#brew_sparge_volume").jqxNumberInput('decimal')),
-			brew_sparge_ph: parseFloat($("#brew_sparge_ph").jqxNumberInput('decimal')),
-			brew_preboil_volume: parseFloat($("#brew_preboil_volume").jqxNumberInput('decimal')),
-			brew_preboil_sg: parseFloat($("#brew_preboil_sg").jqxNumberInput('decimal')),
-			brew_preboil_ph: parseFloat($("#brew_preboil_ph").jqxNumberInput('decimal')),
-			brew_aboil_volume: parseFloat($("#brew_aboil_volume").jqxNumberInput('decimal')),
-			brew_aboil_sg: parseFloat($("#brew_aboil_sg").jqxNumberInput('decimal')),
-			brew_aboil_ph: parseFloat($("#brew_aboil_ph").jqxNumberInput('decimal')),
-			brew_aboil_efficiency: parseFloat($("#brew_aboil_efficiency").jqxNumberInput('decimal')),
-			brew_cooling_method: $("#brew_cooling_method").val(),
-			brew_cooling_time: parseFloat($("#brew_cooling_time").jqxNumberInput('decimal')),
-			brew_cooling_to: parseFloat($("#brew_cooling_to").jqxNumberInput('decimal')),
-			brew_whirlpool9: parseFloat($("#brew_whirlpool9").jqxNumberInput('decimal')),
-			brew_whirlpool7: parseFloat($("#brew_whirlpool7").jqxNumberInput('decimal')),
-			brew_whirlpool6: parseFloat($("#brew_whirlpool6").jqxNumberInput('decimal')),
-			brew_whirlpool2: parseFloat($("#brew_whirlpool2").jqxNumberInput('decimal')),
-			brew_fermenter_volume: parseFloat($("#brew_fermenter_volume").jqxNumberInput('decimal')),
-			brew_fermenter_extrawater: parseFloat($("#brew_fermenter_extrawater").jqxNumberInput('decimal')),
-			brew_fermenter_tcloss: parseFloat($("#brew_fermenter_tcloss").jqxNumberInput('decimal')),
-			brew_aeration_time: parseFloat($("#brew_aeration_time").jqxNumberInput('decimal')),
-			brew_aeration_speed: parseFloat($("#brew_aeration_speed").jqxNumberInput('decimal')),
-			brew_aeration_type: $("#brew_aeration_type").val(),
-			brew_fermenter_sg: parseFloat($("#brew_fermenter_sg").jqxNumberInput('decimal')),
-			brew_fermenter_ibu: parseFloat($("#brew_fermenter_ibu").jqxNumberInput('decimal')),
-			brew_fermenter_color: parseFloat($("#brew_fermenter_color").jqxNumberInput('decimal')),
-			brew_date_end: $("#brew_date_end").val(),
-			og: dataRecord.og,
-			fg: parseFloat($("#fg").jqxNumberInput('decimal')),
-			primary_start_temp: parseFloat($("#primary_start_temp").jqxNumberInput('decimal')),
-			primary_max_temp: parseFloat($("#primary_max_temp").jqxNumberInput('decimal')),
-			primary_end_temp: parseFloat($("#primary_end_temp").jqxNumberInput('decimal')),
-			primary_end_sg: parseFloat($("#primary_end_sg").jqxNumberInput('decimal')),
-			primary_end_date: $("#primary_end_date").val(),
-			secondary_temp: parseFloat($("#secondary_temp").jqxNumberInput('decimal')),
-			secondary_end_date: $("#secondary_end_date").val(),
-			tertiary_temp: parseFloat($("#tertiary_temp").jqxNumberInput('decimal')),
-			package_date: $("#package_date").val(),
-			bottle_amount: parseFloat($("#bottle_amount").jqxNumberInput('decimal')),
-			bottle_carbonation: parseFloat($("#bottle_carbonation").jqxNumberInput('decimal')),
-			bottle_priming_sugar: $("#bottle_priming_sugar").val(),
-			bottle_priming_amount: parseFloat($("#bottle_priming_amount").jqxNumberInput('decimal')),
-			bottle_carbonation_temp: parseFloat($("#bottle_carbonation_temp").jqxNumberInput('decimal')),
-			keg_amount: parseFloat($("#keg_amount").jqxNumberInput('decimal')),
-			keg_carbonation: parseFloat($("#keg_carbonation").jqxNumberInput('decimal')),
-			keg_priming_sugar: $("#keg_priming_sugar").val(),
-			keg_priming_amount: parseFloat($("#keg_priming_amount").jqxNumberInput('decimal')),
-			keg_carbonation_temp: parseFloat($("#keg_carbonation_temp").jqxNumberInput('decimal')),
-			keg_forced_carb: dataRecord.keg_forced_carb,
-			keg_pressure: parseFloat($("#keg_pressure").jqxNumberInput('decimal')),
-			taste_notes: $("#taste_notes").val(),
-			taste_rate: parseFloat($("#taste_rate").jqxNumberInput('decimal')),
-			taste_date: $("#taste_date").val(),
-			taste_color: $("#taste_color").val(),
-			taste_transparency: $("#taste_transparency").val(),
-			taste_head: $("#taste_head").val(),
-			taste_aroma: $("#taste_aroma").val(),
-			taste_taste: $("#taste_taste").val(),
-			taste_mouthfeel: $("#taste_mouthfeel").val(),
-			taste_aftertaste: $("#taste_aftertaste").val(),
-			st_name: $('#st_name').val(),
-			st_letter: $('#st_letter').val(),
-			st_guide: $('#st_guide').val(),
-			st_type: dataRecord.st_type,
-			st_category: $('#st_category').val(),
-			st_category_number: parseFloat($("#st_category_number").jqxNumberInput('decimal')),
-			st_og_min: parseFloat($("#st_og_min").jqxNumberInput('decimal')),
-			st_og_max: parseFloat($("#st_og_max").jqxNumberInput('decimal')),
-			st_fg_min: parseFloat($("#st_fg_min").jqxNumberInput('decimal')),
-			st_fg_max: parseFloat($("#st_fg_max").jqxNumberInput('decimal')),
-			st_ibu_min: parseFloat($("#st_ibu_min").jqxNumberInput('decimal')),
-			st_ibu_max: parseFloat($("#st_ibu_max").jqxNumberInput('decimal')),
-			st_color_min: parseFloat($("#st_color_min").jqxNumberInput('decimal')),
-			st_color_max: parseFloat($("#st_color_max").jqxNumberInput('decimal')),
-			st_carb_min: parseFloat($("#st_carb_min").jqxNumberInput('decimal')),
-			st_carb_max: parseFloat($("#st_carb_max").jqxNumberInput('decimal')),
-			st_abv_min: parseFloat($("#st_abv_min").jqxNumberInput('decimal')),
-			st_abv_max: parseFloat($("#st_abv_max").jqxNumberInput('decimal')),
-			type: $("#type").val(),
-			batch_size: parseFloat($("#batch_size").jqxNumberInput('decimal')),
-			boil_size: parseFloat($("#boil_size").jqxNumberInput('decimal')),
-			boil_time: parseFloat($("#boil_time").jqxNumberInput('decimal')),
-			efficiency: parseFloat($("#efficiency").jqxNumberInput('decimal')),
-			est_og: parseFloat($("#est_og").jqxNumberInput('decimal')),
-			est_fg: parseFloat($("#est_fg").jqxNumberInput('decimal')),
-			est_abv: parseFloat($("#est_abv").jqxNumberInput('decimal')),
-			est_color: parseFloat($("#est_color").jqxNumberInput('decimal')),
-			color_method: $("#color_method").val(),
-			est_ibu: parseFloat($("#est_ibu").jqxNumberInput('decimal')),
-			ibu_method: $("#ibu_method").val(),
-			est_carb: parseFloat($("#est_carb").jqxNumberInput('decimal')),
-			mash_name: $("#mash_name").val(),
-			mash_ph: parseFloat($("#mash_ph").jqxNumberInput('decimal')),
-			sparge_temp: parseFloat($("#sparge_temp").jqxNumberInput('decimal')),
-			sparge_ph: parseFloat($("#sparge_ph").jqxNumberInput('decimal')),
-			sparge_volume: parseFloat($("#sparge_volume").jqxNumberInput('decimal')),
-			sparge_source: $("#sparge_source").val(),
-			sparge_acid_type: $("#sparge_acid_type").val(),
-			sparge_acid_perc: parseFloat($("#sparge_acid_perc").jqxNumberInput('decimal')),
-			sparge_acid_amount: dataRecord.sparge_acid_amount,
-			calc_acid: dataRecord.calc_acid,
-			w1_name: $("#w1_name").val(),
-			w1_amount: parseFloat($("#w1_amount").jqxNumberInput('decimal')),
-			w1_calcium: parseFloat($("#w1_calcium").jqxNumberInput('decimal')),
-			w1_sulfate: parseFloat($("#w1_sulfate").jqxNumberInput('decimal')),
-			w1_chloride: parseFloat($("#w1_chloride").jqxNumberInput('decimal')),
-			w1_sodium: parseFloat($("#w1_sodium").jqxNumberInput('decimal')),
-			w1_magnesium: parseFloat($("#w1_magnesium").jqxNumberInput('decimal')),
-			w1_total_alkalinity: parseFloat($("#w1_total_alkalinity").jqxNumberInput('decimal')),
-			w1_ph: parseFloat($("#w1_ph").jqxNumberInput('decimal')),
-			w1_cost: dataRecord.w1_cost,
-			w2_name: $("#w2_name").val(),
-			w2_amount: parseFloat($("#w2_amount").jqxNumberInput('decimal')),
-			w2_calcium: parseFloat($("#w2_calcium").jqxNumberInput('decimal')),
-			w2_sulfate: parseFloat($("#w2_sulfate").jqxNumberInput('decimal')),
-			w2_chloride: parseFloat($("#w2_chloride").jqxNumberInput('decimal')),
-			w2_sodium: parseFloat($("#w2_sodium").jqxNumberInput('decimal')),
-			w2_magnesium: parseFloat($("#w2_magnesium").jqxNumberInput('decimal')),
-			w2_total_alkalinity: parseFloat($("#w2_total_alkalinity").jqxNumberInput('decimal')),
-			w2_ph: parseFloat($("#w2_ph").jqxNumberInput('decimal')),
-			w2_cost: dataRecord.w2_cost,
-			wa_acid_name: $("#wa_acid_name").val(),
-			wa_acid_perc: parseFloat($("#wa_acid_perc").jqxNumberInput('decimal')),
-			wa_base_name: $("#wa_base_name").val(),
-			fermentables: fermentablerow,
-			hops: hoprow,
-			miscs: miscrow,
-			yeasts: yeastrow,
-			mashs: mashrow
-		};
-		var data = "update=true&" + $.param(row);
-		$.ajax({
-			dataType: 'json',
-			url: url,
-			cache: false,
-			data: data,
-			type: "POST",
-			success: function (data, status, xhr) {
-				// update command is executed.
-				window.location.href = my_return;
-			},
-			error: function(jqXHR, textStatus, errorThrown) {
-			}
-		});
+		saveRecord();
+		window.location.href = my_return;
 	});	
 	createDelElements();
 });
--- a/www/js/rec_edit.js	Mon Feb 11 20:56:17 2019 +0100
+++ b/www/js/rec_edit.js	Mon Feb 11 21:25:29 2019 +0100
@@ -1411,6 +1411,102 @@
 		}
 	});
 
+	function saveRecord() {
+		var fermentablerow = $('#fermentableGrid').jqxGrid('getrows');
+		var hoprow = $('#hopGrid').jqxGrid('getrows');
+		var miscrow = $('#miscGrid').jqxGrid('getrows');
+		var yeastrow = $('#yeastGrid').jqxGrid('getrows');
+		var mashrow = $('#mashGrid').jqxGrid('getrows');
+		var row = {
+			record: my_record,
+			uuid: dataRecord.uuid,
+			name: $("#name").val(),
+			locked: $("#locked").val(),
+			notes: $("#notes").val(),
+			st_name: $('#st_name').val(),
+			st_letter: $('#st_letter').val(),
+			st_guide: $('#st_guide').val(),
+			st_type: dataRecord.st_type,
+			st_category: $('#st_category').val(),
+			st_category_number: parseFloat($("#st_category_number").jqxNumberInput('decimal')),
+			st_og_min: parseFloat($("#st_og_min").jqxNumberInput('decimal')),
+			st_og_max: parseFloat($("#st_og_max").jqxNumberInput('decimal')),
+			st_fg_min: parseFloat($("#st_fg_min").jqxNumberInput('decimal')),
+			st_fg_max: parseFloat($("#st_fg_max").jqxNumberInput('decimal')),
+			st_ibu_min: parseFloat($("#st_ibu_min").jqxNumberInput('decimal')),
+			st_ibu_max: parseFloat($("#st_ibu_max").jqxNumberInput('decimal')),
+			st_color_min: parseFloat($("#st_color_min").jqxNumberInput('decimal')),
+			st_color_max: parseFloat($("#st_color_max").jqxNumberInput('decimal')),
+			st_carb_min: parseFloat($("#st_carb_min").jqxNumberInput('decimal')),
+			st_carb_max: parseFloat($("#st_carb_max").jqxNumberInput('decimal')),
+			st_abv_min: parseFloat($("#st_abv_min").jqxNumberInput('decimal')),
+			st_abv_max: parseFloat($("#st_abv_max").jqxNumberInput('decimal')),
+			type: $("#type").val(),
+			batch_size: parseFloat($("#batch_size").jqxNumberInput('decimal')),
+			boil_size: parseFloat($("#boil_size").jqxNumberInput('decimal')),
+			boil_time: parseFloat($("#boil_time").jqxNumberInput('decimal')),
+			efficiency: parseFloat($("#efficiency").jqxNumberInput('decimal')),
+			est_og: parseFloat($("#est_og").jqxNumberInput('decimal')),
+			est_fg: parseFloat($("#est_fg").jqxNumberInput('decimal')),
+			est_abv: parseFloat($("#est_abv").jqxNumberInput('decimal')),
+			est_color: parseFloat($("#est_color").jqxNumberInput('decimal')),
+			color_method: $("#color_method").val(),
+			est_ibu: parseFloat($("#est_ibu").jqxNumberInput('decimal')),
+			ibu_method: $("#ibu_method").val(),
+			est_carb: parseFloat($("#est_carb").jqxNumberInput('decimal')),
+			mash_name: $("#mash_name").val(),
+			mash_ph: parseFloat($("#mash_ph").jqxNumberInput('decimal')),
+			sparge_temp: parseFloat($("#sparge_temp").jqxNumberInput('decimal')),
+			sparge_ph: parseFloat($("#sparge_ph").jqxNumberInput('decimal')),
+			sparge_volume: parseFloat($("#sparge_volume").jqxNumberInput('decimal')),
+			sparge_source: $("#sparge_source").val(),
+			sparge_acid_type: $("#sparge_acid_type").val(),
+			sparge_acid_perc: parseFloat($("#sparge_acid_perc").jqxNumberInput('decimal')),
+			sparge_acid_amount: dataRecord.sparge_acid_amount,
+			calc_acid: $("#calc_acid").val(),
+			w1_name: $("#w1_name").val(),
+			w1_amount: parseFloat($("#w1_amount").jqxNumberInput('decimal')),
+			w1_calcium: parseFloat($("#w1_calcium").jqxNumberInput('decimal')),
+			w1_sulfate: parseFloat($("#w1_sulfate").jqxNumberInput('decimal')),
+			w1_chloride: parseFloat($("#w1_chloride").jqxNumberInput('decimal')),
+			w1_sodium: parseFloat($("#w1_sodium").jqxNumberInput('decimal')),
+			w1_magnesium: parseFloat($("#w1_magnesium").jqxNumberInput('decimal')),
+			w1_total_alkalinity: parseFloat($("#w1_total_alkalinity").jqxNumberInput('decimal')),
+			w1_ph: parseFloat($("#w1_ph").jqxNumberInput('decimal')),
+			w1_cost: dataRecord.w1_cost,
+			w2_name: $("#w2_name").val(),
+			w2_amount: parseFloat($("#w2_amount").jqxNumberInput('decimal')),
+			w2_calcium: parseFloat($("#w2_calcium").jqxNumberInput('decimal')),
+			w2_sulfate: parseFloat($("#w2_sulfate").jqxNumberInput('decimal')),
+			w2_chloride: parseFloat($("#w2_chloride").jqxNumberInput('decimal')),
+			w2_sodium: parseFloat($("#w2_sodium").jqxNumberInput('decimal')),
+			w2_magnesium: parseFloat($("#w2_magnesium").jqxNumberInput('decimal')),
+			w2_total_alkalinity: parseFloat($("#w2_total_alkalinity").jqxNumberInput('decimal')),
+			w2_ph: parseFloat($("#w2_ph").jqxNumberInput('decimal')),
+			w2_cost: dataRecord.w2_cost,
+			wa_acid_name: $("#wa_acid_name").val(),
+			wa_acid_perc: parseFloat($("#wa_acid_perc").jqxNumberInput('decimal')),
+			wa_base_name: $("#wa_base_name").val(),
+			fermentables: fermentablerow,
+			hops: hoprow,
+			miscs: miscrow,
+			yeasts: yeastrow,
+			mashs: mashrow
+		};
+		var data = "update=true&" + $.param(row);
+		$.ajax({
+			dataType: 'json',
+			url: url,
+			cache: false,
+			data: data,
+			type: "POST",
+			success: function (data, status, xhr) {
+			},
+			error: function(jqXHR, textStatus, errorThrown) {
+			}
+		});
+	};
+
 	var dataRecord = {};
 	var url = "includes/db_recipes.php";
 
@@ -3567,6 +3663,7 @@
 
 	$("#Print").jqxButton({ template: "info", width: '80px', theme: theme });
 	$("#Print").click(function () {
+		saveRecord();
 		// Open print in a new tab.
 		var url="rec_print.php?record=" + my_record;
 		window.open(url);
@@ -3574,7 +3671,7 @@
 
 	$("#Export").jqxButton({ template: "info", width: '80px', theme: theme });
 	$("#Export").click(function () {
-		// Open print in a new tab.
+		saveRecord();
 		var url="rec_export.php?record=" + my_record;
 		window.open(url);
 	});
@@ -3606,103 +3703,10 @@
 		window.location.href = my_return;
 	});
 
-	$("#Save").jqxButton({ template: "success", width: '90px', theme: theme });
+	$("#Save").jqxButton({ template: "success", width: '80px', theme: theme });
 	$("#Save").click(function () {
-		var fermentablerow = $('#fermentableGrid').jqxGrid('getrows');
-		var hoprow = $('#hopGrid').jqxGrid('getrows');
-		var miscrow = $('#miscGrid').jqxGrid('getrows');
-		var yeastrow = $('#yeastGrid').jqxGrid('getrows');
-		var mashrow = $('#mashGrid').jqxGrid('getrows');
-		var row = {
-			record: my_record,
-			uuid: dataRecord.uuid,
-			name: $("#name").val(),
-			locked: $("#locked").val(),
-			notes: $("#notes").val(),
-			st_name: $('#st_name').val(),
-			st_letter: $('#st_letter').val(),
-			st_guide: $('#st_guide').val(),
-			st_type: dataRecord.st_type,
-			st_category: $('#st_category').val(),
-			st_category_number: parseFloat($("#st_category_number").jqxNumberInput('decimal')),
-			st_og_min: parseFloat($("#st_og_min").jqxNumberInput('decimal')),
-			st_og_max: parseFloat($("#st_og_max").jqxNumberInput('decimal')),
-			st_fg_min: parseFloat($("#st_fg_min").jqxNumberInput('decimal')),
-			st_fg_max: parseFloat($("#st_fg_max").jqxNumberInput('decimal')),
-			st_ibu_min: parseFloat($("#st_ibu_min").jqxNumberInput('decimal')),
-			st_ibu_max: parseFloat($("#st_ibu_max").jqxNumberInput('decimal')),
-			st_color_min: parseFloat($("#st_color_min").jqxNumberInput('decimal')),
-			st_color_max: parseFloat($("#st_color_max").jqxNumberInput('decimal')),
-			st_carb_min: parseFloat($("#st_carb_min").jqxNumberInput('decimal')),
-			st_carb_max: parseFloat($("#st_carb_max").jqxNumberInput('decimal')),
-			st_abv_min: parseFloat($("#st_abv_min").jqxNumberInput('decimal')),
-			st_abv_max: parseFloat($("#st_abv_max").jqxNumberInput('decimal')),
-			type: $("#type").val(),
-			batch_size: parseFloat($("#batch_size").jqxNumberInput('decimal')),
-			boil_size: parseFloat($("#boil_size").jqxNumberInput('decimal')),
-			boil_time: parseFloat($("#boil_time").jqxNumberInput('decimal')),
-			efficiency: parseFloat($("#efficiency").jqxNumberInput('decimal')),
-			est_og: parseFloat($("#est_og").jqxNumberInput('decimal')),
-			est_fg: parseFloat($("#est_fg").jqxNumberInput('decimal')),
-			est_abv: parseFloat($("#est_abv").jqxNumberInput('decimal')),
-			est_color: parseFloat($("#est_color").jqxNumberInput('decimal')),
-			color_method: $("#color_method").val(),
-			est_ibu: parseFloat($("#est_ibu").jqxNumberInput('decimal')),
-			ibu_method: $("#ibu_method").val(),
-			est_carb: parseFloat($("#est_carb").jqxNumberInput('decimal')),
-			mash_name: $("#mash_name").val(),
-			mash_ph: parseFloat($("#mash_ph").jqxNumberInput('decimal')),
-			sparge_temp: parseFloat($("#sparge_temp").jqxNumberInput('decimal')),
-			sparge_ph: parseFloat($("#sparge_ph").jqxNumberInput('decimal')),
-			sparge_volume: parseFloat($("#sparge_volume").jqxNumberInput('decimal')),
-			sparge_source: $("#sparge_source").val(),
-			sparge_acid_type: $("#sparge_acid_type").val(),
-			sparge_acid_perc: parseFloat($("#sparge_acid_perc").jqxNumberInput('decimal')),
-			sparge_acid_amount: dataRecord.sparge_acid_amount,
-			calc_acid: $("#calc_acid").val(),
-			w1_name: $("#w1_name").val(),
-			w1_amount: parseFloat($("#w1_amount").jqxNumberInput('decimal')),
-			w1_calcium: parseFloat($("#w1_calcium").jqxNumberInput('decimal')),
-			w1_sulfate: parseFloat($("#w1_sulfate").jqxNumberInput('decimal')),
-			w1_chloride: parseFloat($("#w1_chloride").jqxNumberInput('decimal')),
-			w1_sodium: parseFloat($("#w1_sodium").jqxNumberInput('decimal')),
-			w1_magnesium: parseFloat($("#w1_magnesium").jqxNumberInput('decimal')),
-			w1_total_alkalinity: parseFloat($("#w1_total_alkalinity").jqxNumberInput('decimal')),
-			w1_ph: parseFloat($("#w1_ph").jqxNumberInput('decimal')),
-			w1_cost: dataRecord.w1_cost,
-			w2_name: $("#w2_name").val(),
-			w2_amount: parseFloat($("#w2_amount").jqxNumberInput('decimal')),
-			w2_calcium: parseFloat($("#w2_calcium").jqxNumberInput('decimal')),
-			w2_sulfate: parseFloat($("#w2_sulfate").jqxNumberInput('decimal')),
-			w2_chloride: parseFloat($("#w2_chloride").jqxNumberInput('decimal')),
-			w2_sodium: parseFloat($("#w2_sodium").jqxNumberInput('decimal')),
-			w2_magnesium: parseFloat($("#w2_magnesium").jqxNumberInput('decimal')),
-			w2_total_alkalinity: parseFloat($("#w2_total_alkalinity").jqxNumberInput('decimal')),
-			w2_ph: parseFloat($("#w2_ph").jqxNumberInput('decimal')),
-			w2_cost: dataRecord.w2_cost,
-			wa_acid_name: $("#wa_acid_name").val(),
-			wa_acid_perc: parseFloat($("#wa_acid_perc").jqxNumberInput('decimal')),
-			wa_base_name: $("#wa_base_name").val(),
-			fermentables: fermentablerow,
-			hops: hoprow,
-			miscs: miscrow,
-			yeasts: yeastrow,
-			mashs: mashrow
-		};
-		var data = "update=true&" + $.param(row);
-		$.ajax({
-			dataType: 'json',
-			url: url,
-			cache: false,
-			data: data,
-			type: "POST",
-			success: function (data, status, xhr) {
-				// update command is executed.
-				window.location.href = my_return;
-			},
-			error: function(jqXHR, textStatus, errorThrown) {
-			}
-		});
+		saveRecord();
+		window.location.href = my_return;
 	});
 	createDelElements();
 });

mercurial