Fixed new recipes uuid generation and saving missing new fields.

Thu, 03 Jan 2019 14:21:35 +0100

author
Michiel Broek <mbroek@mbse.eu>
date
Thu, 03 Jan 2019 14:21:35 +0100
changeset 166
635033a29c48
parent 165
5970c8377b89
child 167
dabcd35f8f92

Fixed new recipes uuid generation and saving missing new fields.

www/includes/db_product.php file | annotate | diff | comparison | revisions
www/includes/db_recipes.php file | annotate | diff | comparison | revisions
www/js/prod_new.js file | annotate | diff | comparison | revisions
www/js/rec_edit.js file | annotate | diff | comparison | revisions
www/js/rec_new.js file | annotate | diff | comparison | revisions
--- a/www/includes/db_product.php	Wed Jan 02 20:29:23 2019 +0100
+++ b/www/includes/db_product.php	Thu Jan 03 14:21:35 2019 +0100
@@ -51,7 +51,14 @@
 		$stageno = 11;
 
 	// Basic settings
-	$sql .=    "uuid='" . $_POST['uuid'];
+	if (isset($_POST['uuid'])) {
+		$sql .= "uuid='" . $_POST['uuid'];
+		syslog(LOG_NOTICE, 'Keep uuid ');
+	} else {
+		$uuid = str_replace("\n", "", file_get_contents('/proc/sys/kernel/random/uuid'));
+		$sql .= "uuid='" . $uuid;
+		syslog(LOG_NOTICE, 'New uuid ');
+	}
 	$sql .= "', name='" . mysqli_real_escape_string($connect, $_POST['name']);
 	$sql .= "', code='" . mysqli_real_escape_string($connect, $_POST['code']);
 	$sql .= "', birth='" . $_POST['birth'];
--- a/www/includes/db_recipes.php	Wed Jan 02 20:29:23 2019 +0100
+++ b/www/includes/db_recipes.php	Thu Jan 03 14:21:35 2019 +0100
@@ -26,7 +26,13 @@
 		$sql  = "UPDATE `recipes` SET ";
 	}
 	// Basic settings
-	$sql .=    "st_name='" . mysqli_real_escape_string($connect, $_POST['st_name']);
+	if (isset($_POST['uuid'])) {
+		$sql .= "uuid='" . $_POST['uuid'];
+	} else {
+		$uuid = str_replace("\n", "", file_get_contents('/proc/sys/kernel/random/uuid'));
+		$sql .= "uuid='" . $uuid;
+	}
+	$sql .= "', st_name='" . mysqli_real_escape_string($connect, $_POST['st_name']);
 	$sql .= "', st_letter='" . mysqli_real_escape_string($connect, $_POST['st_letter']);
 	$sql .= "', st_guide='" . mysqli_real_escape_string($connect, $_POST['st_guide']);
 	$sql .= "', st_type='" . mysqli_real_escape_string($connect, $_POST['st_type']);
--- a/www/js/prod_new.js	Wed Jan 02 20:29:23 2019 +0100
+++ b/www/js/prod_new.js	Thu Jan 03 14:21:35 2019 +0100
@@ -43,7 +43,133 @@
 				var newrow = {
 					record: -1,
 					name: $("#name").val(),
+					code: $("#code").val(),
+					birth: $("#birth").val(),
+					stage: 'Plan',
 					notes: $("#notes").val(),
+					log_brew: false,
+					log_fermentation: false,
+					inventory_reduced: false,
+					locked: false,
+					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_mash_ph: 0.0,
+					brew_mash_sg: 1.000,
+					brew_sparge_temperature: 85,
+					brew_sparge_volume: parseFloat($("#eq_mash_volume").jqxNumberInput('decimal')),
+					brew_sparge_ph: 0.0,
+					brew_preboil_volume: parseFloat($("#eq_boil_size").jqxNumberInput('decimal')),
+					brew_preboil_sg: 1.000,
+					brew_preboil_ph: 0.0,
+					brew_aboil_volume: parseFloat($("#eq_boil_size").jqxNumberInput('decimal')) * 0.9,
+					brew_aboil_sg: 1.000,
+					brew_aboil_ph: 0.0,
+					brew_aboil_efficiency: 0,
+					brew_cooling_method: '-',
+					brew_cooling_time: 0,
+					brew_cooling_to: 0,
+					brew_whirlpool9: 0,
+					brew_whirlpool7: 0,
+					brew_whirlpool6: 0,
+					brew_whirlpool2: 0,
+					brew_fermenter_volume: parseFloat($("#eq_batch_size").jqxNumberInput('decimal')),
+					brew_fermenter_extrawater: 0,
+					brew_aeration_time: 0,
+					brew_aeration_speed: 0,
+					brew_aeration_type: 'None',
+					brew_fermenter_sg: 0,
+					brew_fermenter_ibu: 0,
+					brew_date_end: '',
+					brew_log_available: false,
+					og: 0,
+					fg: 0,
+					primary_start_temp: 0,
+					primary_max_temp: 0,
+					primary_end_temp: 0,
+					primary_end_sg: 0,
+					primary_end_date: '',
+					secondary_temp: 0,
+					secondary_end_date: '',
+					tertiary_temp: 0,
+					package_date: '',
+					bottle_amount: 0,
+					bottle_carbonation: 0,
+					bottle_priming_sugar: 'Kristalsuiker',
+					bottle_priming_amount: 0,
+					bottle_carbonation_temp: 23,
+					keg_amount: 0,
+					keg_carbonation: 0,
+					keg_priming_sugar: 'Kristalsuiker',
+					keg_priming_amount: 0,
+					keg_carbonation_temp: 23,
+					keg_forced_carb: false,
+					keg_pressure: 0,
+					taste_notes: '',
+					taste_rate: 0,
+					taste_date: '',
+					taste_color: '',
+					taste_transparency: '',
+					taste_head: '',
+					taste_aroma: '',
+					taste_taste: '',
+					taste_mouthfeel: '',
+					taste_aftertaste: '',
+					st_name: $('#st_name').val(),
+					st_letter: $('#st_letter').val(),
+					st_guide: $('#st_guide').val(),
+					st_type: $('#st_type').val(),
+					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: 20.0,
+					boil_time: parseFloat($("#boil_time").jqxNumberInput('decimal')),
+					efficiency: parseFloat($("#efficiency").jqxNumberInput('decimal')),
+					est_og: parseFloat($("#est_og").jqxNumberInput('decimal')),
+					est_fg: 1.000,
+					est_color: 0,
+					est_abv: 0.0,
+					est_carb: 0.0,
+					color_method: "Morey",
+					est_ibu: 0,
+					ibu_method: "Tinseth",
+					mash_name: "",
+					mash_ph: 5.4,
+					mash_sparge_temp: 78.0
 				};
 				var data = "insert=true&return=" + my_return + "&" + $.param(newrow);
 				$.ajax({
--- a/www/js/rec_edit.js	Wed Jan 02 20:29:23 2019 +0100
+++ b/www/js/rec_edit.js	Thu Jan 03 14:21:35 2019 +0100
@@ -1194,6 +1194,8 @@
 		cache: false,
 		datafields: [
 			{ name: 'record', type: 'number' },
+			{ name: 'uuid', type: 'string' },
+			{ name: 'locked', type: 'bool' },
 			{ name: 'st_name', type: 'string' },
 			{ name: 'st_letter', type: 'string' },
 			{ name: 'st_guide', type: 'string' },
@@ -1271,6 +1273,7 @@
 		loadComplete: function () {
 			var records = dataAdapter.records;
 			dataRecord = records[0];
+			// Hidden record uuid
 			$("#name").val(dataRecord.name);
 			$("#notes").val(dataRecord.notes);
 			$("#st_name").val(dataRecord.st_name);
@@ -2691,6 +2694,7 @@
 		var mashrow = $('#mashGrid').jqxGrid('getrows');
 		var row = {
 			record: my_record,
+			uuid: dataRecord.uuid,
 			name: $("#name").val(),
 			notes: $("#notes").val(),
 			st_name: $('#st_name').val(),
--- a/www/js/rec_new.js	Wed Jan 02 20:29:23 2019 +0100
+++ b/www/js/rec_new.js	Thu Jan 03 14:21:35 2019 +0100
@@ -146,6 +146,7 @@
 					st_abv_max: parseFloat($("#st_abv_max").jqxNumberInput('decimal')),
 					type: $("#type").val(),
 					batch_size: 20.0,
+					boil_size: 22.0,
 					boil_time: parseFloat($("#boil_time").jqxNumberInput('decimal')),
 					efficiency: parseFloat($("#efficiency").jqxNumberInput('decimal')),
 					est_og: parseFloat($("#est_og").jqxNumberInput('decimal')),
@@ -158,7 +159,14 @@
 					ibu_method: "Tinseth",
 					mash_name: "",
 					mash_ph: 5.4,
-					mash_sparge_temp: 78.0
+					sparge_temp: 78.0,
+					sparge_volume: 12.0,
+					sparge_ph: 5.8,
+					sparge_source: 'Bron 1',
+					sparge_acid_type: 'Melkzuur',
+					sparge_acid_perc: 80,
+					sparge_acid_amount: 0,
+					calc_acid: true
 				};
 				var data = "insert=true&return=" + my_return + "&" + $.param(newrow);
 				$.ajax({

mercurial