Sun, 15 Dec 2019 15:08:09 +0100
Version 0.3.27 More code for iSpindels. All online/offline data in the database is now handles as integers. Nodes timeout use the configured interval time from the nodes.
11 | 1 | <?php |
2 | /* | |
3 | * Import inventory from brouwhulp | |
4 | */ | |
5 | ||
6 | require("../config.php"); | |
7 | require("../version.php"); | |
8 | require("../includes/formulas.php"); | |
9 | ||
10 | echo "Start adding data from brouwhulp\n"; | |
11 | ||
12 | $db = mysqli_connect(DBASE_HOST, DBASE_USER, DBASE_PASS, DBASE_NAME); | |
13 | if (! $db) { | |
14 | die('Connect Error (' . mysqli_connect_errno() . ') ' . mysqli_connect_error()); | |
15 | } | |
77
a9f8de2d7b2b
Fixed most charset problems. Added fpdf library. Added inventory pdf creation.
Michiel Broek <mbroek@mbse.eu>
parents:
72
diff
changeset
|
16 | mysqli_set_charset($db, "utf8" ); |
11 | 17 | |
18 | $brouwhulp = '/home/mbroek/Documents/brouwhulp'; | |
106
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
19 | $pCara = 0; |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
20 | $pSugar = 0; |
136
bcc4583fd013
Fixed estimate FG calculation during recipes import. Added estimate FG calculation in the recipe editor but do not yet update the recipe. Added SVG calculation to the recipes editor. Added calculations for hop aroma and flavour contribution.
Michiel Broek <mbroek@mbse.eu>
parents:
131
diff
changeset
|
21 | $svg = 77; |
106
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
22 | $efficiency = 75; |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
23 | $batch_size = 20; |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
24 | $colorw = 0; |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
25 | $f_sugars = 0; |
11 | 26 | |
89
082c23b26055
Missing Water agent costs from Brouwhulp import are now added from the imported miscs database. The printed recipe report now calculates the beer color from the ingredients. Also set during recipes import. This will later allow to set the color method for each recipe individually.
Michiel Broek <mbroek@mbse.eu>
parents:
88
diff
changeset
|
27 | function get_miscs_cost($miscname) { |
082c23b26055
Missing Water agent costs from Brouwhulp import are now added from the imported miscs database. The printed recipe report now calculates the beer color from the ingredients. Also set during recipes import. This will later allow to set the color method for each recipe individually.
Michiel Broek <mbroek@mbse.eu>
parents:
88
diff
changeset
|
28 | global $db; |
082c23b26055
Missing Water agent costs from Brouwhulp import are now added from the imported miscs database. The printed recipe report now calculates the beer color from the ingredients. Also set during recipes import. This will later allow to set the color method for each recipe individually.
Michiel Broek <mbroek@mbse.eu>
parents:
88
diff
changeset
|
29 | |
082c23b26055
Missing Water agent costs from Brouwhulp import are now added from the imported miscs database. The printed recipe report now calculates the beer color from the ingredients. Also set during recipes import. This will later allow to set the color method for each recipe individually.
Michiel Broek <mbroek@mbse.eu>
parents:
88
diff
changeset
|
30 | if ($result = mysqli_query($db, "SELECT cost FROM inventory_miscs WHERE name='$miscname'")) { |
082c23b26055
Missing Water agent costs from Brouwhulp import are now added from the imported miscs database. The printed recipe report now calculates the beer color from the ingredients. Also set during recipes import. This will later allow to set the color method for each recipe individually.
Michiel Broek <mbroek@mbse.eu>
parents:
88
diff
changeset
|
31 | if ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { |
082c23b26055
Missing Water agent costs from Brouwhulp import are now added from the imported miscs database. The printed recipe report now calculates the beer color from the ingredients. Also set during recipes import. This will later allow to set the color method for each recipe individually.
Michiel Broek <mbroek@mbse.eu>
parents:
88
diff
changeset
|
32 | return floatval($row['cost']); |
082c23b26055
Missing Water agent costs from Brouwhulp import are now added from the imported miscs database. The printed recipe report now calculates the beer color from the ingredients. Also set during recipes import. This will later allow to set the color method for each recipe individually.
Michiel Broek <mbroek@mbse.eu>
parents:
88
diff
changeset
|
33 | } |
082c23b26055
Missing Water agent costs from Brouwhulp import are now added from the imported miscs database. The printed recipe report now calculates the beer color from the ingredients. Also set during recipes import. This will later allow to set the color method for each recipe individually.
Michiel Broek <mbroek@mbse.eu>
parents:
88
diff
changeset
|
34 | } |
082c23b26055
Missing Water agent costs from Brouwhulp import are now added from the imported miscs database. The printed recipe report now calculates the beer color from the ingredients. Also set during recipes import. This will later allow to set the color method for each recipe individually.
Michiel Broek <mbroek@mbse.eu>
parents:
88
diff
changeset
|
35 | return 0.0; |
082c23b26055
Missing Water agent costs from Brouwhulp import are now added from the imported miscs database. The printed recipe report now calculates the beer color from the ingredients. Also set during recipes import. This will later allow to set the color method for each recipe individually.
Michiel Broek <mbroek@mbse.eu>
parents:
88
diff
changeset
|
36 | } |
082c23b26055
Missing Water agent costs from Brouwhulp import are now added from the imported miscs database. The printed recipe report now calculates the beer color from the ingredients. Also set during recipes import. This will later allow to set the color method for each recipe individually.
Michiel Broek <mbroek@mbse.eu>
parents:
88
diff
changeset
|
37 | |
082c23b26055
Missing Water agent costs from Brouwhulp import are now added from the imported miscs database. The printed recipe report now calculates the beer color from the ingredients. Also set during recipes import. This will later allow to set the color method for each recipe individually.
Michiel Broek <mbroek@mbse.eu>
parents:
88
diff
changeset
|
38 | |
082c23b26055
Missing Water agent costs from Brouwhulp import are now added from the imported miscs database. The printed recipe report now calculates the beer color from the ingredients. Also set during recipes import. This will later allow to set the color method for each recipe individually.
Michiel Broek <mbroek@mbse.eu>
parents:
88
diff
changeset
|
39 | |
11 | 40 | function do_fermentables() |
41 | { | |
42 | global $brouwhulp, $db; | |
43 | ||
44 | echo " Start adding fermentables to the database\n"; | |
45 | $sql = "TRUNCATE TABLE inventory_fermentables;"; | |
46 | if (! $result = mysqli_query($db, $sql)) { | |
47 | printf("Error: %s\n", mysqli_error($db)); | |
48 | } | |
49 | $myfermentables = simplexml_load_file($brouwhulp . '/fermentables.xml'); | |
50 | ||
51 | foreach ($myfermentables->FERMENTABLE as $fermentable) { | |
52 | ||
53 | $sql = "INSERT INTO inventory_fermentables SET name='" . mysqli_real_escape_string($db, $fermentable->NAME); | |
195
2ac491548d8d
Fermentables database bool to int types. Dropdown lists are using tables with indexes. Dropdown lists display in Dutch. Save and delete in the database now use POST instead of GET. Added the added and dissolved_protein fields. Removed the ibu_gal_per_lb field. Redesigned the web page. Code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
54 | if ($fermentable->TYPE == 'Grain') |
2ac491548d8d
Fermentables database bool to int types. Dropdown lists are using tables with indexes. Dropdown lists display in Dutch. Save and delete in the database now use POST instead of GET. Added the added and dissolved_protein fields. Removed the ibu_gal_per_lb field. Redesigned the web page. Code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
55 | $sql .= "', type='0"; |
2ac491548d8d
Fermentables database bool to int types. Dropdown lists are using tables with indexes. Dropdown lists display in Dutch. Save and delete in the database now use POST instead of GET. Added the added and dissolved_protein fields. Removed the ibu_gal_per_lb field. Redesigned the web page. Code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
56 | else if ($fermentable->TYPE == 'Sugar') |
2ac491548d8d
Fermentables database bool to int types. Dropdown lists are using tables with indexes. Dropdown lists display in Dutch. Save and delete in the database now use POST instead of GET. Added the added and dissolved_protein fields. Removed the ibu_gal_per_lb field. Redesigned the web page. Code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
57 | $sql .= "', type='1"; |
2ac491548d8d
Fermentables database bool to int types. Dropdown lists are using tables with indexes. Dropdown lists display in Dutch. Save and delete in the database now use POST instead of GET. Added the added and dissolved_protein fields. Removed the ibu_gal_per_lb field. Redesigned the web page. Code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
58 | else if ($fermentable->TYPE == 'Extract') |
2ac491548d8d
Fermentables database bool to int types. Dropdown lists are using tables with indexes. Dropdown lists display in Dutch. Save and delete in the database now use POST instead of GET. Added the added and dissolved_protein fields. Removed the ibu_gal_per_lb field. Redesigned the web page. Code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
59 | $sql .= "', type='2"; |
2ac491548d8d
Fermentables database bool to int types. Dropdown lists are using tables with indexes. Dropdown lists display in Dutch. Save and delete in the database now use POST instead of GET. Added the added and dissolved_protein fields. Removed the ibu_gal_per_lb field. Redesigned the web page. Code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
60 | else if ($fermentable->TYPE == 'Dry extract') |
2ac491548d8d
Fermentables database bool to int types. Dropdown lists are using tables with indexes. Dropdown lists display in Dutch. Save and delete in the database now use POST instead of GET. Added the added and dissolved_protein fields. Removed the ibu_gal_per_lb field. Redesigned the web page. Code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
61 | $sql .= "', type='3"; |
2ac491548d8d
Fermentables database bool to int types. Dropdown lists are using tables with indexes. Dropdown lists display in Dutch. Save and delete in the database now use POST instead of GET. Added the added and dissolved_protein fields. Removed the ibu_gal_per_lb field. Redesigned the web page. Code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
62 | else if ($fermentable->TYPE == 'Adjunct') |
2ac491548d8d
Fermentables database bool to int types. Dropdown lists are using tables with indexes. Dropdown lists display in Dutch. Save and delete in the database now use POST instead of GET. Added the added and dissolved_protein fields. Removed the ibu_gal_per_lb field. Redesigned the web page. Code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
63 | $sql .= "', type='4"; |
2ac491548d8d
Fermentables database bool to int types. Dropdown lists are using tables with indexes. Dropdown lists display in Dutch. Save and delete in the database now use POST instead of GET. Added the added and dissolved_protein fields. Removed the ibu_gal_per_lb field. Redesigned the web page. Code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
64 | else |
2ac491548d8d
Fermentables database bool to int types. Dropdown lists are using tables with indexes. Dropdown lists display in Dutch. Save and delete in the database now use POST instead of GET. Added the added and dissolved_protein fields. Removed the ibu_gal_per_lb field. Redesigned the web page. Code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
65 | echo "Unknown TYPE " . $fermentable->TYPE . PHP_EOL; |
11 | 66 | if ($fermentable->YIELD) |
118
07daa505d309
Improved float precision for databases import.
Michiel Broek <mbroek@mbse.eu>
parents:
114
diff
changeset
|
67 | $sql .= "', yield='" . floatval($fermentable->YIELD); |
11 | 68 | if ($fermentable->COLOR) { |
195
2ac491548d8d
Fermentables database bool to int types. Dropdown lists are using tables with indexes. Dropdown lists display in Dutch. Save and delete in the database now use POST instead of GET. Added the added and dissolved_protein fields. Removed the ibu_gal_per_lb field. Redesigned the web page. Code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
69 | $sql .= "', color='" . srm_to_ebc(floatval($fermentable->COLOR)); |
11 | 70 | } |
71 | ($fermentable->ADD_AFTER_BOIL == "TRUE") ? $sql .= "', add_after_boil='1" : $sql .= "', add_after_boil='0"; | |
195
2ac491548d8d
Fermentables database bool to int types. Dropdown lists are using tables with indexes. Dropdown lists display in Dutch. Save and delete in the database now use POST instead of GET. Added the added and dissolved_protein fields. Removed the ibu_gal_per_lb field. Redesigned the web page. Code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
72 | if ($fermentable->ADDED == 'Mash') |
2ac491548d8d
Fermentables database bool to int types. Dropdown lists are using tables with indexes. Dropdown lists display in Dutch. Save and delete in the database now use POST instead of GET. Added the added and dissolved_protein fields. Removed the ibu_gal_per_lb field. Redesigned the web page. Code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
73 | $sql .= "', added='0"; |
2ac491548d8d
Fermentables database bool to int types. Dropdown lists are using tables with indexes. Dropdown lists display in Dutch. Save and delete in the database now use POST instead of GET. Added the added and dissolved_protein fields. Removed the ibu_gal_per_lb field. Redesigned the web page. Code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
74 | else if ($fermentable->ADDED == 'Boil') |
2ac491548d8d
Fermentables database bool to int types. Dropdown lists are using tables with indexes. Dropdown lists display in Dutch. Save and delete in the database now use POST instead of GET. Added the added and dissolved_protein fields. Removed the ibu_gal_per_lb field. Redesigned the web page. Code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
75 | $sql .= "', added='1"; |
2ac491548d8d
Fermentables database bool to int types. Dropdown lists are using tables with indexes. Dropdown lists display in Dutch. Save and delete in the database now use POST instead of GET. Added the added and dissolved_protein fields. Removed the ibu_gal_per_lb field. Redesigned the web page. Code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
76 | else if ($fermentable->ADDED == 'Fermentation') |
2ac491548d8d
Fermentables database bool to int types. Dropdown lists are using tables with indexes. Dropdown lists display in Dutch. Save and delete in the database now use POST instead of GET. Added the added and dissolved_protein fields. Removed the ibu_gal_per_lb field. Redesigned the web page. Code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
77 | $sql .= "', added='2"; |
2ac491548d8d
Fermentables database bool to int types. Dropdown lists are using tables with indexes. Dropdown lists display in Dutch. Save and delete in the database now use POST instead of GET. Added the added and dissolved_protein fields. Removed the ibu_gal_per_lb field. Redesigned the web page. Code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
78 | else if ($fermentable->ADDED == 'Lagering') |
2ac491548d8d
Fermentables database bool to int types. Dropdown lists are using tables with indexes. Dropdown lists display in Dutch. Save and delete in the database now use POST instead of GET. Added the added and dissolved_protein fields. Removed the ibu_gal_per_lb field. Redesigned the web page. Code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
79 | $sql .= "', added='3"; |
2ac491548d8d
Fermentables database bool to int types. Dropdown lists are using tables with indexes. Dropdown lists display in Dutch. Save and delete in the database now use POST instead of GET. Added the added and dissolved_protein fields. Removed the ibu_gal_per_lb field. Redesigned the web page. Code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
80 | else if ($fermentable->ADDED == 'Bottle') |
2ac491548d8d
Fermentables database bool to int types. Dropdown lists are using tables with indexes. Dropdown lists display in Dutch. Save and delete in the database now use POST instead of GET. Added the added and dissolved_protein fields. Removed the ibu_gal_per_lb field. Redesigned the web page. Code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
81 | $sql .= "', added='4"; |
2ac491548d8d
Fermentables database bool to int types. Dropdown lists are using tables with indexes. Dropdown lists display in Dutch. Save and delete in the database now use POST instead of GET. Added the added and dissolved_protein fields. Removed the ibu_gal_per_lb field. Redesigned the web page. Code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
82 | else |
2ac491548d8d
Fermentables database bool to int types. Dropdown lists are using tables with indexes. Dropdown lists display in Dutch. Save and delete in the database now use POST instead of GET. Added the added and dissolved_protein fields. Removed the ibu_gal_per_lb field. Redesigned the web page. Code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
83 | echo "Unknown ADDED " . $fermentable->ADDED . PHP_EOL; |
2ac491548d8d
Fermentables database bool to int types. Dropdown lists are using tables with indexes. Dropdown lists display in Dutch. Save and delete in the database now use POST instead of GET. Added the added and dissolved_protein fields. Removed the ibu_gal_per_lb field. Redesigned the web page. Code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
84 | |
11 | 85 | $sql .= "', origin='" . mysqli_real_escape_string($db, $fermentable->ORIGIN); |
86 | $sql .= "', supplier='" . mysqli_real_escape_string($db, $fermentable->SUPPLIER); | |
87 | $sql .= "', notes='" . mysqli_real_escape_string($db, $fermentable->NOTES); | |
88 | if ($fermentable->COARSE_FINE_DIFF) | |
118
07daa505d309
Improved float precision for databases import.
Michiel Broek <mbroek@mbse.eu>
parents:
114
diff
changeset
|
89 | $sql .= "', coarse_fine_diff='" . floatval($fermentable->COARSE_FINE_DIFF); |
11 | 90 | if ($fermentable->MOISTURE) |
118
07daa505d309
Improved float precision for databases import.
Michiel Broek <mbroek@mbse.eu>
parents:
114
diff
changeset
|
91 | $sql .= "', moisture='" . floatval($fermentable->MOISTURE); |
11 | 92 | if ($fermentable->DIASTATIC_POWER) |
118
07daa505d309
Improved float precision for databases import.
Michiel Broek <mbroek@mbse.eu>
parents:
114
diff
changeset
|
93 | $sql .= "', diastatic_power='" . floatval($fermentable->DIASTATIC_POWER); |
11 | 94 | if ($fermentable->PROTEIN) |
118
07daa505d309
Improved float precision for databases import.
Michiel Broek <mbroek@mbse.eu>
parents:
114
diff
changeset
|
95 | $sql .= "', protein='" . floatval($fermentable->PROTEIN); |
195
2ac491548d8d
Fermentables database bool to int types. Dropdown lists are using tables with indexes. Dropdown lists display in Dutch. Save and delete in the database now use POST instead of GET. Added the added and dissolved_protein fields. Removed the ibu_gal_per_lb field. Redesigned the web page. Code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
96 | if ($fermentable->DISSOLVED_PROTEIN) |
2ac491548d8d
Fermentables database bool to int types. Dropdown lists are using tables with indexes. Dropdown lists display in Dutch. Save and delete in the database now use POST instead of GET. Added the added and dissolved_protein fields. Removed the ibu_gal_per_lb field. Redesigned the web page. Code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
97 | $sql .= "', dissolved_protein='" . floatval($fermentable->DISSOLVED_PROTEIN); |
11 | 98 | if ($fermentable->MAX_IN_BATCH) |
118
07daa505d309
Improved float precision for databases import.
Michiel Broek <mbroek@mbse.eu>
parents:
114
diff
changeset
|
99 | $sql .= "', max_in_batch='" . floatval($fermentable->MAX_IN_BATCH); |
21
acb2d8098f19
Added inventory miscs and water sources.
Michiel Broek <mbroek@mbse.eu>
parents:
20
diff
changeset
|
100 | ($fermentable->RECOMMEND_MASH == "TRUE") ? $sql .= "', recommend_mash='1" : $sql .= "', recommend_mash='0"; |
acb2d8098f19
Added inventory miscs and water sources.
Michiel Broek <mbroek@mbse.eu>
parents:
20
diff
changeset
|
101 | ($fermentable->ALWAYS_ON_STOCK == "TRUE") ? $sql .= "', always_on_stock='1" : $sql .= "', always_on_stock='0"; |
11 | 102 | if ($fermentable->INVENTORY) |
32
8bb369f32ef9
Fixed floating precision problems and also got the SRM to EBC conversion right.
Michiel Broek <mbroek@mbse.eu>
parents:
30
diff
changeset
|
103 | $sql .= "', inventory='" . floatval($fermentable->INVENTORY); |
11 | 104 | if ($fermentable->COST) |
32
8bb369f32ef9
Fixed floating precision problems and also got the SRM to EBC conversion right.
Michiel Broek <mbroek@mbse.eu>
parents:
30
diff
changeset
|
105 | $sql .= "', cost='" . floatval($fermentable->COST); |
11 | 106 | /* |
107 | * These are not beerxml standard: | |
108 | */ | |
109 | if ($fermentable->DI_pH) | |
118
07daa505d309
Improved float precision for databases import.
Michiel Broek <mbroek@mbse.eu>
parents:
114
diff
changeset
|
110 | $sql .= "', di_ph='" . floatval($fermentable->DI_pH); |
11 | 111 | if ($fermentable->{'ACID_TO_pH_5.7'}) |
118
07daa505d309
Improved float precision for databases import.
Michiel Broek <mbroek@mbse.eu>
parents:
114
diff
changeset
|
112 | $sql .= "', acid_to_ph_57='" . floatval($fermentable->{'ACID_TO_pH_5.7'}); |
195
2ac491548d8d
Fermentables database bool to int types. Dropdown lists are using tables with indexes. Dropdown lists display in Dutch. Save and delete in the database now use POST instead of GET. Added the added and dissolved_protein fields. Removed the ibu_gal_per_lb field. Redesigned the web page. Code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
113 | if ($fermentable->GRAINTYPE == 'Base') |
2ac491548d8d
Fermentables database bool to int types. Dropdown lists are using tables with indexes. Dropdown lists display in Dutch. Save and delete in the database now use POST instead of GET. Added the added and dissolved_protein fields. Removed the ibu_gal_per_lb field. Redesigned the web page. Code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
114 | $sql .= "', graintype='0"; |
2ac491548d8d
Fermentables database bool to int types. Dropdown lists are using tables with indexes. Dropdown lists display in Dutch. Save and delete in the database now use POST instead of GET. Added the added and dissolved_protein fields. Removed the ibu_gal_per_lb field. Redesigned the web page. Code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
115 | else if ($fermentable->GRAINTYPE == 'Roast') |
2ac491548d8d
Fermentables database bool to int types. Dropdown lists are using tables with indexes. Dropdown lists display in Dutch. Save and delete in the database now use POST instead of GET. Added the added and dissolved_protein fields. Removed the ibu_gal_per_lb field. Redesigned the web page. Code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
116 | $sql .= "', graintype='1"; |
2ac491548d8d
Fermentables database bool to int types. Dropdown lists are using tables with indexes. Dropdown lists display in Dutch. Save and delete in the database now use POST instead of GET. Added the added and dissolved_protein fields. Removed the ibu_gal_per_lb field. Redesigned the web page. Code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
117 | else if ($fermentable->GRAINTYPE == 'Crystal') |
2ac491548d8d
Fermentables database bool to int types. Dropdown lists are using tables with indexes. Dropdown lists display in Dutch. Save and delete in the database now use POST instead of GET. Added the added and dissolved_protein fields. Removed the ibu_gal_per_lb field. Redesigned the web page. Code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
118 | $sql .= "', graintype='2"; |
2ac491548d8d
Fermentables database bool to int types. Dropdown lists are using tables with indexes. Dropdown lists display in Dutch. Save and delete in the database now use POST instead of GET. Added the added and dissolved_protein fields. Removed the ibu_gal_per_lb field. Redesigned the web page. Code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
119 | else if ($fermentable->GRAINTYPE == 'Kilned') |
2ac491548d8d
Fermentables database bool to int types. Dropdown lists are using tables with indexes. Dropdown lists display in Dutch. Save and delete in the database now use POST instead of GET. Added the added and dissolved_protein fields. Removed the ibu_gal_per_lb field. Redesigned the web page. Code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
120 | $sql .= "', graintype='3"; |
2ac491548d8d
Fermentables database bool to int types. Dropdown lists are using tables with indexes. Dropdown lists display in Dutch. Save and delete in the database now use POST instead of GET. Added the added and dissolved_protein fields. Removed the ibu_gal_per_lb field. Redesigned the web page. Code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
121 | else if ($fermentable->GRAINTYPE == 'Sour malt') |
2ac491548d8d
Fermentables database bool to int types. Dropdown lists are using tables with indexes. Dropdown lists display in Dutch. Save and delete in the database now use POST instead of GET. Added the added and dissolved_protein fields. Removed the ibu_gal_per_lb field. Redesigned the web page. Code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
122 | $sql .= "', graintype='4"; |
2ac491548d8d
Fermentables database bool to int types. Dropdown lists are using tables with indexes. Dropdown lists display in Dutch. Save and delete in the database now use POST instead of GET. Added the added and dissolved_protein fields. Removed the ibu_gal_per_lb field. Redesigned the web page. Code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
123 | else if ($fermentable->GRAINTYPE == 'Special') |
2ac491548d8d
Fermentables database bool to int types. Dropdown lists are using tables with indexes. Dropdown lists display in Dutch. Save and delete in the database now use POST instead of GET. Added the added and dissolved_protein fields. Removed the ibu_gal_per_lb field. Redesigned the web page. Code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
124 | $sql .= "', graintype='5"; |
2ac491548d8d
Fermentables database bool to int types. Dropdown lists are using tables with indexes. Dropdown lists display in Dutch. Save and delete in the database now use POST instead of GET. Added the added and dissolved_protein fields. Removed the ibu_gal_per_lb field. Redesigned the web page. Code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
125 | else if ($fermentable->GRAINTYPE == 'No malt') |
2ac491548d8d
Fermentables database bool to int types. Dropdown lists are using tables with indexes. Dropdown lists display in Dutch. Save and delete in the database now use POST instead of GET. Added the added and dissolved_protein fields. Removed the ibu_gal_per_lb field. Redesigned the web page. Code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
126 | $sql .= "', graintype='6"; |
2ac491548d8d
Fermentables database bool to int types. Dropdown lists are using tables with indexes. Dropdown lists display in Dutch. Save and delete in the database now use POST instead of GET. Added the added and dissolved_protein fields. Removed the ibu_gal_per_lb field. Redesigned the web page. Code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
127 | else |
2ac491548d8d
Fermentables database bool to int types. Dropdown lists are using tables with indexes. Dropdown lists display in Dutch. Save and delete in the database now use POST instead of GET. Added the added and dissolved_protein fields. Removed the ibu_gal_per_lb field. Redesigned the web page. Code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents:
175
diff
changeset
|
128 | echo "Unknown GRAINTYPE " . $fermentable->GRAINTYPE . PHP_EOL; |
11 | 129 | $sql .= "';"; |
130 | if (! $result = mysqli_query($db, $sql)) { | |
131 | printf("Error: %s\n", mysqli_error($db)); | |
132 | } | |
133 | } | |
134 | } | |
135 | ||
136 | ||
137 | function do_hops() | |
138 | { | |
139 | global $brouwhulp, $db; | |
140 | ||
141 | echo " Start adding hops to the database\n"; | |
142 | $sql = "TRUNCATE TABLE inventory_hops;"; | |
143 | if (! $result = mysqli_query($db, $sql)) { | |
144 | printf("Error: %s\n", mysqli_error($db)); | |
145 | } | |
146 | ||
147 | $myhops = simplexml_load_file($brouwhulp . '/hops.xml'); | |
148 | ||
149 | foreach ($myhops->HOP as $hop) { | |
150 | ||
151 | $sql = "INSERT INTO inventory_hops SET name='" . mysqli_real_escape_string($db, $hop->NAME); | |
152 | if ($hop->ALPHA) | |
118
07daa505d309
Improved float precision for databases import.
Michiel Broek <mbroek@mbse.eu>
parents:
114
diff
changeset
|
153 | $sql .= "', alpha='" . floatval($hop->ALPHA); |
11 | 154 | if ($hop->BETA) |
118
07daa505d309
Improved float precision for databases import.
Michiel Broek <mbroek@mbse.eu>
parents:
114
diff
changeset
|
155 | $sql .= "', beta='" . floatval($hop->BETA); |
11 | 156 | if ($hop->HUMULENE) |
118
07daa505d309
Improved float precision for databases import.
Michiel Broek <mbroek@mbse.eu>
parents:
114
diff
changeset
|
157 | $sql .= "', humulene='" . floatval($hop->HUMULENE); |
223
0de4455bd2a1
Fixed spelling area in all programs for caryophyllene. This is still wrong in brouwhulp, we correct it during database import. Also mycrene was spelled myrcene, my fault. The hops grid now uses a popup editor, this is not yet complete. Friendly weight display in the hop grid and added the inventory comlumn.
Michiel Broek <mbroek@mbse.eu>
parents:
220
diff
changeset
|
158 | if ($hop->CAROPHYLLENE) |
0de4455bd2a1
Fixed spelling area in all programs for caryophyllene. This is still wrong in brouwhulp, we correct it during database import. Also mycrene was spelled myrcene, my fault. The hops grid now uses a popup editor, this is not yet complete. Friendly weight display in the hop grid and added the inventory comlumn.
Michiel Broek <mbroek@mbse.eu>
parents:
220
diff
changeset
|
159 | $sql .= "', caryophyllene='" . floatval($hop->CAROPHYLLENE); |
11 | 160 | if ($hop->COHUMULONE) |
118
07daa505d309
Improved float precision for databases import.
Michiel Broek <mbroek@mbse.eu>
parents:
114
diff
changeset
|
161 | $sql .= "', cohumulone='" . floatval($hop->COHUMULONE); |
223
0de4455bd2a1
Fixed spelling area in all programs for caryophyllene. This is still wrong in brouwhulp, we correct it during database import. Also mycrene was spelled myrcene, my fault. The hops grid now uses a popup editor, this is not yet complete. Friendly weight display in the hop grid and added the inventory comlumn.
Michiel Broek <mbroek@mbse.eu>
parents:
220
diff
changeset
|
162 | if ($hop->MYRCENE) |
0de4455bd2a1
Fixed spelling area in all programs for caryophyllene. This is still wrong in brouwhulp, we correct it during database import. Also mycrene was spelled myrcene, my fault. The hops grid now uses a popup editor, this is not yet complete. Friendly weight display in the hop grid and added the inventory comlumn.
Michiel Broek <mbroek@mbse.eu>
parents:
220
diff
changeset
|
163 | $sql .= "', myrcene='" . floatval($hop->MYRCENE); |
11 | 164 | if ($hop->HSI) |
118
07daa505d309
Improved float precision for databases import.
Michiel Broek <mbroek@mbse.eu>
parents:
114
diff
changeset
|
165 | $sql .= "', hsi='" . floatval($hop->HSI); |
196
531d5458782f
Hops database bool to int types. Dropdown lists are using tables with indexes. Dropdown lists display in Dutch. Save and delete in the database now use POST instead of GET. Removed the useat field. Redesigned the web page. Code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
166 | |
531d5458782f
Hops database bool to int types. Dropdown lists are using tables with indexes. Dropdown lists display in Dutch. Save and delete in the database now use POST instead of GET. Removed the useat field. Redesigned the web page. Code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
167 | if ($hop->TYPE == 'Bittering') |
531d5458782f
Hops database bool to int types. Dropdown lists are using tables with indexes. Dropdown lists display in Dutch. Save and delete in the database now use POST instead of GET. Removed the useat field. Redesigned the web page. Code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
168 | $sql .= "', type='0"; |
531d5458782f
Hops database bool to int types. Dropdown lists are using tables with indexes. Dropdown lists display in Dutch. Save and delete in the database now use POST instead of GET. Removed the useat field. Redesigned the web page. Code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
169 | else if ($hop->TYPE == 'Aroma') |
531d5458782f
Hops database bool to int types. Dropdown lists are using tables with indexes. Dropdown lists display in Dutch. Save and delete in the database now use POST instead of GET. Removed the useat field. Redesigned the web page. Code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
170 | $sql .= "', type='1"; |
531d5458782f
Hops database bool to int types. Dropdown lists are using tables with indexes. Dropdown lists display in Dutch. Save and delete in the database now use POST instead of GET. Removed the useat field. Redesigned the web page. Code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
171 | else if ($hop->TYPE == 'Both') |
531d5458782f
Hops database bool to int types. Dropdown lists are using tables with indexes. Dropdown lists display in Dutch. Save and delete in the database now use POST instead of GET. Removed the useat field. Redesigned the web page. Code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
172 | $sql .= "', type='2"; |
531d5458782f
Hops database bool to int types. Dropdown lists are using tables with indexes. Dropdown lists display in Dutch. Save and delete in the database now use POST instead of GET. Removed the useat field. Redesigned the web page. Code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
173 | else |
531d5458782f
Hops database bool to int types. Dropdown lists are using tables with indexes. Dropdown lists display in Dutch. Save and delete in the database now use POST instead of GET. Removed the useat field. Redesigned the web page. Code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
174 | echo "Unknown TYPE " . $hop->TYPE . PHP_EOL; |
531d5458782f
Hops database bool to int types. Dropdown lists are using tables with indexes. Dropdown lists display in Dutch. Save and delete in the database now use POST instead of GET. Removed the useat field. Redesigned the web page. Code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
175 | |
531d5458782f
Hops database bool to int types. Dropdown lists are using tables with indexes. Dropdown lists display in Dutch. Save and delete in the database now use POST instead of GET. Removed the useat field. Redesigned the web page. Code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
176 | if ($hop->FORM == 'Pellet') |
531d5458782f
Hops database bool to int types. Dropdown lists are using tables with indexes. Dropdown lists display in Dutch. Save and delete in the database now use POST instead of GET. Removed the useat field. Redesigned the web page. Code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
177 | $sql .= "', form='0"; |
531d5458782f
Hops database bool to int types. Dropdown lists are using tables with indexes. Dropdown lists display in Dutch. Save and delete in the database now use POST instead of GET. Removed the useat field. Redesigned the web page. Code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
178 | else if ($hop->FORM == 'Plug') |
531d5458782f
Hops database bool to int types. Dropdown lists are using tables with indexes. Dropdown lists display in Dutch. Save and delete in the database now use POST instead of GET. Removed the useat field. Redesigned the web page. Code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
179 | $sql .= "', form='1"; |
531d5458782f
Hops database bool to int types. Dropdown lists are using tables with indexes. Dropdown lists display in Dutch. Save and delete in the database now use POST instead of GET. Removed the useat field. Redesigned the web page. Code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
180 | else if ($hop->FORM == 'Leaf') |
531d5458782f
Hops database bool to int types. Dropdown lists are using tables with indexes. Dropdown lists display in Dutch. Save and delete in the database now use POST instead of GET. Removed the useat field. Redesigned the web page. Code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
181 | $sql .= "', form='2"; |
531d5458782f
Hops database bool to int types. Dropdown lists are using tables with indexes. Dropdown lists display in Dutch. Save and delete in the database now use POST instead of GET. Removed the useat field. Redesigned the web page. Code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
182 | else |
531d5458782f
Hops database bool to int types. Dropdown lists are using tables with indexes. Dropdown lists display in Dutch. Save and delete in the database now use POST instead of GET. Removed the useat field. Redesigned the web page. Code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
183 | echo "Unknown FORM " . $hop->FORM . PHP_EOL; |
531d5458782f
Hops database bool to int types. Dropdown lists are using tables with indexes. Dropdown lists display in Dutch. Save and delete in the database now use POST instead of GET. Removed the useat field. Redesigned the web page. Code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
184 | |
11 | 185 | $sql .= "', notes='" . mysqli_real_escape_string($db, $hop->NOTES); |
186 | $sql .= "', origin='" . mysqli_real_escape_string($db, $hop->ORIGIN); | |
187 | $sql .= "', substitutes='" . mysqli_real_escape_string($db, $hop->SUBSTITUTES); | |
21
acb2d8098f19
Added inventory miscs and water sources.
Michiel Broek <mbroek@mbse.eu>
parents:
20
diff
changeset
|
188 | ($hop->ALWAYS_ON_STOCK == 'TRUE') ? $sql .= "', always_on_stock='1" : $sql .= "', always_on_stock='0"; |
11 | 189 | if ($hop->INVENTORY) |
32
8bb369f32ef9
Fixed floating precision problems and also got the SRM to EBC conversion right.
Michiel Broek <mbroek@mbse.eu>
parents:
30
diff
changeset
|
190 | $sql .= "', inventory='" . floatval($hop->INVENTORY) / 1000.0; |
11 | 191 | if ($hop->COST) |
32
8bb369f32ef9
Fixed floating precision problems and also got the SRM to EBC conversion right.
Michiel Broek <mbroek@mbse.eu>
parents:
30
diff
changeset
|
192 | $sql .= "', cost='" . floatval($hop->COST); |
13 | 193 | if ($hop->TOTAL_OIL) |
118
07daa505d309
Improved float precision for databases import.
Michiel Broek <mbroek@mbse.eu>
parents:
114
diff
changeset
|
194 | $sql .= "', total_oil='" . floatval($hop->TOTAL_OIL); |
196
531d5458782f
Hops database bool to int types. Dropdown lists are using tables with indexes. Dropdown lists display in Dutch. Save and delete in the database now use POST instead of GET. Removed the useat field. Redesigned the web page. Code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
195 | if ($hop->HARVEST_DATE) { |
531d5458782f
Hops database bool to int types. Dropdown lists are using tables with indexes. Dropdown lists display in Dutch. Save and delete in the database now use POST instead of GET. Removed the useat field. Redesigned the web page. Code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
196 | $date = substr($hop->HARVEST_DATE, 6, 4).'-'.substr($hop->HARVEST_DATE, 3, 2).'-'.substr($hop->HARVEST_DATE, 0, 2); |
531d5458782f
Hops database bool to int types. Dropdown lists are using tables with indexes. Dropdown lists display in Dutch. Save and delete in the database now use POST instead of GET. Removed the useat field. Redesigned the web page. Code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
197 | $sql .= "', production_date='" . $date; |
531d5458782f
Hops database bool to int types. Dropdown lists are using tables with indexes. Dropdown lists display in Dutch. Save and delete in the database now use POST instead of GET. Removed the useat field. Redesigned the web page. Code cleanup.
Michiel Broek <mbroek@mbse.eu>
parents:
195
diff
changeset
|
198 | } |
11 | 199 | $sql .= "';"; |
200 | if (! $result = mysqli_query($db, $sql)) { | |
201 | printf("Error: %s\n", mysqli_error($db)); | |
202 | } | |
203 | } | |
204 | ||
205 | } | |
206 | ||
207 | ||
208 | ||
209 | function do_yeasts() | |
210 | { | |
211 | global $brouwhulp, $db; | |
212 | ||
213 | echo " Start adding yeasts to the database\n"; | |
214 | $sql = "TRUNCATE TABLE inventory_yeasts;"; | |
215 | if (! $result = mysqli_query($db, $sql)) { | |
216 | printf("Error: %s\n", mysqli_error($db)); | |
217 | } | |
218 | ||
219 | $yeasts = simplexml_load_file($brouwhulp . '/yeasts.xml'); | |
220 | ||
221 | foreach ($yeasts->YEAST as $yeast) { | |
222 | ||
223 | $sql = "INSERT INTO inventory_yeasts SET name='" . mysqli_real_escape_string($db, $yeast->NAME); | |
198
f0ec83e1e01f
Switches yeasts inventory to indexed names and translations. Database save is using POST instead of GET. Redesigned the web page. Added total cost display which updates on inventory changes.
Michiel Broek <mbroek@mbse.eu>
parents:
196
diff
changeset
|
224 | |
f0ec83e1e01f
Switches yeasts inventory to indexed names and translations. Database save is using POST instead of GET. Redesigned the web page. Added total cost display which updates on inventory changes.
Michiel Broek <mbroek@mbse.eu>
parents:
196
diff
changeset
|
225 | if ($yeast->TYPE == 'Lager') |
f0ec83e1e01f
Switches yeasts inventory to indexed names and translations. Database save is using POST instead of GET. Redesigned the web page. Added total cost display which updates on inventory changes.
Michiel Broek <mbroek@mbse.eu>
parents:
196
diff
changeset
|
226 | $sql .= "', type='0"; |
f0ec83e1e01f
Switches yeasts inventory to indexed names and translations. Database save is using POST instead of GET. Redesigned the web page. Added total cost display which updates on inventory changes.
Michiel Broek <mbroek@mbse.eu>
parents:
196
diff
changeset
|
227 | else if ($yeast->TYPE == 'Ale') |
f0ec83e1e01f
Switches yeasts inventory to indexed names and translations. Database save is using POST instead of GET. Redesigned the web page. Added total cost display which updates on inventory changes.
Michiel Broek <mbroek@mbse.eu>
parents:
196
diff
changeset
|
228 | $sql .= "', type='1"; |
f0ec83e1e01f
Switches yeasts inventory to indexed names and translations. Database save is using POST instead of GET. Redesigned the web page. Added total cost display which updates on inventory changes.
Michiel Broek <mbroek@mbse.eu>
parents:
196
diff
changeset
|
229 | else if ($yeast->TYPE == 'Wheat') |
f0ec83e1e01f
Switches yeasts inventory to indexed names and translations. Database save is using POST instead of GET. Redesigned the web page. Added total cost display which updates on inventory changes.
Michiel Broek <mbroek@mbse.eu>
parents:
196
diff
changeset
|
230 | $sql .= "', type='2"; |
f0ec83e1e01f
Switches yeasts inventory to indexed names and translations. Database save is using POST instead of GET. Redesigned the web page. Added total cost display which updates on inventory changes.
Michiel Broek <mbroek@mbse.eu>
parents:
196
diff
changeset
|
231 | else if ($yeast->TYPE == 'Wine') |
f0ec83e1e01f
Switches yeasts inventory to indexed names and translations. Database save is using POST instead of GET. Redesigned the web page. Added total cost display which updates on inventory changes.
Michiel Broek <mbroek@mbse.eu>
parents:
196
diff
changeset
|
232 | $sql .= "', type='3"; |
f0ec83e1e01f
Switches yeasts inventory to indexed names and translations. Database save is using POST instead of GET. Redesigned the web page. Added total cost display which updates on inventory changes.
Michiel Broek <mbroek@mbse.eu>
parents:
196
diff
changeset
|
233 | else if ($yeast->TYPE == 'Champagne') |
f0ec83e1e01f
Switches yeasts inventory to indexed names and translations. Database save is using POST instead of GET. Redesigned the web page. Added total cost display which updates on inventory changes.
Michiel Broek <mbroek@mbse.eu>
parents:
196
diff
changeset
|
234 | $sql .= "', type='4"; |
f0ec83e1e01f
Switches yeasts inventory to indexed names and translations. Database save is using POST instead of GET. Redesigned the web page. Added total cost display which updates on inventory changes.
Michiel Broek <mbroek@mbse.eu>
parents:
196
diff
changeset
|
235 | else |
f0ec83e1e01f
Switches yeasts inventory to indexed names and translations. Database save is using POST instead of GET. Redesigned the web page. Added total cost display which updates on inventory changes.
Michiel Broek <mbroek@mbse.eu>
parents:
196
diff
changeset
|
236 | echo "Unknown TYPE " . $yeast->TYPE . PHP_EOL; |
f0ec83e1e01f
Switches yeasts inventory to indexed names and translations. Database save is using POST instead of GET. Redesigned the web page. Added total cost display which updates on inventory changes.
Michiel Broek <mbroek@mbse.eu>
parents:
196
diff
changeset
|
237 | |
f0ec83e1e01f
Switches yeasts inventory to indexed names and translations. Database save is using POST instead of GET. Redesigned the web page. Added total cost display which updates on inventory changes.
Michiel Broek <mbroek@mbse.eu>
parents:
196
diff
changeset
|
238 | if ($yeast->FORM == 'Liquid') |
f0ec83e1e01f
Switches yeasts inventory to indexed names and translations. Database save is using POST instead of GET. Redesigned the web page. Added total cost display which updates on inventory changes.
Michiel Broek <mbroek@mbse.eu>
parents:
196
diff
changeset
|
239 | $sql .= "', form='0"; |
f0ec83e1e01f
Switches yeasts inventory to indexed names and translations. Database save is using POST instead of GET. Redesigned the web page. Added total cost display which updates on inventory changes.
Michiel Broek <mbroek@mbse.eu>
parents:
196
diff
changeset
|
240 | else if ($yeast->FORM == 'Dry') |
f0ec83e1e01f
Switches yeasts inventory to indexed names and translations. Database save is using POST instead of GET. Redesigned the web page. Added total cost display which updates on inventory changes.
Michiel Broek <mbroek@mbse.eu>
parents:
196
diff
changeset
|
241 | $sql .= "', form='1"; |
f0ec83e1e01f
Switches yeasts inventory to indexed names and translations. Database save is using POST instead of GET. Redesigned the web page. Added total cost display which updates on inventory changes.
Michiel Broek <mbroek@mbse.eu>
parents:
196
diff
changeset
|
242 | else if ($yeast->FORM == 'Slant') |
f0ec83e1e01f
Switches yeasts inventory to indexed names and translations. Database save is using POST instead of GET. Redesigned the web page. Added total cost display which updates on inventory changes.
Michiel Broek <mbroek@mbse.eu>
parents:
196
diff
changeset
|
243 | $sql .= "', form='2"; |
f0ec83e1e01f
Switches yeasts inventory to indexed names and translations. Database save is using POST instead of GET. Redesigned the web page. Added total cost display which updates on inventory changes.
Michiel Broek <mbroek@mbse.eu>
parents:
196
diff
changeset
|
244 | else if ($yeast->FORM == 'Culture') |
f0ec83e1e01f
Switches yeasts inventory to indexed names and translations. Database save is using POST instead of GET. Redesigned the web page. Added total cost display which updates on inventory changes.
Michiel Broek <mbroek@mbse.eu>
parents:
196
diff
changeset
|
245 | $sql .= "', form='3"; |
f0ec83e1e01f
Switches yeasts inventory to indexed names and translations. Database save is using POST instead of GET. Redesigned the web page. Added total cost display which updates on inventory changes.
Michiel Broek <mbroek@mbse.eu>
parents:
196
diff
changeset
|
246 | else if ($yeast->FORM == 'Frozen') |
f0ec83e1e01f
Switches yeasts inventory to indexed names and translations. Database save is using POST instead of GET. Redesigned the web page. Added total cost display which updates on inventory changes.
Michiel Broek <mbroek@mbse.eu>
parents:
196
diff
changeset
|
247 | $sql .= "', form='4"; |
f0ec83e1e01f
Switches yeasts inventory to indexed names and translations. Database save is using POST instead of GET. Redesigned the web page. Added total cost display which updates on inventory changes.
Michiel Broek <mbroek@mbse.eu>
parents:
196
diff
changeset
|
248 | else if ($yeast->FORM == 'Bottle') |
f0ec83e1e01f
Switches yeasts inventory to indexed names and translations. Database save is using POST instead of GET. Redesigned the web page. Added total cost display which updates on inventory changes.
Michiel Broek <mbroek@mbse.eu>
parents:
196
diff
changeset
|
249 | $sql .= "', form='5"; |
f0ec83e1e01f
Switches yeasts inventory to indexed names and translations. Database save is using POST instead of GET. Redesigned the web page. Added total cost display which updates on inventory changes.
Michiel Broek <mbroek@mbse.eu>
parents:
196
diff
changeset
|
250 | else |
f0ec83e1e01f
Switches yeasts inventory to indexed names and translations. Database save is using POST instead of GET. Redesigned the web page. Added total cost display which updates on inventory changes.
Michiel Broek <mbroek@mbse.eu>
parents:
196
diff
changeset
|
251 | echo "Unknown FORM " . $yeast->FORM . PHP_EOL; |
f0ec83e1e01f
Switches yeasts inventory to indexed names and translations. Database save is using POST instead of GET. Redesigned the web page. Added total cost display which updates on inventory changes.
Michiel Broek <mbroek@mbse.eu>
parents:
196
diff
changeset
|
252 | |
11 | 253 | $sql .= "', laboratory='" . mysqli_real_escape_string($db, $yeast->LABORATORY); |
254 | $sql .= "', product_id='" . mysqli_real_escape_string($db, $yeast->PRODUCT_ID); | |
255 | if ($yeast->MIN_TEMPERATURE) | |
118
07daa505d309
Improved float precision for databases import.
Michiel Broek <mbroek@mbse.eu>
parents:
114
diff
changeset
|
256 | $sql .= "', min_temperature='" . floatval($yeast->MIN_TEMPERATURE); |
11 | 257 | if ($yeast->MAX_TEMPERATURE) |
118
07daa505d309
Improved float precision for databases import.
Michiel Broek <mbroek@mbse.eu>
parents:
114
diff
changeset
|
258 | $sql .= "', max_temperature='" . floatval($yeast->MAX_TEMPERATURE); |
198
f0ec83e1e01f
Switches yeasts inventory to indexed names and translations. Database save is using POST instead of GET. Redesigned the web page. Added total cost display which updates on inventory changes.
Michiel Broek <mbroek@mbse.eu>
parents:
196
diff
changeset
|
259 | |
f0ec83e1e01f
Switches yeasts inventory to indexed names and translations. Database save is using POST instead of GET. Redesigned the web page. Added total cost display which updates on inventory changes.
Michiel Broek <mbroek@mbse.eu>
parents:
196
diff
changeset
|
260 | if ($yeast->FLOCCULATION == 'Low') |
f0ec83e1e01f
Switches yeasts inventory to indexed names and translations. Database save is using POST instead of GET. Redesigned the web page. Added total cost display which updates on inventory changes.
Michiel Broek <mbroek@mbse.eu>
parents:
196
diff
changeset
|
261 | $sql .= "', flocculation='0"; |
f0ec83e1e01f
Switches yeasts inventory to indexed names and translations. Database save is using POST instead of GET. Redesigned the web page. Added total cost display which updates on inventory changes.
Michiel Broek <mbroek@mbse.eu>
parents:
196
diff
changeset
|
262 | else if ($yeast->FLOCCULATION == 'Medium') |
f0ec83e1e01f
Switches yeasts inventory to indexed names and translations. Database save is using POST instead of GET. Redesigned the web page. Added total cost display which updates on inventory changes.
Michiel Broek <mbroek@mbse.eu>
parents:
196
diff
changeset
|
263 | $sql .= "', flocculation='1"; |
f0ec83e1e01f
Switches yeasts inventory to indexed names and translations. Database save is using POST instead of GET. Redesigned the web page. Added total cost display which updates on inventory changes.
Michiel Broek <mbroek@mbse.eu>
parents:
196
diff
changeset
|
264 | else if ($yeast->FLOCCULATION == 'High') |
f0ec83e1e01f
Switches yeasts inventory to indexed names and translations. Database save is using POST instead of GET. Redesigned the web page. Added total cost display which updates on inventory changes.
Michiel Broek <mbroek@mbse.eu>
parents:
196
diff
changeset
|
265 | $sql .= "', flocculation='2"; |
f0ec83e1e01f
Switches yeasts inventory to indexed names and translations. Database save is using POST instead of GET. Redesigned the web page. Added total cost display which updates on inventory changes.
Michiel Broek <mbroek@mbse.eu>
parents:
196
diff
changeset
|
266 | else if ($yeast->FLOCCULATION == 'Very high') |
f0ec83e1e01f
Switches yeasts inventory to indexed names and translations. Database save is using POST instead of GET. Redesigned the web page. Added total cost display which updates on inventory changes.
Michiel Broek <mbroek@mbse.eu>
parents:
196
diff
changeset
|
267 | $sql .= "', flocculation='3"; |
f0ec83e1e01f
Switches yeasts inventory to indexed names and translations. Database save is using POST instead of GET. Redesigned the web page. Added total cost display which updates on inventory changes.
Michiel Broek <mbroek@mbse.eu>
parents:
196
diff
changeset
|
268 | else |
f0ec83e1e01f
Switches yeasts inventory to indexed names and translations. Database save is using POST instead of GET. Redesigned the web page. Added total cost display which updates on inventory changes.
Michiel Broek <mbroek@mbse.eu>
parents:
196
diff
changeset
|
269 | echo "Unknown FLOCCULATION " . $yeast->FLOCCULATION . PHP_EOL; |
f0ec83e1e01f
Switches yeasts inventory to indexed names and translations. Database save is using POST instead of GET. Redesigned the web page. Added total cost display which updates on inventory changes.
Michiel Broek <mbroek@mbse.eu>
parents:
196
diff
changeset
|
270 | |
11 | 271 | if ($yeast->ATTENUATION) |
118
07daa505d309
Improved float precision for databases import.
Michiel Broek <mbroek@mbse.eu>
parents:
114
diff
changeset
|
272 | $sql .= "', attenuation='" . floatval($yeast->ATTENUATION); |
11 | 273 | $sql .= "', notes='" . mysqli_real_escape_string($db, $yeast->NOTES); |
274 | $sql .= "', best_for='" . mysqli_real_escape_string($db, $yeast->BEST_FOR); | |
275 | if ($yeast->MAX_REUSE) | |
276 | $sql .= "', max_reuse='" . $yeast->MAX_REUSE; | |
200
7b2f11652d67
Miscs from bool to ints. Miscs database uses POST instead of GET. Dropdowns are unsing indexes. Dynamic edit screen adjust for weight and liter. Edit screen redesigned. Friendly show duration of ingredients.
Michiel Broek <mbroek@mbse.eu>
parents:
198
diff
changeset
|
277 | |
7b2f11652d67
Miscs from bool to ints. Miscs database uses POST instead of GET. Dropdowns are unsing indexes. Dynamic edit screen adjust for weight and liter. Edit screen redesigned. Friendly show duration of ingredients.
Michiel Broek <mbroek@mbse.eu>
parents:
198
diff
changeset
|
278 | if ($yeast->FORM == 'Liquid') { |
202
64a9c935a66b
Yeast import Imperial Yeast packs are 200 billion cells/pack. Inventory fermentables the origin country column first. Disable filter menu on some fields. Friendy display of stock inventory.
Michiel Broek <mbroek@mbse.eu>
parents:
201
diff
changeset
|
279 | if ($yeast->LABORATORY == 'Imperial Yeast') |
64a9c935a66b
Yeast import Imperial Yeast packs are 200 billion cells/pack. Inventory fermentables the origin country column first. Disable filter menu on some fields. Friendy display of stock inventory.
Michiel Broek <mbroek@mbse.eu>
parents:
201
diff
changeset
|
280 | $sql .= "', cells='200000000000"; // 200 billion cells per pack |
64a9c935a66b
Yeast import Imperial Yeast packs are 200 billion cells/pack. Inventory fermentables the origin country column first. Disable filter menu on some fields. Friendy display of stock inventory.
Michiel Broek <mbroek@mbse.eu>
parents:
201
diff
changeset
|
281 | else |
64a9c935a66b
Yeast import Imperial Yeast packs are 200 billion cells/pack. Inventory fermentables the origin country column first. Disable filter menu on some fields. Friendy display of stock inventory.
Michiel Broek <mbroek@mbse.eu>
parents:
201
diff
changeset
|
282 | $sql .= "', cells='100000000000"; // 100 billion cells per pack |
201
f9b7e3f6be7c
Fixed yeast database import differences between grams, ml and packs. Added cells field filled with defaults. Some edit screen improvements. Dynamic prompts depending on the yeast type. Disable men and filter of most columns in the yeasts list. Friendlier display of inverntory.
Michiel Broek <mbroek@mbse.eu>
parents:
200
diff
changeset
|
283 | if ($yeast->COST) |
f9b7e3f6be7c
Fixed yeast database import differences between grams, ml and packs. Added cells field filled with defaults. Some edit screen improvements. Dynamic prompts depending on the yeast type. Disable men and filter of most columns in the yeasts list. Friendlier display of inverntory.
Michiel Broek <mbroek@mbse.eu>
parents:
200
diff
changeset
|
284 | $sql .= "', cost='" . floatval($yeast->COST); |
f9b7e3f6be7c
Fixed yeast database import differences between grams, ml and packs. Added cells field filled with defaults. Some edit screen improvements. Dynamic prompts depending on the yeast type. Disable men and filter of most columns in the yeasts list. Friendlier display of inverntory.
Michiel Broek <mbroek@mbse.eu>
parents:
200
diff
changeset
|
285 | if ($yeast->INVENTORY) |
f9b7e3f6be7c
Fixed yeast database import differences between grams, ml and packs. Added cells field filled with defaults. Some edit screen improvements. Dynamic prompts depending on the yeast type. Disable men and filter of most columns in the yeasts list. Friendlier display of inverntory.
Michiel Broek <mbroek@mbse.eu>
parents:
200
diff
changeset
|
286 | $sql .= "', inventory='" . floatval($yeast->INVENTORY); |
200
7b2f11652d67
Miscs from bool to ints. Miscs database uses POST instead of GET. Dropdowns are unsing indexes. Dynamic edit screen adjust for weight and liter. Edit screen redesigned. Friendly show duration of ingredients.
Michiel Broek <mbroek@mbse.eu>
parents:
198
diff
changeset
|
287 | } else if ($yeast->FORM == 'Dry') { |
7b2f11652d67
Miscs from bool to ints. Miscs database uses POST instead of GET. Dropdowns are unsing indexes. Dynamic edit screen adjust for weight and liter. Edit screen redesigned. Friendly show duration of ingredients.
Michiel Broek <mbroek@mbse.eu>
parents:
198
diff
changeset
|
288 | $sql .= "', cells='15000000000"; // 6..15 billion per gram |
201
f9b7e3f6be7c
Fixed yeast database import differences between grams, ml and packs. Added cells field filled with defaults. Some edit screen improvements. Dynamic prompts depending on the yeast type. Disable men and filter of most columns in the yeasts list. Friendlier display of inverntory.
Michiel Broek <mbroek@mbse.eu>
parents:
200
diff
changeset
|
289 | if ($yeast->INVENTORY) |
f9b7e3f6be7c
Fixed yeast database import differences between grams, ml and packs. Added cells field filled with defaults. Some edit screen improvements. Dynamic prompts depending on the yeast type. Disable men and filter of most columns in the yeasts list. Friendlier display of inverntory.
Michiel Broek <mbroek@mbse.eu>
parents:
200
diff
changeset
|
290 | $sql .= "', inventory='" . floatval($yeast->INVENTORY) / 1000.0; // To kg |
f9b7e3f6be7c
Fixed yeast database import differences between grams, ml and packs. Added cells field filled with defaults. Some edit screen improvements. Dynamic prompts depending on the yeast type. Disable men and filter of most columns in the yeasts list. Friendlier display of inverntory.
Michiel Broek <mbroek@mbse.eu>
parents:
200
diff
changeset
|
291 | if ($yeast->COST) |
f9b7e3f6be7c
Fixed yeast database import differences between grams, ml and packs. Added cells field filled with defaults. Some edit screen improvements. Dynamic prompts depending on the yeast type. Disable men and filter of most columns in the yeasts list. Friendlier display of inverntory.
Michiel Broek <mbroek@mbse.eu>
parents:
200
diff
changeset
|
292 | $sql .= "', cost='" . floatval($yeast->COST) * 1000.0; // to Euro/kg |
200
7b2f11652d67
Miscs from bool to ints. Miscs database uses POST instead of GET. Dropdowns are unsing indexes. Dynamic edit screen adjust for weight and liter. Edit screen redesigned. Friendly show duration of ingredients.
Michiel Broek <mbroek@mbse.eu>
parents:
198
diff
changeset
|
293 | } else { |
7b2f11652d67
Miscs from bool to ints. Miscs database uses POST instead of GET. Dropdowns are unsing indexes. Dynamic edit screen adjust for weight and liter. Edit screen redesigned. Friendly show duration of ingredients.
Michiel Broek <mbroek@mbse.eu>
parents:
198
diff
changeset
|
294 | $sql .= "', cells='1700000000"; // 1.7 billion cells per ml. |
201
f9b7e3f6be7c
Fixed yeast database import differences between grams, ml and packs. Added cells field filled with defaults. Some edit screen improvements. Dynamic prompts depending on the yeast type. Disable men and filter of most columns in the yeasts list. Friendlier display of inverntory.
Michiel Broek <mbroek@mbse.eu>
parents:
200
diff
changeset
|
295 | if ($yeast->INVENTORY) |
f9b7e3f6be7c
Fixed yeast database import differences between grams, ml and packs. Added cells field filled with defaults. Some edit screen improvements. Dynamic prompts depending on the yeast type. Disable men and filter of most columns in the yeasts list. Friendlier display of inverntory.
Michiel Broek <mbroek@mbse.eu>
parents:
200
diff
changeset
|
296 | $sql .= "', inventory='" . floatval($yeast->INVENTORY) / 1000.0; // To liter |
f9b7e3f6be7c
Fixed yeast database import differences between grams, ml and packs. Added cells field filled with defaults. Some edit screen improvements. Dynamic prompts depending on the yeast type. Disable men and filter of most columns in the yeasts list. Friendlier display of inverntory.
Michiel Broek <mbroek@mbse.eu>
parents:
200
diff
changeset
|
297 | if ($yeast->COST) |
f9b7e3f6be7c
Fixed yeast database import differences between grams, ml and packs. Added cells field filled with defaults. Some edit screen improvements. Dynamic prompts depending on the yeast type. Disable men and filter of most columns in the yeasts list. Friendlier display of inverntory.
Michiel Broek <mbroek@mbse.eu>
parents:
200
diff
changeset
|
298 | $sql .= "', cost='" . floatval($yeast->COST) * 1000.0; // to Euro/liter |
200
7b2f11652d67
Miscs from bool to ints. Miscs database uses POST instead of GET. Dropdowns are unsing indexes. Dynamic edit screen adjust for weight and liter. Edit screen redesigned. Friendly show duration of ingredients.
Michiel Broek <mbroek@mbse.eu>
parents:
198
diff
changeset
|
299 | } |
11 | 300 | if ($yeast->CULTURE_DATE) { |
301 | $date = substr($yeast->CULTURE_DATE, 6, 4) . '-' . substr($yeast->CULTURE_DATE, 3, 2) . '-' . substr($yeast->CULTURE_DATE, 0, 2); | |
302 | $sql .= "', production_date='" . $date; | |
303 | } | |
304 | $sql .= "';"; | |
305 | if (! $result = mysqli_query($db, $sql)) { | |
306 | printf("Error: %s\n", mysqli_error($db)); | |
307 | } | |
308 | } | |
309 | } | |
310 | ||
311 | ||
312 | ||
313 | function do_waters() | |
314 | { | |
315 | global $brouwhulp, $db; | |
316 | ||
317 | echo " Start adding waters to the database\n"; | |
45
95251bedfab4
Moved three inventory tables and screens to profiles
Michiel Broek <mbroek@mbse.eu>
parents:
38
diff
changeset
|
318 | $sql = "TRUNCATE TABLE profile_water;"; |
11 | 319 | if (! $result = mysqli_query($db, $sql)) { |
320 | printf("Error: %s\n", mysqli_error($db)); | |
321 | } | |
64
5d5fc6f7cbfe
Improved recipes import. Finished inventory_suppliers.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
322 | $sql = "TRUNCATE TABLE inventory_waters;"; |
15 | 323 | if (! $result = mysqli_query($db, $sql)) { |
324 | printf("Error: %s\n", mysqli_error($db)); | |
325 | } | |
11 | 326 | |
327 | $waters = simplexml_load_file($brouwhulp . '/waters.xml'); | |
328 | ||
329 | foreach ($waters->WATER as $water) { | |
330 | ||
15 | 331 | if (($water->NAME == "Gedemineraliseerd water") || ($water->NAME == "Cristalline") || ($water->NAME == "Montille (Delhaize)") || |
332 | ($water->NAME == "Spa Reine") || ($water->NAME == "Velsen") || ($water->NAME == "Zutphen") || | |
333 | ($water->NAME == "Aurele Bronwater (Colruyt)")) { | |
64
5d5fc6f7cbfe
Improved recipes import. Finished inventory_suppliers.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
334 | $sql = "INSERT INTO inventory_waters SET name='" . mysqli_real_escape_string($db, $water->NAME); |
15 | 335 | } else { |
45
95251bedfab4
Moved three inventory tables and screens to profiles
Michiel Broek <mbroek@mbse.eu>
parents:
38
diff
changeset
|
336 | $sql = "INSERT INTO profile_water SET name='" . mysqli_real_escape_string($db, $water->NAME); |
15 | 337 | } |
338 | ||
11 | 339 | if ($water->NOTES) |
340 | $sql .= "', notes='" . mysqli_real_escape_string($db, $water->NOTES); | |
118
07daa505d309
Improved float precision for databases import.
Michiel Broek <mbroek@mbse.eu>
parents:
114
diff
changeset
|
341 | $sql .= "', calcium='" . floatval($water->CALCIUM); |
07daa505d309
Improved float precision for databases import.
Michiel Broek <mbroek@mbse.eu>
parents:
114
diff
changeset
|
342 | $sql .= "', bicarbonate='" . floatval($water->BICARBONATE); |
07daa505d309
Improved float precision for databases import.
Michiel Broek <mbroek@mbse.eu>
parents:
114
diff
changeset
|
343 | $sql .= "', sulfate='" . floatval($water->SULFATE); |
07daa505d309
Improved float precision for databases import.
Michiel Broek <mbroek@mbse.eu>
parents:
114
diff
changeset
|
344 | $sql .= "', chloride='" . floatval($water->CHLORIDE); |
07daa505d309
Improved float precision for databases import.
Michiel Broek <mbroek@mbse.eu>
parents:
114
diff
changeset
|
345 | $sql .= "', sodium='" . floatval($water->SODIUM); |
07daa505d309
Improved float precision for databases import.
Michiel Broek <mbroek@mbse.eu>
parents:
114
diff
changeset
|
346 | $sql .= "', magnesium='" . floatval($water->MAGNESIUM); |
07daa505d309
Improved float precision for databases import.
Michiel Broek <mbroek@mbse.eu>
parents:
114
diff
changeset
|
347 | $sql .= "', ph='" . floatval($water->PH); |
11 | 348 | if ($water->TOTAL_ALKALINITY) |
118
07daa505d309
Improved float precision for databases import.
Michiel Broek <mbroek@mbse.eu>
parents:
114
diff
changeset
|
349 | $sql .= "', total_alkalinity='" . floatval($water->TOTAL_ALKALINITY); |
11 | 350 | $sql .= "';"; |
351 | if (! $result = mysqli_query($db, $sql)) { | |
352 | printf("Error: %s\n", mysqli_error($db)); | |
353 | } | |
354 | } | |
355 | } | |
356 | ||
357 | ||
358 | ||
359 | function do_miscs() | |
360 | { | |
361 | global $brouwhulp, $db; | |
362 | ||
363 | echo " Start adding miscs to the database\n"; | |
364 | $sql = "TRUNCATE TABLE inventory_miscs;"; | |
365 | if (! $result = mysqli_query($db, $sql)) { | |
366 | printf("Error: %s\n", mysqli_error($db)); | |
367 | } | |
368 | ||
369 | $miscs = simplexml_load_file($brouwhulp . '/miscs.xml'); | |
370 | ||
371 | foreach ($miscs->MISC as $misc) { | |
372 | ||
373 | $sql = "INSERT INTO inventory_miscs SET name='" . mysqli_real_escape_string($db, $misc->NAME); | |
374 | if ($misc->NOTES) | |
375 | $sql .= "', notes='" . mysqli_real_escape_string($db, $misc->NOTES); | |
200
7b2f11652d67
Miscs from bool to ints. Miscs database uses POST instead of GET. Dropdowns are unsing indexes. Dynamic edit screen adjust for weight and liter. Edit screen redesigned. Friendly show duration of ingredients.
Michiel Broek <mbroek@mbse.eu>
parents:
198
diff
changeset
|
376 | |
7b2f11652d67
Miscs from bool to ints. Miscs database uses POST instead of GET. Dropdowns are unsing indexes. Dynamic edit screen adjust for weight and liter. Edit screen redesigned. Friendly show duration of ingredients.
Michiel Broek <mbroek@mbse.eu>
parents:
198
diff
changeset
|
377 | if ($misc->TYPE == 'Spice') |
7b2f11652d67
Miscs from bool to ints. Miscs database uses POST instead of GET. Dropdowns are unsing indexes. Dynamic edit screen adjust for weight and liter. Edit screen redesigned. Friendly show duration of ingredients.
Michiel Broek <mbroek@mbse.eu>
parents:
198
diff
changeset
|
378 | $sql .= "', type='0"; |
7b2f11652d67
Miscs from bool to ints. Miscs database uses POST instead of GET. Dropdowns are unsing indexes. Dynamic edit screen adjust for weight and liter. Edit screen redesigned. Friendly show duration of ingredients.
Michiel Broek <mbroek@mbse.eu>
parents:
198
diff
changeset
|
379 | else if ($misc->TYPE == 'Herb') |
7b2f11652d67
Miscs from bool to ints. Miscs database uses POST instead of GET. Dropdowns are unsing indexes. Dynamic edit screen adjust for weight and liter. Edit screen redesigned. Friendly show duration of ingredients.
Michiel Broek <mbroek@mbse.eu>
parents:
198
diff
changeset
|
380 | $sql .= "', type='1"; |
7b2f11652d67
Miscs from bool to ints. Miscs database uses POST instead of GET. Dropdowns are unsing indexes. Dynamic edit screen adjust for weight and liter. Edit screen redesigned. Friendly show duration of ingredients.
Michiel Broek <mbroek@mbse.eu>
parents:
198
diff
changeset
|
381 | else if ($misc->TYPE == 'Flavor') |
7b2f11652d67
Miscs from bool to ints. Miscs database uses POST instead of GET. Dropdowns are unsing indexes. Dynamic edit screen adjust for weight and liter. Edit screen redesigned. Friendly show duration of ingredients.
Michiel Broek <mbroek@mbse.eu>
parents:
198
diff
changeset
|
382 | $sql .= "', type='2"; |
7b2f11652d67
Miscs from bool to ints. Miscs database uses POST instead of GET. Dropdowns are unsing indexes. Dynamic edit screen adjust for weight and liter. Edit screen redesigned. Friendly show duration of ingredients.
Michiel Broek <mbroek@mbse.eu>
parents:
198
diff
changeset
|
383 | else if ($misc->TYPE == 'Fining') |
7b2f11652d67
Miscs from bool to ints. Miscs database uses POST instead of GET. Dropdowns are unsing indexes. Dynamic edit screen adjust for weight and liter. Edit screen redesigned. Friendly show duration of ingredients.
Michiel Broek <mbroek@mbse.eu>
parents:
198
diff
changeset
|
384 | $sql .= "', type='3"; |
7b2f11652d67
Miscs from bool to ints. Miscs database uses POST instead of GET. Dropdowns are unsing indexes. Dynamic edit screen adjust for weight and liter. Edit screen redesigned. Friendly show duration of ingredients.
Michiel Broek <mbroek@mbse.eu>
parents:
198
diff
changeset
|
385 | else if ($misc->TYPE == 'Water agent') |
7b2f11652d67
Miscs from bool to ints. Miscs database uses POST instead of GET. Dropdowns are unsing indexes. Dynamic edit screen adjust for weight and liter. Edit screen redesigned. Friendly show duration of ingredients.
Michiel Broek <mbroek@mbse.eu>
parents:
198
diff
changeset
|
386 | $sql .= "', type='4"; |
7b2f11652d67
Miscs from bool to ints. Miscs database uses POST instead of GET. Dropdowns are unsing indexes. Dynamic edit screen adjust for weight and liter. Edit screen redesigned. Friendly show duration of ingredients.
Michiel Broek <mbroek@mbse.eu>
parents:
198
diff
changeset
|
387 | else if ($misc->TYPE == 'Yeast nutrient') |
7b2f11652d67
Miscs from bool to ints. Miscs database uses POST instead of GET. Dropdowns are unsing indexes. Dynamic edit screen adjust for weight and liter. Edit screen redesigned. Friendly show duration of ingredients.
Michiel Broek <mbroek@mbse.eu>
parents:
198
diff
changeset
|
388 | $sql .= "', type='5"; |
7b2f11652d67
Miscs from bool to ints. Miscs database uses POST instead of GET. Dropdowns are unsing indexes. Dynamic edit screen adjust for weight and liter. Edit screen redesigned. Friendly show duration of ingredients.
Michiel Broek <mbroek@mbse.eu>
parents:
198
diff
changeset
|
389 | else if ($misc->TYPE == 'Other') |
7b2f11652d67
Miscs from bool to ints. Miscs database uses POST instead of GET. Dropdowns are unsing indexes. Dynamic edit screen adjust for weight and liter. Edit screen redesigned. Friendly show duration of ingredients.
Michiel Broek <mbroek@mbse.eu>
parents:
198
diff
changeset
|
390 | $sql .= "', type='6"; |
7b2f11652d67
Miscs from bool to ints. Miscs database uses POST instead of GET. Dropdowns are unsing indexes. Dynamic edit screen adjust for weight and liter. Edit screen redesigned. Friendly show duration of ingredients.
Michiel Broek <mbroek@mbse.eu>
parents:
198
diff
changeset
|
391 | else |
7b2f11652d67
Miscs from bool to ints. Miscs database uses POST instead of GET. Dropdowns are unsing indexes. Dynamic edit screen adjust for weight and liter. Edit screen redesigned. Friendly show duration of ingredients.
Michiel Broek <mbroek@mbse.eu>
parents:
198
diff
changeset
|
392 | echo "Unknown TYPE " . $misc->TYPE . PHP_EOL; |
7b2f11652d67
Miscs from bool to ints. Miscs database uses POST instead of GET. Dropdowns are unsing indexes. Dynamic edit screen adjust for weight and liter. Edit screen redesigned. Friendly show duration of ingredients.
Michiel Broek <mbroek@mbse.eu>
parents:
198
diff
changeset
|
393 | |
7b2f11652d67
Miscs from bool to ints. Miscs database uses POST instead of GET. Dropdowns are unsing indexes. Dynamic edit screen adjust for weight and liter. Edit screen redesigned. Friendly show duration of ingredients.
Michiel Broek <mbroek@mbse.eu>
parents:
198
diff
changeset
|
394 | if ($misc->USE == 'Starter') |
7b2f11652d67
Miscs from bool to ints. Miscs database uses POST instead of GET. Dropdowns are unsing indexes. Dynamic edit screen adjust for weight and liter. Edit screen redesigned. Friendly show duration of ingredients.
Michiel Broek <mbroek@mbse.eu>
parents:
198
diff
changeset
|
395 | $sql .= "', use_use='0"; |
7b2f11652d67
Miscs from bool to ints. Miscs database uses POST instead of GET. Dropdowns are unsing indexes. Dynamic edit screen adjust for weight and liter. Edit screen redesigned. Friendly show duration of ingredients.
Michiel Broek <mbroek@mbse.eu>
parents:
198
diff
changeset
|
396 | else if ($misc->USE == 'Mash') |
7b2f11652d67
Miscs from bool to ints. Miscs database uses POST instead of GET. Dropdowns are unsing indexes. Dynamic edit screen adjust for weight and liter. Edit screen redesigned. Friendly show duration of ingredients.
Michiel Broek <mbroek@mbse.eu>
parents:
198
diff
changeset
|
397 | $sql .= "', use_use='1"; |
7b2f11652d67
Miscs from bool to ints. Miscs database uses POST instead of GET. Dropdowns are unsing indexes. Dynamic edit screen adjust for weight and liter. Edit screen redesigned. Friendly show duration of ingredients.
Michiel Broek <mbroek@mbse.eu>
parents:
198
diff
changeset
|
398 | else if ($misc->USE == 'Boil') |
7b2f11652d67
Miscs from bool to ints. Miscs database uses POST instead of GET. Dropdowns are unsing indexes. Dynamic edit screen adjust for weight and liter. Edit screen redesigned. Friendly show duration of ingredients.
Michiel Broek <mbroek@mbse.eu>
parents:
198
diff
changeset
|
399 | $sql .= "', use_use='2"; |
7b2f11652d67
Miscs from bool to ints. Miscs database uses POST instead of GET. Dropdowns are unsing indexes. Dynamic edit screen adjust for weight and liter. Edit screen redesigned. Friendly show duration of ingredients.
Michiel Broek <mbroek@mbse.eu>
parents:
198
diff
changeset
|
400 | else if ($misc->USE == 'Primary') |
7b2f11652d67
Miscs from bool to ints. Miscs database uses POST instead of GET. Dropdowns are unsing indexes. Dynamic edit screen adjust for weight and liter. Edit screen redesigned. Friendly show duration of ingredients.
Michiel Broek <mbroek@mbse.eu>
parents:
198
diff
changeset
|
401 | $sql .= "', use_use='3"; |
7b2f11652d67
Miscs from bool to ints. Miscs database uses POST instead of GET. Dropdowns are unsing indexes. Dynamic edit screen adjust for weight and liter. Edit screen redesigned. Friendly show duration of ingredients.
Michiel Broek <mbroek@mbse.eu>
parents:
198
diff
changeset
|
402 | else if ($misc->USE == 'Secondary') |
7b2f11652d67
Miscs from bool to ints. Miscs database uses POST instead of GET. Dropdowns are unsing indexes. Dynamic edit screen adjust for weight and liter. Edit screen redesigned. Friendly show duration of ingredients.
Michiel Broek <mbroek@mbse.eu>
parents:
198
diff
changeset
|
403 | $sql .= "', use_use='4"; |
7b2f11652d67
Miscs from bool to ints. Miscs database uses POST instead of GET. Dropdowns are unsing indexes. Dynamic edit screen adjust for weight and liter. Edit screen redesigned. Friendly show duration of ingredients.
Michiel Broek <mbroek@mbse.eu>
parents:
198
diff
changeset
|
404 | else if ($misc->USE == 'Bottling') |
7b2f11652d67
Miscs from bool to ints. Miscs database uses POST instead of GET. Dropdowns are unsing indexes. Dynamic edit screen adjust for weight and liter. Edit screen redesigned. Friendly show duration of ingredients.
Michiel Broek <mbroek@mbse.eu>
parents:
198
diff
changeset
|
405 | $sql .= "', use_use='5"; |
7b2f11652d67
Miscs from bool to ints. Miscs database uses POST instead of GET. Dropdowns are unsing indexes. Dynamic edit screen adjust for weight and liter. Edit screen redesigned. Friendly show duration of ingredients.
Michiel Broek <mbroek@mbse.eu>
parents:
198
diff
changeset
|
406 | else |
7b2f11652d67
Miscs from bool to ints. Miscs database uses POST instead of GET. Dropdowns are unsing indexes. Dynamic edit screen adjust for weight and liter. Edit screen redesigned. Friendly show duration of ingredients.
Michiel Broek <mbroek@mbse.eu>
parents:
198
diff
changeset
|
407 | echo "Unknown USE " . $misc->USE . PHP_EOL; |
7b2f11652d67
Miscs from bool to ints. Miscs database uses POST instead of GET. Dropdowns are unsing indexes. Dynamic edit screen adjust for weight and liter. Edit screen redesigned. Friendly show duration of ingredients.
Michiel Broek <mbroek@mbse.eu>
parents:
198
diff
changeset
|
408 | |
11 | 409 | $sql .= "', time='" . $misc->TIME; |
21
acb2d8098f19
Added inventory miscs and water sources.
Michiel Broek <mbroek@mbse.eu>
parents:
20
diff
changeset
|
410 | ($misc->AMOUNT_IS_WEIGHT == 'TRUE') ? $sql .= "', amount_is_weight='1" : $sql .= "', amount_is_weight='0"; |
11 | 411 | if ($misc->USE_FOR) |
412 | $sql .= "', use_for='" . mysqli_real_escape_string($db, $misc->USE_FOR); | |
413 | if ($misc->ALWAYS_ON_STOCK) | |
21
acb2d8098f19
Added inventory miscs and water sources.
Michiel Broek <mbroek@mbse.eu>
parents:
20
diff
changeset
|
414 | ($misc->ALWAYS_ON_STOCK == 'TRUE') ? $sql .= "', always_on_stock='1" : $sql .= "', always_on_stock='0"; |
11 | 415 | if ($misc->INVENTORY) |
32
8bb369f32ef9
Fixed floating precision problems and also got the SRM to EBC conversion right.
Michiel Broek <mbroek@mbse.eu>
parents:
30
diff
changeset
|
416 | $sql .= "', inventory='" . floatval($misc->INVENTORY) / 1000.0; |
11 | 417 | if ($misc->COST) |
32
8bb369f32ef9
Fixed floating precision problems and also got the SRM to EBC conversion right.
Michiel Broek <mbroek@mbse.eu>
parents:
30
diff
changeset
|
418 | $sql .= "', cost='" . floatval($misc->COST); |
11 | 419 | $sql .= "';"; |
420 | if (! $result = mysqli_query($db, $sql)) { | |
421 | printf("Error: %s\n", mysqli_error($db)); | |
422 | } | |
423 | } | |
424 | } | |
425 | ||
426 | ||
427 | ||
428 | function do_equipments() | |
429 | { | |
430 | global $brouwhulp, $db; | |
431 | ||
432 | echo " Start adding equipments to the database\n"; | |
433 | $sql = "TRUNCATE TABLE inventory_equipments;"; | |
434 | if (! $result = mysqli_query($db, $sql)) { | |
435 | printf("Error: %s\n", mysqli_error($db)); | |
436 | } | |
437 | ||
438 | $equipments = simplexml_load_file($brouwhulp . '/equipments.xml'); | |
439 | ||
440 | foreach ($equipments->EQUIPMENT as $equipment) { | |
441 | ||
442 | $sql = "INSERT INTO inventory_equipments SET name='" . mysqli_real_escape_string($db, $equipment->NAME); | |
118
07daa505d309
Improved float precision for databases import.
Michiel Broek <mbroek@mbse.eu>
parents:
114
diff
changeset
|
443 | $sql .= "', boil_size='" . floatval($equipment->BOIL_SIZE); |
07daa505d309
Improved float precision for databases import.
Michiel Broek <mbroek@mbse.eu>
parents:
114
diff
changeset
|
444 | $sql .= "', batch_size='" . floatval($equipment->BATCH_SIZE); |
07daa505d309
Improved float precision for databases import.
Michiel Broek <mbroek@mbse.eu>
parents:
114
diff
changeset
|
445 | $sql .= "', tun_volume='" . floatval($equipment->TUN_VOLUME); |
07daa505d309
Improved float precision for databases import.
Michiel Broek <mbroek@mbse.eu>
parents:
114
diff
changeset
|
446 | $sql .= "', tun_weight='" . floatval($equipment->TUN_WEIGHT); |
07daa505d309
Improved float precision for databases import.
Michiel Broek <mbroek@mbse.eu>
parents:
114
diff
changeset
|
447 | $sql .= "', tun_specific_heat='" . floatval($equipment->TUN_SPECIFIC_HEAT); |
209
dc30801e6961
Import set tun_material from the specifix heat value. Equipment database uses POST instead of GET. Equipment editor screen in style with other inventory screens. In stock print now uses the type indexes to translate to text. Also show the correct unit and values of the yeast.
Michiel Broek <mbroek@mbse.eu>
parents:
202
diff
changeset
|
448 | if (floatval($equipment->TUN_SPECIFIC_HEAT) == 0.11) |
dc30801e6961
Import set tun_material from the specifix heat value. Equipment database uses POST instead of GET. Equipment editor screen in style with other inventory screens. In stock print now uses the type indexes to translate to text. Also show the correct unit and values of the yeast.
Michiel Broek <mbroek@mbse.eu>
parents:
202
diff
changeset
|
449 | $sql .= "', tun_material='0"; |
dc30801e6961
Import set tun_material from the specifix heat value. Equipment database uses POST instead of GET. Equipment editor screen in style with other inventory screens. In stock print now uses the type indexes to translate to text. Also show the correct unit and values of the yeast.
Michiel Broek <mbroek@mbse.eu>
parents:
202
diff
changeset
|
450 | else if (floatval($equipment->TUN_SPECIFIC_HEAT) == 0.22) |
dc30801e6961
Import set tun_material from the specifix heat value. Equipment database uses POST instead of GET. Equipment editor screen in style with other inventory screens. In stock print now uses the type indexes to translate to text. Also show the correct unit and values of the yeast.
Michiel Broek <mbroek@mbse.eu>
parents:
202
diff
changeset
|
451 | $sql .= "', tun_material='1"; |
dc30801e6961
Import set tun_material from the specifix heat value. Equipment database uses POST instead of GET. Equipment editor screen in style with other inventory screens. In stock print now uses the type indexes to translate to text. Also show the correct unit and values of the yeast.
Michiel Broek <mbroek@mbse.eu>
parents:
202
diff
changeset
|
452 | else if (floatval($equipment->TUN_SPECIFIC_HEAT) == 0.46) |
dc30801e6961
Import set tun_material from the specifix heat value. Equipment database uses POST instead of GET. Equipment editor screen in style with other inventory screens. In stock print now uses the type indexes to translate to text. Also show the correct unit and values of the yeast.
Michiel Broek <mbroek@mbse.eu>
parents:
202
diff
changeset
|
453 | $sql .= "', tun_material='2"; |
dc30801e6961
Import set tun_material from the specifix heat value. Equipment database uses POST instead of GET. Equipment editor screen in style with other inventory screens. In stock print now uses the type indexes to translate to text. Also show the correct unit and values of the yeast.
Michiel Broek <mbroek@mbse.eu>
parents:
202
diff
changeset
|
454 | else if (floatval($equipment->TUN_SPECIFIC_HEAT) == 0.092) |
dc30801e6961
Import set tun_material from the specifix heat value. Equipment database uses POST instead of GET. Equipment editor screen in style with other inventory screens. In stock print now uses the type indexes to translate to text. Also show the correct unit and values of the yeast.
Michiel Broek <mbroek@mbse.eu>
parents:
202
diff
changeset
|
455 | $sql .= "', tun_material='3"; |
dc30801e6961
Import set tun_material from the specifix heat value. Equipment database uses POST instead of GET. Equipment editor screen in style with other inventory screens. In stock print now uses the type indexes to translate to text. Also show the correct unit and values of the yeast.
Michiel Broek <mbroek@mbse.eu>
parents:
202
diff
changeset
|
456 | else |
dc30801e6961
Import set tun_material from the specifix heat value. Equipment database uses POST instead of GET. Equipment editor screen in style with other inventory screens. In stock print now uses the type indexes to translate to text. Also show the correct unit and values of the yeast.
Michiel Broek <mbroek@mbse.eu>
parents:
202
diff
changeset
|
457 | echo "Unknown TUN_SPECIFIC_HEAT" . $equipment->TUN_SPECIFIC_HEAT . PHP_EOL; |
118
07daa505d309
Improved float precision for databases import.
Michiel Broek <mbroek@mbse.eu>
parents:
114
diff
changeset
|
458 | $sql .= "', tun_height='" . floatval($equipment->TUN_HEIGHT); |
07daa505d309
Improved float precision for databases import.
Michiel Broek <mbroek@mbse.eu>
parents:
114
diff
changeset
|
459 | $sql .= "', top_up_water='" . floatval($equipment->TOP_UP_WATER); |
07daa505d309
Improved float precision for databases import.
Michiel Broek <mbroek@mbse.eu>
parents:
114
diff
changeset
|
460 | $sql .= "', trub_chiller_loss='" . floatval($equipment->TRUB_CHILLER_LOSS); |
11 | 461 | /* |
462 | * Brouwhulp uses a percentage for the evaporation rate. This is wrong | |
463 | * but was made so because the beerxml standard requires this. What we | |
464 | * do is calculate the actual evaporation and store that. | |
465 | * This is what we use. Brouwhulp calculates this on the fly. | |
466 | */ | |
118
07daa505d309
Improved float precision for databases import.
Michiel Broek <mbroek@mbse.eu>
parents:
114
diff
changeset
|
467 | $sql .= "', evap_rate='" . (floatval($equipment->EVAP_RATE) * floatval($equipment->BOIL_SIZE)) / 100.0; |
07daa505d309
Improved float precision for databases import.
Michiel Broek <mbroek@mbse.eu>
parents:
114
diff
changeset
|
468 | $sql .= "', boil_time='" . floatval($equipment->BOIL_TIME); |
21
acb2d8098f19
Added inventory miscs and water sources.
Michiel Broek <mbroek@mbse.eu>
parents:
20
diff
changeset
|
469 | ($equipment->CALC_BOIL_VOLUME == 'TRUE') ? $sql .= "', calc_boil_volume='1" : $sql .= "', calc_boil_volume='0"; |
118
07daa505d309
Improved float precision for databases import.
Michiel Broek <mbroek@mbse.eu>
parents:
114
diff
changeset
|
470 | $sql .= "', top_up_kettle='" . floatval($equipment->TOP_UP_KETTLE); |
07daa505d309
Improved float precision for databases import.
Michiel Broek <mbroek@mbse.eu>
parents:
114
diff
changeset
|
471 | $sql .= "', hop_utilization='" . floatval($equipment->HOP_UTILIZATION); |
11 | 472 | if ($equipment->NOTES) |
473 | $sql .= "', notes='" . mysqli_real_escape_string($db, $equipment->NOTES); | |
118
07daa505d309
Improved float precision for databases import.
Michiel Broek <mbroek@mbse.eu>
parents:
114
diff
changeset
|
474 | $sql .= "', lauter_volume='" . floatval($equipment->LAUTER_VOLUME); |
07daa505d309
Improved float precision for databases import.
Michiel Broek <mbroek@mbse.eu>
parents:
114
diff
changeset
|
475 | $sql .= "', lauter_height='" . floatval($equipment->LAUTER_HEIGHT); |
07daa505d309
Improved float precision for databases import.
Michiel Broek <mbroek@mbse.eu>
parents:
114
diff
changeset
|
476 | $sql .= "', lauter_deadspace='" . floatval($equipment->LAUTER_DEADSPACE); |
07daa505d309
Improved float precision for databases import.
Michiel Broek <mbroek@mbse.eu>
parents:
114
diff
changeset
|
477 | $sql .= "', kettle_volume='" . floatval($equipment->KETTLE_VOLUME); |
07daa505d309
Improved float precision for databases import.
Michiel Broek <mbroek@mbse.eu>
parents:
114
diff
changeset
|
478 | $sql .= "', kettle_height='" . floatval($equipment->KETTLE_HEIGHT); |
07daa505d309
Improved float precision for databases import.
Michiel Broek <mbroek@mbse.eu>
parents:
114
diff
changeset
|
479 | $sql .= "', mash_volume='" . floatval($equipment->MASH_VOLUME); |
149
ff45488d480e
Added some icons from Brewersfriend. They should be replaced someday. Added maximum mash weight setting to the equipment database. Usefull for brew automate and RIMS systems. During recipes import acid and base additions are translated. Brews and recipes now have 2 water sources. Added water mixer. Added basic water treatment, but not for pH yet. Redesigned the fermentables and water tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
148
diff
changeset
|
480 | $sql .= "', mash_max='" . round((floatval($equipment->MASH_VOLUME) / 3) * 10) / 10; // Not in beerxml/brouwhulp. For RIMS systems. |
118
07daa505d309
Improved float precision for databases import.
Michiel Broek <mbroek@mbse.eu>
parents:
114
diff
changeset
|
481 | $sql .= "', efficiency='" . floatval($equipment->EFFICIENCY); |
11 | 482 | $sql .= "';"; |
483 | if (! $result = mysqli_query($db, $sql)) { | |
484 | printf("Error: %s\n", mysqli_error($db)); | |
485 | } | |
486 | } | |
487 | } | |
488 | ||
489 | ||
490 | ||
491 | function do_styles() | |
492 | { | |
493 | global $brouwhulp, $db; | |
494 | ||
495 | echo " Start adding styles to the database\n"; | |
45
95251bedfab4
Moved three inventory tables and screens to profiles
Michiel Broek <mbroek@mbse.eu>
parents:
38
diff
changeset
|
496 | $sql = "TRUNCATE TABLE profile_styles;"; |
11 | 497 | if (! $result = mysqli_query($db, $sql)) { |
498 | printf("Error: %s\n", mysqli_error($db)); | |
499 | } | |
500 | ||
501 | $styles = simplexml_load_file($brouwhulp . '/styles.xml'); | |
502 | ||
503 | foreach ($styles->STYLE as $style) { | |
504 | ||
45
95251bedfab4
Moved three inventory tables and screens to profiles
Michiel Broek <mbroek@mbse.eu>
parents:
38
diff
changeset
|
505 | $sql = "INSERT INTO profile_styles SET name='" . mysqli_real_escape_string($db, $style->NAME); |
11 | 506 | if ($style->NOTES) |
507 | $sql .= "', notes='" . mysqli_real_escape_string($db, $style->NOTES); | |
508 | if ($style->CATEGORY) | |
509 | $sql .= "', category='" . mysqli_real_escape_string($db, $style->CATEGORY); | |
510 | if ($style->CATEGORY_NUMBER) | |
511 | $sql .= "', category_number='" . $style->CATEGORY_NUMBER; | |
512 | if ($style->STYLE_LETTER) | |
513 | $sql .= "', style_letter='" . mysqli_real_escape_string($db, $style->STYLE_LETTER); | |
514 | if ($style->STYLE_GUIDE) | |
515 | $sql .= "', style_guide='" . mysqli_real_escape_string($db, $style->STYLE_GUIDE); | |
217
318aab371497
Profile style is using indexes. Profile styles and fermentation switched to POST. Standard edit screens.
Michiel Broek <mbroek@mbse.eu>
parents:
213
diff
changeset
|
516 | |
318aab371497
Profile style is using indexes. Profile styles and fermentation switched to POST. Standard edit screens.
Michiel Broek <mbroek@mbse.eu>
parents:
213
diff
changeset
|
517 | if ($style->TYPE == 'Lager') |
318aab371497
Profile style is using indexes. Profile styles and fermentation switched to POST. Standard edit screens.
Michiel Broek <mbroek@mbse.eu>
parents:
213
diff
changeset
|
518 | $sql .= "', type='0"; |
318aab371497
Profile style is using indexes. Profile styles and fermentation switched to POST. Standard edit screens.
Michiel Broek <mbroek@mbse.eu>
parents:
213
diff
changeset
|
519 | else if ($style->TYPE == 'Ale') |
318aab371497
Profile style is using indexes. Profile styles and fermentation switched to POST. Standard edit screens.
Michiel Broek <mbroek@mbse.eu>
parents:
213
diff
changeset
|
520 | $sql .= "', type='1"; |
318aab371497
Profile style is using indexes. Profile styles and fermentation switched to POST. Standard edit screens.
Michiel Broek <mbroek@mbse.eu>
parents:
213
diff
changeset
|
521 | else if ($style->TYPE == 'Mead') |
318aab371497
Profile style is using indexes. Profile styles and fermentation switched to POST. Standard edit screens.
Michiel Broek <mbroek@mbse.eu>
parents:
213
diff
changeset
|
522 | $sql .= "', type='2"; |
318aab371497
Profile style is using indexes. Profile styles and fermentation switched to POST. Standard edit screens.
Michiel Broek <mbroek@mbse.eu>
parents:
213
diff
changeset
|
523 | else if ($style->TYPE == 'Wheat') |
318aab371497
Profile style is using indexes. Profile styles and fermentation switched to POST. Standard edit screens.
Michiel Broek <mbroek@mbse.eu>
parents:
213
diff
changeset
|
524 | $sql .= "', type='3"; |
318aab371497
Profile style is using indexes. Profile styles and fermentation switched to POST. Standard edit screens.
Michiel Broek <mbroek@mbse.eu>
parents:
213
diff
changeset
|
525 | else if ($style->TYPE == 'Mixed') |
318aab371497
Profile style is using indexes. Profile styles and fermentation switched to POST. Standard edit screens.
Michiel Broek <mbroek@mbse.eu>
parents:
213
diff
changeset
|
526 | $sql .= "', type='4"; |
318aab371497
Profile style is using indexes. Profile styles and fermentation switched to POST. Standard edit screens.
Michiel Broek <mbroek@mbse.eu>
parents:
213
diff
changeset
|
527 | else if ($style->TYPE == 'Cider') |
318aab371497
Profile style is using indexes. Profile styles and fermentation switched to POST. Standard edit screens.
Michiel Broek <mbroek@mbse.eu>
parents:
213
diff
changeset
|
528 | $sql .= "', type='5"; |
318aab371497
Profile style is using indexes. Profile styles and fermentation switched to POST. Standard edit screens.
Michiel Broek <mbroek@mbse.eu>
parents:
213
diff
changeset
|
529 | else |
318aab371497
Profile style is using indexes. Profile styles and fermentation switched to POST. Standard edit screens.
Michiel Broek <mbroek@mbse.eu>
parents:
213
diff
changeset
|
530 | echo "Unknown TYPE " . $style->TYPE . PHP_EOL; |
318aab371497
Profile style is using indexes. Profile styles and fermentation switched to POST. Standard edit screens.
Michiel Broek <mbroek@mbse.eu>
parents:
213
diff
changeset
|
531 | |
48
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
532 | $sql .= "', og_min='" . floatval($style->OG_MIN); |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
533 | $sql .= "', og_max='" . floatval($style->OG_MAX); |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
534 | $sql .= "', fg_min='" . floatval($style->FG_MIN); |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
535 | $sql .= "', fg_max='" . floatval($style->FG_MAX); |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
536 | $sql .= "', ibu_min='" . floatval($style->IBU_MIN); |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
537 | $sql .= "', ibu_max='" . floatval($style->IBU_MAX); |
152
2e4249add363
Import from brouwhulp fix style color ranges. Added calcSVG and calcABV calculation. Added batch size, time, efficiency and og change actions. Added style select and redesigned the first tab to fit this in. When equipment is changed, recalculate the recipe. Added print button.
Michiel Broek <mbroek@mbse.eu>
parents:
151
diff
changeset
|
538 | $sql .= "', color_min='" . srm_to_ebc(floatval($style->COLOR_MIN)); |
2e4249add363
Import from brouwhulp fix style color ranges. Added calcSVG and calcABV calculation. Added batch size, time, efficiency and og change actions. Added style select and redesigned the first tab to fit this in. When equipment is changed, recalculate the recipe. Added print button.
Michiel Broek <mbroek@mbse.eu>
parents:
151
diff
changeset
|
539 | $sql .= "', color_max='" . srm_to_ebc(floatval($style->COLOR_MAX)); |
48
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
540 | $sql .= "', carb_min='" . floatval($style->CARB_MIN); |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
541 | $sql .= "', carb_max='" . floatval($style->CARB_MAX); |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
542 | $sql .= "', abv_min='" . floatval($style->ABV_MIN); |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
543 | $sql .= "', abv_max='" . floatval($style->ABV_MAX); |
11 | 544 | if ($style->PROFILE) |
545 | $sql .= "', profile='" . mysqli_real_escape_string($db, $style->PROFILE); | |
546 | if ($style->INGREDIENTS) | |
547 | $sql .= "', ingredients='" . mysqli_real_escape_string($db, $style->INGREDIENTS); | |
548 | if ($style->EXAMPLES) | |
549 | $sql .= "', examples='" . mysqli_real_escape_string($db, $style->EXAMPLES); | |
550 | ||
551 | $sql .= "';"; | |
552 | if (! $result = mysqli_query($db, $sql)) { | |
553 | printf("Error: %s\n", mysqli_error($db)); | |
554 | } | |
555 | } | |
556 | } | |
557 | ||
558 | ||
559 | ||
560 | function do_mash() | |
561 | { | |
562 | global $brouwhulp, $db; | |
563 | ||
564 | echo " Start adding mash profiles to the database\n"; | |
45
95251bedfab4
Moved three inventory tables and screens to profiles
Michiel Broek <mbroek@mbse.eu>
parents:
38
diff
changeset
|
565 | $sql = "TRUNCATE TABLE profile_mash;"; |
11 | 566 | if (! $result = mysqli_query($db, $sql)) { |
567 | printf("Error: %s\n", mysqli_error($db)); | |
568 | } | |
569 | ||
570 | $mashes = simplexml_load_file($brouwhulp . '/mashs.xml'); | |
571 | ||
572 | foreach ($mashes->MASH as $mash) { | |
45
95251bedfab4
Moved three inventory tables and screens to profiles
Michiel Broek <mbroek@mbse.eu>
parents:
38
diff
changeset
|
573 | $sql = "INSERT INTO profile_mash SET name='" . mysqli_real_escape_string($db, $mash->NAME); |
11 | 574 | if ($mash->NOTES) |
575 | $sql .= "', notes='" . mysqli_real_escape_string($db, $mash->NOTES); | |
576 | ||
577 | /* | |
23
4b157d7a1cee
Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
22
diff
changeset
|
578 | * Put the steps in a json array |
11 | 579 | */ |
580 | if ($mash->MASH_STEPS) { | |
23
4b157d7a1cee
Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
22
diff
changeset
|
581 | $steps = "["; |
4b157d7a1cee
Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
22
diff
changeset
|
582 | $comma = FALSE; |
11 | 583 | foreach ($mash->MASH_STEPS->MASH_STEP as $step) { |
584 | ||
23
4b157d7a1cee
Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
22
diff
changeset
|
585 | if ($comma) |
4b157d7a1cee
Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
22
diff
changeset
|
586 | $steps .= ','; |
4b157d7a1cee
Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
22
diff
changeset
|
587 | $comma = TRUE; |
38
b7d44c98d609
Initial setup for mash steps editing.
Michiel Broek <mbroek@mbse.eu>
parents:
35
diff
changeset
|
588 | $steps .= '{"step_name":"' . mysqli_real_escape_string($db, $step->NAME) . '"'; |
213
b0d484a5525e
First step to make profile mash work with indexes and make the edit screen universal.
Michiel Broek <mbroek@mbse.eu>
parents:
209
diff
changeset
|
589 | if ($step->TYPE == 'Infusion') |
b0d484a5525e
First step to make profile mash work with indexes and make the edit screen universal.
Michiel Broek <mbroek@mbse.eu>
parents:
209
diff
changeset
|
590 | $steps .= ',"step_type":"0"'; |
b0d484a5525e
First step to make profile mash work with indexes and make the edit screen universal.
Michiel Broek <mbroek@mbse.eu>
parents:
209
diff
changeset
|
591 | else if ($step->TYPE == 'Temperature') |
b0d484a5525e
First step to make profile mash work with indexes and make the edit screen universal.
Michiel Broek <mbroek@mbse.eu>
parents:
209
diff
changeset
|
592 | $steps .= ',"step_type":"1"'; |
b0d484a5525e
First step to make profile mash work with indexes and make the edit screen universal.
Michiel Broek <mbroek@mbse.eu>
parents:
209
diff
changeset
|
593 | else if ($step->TYPE == 'Decoction') |
b0d484a5525e
First step to make profile mash work with indexes and make the edit screen universal.
Michiel Broek <mbroek@mbse.eu>
parents:
209
diff
changeset
|
594 | $steps .= ',"step_type":"2"'; |
b0d484a5525e
First step to make profile mash work with indexes and make the edit screen universal.
Michiel Broek <mbroek@mbse.eu>
parents:
209
diff
changeset
|
595 | else |
b0d484a5525e
First step to make profile mash work with indexes and make the edit screen universal.
Michiel Broek <mbroek@mbse.eu>
parents:
209
diff
changeset
|
596 | echo "Unknown step TYPE " . $step->TYPE . PHP_EOL; |
23
4b157d7a1cee
Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
22
diff
changeset
|
597 | if ($step->STEP_TEMP) { |
118
07daa505d309
Improved float precision for databases import.
Michiel Broek <mbroek@mbse.eu>
parents:
114
diff
changeset
|
598 | $steps .= ',"step_temp":"' . floatval($step->STEP_TEMP) . '"'; |
23
4b157d7a1cee
Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
22
diff
changeset
|
599 | } |
4b157d7a1cee
Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
22
diff
changeset
|
600 | if ($step->STEP_TIME) { |
118
07daa505d309
Improved float precision for databases import.
Michiel Broek <mbroek@mbse.eu>
parents:
114
diff
changeset
|
601 | $steps .= ',"step_time":"' . floatval($step->STEP_TIME) . '"'; |
11 | 602 | } |
23
4b157d7a1cee
Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
22
diff
changeset
|
603 | if ($step->RAMP_TIME) { |
118
07daa505d309
Improved float precision for databases import.
Michiel Broek <mbroek@mbse.eu>
parents:
114
diff
changeset
|
604 | $steps .= ',"ramp_time":"' . floatval($step->RAMP_TIME) . '"'; |
23
4b157d7a1cee
Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
22
diff
changeset
|
605 | } |
4b157d7a1cee
Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
22
diff
changeset
|
606 | if ($step->END_TEMP) { |
118
07daa505d309
Improved float precision for databases import.
Michiel Broek <mbroek@mbse.eu>
parents:
114
diff
changeset
|
607 | $steps .= ',"end_temp":"' . floatval($step->END_TEMP) . '"'; |
23
4b157d7a1cee
Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
22
diff
changeset
|
608 | } |
4b157d7a1cee
Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
22
diff
changeset
|
609 | $steps .= "}"; |
11 | 610 | } |
23
4b157d7a1cee
Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
22
diff
changeset
|
611 | $steps .= ']'; |
4b157d7a1cee
Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
22
diff
changeset
|
612 | $sql .= "', steps='" . $steps; |
4b157d7a1cee
Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
22
diff
changeset
|
613 | } |
35 | 614 | $sql .= "';"; |
23
4b157d7a1cee
Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
22
diff
changeset
|
615 | if (! $result = mysqli_query($db, $sql)) { |
4b157d7a1cee
Added first part of mash profiles. Steps are in the database but not in the web ui.
Michiel Broek <mbroek@mbse.eu>
parents:
22
diff
changeset
|
616 | printf("Error: %s\n", mysqli_error($db)); |
11 | 617 | } |
618 | } | |
619 | } | |
620 | ||
621 | ||
622 | ||
106
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
623 | /* |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
624 | * Return recipe ingredients as json functions. |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
625 | */ |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
626 | function recipe_style($recipe) |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
627 | { |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
628 | global $db; |
48
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
629 | |
106
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
630 | if ($recipe->STYLE->NAME) |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
631 | $sql = "', st_name='" . mysqli_real_escape_string($db, $recipe->STYLE->NAME); |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
632 | if ($recipe->STYLE->STYLE_LETTER) |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
633 | $sql .= "', st_letter='" . mysqli_real_escape_string($db, $recipe->STYLE->STYLE_LETTER); |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
634 | if ($recipe->STYLE->STYLE_GUIDE) { |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
635 | if ($recipe->STYLE->STYLE_GUIDE == "Biertypengids Derek Walsh") { |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
636 | $sql .= "', st_guide='BKG 2015"; |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
637 | } else if ($recipe->STYLE->STYLE_GUIDE == "BKG Biertypen") { |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
638 | $sql .= "', st_guide='BKG 2015"; |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
639 | } else { |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
640 | $sql .= "', st_guide='" . mysqli_real_escape_string($db, $recipe->STYLE->STYLE_GUIDE); |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
641 | } |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
642 | } |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
643 | if ($recipe->STYLE->CATEGORY) |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
644 | $sql .= "', st_category='" . mysqli_real_escape_string($db, $recipe->STYLE->CATEGORY); |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
645 | if ($recipe->STYLE->CATEGORY_NUMBER) |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
646 | $sql .= "', st_category_number='" . floatval($recipe->STYLE->CATEGORY_NUMBER); |
217
318aab371497
Profile style is using indexes. Profile styles and fermentation switched to POST. Standard edit screens.
Michiel Broek <mbroek@mbse.eu>
parents:
213
diff
changeset
|
647 | if ($recipe->STYLE->TYPE == 'Lager') |
318aab371497
Profile style is using indexes. Profile styles and fermentation switched to POST. Standard edit screens.
Michiel Broek <mbroek@mbse.eu>
parents:
213
diff
changeset
|
648 | $sql .= "', st_type='0"; |
318aab371497
Profile style is using indexes. Profile styles and fermentation switched to POST. Standard edit screens.
Michiel Broek <mbroek@mbse.eu>
parents:
213
diff
changeset
|
649 | else if ($recipe->STYLE->TYPE == 'Ale') |
318aab371497
Profile style is using indexes. Profile styles and fermentation switched to POST. Standard edit screens.
Michiel Broek <mbroek@mbse.eu>
parents:
213
diff
changeset
|
650 | $sql .= "', st_type='1"; |
318aab371497
Profile style is using indexes. Profile styles and fermentation switched to POST. Standard edit screens.
Michiel Broek <mbroek@mbse.eu>
parents:
213
diff
changeset
|
651 | else if ($recipe->STYLE->TYPE == 'Mead') |
318aab371497
Profile style is using indexes. Profile styles and fermentation switched to POST. Standard edit screens.
Michiel Broek <mbroek@mbse.eu>
parents:
213
diff
changeset
|
652 | $sql .= "', st_type='2"; |
318aab371497
Profile style is using indexes. Profile styles and fermentation switched to POST. Standard edit screens.
Michiel Broek <mbroek@mbse.eu>
parents:
213
diff
changeset
|
653 | else if ($recipe->STYLE->TYPE == 'Wheat') |
318aab371497
Profile style is using indexes. Profile styles and fermentation switched to POST. Standard edit screens.
Michiel Broek <mbroek@mbse.eu>
parents:
213
diff
changeset
|
654 | $sql .= "', st_type='3"; |
318aab371497
Profile style is using indexes. Profile styles and fermentation switched to POST. Standard edit screens.
Michiel Broek <mbroek@mbse.eu>
parents:
213
diff
changeset
|
655 | else if ($recipe->STYLE->TYPE == 'Mixed') |
318aab371497
Profile style is using indexes. Profile styles and fermentation switched to POST. Standard edit screens.
Michiel Broek <mbroek@mbse.eu>
parents:
213
diff
changeset
|
656 | $sql .= "', st_type='4"; |
318aab371497
Profile style is using indexes. Profile styles and fermentation switched to POST. Standard edit screens.
Michiel Broek <mbroek@mbse.eu>
parents:
213
diff
changeset
|
657 | else if ($recipe->STYLE->TYPE == 'Cider') |
318aab371497
Profile style is using indexes. Profile styles and fermentation switched to POST. Standard edit screens.
Michiel Broek <mbroek@mbse.eu>
parents:
213
diff
changeset
|
658 | $sql .= "', st_type='5"; |
318aab371497
Profile style is using indexes. Profile styles and fermentation switched to POST. Standard edit screens.
Michiel Broek <mbroek@mbse.eu>
parents:
213
diff
changeset
|
659 | else |
318aab371497
Profile style is using indexes. Profile styles and fermentation switched to POST. Standard edit screens.
Michiel Broek <mbroek@mbse.eu>
parents:
213
diff
changeset
|
660 | echo "Unknown TYPE " . $recipe->STYLE->TYPE . PHP_EOL; |
318aab371497
Profile style is using indexes. Profile styles and fermentation switched to POST. Standard edit screens.
Michiel Broek <mbroek@mbse.eu>
parents:
213
diff
changeset
|
661 | |
106
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
662 | if ($recipe->STYLE->OG_MIN) |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
663 | $sql .= "', st_og_min='" . floatval($recipe->STYLE->OG_MIN); |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
664 | if ($recipe->STYLE->OG_MAX) |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
665 | $sql .= "', st_og_max='" . floatval($recipe->STYLE->OG_MAX); |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
666 | if ($recipe->STYLE->FG_MIN) |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
667 | $sql .= "', st_fg_min='" . floatval($recipe->STYLE->FG_MIN); |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
668 | if ($recipe->STYLE->FG_MAX) |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
669 | $sql .= "', st_fg_max='" . floatval($recipe->STYLE->FG_MAX); |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
670 | if ($recipe->STYLE->IBU_MIN) |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
671 | $sql .= "', st_ibu_min='" . floatval($recipe->STYLE->IBU_MIN); |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
672 | if ($recipe->STYLE->IBU_MAX) |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
673 | $sql .= "', st_ibu_max='" . floatval($recipe->STYLE->IBU_MAX); |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
674 | if ($recipe->STYLE->COLOR_MIN) { |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
675 | $srm = floatval($recipe->STYLE->COLOR_MIN); |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
676 | $sql .= "', st_color_min='" . srm_to_ebc($srm); |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
677 | } |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
678 | if ($recipe->STYLE->COLOR_MAX) { |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
679 | $srm = floatval($recipe->STYLE->COLOR_MAX); |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
680 | $sql .= "', st_color_max='" . srm_to_ebc($srm); |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
681 | } |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
682 | if ($recipe->STYLE->CARB_MIN) |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
683 | $sql .= "', st_carb_min='" . floatval($recipe->STYLE->CARB_MIN); |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
684 | if ($recipe->STYLE->CARB_MAX) |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
685 | $sql .= "', st_carb_max='" . floatval($recipe->STYLE->CARB_MAX); |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
686 | if ($recipe->STYLE->ABV_MIN) |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
687 | $sql .= "', st_abv_min='" . floatval($recipe->STYLE->ABV_MIN); |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
688 | if ($recipe->STYLE->ABV_MAX) |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
689 | $sql .= "', st_abv_max='" . floatval($recipe->STYLE->ABV_MAX); |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
690 | return $sql; |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
691 | } |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
692 | |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
693 | function recipe_fermentables($recipe) |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
694 | { |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
695 | global $db; |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
696 | global $pCara; |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
697 | global $pSugar; |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
698 | global $batch_size; |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
699 | global $efficiency; |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
700 | global $colorw; |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
701 | global $f_sugars; |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
702 | |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
703 | $fermentables = "["; |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
704 | $comma = FALSE; |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
705 | foreach ($recipe->FERMENTABLES->FERMENTABLE as $fermentable) { |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
706 | if ($comma) |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
707 | $fermentables .= ','; |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
708 | $comma = TRUE; |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
709 | $fermentables .= '{"f_name":"' . mysqli_real_escape_string($db, $fermentable->NAME) . '"'; |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
710 | $fermentables .= ',"f_origin":"' . mysqli_real_escape_string($db, $fermentable->ORIGIN) . '"'; |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
711 | $fermentables .= ',"f_supplier":"' . mysqli_real_escape_string($db, $fermentable->SUPPLIER) . '"'; |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
712 | $famount = floatval($fermentable->AMOUNT); |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
713 | $fermentables .= ',"f_amount":' . $famount; |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
714 | $fermentables .= ',"f_cost":' . floatval($fermentable->COST); |
220
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
715 | |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
716 | if ($fermentable->TYPE == 'Grain') |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
717 | $fermentables .= ',"f_type":0'; |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
718 | else if ($fermentable->TYPE == 'Sugar') |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
719 | $fermentables .= ',"f_type":1'; |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
720 | else if ($fermentable->TYPE == 'Extract') |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
721 | $fermentables .= ',"f_type":2'; |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
722 | else if ($fermentable->TYPE == 'Dry extract') |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
723 | $fermentables .= ',"f_type":3'; |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
724 | else if ($fermentable->TYPE == 'Adjunct') |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
725 | $fermentables .= ',"f_type":4'; |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
726 | else |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
727 | echo "Unknown TYPE " . $fermentable->TYPE . PHP_EOL; |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
728 | |
106
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
729 | $fyield = floatval($fermentable->YIELD); |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
730 | $fermentables .= ',"f_yield":' . $fyield; |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
731 | if ($fermentable->COLOR) { |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
732 | $srm = floatval($fermentable->COLOR); |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
733 | $ebc = srm_to_ebc($srm); |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
734 | } else { |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
735 | $srm = 0; |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
736 | $ebc = 0; |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
737 | } |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
738 | $colorw += ($famount * $srm / $batch_size) * 8.34436; /* Kleurwerking */ |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
739 | $fermentables .= ',"f_color":' . $ebc; |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
740 | if ($fermentable->COARSE_FINE_DIFF) |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
741 | $fermentables .= ',"f_coarse_fine_diff":' . floatval($fermentable->COARSE_FINE_DIFF); |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
742 | else |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
743 | $fermentables .= ',"f_coarse_fine_diff":0'; |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
744 | if ($fermentable->MOISTURE) |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
745 | $fmoisture = floatval($fermentable->MOISTURE); |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
746 | else |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
747 | $fmoisture = 0; |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
748 | $fermentables .= ',"f_moisture":' . $fmoisture; |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
749 | if ($fermentable->DIASTATIC_POWER) |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
750 | $fermentables .= ',"f_diastatic_power":' . floatval($fermentable->DIASTATIC_POWER); |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
751 | else |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
752 | $fermentables .= ',"f_diastatic_power":0'; |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
753 | if ($fermentable->PROTEIN) |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
754 | $fermentables .= ',"f_protein":' . floatval($fermentable->PROTEIN); |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
755 | else |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
756 | $fermentables .= ',"f_protein":0'; |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
757 | if ($fermentable->MAX_IN_BATCH) |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
758 | $fermentables .= ',"f_max_in_batch":' . floatval($fermentable->MAX_IN_BATCH); |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
759 | else |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
760 | $fermentables .= ',"f_max_in_batch":100.0'; |
220
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
761 | |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
762 | if ($fermentable->GRAINTYPE == 'Base') |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
763 | $fermentables .= ',"f_graintype":0'; |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
764 | else if ($fermentable->GRAINTYPE == 'Roast') |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
765 | $fermentables .= ',"f_graintype":1'; |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
766 | else if ($fermentable->GRAINTYPE == 'Crystal') |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
767 | $fermentables .= ',"f_graintype":2'; |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
768 | else if ($fermentable->GRAINTYPE == 'Kilned') |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
769 | $fermentables .= ',"f_graintype":3'; |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
770 | else if ($fermentable->GRAINTYPE == 'Sour malt') |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
771 | $fermentables .= ',"f_graintype":4'; |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
772 | else if ($fermentable->GRAINTYPE == 'Special') |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
773 | $fermentables .= ',"f_graintype":5'; |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
774 | else if ($fermentable->GRAINTYPE == 'No malt') |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
775 | $fermentables .= ',"f_graintype":6'; |
106
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
776 | else |
220
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
777 | echo "Unknown GRAINTYPE " . $fermentable->GRAINTYPE . PHP_EOL; |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
778 | |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
779 | if ($fermentable->ADDED == 'Mash') |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
780 | $fermentables .= ',"f_added":0'; |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
781 | else if ($fermentable->ADDED == 'Boil') |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
782 | $fermentables .= ',"f_added":1'; |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
783 | else if ($fermentable->ADDED == 'Fermentation') |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
784 | $fermentables .= ',"f_added":2'; |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
785 | else if ($fermentable->ADDED == 'Lagering') |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
786 | $fermentables .= ',"f_added":3'; |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
787 | else if ($fermentable->ADDED == 'Bottle') |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
788 | $fermentables .= ',"f_added":4'; |
106
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
789 | else |
220
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
790 | echo "Unknown ADDED " . $fermentable->ADDED . PHP_EOL; |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
791 | |
175
da16371538c3
When importing from brouwhulp use 0 and 1 instead of false and true for boolean variables. Added Export button to the recipe editor. Added beerxml recipe export.
Michiel Broek <mbroek@mbse.eu>
parents:
163
diff
changeset
|
792 | ($fermentable->ADD_AFTER_BOIL== "TRUE") ? $fermentables .= ',"f_add_after_boil":1' : $fermentables .= ',"f_add_after_boil":0'; |
da16371538c3
When importing from brouwhulp use 0 and 1 instead of false and true for boolean variables. Added Export button to the recipe editor. Added beerxml recipe export.
Michiel Broek <mbroek@mbse.eu>
parents:
163
diff
changeset
|
793 | ($fermentable->RECOMMEND_MASH== "TRUE") ? $fermentables .= ',"f_recommend_mash":1' : $fermentables .= ',"f_recommend_mash":0'; |
106
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
794 | if ($fermentable->DISSOLVED_PROTEIN) |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
795 | $fermentables .= ',"f_dissolved_protein":' . floatval($fermentable->DISSOLVED_PROTEIN); |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
796 | else |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
797 | $fermentables .= ',"f_dissolved_protein":0'; |
175
da16371538c3
When importing from brouwhulp use 0 and 1 instead of false and true for boolean variables. Added Export button to the recipe editor. Added beerxml recipe export.
Michiel Broek <mbroek@mbse.eu>
parents:
163
diff
changeset
|
798 | ($fermentable->ADJUST_TO_TOTAL_100 == "TRUE") ? $fermentables .= ',"f_adjust_to_total_100":1' : $fermentables .= ',"f_adjust_to_total_100":0'; |
106
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
799 | $percent = floatval($fermentable->PERCENTAGE); |
126
9999b3ce98cb
Row editors are now per cell. Added fermentable percentages editor.
Michiel Broek <mbroek@mbse.eu>
parents:
121
diff
changeset
|
800 | $fermentables .= ',"f_percentage":' . round($percent * 10) / 10.0; |
106
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
801 | if ($fermentable->DI_pH) |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
802 | $fermentables .= ',"f_di_ph":' . floatval($fermentable->DI_pH); |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
803 | else |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
804 | $fermentables .= ',"f_di_ph":0.0'; |
154
ef298b5aa994
Added f_acid_to_ph_57 to the fermentables json in the recipes. The protonDeficit now processes the grist. Water pH calculations are partly in place. Added simple BU and Cl/So4 indicators. Redesign of the water screen.
Michiel Broek <mbroek@mbse.eu>
parents:
152
diff
changeset
|
805 | if ($fermentable->{'ACID_TO_pH_5.7'}) |
ef298b5aa994
Added f_acid_to_ph_57 to the fermentables json in the recipes. The protonDeficit now processes the grist. Water pH calculations are partly in place. Added simple BU and Cl/So4 indicators. Redesign of the water screen.
Michiel Broek <mbroek@mbse.eu>
parents:
152
diff
changeset
|
806 | $fermentables .= ',"f_acid_to_ph_57":' . floatval($fermentable->{'ACID_TO_pH_5.7'}); |
ef298b5aa994
Added f_acid_to_ph_57 to the fermentables json in the recipes. The protonDeficit now processes the grist. Water pH calculations are partly in place. Added simple BU and Cl/So4 indicators. Redesign of the water screen.
Michiel Broek <mbroek@mbse.eu>
parents:
152
diff
changeset
|
807 | else |
ef298b5aa994
Added f_acid_to_ph_57 to the fermentables json in the recipes. The protonDeficit now processes the grist. Water pH calculations are partly in place. Added simple BU and Cl/So4 indicators. Redesign of the water screen.
Michiel Broek <mbroek@mbse.eu>
parents:
152
diff
changeset
|
808 | $fermentables .= ',"f_acid_to_ph_57":0.0'; |
106
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
809 | $fermentables .= "}"; |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
810 | /* Sugars */ |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
811 | $d = $famount * ($fyield / 100) * (1 - $fmoisture / 100); |
220
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
812 | if ($fermentable->ADDED == 'Mash') |
106
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
813 | $d = floatval($efficiency) / 100 * $d; |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
814 | $f_sugars += $d; |
220
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
815 | if ($fermentable->GRAINTYPE == 'Crystal') |
106
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
816 | $pCara += $percent; |
220
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
817 | if ($fermentable->TYPE == 'Sugar') |
106
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
818 | $pSugar += $percent; |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
819 | } |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
820 | $fermentables .= ']'; |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
821 | return $fermentables; |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
822 | } |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
823 | |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
824 | function recipe_hops($recipe) |
48
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
825 | { |
106
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
826 | global $db; |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
827 | |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
828 | $hops = "["; |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
829 | $comma = FALSE; |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
830 | foreach ($recipe->HOPS->HOP as $hop) { |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
831 | if ($comma) |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
832 | $hops .= ','; |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
833 | $comma = TRUE; |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
834 | $hops .= '{"h_name":"' . mysqli_real_escape_string($db, $hop->NAME) . '"'; |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
835 | $hops .= ',"h_amount":' . floatval($hop->AMOUNT); |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
836 | $hops .= ',"h_cost":' . floatval($hop->COST); |
220
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
837 | |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
838 | if ($hop->TYPE == 'Bittering') |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
839 | $hops .= ',"h_type":0'; |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
840 | else if ($hop->TYPE == 'Aroma') |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
841 | $hops .= ',"h_type":1'; |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
842 | else if ($hop->TYPE == 'Both') |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
843 | $hops .= ',"h_type":2'; |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
844 | else |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
845 | echo "Unknown TYPE " . $hop->TYPE . PHP_EOL; |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
846 | |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
847 | if ($hop->FORM == 'Pellet') |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
848 | $hops .= ',"h_form":0'; |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
849 | else if ($hop->FORM == 'Plug') |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
850 | $hops .= ',"h_form":1'; |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
851 | else if ($hop->FORM == 'Leaf') |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
852 | $hops .= ',"h_form":2'; |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
853 | else |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
854 | echo "Unknown FORM " . $hop->FORM . PHP_EOL; |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
855 | |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
856 | if ($hop->USE == 'Mash') |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
857 | $hops .= ',"h_useat":0'; |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
858 | else if ($hop->USE == 'First wort') |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
859 | $hops .= ',"h_useat":1'; |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
860 | else if ($hop->USE == 'Boil') |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
861 | $hops .= ',"h_useat":2'; |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
862 | else if ($hop->USE == 'Aroma') |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
863 | $hops .= ',"h_useat":3'; |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
864 | else if ($hop->USE == 'Whirlpool') |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
865 | $hops .= ',"h_useat":4'; |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
866 | else if ($hop->USE == 'Dry hop') |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
867 | $hops .= ',"h_useat":5'; |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
868 | else |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
869 | echo "Unknown USE " . $hop->USE . PHP_EOL; |
106
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
870 | if ($hop->TIME) |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
871 | $hops .= ',"h_time":' . floatval($hop->TIME); |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
872 | else |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
873 | $hops .= ',"h_time":0'; |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
874 | $hops .= ',"h_alpha":' . floatval($hop->ALPHA); |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
875 | $hops .= ',"h_beta":' . floatval($hop->BETA); |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
876 | $hops .= ',"h_hsi":' . floatval($hop->HSI); |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
877 | $hops .= ',"h_humulene":' . floatval($hop->HUMULENE); |
223
0de4455bd2a1
Fixed spelling area in all programs for caryophyllene. This is still wrong in brouwhulp, we correct it during database import. Also mycrene was spelled myrcene, my fault. The hops grid now uses a popup editor, this is not yet complete. Friendly weight display in the hop grid and added the inventory comlumn.
Michiel Broek <mbroek@mbse.eu>
parents:
220
diff
changeset
|
878 | $hops .= ',"h_caryophyllene":' . floatval($hop->CAROPHYLLENE); |
106
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
879 | $hops .= ',"h_cohumulone":' . floatval($hop->COHUMULONE); |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
880 | $hops .= ',"h_myrcene":' . floatval($hop->MYRCENE); |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
881 | if ($hop->TOTAL_OIL) |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
882 | $hops .= ',"h_total_oil":' . floatval($hop->TOTAL_OIL); |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
883 | else |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
884 | $hops .= ',"h_total_oil":0'; |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
885 | if ($hop->ORIGIN) |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
886 | $hops .= ',"h_origin":"' . mysqli_real_escape_string($db, $hop->ORIGIN) . '"'; |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
887 | else |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
888 | $hops .= ',"h_origin":""'; |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
889 | $hops .= "}"; |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
890 | } |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
891 | $hops .= ']'; |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
892 | return $hops; |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
893 | } |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
894 | |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
895 | function recipe_miscs($recipe) |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
896 | { |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
897 | global $db; |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
898 | |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
899 | $miscs = "["; |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
900 | $comma = FALSE; |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
901 | foreach ($recipe->MISCS->MISC as $misc) { |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
902 | if ($comma) |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
903 | $miscs .= ','; |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
904 | $comma = TRUE; |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
905 | $mname = mysqli_real_escape_string($db, $misc->NAME); |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
906 | $miscs .= '{"m_name":"' . $mname . '"'; |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
907 | $miscs .= ',"m_amount":' . floatval($misc->AMOUNT); |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
908 | if ($misc->COST) { |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
909 | $miscs .= ',"m_cost":' . floatval($misc->COST); |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
910 | } else { |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
911 | /* Brouwhulp bug, added water agents have no cost field. */ |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
912 | if ($misc->TYPE == "Water agent") { |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
913 | $miscs .= ',"m_cost":'. get_miscs_cost($mname); |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
914 | } else { |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
915 | $miscs .= ',"m_cost":0'; |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
916 | } |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
917 | } |
220
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
918 | |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
919 | if ($misc->TYPE == 'Spice') |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
920 | $miscs .= ',"m_type":0'; |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
921 | else if ($misc->TYPE == 'Herb') |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
922 | $miscs .= ',"m_type":1'; |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
923 | else if ($misc->TYPE == 'Flavor') |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
924 | $miscs .= ',"m_type":2'; |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
925 | else if ($misc->TYPE == 'Fining') |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
926 | $miscs .= ',"m_type":3'; |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
927 | else if ($misc->TYPE == 'Water agent') |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
928 | $miscs .= ',"m_type":4'; |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
929 | else if ($misc->TYPE == 'Yeast nutrient') |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
930 | $miscs .= ',"m_type":5'; |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
931 | else if ($misc->TYPE == 'Other') |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
932 | $miscs .= ',"m_type":6'; |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
933 | else |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
934 | echo "Unknown TYPE " . $misc->TYPE . PHP_EOL; |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
935 | |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
936 | if ($misc->USE == 'Starter') |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
937 | $miscs .= ',"m_use_use":0'; |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
938 | else if ($misc->USE == 'Mash') |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
939 | $miscs .= ',"m_use_use":1'; |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
940 | else if ($misc->USE == 'Boil') |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
941 | $miscs .= ',"m_use_use":2'; |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
942 | else if ($misc->USE == 'Primary') |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
943 | $miscs .= ',"m_use_use":3'; |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
944 | else if ($misc->USE == 'Secondary') |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
945 | $miscs .= ',"m_use_use":4'; |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
946 | else if ($misc->USE == 'Bottling') |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
947 | $miscs .= ',"m_use_use":5'; |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
948 | else |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
949 | echo "Unknown USE " . $misc->USE . PHP_EOL; |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
950 | |
175
da16371538c3
When importing from brouwhulp use 0 and 1 instead of false and true for boolean variables. Added Export button to the recipe editor. Added beerxml recipe export.
Michiel Broek <mbroek@mbse.eu>
parents:
163
diff
changeset
|
951 | ($misc->AMOUNT_IS_WEIGHT== "TRUE") ? $miscs .= ',"m_amount_is_weight":1' : $miscs.= ',"m_amount_is_weight":0'; |
143
122f64716161
During recipes import of miscs ingredients, convert time in Secondary to days. The hop grid also display the country of origin. Misc ingredients now use a temporary weight table just like the hops.
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
952 | if ($misc->TIME) { |
220
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
953 | $miscs .= ',"m_time":' . floatval($misc->TIME); |
143
122f64716161
During recipes import of miscs ingredients, convert time in Secondary to days. The hop grid also display the country of origin. Misc ingredients now use a temporary weight table just like the hops.
Michiel Broek <mbroek@mbse.eu>
parents:
136
diff
changeset
|
954 | } else |
106
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
955 | $miscs .= ',"m_time":0'; |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
956 | $miscs .= "}"; |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
957 | } |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
958 | $miscs .= ']'; |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
959 | return $miscs; |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
960 | } |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
961 | |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
962 | function recipe_yeasts($recipe) |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
963 | { |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
964 | global $db; |
136
bcc4583fd013
Fixed estimate FG calculation during recipes import. Added estimate FG calculation in the recipe editor but do not yet update the recipe. Added SVG calculation to the recipes editor. Added calculations for hop aroma and flavour contribution.
Michiel Broek <mbroek@mbse.eu>
parents:
131
diff
changeset
|
965 | global $svg; |
106
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
966 | |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
967 | $yeasts = "["; |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
968 | $comma = FALSE; |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
969 | foreach ($recipe->YEASTS->YEAST as $yeast) { |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
970 | if ($comma) |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
971 | $yeasts .= ','; |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
972 | $comma = TRUE; |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
973 | $yeasts .= '{"y_name":"' . mysqli_real_escape_string($db, $yeast->NAME) . '"'; |
226
40e68b18b50d
The recipes yeast grid now uses a popup editor.
Michiel Broek <mbroek@mbse.eu>
parents:
223
diff
changeset
|
974 | if ($yeast->FORM == "Liquid") { |
40e68b18b50d
The recipes yeast grid now uses a popup editor.
Michiel Broek <mbroek@mbse.eu>
parents:
223
diff
changeset
|
975 | $paks = floatval($yeast->AMOUNT) / 0.0588; |
40e68b18b50d
The recipes yeast grid now uses a popup editor.
Michiel Broek <mbroek@mbse.eu>
parents:
223
diff
changeset
|
976 | $yeasts .= ',"y_amount":' . $paks; |
266
4cfbf25e3093
Fix yeast cost during import.
Michiel Broek <mbroek@mbse.eu>
parents:
253
diff
changeset
|
977 | $yeasts .= ',"y_cost":' . floatval($yeast->COST); |
226
40e68b18b50d
The recipes yeast grid now uses a popup editor.
Michiel Broek <mbroek@mbse.eu>
parents:
223
diff
changeset
|
978 | } else { |
40e68b18b50d
The recipes yeast grid now uses a popup editor.
Michiel Broek <mbroek@mbse.eu>
parents:
223
diff
changeset
|
979 | $yeasts .= ',"y_amount":' . floatval($yeast->AMOUNT); |
266
4cfbf25e3093
Fix yeast cost during import.
Michiel Broek <mbroek@mbse.eu>
parents:
253
diff
changeset
|
980 | $yeasts .= ',"y_cost":' . floatval($yeast->COST) * 1000; |
226
40e68b18b50d
The recipes yeast grid now uses a popup editor.
Michiel Broek <mbroek@mbse.eu>
parents:
223
diff
changeset
|
981 | } |
40e68b18b50d
The recipes yeast grid now uses a popup editor.
Michiel Broek <mbroek@mbse.eu>
parents:
223
diff
changeset
|
982 | |
106
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
983 | $yeasts .= ',"y_laboratory":"' . mysqli_real_escape_string($db, $yeast->LABORATORY) . '"'; |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
984 | $yeasts .= ',"y_product_id":"' . mysqli_real_escape_string($db, $yeast->PRODUCT_ID) . '"'; |
220
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
985 | |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
986 | if ($yeast->TYPE == 'Lager') |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
987 | $yeasts .= ',"y_type":0'; |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
988 | else if ($yeast->TYPE == 'Ale') |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
989 | $yeasts .= ',"y_type":1'; |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
990 | else if ($yeast->TYPE == 'Wheat') |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
991 | $yeasts .= ',"y_type":2'; |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
992 | else if ($yeast->TYPE == 'Wine') |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
993 | $yeasts .= ',"y_type":3'; |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
994 | else if ($yeast->TYPE == 'Champagne') |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
995 | $yeasts .= ',"y_type":4'; |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
996 | else |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
997 | echo "Unknown TYPE " . $yeast->TYPE . PHP_EOL; |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
998 | |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
999 | if ($yeast->FORM == 'Liquid') { |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
1000 | if ($yeast->LABORATORY == 'Imperial Yeast') |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
1001 | $yeasts .= ',"y_form":0,"y_cells":200000000000'; |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
1002 | else |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
1003 | $yeasts .= ',"y_form":0,"y_cells":100000000000'; |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
1004 | } else if ($yeast->FORM == 'Dry') |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
1005 | $yeasts .= ',"y_form":1,"y_cells":15000000000'; |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
1006 | else if ($yeast->FORM == 'Slant') |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
1007 | $yeasts .= ',"y_form":2,"y_cells":1700000000'; |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
1008 | else if ($yeast->FORM == 'Culture') |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
1009 | $yeasts .= ',"y_form":3,"y_cells":1700000000'; |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
1010 | else if ($yeast->FORM == 'Frozen') |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
1011 | $yeasts .= ',"y_form":4,"y_cells":1700000000'; |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
1012 | else if ($yeast->FORM == 'Bottle') |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
1013 | $yeasts .= ',"y_form":5,"y_cells":1700000000'; |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
1014 | else |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
1015 | echo "Unknown FORM " . $yeast->FORM . PHP_EOL; |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
1016 | |
226
40e68b18b50d
The recipes yeast grid now uses a popup editor.
Michiel Broek <mbroek@mbse.eu>
parents:
223
diff
changeset
|
1017 | if ($yeast->FLOCCULATION == 'Low') |
40e68b18b50d
The recipes yeast grid now uses a popup editor.
Michiel Broek <mbroek@mbse.eu>
parents:
223
diff
changeset
|
1018 | $yeasts .= ',"y_flocculation":0'; |
40e68b18b50d
The recipes yeast grid now uses a popup editor.
Michiel Broek <mbroek@mbse.eu>
parents:
223
diff
changeset
|
1019 | else if ($yeast->FLOCCULATION == 'Medium') |
40e68b18b50d
The recipes yeast grid now uses a popup editor.
Michiel Broek <mbroek@mbse.eu>
parents:
223
diff
changeset
|
1020 | $yeasts .= ',"y_flocculation":1'; |
40e68b18b50d
The recipes yeast grid now uses a popup editor.
Michiel Broek <mbroek@mbse.eu>
parents:
223
diff
changeset
|
1021 | else if ($yeast->FLOCCULATION == 'High') |
40e68b18b50d
The recipes yeast grid now uses a popup editor.
Michiel Broek <mbroek@mbse.eu>
parents:
223
diff
changeset
|
1022 | $yeasts .= ',"y_flocculation":2'; |
40e68b18b50d
The recipes yeast grid now uses a popup editor.
Michiel Broek <mbroek@mbse.eu>
parents:
223
diff
changeset
|
1023 | else if ($yeast->FLOCCULATION == 'Very high') |
40e68b18b50d
The recipes yeast grid now uses a popup editor.
Michiel Broek <mbroek@mbse.eu>
parents:
223
diff
changeset
|
1024 | $yeasts .= ',"y_flocculation":3'; |
40e68b18b50d
The recipes yeast grid now uses a popup editor.
Michiel Broek <mbroek@mbse.eu>
parents:
223
diff
changeset
|
1025 | else |
40e68b18b50d
The recipes yeast grid now uses a popup editor.
Michiel Broek <mbroek@mbse.eu>
parents:
223
diff
changeset
|
1026 | echo "Unknown FLOCCULATION " . $yeast->FLOCCULATION . PHP_EOL; |
40e68b18b50d
The recipes yeast grid now uses a popup editor.
Michiel Broek <mbroek@mbse.eu>
parents:
223
diff
changeset
|
1027 | |
278
dc22dd5d77fd
Initial design of a yeast starter calculator based on the Braukaiser model. Changed the yeast inventory prompts to the correct Dutch amounts. The pitchrate calculator makes a difference between light and heavy beers, turning point is a SG 1.060. Some code is from Homebrew Dad's calculator.
Michiel Broek <mbroek@mbse.eu>
parents:
266
diff
changeset
|
1028 | if ($yeast->PRODUCT_ID=="F2" || $yeast->PRODUCT_ID=="CBC-1") { |
dc22dd5d77fd
Initial design of a yeast starter calculator based on the Braukaiser model. Changed the yeast inventory prompts to the correct Dutch amounts. The pitchrate calculator makes a difference between light and heavy beers, turning point is a SG 1.060. Some code is from Homebrew Dad's calculator.
Michiel Broek <mbroek@mbse.eu>
parents:
266
diff
changeset
|
1029 | $yeasts .= ',"y_use":3'; // Bottle |
dc22dd5d77fd
Initial design of a yeast starter calculator based on the Braukaiser model. Changed the yeast inventory prompts to the correct Dutch amounts. The pitchrate calculator makes a difference between light and heavy beers, turning point is a SG 1.060. Some code is from Homebrew Dad's calculator.
Michiel Broek <mbroek@mbse.eu>
parents:
266
diff
changeset
|
1030 | } else if ($yeast->ADD_TO_SECONDARY=="TRUE") { |
dc22dd5d77fd
Initial design of a yeast starter calculator based on the Braukaiser model. Changed the yeast inventory prompts to the correct Dutch amounts. The pitchrate calculator makes a difference between light and heavy beers, turning point is a SG 1.060. Some code is from Homebrew Dad's calculator.
Michiel Broek <mbroek@mbse.eu>
parents:
266
diff
changeset
|
1031 | $yeasts .= ',"y_use":1'; // Secondary |
106
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1032 | $svg = floatval($yeast->ATTENUATION); |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1033 | } else { |
278
dc22dd5d77fd
Initial design of a yeast starter calculator based on the Braukaiser model. Changed the yeast inventory prompts to the correct Dutch amounts. The pitchrate calculator makes a difference between light and heavy beers, turning point is a SG 1.060. Some code is from Homebrew Dad's calculator.
Michiel Broek <mbroek@mbse.eu>
parents:
266
diff
changeset
|
1034 | $yeasts .= ',"y_use":0'; // Primary |
106
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1035 | } |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1036 | $yeasts .= ',"y_min_temperature":' . floatval($yeast->MIN_TEMPERATURE); |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1037 | $yeasts .= ',"y_max_temperature":' . floatval($yeast->MAX_TEMPERATURE); |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1038 | $yeasts .= ',"y_attenuation":' . floatval($yeast->ATTENUATION); |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1039 | $yeasts .= "}"; |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1040 | } |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1041 | $yeasts .= ']'; |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1042 | return $yeasts; |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1043 | } |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1044 | |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1045 | function recipe_waters($recipe, $db) |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1046 | { |
148
c0f0bbfefd63
Source waters are fixed, removed grid editor. Redesigned the water screen. Made a simple visual if water treatments are out of range. Water mixer for standard and dillute water works. Swapped the mash and water tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
147
diff
changeset
|
1047 | $waters = ""; |
c0f0bbfefd63
Source waters are fixed, removed grid editor. Redesigned the water screen. Made a simple visual if water treatments are out of range. Water mixer for standard and dillute water works. Swapped the mash and water tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
147
diff
changeset
|
1048 | $index = 0; |
106
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1049 | foreach ($recipe->WATERS->WATER as $water) { |
148
c0f0bbfefd63
Source waters are fixed, removed grid editor. Redesigned the water screen. Made a simple visual if water treatments are out of range. Water mixer for standard and dillute water works. Swapped the mash and water tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
147
diff
changeset
|
1050 | $index++; |
c0f0bbfefd63
Source waters are fixed, removed grid editor. Redesigned the water screen. Made a simple visual if water treatments are out of range. Water mixer for standard and dillute water works. Swapped the mash and water tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
147
diff
changeset
|
1051 | $waters .= "', w" . $index . "_name='" . mysqli_real_escape_string($db, $water->NAME); |
c0f0bbfefd63
Source waters are fixed, removed grid editor. Redesigned the water screen. Made a simple visual if water treatments are out of range. Water mixer for standard and dillute water works. Swapped the mash and water tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
147
diff
changeset
|
1052 | $waters .= "', w" . $index . "_amount='" . floatval($water->AMOUNT); |
106
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1053 | if ($water->CALCIUM) |
148
c0f0bbfefd63
Source waters are fixed, removed grid editor. Redesigned the water screen. Made a simple visual if water treatments are out of range. Water mixer for standard and dillute water works. Swapped the mash and water tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
147
diff
changeset
|
1054 | $waters .= "', w" . $index . "_calcium='" . floatval($water->CALCIUM); |
106
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1055 | if ($water->SULFATE) |
148
c0f0bbfefd63
Source waters are fixed, removed grid editor. Redesigned the water screen. Made a simple visual if water treatments are out of range. Water mixer for standard and dillute water works. Swapped the mash and water tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
147
diff
changeset
|
1056 | $waters .= "', w" . $index . "_sulfate='" . floatval($water->SULFATE); |
106
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1057 | if ($water->CHLORIDE) |
148
c0f0bbfefd63
Source waters are fixed, removed grid editor. Redesigned the water screen. Made a simple visual if water treatments are out of range. Water mixer for standard and dillute water works. Swapped the mash and water tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
147
diff
changeset
|
1058 | $waters .= "', w" . $index . "_chloride='" . floatval($water->CHLORIDE); |
106
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1059 | if ($water->SODIUM) |
148
c0f0bbfefd63
Source waters are fixed, removed grid editor. Redesigned the water screen. Made a simple visual if water treatments are out of range. Water mixer for standard and dillute water works. Swapped the mash and water tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
147
diff
changeset
|
1060 | $waters .= "', w" . $index . "_sodium='" . floatval($water->SODIUM); |
106
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1061 | if ($water->MAGNESIUM) |
148
c0f0bbfefd63
Source waters are fixed, removed grid editor. Redesigned the water screen. Made a simple visual if water treatments are out of range. Water mixer for standard and dillute water works. Swapped the mash and water tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
147
diff
changeset
|
1062 | $waters .= "', w" . $index . "_magnesium='" . floatval($water->MAGNESIUM); |
106
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1063 | if ($water->PH) |
148
c0f0bbfefd63
Source waters are fixed, removed grid editor. Redesigned the water screen. Made a simple visual if water treatments are out of range. Water mixer for standard and dillute water works. Swapped the mash and water tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
147
diff
changeset
|
1064 | $waters .= "', w" . $index . "_ph='" . floatval($water->PH); |
106
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1065 | if ($water->TOTAL_ALKALINITY) |
148
c0f0bbfefd63
Source waters are fixed, removed grid editor. Redesigned the water screen. Made a simple visual if water treatments are out of range. Water mixer for standard and dillute water works. Swapped the mash and water tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
147
diff
changeset
|
1066 | $waters .= "', w" . $index . "_total_alkalinity='" . floatval($water->TOTAL_ALKALINITY); |
106
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1067 | if ($water->COST) |
148
c0f0bbfefd63
Source waters are fixed, removed grid editor. Redesigned the water screen. Made a simple visual if water treatments are out of range. Water mixer for standard and dillute water works. Swapped the mash and water tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
147
diff
changeset
|
1068 | $waters .= "', w" . $index . "_cost='" . floatval($water->COST); |
106
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1069 | else |
148
c0f0bbfefd63
Source waters are fixed, removed grid editor. Redesigned the water screen. Made a simple visual if water treatments are out of range. Water mixer for standard and dillute water works. Swapped the mash and water tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
147
diff
changeset
|
1070 | $waters .= "', w" . $index . "_cost='0"; |
106
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1071 | } |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1072 | return $waters; |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1073 | } |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1074 | |
220
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
1075 | |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
1076 | |
106
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1077 | function recipe_mash_steps($recipe) |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1078 | { |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1079 | global $db; |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1080 | |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1081 | $steps = '['; |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1082 | $comma = FALSE; |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1083 | foreach ($recipe->MASH->MASH_STEPS->MASH_STEP as $step) { |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1084 | if ($comma) |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1085 | $steps .= ','; |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1086 | $comma = TRUE; |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1087 | $steps .= '{"step_name":"' . mysqli_real_escape_string($db, $step->NAME) . '"'; |
220
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
1088 | |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
1089 | if ($step->TYPE == 'Infusion') |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
1090 | $steps .= ',"step_type":0'; |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
1091 | else if ($step->TYPE == 'Temperature') |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
1092 | $steps .= ',"step_type":1'; |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
1093 | else if ($step->TYPE == 'Decoction') |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
1094 | $steps .= ',"step_type":2'; |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
1095 | else |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
1096 | echo "Unknown step TYPE " . $step->TYPE . PHP_EOL; |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
1097 | |
106
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1098 | if ($step->INFUSE_AMOUNT) |
228
98536f6539ee
The mash grid now uses a popup editor. There is now a dropdown mash selector to replace the mash scheme.
Michiel Broek <mbroek@mbse.eu>
parents:
226
diff
changeset
|
1099 | $steps .= ',"step_infuse_amount":' . floatval($step->INFUSE_AMOUNT); |
98536f6539ee
The mash grid now uses a popup editor. There is now a dropdown mash selector to replace the mash scheme.
Michiel Broek <mbroek@mbse.eu>
parents:
226
diff
changeset
|
1100 | else |
98536f6539ee
The mash grid now uses a popup editor. There is now a dropdown mash selector to replace the mash scheme.
Michiel Broek <mbroek@mbse.eu>
parents:
226
diff
changeset
|
1101 | $steps .= ',"step_infuse_amount":0'; |
106
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1102 | if ($step->STEP_TEMP) |
228
98536f6539ee
The mash grid now uses a popup editor. There is now a dropdown mash selector to replace the mash scheme.
Michiel Broek <mbroek@mbse.eu>
parents:
226
diff
changeset
|
1103 | $steps .= ',"step_temp":' . floatval($step->STEP_TEMP); |
106
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1104 | if ($step->STEP_TIME) |
228
98536f6539ee
The mash grid now uses a popup editor. There is now a dropdown mash selector to replace the mash scheme.
Michiel Broek <mbroek@mbse.eu>
parents:
226
diff
changeset
|
1105 | $steps .= ',"step_time":' . floatval($step->STEP_TIME); |
106
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1106 | if ($step->RAMP_TIME) |
228
98536f6539ee
The mash grid now uses a popup editor. There is now a dropdown mash selector to replace the mash scheme.
Michiel Broek <mbroek@mbse.eu>
parents:
226
diff
changeset
|
1107 | $steps .= ',"ramp_time":' . floatval($step->RAMP_TIME); |
106
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1108 | if ($step->END_TEMP) |
228
98536f6539ee
The mash grid now uses a popup editor. There is now a dropdown mash selector to replace the mash scheme.
Michiel Broek <mbroek@mbse.eu>
parents:
226
diff
changeset
|
1109 | $steps .= ',"end_temp":' . floatval($step->END_TEMP); |
106
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1110 | $steps .= "}"; |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1111 | } |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1112 | $steps .= ']'; |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1113 | return $steps; |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1114 | } |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1115 | |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1116 | |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1117 | |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1118 | function do_recipes() |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1119 | { |
136
bcc4583fd013
Fixed estimate FG calculation during recipes import. Added estimate FG calculation in the recipe editor but do not yet update the recipe. Added SVG calculation to the recipes editor. Added calculations for hop aroma and flavour contribution.
Michiel Broek <mbroek@mbse.eu>
parents:
131
diff
changeset
|
1120 | global $brouwhulp, $db, $efficiency, $batch_size, $pCara, $pSugar, $svg, $colorw, $f_sugars; |
48
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
1121 | $len_fermentables = 0; |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
1122 | $len_hops = 0; |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
1123 | $len_miscs = 0; |
49
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
1124 | $len_yeasts = 0; |
48
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
1125 | $len_mash = 0; |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
1126 | |
106
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1127 | echo " Start adding recipes to the database\n"; |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1128 | $sql = "TRUNCATE TABLE recipes;"; |
48
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
1129 | if (! $result = mysqli_query($db, $sql)) { |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
1130 | printf("Error: %s\n", mysqli_error($db)); |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
1131 | } |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
1132 | |
106
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1133 | $recipes = simplexml_load_file($brouwhulp . '/recipes.xml'); |
48
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
1134 | |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
1135 | foreach ($recipes->RECIPE as $recipe) { |
86
e977a505ea8c
With recipe import calculate the OG
Michiel Broek <mbroek@mbse.eu>
parents:
77
diff
changeset
|
1136 | $f_sugars = 0; |
e977a505ea8c
With recipe import calculate the OG
Michiel Broek <mbroek@mbse.eu>
parents:
77
diff
changeset
|
1137 | $efficiency = 75; |
e977a505ea8c
With recipe import calculate the OG
Michiel Broek <mbroek@mbse.eu>
parents:
77
diff
changeset
|
1138 | $batch_size = 20; |
94
295c3af2a421
Include boil_size field in the recipes table. Calculate pre-boil SG. Use that in the IBU calculation.
Michiel Broek <mbroek@mbse.eu>
parents:
89
diff
changeset
|
1139 | $boil_size = 22; |
87
7f1d0abe5571
OG and FG are now calculated from the grist. The printed report has a summary an notes section at the end. The formulas are in the global formulas script.
Michiel Broek <mbroek@mbse.eu>
parents:
86
diff
changeset
|
1140 | $pCara = 0; |
7f1d0abe5571
OG and FG are now calculated from the grist. The printed report has a summary an notes section at the end. The formulas are in the global formulas script.
Michiel Broek <mbroek@mbse.eu>
parents:
86
diff
changeset
|
1141 | $pSugar = 0; |
7f1d0abe5571
OG and FG are now calculated from the grist. The printed report has a summary an notes section at the end. The formulas are in the global formulas script.
Michiel Broek <mbroek@mbse.eu>
parents:
86
diff
changeset
|
1142 | $svg = 77; |
89
082c23b26055
Missing Water agent costs from Brouwhulp import are now added from the imported miscs database. The printed recipe report now calculates the beer color from the ingredients. Also set during recipes import. This will later allow to set the color method for each recipe individually.
Michiel Broek <mbroek@mbse.eu>
parents:
88
diff
changeset
|
1143 | $colorw = 0; |
105
d06ddc4d1af0
Added uuid and locked fields to the recipes table.
Michiel Broek <mbroek@mbse.eu>
parents:
104
diff
changeset
|
1144 | $uuid = str_replace("\n", "", file_get_contents('/proc/sys/kernel/random/uuid')); |
86
e977a505ea8c
With recipe import calculate the OG
Michiel Broek <mbroek@mbse.eu>
parents:
77
diff
changeset
|
1145 | |
106
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1146 | $sql = "INSERT INTO recipes SET uuid='" . $uuid; |
105
d06ddc4d1af0
Added uuid and locked fields to the recipes table.
Michiel Broek <mbroek@mbse.eu>
parents:
104
diff
changeset
|
1147 | $sql .= "', name='" . mysqli_real_escape_string($db, $recipe->NAME); |
d06ddc4d1af0
Added uuid and locked fields to the recipes table.
Michiel Broek <mbroek@mbse.eu>
parents:
104
diff
changeset
|
1148 | $sql .= "', locked='0"; |
48
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
1149 | if ($recipe->NOTES) |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
1150 | $sql .= "', notes='" . mysqli_real_escape_string($db, $recipe->NOTES); |
64
5d5fc6f7cbfe
Improved recipes import. Finished inventory_suppliers.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
1151 | else |
5d5fc6f7cbfe
Improved recipes import. Finished inventory_suppliers.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
1152 | $sql .= "', notes='"; |
220
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
1153 | |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
1154 | if ($recipe->TYPE == 'Extract') |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
1155 | $sql .= "', type='0"; |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
1156 | else if ($recipe->TYPE == 'Partial Mash') |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
1157 | $sql .= "', type='1"; |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
1158 | else if ($recipe->TYPE == 'All Grain') |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
1159 | $sql .= "', type='2"; |
64
5d5fc6f7cbfe
Improved recipes import. Finished inventory_suppliers.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
1160 | else |
220
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
1161 | echo "Unknown TYPE " . $recipe->TYPE . PHP_EOL; |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
1162 | |
48
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
1163 | if ($recipe->BATCH_SIZE) |
86
e977a505ea8c
With recipe import calculate the OG
Michiel Broek <mbroek@mbse.eu>
parents:
77
diff
changeset
|
1164 | $batch_size = floatval($recipe->BATCH_SIZE); |
e977a505ea8c
With recipe import calculate the OG
Michiel Broek <mbroek@mbse.eu>
parents:
77
diff
changeset
|
1165 | $sql .= "', batch_size='" . $batch_size; |
94
295c3af2a421
Include boil_size field in the recipes table. Calculate pre-boil SG. Use that in the IBU calculation.
Michiel Broek <mbroek@mbse.eu>
parents:
89
diff
changeset
|
1166 | if ($recipe->BOIL_SIZE) |
295c3af2a421
Include boil_size field in the recipes table. Calculate pre-boil SG. Use that in the IBU calculation.
Michiel Broek <mbroek@mbse.eu>
parents:
89
diff
changeset
|
1167 | $boil_size = floatval($recipe->BOIL_SIZE); |
295c3af2a421
Include boil_size field in the recipes table. Calculate pre-boil SG. Use that in the IBU calculation.
Michiel Broek <mbroek@mbse.eu>
parents:
89
diff
changeset
|
1168 | $sql .= "', boil_size='" . $boil_size; |
48
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
1169 | if ($recipe->BOIL_TIME) |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
1170 | $sql .= "', boil_time='" . floatval($recipe->BOIL_TIME); |
64
5d5fc6f7cbfe
Improved recipes import. Finished inventory_suppliers.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
1171 | else |
5d5fc6f7cbfe
Improved recipes import. Finished inventory_suppliers.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
1172 | $sql .= "', boil_time='90"; |
48
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
1173 | if ($recipe->EFFICIENCY) |
86
e977a505ea8c
With recipe import calculate the OG
Michiel Broek <mbroek@mbse.eu>
parents:
77
diff
changeset
|
1174 | $efficiency = floatval($recipe->EFFICIENCY); |
e977a505ea8c
With recipe import calculate the OG
Michiel Broek <mbroek@mbse.eu>
parents:
77
diff
changeset
|
1175 | $sql .= "', efficiency='" . $efficiency; |
e977a505ea8c
With recipe import calculate the OG
Michiel Broek <mbroek@mbse.eu>
parents:
77
diff
changeset
|
1176 | /* Don't use $recipe->EST_OG but recalculate it */ |
87
7f1d0abe5571
OG and FG are now calculated from the grist. The printed report has a summary an notes section at the end. The formulas are in the global formulas script.
Michiel Broek <mbroek@mbse.eu>
parents:
86
diff
changeset
|
1177 | /* Don't use $recipe->EST_FG but recalculate it */ |
89
082c23b26055
Missing Water agent costs from Brouwhulp import are now added from the imported miscs database. The printed recipe report now calculates the beer color from the ingredients. Also set during recipes import. This will later allow to set the color method for each recipe individually.
Michiel Broek <mbroek@mbse.eu>
parents:
88
diff
changeset
|
1178 | /* Don't use $recipe->EST_COLOR but recalculate it */ |
234
b8b5efa495bb
Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
1179 | $color_method = 0; |
b8b5efa495bb
Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
1180 | if ($recipe->COLOR_METHOD == 'Morey') { |
b8b5efa495bb
Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
1181 | $color_method = 0; |
220
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
1182 | $sql .= "', color_method='0"; |
234
b8b5efa495bb
Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
1183 | } else if ($recipe->COLOR_METHOD == 'Mosher') { |
b8b5efa495bb
Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
1184 | $color_method = 1; |
220
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
1185 | $sql .= "', color_method='1"; |
234
b8b5efa495bb
Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
1186 | } else if ($recipe->COLOR_METHOD == 'Daniels') { |
b8b5efa495bb
Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
1187 | $color_method = 2; |
220
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
1188 | $sql .= "', color_method='2"; |
234
b8b5efa495bb
Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
1189 | } else |
220
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
1190 | echo "Unknown COLOR_METHO " . $recipe->COLOR_METHOD . PHP_EOL; |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
1191 | |
48
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
1192 | if ($recipe->IBU) |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
1193 | $sql .= "', est_ibu='" . floatval($recipe->IBU); |
220
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
1194 | if ($recipe->IBU_METHOD == 'Tinseth') |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
1195 | $sql .= "', ibu_method='0"; |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
1196 | else if ($recipe->IBU_METHOD == 'Rager') |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
1197 | $sql .= "', ibu_method='1"; |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
1198 | else if ($recipe->IBU_METHOD == 'Daniels') |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
1199 | $sql .= "', ibu_method='2"; |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
1200 | else |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
1201 | echo "Unknown IBU_METHOD " . $recipe->IBU_METHOD . PHP_EOL; |
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
1202 | |
102
679ddf512b65
Added est_carb field import in the recipes.
Michiel Broek <mbroek@mbse.eu>
parents:
100
diff
changeset
|
1203 | if ($recipe->CARBONATION) |
679ddf512b65
Added est_carb field import in the recipes.
Michiel Broek <mbroek@mbse.eu>
parents:
100
diff
changeset
|
1204 | $sql .= "', est_carb='" . floatval($recipe->CARBONATION); |
48
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
1205 | |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
1206 | if ($recipe->STYLE) { |
106
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1207 | $sql .= recipe_style($recipe); |
48
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
1208 | } |
147
e6e5d007eb54
Added several sparge_ fields in the recipes databases. Added basic water mix calculator. Added fields on the water tab for water calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
143
diff
changeset
|
1209 | if ($recipe->CALC_ACID) { |
e6e5d007eb54
Added several sparge_ fields in the recipes databases. Added basic water mix calculator. Added fields on the water tab for water calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
143
diff
changeset
|
1210 | ($recipe->CALC_ACID == "TRUE") ? $sql .= "', calc_acid='1" : $sql .= "', calc_acid='0"; |
e6e5d007eb54
Added several sparge_ fields in the recipes databases. Added basic water mix calculator. Added fields on the water tab for water calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
143
diff
changeset
|
1211 | } |
e6e5d007eb54
Added several sparge_ fields in the recipes databases. Added basic water mix calculator. Added fields on the water tab for water calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
143
diff
changeset
|
1212 | if ($recipe->TARGET_PH) { |
e6e5d007eb54
Added several sparge_ fields in the recipes databases. Added basic water mix calculator. Added fields on the water tab for water calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
143
diff
changeset
|
1213 | $sql .= "', mash_ph='" . floatval($recipe->TARGET_PH); |
e6e5d007eb54
Added several sparge_ fields in the recipes databases. Added basic water mix calculator. Added fields on the water tab for water calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
143
diff
changeset
|
1214 | } |
149
ff45488d480e
Added some icons from Brewersfriend. They should be replaced someday. Added maximum mash weight setting to the equipment database. Usefull for brew automate and RIMS systems. During recipes import acid and base additions are translated. Brews and recipes now have 2 water sources. Added water mixer. Added basic water treatment, but not for pH yet. Redesigned the fermentables and water tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
148
diff
changeset
|
1215 | if ($recipe->SPARGE_ACID_TYPE && ($recipe->SPARGE_ACID_TYPE == "Lactic")) { |
220
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
1216 | $sql .= "', sparge_acid_type='0"; |
149
ff45488d480e
Added some icons from Brewersfriend. They should be replaced someday. Added maximum mash weight setting to the equipment database. Usefull for brew automate and RIMS systems. During recipes import acid and base additions are translated. Brews and recipes now have 2 water sources. Added water mixer. Added basic water treatment, but not for pH yet. Redesigned the fermentables and water tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
148
diff
changeset
|
1217 | } else if ($recipe->SPARGE_ACID_TYPE && ($recipe->SPARGE_ACID_TYPE == "Hydrochloric")) { |
220
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
1218 | $sql .= "', sparge_acid_type='1"; |
149
ff45488d480e
Added some icons from Brewersfriend. They should be replaced someday. Added maximum mash weight setting to the equipment database. Usefull for brew automate and RIMS systems. During recipes import acid and base additions are translated. Brews and recipes now have 2 water sources. Added water mixer. Added basic water treatment, but not for pH yet. Redesigned the fermentables and water tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
148
diff
changeset
|
1219 | } else if ($recipe->SPARGE_ACID_TYPE && ($recipe->SPARGE_ACID_TYPE == "Phosphoric")) { |
220
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
1220 | $sql .= "', sparge_acid_type='2"; |
149
ff45488d480e
Added some icons from Brewersfriend. They should be replaced someday. Added maximum mash weight setting to the equipment database. Usefull for brew automate and RIMS systems. During recipes import acid and base additions are translated. Brews and recipes now have 2 water sources. Added water mixer. Added basic water treatment, but not for pH yet. Redesigned the fermentables and water tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
148
diff
changeset
|
1221 | } else if ($recipe->SPARGE_ACID_TYPE && ($recipe->SPARGE_ACID_TYPE == "Sulfuric")) { |
220
14e349ff2a10
Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents:
217
diff
changeset
|
1222 | $sql .= "', sparge_acid_type='3"; |
147
e6e5d007eb54
Added several sparge_ fields in the recipes databases. Added basic water mix calculator. Added fields on the water tab for water calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
143
diff
changeset
|
1223 | } |
e6e5d007eb54
Added several sparge_ fields in the recipes databases. Added basic water mix calculator. Added fields on the water tab for water calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
143
diff
changeset
|
1224 | if ($recipe->ACID_SPARGE_PERC) { |
e6e5d007eb54
Added several sparge_ fields in the recipes databases. Added basic water mix calculator. Added fields on the water tab for water calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
143
diff
changeset
|
1225 | $sql .= "', sparge_acid_perc='" . floatval($recipe->ACID_SPARGE_PERC); |
e6e5d007eb54
Added several sparge_ fields in the recipes databases. Added basic water mix calculator. Added fields on the water tab for water calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
143
diff
changeset
|
1226 | } |
e6e5d007eb54
Added several sparge_ fields in the recipes databases. Added basic water mix calculator. Added fields on the water tab for water calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
143
diff
changeset
|
1227 | if ($recipe->LACTIC_SPARGE) { |
e6e5d007eb54
Added several sparge_ fields in the recipes databases. Added basic water mix calculator. Added fields on the water tab for water calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
143
diff
changeset
|
1228 | $sql .= "', sparge_acid_amount='" . floatval($recipe->LACTIC_SPARGE); |
e6e5d007eb54
Added several sparge_ fields in the recipes databases. Added basic water mix calculator. Added fields on the water tab for water calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
143
diff
changeset
|
1229 | } |
e6e5d007eb54
Added several sparge_ fields in the recipes databases. Added basic water mix calculator. Added fields on the water tab for water calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
143
diff
changeset
|
1230 | if ($recipe->VOLUME_HLT) { |
e6e5d007eb54
Added several sparge_ fields in the recipes databases. Added basic water mix calculator. Added fields on the water tab for water calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
143
diff
changeset
|
1231 | $sql .= "', sparge_volume='" . floatval($recipe->VOLUME_HLT); |
e6e5d007eb54
Added several sparge_ fields in the recipes databases. Added basic water mix calculator. Added fields on the water tab for water calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
143
diff
changeset
|
1232 | } |
230
8edca0488e65
Finished the water treatment in the recipes editor. It seems that the recipes editor is ready.
Michiel Broek <mbroek@mbse.eu>
parents:
228
diff
changeset
|
1233 | $sql .= "', sparge_source='0"; |
48
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
1234 | |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
1235 | /* |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
1236 | * Put the fermentables in a json array |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
1237 | */ |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
1238 | if ($recipe->FERMENTABLES) { |
106
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1239 | $fermentables = recipe_fermentables($recipe); |
48
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
1240 | $sql .= "', json_fermentables='" . $fermentables; |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
1241 | if (strlen($fermentables) > $len_fermentables) |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
1242 | $len_fermentables = strlen($fermentables); |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
1243 | } |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
1244 | |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
1245 | /* |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
1246 | * Put the hops in a json array |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
1247 | */ |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
1248 | if ($recipe->HOPS) { |
106
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1249 | $hops = recipe_hops($recipe); |
48
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
1250 | $sql .= "', json_hops='" . $hops; |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
1251 | if (strlen($hops) > $len_hops) |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
1252 | $len_hops = strlen($hops); |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
1253 | } |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
1254 | |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
1255 | /* |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
1256 | * Put the miscs in a json array |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
1257 | */ |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
1258 | if ($recipe->MISCS) { |
106
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1259 | $miscs = recipe_miscs($recipe); |
48
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
1260 | $sql .= "', json_miscs='" . $miscs; |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
1261 | if (strlen($miscs) > $len_miscs) |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
1262 | $len_miscs = strlen($miscs); |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
1263 | } |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
1264 | |
49
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
1265 | /* |
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
1266 | * Put the yeasts in a json array |
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
1267 | */ |
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
1268 | if ($recipe->YEASTS) { |
106
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1269 | $yeasts = recipe_yeasts($recipe); |
49
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
1270 | $sql .= "', json_yeasts='" . $yeasts; |
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
1271 | if (strlen($yeasts) > $len_yeasts) |
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
1272 | $len_yeasts = strlen($yeasts); |
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
1273 | } |
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
1274 | |
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
1275 | /* |
148
c0f0bbfefd63
Source waters are fixed, removed grid editor. Redesigned the water screen. Made a simple visual if water treatments are out of range. Water mixer for standard and dillute water works. Swapped the mash and water tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
147
diff
changeset
|
1276 | * Get the waters |
49
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
1277 | */ |
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
1278 | if ($recipe->WATERS) { |
148
c0f0bbfefd63
Source waters are fixed, removed grid editor. Redesigned the water screen. Made a simple visual if water treatments are out of range. Water mixer for standard and dillute water works. Swapped the mash and water tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
147
diff
changeset
|
1279 | $sql .= recipe_waters($recipe, $db); |
49
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
1280 | } |
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
1281 | |
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
1282 | /* |
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
1283 | * Put the mash in a json array |
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
1284 | */ |
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
1285 | if ($recipe->MASH) { |
147
e6e5d007eb54
Added several sparge_ fields in the recipes databases. Added basic water mix calculator. Added fields on the water tab for water calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
143
diff
changeset
|
1286 | $sql .= "',sparge_temp='" . floatval($recipe->MASH->SPARGE_TEMP); |
e6e5d007eb54
Added several sparge_ fields in the recipes databases. Added basic water mix calculator. Added fields on the water tab for water calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
143
diff
changeset
|
1287 | $sql .= "',sparge_ph='" . floatval($recipe->MASH->PH); |
49
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
1288 | if ($recipe->MASH->NAME) |
51 | 1289 | $sql .= "',mash_name='" . mysqli_real_escape_string($db, $recipe->MASH->NAME); |
1290 | ||
49
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
1291 | if ($recipe->MASH->MASH_STEPS) { |
106
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1292 | $steps = recipe_mash_steps($recipe); |
51 | 1293 | $sql .= "', json_mashs='" . $steps; |
1294 | if (strlen($steps) > $len_mash) | |
1295 | $len_mash = strlen($steps); | |
49
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
1296 | } |
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
1297 | } |
4d27a7fb1265
Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
1298 | |
86
e977a505ea8c
With recipe import calculate the OG
Michiel Broek <mbroek@mbse.eu>
parents:
77
diff
changeset
|
1299 | /* |
e977a505ea8c
With recipe import calculate the OG
Michiel Broek <mbroek@mbse.eu>
parents:
77
diff
changeset
|
1300 | * Added the calculated values |
e977a505ea8c
With recipe import calculate the OG
Michiel Broek <mbroek@mbse.eu>
parents:
77
diff
changeset
|
1301 | * OG, FG, color, IBU |
e977a505ea8c
With recipe import calculate the OG
Michiel Broek <mbroek@mbse.eu>
parents:
77
diff
changeset
|
1302 | */ |
96
107c12c3e49d
Renamed estimate_og() to estimate_sg() formula. Updated the formulas in javascript. The calcFermenter() function now only calculates the gravities. The colors still need to be added. When a recept is loaded in the editor, all tabs are selected once to load all subgrid data. Ugly and slow but it at least it works.
Michiel Broek <mbroek@mbse.eu>
parents:
94
diff
changeset
|
1303 | $og = estimate_sg($f_sugars, $batch_size); |
87
7f1d0abe5571
OG and FG are now calculated from the grist. The printed report has a summary an notes section at the end. The formulas are in the global formulas script.
Michiel Broek <mbroek@mbse.eu>
parents:
86
diff
changeset
|
1304 | $sql .= "', est_og='" . floatval($og); |
7f1d0abe5571
OG and FG are now calculated from the grist. The printed report has a summary an notes section at the end. The formulas are in the global formulas script.
Michiel Broek <mbroek@mbse.eu>
parents:
86
diff
changeset
|
1305 | $fg = estimate_fg($pSugar, $pCara, 0, 0, 0, $svg, $og); |
7f1d0abe5571
OG and FG are now calculated from the grist. The printed report has a summary an notes section at the end. The formulas are in the global formulas script.
Michiel Broek <mbroek@mbse.eu>
parents:
86
diff
changeset
|
1306 | $sql .= "', est_fg='" . floatval($fg); |
88 | 1307 | $abv = abvol($og, $fg); |
1308 | $sql .= "', est_abv='" . floatval($abv); | |
234
b8b5efa495bb
Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
1309 | $color = kw_to_ebc($color_method, $colorw); |
89
082c23b26055
Missing Water agent costs from Brouwhulp import are now added from the imported miscs database. The printed recipe report now calculates the beer color from the ingredients. Also set during recipes import. This will later allow to set the color method for each recipe individually.
Michiel Broek <mbroek@mbse.eu>
parents:
88
diff
changeset
|
1310 | $sql .= "', est_color='" . floatval($color); |
48
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
1311 | $sql .= "';"; |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
1312 | if (! $result = mysqli_query($db, $sql)) { |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
1313 | printf("Error: %s\n", mysqli_error($db)); |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
1314 | } |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
1315 | } |
64
5d5fc6f7cbfe
Improved recipes import. Finished inventory_suppliers.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
1316 | // echo "Fermentables: " . $len_fermentables . PHP_EOL; |
5d5fc6f7cbfe
Improved recipes import. Finished inventory_suppliers.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
1317 | // echo "Hops: " . $len_hops . PHP_EOL; |
5d5fc6f7cbfe
Improved recipes import. Finished inventory_suppliers.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
1318 | // echo "Miscs: " . $len_miscs . PHP_EOL; |
5d5fc6f7cbfe
Improved recipes import. Finished inventory_suppliers.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
1319 | // echo "Yeasts: " . $len_yeasts . PHP_EOL; |
5d5fc6f7cbfe
Improved recipes import. Finished inventory_suppliers.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
1320 | // echo "Mash: " . $len_mash . PHP_EOL; |
48
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
1321 | } |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
1322 | |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
1323 | |
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
1324 | |
106
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1325 | function do_brews() |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1326 | { |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1327 | global $brouwhulp, $db, $efficiency, $batch_size, $pCara, $pSugar, $colorw, $f_sugars; |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1328 | $len_fermentables = 0; |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1329 | $len_hops = 0; |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1330 | $len_miscs = 0; |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1331 | $len_yeasts = 0; |
234
b8b5efa495bb
Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
1332 | $len_mash = 0; |
106
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1333 | |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1334 | echo " Start adding brews to the database\n"; |
151
2c9cfe2f0860
Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents:
150
diff
changeset
|
1335 | $sql = "TRUNCATE TABLE products;"; |
2c9cfe2f0860
Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents:
150
diff
changeset
|
1336 | if (! $presult = mysqli_query($db, $sql)) { |
106
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1337 | printf("Error: %s\n", mysqli_error($db)); |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1338 | } |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1339 | |
108 | 1340 | date_default_timezone_set('Europe/Amsterdam'); |
106
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1341 | $recipes = simplexml_load_file($brouwhulp . '/brews.xml'); |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1342 | |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1343 | foreach ($recipes->RECIPE as $recipe) { |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1344 | $f_sugars = 0; |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1345 | $efficiency = 75; |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1346 | $batch_size = 20; |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1347 | $boil_size = 22; |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1348 | $pCara = 0; |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1349 | $pSugar = 0; |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1350 | $svg = 77; |
108 | 1351 | $colorw = 0; |
234
b8b5efa495bb
Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
1352 | $stage = 0; |
106
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1353 | $uuid = str_replace("\n", "", file_get_contents('/proc/sys/kernel/random/uuid')); |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1354 | |
151
2c9cfe2f0860
Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents:
150
diff
changeset
|
1355 | $sql = "INSERT INTO products SET uuid='" . $uuid; |
2c9cfe2f0860
Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents:
150
diff
changeset
|
1356 | $sql .= "', name='" . mysqli_real_escape_string($db, $recipe->NAME); |
106
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1357 | |
111
8c4ba91adf58
Basic screens for brew products.
Michiel Broek <mbroek@mbse.eu>
parents:
108
diff
changeset
|
1358 | if ($recipe->NOTES) { |
151
2c9cfe2f0860
Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents:
150
diff
changeset
|
1359 | $sql .= "', notes='" . mysqli_real_escape_string($db, $recipe->NOTES); |
111
8c4ba91adf58
Basic screens for brew products.
Michiel Broek <mbroek@mbse.eu>
parents:
108
diff
changeset
|
1360 | } else { |
151
2c9cfe2f0860
Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents:
150
diff
changeset
|
1361 | $sql .= "', notes='"; |
111
8c4ba91adf58
Basic screens for brew products.
Michiel Broek <mbroek@mbse.eu>
parents:
108
diff
changeset
|
1362 | } |
234
b8b5efa495bb
Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
1363 | |
b8b5efa495bb
Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
1364 | if ($recipe->TYPE == 'Extract') |
b8b5efa495bb
Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
1365 | $sql .= "', type='0"; |
b8b5efa495bb
Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
1366 | else if ($recipe->TYPE == 'Partial Mash') |
b8b5efa495bb
Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
1367 | $sql .= "', type='1"; |
b8b5efa495bb
Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
1368 | else if ($recipe->TYPE == 'All Grain') |
b8b5efa495bb
Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
1369 | $sql .= "', type='2"; |
b8b5efa495bb
Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
1370 | |
106
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1371 | if ($recipe->BATCH_SIZE) |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1372 | $batch_size = floatval($recipe->BATCH_SIZE); |
151
2c9cfe2f0860
Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents:
150
diff
changeset
|
1373 | $sql .= "', batch_size='" . $batch_size; |
106
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1374 | if ($recipe->BOIL_SIZE) |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1375 | $boil_size = floatval($recipe->BOIL_SIZE); |
151
2c9cfe2f0860
Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents:
150
diff
changeset
|
1376 | $sql .= "', boil_size='" . $boil_size; |
106
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1377 | if ($recipe->BOIL_TIME) |
151
2c9cfe2f0860
Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents:
150
diff
changeset
|
1378 | $sql .= "', boil_time='" . floatval($recipe->BOIL_TIME); |
106
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1379 | else |
151
2c9cfe2f0860
Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents:
150
diff
changeset
|
1380 | $sql .= "', boil_time='90"; |
106
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1381 | if ($recipe->EFFICIENCY) |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1382 | $efficiency = floatval($recipe->EFFICIENCY); |
151
2c9cfe2f0860
Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents:
150
diff
changeset
|
1383 | $sql .= "', efficiency='" . $efficiency; |
106
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1384 | /* Don't use $recipe->EST_OG but recalculate it */ |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1385 | /* Don't use $recipe->EST_FG but recalculate it */ |
234
b8b5efa495bb
Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
1386 | /* Don't use $recipe->EST_COLOR but recalculate it */ |
b8b5efa495bb
Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
1387 | $color_method = 0; |
b8b5efa495bb
Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
1388 | if ($recipe->COLOR_METHOD == 'Morey') { |
b8b5efa495bb
Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
1389 | $color_method = 0; |
b8b5efa495bb
Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
1390 | $sql .= "', color_method='0"; |
b8b5efa495bb
Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
1391 | } else if ($recipe->COLOR_METHOD == 'Mosher') { |
b8b5efa495bb
Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
1392 | $color_method = 1; |
b8b5efa495bb
Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
1393 | $sql .= "', color_method='1"; |
b8b5efa495bb
Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
1394 | } else if ($recipe->COLOR_METHOD == 'Daniels') { |
b8b5efa495bb
Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
1395 | $color_method = 2; |
b8b5efa495bb
Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
1396 | $sql .= "', color_method='2"; |
b8b5efa495bb
Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
1397 | } else |
b8b5efa495bb
Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
1398 | echo "Unknown COLOR_METHO " . $recipe->COLOR_METHOD . PHP_EOL; |
b8b5efa495bb
Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
1399 | |
b8b5efa495bb
Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
1400 | if ($recipe->IBU) |
b8b5efa495bb
Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
1401 | $sql .= "', est_ibu='" . floatval($recipe->IBU); |
b8b5efa495bb
Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
1402 | if ($recipe->IBU_METHOD == 'Tinseth') |
b8b5efa495bb
Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
1403 | $sql .= "', ibu_method='0"; |
b8b5efa495bb
Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
1404 | else if ($recipe->IBU_METHOD == 'Rager') |
b8b5efa495bb
Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
1405 | $sql .= "', ibu_method='1"; |
b8b5efa495bb
Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
1406 | else if ($recipe->IBU_METHOD == 'Daniels') |
b8b5efa495bb
Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
1407 | $sql .= "', ibu_method='2"; |
b8b5efa495bb
Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
1408 | else |
b8b5efa495bb
Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
1409 | echo "Unknown IBU_METHOD " . $recipe->IBU_METHOD . PHP_EOL; |
b8b5efa495bb
Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
1410 | |
106
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1411 | if ($recipe->CARBONATION) |
151
2c9cfe2f0860
Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents:
150
diff
changeset
|
1412 | $sql .= "', est_carb='" . floatval($recipe->CARBONATION); |
106
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1413 | |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1414 | if ($recipe->STYLE) { |
151
2c9cfe2f0860
Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents:
150
diff
changeset
|
1415 | $sql .= recipe_style($recipe); |
106
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1416 | } |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1417 | |
147
e6e5d007eb54
Added several sparge_ fields in the recipes databases. Added basic water mix calculator. Added fields on the water tab for water calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
143
diff
changeset
|
1418 | if ($recipe->CALC_ACID) { |
151
2c9cfe2f0860
Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents:
150
diff
changeset
|
1419 | ($recipe->CALC_ACID == "TRUE") ? $sql .= "', calc_acid='1" : $sql .= "', calc_acid='0"; |
147
e6e5d007eb54
Added several sparge_ fields in the recipes databases. Added basic water mix calculator. Added fields on the water tab for water calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
143
diff
changeset
|
1420 | } |
e6e5d007eb54
Added several sparge_ fields in the recipes databases. Added basic water mix calculator. Added fields on the water tab for water calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
143
diff
changeset
|
1421 | if ($recipe->TARGET_PH) { |
151
2c9cfe2f0860
Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents:
150
diff
changeset
|
1422 | $sql .= "', mash_ph='" . floatval($recipe->TARGET_PH); |
147
e6e5d007eb54
Added several sparge_ fields in the recipes databases. Added basic water mix calculator. Added fields on the water tab for water calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
143
diff
changeset
|
1423 | } |
149
ff45488d480e
Added some icons from Brewersfriend. They should be replaced someday. Added maximum mash weight setting to the equipment database. Usefull for brew automate and RIMS systems. During recipes import acid and base additions are translated. Brews and recipes now have 2 water sources. Added water mixer. Added basic water treatment, but not for pH yet. Redesigned the fermentables and water tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
148
diff
changeset
|
1424 | if ($recipe->SPARGE_ACID_TYPE && ($recipe->SPARGE_ACID_TYPE == "Lactic")) { |
234
b8b5efa495bb
Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
1425 | $sql .= "', sparge_acid_type='0"; |
149
ff45488d480e
Added some icons from Brewersfriend. They should be replaced someday. Added maximum mash weight setting to the equipment database. Usefull for brew automate and RIMS systems. During recipes import acid and base additions are translated. Brews and recipes now have 2 water sources. Added water mixer. Added basic water treatment, but not for pH yet. Redesigned the fermentables and water tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
148
diff
changeset
|
1426 | } else if ($recipe->SPARGE_ACID_TYPE && ($recipe->SPARGE_ACID_TYPE == "Hydrochloric")) { |
234
b8b5efa495bb
Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
1427 | $sql .= "', sparge_acid_type='1"; |
149
ff45488d480e
Added some icons from Brewersfriend. They should be replaced someday. Added maximum mash weight setting to the equipment database. Usefull for brew automate and RIMS systems. During recipes import acid and base additions are translated. Brews and recipes now have 2 water sources. Added water mixer. Added basic water treatment, but not for pH yet. Redesigned the fermentables and water tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
148
diff
changeset
|
1428 | } else if ($recipe->SPARGE_ACID_TYPE && ($recipe->SPARGE_ACID_TYPE == "Phosphoric")) { |
234
b8b5efa495bb
Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
1429 | $sql .= "', sparge_acid_type='2"; |
149
ff45488d480e
Added some icons from Brewersfriend. They should be replaced someday. Added maximum mash weight setting to the equipment database. Usefull for brew automate and RIMS systems. During recipes import acid and base additions are translated. Brews and recipes now have 2 water sources. Added water mixer. Added basic water treatment, but not for pH yet. Redesigned the fermentables and water tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
148
diff
changeset
|
1430 | } else if ($recipe->SPARGE_ACID_TYPE && ($recipe->SPARGE_ACID_TYPE == "Sulfuric")) { |
234
b8b5efa495bb
Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
1431 | $sql .= "', sparge_acid_type='3"; |
147
e6e5d007eb54
Added several sparge_ fields in the recipes databases. Added basic water mix calculator. Added fields on the water tab for water calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
143
diff
changeset
|
1432 | } |
e6e5d007eb54
Added several sparge_ fields in the recipes databases. Added basic water mix calculator. Added fields on the water tab for water calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
143
diff
changeset
|
1433 | if ($recipe->ACID_SPARGE_PERC) { |
151
2c9cfe2f0860
Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents:
150
diff
changeset
|
1434 | $sql .= "', sparge_acid_perc='" . floatval($recipe->ACID_SPARGE_PERC); |
147
e6e5d007eb54
Added several sparge_ fields in the recipes databases. Added basic water mix calculator. Added fields on the water tab for water calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
143
diff
changeset
|
1435 | } |
e6e5d007eb54
Added several sparge_ fields in the recipes databases. Added basic water mix calculator. Added fields on the water tab for water calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
143
diff
changeset
|
1436 | if ($recipe->LACTIC_SPARGE) { |
151
2c9cfe2f0860
Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents:
150
diff
changeset
|
1437 | $sql .= "', sparge_acid_amount='" . floatval($recipe->LACTIC_SPARGE); |
147
e6e5d007eb54
Added several sparge_ fields in the recipes databases. Added basic water mix calculator. Added fields on the water tab for water calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
143
diff
changeset
|
1438 | } |
e6e5d007eb54
Added several sparge_ fields in the recipes databases. Added basic water mix calculator. Added fields on the water tab for water calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
143
diff
changeset
|
1439 | if ($recipe->VOLUME_HLT) { |
151
2c9cfe2f0860
Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents:
150
diff
changeset
|
1440 | $sql .= "', sparge_volume='" . floatval($recipe->VOLUME_HLT); |
147
e6e5d007eb54
Added several sparge_ fields in the recipes databases. Added basic water mix calculator. Added fields on the water tab for water calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
143
diff
changeset
|
1441 | } |
230
8edca0488e65
Finished the water treatment in the recipes editor. It seems that the recipes editor is ready.
Michiel Broek <mbroek@mbse.eu>
parents:
228
diff
changeset
|
1442 | $sql .= "', sparge_source='0"; |
147
e6e5d007eb54
Added several sparge_ fields in the recipes databases. Added basic water mix calculator. Added fields on the water tab for water calculations.
Michiel Broek <mbroek@mbse.eu>
parents:
143
diff
changeset
|
1443 | |
106
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1444 | /* |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1445 | * Put the fermentables in a json array |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1446 | */ |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1447 | if ($recipe->FERMENTABLES) { |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1448 | $fermentables = recipe_fermentables($recipe); |
151
2c9cfe2f0860
Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents:
150
diff
changeset
|
1449 | $sql .= "', json_fermentables='" . $fermentables; |
106
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1450 | if (strlen($fermentables) > $len_fermentables) |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1451 | $len_fermentables = strlen($fermentables); |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1452 | } |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1453 | |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1454 | /* |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1455 | * Put the hops in a json array |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1456 | */ |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1457 | if ($recipe->HOPS) { |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1458 | $hops = recipe_hops($recipe); |
151
2c9cfe2f0860
Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents:
150
diff
changeset
|
1459 | $sql .= "', json_hops='" . $hops; |
106
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1460 | if (strlen($hops) > $len_hops) |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1461 | $len_hops = strlen($hops); |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1462 | } |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1463 | |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1464 | /* |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1465 | * Put the miscs in a json array |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1466 | */ |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1467 | if ($recipe->MISCS) { |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1468 | $miscs = recipe_miscs($recipe); |
151
2c9cfe2f0860
Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents:
150
diff
changeset
|
1469 | $sql .= "', json_miscs='" . $miscs; |
106
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1470 | if (strlen($miscs) > $len_miscs) |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1471 | $len_miscs = strlen($miscs); |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1472 | } |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1473 | |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1474 | /* |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1475 | * Put the yeasts in a json array |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1476 | */ |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1477 | if ($recipe->YEASTS) { |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1478 | $yeasts = recipe_yeasts($recipe); |
151
2c9cfe2f0860
Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents:
150
diff
changeset
|
1479 | $sql .= "', json_yeasts='" . $yeasts; |
106
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1480 | if (strlen($yeasts) > $len_yeasts) |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1481 | $len_yeasts = strlen($yeasts); |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1482 | } |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1483 | |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1484 | /* |
148
c0f0bbfefd63
Source waters are fixed, removed grid editor. Redesigned the water screen. Made a simple visual if water treatments are out of range. Water mixer for standard and dillute water works. Swapped the mash and water tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
147
diff
changeset
|
1485 | * Get the waters |
106
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1486 | */ |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1487 | if ($recipe->WATERS) { |
151
2c9cfe2f0860
Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents:
150
diff
changeset
|
1488 | $sql .= recipe_waters($recipe, $db); |
106
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1489 | } |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1490 | |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1491 | /* |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1492 | * Put the mash in a json array |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1493 | */ |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1494 | if ($recipe->MASH) { |
151
2c9cfe2f0860
Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents:
150
diff
changeset
|
1495 | $sql .= "',sparge_temp='" . floatval($recipe->MASH->SPARGE_TEMP); |
2c9cfe2f0860
Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents:
150
diff
changeset
|
1496 | $sql .= "',sparge_ph='" . floatval($recipe->MASH->PH); |
106
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1497 | if ($recipe->MASH->NAME) |
151
2c9cfe2f0860
Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents:
150
diff
changeset
|
1498 | $sql .= "',mash_name='" . mysqli_real_escape_string($db, $recipe->MASH->NAME); |
106
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1499 | |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1500 | if ($recipe->MASH->MASH_STEPS) { |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1501 | $steps = recipe_mash_steps($recipe); |
151
2c9cfe2f0860
Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents:
150
diff
changeset
|
1502 | $sql .= "', json_mashs='" . $steps; |
106
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1503 | if (strlen($steps) > $len_mash) |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1504 | $len_mash = strlen($steps); |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1505 | } |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1506 | } |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1507 | |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1508 | /* |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1509 | * Added the calculated values |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1510 | * OG, FG, color, IBU |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1511 | */ |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1512 | $og = estimate_sg($f_sugars, $batch_size); |
151
2c9cfe2f0860
Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents:
150
diff
changeset
|
1513 | $sql .= "', est_og='" . floatval($og); |
106
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1514 | $fg = estimate_fg($pSugar, $pCara, 0, 0, 0, $svg, $og); |
151
2c9cfe2f0860
Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents:
150
diff
changeset
|
1515 | $sql .= "', est_fg='" . floatval($fg); |
106
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1516 | $abv = abvol($og, $fg); |
151
2c9cfe2f0860
Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents:
150
diff
changeset
|
1517 | $sql .= "', est_abv='" . floatval($abv); |
234
b8b5efa495bb
Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
1518 | $color = kw_to_ebc($color_method, $colorw); |
151
2c9cfe2f0860
Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents:
150
diff
changeset
|
1519 | $sql .= "', est_color='" . floatval($color); |
2c9cfe2f0860
Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents:
150
diff
changeset
|
1520 | $sql .= "', code='" . mysqli_real_escape_string($db, $recipe->NR_RECIPE); |
108 | 1521 | |
1522 | /* | |
1523 | * Update external logfiles | |
1524 | */ | |
151
2c9cfe2f0860
Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents:
150
diff
changeset
|
1525 | $lsql = "UPDATE log_brews SET product_uuid='".$uuid."', product_name='".mysqli_real_escape_string($db, $recipe->NAME); |
2c9cfe2f0860
Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents:
150
diff
changeset
|
1526 | $lsql .= "' WHERE product_code='".mysqli_real_escape_string($db, $recipe->NR_RECIPE)."';"; |
2c9cfe2f0860
Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents:
150
diff
changeset
|
1527 | if (! $result = mysqli_query($db, $lsql)) { |
108 | 1528 | printf("Error: %s\n", mysqli_error($db)); |
1529 | } | |
1530 | $count = mysqli_affected_rows($db); | |
1531 | if ($count > 0) { | |
151
2c9cfe2f0860
Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents:
150
diff
changeset
|
1532 | $sql .= "', log_brew='1"; |
108 | 1533 | } |
234
b8b5efa495bb
Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
1534 | |
b8b5efa495bb
Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
1535 | $filename = '../log/fermentation/'.$recipe->NR_RECIPE.' '.$recipe->NAME.'.log'; |
b8b5efa495bb
Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
1536 | if (file_exists($filename)) { |
151
2c9cfe2f0860
Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents:
150
diff
changeset
|
1537 | $sql .= "', log_fermentation='1"; |
114
4935e86b2775
Small fixes for prject import from Brouwhulp. Fixes for poduct database read/write. New menu entries. Equipment select in product editor. Started brewday editor. Added conditions on some buttons and edit fields. Screen layout changes.
Michiel Broek <mbroek@mbse.eu>
parents:
111
diff
changeset
|
1538 | } else { |
234
b8b5efa495bb
Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
1539 | if ($recipe->FERM_MEASUREMENTS) { |
b8b5efa495bb
Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
1540 | /* |
b8b5efa495bb
Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
1541 | * There is internal logdata in the xml, create a logfile |
b8b5efa495bb
Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
1542 | */ |
b8b5efa495bb
Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
1543 | $fp = fopen($filename, "w+"); |
b8b5efa495bb
Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
1544 | foreach ($recipe->FERM_MEASUREMENTS->FERM_MEASUREMENT as $measurement) { |
b8b5efa495bb
Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
1545 | $dt = substr($measurement->DATE_TIME, 6, 4).substr($measurement->DATE_TIME,2,4).substr($measurement->DATE_TIME,0,2); |
b8b5efa495bb
Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
1546 | $dt .= ' '.substr($measurement->DATE_TIME, 11,8); |
b8b5efa495bb
Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
1547 | $line = $dt.',NONE,PRIMARY,'; |
b8b5efa495bb
Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
1548 | $line .= sprintf("%.1f",floatval($measurement->TEMP_SENSOR_1)) .','; |
b8b5efa495bb
Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
1549 | $line .= sprintf("%.1f",floatval($measurement->TEMP_SENSOR_2)) .','; |
b8b5efa495bb
Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
1550 | $line .= 'NA,NA,NA,NA,NA,NA,NA,NA,' . PHP_EOL; |
b8b5efa495bb
Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
1551 | fwrite($fp, $line); |
b8b5efa495bb
Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
1552 | } |
b8b5efa495bb
Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
1553 | fclose($fp); |
151
2c9cfe2f0860
Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents:
150
diff
changeset
|
1554 | $sql .= "', log_fermentation='1"; |
234
b8b5efa495bb
Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
1555 | } else { |
b8b5efa495bb
Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
1556 | $sql .= "', log_fermentation='0"; |
108 | 1557 | } |
1558 | } | |
106
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1559 | |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1560 | if ($recipe->EQUIPMENT) { |
151
2c9cfe2f0860
Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents:
150
diff
changeset
|
1561 | $sql .= "', eq_name='" . mysqli_real_escape_string($db, $recipe->EQUIPMENT->NAME); |
2c9cfe2f0860
Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents:
150
diff
changeset
|
1562 | $sql .= "', eq_notes='" . mysqli_real_escape_string($db, $recipe->EQUIPMENT->NOTES); |
2c9cfe2f0860
Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents:
150
diff
changeset
|
1563 | $sql .= "', eq_boil_size='" . floatval($recipe->EQUIPMENT->BOIL_SIZE); |
2c9cfe2f0860
Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents:
150
diff
changeset
|
1564 | $sql .= "', eq_batch_size='" . floatval($recipe->EQUIPMENT->BATCH_SIZE); |
2c9cfe2f0860
Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents:
150
diff
changeset
|
1565 | $sql .= "', eq_tun_volume='" . floatval($recipe->EQUIPMENT->TUN_VOLUME); |
2c9cfe2f0860
Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents:
150
diff
changeset
|
1566 | $sql .= "', eq_tun_weight='" . floatval($recipe->EQUIPMENT->TUN_WEIGHT); |
2c9cfe2f0860
Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents:
150
diff
changeset
|
1567 | $sql .= "', eq_tun_specific_heat='" . floatval($recipe->EQUIPMENT->TUN_SPECIFIC_HEAT); |
234
b8b5efa495bb
Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
1568 | $sql .= "', eq_tun_material='" . $recipe->EQUIPMENT->TUN_MATERIAL; |
151
2c9cfe2f0860
Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents:
150
diff
changeset
|
1569 | $sql .= "', eq_tun_height='" . floatval($recipe->EQUIPMENT->TUN_HEIGHT); |
108 | 1570 | if ($recipe->EQUIPMENT->TOP_UP_WATER) |
151
2c9cfe2f0860
Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents:
150
diff
changeset
|
1571 | $sql .= "', eq_top_up_water='" . floatval($recipe->EQUIPMENT->TOP_UP_WATER); |
2c9cfe2f0860
Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents:
150
diff
changeset
|
1572 | $sql .= "', eq_trub_chiller_loss='" . floatval($recipe->EQUIPMENT->TRUB_CHILLER_LOSS); |
114
4935e86b2775
Small fixes for prject import from Brouwhulp. Fixes for poduct database read/write. New menu entries. Equipment select in product editor. Started brewday editor. Added conditions on some buttons and edit fields. Screen layout changes.
Michiel Broek <mbroek@mbse.eu>
parents:
111
diff
changeset
|
1573 | /* |
4935e86b2775
Small fixes for prject import from Brouwhulp. Fixes for poduct database read/write. New menu entries. Equipment select in product editor. Started brewday editor. Added conditions on some buttons and edit fields. Screen layout changes.
Michiel Broek <mbroek@mbse.eu>
parents:
111
diff
changeset
|
1574 | * Brouwhulp uses a percentage for the evaporation rate. This is wrong |
4935e86b2775
Small fixes for prject import from Brouwhulp. Fixes for poduct database read/write. New menu entries. Equipment select in product editor. Started brewday editor. Added conditions on some buttons and edit fields. Screen layout changes.
Michiel Broek <mbroek@mbse.eu>
parents:
111
diff
changeset
|
1575 | * but was made so because the beerxml standard requires this. What we |
4935e86b2775
Small fixes for prject import from Brouwhulp. Fixes for poduct database read/write. New menu entries. Equipment select in product editor. Started brewday editor. Added conditions on some buttons and edit fields. Screen layout changes.
Michiel Broek <mbroek@mbse.eu>
parents:
111
diff
changeset
|
1576 | * do is calculate the actual evaporation and store that. |
4935e86b2775
Small fixes for prject import from Brouwhulp. Fixes for poduct database read/write. New menu entries. Equipment select in product editor. Started brewday editor. Added conditions on some buttons and edit fields. Screen layout changes.
Michiel Broek <mbroek@mbse.eu>
parents:
111
diff
changeset
|
1577 | * This is what we use. Brouwhulp calculates this on the fly. |
4935e86b2775
Small fixes for prject import from Brouwhulp. Fixes for poduct database read/write. New menu entries. Equipment select in product editor. Started brewday editor. Added conditions on some buttons and edit fields. Screen layout changes.
Michiel Broek <mbroek@mbse.eu>
parents:
111
diff
changeset
|
1578 | */ |
151
2c9cfe2f0860
Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents:
150
diff
changeset
|
1579 | $sql .= "', eq_evap_rate='" . (floatval($recipe->EQUIPMENT->EVAP_RATE) * floatval($recipe->EQUIPMENT->BOIL_SIZE)) / 100; |
2c9cfe2f0860
Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents:
150
diff
changeset
|
1580 | $sql .= "', eq_boil_time='" . floatval($recipe->EQUIPMENT->BOIL_TIME); |
2c9cfe2f0860
Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents:
150
diff
changeset
|
1581 | ($recipe->EQUIPMENT->CALC_BOIL_VOLUME == 'TRUE') ? $sql .= "', eq_calc_boil_volume='1" : $sql .= "', eq_calc_boil_volume='0"; |
108 | 1582 | if ($recipe->EQUIPMENT->TOP_UP_KETTLE) |
151
2c9cfe2f0860
Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents:
150
diff
changeset
|
1583 | $sql .= "', eq_top_up_kettle='" . floatval($recipe->EQUIPMENT->TOP_UP_KETTLE); |
2c9cfe2f0860
Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents:
150
diff
changeset
|
1584 | $sql .= "', eq_hop_utilization='" . floatval($recipe->EQUIPMENT->HOP_UTILIZATION); |
2c9cfe2f0860
Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents:
150
diff
changeset
|
1585 | $sql .= "', eq_lauter_volume='" . floatval($recipe->EQUIPMENT->LAUTER_VOLUME); |
2c9cfe2f0860
Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents:
150
diff
changeset
|
1586 | $sql .= "', eq_lauter_height='" . floatval($recipe->EQUIPMENT->LAUTER_HEIGHT); |
2c9cfe2f0860
Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents:
150
diff
changeset
|
1587 | $sql .= "', eq_lauter_deadspace='" . floatval($recipe->EQUIPMENT->LAUTER_DEADSPACE); |
2c9cfe2f0860
Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents:
150
diff
changeset
|
1588 | $sql .= "', eq_kettle_volume='" . floatval($recipe->EQUIPMENT->KETTLE_VOLUME); |
2c9cfe2f0860
Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents:
150
diff
changeset
|
1589 | $sql .= "', eq_kettle_height='" . floatval($recipe->EQUIPMENT->KETTLE_HEIGHT); |
2c9cfe2f0860
Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents:
150
diff
changeset
|
1590 | $sql .= "', eq_mash_volume='" . floatval($recipe->EQUIPMENT->MASH_VOLUME); |
2c9cfe2f0860
Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents:
150
diff
changeset
|
1591 | $sql .= "', eq_mash_max='" . round((floatval($recipe->EQUIPMENT->MASH_VOLUME) / 3) * 10) / 10; // Not in beerxml/brouwhulp. For RIMS systems. |
2c9cfe2f0860
Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents:
150
diff
changeset
|
1592 | $sql .= "', eq_efficiency='" . floatval($recipe->EQUIPMENT->EFFICIENCY); |
106
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1593 | } |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1594 | |
108 | 1595 | if (($recipe->DATE) && (! $recipe->TIME_STARTED) && (! $recipe->TIME_ENDED)) { |
1596 | /* We have a plan date but haven't brewed yet, use current date */ | |
151
2c9cfe2f0860
Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents:
150
diff
changeset
|
1597 | $sql .= "', birth='" . date("Y-m-d"); |
234
b8b5efa495bb
Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
1598 | $stage = 1; |
108 | 1599 | } |
1600 | ||
107 | 1601 | if (($recipe->DATE) && ($recipe->TIME_STARTED) && ($recipe->TIME_ENDED)) { |
1602 | /* We have brew data */ | |
234
b8b5efa495bb
Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
1603 | $stage = 3; // Need to think about during a brew... |
108 | 1604 | $brewdate = substr($recipe->DATE, 6, 4).substr($recipe->DATE,2,4).substr($recipe->DATE,0,2); |
151
2c9cfe2f0860
Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents:
150
diff
changeset
|
1605 | $sql .= "', birth='" . $brewdate; |
108 | 1606 | $date_start = $brewdate.' '.$recipe->TIME_STARTED; |
1607 | $date_end = $brewdate.' '.$recipe->TIME_ENDED; | |
151
2c9cfe2f0860
Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents:
150
diff
changeset
|
1608 | $sql .= "', brew_date_start='" . $date_start; |
107 | 1609 | |
1610 | if ($recipe->PH_ADJUSTED) | |
151
2c9cfe2f0860
Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents:
150
diff
changeset
|
1611 | $sql .= "', brew_mash_ph='" . floatval($recipe->PH_ADJUSTED); |
107 | 1612 | if (floatval($recipe->SG_END_MASH) != 1.0) |
151
2c9cfe2f0860
Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents:
150
diff
changeset
|
1613 | $sql .= "', brew_mash_sg='" . floatval($recipe->SG_END_MASH); |
121
875aeb365e1c
Added sparge pH during import. Added several calculations. Added calculated estimates to the brewday screen.
Michiel Broek <mbroek@mbse.eu>
parents:
119
diff
changeset
|
1614 | if ($recipe->MASH->PH) |
151
2c9cfe2f0860
Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents:
150
diff
changeset
|
1615 | $sql .= "', brew_sparge_ph='" . floatval($recipe->MASH->PH); |
107 | 1616 | if ($recipe->VOLUME_HLT) |
432
99dcd8488b62
Merged brew_sparge_temperature with sparge_temp and brew_sparge_volume with sparge_volume.
Michiel Broek <mbroek@mbse.eu>
parents:
278
diff
changeset
|
1617 | $sql .= "', sparge_volume='" . floatval($recipe->VOLUME_HLT); |
107 | 1618 | if ($recipe->VOLUME_BEFORE_BOIL) |
246
8580a08cbaa7
Tab brouwdag automatische berekening rendement voor en na het koken. Bij import worden de kook volumes omgerekend naar 100 graden.
Michiel Broek <mbroek@mbse.eu>
parents:
234
diff
changeset
|
1619 | $sql .= "', brew_preboil_volume='" . sprintf("%.5f",floatval($recipe->VOLUME_BEFORE_BOIL) * 1.04); |
107 | 1620 | if (floatval($recipe->OG_BEFORE_BOIL) != 1.0) |
151
2c9cfe2f0860
Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents:
150
diff
changeset
|
1621 | $sql .= "', brew_preboil_sg='" . floatval($recipe->OG_BEFORE_BOIL); |
107 | 1622 | if ($recipe->PH_BEFORE_BOIL) |
151
2c9cfe2f0860
Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents:
150
diff
changeset
|
1623 | $sql .= "', brew_preboil_ph='" . floatval($recipe->PH_BEFORE_BOIL); |
107 | 1624 | if ($recipe->VOLUME_AFTER_BOIL) |
246
8580a08cbaa7
Tab brouwdag automatische berekening rendement voor en na het koken. Bij import worden de kook volumes omgerekend naar 100 graden.
Michiel Broek <mbroek@mbse.eu>
parents:
234
diff
changeset
|
1625 | $sql .= "', brew_aboil_volume='" . sprintf("%.5f",floatval($recipe->VOLUME_AFTER_BOIL) * 1.04); |
151
2c9cfe2f0860
Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents:
150
diff
changeset
|
1626 | $sql .= "', brew_aboil_sg='" . floatval($recipe->OG); |
107 | 1627 | if ($recipe->PH_AFTER_BOIL) |
151
2c9cfe2f0860
Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents:
150
diff
changeset
|
1628 | $sql .= "', brew_aboil_ph='" . floatval($recipe->PH_AFTER_BOIL); |
107 | 1629 | if ($recipe->ACTUAL_EFFICIENCY) |
151
2c9cfe2f0860
Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents:
150
diff
changeset
|
1630 | $sql .= "', brew_aboil_efficiency='" . floatval($recipe->ACTUAL_EFFICIENCY); |
2c9cfe2f0860
Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents:
150
diff
changeset
|
1631 | $sql .= "', brew_whirlpool2='" . floatval($recipe->WHIRLPOOL_TIME); |
234
b8b5efa495bb
Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
1632 | |
b8b5efa495bb
Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
1633 | if ($recipe->COOLING_METHOD == '-') |
b8b5efa495bb
Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
1634 | $sql .= "', brew_cooling_method='0"; |
b8b5efa495bb
Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
1635 | else if ($recipe->COOLING_METHOD == 'Emersion chiller') |
b8b5efa495bb
Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
1636 | $sql .= "', brew_cooling_method='1"; |
b8b5efa495bb
Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
1637 | else if ($recipe->COOLING_METHOD == 'Counterflow chiller') |
b8b5efa495bb
Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
1638 | $sql .= "', brew_cooling_method='2"; |
b8b5efa495bb
Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
1639 | else if ($recipe->COOLING_METHOD == 'Au bain marie') |
b8b5efa495bb
Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
1640 | $sql .= "', brew_cooling_method='3"; |
b8b5efa495bb
Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
1641 | else if ($recipe->COOLING_METHOD == 'Natural') |
b8b5efa495bb
Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
1642 | $sql .= "', brew_cooling_method='4"; |
b8b5efa495bb
Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
1643 | else |
b8b5efa495bb
Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
1644 | echo "Unknown COOLING_METHOD " . $recipe->COOLING_METHOD . PHP_EOL; |
151
2c9cfe2f0860
Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents:
150
diff
changeset
|
1645 | $sql .= "', brew_cooling_time='" . floatval($recipe->COOLING_TIME); |
2c9cfe2f0860
Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents:
150
diff
changeset
|
1646 | $sql .= "', brew_cooling_to='" . floatval($recipe->COOLING_TO); |
107 | 1647 | if ($recipe->VOLUME_FERMENTER) |
151
2c9cfe2f0860
Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents:
150
diff
changeset
|
1648 | $sql .= "', brew_fermenter_volume='" . floatval($recipe->VOLUME_FERMENTER); |
107 | 1649 | if ($recipe->EQUIPMENT->TOP_UP_WATER_BREWDAY) |
151
2c9cfe2f0860
Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents:
150
diff
changeset
|
1650 | $sql .= "', brew_fermenter_extrawater='" . floatval($recipe->EQUIPMENT->TOP_UP_WATER_BREWDAY); |
2c9cfe2f0860
Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents:
150
diff
changeset
|
1651 | $sql .= "', brew_fermenter_sg='" . floatval($recipe->OG_FERMENTER); |
2c9cfe2f0860
Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents:
150
diff
changeset
|
1652 | $sql .= "', brew_fermenter_ibu='" . floatval($recipe->IBU); |
234
b8b5efa495bb
Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
1653 | |
b8b5efa495bb
Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
1654 | if ($recipe->AERATION_TYPE == 'None') |
b8b5efa495bb
Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
1655 | $sql .= "', brew_aeration_type='0"; |
b8b5efa495bb
Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
1656 | else if ($recipe->AERATION_TYPE == 'Air') { |
b8b5efa495bb
Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
1657 | $sql .= "', brew_aeration_type='1"; |
151
2c9cfe2f0860
Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents:
150
diff
changeset
|
1658 | $sql .= "', brew_aeration_speed='" . floatval($recipe->AERATION_SPEED); |
2c9cfe2f0860
Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents:
150
diff
changeset
|
1659 | $sql .= "', brew_aeration_time='" . floatval($recipe->AERATION_TIME); |
234
b8b5efa495bb
Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
1660 | } else if ($recipe->AERATION_TYPE == 'Oxygen') { |
b8b5efa495bb
Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
1661 | $sql .= "', brew_aeration_type='2"; |
b8b5efa495bb
Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
1662 | $sql .= "', brew_aeration_speed='" . floatval($recipe->AERATION_SPEED); |
b8b5efa495bb
Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
1663 | $sql .= "', brew_aeration_time='" . floatval($recipe->AERATION_TIME); |
b8b5efa495bb
Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
1664 | } else |
b8b5efa495bb
Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
1665 | echo "Unknown AERATION_TYPE " . $recipe->AERATION_TYPE . PHP_EOL; |
b8b5efa495bb
Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
1666 | |
151
2c9cfe2f0860
Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents:
150
diff
changeset
|
1667 | $sql .= "', brew_date_end='" . $date_end; |
107 | 1668 | } |
108 | 1669 | |
163
4a4cc3497a57
Added the packaging tab contents.
Michiel Broek <mbroek@mbse.eu>
parents:
154
diff
changeset
|
1670 | $sql .= "', og='" . floatval($recipe->OG); |
4a4cc3497a57
Added the packaging tab contents.
Michiel Broek <mbroek@mbse.eu>
parents:
154
diff
changeset
|
1671 | $sql .= "', fg='" . floatval($recipe->FG); |
4a4cc3497a57
Added the packaging tab contents.
Michiel Broek <mbroek@mbse.eu>
parents:
154
diff
changeset
|
1672 | |
234
b8b5efa495bb
Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
1673 | if ($recipe->PRIMARY_AGE && ($stage >= 3)) { |
108 | 1674 | /* PRIMARY_TEMP is the average of START_TEMP_PRIMARY MAX_TEMP_PRIMARY END_TEMP_PRIMARY */ |
1675 | $pdate = new DateTime($brewdate); | |
1676 | $pdate->modify("+".floatval($recipe->PRIMARY_AGE)." days"); | |
151
2c9cfe2f0860
Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents:
150
diff
changeset
|
1677 | $sql .= "', primary_start_temp='" . floatval($recipe->START_TEMP_PRIMARY); |
2c9cfe2f0860
Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents:
150
diff
changeset
|
1678 | $sql .= "', primary_max_temp='" . floatval($recipe->MAX_TEMP_PRIMARY); |
2c9cfe2f0860
Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents:
150
diff
changeset
|
1679 | $sql .= "', primary_end_temp='" . floatval($recipe->END_TEMP_PRIMARY); |
2c9cfe2f0860
Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents:
150
diff
changeset
|
1680 | $sql .= "', primary_end_sg='" . floatval($recipe->SG_END_PRIMARY); |
2c9cfe2f0860
Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents:
150
diff
changeset
|
1681 | $sql .= "', primary_end_date='" . $pdate->format("Y-m-d"); |
234
b8b5efa495bb
Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
1682 | $stage = 4; // Secondary |
108 | 1683 | |
234
b8b5efa495bb
Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
1684 | if ($recipe->SECONDARY_AGE && ($stage >= 4)) { |
108 | 1685 | $sdate = new DateTime($brewdate); |
1686 | $sdate->modify("+".floatval($recipe->SECONDARY_AGE)." days"); | |
151
2c9cfe2f0860
Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents:
150
diff
changeset
|
1687 | $sql .= "', secondary_temp='" . floatval($recipe->SECONDARY_TEMP); |
460
046ff5fdc96c
Implemented products.secondary_end_sg field. The missing values are updated by the crontask.
Michiel Broek <mbroek@mbse.eu>
parents:
432
diff
changeset
|
1688 | $sql .= "', secondary_end_sg='" . floatval($recipe->FG); |
151
2c9cfe2f0860
Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents:
150
diff
changeset
|
1689 | $sql .= "', secondary_end_date='" . $sdate->format("Y-m-d"); |
234
b8b5efa495bb
Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
1690 | $stage = 5; // Tertiary |
107 | 1691 | |
234
b8b5efa495bb
Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
1692 | if ($recipe->TERTIARY_TEMP && ($stage >= 5)) { |
151
2c9cfe2f0860
Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents:
150
diff
changeset
|
1693 | $sql .= "', tertiary_temp='" . floatval($recipe->TERTIARY_TEMP); |
108 | 1694 | } |
1695 | } | |
1696 | } | |
1697 | ||
1698 | if ($recipe->DATE_BOTTLING && ($recipe->AMOUNT_BOTTLING || $recipe->AMOUNT_KEGGED) && | |
234
b8b5efa495bb
Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
1699 | ($recipe->AMOUNT_PRIMING || $recipe->AMOUNT_PRIMING_KEGS) && ($stage >= 5)) { |
108 | 1700 | $bdate = substr($recipe->DATE_BOTTLING, 6, 4).substr($recipe->DATE_BOTTLING,2,4).substr($recipe->DATE_BOTTLING,0,2); |
151
2c9cfe2f0860
Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents:
150
diff
changeset
|
1701 | $sql .= "', package_date='" . $bdate; |
234
b8b5efa495bb
Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
1702 | $stage = 6; // Package |
108 | 1703 | $dStart = new DateTime($bdate); |
1704 | $dEnd = new DateTime(''); | |
1705 | $dDiff = $dStart->diff($dEnd); | |
1706 | $age = floatval($dDiff->days); | |
150
159d7a89fcef
Better stage detection during product import from brouwhulp. Added tooltips for treated water.
Michiel Broek <mbroek@mbse.eu>
parents:
149
diff
changeset
|
1707 | if ($age == 0) { // Package day |
234
b8b5efa495bb
Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
1708 | $stage = 6; |
150
159d7a89fcef
Better stage detection during product import from brouwhulp. Added tooltips for treated water.
Michiel Broek <mbroek@mbse.eu>
parents:
149
diff
changeset
|
1709 | } else if ($age < 14) { // Carbonation period |
234
b8b5efa495bb
Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
1710 | $stage = 7; |
150
159d7a89fcef
Better stage detection during product import from brouwhulp. Added tooltips for treated water.
Michiel Broek <mbroek@mbse.eu>
parents:
149
diff
changeset
|
1711 | } else if ($age < 42) { // Mature, fixed 6 weeks |
234
b8b5efa495bb
Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
1712 | $stage = 8; |
150
159d7a89fcef
Better stage detection during product import from brouwhulp. Added tooltips for treated water.
Michiel Broek <mbroek@mbse.eu>
parents:
149
diff
changeset
|
1713 | } else { // Ready for tasting. |
234
b8b5efa495bb
Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
1714 | $stage = 9; |
150
159d7a89fcef
Better stage detection during product import from brouwhulp. Added tooltips for treated water.
Michiel Broek <mbroek@mbse.eu>
parents:
149
diff
changeset
|
1715 | } |
107 | 1716 | |
108 | 1717 | if ($recipe->AMOUNT_BOTTLING && $recipe->AMOUNT_PRIMING) { |
151
2c9cfe2f0860
Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents:
150
diff
changeset
|
1718 | $sql .= "', bottle_amount='" . floatval($recipe->AMOUNT_BOTTLING); |
2c9cfe2f0860
Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents:
150
diff
changeset
|
1719 | $sql .= "', bottle_carbonation='" . floatval($recipe->CARBONATION); |
234
b8b5efa495bb
Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
1720 | |
163
4a4cc3497a57
Added the packaging tab contents.
Michiel Broek <mbroek@mbse.eu>
parents:
154
diff
changeset
|
1721 | if ($recipe->PRIMING_SUGAR_BOTTLES == "Saccharose") |
234
b8b5efa495bb
Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
1722 | $sql .= "', bottle_priming_sugar='0"; |
163
4a4cc3497a57
Added the packaging tab contents.
Michiel Broek <mbroek@mbse.eu>
parents:
154
diff
changeset
|
1723 | else if ($recipe->PRIMING_SUGAR_BOTTLES == "Glucose or dextrose") |
234
b8b5efa495bb
Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
1724 | $sql .= "', bottle_priming_sugar='1"; |
163
4a4cc3497a57
Added the packaging tab contents.
Michiel Broek <mbroek@mbse.eu>
parents:
154
diff
changeset
|
1725 | else if ($recipe->PRIMING_SUGAR_BOTTLES == "Honey") |
234
b8b5efa495bb
Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
1726 | $sql .= "', bottle_priming_sugar='2"; |
163
4a4cc3497a57
Added the packaging tab contents.
Michiel Broek <mbroek@mbse.eu>
parents:
154
diff
changeset
|
1727 | else if ($recipe->PRIMING_SUGAR_BOTTLES == "DME") |
234
b8b5efa495bb
Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
1728 | $sql .= "', bottle_priming_sugar='3"; |
163
4a4cc3497a57
Added the packaging tab contents.
Michiel Broek <mbroek@mbse.eu>
parents:
154
diff
changeset
|
1729 | else if ($recipe->PRIMING_SUGAR_BOTTLES == "Molassis") |
234
b8b5efa495bb
Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
1730 | $sql .= "', bottle_priming_sugar='4"; |
151
2c9cfe2f0860
Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents:
150
diff
changeset
|
1731 | $sql .= "', bottle_priming_amount='" . floatval($recipe->AMOUNT_PRIMING); |
2c9cfe2f0860
Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents:
150
diff
changeset
|
1732 | $sql .= "', bottle_carbonation_temp='" . floatval($recipe->CARBONATION_TEMP); |
108 | 1733 | } |
1734 | if ($recipe->AMOUNT_KEGGED && $recipe->AMOUNT_PRIMING_KEGS) { | |
151
2c9cfe2f0860
Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents:
150
diff
changeset
|
1735 | $sql .= "', keg_amount='" . floatval($recipe->AMOUNT_KEGGED); |
2c9cfe2f0860
Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents:
150
diff
changeset
|
1736 | $sql .= "', keg_carbonation='" . floatval($recipe->CARBONATION); // Lijkt wel hetzelfde als bottles |
163
4a4cc3497a57
Added the packaging tab contents.
Michiel Broek <mbroek@mbse.eu>
parents:
154
diff
changeset
|
1737 | if ($recipe->PRIMING_SUGAR_BOTTLES == "Saccharose") |
234
b8b5efa495bb
Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
1738 | $sql .= "', keg_priming_sugar='0"; |
163
4a4cc3497a57
Added the packaging tab contents.
Michiel Broek <mbroek@mbse.eu>
parents:
154
diff
changeset
|
1739 | else if ($recipe->PRIMING_SUGAR_BOTTLES == "Glucose or dextrose") |
234
b8b5efa495bb
Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
1740 | $sql .= "', keg_priming_sugar='1"; |
163
4a4cc3497a57
Added the packaging tab contents.
Michiel Broek <mbroek@mbse.eu>
parents:
154
diff
changeset
|
1741 | else if ($recipe->PRIMING_SUGAR_BOTTLES == "Honey") |
234
b8b5efa495bb
Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
1742 | $sql .= "', keg_priming_sugar='2"; |
163
4a4cc3497a57
Added the packaging tab contents.
Michiel Broek <mbroek@mbse.eu>
parents:
154
diff
changeset
|
1743 | else if ($recipe->PRIMING_SUGAR_BOTTLES == "DME") |
234
b8b5efa495bb
Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
1744 | $sql .= "', keg_priming_sugar='3"; |
163
4a4cc3497a57
Added the packaging tab contents.
Michiel Broek <mbroek@mbse.eu>
parents:
154
diff
changeset
|
1745 | else if ($recipe->PRIMING_SUGAR_BOTTLES == "Molassis") |
234
b8b5efa495bb
Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
1746 | $sql .= "', keg_priming_sugar='4"; |
151
2c9cfe2f0860
Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents:
150
diff
changeset
|
1747 | $sql .= "', keg_priming_amount='" . floatval($recipe->AMOUNT_PRIMING_KEGS); |
2c9cfe2f0860
Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents:
150
diff
changeset
|
1748 | $sql .= "', keg_carbonation_temp='" . floatval($recipe->KEG_CARB_TEMP); |
2c9cfe2f0860
Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents:
150
diff
changeset
|
1749 | ($recipe->FORCED_CARB_KEGS == 'TRUE') ? $sql .= "', keg_forced_carb='1" : $sql .= "', keg_forced_carb='0"; |
2c9cfe2f0860
Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents:
150
diff
changeset
|
1750 | $sql .= "', keg_pressure='" . floatval($recipe->KEG_PRESSURE); |
108 | 1751 | } |
1752 | } | |
1753 | ||
234
b8b5efa495bb
Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
1754 | if ($recipe->TASTE_NOTES && $recipe->TASTING_RATE && $recipe->TASTE_DATE && ($stage >= 9)) { |
b8b5efa495bb
Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
1755 | $stage = 10; // Ready |
151
2c9cfe2f0860
Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents:
150
diff
changeset
|
1756 | $sql .= "', taste_notes='" . mysqli_real_escape_string($db, $recipe->TASTE_NOTES); |
2c9cfe2f0860
Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents:
150
diff
changeset
|
1757 | $sql .= "', taste_rate='" . floatval($recipe->TASTING_RATE); |
108 | 1758 | $tdate = substr($recipe->TASTE_DATE, 6, 4).substr($recipe->TASTE_DATE,2,4).substr($recipe->TASTE_DATE,0,2); |
151
2c9cfe2f0860
Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents:
150
diff
changeset
|
1759 | $sql .= "', taste_date='" . $tdate; |
2c9cfe2f0860
Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents:
150
diff
changeset
|
1760 | $sql .= "', taste_color='" . mysqli_real_escape_string($db, $recipe->TASTE_COLOR); |
2c9cfe2f0860
Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents:
150
diff
changeset
|
1761 | $sql .= "', taste_transparency='" . mysqli_real_escape_string($db, $recipe->TASTE_TRANSPARENCY); |
2c9cfe2f0860
Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents:
150
diff
changeset
|
1762 | $sql .= "', taste_head='" . mysqli_real_escape_string($db, $recipe->TASTE_HEAD); |
2c9cfe2f0860
Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents:
150
diff
changeset
|
1763 | $sql .= "', taste_aroma='" . mysqli_real_escape_string($db, $recipe->TASTE_AROMA); |
2c9cfe2f0860
Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents:
150
diff
changeset
|
1764 | $sql .= "', taste_taste='" . mysqli_real_escape_string($db, $recipe->TASTE_TASTE); |
2c9cfe2f0860
Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents:
150
diff
changeset
|
1765 | $sql .= "', taste_mouthfeel='" . mysqli_real_escape_string($db, $recipe->TASTE_MOUTHFEEL); |
2c9cfe2f0860
Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents:
150
diff
changeset
|
1766 | $sql .= "', taste_aftertaste='" . mysqli_real_escape_string($db, $recipe->TASTE_AFTERTASTE); |
108 | 1767 | } |
1768 | ||
151
2c9cfe2f0860
Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents:
150
diff
changeset
|
1769 | ($recipe->INVENTORY_REDUCED == 'TRUE') ? $sql .= "', inventory_reduced='1" : $sql .= "', inventory_reduced='0"; |
234
b8b5efa495bb
Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
1770 | if (($recipe->LOCKED == 'TRUE') && ($stage == 10)) { |
151
2c9cfe2f0860
Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents:
150
diff
changeset
|
1771 | $sql .= "', locked='1"; |
234
b8b5efa495bb
Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents:
230
diff
changeset
|
1772 | $stage = 11; |
108 | 1773 | } else { |
151
2c9cfe2f0860
Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents:
150
diff
changeset
|
1774 | $sql .= "', locked='0"; |
108 | 1775 | } |
1776 | ||
151
2c9cfe2f0860
Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents:
150
diff
changeset
|
1777 | $sql .= "', stage='" . $stage; |
108 | 1778 | // echo ' '.$brewdate.' '.$recipe->NR_RECIPE.' '.$stage . PHP_EOL; |
1779 | ||
151
2c9cfe2f0860
Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents:
150
diff
changeset
|
1780 | $sql .= "';"; |
2c9cfe2f0860
Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents:
150
diff
changeset
|
1781 | if (! $rresult = mysqli_query($db, $sql)) { |
106
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1782 | printf("Error: %s\n", mysqli_error($db)); |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1783 | } |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1784 | } |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1785 | } |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1786 | |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1787 | |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1788 | |
64
5d5fc6f7cbfe
Improved recipes import. Finished inventory_suppliers.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
1789 | do_fermentables(); |
5d5fc6f7cbfe
Improved recipes import. Finished inventory_suppliers.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
1790 | do_hops(); |
5d5fc6f7cbfe
Improved recipes import. Finished inventory_suppliers.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
1791 | do_yeasts(); |
5d5fc6f7cbfe
Improved recipes import. Finished inventory_suppliers.
Michiel Broek <mbroek@mbse.eu>
parents:
61
diff
changeset
|
1792 | do_miscs(); |
432
99dcd8488b62
Merged brew_sparge_temperature with sparge_temp and brew_sparge_volume with sparge_volume.
Michiel Broek <mbroek@mbse.eu>
parents:
278
diff
changeset
|
1793 | do_waters(); |
99dcd8488b62
Merged brew_sparge_temperature with sparge_temp and brew_sparge_volume with sparge_volume.
Michiel Broek <mbroek@mbse.eu>
parents:
278
diff
changeset
|
1794 | do_equipments(); |
99dcd8488b62
Merged brew_sparge_temperature with sparge_temp and brew_sparge_volume with sparge_volume.
Michiel Broek <mbroek@mbse.eu>
parents:
278
diff
changeset
|
1795 | do_styles(); |
99dcd8488b62
Merged brew_sparge_temperature with sparge_temp and brew_sparge_volume with sparge_volume.
Michiel Broek <mbroek@mbse.eu>
parents:
278
diff
changeset
|
1796 | do_mash(); |
106
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1797 | do_recipes(); |
c64d979613ab
Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents:
105
diff
changeset
|
1798 | do_brews(); |
48
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
1799 | |
11 | 1800 | |
1801 | mysqli_close($db); | |
1802 | ||
1803 | echo "Finished adding data\n"; | |
1804 | ||
1805 | ||
1806 | ?> |