Mon, 06 Jan 2020 14:20:17 +0100
Interval is 3600 seconds when running on low battery.
303 | 1 | <?php |
2 | require_once('config.php'); | |
3 | ||
4 | ||
5 | $link = mysqli_connect(DBASE_HOST,DBASE_USER,DBASE_PASS,DBASE_NAME); | |
6 | if (! $link) { | |
7 | die('Connect Error (' . mysqli_connect_errno() . ') ' . mysqli_connect_error()); | |
8 | } | |
9 | if (! mysqli_set_charset($link, "utf8" )) { | |
10 | echo "error"; | |
11 | return 1; | |
12 | } | |
13 | ||
305 | 14 | $rescapers = array("'"); |
15 | $rreplacements = array("\\'"); | |
16 | ||
303 | 17 | date_default_timezone_set('Europe/Amsterdam'); |
18 | if (isset($_GET["record"])) | |
19 | $record = $_GET["record"]; | |
20 | else | |
21 | $record = 78; | |
22 | $result = mysqli_query($link, "SELECT * FROM recipes WHERE record='".$record."'"); | |
23 | $row = mysqli_fetch_array($result); | |
24 | ||
25 | ||
26 | /* | |
27 | * Copy this to a fresh product. | |
28 | */ | |
29 | $sql = "INSERT INTO `products` SET "; | |
30 | $sql .= "name='" . mysqli_real_escape_string($link, $row['name']); | |
31 | $sql .= "', uuid='" . str_replace("\n", "", file_get_contents('/proc/sys/kernel/random/uuid')); | |
32 | $sql .= "', code='" . date("YmdHi"); | |
33 | $sql .= "', birth='" . date("Y-m-d"); | |
34 | $sql .= "', stage='1"; | |
35 | $sql .= "', notes='" . mysqli_real_escape_string($link, $row['notes']); | |
36 | $sql .= "', log_brew='0', log_fermentation='0', inventory_reduced='0', locked='0"; | |
37 | // Equipment | |
38 | $sql .= "', eq_name='Kies zelf een installatie!"; | |
39 | $sql .= "', eq_boil_size='" . $row['boil_size']; | |
40 | $sql .= "', eq_batch_size='" . $row['batch_size']; | |
41 | $sql .= "', eq_tun_volume='20', eq_tun_weight='2', eq_tun_specific_heat='0.11', eq_tun_material='0"; | |
42 | $sql .= "', eq_tun_height='20', eq_top_up_water='0', eq_trub_chiller_loss='0.5', eq_evap_rate='1.8"; | |
43 | $sql .= "', eq_boil_time='" . $row['boil_time']; | |
44 | $sql .= "', eq_calc_boil_volume='1', eq_top_up_kettle='0', eq_hop_utilization='100', eq_notes='"; | |
45 | $sql .= "', eq_lauter_volume='20', eq_lauter_height='20', eq_lauter_deadspace='0.5', eq_kettle_volume='20"; | |
46 | $sql .= "', eq_kettle_height='20', eq_mash_volume='18', eq_mash_max='6', eq_efficiency='75"; | |
47 | // brewdate | |
48 | $sql .= "', brew_date_start=NULL, brew_mash_ph='0.0', brew_mash_sg='1.000"; | |
536
ada10cabf217
Updated design notes. Added missing fields to rec_toproduct.
Michiel Broek <mbroek@mbse.eu>
parents:
518
diff
changeset
|
49 | $sql .= "', brew_mash_efficiency='0.0', brew_sparge_ph='0.0', brew_sparge_temperature='85.0"; |
ada10cabf217
Updated design notes. Added missing fields to rec_toproduct.
Michiel Broek <mbroek@mbse.eu>
parents:
518
diff
changeset
|
50 | $sql .= "', brew_preboil_volume='0', brew_preboil_sg='0', brew_preboil_ph='0.0', brew_preboil_efficiency='0"; |
303 | 51 | $sql .= "', brew_aboil_volume='0', brew_aboil_sg='0', brew_aboil_ph='0.0', brew_aboil_efficiency='0"; |
52 | $sql .= "', brew_cooling_method='0', brew_cooling_time='0', brew_cooling_to='20"; | |
53 | $sql .= "', brew_whirlpool9='0', brew_whirlpool7='0', brew_whirlpool6='0', brew_whirlpool2='0"; | |
54 | $sql .= "', brew_aeration_time='0', brew_aeration_speed='0', brew_aeration_type='0"; | |
55 | $sql .= "', brew_fermenter_volume='" . floatval($row['batch_size']) - 0.5; | |
56 | $sql .= "', brew_fermenter_extrawater='0', brew_fermenter_tcloss='0.5', brew_fermenter_sg='0"; | |
57 | $sql .= "', brew_fermenter_ibu='0', brew_fermenter_color='0', brew_date_end=NULL, og='0', fg='0"; | |
58 | $sql .= "', primary_start_temp='0', primary_max_temp='0', primary_end_temp='0', primary_end_date=NULL, primary_end_sg='0"; | |
460
046ff5fdc96c
Implemented products.secondary_end_sg field. The missing values are updated by the crontask.
Michiel Broek <mbroek@mbse.eu>
parents:
458
diff
changeset
|
59 | $sql .= "', secondary_temp='0', secondary_end_sg='0', secondary_end_date=NULL, tertiary_temp='0"; |
458
47b592993dd5
Version 0.3.15. Implemented final pH during packaging. Updated prod_new, prod_duplicate, prod_edit, rec_toproduct for this new field and several other fields added in previous versions.
Michiel Broek <mbroek@mbse.eu>
parents:
432
diff
changeset
|
60 | $sql .= "', package_date=NULL, package_volume='0', package_infuse_amount='0', package_infuse_abv='0', package_infuse_notes='"; |
47b592993dd5
Version 0.3.15. Implemented final pH during packaging. Updated prod_new, prod_duplicate, prod_edit, rec_toproduct for this new field and several other fields added in previous versions.
Michiel Broek <mbroek@mbse.eu>
parents:
432
diff
changeset
|
61 | $sql .= "', package_abv='0', package_ph='0"; |
47b592993dd5
Version 0.3.15. Implemented final pH during packaging. Updated prod_new, prod_duplicate, prod_edit, rec_toproduct for this new field and several other fields added in previous versions.
Michiel Broek <mbroek@mbse.eu>
parents:
432
diff
changeset
|
62 | $sql .= "', bottle_amount='0', bottle_carbonation='0', bottle_priming_water='0', bottle_priming_amount='0', bottle_carbonation_temp='23"; |
47b592993dd5
Version 0.3.15. Implemented final pH during packaging. Updated prod_new, prod_duplicate, prod_edit, rec_toproduct for this new field and several other fields added in previous versions.
Michiel Broek <mbroek@mbse.eu>
parents:
432
diff
changeset
|
63 | $sql .= "', keg_amount='0', keg_carbonation='0', keg_priming_water='0', keg_priming_amount='0', keg_carbonation_temp='23"; |
303 | 64 | $sql .= "', keg_forced_carb='0', keg_pressure='0"; |
65 | $sql .= "', taste_notes='"; | |
66 | $sql .= "', taste_rate='0"; | |
67 | $sql .= "', taste_date=NULL"; | |
68 | $sql .= ", taste_color='"; | |
69 | $sql .= "', taste_transparency='"; | |
70 | $sql .= "', taste_head='"; | |
71 | $sql .= "', taste_aroma='"; | |
72 | $sql .= "', taste_taste='"; | |
73 | $sql .= "', taste_mouthfeel='"; | |
74 | $sql .= "', taste_aftertaste='"; | |
75 | // Style | |
76 | $sql .= "', st_name='" . mysqli_real_escape_string($link, $row['st_name']); | |
77 | $sql .= "', st_letter='" . mysqli_real_escape_string($link, $row['st_letter']); | |
78 | $sql .= "', st_guide='" . mysqli_real_escape_string($link, $row['st_guide']); | |
79 | $sql .= "', st_type='" . $row['st_type']; | |
80 | $sql .= "', st_category='" . mysqli_real_escape_string($link, $row['st_category']); | |
81 | $sql .= "', st_category_number='" . $row['st_category_number']; | |
82 | $sql .= "', st_og_min='" . $row['st_og_min']; | |
83 | $sql .= "', st_og_max='" . $row['st_og_max']; | |
84 | $sql .= "', st_fg_min='" . $row['st_fg_min']; | |
85 | $sql .= "', st_fg_max='" . $row['st_fg_max']; | |
86 | $sql .= "', st_ibu_min='" . $row['st_ibu_min']; | |
87 | $sql .= "', st_ibu_max='" . $row['st_ibu_max']; | |
88 | $sql .= "', st_color_min='" . $row['st_color_min']; | |
89 | $sql .= "', st_color_max='" . $row['st_color_max']; | |
90 | $sql .= "', st_carb_min='" . $row['st_carb_min']; | |
91 | $sql .= "', st_carb_max='" . $row['st_carb_max']; | |
92 | $sql .= "', st_abv_min='" . $row['st_abv_min']; | |
93 | $sql .= "', st_abv_max='" . $row['st_abv_max']; | |
94 | $sql .= "', type='" . $row['type']; | |
95 | $sql .= "', batch_size='" . $row['batch_size']; | |
96 | $sql .= "', boil_size='" . $row['boil_size']; | |
97 | $sql .= "', boil_time='" . $row['boil_time']; | |
98 | $sql .= "', efficiency='" . $row['efficiency']; | |
99 | $sql .= "', est_og='0.000"; | |
100 | $sql .= "', est_fg='0.000"; | |
101 | $sql .= "', est_abv='0.0"; | |
102 | $sql .= "', est_carb='0"; | |
103 | $sql .= "', est_color='0"; | |
104 | $sql .= "', color_method='0"; | |
105 | $sql .= "', est_ibu='0"; | |
106 | $sql .= "', ibu_method='0"; | |
304
c0ca21cdd291
Fix for recipe to product mash and water.
Michiel Broek <mbroek@mbse.eu>
parents:
303
diff
changeset
|
107 | $sql .= "', sparge_temp='" . $row['sparge_temp']; |
c0ca21cdd291
Fix for recipe to product mash and water.
Michiel Broek <mbroek@mbse.eu>
parents:
303
diff
changeset
|
108 | $sql .= "', sparge_ph='" . $row['sparge_ph']; |
c0ca21cdd291
Fix for recipe to product mash and water.
Michiel Broek <mbroek@mbse.eu>
parents:
303
diff
changeset
|
109 | $sql .= "', sparge_volume='" . $row['sparge_volume']; |
c0ca21cdd291
Fix for recipe to product mash and water.
Michiel Broek <mbroek@mbse.eu>
parents:
303
diff
changeset
|
110 | $sql .= "', sparge_source='" . $row['sparge_source']; |
c0ca21cdd291
Fix for recipe to product mash and water.
Michiel Broek <mbroek@mbse.eu>
parents:
303
diff
changeset
|
111 | $sql .= "', sparge_acid_type='" . $row['sparge_acid_type']; |
c0ca21cdd291
Fix for recipe to product mash and water.
Michiel Broek <mbroek@mbse.eu>
parents:
303
diff
changeset
|
112 | $sql .= "', sparge_acid_perc='" . $row['sparge_acid_perc']; |
303 | 113 | $sql .= "', sparge_acid_amount='0"; |
304
c0ca21cdd291
Fix for recipe to product mash and water.
Michiel Broek <mbroek@mbse.eu>
parents:
303
diff
changeset
|
114 | $sql .= "', mash_ph='" . $row['mash_ph']; |
c0ca21cdd291
Fix for recipe to product mash and water.
Michiel Broek <mbroek@mbse.eu>
parents:
303
diff
changeset
|
115 | $sql .= "', mash_name='" . $row['mash_name']; |
303 | 116 | $sql .= "', calc_acid='1"; |
304
c0ca21cdd291
Fix for recipe to product mash and water.
Michiel Broek <mbroek@mbse.eu>
parents:
303
diff
changeset
|
117 | $sql .= "', w1_name='" . mysqli_real_escape_string($link, $row['w1_name']); |
c0ca21cdd291
Fix for recipe to product mash and water.
Michiel Broek <mbroek@mbse.eu>
parents:
303
diff
changeset
|
118 | $sql .= "', w1_amount='" . $row['w1_amount']; |
c0ca21cdd291
Fix for recipe to product mash and water.
Michiel Broek <mbroek@mbse.eu>
parents:
303
diff
changeset
|
119 | $sql .= "', w1_calcium='" . $row['w1_calcium']; |
c0ca21cdd291
Fix for recipe to product mash and water.
Michiel Broek <mbroek@mbse.eu>
parents:
303
diff
changeset
|
120 | $sql .= "', w1_sulfate='" . $row['w1_sulfate']; |
c0ca21cdd291
Fix for recipe to product mash and water.
Michiel Broek <mbroek@mbse.eu>
parents:
303
diff
changeset
|
121 | $sql .= "', w1_chloride='" . $row['w1_chloride']; |
c0ca21cdd291
Fix for recipe to product mash and water.
Michiel Broek <mbroek@mbse.eu>
parents:
303
diff
changeset
|
122 | $sql .= "', w1_sodium='" . $row['w1_sodium']; |
c0ca21cdd291
Fix for recipe to product mash and water.
Michiel Broek <mbroek@mbse.eu>
parents:
303
diff
changeset
|
123 | $sql .= "', w1_magnesium='" . $row['w1_magnesium']; |
c0ca21cdd291
Fix for recipe to product mash and water.
Michiel Broek <mbroek@mbse.eu>
parents:
303
diff
changeset
|
124 | $sql .= "', w1_total_alkalinity='" . $row['w1_total_alkalinity']; |
c0ca21cdd291
Fix for recipe to product mash and water.
Michiel Broek <mbroek@mbse.eu>
parents:
303
diff
changeset
|
125 | $sql .= "', w1_ph='" . $row['w1_ph']; |
c0ca21cdd291
Fix for recipe to product mash and water.
Michiel Broek <mbroek@mbse.eu>
parents:
303
diff
changeset
|
126 | $sql .= "', w1_cost='" . $row['w1_cost']; |
c0ca21cdd291
Fix for recipe to product mash and water.
Michiel Broek <mbroek@mbse.eu>
parents:
303
diff
changeset
|
127 | $sql .= "', w2_name='" . mysqli_real_escape_string($link, $row['w2_name']); |
c0ca21cdd291
Fix for recipe to product mash and water.
Michiel Broek <mbroek@mbse.eu>
parents:
303
diff
changeset
|
128 | $sql .= "', w2_amount='" . $row['w2_amount']; |
c0ca21cdd291
Fix for recipe to product mash and water.
Michiel Broek <mbroek@mbse.eu>
parents:
303
diff
changeset
|
129 | $sql .= "', w2_calcium='" . $row['w2_calcium']; |
c0ca21cdd291
Fix for recipe to product mash and water.
Michiel Broek <mbroek@mbse.eu>
parents:
303
diff
changeset
|
130 | $sql .= "', w2_sulfate='" . $row['w2_sulfate']; |
c0ca21cdd291
Fix for recipe to product mash and water.
Michiel Broek <mbroek@mbse.eu>
parents:
303
diff
changeset
|
131 | $sql .= "', w2_chloride='" . $row['w2_chloride']; |
c0ca21cdd291
Fix for recipe to product mash and water.
Michiel Broek <mbroek@mbse.eu>
parents:
303
diff
changeset
|
132 | $sql .= "', w2_sodium='" . $row['w2_sodium']; |
c0ca21cdd291
Fix for recipe to product mash and water.
Michiel Broek <mbroek@mbse.eu>
parents:
303
diff
changeset
|
133 | $sql .= "', w2_magnesium='" . $row['w2_magnesium']; |
c0ca21cdd291
Fix for recipe to product mash and water.
Michiel Broek <mbroek@mbse.eu>
parents:
303
diff
changeset
|
134 | $sql .= "', w2_total_alkalinity='" . $row['w2_total_alkalinity']; |
c0ca21cdd291
Fix for recipe to product mash and water.
Michiel Broek <mbroek@mbse.eu>
parents:
303
diff
changeset
|
135 | $sql .= "', w2_ph='" . $row['w2_ph']; |
c0ca21cdd291
Fix for recipe to product mash and water.
Michiel Broek <mbroek@mbse.eu>
parents:
303
diff
changeset
|
136 | $sql .= "', w2_cost='" . $row['w2_cost']; |
536
ada10cabf217
Updated design notes. Added missing fields to rec_toproduct.
Michiel Broek <mbroek@mbse.eu>
parents:
518
diff
changeset
|
137 | $sql .= "', wg_amount='" . $row['wg_amount']; |
ada10cabf217
Updated design notes. Added missing fields to rec_toproduct.
Michiel Broek <mbroek@mbse.eu>
parents:
518
diff
changeset
|
138 | $sql .= "', wg_calcium='" . $row['wg_calcium']; |
ada10cabf217
Updated design notes. Added missing fields to rec_toproduct.
Michiel Broek <mbroek@mbse.eu>
parents:
518
diff
changeset
|
139 | $sql .= "', wg_sulfate='" . $row['wg_sulfate']; |
ada10cabf217
Updated design notes. Added missing fields to rec_toproduct.
Michiel Broek <mbroek@mbse.eu>
parents:
518
diff
changeset
|
140 | $sql .= "', wg_chloride='" . $row['wg_chloride']; |
ada10cabf217
Updated design notes. Added missing fields to rec_toproduct.
Michiel Broek <mbroek@mbse.eu>
parents:
518
diff
changeset
|
141 | $sql .= "', wg_sodium='" . $row['wg_sodium']; |
ada10cabf217
Updated design notes. Added missing fields to rec_toproduct.
Michiel Broek <mbroek@mbse.eu>
parents:
518
diff
changeset
|
142 | $sql .= "', wg_magnesium='" . $row['wg_magnesium']; |
ada10cabf217
Updated design notes. Added missing fields to rec_toproduct.
Michiel Broek <mbroek@mbse.eu>
parents:
518
diff
changeset
|
143 | $sql .= "', wg_total_alkalinity='" . $row['wg_total_alkalinity']; |
ada10cabf217
Updated design notes. Added missing fields to rec_toproduct.
Michiel Broek <mbroek@mbse.eu>
parents:
518
diff
changeset
|
144 | $sql .= "', wg_ph='" . $row['wg_ph']; |
ada10cabf217
Updated design notes. Added missing fields to rec_toproduct.
Michiel Broek <mbroek@mbse.eu>
parents:
518
diff
changeset
|
145 | $sql .= "', wb_calcium='" . $row['wb_calcium']; |
ada10cabf217
Updated design notes. Added missing fields to rec_toproduct.
Michiel Broek <mbroek@mbse.eu>
parents:
518
diff
changeset
|
146 | $sql .= "', wb_sulfate='" . $row['wb_sulfate']; |
ada10cabf217
Updated design notes. Added missing fields to rec_toproduct.
Michiel Broek <mbroek@mbse.eu>
parents:
518
diff
changeset
|
147 | $sql .= "', wb_chloride='" . $row['wb_chloride']; |
ada10cabf217
Updated design notes. Added missing fields to rec_toproduct.
Michiel Broek <mbroek@mbse.eu>
parents:
518
diff
changeset
|
148 | $sql .= "', wb_sodium='" . $row['wb_sodium']; |
ada10cabf217
Updated design notes. Added missing fields to rec_toproduct.
Michiel Broek <mbroek@mbse.eu>
parents:
518
diff
changeset
|
149 | $sql .= "', wb_magnesium='" . $row['wb_magnesium']; |
ada10cabf217
Updated design notes. Added missing fields to rec_toproduct.
Michiel Broek <mbroek@mbse.eu>
parents:
518
diff
changeset
|
150 | $sql .= "', wb_total_alkalinity='" . $row['wb_total_alkalinity']; |
ada10cabf217
Updated design notes. Added missing fields to rec_toproduct.
Michiel Broek <mbroek@mbse.eu>
parents:
518
diff
changeset
|
151 | $sql .= "', wb_ph='" . $row['wb_ph']; |
304
c0ca21cdd291
Fix for recipe to product mash and water.
Michiel Broek <mbroek@mbse.eu>
parents:
303
diff
changeset
|
152 | $sql .= "', wa_acid_name='" . $row['wa_acid_name']; |
c0ca21cdd291
Fix for recipe to product mash and water.
Michiel Broek <mbroek@mbse.eu>
parents:
303
diff
changeset
|
153 | $sql .= "', wa_acid_perc='" . $row['wa_acid_perc']; |
c0ca21cdd291
Fix for recipe to product mash and water.
Michiel Broek <mbroek@mbse.eu>
parents:
303
diff
changeset
|
154 | $sql .= "', wa_base_name='" . $row['wa_base_name']; |
518
00e110567fee
The default starter SG changed to 1.037. Added several tooltips on the yeast tab.
Michiel Broek <mbroek@mbse.eu>
parents:
460
diff
changeset
|
155 | $sql .= "', starter_enable='0', starter_type='0', starter_sg='1.037', starter_viability='97"; |
458
47b592993dd5
Version 0.3.15. Implemented final pH during packaging. Updated prod_new, prod_duplicate, prod_edit, rec_toproduct for this new field and several other fields added in previous versions.
Michiel Broek <mbroek@mbse.eu>
parents:
432
diff
changeset
|
156 | $sql .= "', prop1_type='0', prop1_volume='0', prop2_type='0', prop2_volume='0"; |
47b592993dd5
Version 0.3.15. Implemented final pH during packaging. Updated prod_new, prod_duplicate, prod_edit, rec_toproduct for this new field and several other fields added in previous versions.
Michiel Broek <mbroek@mbse.eu>
parents:
432
diff
changeset
|
157 | $sql .= "', prop3_type='0', prop3_volume='0', prop4_type='0', prop4_volume='0"; |
536
ada10cabf217
Updated design notes. Added missing fields to rec_toproduct.
Michiel Broek <mbroek@mbse.eu>
parents:
518
diff
changeset
|
158 | $sql .= "', divide_type='0', divide_parts='0', divide_part='0', divide_size='0', divide_factor='1.0"; |
305 | 159 | $sql .= "', json_fermentables='" . str_replace($rescapers,$rreplacements,$row['json_fermentables']); |
160 | $sql .= "', json_hops='" . str_replace($rescapers,$rreplacements,$row['json_hops']); | |
161 | $sql .= "', json_miscs='" . str_replace($rescapers,$rreplacements,$row['json_miscs']); | |
162 | $sql .= "', json_yeasts='" . str_replace($rescapers,$rreplacements,$row['json_yeasts']); | |
163 | $sql .= "', json_mashs='" . str_replace($rescapers,$rreplacements,$row['json_mashs']); | |
303 | 164 | $sql .= "';"; |
165 | syslog(LOG_NOTICE, $sql); | |
166 | ||
167 | $result = mysqli_query($link, $sql); | |
168 | if (! $result) { | |
169 | syslog(LOG_NOTICE, "rec_toproduct: result: ".mysqli_error($link)); | |
170 | } else { | |
171 | $lastid = mysqli_insert_id($link); | |
172 | syslog(LOG_NOTICE, "rec_toproduct: inserted record ".$lastid); | |
173 | } | |
174 | echo "<script>window.close();</script>"; | |
175 | exit; |