Thu, 20 Jun 2019 13:55:12 +0200
Added packaging volume and add water or liquer to the beer after fermentation. Auto divide changing volumes between bottles and fusts. Upgrade the database in the crontask. Added these fields to the packaging tab screen.
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"; | |
49 | $sql .= "', brew_sparge_temperature='0', brew_sparge_volume='0', brew_sparge_ph='0.0"; | |
50 | $sql .= "', brew_preboil_volume='0', brew_preboil_sg='0', brew_preboil_ph='0.0"; | |
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"; | |
59 | $sql .= "', secondary_temp='0', secondary_end_date=NULL, tertiary_temp='0"; | |
60 | $sql .= "', package_date=NULL"; | |
61 | $sql .= ", bottle_amount='0', bottle_carbonation='0', bottle_priming_sugar='0', bottle_priming_amount='0', bottle_carbonation_temp='23"; | |
62 | $sql .= "', keg_amount='0', keg_carbonation='0', keg_priming_sugar='0', keg_priming_amount='0', keg_carbonation_temp='23"; | |
63 | $sql .= "', keg_forced_carb='0', keg_pressure='0"; | |
64 | $sql .= "', taste_notes='"; | |
65 | $sql .= "', taste_rate='0"; | |
66 | $sql .= "', taste_date=NULL"; | |
67 | $sql .= ", taste_color='"; | |
68 | $sql .= "', taste_transparency='"; | |
69 | $sql .= "', taste_head='"; | |
70 | $sql .= "', taste_aroma='"; | |
71 | $sql .= "', taste_taste='"; | |
72 | $sql .= "', taste_mouthfeel='"; | |
73 | $sql .= "', taste_aftertaste='"; | |
74 | // Style | |
75 | $sql .= "', st_name='" . mysqli_real_escape_string($link, $row['st_name']); | |
76 | $sql .= "', st_letter='" . mysqli_real_escape_string($link, $row['st_letter']); | |
77 | $sql .= "', st_guide='" . mysqli_real_escape_string($link, $row['st_guide']); | |
78 | $sql .= "', st_type='" . $row['st_type']; | |
79 | $sql .= "', st_category='" . mysqli_real_escape_string($link, $row['st_category']); | |
80 | $sql .= "', st_category_number='" . $row['st_category_number']; | |
81 | $sql .= "', st_og_min='" . $row['st_og_min']; | |
82 | $sql .= "', st_og_max='" . $row['st_og_max']; | |
83 | $sql .= "', st_fg_min='" . $row['st_fg_min']; | |
84 | $sql .= "', st_fg_max='" . $row['st_fg_max']; | |
85 | $sql .= "', st_ibu_min='" . $row['st_ibu_min']; | |
86 | $sql .= "', st_ibu_max='" . $row['st_ibu_max']; | |
87 | $sql .= "', st_color_min='" . $row['st_color_min']; | |
88 | $sql .= "', st_color_max='" . $row['st_color_max']; | |
89 | $sql .= "', st_carb_min='" . $row['st_carb_min']; | |
90 | $sql .= "', st_carb_max='" . $row['st_carb_max']; | |
91 | $sql .= "', st_abv_min='" . $row['st_abv_min']; | |
92 | $sql .= "', st_abv_max='" . $row['st_abv_max']; | |
93 | $sql .= "', type='" . $row['type']; | |
94 | $sql .= "', batch_size='" . $row['batch_size']; | |
95 | $sql .= "', boil_size='" . $row['boil_size']; | |
96 | $sql .= "', boil_time='" . $row['boil_time']; | |
97 | $sql .= "', efficiency='" . $row['efficiency']; | |
98 | $sql .= "', est_og='0.000"; | |
99 | $sql .= "', est_fg='0.000"; | |
100 | $sql .= "', est_abv='0.0"; | |
101 | $sql .= "', est_carb='0"; | |
102 | $sql .= "', est_color='0"; | |
103 | $sql .= "', color_method='0"; | |
104 | $sql .= "', est_ibu='0"; | |
105 | $sql .= "', ibu_method='0"; | |
304
c0ca21cdd291
Fix for recipe to product mash and water.
Michiel Broek <mbroek@mbse.eu>
parents:
303
diff
changeset
|
106 | $sql .= "', sparge_temp='" . $row['sparge_temp']; |
c0ca21cdd291
Fix for recipe to product mash and water.
Michiel Broek <mbroek@mbse.eu>
parents:
303
diff
changeset
|
107 | $sql .= "', sparge_ph='" . $row['sparge_ph']; |
c0ca21cdd291
Fix for recipe to product mash and water.
Michiel Broek <mbroek@mbse.eu>
parents:
303
diff
changeset
|
108 | $sql .= "', sparge_volume='" . $row['sparge_volume']; |
c0ca21cdd291
Fix for recipe to product mash and water.
Michiel Broek <mbroek@mbse.eu>
parents:
303
diff
changeset
|
109 | $sql .= "', sparge_source='" . $row['sparge_source']; |
c0ca21cdd291
Fix for recipe to product mash and water.
Michiel Broek <mbroek@mbse.eu>
parents:
303
diff
changeset
|
110 | $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
|
111 | $sql .= "', sparge_acid_perc='" . $row['sparge_acid_perc']; |
303 | 112 | $sql .= "', sparge_acid_amount='0"; |
304
c0ca21cdd291
Fix for recipe to product mash and water.
Michiel Broek <mbroek@mbse.eu>
parents:
303
diff
changeset
|
113 | $sql .= "', mash_ph='" . $row['mash_ph']; |
c0ca21cdd291
Fix for recipe to product mash and water.
Michiel Broek <mbroek@mbse.eu>
parents:
303
diff
changeset
|
114 | $sql .= "', mash_name='" . $row['mash_name']; |
303 | 115 | $sql .= "', calc_acid='1"; |
304
c0ca21cdd291
Fix for recipe to product mash and water.
Michiel Broek <mbroek@mbse.eu>
parents:
303
diff
changeset
|
116 | $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
|
117 | $sql .= "', w1_amount='" . $row['w1_amount']; |
c0ca21cdd291
Fix for recipe to product mash and water.
Michiel Broek <mbroek@mbse.eu>
parents:
303
diff
changeset
|
118 | $sql .= "', w1_calcium='" . $row['w1_calcium']; |
c0ca21cdd291
Fix for recipe to product mash and water.
Michiel Broek <mbroek@mbse.eu>
parents:
303
diff
changeset
|
119 | $sql .= "', w1_sulfate='" . $row['w1_sulfate']; |
c0ca21cdd291
Fix for recipe to product mash and water.
Michiel Broek <mbroek@mbse.eu>
parents:
303
diff
changeset
|
120 | $sql .= "', w1_chloride='" . $row['w1_chloride']; |
c0ca21cdd291
Fix for recipe to product mash and water.
Michiel Broek <mbroek@mbse.eu>
parents:
303
diff
changeset
|
121 | $sql .= "', w1_sodium='" . $row['w1_sodium']; |
c0ca21cdd291
Fix for recipe to product mash and water.
Michiel Broek <mbroek@mbse.eu>
parents:
303
diff
changeset
|
122 | $sql .= "', w1_magnesium='" . $row['w1_magnesium']; |
c0ca21cdd291
Fix for recipe to product mash and water.
Michiel Broek <mbroek@mbse.eu>
parents:
303
diff
changeset
|
123 | $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
|
124 | $sql .= "', w1_ph='" . $row['w1_ph']; |
c0ca21cdd291
Fix for recipe to product mash and water.
Michiel Broek <mbroek@mbse.eu>
parents:
303
diff
changeset
|
125 | $sql .= "', w1_cost='" . $row['w1_cost']; |
c0ca21cdd291
Fix for recipe to product mash and water.
Michiel Broek <mbroek@mbse.eu>
parents:
303
diff
changeset
|
126 | $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
|
127 | $sql .= "', w2_amount='" . $row['w2_amount']; |
c0ca21cdd291
Fix for recipe to product mash and water.
Michiel Broek <mbroek@mbse.eu>
parents:
303
diff
changeset
|
128 | $sql .= "', w2_calcium='" . $row['w2_calcium']; |
c0ca21cdd291
Fix for recipe to product mash and water.
Michiel Broek <mbroek@mbse.eu>
parents:
303
diff
changeset
|
129 | $sql .= "', w2_sulfate='" . $row['w2_sulfate']; |
c0ca21cdd291
Fix for recipe to product mash and water.
Michiel Broek <mbroek@mbse.eu>
parents:
303
diff
changeset
|
130 | $sql .= "', w2_chloride='" . $row['w2_chloride']; |
c0ca21cdd291
Fix for recipe to product mash and water.
Michiel Broek <mbroek@mbse.eu>
parents:
303
diff
changeset
|
131 | $sql .= "', w2_sodium='" . $row['w2_sodium']; |
c0ca21cdd291
Fix for recipe to product mash and water.
Michiel Broek <mbroek@mbse.eu>
parents:
303
diff
changeset
|
132 | $sql .= "', w2_magnesium='" . $row['w2_magnesium']; |
c0ca21cdd291
Fix for recipe to product mash and water.
Michiel Broek <mbroek@mbse.eu>
parents:
303
diff
changeset
|
133 | $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
|
134 | $sql .= "', w2_ph='" . $row['w2_ph']; |
c0ca21cdd291
Fix for recipe to product mash and water.
Michiel Broek <mbroek@mbse.eu>
parents:
303
diff
changeset
|
135 | $sql .= "', w2_cost='" . $row['w2_cost']; |
c0ca21cdd291
Fix for recipe to product mash and water.
Michiel Broek <mbroek@mbse.eu>
parents:
303
diff
changeset
|
136 | $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
|
137 | $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
|
138 | $sql .= "', wa_base_name='" . $row['wa_base_name']; |
305 | 139 | $sql .= "', json_fermentables='" . str_replace($rescapers,$rreplacements,$row['json_fermentables']); |
140 | $sql .= "', json_hops='" . str_replace($rescapers,$rreplacements,$row['json_hops']); | |
141 | $sql .= "', json_miscs='" . str_replace($rescapers,$rreplacements,$row['json_miscs']); | |
142 | $sql .= "', json_yeasts='" . str_replace($rescapers,$rreplacements,$row['json_yeasts']); | |
143 | $sql .= "', json_mashs='" . str_replace($rescapers,$rreplacements,$row['json_mashs']); | |
303 | 144 | $sql .= "';"; |
145 | syslog(LOG_NOTICE, $sql); | |
146 | ||
147 | $result = mysqli_query($link, $sql); | |
148 | if (! $result) { | |
149 | syslog(LOG_NOTICE, "rec_toproduct: result: ".mysqli_error($link)); | |
150 | } else { | |
151 | $lastid = mysqli_insert_id($link); | |
152 | syslog(LOG_NOTICE, "rec_toproduct: inserted record ".$lastid); | |
153 | } | |
154 | echo "<script>window.close();</script>"; | |
155 | exit; |