Added product export screen with choices to export to beerxml, duplicate product or copy to recipe. Products in wait state can now be deleted.

Thu, 28 Feb 2019 22:50:58 +0100

author
Michiel Broek <mbroek@mbse.eu>
date
Thu, 28 Feb 2019 22:50:58 +0100
changeset 302
d0f7b4ab000f
parent 301
72bcc7ac60da
child 303
98c2afc88780

Added product export screen with choices to export to beerxml, duplicate product or copy to recipe. Products in wait state can now be deleted.

www/Makefile file | annotate | diff | comparison | revisions
www/css/style.css file | annotate | diff | comparison | revisions
www/includes/global.inc.php file | annotate | diff | comparison | revisions
www/js/prod_edit.js file | annotate | diff | comparison | revisions
www/js/prod_export.js file | annotate | diff | comparison | revisions
www/js/rec_export.js file | annotate | diff | comparison | revisions
www/prod_duplicate.php file | annotate | diff | comparison | revisions
www/prod_export.php file | annotate | diff | comparison | revisions
www/prod_torecipe.php file | annotate | diff | comparison | revisions
www/rec_export.php file | annotate | diff | comparison | revisions
--- a/www/Makefile	Thu Feb 28 15:40:14 2019 +0100
+++ b/www/Makefile	Thu Feb 28 22:50:58 2019 +0100
@@ -10,11 +10,11 @@
 		  inv_equipments.php inv_fermentables.php inv_hops.php inv_instock.php \
 		  inv_miscs.php inv_suppliers.php inv_waters.php inv_yeasts.php log_brew.php \
 		  log_fermentation.php mon_brewer.php mon_fermenter.php mon_node.php \
-		  prod_archive_code.php prod_archive_date.php prod_archive_name.php \
-		  prod_edit.php prod_export.php prod_impbrew.php prod_inprod.php prod_new.php \
-		  prod_print.php prod_reduce.php profile_fermentation.php \
+		  prod_archive_code.php prod_archive_date.php prod_archive_name.php prod_beerxml.php \
+		  prod_duplicate.php prod_edit.php prod_export.php prod_impbrew.php prod_inprod.php prod_new.php \
+		  prod_print.php prod_reduce.php prod_torecipe.php profile_fermentation.php \
 		  profile_mash.php profile_setup.php profile_styles.php profile_water.php \
-		  rec_edit.php rec_export.php rec_main.php rec_new.php rec_print.php \
+		  rec_beerxml.php rec_edit.php rec_export.php rec_main.php rec_new.php rec_print.php \
 		  upl_brew.php version.php
 SUB		= version.php.in images/* css/* jqwidgets/* jqwidgets/styles/* \
 		  jqwidgets/styles/images/* jqwidgets/globalization/* js/* \
--- a/www/css/style.css	Thu Feb 28 15:40:14 2019 +0100
+++ b/www/css/style.css	Thu Feb 28 22:50:58 2019 +0100
@@ -40,6 +40,7 @@
 }
 
 
+#export_table,
 #about_table {
     width: 960px;
     background: #353536;
@@ -50,6 +51,7 @@
 }
 
 
+
 #node_table {
     width: 600px;
     background: #353536;
--- a/www/includes/global.inc.php	Thu Feb 28 15:40:14 2019 +0100
+++ b/www/includes/global.inc.php	Thu Feb 28 22:50:58 2019 +0100
@@ -50,6 +50,10 @@
 	$my_name = $_GET['name'];
 else
 	$my_name = '';
+if (isset($_GET['select']))
+	$my_select = $_GET['select'];
+else
+	$my_select = '';
 
 $escapers = array("\\", "/", "\"", "\n", "\r", "\t", "\x08", "\x0c");
 $replacements = array("\\\\", "\\/", "\\\"", "\\n", "\\r", "\\t", "\\f", "\\b");
@@ -93,6 +97,7 @@
 	global $my_return;
 	global $my_name;
 	global $my_code;
+	global $my_select;
 	global $my_brewery_name;
 	global $my_factor_mashhop;
 	global $my_factor_fwh;
@@ -118,9 +123,10 @@
 	var theme = "<?php echo $my_style; ?>";
 	var my_record = "<?php echo $my_record; ?>";
 	var my_return = "<?php echo $my_return; ?>";
-	var my_name= "<?php echo $my_name; ?>";
-	var my_code= "<?php echo $my_code; ?>";
-        var my_uuid= "<?php echo $my_uuid; ?>";
+	var my_name = "<?php echo $my_name; ?>";
+	var my_code = "<?php echo $my_code; ?>";
+	var my_uuid = "<?php echo $my_uuid; ?>";
+	var my_select = "<?php echo $my_select; ?>";
 	var my_brewery_name = "<?php echo $my_brewery_name; ?>";
 	var my_factor_mashhop = "<?php echo $my_factor_mashhop; ?>";
 	var my_factor_fwh = "<?php echo $my_factor_fwh; ?>";
--- a/www/js/prod_edit.js	Thu Feb 28 15:40:14 2019 +0100
+++ b/www/js/prod_edit.js	Thu Feb 28 22:50:58 2019 +0100
@@ -1765,11 +1765,10 @@
 		}
 
 		/*
-		 * When the brew is in progress or done, block equipment select.
+		 * When the brew is in progress or done, block equipment select and delete.
 		 */
-		if (dataRecord.stage > 1)
+		if (dataRecord.stage > 1) {
 			$("#equipmentSelect").jqxDropDownList({ disabled: true });
-		if (dataRecord.stage > 0) {
 			$("#Delete").jqxButton({ disabled: true });
 		}
 
@@ -5307,8 +5306,9 @@
 	$("#Export").jqxButton({ template: "info", width: '80px', theme: theme });
 	$("#Export").click(function () {
 		saveRecord();
-		var url="prod_beerxml.php?record=" + my_record;
-		window.open(url);
+		var url="prod_export.php?record=" + my_record + "&return=" + my_return + "&select=" + my_select +
+			"&code=" + dataRecord.code + "&name=" + dataRecord.name;
+		window.location.href = url;
 	});
 
 	$("#Delete").jqxButton({ template: "danger", width: '80px', theme: theme });
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/www/js/prod_export.js	Thu Feb 28 22:50:58 2019 +0100
@@ -0,0 +1,62 @@
+/*****************************************************************************
+ * Copyright (C) 2019
+ *
+ * Michiel Broek <mbroek at mbse dot eu>
+ *
+ * This file is part of BMS
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2, or (at your option) any
+ * later version.
+ *
+ * BrewCloud is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with ThermFerm; see the file COPYING.  If not, write to the Free
+ * Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ *****************************************************************************/
+
+
+$(document).ready(function () {
+
+	var	choice = 0;
+
+	$("#name").html(my_name);
+	$("#code").html(my_code);
+	$("#jqxRadioButton1").jqxRadioButton({ theme: theme, width: 250, height: 23 });
+	$("#jqxRadioButton2").jqxRadioButton({ theme: theme, width: 250, height: 23 });
+	$("#jqxRadioButton3").jqxRadioButton({ theme: theme, width: 250, height: 23 });
+	$('#jqxRadioButton1').on('checked', function (event) {
+	       	$('#Start').jqxButton({ disabled: false });
+		choice = 1;
+	});
+	$('#jqxRadioButton2').on('checked', function (event) {
+		$('#Start').jqxButton({ disabled: false });
+		choice = 2;
+	});
+	$('#jqxRadioButton3').on('checked', function (event) {
+		$('#Start').jqxButton({ disabled: false });
+		choice = 3;
+	});
+
+	$('#Start').jqxButton({ template: "success", width: '100px', theme: theme, disabled: true });
+	$('#Start').click(function () {
+		if (choice == 1) {
+			var url="prod_beerxml.php?record=" + my_record;
+			window.open(url);
+		} else if (choice == 2) {
+			var url="prod_duplicate.php?record=" + my_record;
+			window.open(url);
+		} else if (choice == 3) {
+			var url="prod_torecipe.php?record=" + my_record;
+			window.open(url);
+		}
+		// Return to the original product
+		window.location.href = my_return + "?record=" + my_record;
+	});
+
+});
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/www/js/rec_export.js	Thu Feb 28 22:50:58 2019 +0100
@@ -0,0 +1,27 @@
+/*****************************************************************************
+ * Copyright (C) 2019
+ *
+ * Michiel Broek <mbroek at mbse dot eu>
+ *
+ * This file is part of BMS
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2, or (at your option) any
+ * later version.
+ *
+ * BrewCloud is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with ThermFerm; see the file COPYING.  If not, write to the Free
+ * Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ *****************************************************************************/
+
+
+$(document).ready(function () {
+
+
+});
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/www/prod_duplicate.php	Thu Feb 28 22:50:58 2019 +0100
@@ -0,0 +1,221 @@
+<?php
+require_once('config.php');
+//require_once('includes/formulas.php');
+//require_once($_SERVER['DOCUMENT_ROOT'].'/config.php');
+//require_once($_SERVER['DOCUMENT_ROOT'].'/includes/formulas.php');
+
+
+$link = mysqli_connect(DBASE_HOST,DBASE_USER,DBASE_PASS,DBASE_NAME);
+if (! $link) {
+	die('Connect Error (' . mysqli_connect_errno() . ') ' . mysqli_connect_error());
+}
+if (! mysqli_set_charset($link, "utf8" )) {
+	echo "error";
+	return 1;
+}
+
+date_default_timezone_set('Europe/Amsterdam');
+//setlocale ( LC_ALL, 'nl_NL.UTF-8');
+if (isset($_GET["record"]))
+	$record = $_GET["record"];
+else
+	$record = 78;
+$result = mysqli_query($link, "SELECT * FROM products WHERE record='".$record."'");
+$row = mysqli_fetch_array($result);
+
+/*
+ * Make this duplicate a fresh product.
+ */
+$sql  = "INSERT INTO `products` SET ";
+$sql .= "name='" . mysqli_real_escape_string($link, $row['name']) . ' [duplicate]';
+$sql .= "', uuid='" . str_replace("\n", "", file_get_contents('/proc/sys/kernel/random/uuid'));
+$sql .= "', code='" . mysqli_real_escape_string($link, $row['code']) . '-DuP';
+$sql .= "', birth='" . date("Y-m-d");
+$sql .= "', stage='1";
+$sql .= "', notes='" . mysqli_real_escape_string($link, $row['notes']);
+$sql .= "', log_brew='0";
+$sql .= "', log_fermentation='0";
+$sql .= "', inventory_reduced='0";
+$sql .= "', locked='0";
+// Equipment
+$sql .= "', eq_name='" . mysqli_real_escape_string($link, $row['eq_name']);
+$sql .= "', eq_boil_size='" . $row['eq_boil_size'];
+$sql .= "', eq_batch_size='" . $row['eq_batch_size'];
+$sql .= "', eq_tun_volume='" . $row['eq_tun_volume'];
+$sql .= "', eq_tun_weight='" . $row['eq_tun_weight'];
+$sql .= "', eq_tun_specific_heat='" . $row['eq_tun_specific_heat'];
+$sql .= "', eq_tun_material='" . $row['eq_tun_material'];
+$sql .= "', eq_tun_height='" . $row['eq_tun_height'];
+$sql .= "', eq_top_up_water='" . $row['eq_top_up_water'];
+$sql .= "', eq_trub_chiller_loss='" . $row['eq_trub_chiller_loss'];
+$sql .= "', eq_evap_rate='" . $row['eq_evap_rate'];
+$sql .= "', eq_boil_time='" . $row['eq_boil_time'];
+$sql .= "', eq_calc_boil_volume='" . $row['eq_calc_boil_volume'];
+$sql .= "', eq_top_up_kettle='" . $row['eq_top_up_kettle'];
+$sql .= "', eq_hop_utilization='" . $row['eq_hop_utilization'];
+$sql .= "', eq_notes='" . mysqli_real_escape_string($link, $row['eq_notes']);
+$sql .= "', eq_lauter_volume='" . $row['eq_lauter_volume'];
+$sql .= "', eq_lauter_height='" . $row['eq_lauter_height'];
+$sql .= "', eq_lauter_deadspace='" . $row['eq_lauter_deadspace'];
+$sql .= "', eq_kettle_volume='" . $row['eq_kettle_volume'];
+$sql .= "', eq_kettle_height='" . $row['eq_kettle_height'];
+$sql .= "', eq_mash_volume='" . $row['eq_mash_volume'];
+$sql .= "', eq_mash_max='" . $row['eq_mash_max'];
+$sql .= "', eq_efficiency='" . $row['eq_efficiency'];
+// brewdate
+$sql .= "', brew_date_start=NULL";
+$sql .=  ", brew_mash_ph='0.0";
+$sql .= "', brew_mash_sg='1.000";
+$sql .= "', brew_sparge_temperature='" . $row['brew_sparge_temperature'];
+$sql .= "', brew_sparge_volume='" . $row['brew_sparge_volume'];
+$sql .= "', brew_sparge_ph='" . $row['brew_sparge_ph'];
+$sql .= "', brew_preboil_volume='0";
+$sql .= "', brew_preboil_sg='0";
+$sql .= "', brew_preboil_ph='0.0";
+$sql .= "', brew_aboil_volume='0";
+$sql .= "', brew_aboil_sg='0";
+$sql .= "', brew_aboil_ph='0.0";
+$sql .= "', brew_aboil_efficiency='0";
+$sql .= "', brew_cooling_method='" . $row['brew_cooling_method'];
+$sql .= "', brew_cooling_time='0";
+$sql .= "', brew_cooling_to='" . $row['brew_cooling_to'];
+$sql .= "', brew_whirlpool9='" . $row['brew_whirlpool9'];
+$sql .= "', brew_whirlpool7='" . $row['brew_whirlpool7'];
+$sql .= "', brew_whirlpool6='" . $row['brew_whirlpool6'];
+$sql .= "', brew_whirlpool2='" . $row['brew_whirlpool2'];
+$sql .= "', brew_aeration_time='" . $row['brew_aeration_time'];
+$sql .= "', brew_aeration_speed='" . $row['brew_aeration_speed'];
+$sql .= "', brew_aeration_type='" . $row['brew_aeration_type'];
+$sql .= "', brew_fermenter_volume='" . $row['brew_fermenter_volume'];
+$sql .= "', brew_fermenter_extrawater='" . $row['brew_fermenter_extrawater'];
+$sql .= "', brew_fermenter_tcloss='" . $row['brew_fermenter_tcloss'];
+$sql .= "', brew_fermenter_sg='0";
+$sql .= "', brew_fermenter_ibu='0";
+$sql .= "', brew_fermenter_color='0";
+$sql .= "', brew_date_end=NULL";
+$sql .=  ", og='0";
+$sql .= "', fg='0";
+$sql .= "', primary_start_temp='0";
+$sql .= "', primary_max_temp='0";
+$sql .= "', primary_end_temp='0";
+$sql .= "', primary_end_date=NULL";
+$sql .=  ", primary_end_sg='0";
+$sql .= "', secondary_temp='0";
+$sql .= "', secondary_end_date=NULL";
+$sql .=  ", tertiary_temp='0";
+$sql .= "', package_date=NULL";
+$sql .=  ", bottle_amount='0";
+$sql .= "', bottle_carbonation='" . $row['bottle_carbonation'];
+$sql .= "', bottle_priming_sugar='" . $row['bottle_priming_sugar'];
+$sql .= "', bottle_priming_amount='0";
+$sql .= "', bottle_carbonation_temp='" . $row['bottle_carbonation_temp'];
+$sql .= "', keg_amount='0";
+$sql .= "', keg_carbonation='" . $row['keg_carbonation'];
+$sql .= "', keg_priming_sugar='" . $row['keg_priming_sugar'];
+$sql .= "', keg_priming_amount='0";
+$sql .= "', keg_carbonation_temp='" . $row['keg_carbonation_temp'];
+$sql .= "', keg_forced_carb='" . $row['keg_forced_carb'];
+$sql .= "', keg_pressure='" . $row['keg_pressure'];
+$sql .= "', taste_notes='";
+$sql .= "', taste_rate='0";
+$sql .= "', taste_date=NULL";
+$sql .=  ", taste_color='";
+$sql .= "', taste_transparency='";
+$sql .= "', taste_head='";
+$sql .= "', taste_aroma='";
+$sql .= "', taste_taste='";
+$sql .= "', taste_mouthfeel='";
+$sql .= "', taste_aftertaste='";
+// Style
+$sql .= "', st_name='" . mysqli_real_escape_string($link, $row['st_name']);
+$sql .= "', st_letter='" . mysqli_real_escape_string($link, $row['st_letter']);
+$sql .= "', st_guide='" . mysqli_real_escape_string($link, $row['st_guide']);
+$sql .= "', st_type='" . $row['st_type'];
+$sql .= "', st_category='" . mysqli_real_escape_string($link, $row['st_category']);
+$sql .= "', st_category_number='" . $row['st_category_number'];
+$sql .= "', st_og_min='" . $row['st_og_min'];
+$sql .= "', st_og_max='" . $row['st_og_max'];
+$sql .= "', st_fg_min='" . $row['st_fg_min'];
+$sql .= "', st_fg_max='" . $row['st_fg_max'];
+$sql .= "', st_ibu_min='" . $row['st_ibu_min'];
+$sql .= "', st_ibu_max='" . $row['st_ibu_max'];
+$sql .= "', st_color_min='" . $row['st_color_min'];
+$sql .= "', st_color_max='" . $row['st_color_max'];
+$sql .= "', st_carb_min='" . $row['st_carb_min'];
+$sql .= "', st_carb_max='" . $row['st_carb_max'];
+$sql .= "', st_abv_min='" . $row['st_abv_min'];
+$sql .= "', st_abv_max='" . $row['st_abv_max'];
+$sql .= "', type='" . $row['type'];
+$sql .= "', batch_size='" . $row['batch_size'];
+$sql .= "', boil_size='" . $row['boil_size'];
+$sql .= "', boil_time='" . $row['boil_time'];
+$sql .= "', efficiency='" . $row['efficiency'];
+$sql .= "', est_og='0.000";
+$sql .= "', est_fg='0.000";
+$sql .= "', est_abv='0.0";
+$sql .= "', est_carb='0";
+$sql .= "', est_color='0";
+$sql .= "', color_method='" . $row['color_method'];
+$sql .= "', est_ibu='0";
+$sql .= "', ibu_method='" . $row['ibu_method'];
+$sql .= "', sparge_temp='" . $row['sparge_temp'];
+$sql .= "', sparge_ph='" . $row['sparge_ph'];
+$sql .= "', sparge_volume='" . $row['sparge_volume'];
+$sql .= "', sparge_source='" . $row['sparge_source'];
+$sql .= "', sparge_acid_type='" . $row['sparge_acid_type'];
+$sql .= "', sparge_acid_perc='" . $row['sparge_acid_perc'];
+$sql .= "', sparge_acid_amount='0";
+$sql .= "', mash_ph='" . $row['mash_ph'];
+$sql .= "', mash_name='" . $row['mash_name'];
+$sql .= "', calc_acid='" . $row['calc_acid'];
+$sql .= "', w1_name='" . mysqli_real_escape_string($link, $row['w1_name']);
+$sql .= "', w1_amount='" . $row['w1_amount'];
+$sql .= "', w1_calcium='" . $row['w1_calcium'];
+$sql .= "', w1_sulfate='" . $row['w1_sulfate'];
+$sql .= "', w1_chloride='" . $row['w1_chloride'];
+$sql .= "', w1_sodium='" . $row['w1_sodium'];
+$sql .= "', w1_magnesium='" . $row['w1_magnesium'];
+$sql .= "', w1_total_alkalinity='" . $row['w1_total_alkalinity'];
+$sql .= "', w1_ph='" . $row['w1_ph'];
+$sql .= "', w1_cost='" . $row['w1_cost'];
+$sql .= "', w2_name='" . mysqli_real_escape_string($link, $row['w2_name']);
+$sql .= "', w2_amount='" . $row['w2_amount'];
+$sql .= "', w2_calcium='" . $row['w2_calcium'];
+$sql .= "', w2_sulfate='" . $row['w2_sulfate'];
+$sql .= "', w2_chloride='" . $row['w2_chloride'];
+$sql .= "', w2_sodium='" . $row['w2_sodium'];
+$sql .= "', w2_magnesium='" . $row['w2_magnesium'];
+$sql .= "', w2_total_alkalinity='" . $row['w2_total_alkalinity'];
+$sql .= "', w2_ph='" . $row['w2_ph'];
+$sql .= "', w2_cost='" . $row['w2_cost'];
+$sql .= "', wa_acid_name='" . $row['wa_acid_name'];
+$sql .= "', wa_acid_perc='" . $row['wa_acid_perc'];
+$sql .= "', wa_base_name='" . $row['wa_base_name'];
+$sql .= "', starter_enable='" . $row['starter_enable'];
+$sql .= "', starter_type='" . $row['starter_type'];
+$sql .= "', starter_sg='" . $row['starter_sg'];
+$sql .= "', prop1_type='" . $row['prop1_type'];
+$sql .= "', prop1_volume='" . $row['prop1_volume'];
+$sql .= "', prop2_type='" . $row['prop2_type'];
+$sql .= "', prop2_volume='" . $row['prop2_volume'];
+$sql .= "', prop3_type='" . $row['prop3_type'];
+$sql .= "', prop3_volume='" . $row['prop3_volume'];
+$sql .= "', prop4_type='" . $row['prop4_type'];
+$sql .= "', prop4_volume='" . $row['prop4_volume'];
+$sql .= "', json_fermentables='" . $row['json_fermentables'];
+$sql .= "', json_hops='" . $row['json_hops'];
+$sql .= "', json_miscs='" . $row['json_miscs'];
+$sql .= "', json_yeasts='" . $row['json_yeasts'];
+$sql .= "', json_mashs='" . $row['json_mashs'];
+$sql .= "';";
+syslog(LOG_NOTICE, $sql);
+
+$result = mysqli_query($link, $sql);
+if (! $result) {
+	syslog(LOG_NOTICE, "db_product: result: ".mysqli_error($link));
+} else {
+	$lastid = mysqli_insert_id($link);
+	syslog(LOG_NOTICE, "db_product: inserted record ".$lastid);
+}
+echo "<script>window.close();</script>";
+exit;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/www/prod_export.php	Thu Feb 28 22:50:58 2019 +0100
@@ -0,0 +1,42 @@
+<?php
+require_once($_SERVER['DOCUMENT_ROOT'].'/includes/global.inc.php');
+page_header('Product export', 'prod_export');
+?>
+
+   <div id="MainPanel">
+    <div id='export_table'>
+     <table style='width: 100%; padding: 10px;'>
+      <tr><th colspan=2>Export product</th></tr>
+      <tr><td colspan="2">&nbsp;</td></tr>
+      <tr>
+       <td align="right" style="vertical-align: top;">Naam:</td>
+       <td align="left"><div style='margin-left: 10px;' id='name'></div></td>
+      </tr>
+      <tr>
+       <td align="right" style="vertical-align: top;">Code:</td>
+       <td align="left"><div style='margin-left: 10px;' id='code'></div></td>
+      </tr>
+      <tr>
+       <td align="right" style="vertical-align: top;">Maak beerxml bestand:</td>
+       <td align="left"><div style='margin-left: 10px;' id='jqxRadioButton1'></td>
+      </tr>
+      <tr>
+       <td align="right" style="vertical-align: top;">Dupliceer als nieuw product:</td>
+       <td align="left"><div style='margin-left: 10px;' id='jqxRadioButton2'></td>
+      </tr>
+      <tr>
+       <td align="right" style="vertical-align: top;">Copieer als recept:</td>
+       <td align="left"><div style='margin-left: 10px;' id='jqxRadioButton3'></td>
+      </tr>
+      <tr><td colspan="2">&nbsp;</td></tr>
+      <tr>
+       <td align="right" style="vertical-align: top;"></td>
+       <td align="left"><input type="button" id="Start" value="Start" /></td>
+      </tr>
+     </table>
+    </div>
+   </div>
+
+<?php
+page_footer();
+?>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/www/prod_torecipe.php	Thu Feb 28 22:50:58 2019 +0100
@@ -0,0 +1,110 @@
+<?php
+require_once('config.php');
+
+
+$link = mysqli_connect(DBASE_HOST,DBASE_USER,DBASE_PASS,DBASE_NAME);
+if (! $link) {
+	die('Connect Error (' . mysqli_connect_errno() . ') ' . mysqli_connect_error());
+}
+if (! mysqli_set_charset($link, "utf8" )) {
+	echo "error";
+	return 1;
+}
+
+date_default_timezone_set('Europe/Amsterdam');
+if (isset($_GET["record"]))
+	$record = $_GET["record"];
+else
+	$record = 78;
+$result = mysqli_query($link, "SELECT * FROM products WHERE record='".$record."'");
+$row = mysqli_fetch_array($result);
+
+/*
+ * Make this duplicate a fresh product.
+ */
+$sql  = "INSERT INTO `recipes` SET ";
+$sql .= "name='" . mysqli_real_escape_string($link, $row['name']) . ' [duplicate]';
+$sql .= "', uuid='" . str_replace("\n", "", file_get_contents('/proc/sys/kernel/random/uuid'));
+$sql .= "', notes='" . mysqli_real_escape_string($link, $row['notes']);
+$sql .= "', locked='0";
+$sql .= "', st_name='" . mysqli_real_escape_string($link, $row['st_name']);
+$sql .= "', st_letter='" . mysqli_real_escape_string($link, $row['st_letter']);
+$sql .= "', st_guide='" . mysqli_real_escape_string($link, $row['st_guide']);
+$sql .= "', st_type='" . $row['st_type'];
+$sql .= "', st_category='" . mysqli_real_escape_string($link, $row['st_category']);
+$sql .= "', st_category_number='" . $row['st_category_number'];
+$sql .= "', st_og_min='" . $row['st_og_min'];
+$sql .= "', st_og_max='" . $row['st_og_max'];
+$sql .= "', st_fg_min='" . $row['st_fg_min'];
+$sql .= "', st_fg_max='" . $row['st_fg_max'];
+$sql .= "', st_ibu_min='" . $row['st_ibu_min'];
+$sql .= "', st_ibu_max='" . $row['st_ibu_max'];
+$sql .= "', st_color_min='" . $row['st_color_min'];
+$sql .= "', st_color_max='" . $row['st_color_max'];
+$sql .= "', st_carb_min='" . $row['st_carb_min'];
+$sql .= "', st_carb_max='" . $row['st_carb_max'];
+$sql .= "', st_abv_min='" . $row['st_abv_min'];
+$sql .= "', st_abv_max='" . $row['st_abv_max'];
+$sql .= "', type='" . $row['type'];
+$sql .= "', batch_size='" . $row['batch_size'];
+$sql .= "', boil_size='" . $row['boil_size'];
+$sql .= "', boil_time='" . $row['boil_time'];
+$sql .= "', efficiency='" . $row['efficiency'];
+$sql .= "', est_og='" . $row['est_og'];
+$sql .= "', est_fg='0.000";
+$sql .= "', est_abv='" . $row['est_abv'];
+$sql .= "', est_carb='0";
+$sql .= "', est_color='" . $row['est_color'];
+$sql .= "', color_method='" . $row['color_method'];
+$sql .= "', est_ibu='" . $row['est_ibu'];
+$sql .= "', ibu_method='" . $row['ibu_method'];
+$sql .= "', sparge_temp='" . $row['sparge_temp'];
+$sql .= "', sparge_ph='" . $row['sparge_ph'];
+$sql .= "', sparge_volume='" . $row['sparge_volume'];
+$sql .= "', sparge_source='" . $row['sparge_source'];
+$sql .= "', sparge_acid_type='" . $row['sparge_acid_type'];
+$sql .= "', sparge_acid_perc='" . $row['sparge_acid_perc'];
+$sql .= "', sparge_acid_amount='0";
+$sql .= "', mash_ph='" . $row['mash_ph'];
+$sql .= "', mash_name='" . $row['mash_name'];
+$sql .= "', calc_acid='" . $row['calc_acid'];
+$sql .= "', w1_name='" . mysqli_real_escape_string($link, $row['w1_name']);
+$sql .= "', w1_amount='" . $row['w1_amount'];
+$sql .= "', w1_calcium='" . $row['w1_calcium'];
+$sql .= "', w1_sulfate='" . $row['w1_sulfate'];
+$sql .= "', w1_chloride='" . $row['w1_chloride'];
+$sql .= "', w1_sodium='" . $row['w1_sodium'];
+$sql .= "', w1_magnesium='" . $row['w1_magnesium'];
+$sql .= "', w1_total_alkalinity='" . $row['w1_total_alkalinity'];
+$sql .= "', w1_ph='" . $row['w1_ph'];
+$sql .= "', w1_cost='" . $row['w1_cost'];
+$sql .= "', w2_name='" . mysqli_real_escape_string($link, $row['w2_name']);
+$sql .= "', w2_amount='" . $row['w2_amount'];
+$sql .= "', w2_calcium='" . $row['w2_calcium'];
+$sql .= "', w2_sulfate='" . $row['w2_sulfate'];
+$sql .= "', w2_chloride='" . $row['w2_chloride'];
+$sql .= "', w2_sodium='" . $row['w2_sodium'];
+$sql .= "', w2_magnesium='" . $row['w2_magnesium'];
+$sql .= "', w2_total_alkalinity='" . $row['w2_total_alkalinity'];
+$sql .= "', w2_ph='" . $row['w2_ph'];
+$sql .= "', w2_cost='" . $row['w2_cost'];
+$sql .= "', wa_acid_name='" . $row['wa_acid_name'];
+$sql .= "', wa_acid_perc='" . $row['wa_acid_perc'];
+$sql .= "', wa_base_name='" . $row['wa_base_name'];
+$sql .= "', json_fermentables='" . $row['json_fermentables'];
+$sql .= "', json_hops='" . $row['json_hops'];
+$sql .= "', json_miscs='" . $row['json_miscs'];
+$sql .= "', json_yeasts='" . $row['json_yeasts'];
+$sql .= "', json_mashs='" . $row['json_mashs'];
+$sql .= "';";
+syslog(LOG_NOTICE, $sql);
+
+$result = mysqli_query($link, $sql);
+if (! $result) {
+	syslog(LOG_NOTICE, "db_recipes: result: ".mysqli_error($link));
+} else {
+	$lastid = mysqli_insert_id($link);
+	syslog(LOG_NOTICE, "db_recipes: inserted record ".$lastid);
+}
+echo "<script>window.close();</script>";
+exit;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/www/rec_export.php	Thu Feb 28 22:50:58 2019 +0100
@@ -0,0 +1,11 @@
+<?php
+require_once($_SERVER['DOCUMENT_ROOT'].'/includes/global.inc.php');
+page_header('Recept export', 'rec_export');
+?>
+
+   <div id="MainPanel">
+   </div>
+
+<?php
+page_footer();
+?>

mercurial