Wed, 16 Oct 2019 21:05:03 +0200
Added dutch array strings to a global php script. Changed fermentables, hops, yeast and misc inventory scripts to use these strings between the database scripts and javascript scripts. This makes filtering on types strings useable. Added these changes to the product/recipe forum and print exports too.
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"; | |
432
99dcd8488b62
Merged brew_sparge_temperature with sparge_temp and brew_sparge_volume with sparge_volume.
Michiel Broek <mbroek@mbse.eu>
parents:
305
diff
changeset
|
49 | $sql .= "', brew_sparge_ph='0.0"; |
303 | 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"; | |
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']; |
c0ca21cdd291
Fix for recipe to product mash and water.
Michiel Broek <mbroek@mbse.eu>
parents:
303
diff
changeset
|
137 | $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
|
138 | $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
|
139 | $sql .= "', wa_base_name='" . $row['wa_base_name']; |
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
|
140 | $sql .= "', starter_enable='0', starter_type='0', starter_sg='1.040', starter_viability='97"; |
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
|
141 | $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
|
142 | $sql .= "', prop3_type='0', prop3_volume='0', prop4_type='0', prop4_volume='0"; |
305 | 143 | $sql .= "', json_fermentables='" . str_replace($rescapers,$rreplacements,$row['json_fermentables']); |
144 | $sql .= "', json_hops='" . str_replace($rescapers,$rreplacements,$row['json_hops']); | |
145 | $sql .= "', json_miscs='" . str_replace($rescapers,$rreplacements,$row['json_miscs']); | |
146 | $sql .= "', json_yeasts='" . str_replace($rescapers,$rreplacements,$row['json_yeasts']); | |
147 | $sql .= "', json_mashs='" . str_replace($rescapers,$rreplacements,$row['json_mashs']); | |
303 | 148 | $sql .= "';"; |
149 | syslog(LOG_NOTICE, $sql); | |
150 | ||
151 | $result = mysqli_query($link, $sql); | |
152 | if (! $result) { | |
153 | syslog(LOG_NOTICE, "rec_toproduct: result: ".mysqli_error($link)); | |
154 | } else { | |
155 | $lastid = mysqli_insert_id($link); | |
156 | syslog(LOG_NOTICE, "rec_toproduct: inserted record ".$lastid); | |
157 | } | |
158 | echo "<script>window.close();</script>"; | |
159 | exit; |