www/import/from_brouwhulp.php

Tue, 29 Jan 2019 21:52:08 +0100

author
Michiel Broek <mbroek@mbse.eu>
date
Tue, 29 Jan 2019 21:52:08 +0100
changeset 220
14e349ff2a10
parent 217
318aab371497
child 223
0de4455bd2a1
permissions
-rw-r--r--

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.

11
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1 <?php
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2 /*
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3 * Import inventory from brouwhulp
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4 */
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6 require("../config.php");
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7 require("../version.php");
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8 require("../includes/formulas.php");
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10 echo "Start adding data from brouwhulp\n";
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12 $db = mysqli_connect(DBASE_HOST, DBASE_USER, DBASE_PASS, DBASE_NAME);
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13 if (! $db) {
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14 die('Connect Error (' . mysqli_connect_errno() . ') ' . mysqli_connect_error());
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
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
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
17
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
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
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
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
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
40 function do_fermentables()
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
41 {
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
42 global $brouwhulp, $db;
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
43
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
44 echo " Start adding fermentables to the database\n";
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
45 $sql = "TRUNCATE TABLE inventory_fermentables;";
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
46 if (! $result = mysqli_query($db, $sql)) {
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
47 printf("Error: %s\n", mysqli_error($db));
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
48 }
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
49 $myfermentables = simplexml_load_file($brouwhulp . '/fermentables.xml');
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
50
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
51 foreach ($myfermentables->FERMENTABLE as $fermentable) {
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
52
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
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
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
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
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
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
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
70 }
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
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
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
85 $sql .= "', origin='" . mysqli_real_escape_string($db, $fermentable->ORIGIN);
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
86 $sql .= "', supplier='" . mysqli_real_escape_string($db, $fermentable->SUPPLIER);
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
87 $sql .= "', notes='" . mysqli_real_escape_string($db, $fermentable->NOTES);
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
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
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
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
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
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
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
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
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
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
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
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
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
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
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
106 /*
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
107 * These are not beerxml standard:
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
108 */
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
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
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
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
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
129 $sql .= "';";
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
130 if (! $result = mysqli_query($db, $sql)) {
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
131 printf("Error: %s\n", mysqli_error($db));
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
132 }
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
133 }
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
134 }
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
135
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
136
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
137 function do_hops()
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
138 {
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
139 global $brouwhulp, $db;
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
140
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
141 echo " Start adding hops to the database\n";
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
142 $sql = "TRUNCATE TABLE inventory_hops;";
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
143 if (! $result = mysqli_query($db, $sql)) {
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
144 printf("Error: %s\n", mysqli_error($db));
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
145 }
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
146
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
147 $myhops = simplexml_load_file($brouwhulp . '/hops.xml');
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
148
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
149 foreach ($myhops->HOP as $hop) {
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
150
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
151 $sql = "INSERT INTO inventory_hops SET name='" . mysqli_real_escape_string($db, $hop->NAME);
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
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
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
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
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
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);
11
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
158 if ($hop->CARYOPHYLLENE)
118
07daa505d309 Improved float precision for databases import.
Michiel Broek <mbroek@mbse.eu>
parents: 114
diff changeset
159 $sql .= "', caryophyllene='" . floatval($hop->CARYOPHYLLENE);
11
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
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);
11
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
162 if ($hop->MYCRENE)
118
07daa505d309 Improved float precision for databases import.
Michiel Broek <mbroek@mbse.eu>
parents: 114
diff changeset
163 $sql .= "', myrcene='" . floatval($hop->MYCRENE);
11
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
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
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
185 $sql .= "', notes='" . mysqli_real_escape_string($db, $hop->NOTES);
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
186 $sql .= "', origin='" . mysqli_real_escape_string($db, $hop->ORIGIN);
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
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
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
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
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
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
b8c3ca152984 Added hops inventory
Michiel Broek <mbroek@mbse.eu>
parents: 11
diff changeset
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
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
199 $sql .= "';";
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
200 if (! $result = mysqli_query($db, $sql)) {
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
201 printf("Error: %s\n", mysqli_error($db));
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
202 }
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
203 }
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
204
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
205 }
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
206
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
207
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
208
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
209 function do_yeasts()
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
210 {
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
211 global $brouwhulp, $db;
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
212
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
213 echo " Start adding yeasts to the database\n";
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
214 $sql = "TRUNCATE TABLE inventory_yeasts;";
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
215 if (! $result = mysqli_query($db, $sql)) {
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
216 printf("Error: %s\n", mysqli_error($db));
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
217 }
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
218
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
219 $yeasts = simplexml_load_file($brouwhulp . '/yeasts.xml');
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
220
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
221 foreach ($yeasts->YEAST as $yeast) {
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
222
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
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
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
253 $sql .= "', laboratory='" . mysqli_real_escape_string($db, $yeast->LABORATORY);
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
254 $sql .= "', product_id='" . mysqli_real_escape_string($db, $yeast->PRODUCT_ID);
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
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
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
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
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
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
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
273 $sql .= "', notes='" . mysqli_real_escape_string($db, $yeast->NOTES);
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
274 $sql .= "', best_for='" . mysqli_real_escape_string($db, $yeast->BEST_FOR);
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
275 if ($yeast->MAX_REUSE)
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
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
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
300 if ($yeast->CULTURE_DATE) {
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
301 $date = substr($yeast->CULTURE_DATE, 6, 4) . '-' . substr($yeast->CULTURE_DATE, 3, 2) . '-' . substr($yeast->CULTURE_DATE, 0, 2);
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
302 $sql .= "', production_date='" . $date;
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
303 }
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
304 $sql .= "';";
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
305 if (! $result = mysqli_query($db, $sql)) {
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
306 printf("Error: %s\n", mysqli_error($db));
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
307 }
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
308 }
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
309 }
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
310
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
311
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
312
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
313 function do_waters()
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
314 {
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
315 global $brouwhulp, $db;
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
316
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
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
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
319 if (! $result = mysqli_query($db, $sql)) {
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
320 printf("Error: %s\n", mysqli_error($db));
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
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
ccbe79db80b8 Waters import and home page
Michiel Broek <mbroek@mbse.eu>
parents: 13
diff changeset
323 if (! $result = mysqli_query($db, $sql)) {
ccbe79db80b8 Waters import and home page
Michiel Broek <mbroek@mbse.eu>
parents: 13
diff changeset
324 printf("Error: %s\n", mysqli_error($db));
ccbe79db80b8 Waters import and home page
Michiel Broek <mbroek@mbse.eu>
parents: 13
diff changeset
325 }
11
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
326
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
327 $waters = simplexml_load_file($brouwhulp . '/waters.xml');
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
328
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
329 foreach ($waters->WATER as $water) {
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
330
15
ccbe79db80b8 Waters import and home page
Michiel Broek <mbroek@mbse.eu>
parents: 13
diff changeset
331 if (($water->NAME == "Gedemineraliseerd water") || ($water->NAME == "Cristalline") || ($water->NAME == "Montille (Delhaize)") ||
ccbe79db80b8 Waters import and home page
Michiel Broek <mbroek@mbse.eu>
parents: 13
diff changeset
332 ($water->NAME == "Spa Reine") || ($water->NAME == "Velsen") || ($water->NAME == "Zutphen") ||
ccbe79db80b8 Waters import and home page
Michiel Broek <mbroek@mbse.eu>
parents: 13
diff changeset
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
ccbe79db80b8 Waters import and home page
Michiel Broek <mbroek@mbse.eu>
parents: 13
diff changeset
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
ccbe79db80b8 Waters import and home page
Michiel Broek <mbroek@mbse.eu>
parents: 13
diff changeset
337 }
ccbe79db80b8 Waters import and home page
Michiel Broek <mbroek@mbse.eu>
parents: 13
diff changeset
338
11
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
339 if ($water->NOTES)
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
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
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
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
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
350 $sql .= "';";
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
351 if (! $result = mysqli_query($db, $sql)) {
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
352 printf("Error: %s\n", mysqli_error($db));
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
353 }
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
354 }
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
355 }
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
356
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
357
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
358
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
359 function do_miscs()
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
360 {
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
361 global $brouwhulp, $db;
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
362
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
363 echo " Start adding miscs to the database\n";
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
364 $sql = "TRUNCATE TABLE inventory_miscs;";
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
365 if (! $result = mysqli_query($db, $sql)) {
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
366 printf("Error: %s\n", mysqli_error($db));
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
367 }
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
368
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
369 $miscs = simplexml_load_file($brouwhulp . '/miscs.xml');
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
370
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
371 foreach ($miscs->MISC as $misc) {
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
372
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
373 $sql = "INSERT INTO inventory_miscs SET name='" . mysqli_real_escape_string($db, $misc->NAME);
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
374 if ($misc->NOTES)
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
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
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
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
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
411 if ($misc->USE_FOR)
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
412 $sql .= "', use_for='" . mysqli_real_escape_string($db, $misc->USE_FOR);
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
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
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
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
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
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
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
419 $sql .= "';";
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
420 if (! $result = mysqli_query($db, $sql)) {
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
421 printf("Error: %s\n", mysqli_error($db));
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
422 }
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
423 }
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
424 }
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
425
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
426
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
427
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
428 function do_equipments()
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
429 {
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
430 global $brouwhulp, $db;
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
431
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
432 echo " Start adding equipments to the database\n";
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
433 $sql = "TRUNCATE TABLE inventory_equipments;";
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
434 if (! $result = mysqli_query($db, $sql)) {
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
435 printf("Error: %s\n", mysqli_error($db));
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
436 }
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
437
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
438 $equipments = simplexml_load_file($brouwhulp . '/equipments.xml');
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
439
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
440 foreach ($equipments->EQUIPMENT as $equipment) {
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
441
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
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
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
461 /*
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
462 * Brouwhulp uses a percentage for the evaporation rate. This is wrong
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
463 * but was made so because the beerxml standard requires this. What we
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
464 * do is calculate the actual evaporation and store that.
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
465 * This is what we use. Brouwhulp calculates this on the fly.
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
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
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
472 if ($equipment->NOTES)
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
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
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
482 $sql .= "';";
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
483 if (! $result = mysqli_query($db, $sql)) {
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
484 printf("Error: %s\n", mysqli_error($db));
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
485 }
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
486 }
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
487 }
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
488
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
489
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
490
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
491 function do_styles()
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
492 {
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
493 global $brouwhulp, $db;
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
494
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
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
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
497 if (! $result = mysqli_query($db, $sql)) {
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
498 printf("Error: %s\n", mysqli_error($db));
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
499 }
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
500
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
501 $styles = simplexml_load_file($brouwhulp . '/styles.xml');
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
502
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
503 foreach ($styles->STYLE as $style) {
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
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
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
506 if ($style->NOTES)
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
507 $sql .= "', notes='" . mysqli_real_escape_string($db, $style->NOTES);
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
508 if ($style->CATEGORY)
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
509 $sql .= "', category='" . mysqli_real_escape_string($db, $style->CATEGORY);
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
510 if ($style->CATEGORY_NUMBER)
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
511 $sql .= "', category_number='" . $style->CATEGORY_NUMBER;
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
512 if ($style->STYLE_LETTER)
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
513 $sql .= "', style_letter='" . mysqli_real_escape_string($db, $style->STYLE_LETTER);
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
514 if ($style->STYLE_GUIDE)
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
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
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
544 if ($style->PROFILE)
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
545 $sql .= "', profile='" . mysqli_real_escape_string($db, $style->PROFILE);
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
546 if ($style->INGREDIENTS)
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
547 $sql .= "', ingredients='" . mysqli_real_escape_string($db, $style->INGREDIENTS);
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
548 if ($style->EXAMPLES)
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
549 $sql .= "', examples='" . mysqli_real_escape_string($db, $style->EXAMPLES);
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
550
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
551 $sql .= "';";
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
552 if (! $result = mysqli_query($db, $sql)) {
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
553 printf("Error: %s\n", mysqli_error($db));
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
554 }
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
555 }
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
556 }
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
557
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
558
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
559
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
560 function do_mash()
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
561 {
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
562 global $brouwhulp, $db;
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
563
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
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
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
566 if (! $result = mysqli_query($db, $sql)) {
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
567 printf("Error: %s\n", mysqli_error($db));
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
568 }
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
569
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
570 $mashes = simplexml_load_file($brouwhulp . '/mashs.xml');
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
571
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
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
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
574 if ($mash->NOTES)
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
575 $sql .= "', notes='" . mysqli_real_escape_string($db, $mash->NOTES);
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
576
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
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
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
579 */
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
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
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
583 foreach ($mash->MASH_STEPS->MASH_STEP as $step) {
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
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
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
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
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
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
d6314a95021c Enabled mash
Michiel Broek <mbroek@mbse.eu>
parents: 32
diff changeset
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
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
617 }
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
618 }
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
619 }
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
620
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
621
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
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);
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
878 $hops .= ',"h_carophyllene":' . floatval($hop->CAROPHYLLENE);
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) . '"';
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
974 $yeasts .= ',"y_amount":' . floatval($yeast->AMOUNT);
131
71f1ca48c551 When importing recipes with liquid yeast divide the cost by the pack volume. Don't allow alpha editing of hops in a recipe. Fix hop use time when the hop is used when not boiling and set the fixed time.
Michiel Broek <mbroek@mbse.eu>
parents: 126
diff changeset
975 if ($yeast->COST) {
71f1ca48c551 When importing recipes with liquid yeast divide the cost by the pack volume. Don't allow alpha editing of hops in a recipe. Fix hop use time when the hop is used when not boiling and set the fixed time.
Michiel Broek <mbroek@mbse.eu>
parents: 126
diff changeset
976 if (($yeast->FORM == "Liquid") && ($yeast->AMOUNT == "0.0588")) { // Packs
71f1ca48c551 When importing recipes with liquid yeast divide the cost by the pack volume. Don't allow alpha editing of hops in a recipe. Fix hop use time when the hop is used when not boiling and set the fixed time.
Michiel Broek <mbroek@mbse.eu>
parents: 126
diff changeset
977 $yeasts .= ',"y_cost":' . floatval($yeast->COST) / 58.8;
71f1ca48c551 When importing recipes with liquid yeast divide the cost by the pack volume. Don't allow alpha editing of hops in a recipe. Fix hop use time when the hop is used when not boiling and set the fixed time.
Michiel Broek <mbroek@mbse.eu>
parents: 126
diff changeset
978 } else {
71f1ca48c551 When importing recipes with liquid yeast divide the cost by the pack volume. Don't allow alpha editing of hops in a recipe. Fix hop use time when the hop is used when not boiling and set the fixed time.
Michiel Broek <mbroek@mbse.eu>
parents: 126
diff changeset
979 $yeasts .= ',"y_cost":' . floatval($yeast->COST);
71f1ca48c551 When importing recipes with liquid yeast divide the cost by the pack volume. Don't allow alpha editing of hops in a recipe. Fix hop use time when the hop is used when not boiling and set the fixed time.
Michiel Broek <mbroek@mbse.eu>
parents: 126
diff changeset
980 }
71f1ca48c551 When importing recipes with liquid yeast divide the cost by the pack volume. Don't allow alpha editing of hops in a recipe. Fix hop use time when the hop is used when not boiling and set the fixed time.
Michiel Broek <mbroek@mbse.eu>
parents: 126
diff changeset
981 } else
106
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
982 $yeasts .= ',"y_cost":0';
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
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
1017 ($yeast->AMOUNT_IS_WEIGHT== "TRUE") ? $yeasts .= ',"y_amount_is_weight":1' : $yeasts.= ',"y_amount_is_weight":0';
106
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1018 if ($yeast->ADD_TO_SECONDARY=="FALSE") {
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
1019 $yeasts .= ',"y_use":0'; // Primary
106
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1020 $svg = floatval($yeast->ATTENUATION);
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1021 } else if ($yeast->PRODUCT_ID=="F2") {
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
1022 $yeasts .= ',"y_use":3'; // Bottle
106
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1023 } 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
1024 $yeasts .= ',"y_use":1'; // Secondary
106
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1025 }
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1026 $yeasts .= ',"y_min_temperature":' . floatval($yeast->MIN_TEMPERATURE);
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1027 $yeasts .= ',"y_max_temperature":' . floatval($yeast->MAX_TEMPERATURE);
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1028 $yeasts .= ',"y_attenuation":' . floatval($yeast->ATTENUATION);
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1029 $yeasts .= "}";
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1030 }
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1031 $yeasts .= ']';
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1032 return $yeasts;
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1033 }
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1034
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1035 function recipe_waters($recipe, $db)
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1036 {
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
1037 $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
1038 $index = 0;
106
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1039 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
1040 $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
1041 $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
1042 $waters .= "', w" . $index . "_amount='" . floatval($water->AMOUNT);
106
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1043 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
1044 $waters .= "', w" . $index . "_calcium='" . floatval($water->CALCIUM);
106
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1045 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
1046 $waters .= "', w" . $index . "_sulfate='" . floatval($water->SULFATE);
106
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1047 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
1048 $waters .= "', w" . $index . "_chloride='" . floatval($water->CHLORIDE);
106
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1049 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
1050 $waters .= "', w" . $index . "_sodium='" . floatval($water->SODIUM);
106
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1051 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
1052 $waters .= "', w" . $index . "_magnesium='" . floatval($water->MAGNESIUM);
106
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1053 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
1054 $waters .= "', w" . $index . "_ph='" . floatval($water->PH);
106
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1055 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
1056 $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
1057 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
1058 $waters .= "', w" . $index . "_cost='" . floatval($water->COST);
106
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1059 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
1060 $waters .= "', w" . $index . "_cost='0";
106
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1061 }
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1062 return $waters;
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1063 }
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1064
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
1065
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
1066
106
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1067 function recipe_mash_steps($recipe)
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1068 {
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1069 global $db;
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1070
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1071 $steps = '[';
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1072 $comma = FALSE;
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1073 foreach ($recipe->MASH->MASH_STEPS->MASH_STEP as $step) {
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1074 if ($comma)
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1075 $steps .= ',';
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1076 $comma = TRUE;
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1077 $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
1078
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
1079 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
1080 $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
1081 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
1082 $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
1083 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
1084 $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
1085 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
1086 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
1087
106
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1088 if ($step->INFUSE_AMOUNT)
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1089 $steps .= ',"step_infuse_amount":"' . floatval($step->INFUSE_AMOUNT) . '"';
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1090 if ($step->STEP_TEMP)
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1091 $steps .= ',"step_temp":"' . floatval($step->STEP_TEMP) . '"';
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1092 if ($step->STEP_TIME)
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1093 $steps .= ',"step_time":"' . floatval($step->STEP_TIME) . '"';
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1094 if ($step->RAMP_TIME)
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1095 $steps .= ',"ramp_time":"' . floatval($step->RAMP_TIME) . '"';
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1096 if ($step->END_TEMP)
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1097 $steps .= ',"end_temp":"' . floatval($step->END_TEMP) . '"';
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1098 $steps .= "}";
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1099 }
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1100 $steps .= ']';
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1101 return $steps;
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1102 }
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1103
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1104
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1105
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1106 function do_recipes()
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1107 {
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
1108 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
1109 $len_fermentables = 0;
bdd1ec9b9c06 Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents: 45
diff changeset
1110 $len_hops = 0;
bdd1ec9b9c06 Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents: 45
diff changeset
1111 $len_miscs = 0;
49
4d27a7fb1265 Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents: 48
diff changeset
1112 $len_yeasts = 0;
48
bdd1ec9b9c06 Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents: 45
diff changeset
1113 $len_mash = 0;
bdd1ec9b9c06 Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents: 45
diff changeset
1114
106
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1115 echo " Start adding recipes to the database\n";
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1116 $sql = "TRUNCATE TABLE recipes;";
48
bdd1ec9b9c06 Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents: 45
diff changeset
1117 if (! $result = mysqli_query($db, $sql)) {
bdd1ec9b9c06 Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents: 45
diff changeset
1118 printf("Error: %s\n", mysqli_error($db));
bdd1ec9b9c06 Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents: 45
diff changeset
1119 }
bdd1ec9b9c06 Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents: 45
diff changeset
1120
106
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1121 $recipes = simplexml_load_file($brouwhulp . '/recipes.xml');
48
bdd1ec9b9c06 Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents: 45
diff changeset
1122
bdd1ec9b9c06 Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents: 45
diff changeset
1123 foreach ($recipes->RECIPE as $recipe) {
86
e977a505ea8c With recipe import calculate the OG
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
1124 $f_sugars = 0;
e977a505ea8c With recipe import calculate the OG
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
1125 $efficiency = 75;
e977a505ea8c With recipe import calculate the OG
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
1126 $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
1127 $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
1128 $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
1129 $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
1130 $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
1131 $colorw = 0;
105
d06ddc4d1af0 Added uuid and locked fields to the recipes table.
Michiel Broek <mbroek@mbse.eu>
parents: 104
diff changeset
1132 $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
1133
106
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1134 $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
1135 $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
1136 $sql .= "', locked='0";
48
bdd1ec9b9c06 Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents: 45
diff changeset
1137 if ($recipe->NOTES)
bdd1ec9b9c06 Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents: 45
diff changeset
1138 $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
1139 else
5d5fc6f7cbfe Improved recipes import. Finished inventory_suppliers.
Michiel Broek <mbroek@mbse.eu>
parents: 61
diff changeset
1140 $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
1141
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
1142 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
1143 $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
1144 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
1145 $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
1146 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
1147 $sql .= "', type='2";
64
5d5fc6f7cbfe Improved recipes import. Finished inventory_suppliers.
Michiel Broek <mbroek@mbse.eu>
parents: 61
diff changeset
1148 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
1149 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
1150
48
bdd1ec9b9c06 Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents: 45
diff changeset
1151 if ($recipe->BATCH_SIZE)
86
e977a505ea8c With recipe import calculate the OG
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
1152 $batch_size = floatval($recipe->BATCH_SIZE);
e977a505ea8c With recipe import calculate the OG
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
1153 $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
1154 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
1155 $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
1156 $sql .= "', boil_size='" . $boil_size;
48
bdd1ec9b9c06 Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents: 45
diff changeset
1157 if ($recipe->BOIL_TIME)
bdd1ec9b9c06 Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents: 45
diff changeset
1158 $sql .= "', boil_time='" . floatval($recipe->BOIL_TIME);
64
5d5fc6f7cbfe Improved recipes import. Finished inventory_suppliers.
Michiel Broek <mbroek@mbse.eu>
parents: 61
diff changeset
1159 else
5d5fc6f7cbfe Improved recipes import. Finished inventory_suppliers.
Michiel Broek <mbroek@mbse.eu>
parents: 61
diff changeset
1160 $sql .= "', boil_time='90";
48
bdd1ec9b9c06 Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents: 45
diff changeset
1161 if ($recipe->EFFICIENCY)
86
e977a505ea8c With recipe import calculate the OG
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
1162 $efficiency = floatval($recipe->EFFICIENCY);
e977a505ea8c With recipe import calculate the OG
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
1163 $sql .= "', efficiency='" . $efficiency;
e977a505ea8c With recipe import calculate the OG
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
1164 /* 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
1165 /* 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
1166 /* Don't use $recipe->EST_COLOR but recalculate it */
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
1167 if ($recipe->COLOR_METHOD == 'Morey')
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
1168 $sql .= "', color_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
1169 else if ($recipe->COLOR_METHOD == 'Mosher')
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
1170 $sql .= "', color_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
1171 else if ($recipe->COLOR_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
1172 $sql .= "', color_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
1173 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
1174 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
1175
48
bdd1ec9b9c06 Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents: 45
diff changeset
1176 if ($recipe->IBU)
bdd1ec9b9c06 Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents: 45
diff changeset
1177 $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
1178 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
1179 $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
1180 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
1181 $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
1182 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
1183 $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
1184 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
1185 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
1186
102
679ddf512b65 Added est_carb field import in the recipes.
Michiel Broek <mbroek@mbse.eu>
parents: 100
diff changeset
1187 if ($recipe->CARBONATION)
679ddf512b65 Added est_carb field import in the recipes.
Michiel Broek <mbroek@mbse.eu>
parents: 100
diff changeset
1188 $sql .= "', est_carb='" . floatval($recipe->CARBONATION);
48
bdd1ec9b9c06 Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents: 45
diff changeset
1189
bdd1ec9b9c06 Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents: 45
diff changeset
1190 if ($recipe->STYLE) {
106
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1191 $sql .= recipe_style($recipe);
48
bdd1ec9b9c06 Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents: 45
diff changeset
1192 }
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
1193 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
1194 ($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
1195 }
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
1196 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
1197 $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
1198 }
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
1199 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
1200 $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
1201 } 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
1202 $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
1203 } 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
1204 $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
1205 } 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
1206 $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
1207 }
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
1208 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
1209 $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
1210 }
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 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
1212 $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
1213 }
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 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
1215 $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
1216 }
48
bdd1ec9b9c06 Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents: 45
diff changeset
1217
bdd1ec9b9c06 Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents: 45
diff changeset
1218 /*
bdd1ec9b9c06 Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents: 45
diff changeset
1219 * Put the fermentables in a json array
bdd1ec9b9c06 Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents: 45
diff changeset
1220 */
bdd1ec9b9c06 Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents: 45
diff changeset
1221 if ($recipe->FERMENTABLES) {
106
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1222 $fermentables = recipe_fermentables($recipe);
48
bdd1ec9b9c06 Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents: 45
diff changeset
1223 $sql .= "', json_fermentables='" . $fermentables;
bdd1ec9b9c06 Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents: 45
diff changeset
1224 if (strlen($fermentables) > $len_fermentables)
bdd1ec9b9c06 Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents: 45
diff changeset
1225 $len_fermentables = strlen($fermentables);
bdd1ec9b9c06 Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents: 45
diff changeset
1226 }
bdd1ec9b9c06 Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents: 45
diff changeset
1227
bdd1ec9b9c06 Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents: 45
diff changeset
1228 /*
bdd1ec9b9c06 Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents: 45
diff changeset
1229 * Put the hops in a json array
bdd1ec9b9c06 Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents: 45
diff changeset
1230 */
bdd1ec9b9c06 Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents: 45
diff changeset
1231 if ($recipe->HOPS) {
106
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1232 $hops = recipe_hops($recipe);
48
bdd1ec9b9c06 Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents: 45
diff changeset
1233 $sql .= "', json_hops='" . $hops;
bdd1ec9b9c06 Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents: 45
diff changeset
1234 if (strlen($hops) > $len_hops)
bdd1ec9b9c06 Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents: 45
diff changeset
1235 $len_hops = strlen($hops);
bdd1ec9b9c06 Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents: 45
diff changeset
1236 }
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 /*
bdd1ec9b9c06 Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents: 45
diff changeset
1239 * Put the miscs in a json array
bdd1ec9b9c06 Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents: 45
diff changeset
1240 */
bdd1ec9b9c06 Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents: 45
diff changeset
1241 if ($recipe->MISCS) {
106
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1242 $miscs = recipe_miscs($recipe);
48
bdd1ec9b9c06 Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents: 45
diff changeset
1243 $sql .= "', json_miscs='" . $miscs;
bdd1ec9b9c06 Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents: 45
diff changeset
1244 if (strlen($miscs) > $len_miscs)
bdd1ec9b9c06 Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents: 45
diff changeset
1245 $len_miscs = strlen($miscs);
bdd1ec9b9c06 Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents: 45
diff changeset
1246 }
bdd1ec9b9c06 Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents: 45
diff changeset
1247
49
4d27a7fb1265 Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents: 48
diff changeset
1248 /*
4d27a7fb1265 Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents: 48
diff changeset
1249 * Put the yeasts in a json array
4d27a7fb1265 Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents: 48
diff changeset
1250 */
4d27a7fb1265 Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents: 48
diff changeset
1251 if ($recipe->YEASTS) {
106
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1252 $yeasts = recipe_yeasts($recipe);
49
4d27a7fb1265 Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents: 48
diff changeset
1253 $sql .= "', json_yeasts='" . $yeasts;
4d27a7fb1265 Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents: 48
diff changeset
1254 if (strlen($yeasts) > $len_yeasts)
4d27a7fb1265 Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents: 48
diff changeset
1255 $len_yeasts = strlen($yeasts);
4d27a7fb1265 Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents: 48
diff changeset
1256 }
4d27a7fb1265 Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents: 48
diff changeset
1257
4d27a7fb1265 Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents: 48
diff changeset
1258 /*
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
1259 * Get the waters
49
4d27a7fb1265 Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents: 48
diff changeset
1260 */
4d27a7fb1265 Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents: 48
diff changeset
1261 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
1262 $sql .= recipe_waters($recipe, $db);
49
4d27a7fb1265 Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents: 48
diff changeset
1263 }
4d27a7fb1265 Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents: 48
diff changeset
1264
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 mash 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->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
1269 $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
1270 $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
1271 if ($recipe->MASH->NAME)
51
7224109adfe1 More recipe editor changes
Michiel Broek <mbroek@mbse.eu>
parents: 50
diff changeset
1272 $sql .= "',mash_name='" . mysqli_real_escape_string($db, $recipe->MASH->NAME);
7224109adfe1 More recipe editor changes
Michiel Broek <mbroek@mbse.eu>
parents: 50
diff changeset
1273
49
4d27a7fb1265 Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents: 48
diff changeset
1274 if ($recipe->MASH->MASH_STEPS) {
106
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1275 $steps = recipe_mash_steps($recipe);
51
7224109adfe1 More recipe editor changes
Michiel Broek <mbroek@mbse.eu>
parents: 50
diff changeset
1276 $sql .= "', json_mashs='" . $steps;
7224109adfe1 More recipe editor changes
Michiel Broek <mbroek@mbse.eu>
parents: 50
diff changeset
1277 if (strlen($steps) > $len_mash)
7224109adfe1 More recipe editor changes
Michiel Broek <mbroek@mbse.eu>
parents: 50
diff changeset
1278 $len_mash = strlen($steps);
49
4d27a7fb1265 Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents: 48
diff changeset
1279 }
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
86
e977a505ea8c With recipe import calculate the OG
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
1282 /*
e977a505ea8c With recipe import calculate the OG
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
1283 * Added the calculated values
e977a505ea8c With recipe import calculate the OG
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
1284 * OG, FG, color, IBU
e977a505ea8c With recipe import calculate the OG
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
1285 */
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
1286 $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
1287 $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
1288 $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
1289 $sql .= "', est_fg='" . floatval($fg);
88
0a39cbdcf085 Added ABV clculation.
Michiel Broek <mbroek@mbse.eu>
parents: 87
diff changeset
1290 $abv = abvol($og, $fg);
0a39cbdcf085 Added ABV clculation.
Michiel Broek <mbroek@mbse.eu>
parents: 87
diff changeset
1291 $sql .= "', est_abv='" . floatval($abv);
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
1292 $color = kw_to_ebc(mysqli_real_escape_string($db, $recipe->COLOR_METHOD), $colorw);
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
1293 $sql .= "', est_color='" . floatval($color);
48
bdd1ec9b9c06 Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents: 45
diff changeset
1294 $sql .= "';";
bdd1ec9b9c06 Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents: 45
diff changeset
1295 if (! $result = mysqli_query($db, $sql)) {
bdd1ec9b9c06 Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents: 45
diff changeset
1296 printf("Error: %s\n", mysqli_error($db));
bdd1ec9b9c06 Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents: 45
diff changeset
1297 }
bdd1ec9b9c06 Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents: 45
diff changeset
1298 }
64
5d5fc6f7cbfe Improved recipes import. Finished inventory_suppliers.
Michiel Broek <mbroek@mbse.eu>
parents: 61
diff changeset
1299 // echo "Fermentables: " . $len_fermentables . PHP_EOL;
5d5fc6f7cbfe Improved recipes import. Finished inventory_suppliers.
Michiel Broek <mbroek@mbse.eu>
parents: 61
diff changeset
1300 // echo "Hops: " . $len_hops . PHP_EOL;
5d5fc6f7cbfe Improved recipes import. Finished inventory_suppliers.
Michiel Broek <mbroek@mbse.eu>
parents: 61
diff changeset
1301 // echo "Miscs: " . $len_miscs . PHP_EOL;
5d5fc6f7cbfe Improved recipes import. Finished inventory_suppliers.
Michiel Broek <mbroek@mbse.eu>
parents: 61
diff changeset
1302 // echo "Yeasts: " . $len_yeasts . PHP_EOL;
5d5fc6f7cbfe Improved recipes import. Finished inventory_suppliers.
Michiel Broek <mbroek@mbse.eu>
parents: 61
diff changeset
1303 // echo "Mash: " . $len_mash . PHP_EOL;
48
bdd1ec9b9c06 Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents: 45
diff changeset
1304 }
bdd1ec9b9c06 Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents: 45
diff changeset
1305
bdd1ec9b9c06 Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents: 45
diff changeset
1306
bdd1ec9b9c06 Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents: 45
diff changeset
1307
106
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1308 function do_brews()
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1309 {
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1310 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
1311 $len_fermentables = 0;
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1312 $len_hops = 0;
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1313 $len_miscs = 0;
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1314 $len_yeasts = 0;
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1315 $len_mash = 0;
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1316
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1317 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
1318 $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
1319 if (! $presult = mysqli_query($db, $sql)) {
106
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1320 printf("Error: %s\n", mysqli_error($db));
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1321 }
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1322
108
a466373bc23f Finished brews import
Michiel Broek <mbroek@mbse.eu>
parents: 107
diff changeset
1323 date_default_timezone_set('Europe/Amsterdam');
106
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1324 $recipes = simplexml_load_file($brouwhulp . '/brews.xml');
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1325
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1326 foreach ($recipes->RECIPE as $recipe) {
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1327 $f_sugars = 0;
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1328 $efficiency = 75;
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1329 $batch_size = 20;
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1330 $boil_size = 22;
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1331 $pCara = 0;
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1332 $pSugar = 0;
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1333 $svg = 77;
108
a466373bc23f Finished brews import
Michiel Broek <mbroek@mbse.eu>
parents: 107
diff changeset
1334 $colorw = 0;
150
159d7a89fcef Better stage detection during product import from brouwhulp. Added tooltips for treated water.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
1335 $stageno = 0;
108
a466373bc23f Finished brews import
Michiel Broek <mbroek@mbse.eu>
parents: 107
diff changeset
1336 $stage = "Plan"; // Default value.
106
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1337 $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
1338
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
1339 $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
1340 $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
1341
111
8c4ba91adf58 Basic screens for brew products.
Michiel Broek <mbroek@mbse.eu>
parents: 108
diff changeset
1342 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
1343 $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
1344 } 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
1345 $sql .= "', notes='";
111
8c4ba91adf58 Basic screens for brew products.
Michiel Broek <mbroek@mbse.eu>
parents: 108
diff changeset
1346 }
106
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1347 if ($recipe->TYPE)
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
1348 $sql .= "', type='" . mysqli_real_escape_string($db, $recipe->TYPE);
106
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1349 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
1350 $sql .= "', type='";
106
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1351 if ($recipe->BATCH_SIZE)
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1352 $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
1353 $sql .= "', batch_size='" . $batch_size;
106
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1354 if ($recipe->BOIL_SIZE)
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1355 $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
1356 $sql .= "', boil_size='" . $boil_size;
106
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1357 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
1358 $sql .= "', boil_time='" . floatval($recipe->BOIL_TIME);
106
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1359 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
1360 $sql .= "', boil_time='90";
106
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1361 if ($recipe->EFFICIENCY)
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1362 $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
1363 $sql .= "', efficiency='" . $efficiency;
106
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1364 /* Don't use $recipe->EST_OG but recalculate it */
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1365 /* Don't use $recipe->EST_FG but recalculate it */
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1366 /* Don't use $recipe->EST_COLOR but recalculate it */
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1367 if ($recipe->COLOR_METHOD)
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
1368 $sql .= "', color_method='" . mysqli_real_escape_string($db, $recipe->COLOR_METHOD);
106
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1369 if ($recipe->IBU)
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
1370 $sql .= "', est_ibu='" . floatval($recipe->IBU);
106
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1371 if ($recipe->IBU_METHOD)
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
1372 $sql .= "', ibu_method='" . mysqli_real_escape_string($db, $recipe->IBU_METHOD);
106
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1373 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
1374 $sql .= "', est_carb='" . floatval($recipe->CARBONATION);
106
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1375
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1376 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
1377 $sql .= recipe_style($recipe);
106
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1378 }
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1379
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
1380 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
1381 ($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
1382 }
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
1383 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
1384 $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
1385 }
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
1386 if ($recipe->SPARGE_ACID_TYPE && ($recipe->SPARGE_ACID_TYPE == "Lactic")) {
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
1387 $sql .= "', sparge_acid_type='Melkzuur";
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
1388 } else if ($recipe->SPARGE_ACID_TYPE && ($recipe->SPARGE_ACID_TYPE == "Hydrochloric")) {
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
1389 $sql .= "', sparge_acid_type='Zoutzuur";
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
1390 } else if ($recipe->SPARGE_ACID_TYPE && ($recipe->SPARGE_ACID_TYPE == "Phosphoric")) {
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
1391 $sql .= "', sparge_acid_type='Fosforzuur";
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
1392 } else if ($recipe->SPARGE_ACID_TYPE && ($recipe->SPARGE_ACID_TYPE == "Sulfuric")) {
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
1393 $sql .= "', sparge_acid_type='Zwavelzuur";
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
1394 }
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
1395 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
1396 $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
1397 }
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
1398 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
1399 $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
1400 }
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
1401 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
1402 $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
1403 }
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
1404
106
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1405 /*
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1406 * Put the fermentables in a json array
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1407 */
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1408 if ($recipe->FERMENTABLES) {
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1409 $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
1410 $sql .= "', json_fermentables='" . $fermentables;
106
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1411 if (strlen($fermentables) > $len_fermentables)
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1412 $len_fermentables = strlen($fermentables);
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
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1415 /*
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1416 * Put the hops in a json array
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1417 */
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1418 if ($recipe->HOPS) {
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1419 $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
1420 $sql .= "', json_hops='" . $hops;
106
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1421 if (strlen($hops) > $len_hops)
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1422 $len_hops = strlen($hops);
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1423 }
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1424
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1425 /*
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1426 * Put the miscs in a json array
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1427 */
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1428 if ($recipe->MISCS) {
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1429 $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
1430 $sql .= "', json_miscs='" . $miscs;
106
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1431 if (strlen($miscs) > $len_miscs)
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1432 $len_miscs = strlen($miscs);
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1433 }
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1434
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1435 /*
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1436 * Put the yeasts in a json array
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1437 */
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1438 if ($recipe->YEASTS) {
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1439 $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
1440 $sql .= "', json_yeasts='" . $yeasts;
106
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1441 if (strlen($yeasts) > $len_yeasts)
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1442 $len_yeasts = strlen($yeasts);
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1443 }
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 /*
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
1446 * Get the waters
106
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1447 */
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1448 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
1449 $sql .= recipe_waters($recipe, $db);
106
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1450 }
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1451
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 * Put the mash in a json array
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 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
1456 $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
1457 $sql .= "',sparge_ph='" . floatval($recipe->MASH->PH);
106
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1458 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
1459 $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
1460
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1461 if ($recipe->MASH->MASH_STEPS) {
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1462 $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
1463 $sql .= "', json_mashs='" . $steps;
106
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1464 if (strlen($steps) > $len_mash)
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1465 $len_mash = strlen($steps);
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 }
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1468
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1469 /*
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1470 * Added the calculated values
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1471 * OG, FG, color, IBU
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 $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
1474 $sql .= "', est_og='" . floatval($og);
106
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1475 $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
1476 $sql .= "', est_fg='" . floatval($fg);
106
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1477 $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
1478 $sql .= "', est_abv='" . floatval($abv);
106
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1479 $color = kw_to_ebc(mysqli_real_escape_string($db, $recipe->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
1480 $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
1481 $sql .= "', code='" . mysqli_real_escape_string($db, $recipe->NR_RECIPE);
108
a466373bc23f Finished brews import
Michiel Broek <mbroek@mbse.eu>
parents: 107
diff changeset
1482
a466373bc23f Finished brews import
Michiel Broek <mbroek@mbse.eu>
parents: 107
diff changeset
1483 /*
a466373bc23f Finished brews import
Michiel Broek <mbroek@mbse.eu>
parents: 107
diff changeset
1484 * Update external logfiles
a466373bc23f Finished brews import
Michiel Broek <mbroek@mbse.eu>
parents: 107
diff changeset
1485 */
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
1486 $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
1487 $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
1488 if (! $result = mysqli_query($db, $lsql)) {
108
a466373bc23f Finished brews import
Michiel Broek <mbroek@mbse.eu>
parents: 107
diff changeset
1489 printf("Error: %s\n", mysqli_error($db));
a466373bc23f Finished brews import
Michiel Broek <mbroek@mbse.eu>
parents: 107
diff changeset
1490 }
a466373bc23f Finished brews import
Michiel Broek <mbroek@mbse.eu>
parents: 107
diff changeset
1491 $count = mysqli_affected_rows($db);
a466373bc23f Finished brews import
Michiel Broek <mbroek@mbse.eu>
parents: 107
diff changeset
1492 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
1493 $sql .= "', log_brew='1";
108
a466373bc23f Finished brews import
Michiel Broek <mbroek@mbse.eu>
parents: 107
diff changeset
1494 }
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 $lsql = "UPDATE log_fermentation 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
1496 $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
1497 if (! $result = mysqli_query($db, $lsql)) {
108
a466373bc23f Finished brews import
Michiel Broek <mbroek@mbse.eu>
parents: 107
diff changeset
1498 printf("Error: %s\n", mysqli_error($db));
a466373bc23f Finished brews import
Michiel Broek <mbroek@mbse.eu>
parents: 107
diff changeset
1499 }
a466373bc23f Finished brews import
Michiel Broek <mbroek@mbse.eu>
parents: 107
diff changeset
1500 $count = mysqli_affected_rows($db);
a466373bc23f Finished brews import
Michiel Broek <mbroek@mbse.eu>
parents: 107
diff changeset
1501 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
1502 $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
1503 } else {
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
1504 // See if there really are no records
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
1505 $lsql = "SELECT product_code FROM log_fermentation WHERE product_code='".$recipe->NR_RECIPE."';";
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
1506 $count = mysqli_affected_rows($db);
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
1507 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
1508 $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
1509 }
106
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1510 }
108
a466373bc23f Finished brews import
Michiel Broek <mbroek@mbse.eu>
parents: 107
diff changeset
1511
a466373bc23f Finished brews import
Michiel Broek <mbroek@mbse.eu>
parents: 107
diff changeset
1512 /*
a466373bc23f Finished brews import
Michiel Broek <mbroek@mbse.eu>
parents: 107
diff changeset
1513 * If no external fermentation log is found, check for an internal one.
a466373bc23f Finished brews import
Michiel Broek <mbroek@mbse.eu>
parents: 107
diff changeset
1514 */
a466373bc23f Finished brews import
Michiel Broek <mbroek@mbse.eu>
parents: 107
diff changeset
1515 if (($count == 0) && $recipe->FERM_MEASUREMENTS) {
a466373bc23f Finished brews import
Michiel Broek <mbroek@mbse.eu>
parents: 107
diff changeset
1516 $lsql = "DELETE FROM log_fermentation WHERE product_code='".mysqli_real_escape_string($db, $recipe->NR_RECIPE)."';";
a466373bc23f Finished brews import
Michiel Broek <mbroek@mbse.eu>
parents: 107
diff changeset
1517 if (! $lresult = mysqli_query($db, $lsql)) {
a466373bc23f Finished brews import
Michiel Broek <mbroek@mbse.eu>
parents: 107
diff changeset
1518 printf("Error: %s\n", mysqli_error($db));
a466373bc23f Finished brews import
Michiel Broek <mbroek@mbse.eu>
parents: 107
diff changeset
1519 }
a466373bc23f Finished brews import
Michiel Broek <mbroek@mbse.eu>
parents: 107
diff changeset
1520 foreach ($recipe->FERM_MEASUREMENTS->FERM_MEASUREMENT as $measurement) {
a466373bc23f Finished brews import
Michiel Broek <mbroek@mbse.eu>
parents: 107
diff changeset
1521 $dt = substr($measurement->DATE_TIME, 6, 4).substr($measurement->DATE_TIME,2,4).substr($measurement->DATE_TIME,0,2);
a466373bc23f Finished brews import
Michiel Broek <mbroek@mbse.eu>
parents: 107
diff changeset
1522 $dt .= ' '.substr($measurement->DATE_TIME, 11,8);
a466373bc23f Finished brews import
Michiel Broek <mbroek@mbse.eu>
parents: 107
diff changeset
1523 $lsql = "INSERT INTO log_fermentation SET product_uuid='".$uuid;
a466373bc23f Finished brews import
Michiel Broek <mbroek@mbse.eu>
parents: 107
diff changeset
1524 $lsql .= "', product_code='" . mysqli_real_escape_string($db, $recipe->NR_RECIPE);
a466373bc23f Finished brews import
Michiel Broek <mbroek@mbse.eu>
parents: 107
diff changeset
1525 $lsql .= "', product_name='" . mysqli_real_escape_string($db, $recipe->NAME);
a466373bc23f Finished brews import
Michiel Broek <mbroek@mbse.eu>
parents: 107
diff changeset
1526 $lsql .= "', datetime='" . $dt;
a466373bc23f Finished brews import
Michiel Broek <mbroek@mbse.eu>
parents: 107
diff changeset
1527 $lsql .= "', temperature_air='" . floatval($measurement->TEMP_SENSOR_1);
a466373bc23f Finished brews import
Michiel Broek <mbroek@mbse.eu>
parents: 107
diff changeset
1528 $lsql .= "', temperature_beer='" . floatval($measurement->TEMP_SENSOR_2);
a466373bc23f Finished brews import
Michiel Broek <mbroek@mbse.eu>
parents: 107
diff changeset
1529 $lsql .= "';";
a466373bc23f Finished brews import
Michiel Broek <mbroek@mbse.eu>
parents: 107
diff changeset
1530 if (! $lresult = mysqli_query($db, $lsql)) {
a466373bc23f Finished brews import
Michiel Broek <mbroek@mbse.eu>
parents: 107
diff changeset
1531 printf("Error: %s\n", mysqli_error($db));
a466373bc23f Finished brews import
Michiel Broek <mbroek@mbse.eu>
parents: 107
diff changeset
1532 }
a466373bc23f Finished brews import
Michiel Broek <mbroek@mbse.eu>
parents: 107
diff changeset
1533 }
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
1534 $sql .= "', log_fermentation='1";
108
a466373bc23f Finished brews import
Michiel Broek <mbroek@mbse.eu>
parents: 107
diff changeset
1535 }
106
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1536
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1537 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
1538 $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
1539 $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
1540 $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
1541 $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
1542 $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
1543 $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
1544 $sql .= "', eq_tun_specific_heat='" . floatval($recipe->EQUIPMENT->TUN_SPECIFIC_HEAT);
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
1545 $sql .= "', eq_tun_material='" . mysqli_real_escape_string($db, $recipe->EQUIPMENT->TUN_MATERIAL);
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
1546 $sql .= "', eq_tun_height='" . floatval($recipe->EQUIPMENT->TUN_HEIGHT);
108
a466373bc23f Finished brews import
Michiel Broek <mbroek@mbse.eu>
parents: 107
diff changeset
1547 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
1548 $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
1549 $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
1550 /*
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
1551 * 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
1552 * 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
1553 * 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
1554 * 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
1555 */
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
1556 $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
1557 $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
1558 ($recipe->EQUIPMENT->CALC_BOIL_VOLUME == 'TRUE') ? $sql .= "', eq_calc_boil_volume='1" : $sql .= "', eq_calc_boil_volume='0";
108
a466373bc23f Finished brews import
Michiel Broek <mbroek@mbse.eu>
parents: 107
diff changeset
1559 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
1560 $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
1561 $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
1562 $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
1563 $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
1564 $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
1565 $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
1566 $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
1567 $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
1568 $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
1569 $sql .= "', eq_efficiency='" . floatval($recipe->EQUIPMENT->EFFICIENCY);
106
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1570 }
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1571
108
a466373bc23f Finished brews import
Michiel Broek <mbroek@mbse.eu>
parents: 107
diff changeset
1572 if (($recipe->DATE) && (! $recipe->TIME_STARTED) && (! $recipe->TIME_ENDED)) {
a466373bc23f Finished brews import
Michiel Broek <mbroek@mbse.eu>
parents: 107
diff changeset
1573 /* 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
1574 $sql .= "', birth='" . date("Y-m-d");
150
159d7a89fcef Better stage detection during product import from brouwhulp. Added tooltips for treated water.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
1575 $stageno= 1;
108
a466373bc23f Finished brews import
Michiel Broek <mbroek@mbse.eu>
parents: 107
diff changeset
1576 $stage = "Wait";
a466373bc23f Finished brews import
Michiel Broek <mbroek@mbse.eu>
parents: 107
diff changeset
1577 }
a466373bc23f Finished brews import
Michiel Broek <mbroek@mbse.eu>
parents: 107
diff changeset
1578
107
8b4fdadf320c Added brewday data
Michiel Broek <mbroek@mbse.eu>
parents: 106
diff changeset
1579 if (($recipe->DATE) && ($recipe->TIME_STARTED) && ($recipe->TIME_ENDED)) {
8b4fdadf320c Added brewday data
Michiel Broek <mbroek@mbse.eu>
parents: 106
diff changeset
1580 /* We have brew data */
150
159d7a89fcef Better stage detection during product import from brouwhulp. Added tooltips for treated water.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
1581 $stageno = 3;
108
a466373bc23f Finished brews import
Michiel Broek <mbroek@mbse.eu>
parents: 107
diff changeset
1582 $stage = "Primary"; // Need to think about during a brew...
a466373bc23f Finished brews import
Michiel Broek <mbroek@mbse.eu>
parents: 107
diff changeset
1583 $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
1584 $sql .= "', birth='" . $brewdate;
108
a466373bc23f Finished brews import
Michiel Broek <mbroek@mbse.eu>
parents: 107
diff changeset
1585 $date_start = $brewdate.' '.$recipe->TIME_STARTED;
a466373bc23f Finished brews import
Michiel Broek <mbroek@mbse.eu>
parents: 107
diff changeset
1586 $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
1587 $sql .= "', brew_date_start='" . $date_start;
107
8b4fdadf320c Added brewday data
Michiel Broek <mbroek@mbse.eu>
parents: 106
diff changeset
1588
8b4fdadf320c Added brewday data
Michiel Broek <mbroek@mbse.eu>
parents: 106
diff changeset
1589 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
1590 $sql .= "', brew_mash_ph='" . floatval($recipe->PH_ADJUSTED);
107
8b4fdadf320c Added brewday data
Michiel Broek <mbroek@mbse.eu>
parents: 106
diff changeset
1591 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
1592 $sql .= "', brew_mash_sg='" . floatval($recipe->SG_END_MASH);
107
8b4fdadf320c Added brewday data
Michiel Broek <mbroek@mbse.eu>
parents: 106
diff changeset
1593 if ($recipe->MASH->SPARGE_TEMP)
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
1594 $sql .= "', brew_sparge_temperature='" . floatval($recipe->MASH->SPARGE_TEMP);
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
1595 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
1596 $sql .= "', brew_sparge_ph='" . floatval($recipe->MASH->PH);
107
8b4fdadf320c Added brewday data
Michiel Broek <mbroek@mbse.eu>
parents: 106
diff changeset
1597 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
1598 $sql .= "', brew_sparge_volume='" . floatval($recipe->VOLUME_HLT);
107
8b4fdadf320c Added brewday data
Michiel Broek <mbroek@mbse.eu>
parents: 106
diff changeset
1599 if ($recipe->VOLUME_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
1600 $sql .= "', brew_preboil_volume='" . floatval($recipe->VOLUME_BEFORE_BOIL);
107
8b4fdadf320c Added brewday data
Michiel Broek <mbroek@mbse.eu>
parents: 106
diff changeset
1601 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
1602 $sql .= "', brew_preboil_sg='" . floatval($recipe->OG_BEFORE_BOIL);
107
8b4fdadf320c Added brewday data
Michiel Broek <mbroek@mbse.eu>
parents: 106
diff changeset
1603 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
1604 $sql .= "', brew_preboil_ph='" . floatval($recipe->PH_BEFORE_BOIL);
107
8b4fdadf320c Added brewday data
Michiel Broek <mbroek@mbse.eu>
parents: 106
diff changeset
1605 if ($recipe->VOLUME_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
1606 $sql .= "', brew_aboil_volume='" . floatval($recipe->VOLUME_AFTER_BOIL);
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
1607 $sql .= "', brew_aboil_sg='" . floatval($recipe->OG);
107
8b4fdadf320c Added brewday data
Michiel Broek <mbroek@mbse.eu>
parents: 106
diff changeset
1608 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
1609 $sql .= "', brew_aboil_ph='" . floatval($recipe->PH_AFTER_BOIL);
107
8b4fdadf320c Added brewday data
Michiel Broek <mbroek@mbse.eu>
parents: 106
diff changeset
1610 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
1611 $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
1612 $sql .= "', brew_whirlpool2='" . floatval($recipe->WHIRLPOOL_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
1613 $sql .= "', brew_cooling_method='" . mysqli_real_escape_string($db, $recipe->COOLING_METHOD);
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
1614 $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
1615 $sql .= "', brew_cooling_to='" . floatval($recipe->COOLING_TO);
107
8b4fdadf320c Added brewday data
Michiel Broek <mbroek@mbse.eu>
parents: 106
diff changeset
1616 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
1617 $sql .= "', brew_fermenter_volume='" . floatval($recipe->VOLUME_FERMENTER);
107
8b4fdadf320c Added brewday data
Michiel Broek <mbroek@mbse.eu>
parents: 106
diff changeset
1618 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
1619 $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
1620 $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
1621 $sql .= "', brew_fermenter_ibu='" . floatval($recipe->IBU);
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
1622 $sql .= "', brew_aeration_type='" . mysqli_real_escape_string($db, $recipe->AERATION_TYPE);
107
8b4fdadf320c Added brewday data
Michiel Broek <mbroek@mbse.eu>
parents: 106
diff changeset
1623 if ($recipe->AERATION_TYPE != "None") {
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
1624 $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
1625 $sql .= "', brew_aeration_time='" . floatval($recipe->AERATION_TIME);
107
8b4fdadf320c Added brewday data
Michiel Broek <mbroek@mbse.eu>
parents: 106
diff changeset
1626 }
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
1627 $sql .= "', brew_date_end='" . $date_end;
107
8b4fdadf320c Added brewday data
Michiel Broek <mbroek@mbse.eu>
parents: 106
diff changeset
1628 }
108
a466373bc23f Finished brews import
Michiel Broek <mbroek@mbse.eu>
parents: 107
diff changeset
1629
163
4a4cc3497a57 Added the packaging tab contents.
Michiel Broek <mbroek@mbse.eu>
parents: 154
diff changeset
1630 $sql .= "', og='" . floatval($recipe->OG);
4a4cc3497a57 Added the packaging tab contents.
Michiel Broek <mbroek@mbse.eu>
parents: 154
diff changeset
1631 $sql .= "', fg='" . floatval($recipe->FG);
4a4cc3497a57 Added the packaging tab contents.
Michiel Broek <mbroek@mbse.eu>
parents: 154
diff changeset
1632
150
159d7a89fcef Better stage detection during product import from brouwhulp. Added tooltips for treated water.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
1633 if ($recipe->PRIMARY_AGE && ($stageno >= 3)) {
108
a466373bc23f Finished brews import
Michiel Broek <mbroek@mbse.eu>
parents: 107
diff changeset
1634 /* PRIMARY_TEMP is the average of START_TEMP_PRIMARY MAX_TEMP_PRIMARY END_TEMP_PRIMARY */
a466373bc23f Finished brews import
Michiel Broek <mbroek@mbse.eu>
parents: 107
diff changeset
1635 $pdate = new DateTime($brewdate);
a466373bc23f Finished brews import
Michiel Broek <mbroek@mbse.eu>
parents: 107
diff changeset
1636 $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
1637 $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
1638 $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
1639 $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
1640 $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
1641 $sql .= "', primary_end_date='" . $pdate->format("Y-m-d");
150
159d7a89fcef Better stage detection during product import from brouwhulp. Added tooltips for treated water.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
1642 $stageno = 4;
108
a466373bc23f Finished brews import
Michiel Broek <mbroek@mbse.eu>
parents: 107
diff changeset
1643 $stage = "Secondary";
a466373bc23f Finished brews import
Michiel Broek <mbroek@mbse.eu>
parents: 107
diff changeset
1644
150
159d7a89fcef Better stage detection during product import from brouwhulp. Added tooltips for treated water.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
1645 if ($recipe->SECONDARY_AGE && ($stageno >= 4)) {
108
a466373bc23f Finished brews import
Michiel Broek <mbroek@mbse.eu>
parents: 107
diff changeset
1646 $sdate = new DateTime($brewdate);
a466373bc23f Finished brews import
Michiel Broek <mbroek@mbse.eu>
parents: 107
diff changeset
1647 $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
1648 $sql .= "', secondary_temp='" . floatval($recipe->SECONDARY_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
1649 $sql .= "', secondary_end_date='" . $sdate->format("Y-m-d");
150
159d7a89fcef Better stage detection during product import from brouwhulp. Added tooltips for treated water.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
1650 $stageno = 5;
108
a466373bc23f Finished brews import
Michiel Broek <mbroek@mbse.eu>
parents: 107
diff changeset
1651 $stage = "Tertiary";
107
8b4fdadf320c Added brewday data
Michiel Broek <mbroek@mbse.eu>
parents: 106
diff changeset
1652
150
159d7a89fcef Better stage detection during product import from brouwhulp. Added tooltips for treated water.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
1653 if ($recipe->TERTIARY_TEMP && ($stageno >= 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
1654 $sql .= "', tertiary_temp='" . floatval($recipe->TERTIARY_TEMP);
108
a466373bc23f Finished brews import
Michiel Broek <mbroek@mbse.eu>
parents: 107
diff changeset
1655 }
a466373bc23f Finished brews import
Michiel Broek <mbroek@mbse.eu>
parents: 107
diff changeset
1656 }
a466373bc23f Finished brews import
Michiel Broek <mbroek@mbse.eu>
parents: 107
diff changeset
1657 }
a466373bc23f Finished brews import
Michiel Broek <mbroek@mbse.eu>
parents: 107
diff changeset
1658
a466373bc23f Finished brews import
Michiel Broek <mbroek@mbse.eu>
parents: 107
diff changeset
1659 if ($recipe->DATE_BOTTLING && ($recipe->AMOUNT_BOTTLING || $recipe->AMOUNT_KEGGED) &&
150
159d7a89fcef Better stage detection during product import from brouwhulp. Added tooltips for treated water.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
1660 ($recipe->AMOUNT_PRIMING || $recipe->AMOUNT_PRIMING_KEGS) && ($stageno >= 5)) {
108
a466373bc23f Finished brews import
Michiel Broek <mbroek@mbse.eu>
parents: 107
diff changeset
1661 $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
1662 $sql .= "', package_date='" . $bdate;
108
a466373bc23f Finished brews import
Michiel Broek <mbroek@mbse.eu>
parents: 107
diff changeset
1663 $stage = "Package";
150
159d7a89fcef Better stage detection during product import from brouwhulp. Added tooltips for treated water.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
1664 $stageno = 6;
108
a466373bc23f Finished brews import
Michiel Broek <mbroek@mbse.eu>
parents: 107
diff changeset
1665 $dStart = new DateTime($bdate);
a466373bc23f Finished brews import
Michiel Broek <mbroek@mbse.eu>
parents: 107
diff changeset
1666 $dEnd = new DateTime('');
a466373bc23f Finished brews import
Michiel Broek <mbroek@mbse.eu>
parents: 107
diff changeset
1667 $dDiff = $dStart->diff($dEnd);
a466373bc23f Finished brews import
Michiel Broek <mbroek@mbse.eu>
parents: 107
diff changeset
1668 $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
1669 if ($age == 0) { // Package day
108
a466373bc23f Finished brews import
Michiel Broek <mbroek@mbse.eu>
parents: 107
diff changeset
1670 $stage = "Package";
150
159d7a89fcef Better stage detection during product import from brouwhulp. Added tooltips for treated water.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
1671 $stageno = 6;
159d7a89fcef Better stage detection during product import from brouwhulp. Added tooltips for treated water.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
1672 } else if ($age < 14) { // Carbonation period
108
a466373bc23f Finished brews import
Michiel Broek <mbroek@mbse.eu>
parents: 107
diff changeset
1673 $stage = "Carbonation";
150
159d7a89fcef Better stage detection during product import from brouwhulp. Added tooltips for treated water.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
1674 $stageno = 7;
159d7a89fcef Better stage detection during product import from brouwhulp. Added tooltips for treated water.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
1675 } else if ($age < 42) { // Mature, fixed 6 weeks
108
a466373bc23f Finished brews import
Michiel Broek <mbroek@mbse.eu>
parents: 107
diff changeset
1676 $stage = "Mature";
150
159d7a89fcef Better stage detection during product import from brouwhulp. Added tooltips for treated water.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
1677 $stageno = 8;
159d7a89fcef Better stage detection during product import from brouwhulp. Added tooltips for treated water.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
1678 } else { // Ready for tasting.
108
a466373bc23f Finished brews import
Michiel Broek <mbroek@mbse.eu>
parents: 107
diff changeset
1679 $stage = "Taste";
150
159d7a89fcef Better stage detection during product import from brouwhulp. Added tooltips for treated water.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
1680 $stageno = 9;
159d7a89fcef Better stage detection during product import from brouwhulp. Added tooltips for treated water.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
1681 }
107
8b4fdadf320c Added brewday data
Michiel Broek <mbroek@mbse.eu>
parents: 106
diff changeset
1682
108
a466373bc23f Finished brews import
Michiel Broek <mbroek@mbse.eu>
parents: 107
diff changeset
1683 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
1684 $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
1685 $sql .= "', bottle_carbonation='" . floatval($recipe->CARBONATION);
163
4a4cc3497a57 Added the packaging tab contents.
Michiel Broek <mbroek@mbse.eu>
parents: 154
diff changeset
1686 if ($recipe->PRIMING_SUGAR_BOTTLES == "Saccharose")
4a4cc3497a57 Added the packaging tab contents.
Michiel Broek <mbroek@mbse.eu>
parents: 154
diff changeset
1687 $sql .= "', bottle_priming_sugar='Kristalsuiker";
4a4cc3497a57 Added the packaging tab contents.
Michiel Broek <mbroek@mbse.eu>
parents: 154
diff changeset
1688 else if ($recipe->PRIMING_SUGAR_BOTTLES == "Glucose or dextrose")
4a4cc3497a57 Added the packaging tab contents.
Michiel Broek <mbroek@mbse.eu>
parents: 154
diff changeset
1689 $sql .= "', bottle_priming_sugar='Glucose/dextrose";
4a4cc3497a57 Added the packaging tab contents.
Michiel Broek <mbroek@mbse.eu>
parents: 154
diff changeset
1690 else if ($recipe->PRIMING_SUGAR_BOTTLES == "Honey")
4a4cc3497a57 Added the packaging tab contents.
Michiel Broek <mbroek@mbse.eu>
parents: 154
diff changeset
1691 $sql .= "', bottle_priming_sugar='Honing";
4a4cc3497a57 Added the packaging tab contents.
Michiel Broek <mbroek@mbse.eu>
parents: 154
diff changeset
1692 else if ($recipe->PRIMING_SUGAR_BOTTLES == "DME")
4a4cc3497a57 Added the packaging tab contents.
Michiel Broek <mbroek@mbse.eu>
parents: 154
diff changeset
1693 $sql .= "', bottle_priming_sugar='Moutextract";
4a4cc3497a57 Added the packaging tab contents.
Michiel Broek <mbroek@mbse.eu>
parents: 154
diff changeset
1694 else if ($recipe->PRIMING_SUGAR_BOTTLES == "Molassis")
4a4cc3497a57 Added the packaging tab contents.
Michiel Broek <mbroek@mbse.eu>
parents: 154
diff changeset
1695 $sql .= "', bottle_priming_sugar='Melasse";
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
1696 $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
1697 $sql .= "', bottle_carbonation_temp='" . floatval($recipe->CARBONATION_TEMP);
108
a466373bc23f Finished brews import
Michiel Broek <mbroek@mbse.eu>
parents: 107
diff changeset
1698 }
a466373bc23f Finished brews import
Michiel Broek <mbroek@mbse.eu>
parents: 107
diff changeset
1699 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
1700 $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
1701 $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
1702 if ($recipe->PRIMING_SUGAR_BOTTLES == "Saccharose")
4a4cc3497a57 Added the packaging tab contents.
Michiel Broek <mbroek@mbse.eu>
parents: 154
diff changeset
1703 $sql .= "', keg_priming_sugar='Kristalsuiker";
4a4cc3497a57 Added the packaging tab contents.
Michiel Broek <mbroek@mbse.eu>
parents: 154
diff changeset
1704 else if ($recipe->PRIMING_SUGAR_BOTTLES == "Glucose or dextrose")
4a4cc3497a57 Added the packaging tab contents.
Michiel Broek <mbroek@mbse.eu>
parents: 154
diff changeset
1705 $sql .= "', keg_priming_sugar='Glucose/dextrose";
4a4cc3497a57 Added the packaging tab contents.
Michiel Broek <mbroek@mbse.eu>
parents: 154
diff changeset
1706 else if ($recipe->PRIMING_SUGAR_BOTTLES == "Honey")
4a4cc3497a57 Added the packaging tab contents.
Michiel Broek <mbroek@mbse.eu>
parents: 154
diff changeset
1707 $sql .= "', keg_priming_sugar='Honing";
4a4cc3497a57 Added the packaging tab contents.
Michiel Broek <mbroek@mbse.eu>
parents: 154
diff changeset
1708 else if ($recipe->PRIMING_SUGAR_BOTTLES == "DME")
4a4cc3497a57 Added the packaging tab contents.
Michiel Broek <mbroek@mbse.eu>
parents: 154
diff changeset
1709 $sql .= "', keg_priming_sugar='Moutextract";
4a4cc3497a57 Added the packaging tab contents.
Michiel Broek <mbroek@mbse.eu>
parents: 154
diff changeset
1710 else if ($recipe->PRIMING_SUGAR_BOTTLES == "Molassis")
4a4cc3497a57 Added the packaging tab contents.
Michiel Broek <mbroek@mbse.eu>
parents: 154
diff changeset
1711 $sql .= "', keg_priming_sugar='Melasse";
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
1712 $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
1713 $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
1714 ($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
1715 $sql .= "', keg_pressure='" . floatval($recipe->KEG_PRESSURE);
108
a466373bc23f Finished brews import
Michiel Broek <mbroek@mbse.eu>
parents: 107
diff changeset
1716 }
a466373bc23f Finished brews import
Michiel Broek <mbroek@mbse.eu>
parents: 107
diff changeset
1717 }
a466373bc23f Finished brews import
Michiel Broek <mbroek@mbse.eu>
parents: 107
diff changeset
1718
150
159d7a89fcef Better stage detection during product import from brouwhulp. Added tooltips for treated water.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
1719 if ($recipe->TASTE_NOTES && $recipe->TASTING_RATE && $recipe->TASTE_DATE && ($stageno >= 9)) {
108
a466373bc23f Finished brews import
Michiel Broek <mbroek@mbse.eu>
parents: 107
diff changeset
1720 $stage = "Ready"; // Ready if tasted.
150
159d7a89fcef Better stage detection during product import from brouwhulp. Added tooltips for treated water.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
1721 $stageno = 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
1722 $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
1723 $sql .= "', taste_rate='" . floatval($recipe->TASTING_RATE);
108
a466373bc23f Finished brews import
Michiel Broek <mbroek@mbse.eu>
parents: 107
diff changeset
1724 $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
1725 $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
1726 $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
1727 $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
1728 $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
1729 $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
1730 $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
1731 $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
1732 $sql .= "', taste_aftertaste='" . mysqli_real_escape_string($db, $recipe->TASTE_AFTERTASTE);
108
a466373bc23f Finished brews import
Michiel Broek <mbroek@mbse.eu>
parents: 107
diff changeset
1733 }
a466373bc23f Finished brews import
Michiel Broek <mbroek@mbse.eu>
parents: 107
diff changeset
1734
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 ($recipe->INVENTORY_REDUCED == 'TRUE') ? $sql .= "', inventory_reduced='1" : $sql .= "', inventory_reduced='0";
108
a466373bc23f Finished brews import
Michiel Broek <mbroek@mbse.eu>
parents: 107
diff changeset
1736 if (($recipe->LOCKED == 'TRUE') && ($stage == '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
1737 $sql .= "', locked='1";
108
a466373bc23f Finished brews import
Michiel Broek <mbroek@mbse.eu>
parents: 107
diff changeset
1738 $stage = "Closed";
150
159d7a89fcef Better stage detection during product import from brouwhulp. Added tooltips for treated water.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
1739 $stageno = 11;
108
a466373bc23f Finished brews import
Michiel Broek <mbroek@mbse.eu>
parents: 107
diff changeset
1740 } 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
1741 $sql .= "', locked='0";
108
a466373bc23f Finished brews import
Michiel Broek <mbroek@mbse.eu>
parents: 107
diff changeset
1742 }
a466373bc23f Finished brews import
Michiel Broek <mbroek@mbse.eu>
parents: 107
diff changeset
1743
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
1744 $sql .= "', stage='" . $stage;
108
a466373bc23f Finished brews import
Michiel Broek <mbroek@mbse.eu>
parents: 107
diff changeset
1745 // echo ' '.$brewdate.' '.$recipe->NR_RECIPE.' '.$stage . PHP_EOL;
a466373bc23f Finished brews import
Michiel Broek <mbroek@mbse.eu>
parents: 107
diff changeset
1746
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 .= "';";
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 if (! $rresult = mysqli_query($db, $sql)) {
106
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1749 printf("Error: %s\n", mysqli_error($db));
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1750 }
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1751 }
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1752 }
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1753
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1754
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1755
64
5d5fc6f7cbfe Improved recipes import. Finished inventory_suppliers.
Michiel Broek <mbroek@mbse.eu>
parents: 61
diff changeset
1756 do_fermentables();
5d5fc6f7cbfe Improved recipes import. Finished inventory_suppliers.
Michiel Broek <mbroek@mbse.eu>
parents: 61
diff changeset
1757 do_hops();
5d5fc6f7cbfe Improved recipes import. Finished inventory_suppliers.
Michiel Broek <mbroek@mbse.eu>
parents: 61
diff changeset
1758 do_yeasts();
5d5fc6f7cbfe Improved recipes import. Finished inventory_suppliers.
Michiel Broek <mbroek@mbse.eu>
parents: 61
diff changeset
1759 do_miscs();
5d5fc6f7cbfe Improved recipes import. Finished inventory_suppliers.
Michiel Broek <mbroek@mbse.eu>
parents: 61
diff changeset
1760 do_waters();
5d5fc6f7cbfe Improved recipes import. Finished inventory_suppliers.
Michiel Broek <mbroek@mbse.eu>
parents: 61
diff changeset
1761 do_equipments();
50
6d94167c2697 Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents: 49
diff changeset
1762 do_styles();
64
5d5fc6f7cbfe Improved recipes import. Finished inventory_suppliers.
Michiel Broek <mbroek@mbse.eu>
parents: 61
diff changeset
1763 do_mash();
106
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1764 do_recipes();
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1765 do_brews();
48
bdd1ec9b9c06 Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents: 45
diff changeset
1766
11
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1767
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1768 mysqli_close($db);
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1769
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1770 echo "Finished adding data\n";
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1771
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1772
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1773 ?>

mercurial