www/import/from_brouwhulp.php

Fri, 08 Feb 2019 11:30:22 +0100

author
Michiel Broek <mbroek@mbse.eu>
date
Fri, 08 Feb 2019 11:30:22 +0100
changeset 253
296caca18161
parent 250
30e7d6ea119b
child 266
4cfbf25e3093
permissions
-rw-r--r--

Fix for import with CBC-1 yeast

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);
223
0de4455bd2a1 Fixed spelling area in all programs for caryophyllene. This is still wrong in brouwhulp, we correct it during database import. Also mycrene was spelled myrcene, my fault. The hops grid now uses a popup editor, this is not yet complete. Friendly weight display in the hop grid and added the inventory comlumn.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
158 if ($hop->CAROPHYLLENE)
0de4455bd2a1 Fixed spelling area in all programs for caryophyllene. This is still wrong in brouwhulp, we correct it during database import. Also mycrene was spelled myrcene, my fault. The hops grid now uses a popup editor, this is not yet complete. Friendly weight display in the hop grid and added the inventory comlumn.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
159 $sql .= "', caryophyllene='" . floatval($hop->CAROPHYLLENE);
11
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);
223
0de4455bd2a1 Fixed spelling area in all programs for caryophyllene. This is still wrong in brouwhulp, we correct it during database import. Also mycrene was spelled myrcene, my fault. The hops grid now uses a popup editor, this is not yet complete. Friendly weight display in the hop grid and added the inventory comlumn.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
162 if ($hop->MYRCENE)
0de4455bd2a1 Fixed spelling area in all programs for caryophyllene. This is still wrong in brouwhulp, we correct it during database import. Also mycrene was spelled myrcene, my fault. The hops grid now uses a popup editor, this is not yet complete. Friendly weight display in the hop grid and added the inventory comlumn.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
163 $sql .= "', myrcene='" . floatval($hop->MYRCENE);
11
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);
223
0de4455bd2a1 Fixed spelling area in all programs for caryophyllene. This is still wrong in brouwhulp, we correct it during database import. Also mycrene was spelled myrcene, my fault. The hops grid now uses a popup editor, this is not yet complete. Friendly weight display in the hop grid and added the inventory comlumn.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
878 $hops .= ',"h_caryophyllene":' . floatval($hop->CAROPHYLLENE);
106
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
879 $hops .= ',"h_cohumulone":' . floatval($hop->COHUMULONE);
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
880 $hops .= ',"h_myrcene":' . floatval($hop->MYRCENE);
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
881 if ($hop->TOTAL_OIL)
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
882 $hops .= ',"h_total_oil":' . floatval($hop->TOTAL_OIL);
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
883 else
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
884 $hops .= ',"h_total_oil":0';
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
885 if ($hop->ORIGIN)
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
886 $hops .= ',"h_origin":"' . mysqli_real_escape_string($db, $hop->ORIGIN) . '"';
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
887 else
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
888 $hops .= ',"h_origin":""';
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
889 $hops .= "}";
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
890 }
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
891 $hops .= ']';
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
892 return $hops;
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
893 }
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
894
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
895 function recipe_miscs($recipe)
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
896 {
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
897 global $db;
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
898
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
899 $miscs = "[";
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
900 $comma = FALSE;
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
901 foreach ($recipe->MISCS->MISC as $misc) {
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
902 if ($comma)
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
903 $miscs .= ',';
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
904 $comma = TRUE;
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
905 $mname = mysqli_real_escape_string($db, $misc->NAME);
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
906 $miscs .= '{"m_name":"' . $mname . '"';
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
907 $miscs .= ',"m_amount":' . floatval($misc->AMOUNT);
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
908 if ($misc->COST) {
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
909 $miscs .= ',"m_cost":' . floatval($misc->COST);
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
910 } else {
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
911 /* Brouwhulp bug, added water agents have no cost field. */
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
912 if ($misc->TYPE == "Water agent") {
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
913 $miscs .= ',"m_cost":'. get_miscs_cost($mname);
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
914 } else {
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
915 $miscs .= ',"m_cost":0';
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
916 }
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
917 }
220
14e349ff2a10 Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents: 217
diff changeset
918
14e349ff2a10 Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents: 217
diff changeset
919 if ($misc->TYPE == 'Spice')
14e349ff2a10 Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents: 217
diff changeset
920 $miscs .= ',"m_type":0';
14e349ff2a10 Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents: 217
diff changeset
921 else if ($misc->TYPE == 'Herb')
14e349ff2a10 Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents: 217
diff changeset
922 $miscs .= ',"m_type":1';
14e349ff2a10 Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents: 217
diff changeset
923 else if ($misc->TYPE == 'Flavor')
14e349ff2a10 Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents: 217
diff changeset
924 $miscs .= ',"m_type":2';
14e349ff2a10 Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents: 217
diff changeset
925 else if ($misc->TYPE == 'Fining')
14e349ff2a10 Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents: 217
diff changeset
926 $miscs .= ',"m_type":3';
14e349ff2a10 Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents: 217
diff changeset
927 else if ($misc->TYPE == 'Water agent')
14e349ff2a10 Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents: 217
diff changeset
928 $miscs .= ',"m_type":4';
14e349ff2a10 Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents: 217
diff changeset
929 else if ($misc->TYPE == 'Yeast nutrient')
14e349ff2a10 Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents: 217
diff changeset
930 $miscs .= ',"m_type":5';
14e349ff2a10 Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents: 217
diff changeset
931 else if ($misc->TYPE == 'Other')
14e349ff2a10 Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents: 217
diff changeset
932 $miscs .= ',"m_type":6';
14e349ff2a10 Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents: 217
diff changeset
933 else
14e349ff2a10 Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents: 217
diff changeset
934 echo "Unknown TYPE " . $misc->TYPE . PHP_EOL;
14e349ff2a10 Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents: 217
diff changeset
935
14e349ff2a10 Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents: 217
diff changeset
936 if ($misc->USE == 'Starter')
14e349ff2a10 Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents: 217
diff changeset
937 $miscs .= ',"m_use_use":0';
14e349ff2a10 Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents: 217
diff changeset
938 else if ($misc->USE == 'Mash')
14e349ff2a10 Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents: 217
diff changeset
939 $miscs .= ',"m_use_use":1';
14e349ff2a10 Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents: 217
diff changeset
940 else if ($misc->USE == 'Boil')
14e349ff2a10 Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents: 217
diff changeset
941 $miscs .= ',"m_use_use":2';
14e349ff2a10 Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents: 217
diff changeset
942 else if ($misc->USE == 'Primary')
14e349ff2a10 Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents: 217
diff changeset
943 $miscs .= ',"m_use_use":3';
14e349ff2a10 Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents: 217
diff changeset
944 else if ($misc->USE == 'Secondary')
14e349ff2a10 Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents: 217
diff changeset
945 $miscs .= ',"m_use_use":4';
14e349ff2a10 Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents: 217
diff changeset
946 else if ($misc->USE == 'Bottling')
14e349ff2a10 Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents: 217
diff changeset
947 $miscs .= ',"m_use_use":5';
14e349ff2a10 Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents: 217
diff changeset
948 else
14e349ff2a10 Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents: 217
diff changeset
949 echo "Unknown USE " . $misc->USE . PHP_EOL;
14e349ff2a10 Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents: 217
diff changeset
950
175
da16371538c3 When importing from brouwhulp use 0 and 1 instead of false and true for boolean variables. Added Export button to the recipe editor. Added beerxml recipe export.
Michiel Broek <mbroek@mbse.eu>
parents: 163
diff changeset
951 ($misc->AMOUNT_IS_WEIGHT== "TRUE") ? $miscs .= ',"m_amount_is_weight":1' : $miscs.= ',"m_amount_is_weight":0';
143
122f64716161 During recipes import of miscs ingredients, convert time in Secondary to days. The hop grid also display the country of origin. Misc ingredients now use a temporary weight table just like the hops.
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
952 if ($misc->TIME) {
220
14e349ff2a10 Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents: 217
diff changeset
953 $miscs .= ',"m_time":' . floatval($misc->TIME);
143
122f64716161 During recipes import of miscs ingredients, convert time in Secondary to days. The hop grid also display the country of origin. Misc ingredients now use a temporary weight table just like the hops.
Michiel Broek <mbroek@mbse.eu>
parents: 136
diff changeset
954 } else
106
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
955 $miscs .= ',"m_time":0';
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
956 $miscs .= "}";
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
957 }
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
958 $miscs .= ']';
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
959 return $miscs;
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
960 }
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
961
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
962 function recipe_yeasts($recipe)
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
963 {
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
964 global $db;
136
bcc4583fd013 Fixed estimate FG calculation during recipes import. Added estimate FG calculation in the recipe editor but do not yet update the recipe. Added SVG calculation to the recipes editor. Added calculations for hop aroma and flavour contribution.
Michiel Broek <mbroek@mbse.eu>
parents: 131
diff changeset
965 global $svg;
106
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
966
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
967 $yeasts = "[";
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
968 $comma = FALSE;
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
969 foreach ($recipe->YEASTS->YEAST as $yeast) {
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
970 if ($comma)
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
971 $yeasts .= ',';
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
972 $comma = TRUE;
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
973 $yeasts .= '{"y_name":"' . mysqli_real_escape_string($db, $yeast->NAME) . '"';
226
40e68b18b50d The recipes yeast grid now uses a popup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 223
diff changeset
974 if ($yeast->FORM == "Liquid") {
40e68b18b50d The recipes yeast grid now uses a popup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 223
diff changeset
975 $paks = floatval($yeast->AMOUNT) / 0.0588;
40e68b18b50d The recipes yeast grid now uses a popup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 223
diff changeset
976 $yeasts .= ',"y_amount":' . $paks;
40e68b18b50d The recipes yeast grid now uses a popup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 223
diff changeset
977 } else {
40e68b18b50d The recipes yeast grid now uses a popup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 223
diff changeset
978 $yeasts .= ',"y_amount":' . floatval($yeast->AMOUNT);
40e68b18b50d The recipes yeast grid now uses a popup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 223
diff changeset
979 }
40e68b18b50d The recipes yeast grid now uses a popup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 223
diff changeset
980
40e68b18b50d The recipes yeast grid now uses a popup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 223
diff changeset
981 $yeasts .= ',"y_cost":' . floatval($yeast->COST);
106
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
982 $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
983 $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
984
14e349ff2a10 Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable 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 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
986 $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
987 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
988 $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
989 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
990 $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
991 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
992 $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
993 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
994 $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
995 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
996 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
997
14e349ff2a10 Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable 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 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
999 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
1000 $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
1001 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
1002 $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
1003 } 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
1004 $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
1005 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
1006 $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
1007 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
1008 $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
1009 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
1010 $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
1011 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
1012 $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
1013 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
1014 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
1015
226
40e68b18b50d The recipes yeast grid now uses a popup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 223
diff changeset
1016 if ($yeast->FLOCCULATION == 'Low')
40e68b18b50d The recipes yeast grid now uses a popup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 223
diff changeset
1017 $yeasts .= ',"y_flocculation":0';
40e68b18b50d The recipes yeast grid now uses a popup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 223
diff changeset
1018 else if ($yeast->FLOCCULATION == 'Medium')
40e68b18b50d The recipes yeast grid now uses a popup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 223
diff changeset
1019 $yeasts .= ',"y_flocculation":1';
40e68b18b50d The recipes yeast grid now uses a popup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 223
diff changeset
1020 else if ($yeast->FLOCCULATION == 'High')
40e68b18b50d The recipes yeast grid now uses a popup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 223
diff changeset
1021 $yeasts .= ',"y_flocculation":2';
40e68b18b50d The recipes yeast grid now uses a popup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 223
diff changeset
1022 else if ($yeast->FLOCCULATION == 'Very high')
40e68b18b50d The recipes yeast grid now uses a popup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 223
diff changeset
1023 $yeasts .= ',"y_flocculation":3';
40e68b18b50d The recipes yeast grid now uses a popup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 223
diff changeset
1024 else
40e68b18b50d The recipes yeast grid now uses a popup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 223
diff changeset
1025 echo "Unknown FLOCCULATION " . $yeast->FLOCCULATION . PHP_EOL;
40e68b18b50d The recipes yeast grid now uses a popup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 223
diff changeset
1026
106
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1027 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
1028 $yeasts .= ',"y_use":0'; // Primary
106
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1029 $svg = floatval($yeast->ATTENUATION);
253
296caca18161 Fix for import with CBC-1 yeast
Michiel Broek <mbroek@mbse.eu>
parents: 250
diff changeset
1030 } else if ($yeast->PRODUCT_ID=="F2" || $yeast->PRODUCT_ID=="CBC-1") {
220
14e349ff2a10 Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents: 217
diff changeset
1031 $yeasts .= ',"y_use":3'; // Bottle
106
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1032 } 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
1033 $yeasts .= ',"y_use":1'; // Secondary
106
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 $yeasts .= ',"y_min_temperature":' . floatval($yeast->MIN_TEMPERATURE);
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1036 $yeasts .= ',"y_max_temperature":' . floatval($yeast->MAX_TEMPERATURE);
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1037 $yeasts .= ',"y_attenuation":' . floatval($yeast->ATTENUATION);
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1038 $yeasts .= "}";
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1039 }
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1040 $yeasts .= ']';
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1041 return $yeasts;
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1042 }
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1043
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1044 function recipe_waters($recipe, $db)
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1045 {
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 = "";
c0f0bbfefd63 Source waters are fixed, removed grid editor. Redesigned the water screen. Made a simple visual if water treatments are out of range. Water mixer for standard and dillute water works. Swapped the mash and water tabs.
Michiel Broek <mbroek@mbse.eu>
parents: 147
diff changeset
1047 $index = 0;
106
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1048 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
1049 $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
1050 $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
1051 $waters .= "', w" . $index . "_amount='" . floatval($water->AMOUNT);
106
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1052 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
1053 $waters .= "', w" . $index . "_calcium='" . floatval($water->CALCIUM);
106
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1054 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
1055 $waters .= "', w" . $index . "_sulfate='" . floatval($water->SULFATE);
106
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1056 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
1057 $waters .= "', w" . $index . "_chloride='" . floatval($water->CHLORIDE);
106
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1058 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
1059 $waters .= "', w" . $index . "_sodium='" . floatval($water->SODIUM);
106
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1060 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
1061 $waters .= "', w" . $index . "_magnesium='" . floatval($water->MAGNESIUM);
106
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1062 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
1063 $waters .= "', w" . $index . "_ph='" . floatval($water->PH);
106
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1064 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
1065 $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
1066 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
1067 $waters .= "', w" . $index . "_cost='" . floatval($water->COST);
106
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1068 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
1069 $waters .= "', w" . $index . "_cost='0";
106
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 return $waters;
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1072 }
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1073
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
1074
14e349ff2a10 Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents: 217
diff changeset
1075
106
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1076 function recipe_mash_steps($recipe)
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1077 {
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1078 global $db;
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1079
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1080 $steps = '[';
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1081 $comma = FALSE;
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1082 foreach ($recipe->MASH->MASH_STEPS->MASH_STEP as $step) {
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1083 if ($comma)
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1084 $steps .= ',';
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1085 $comma = TRUE;
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1086 $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
1087
14e349ff2a10 Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents: 217
diff changeset
1088 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
1089 $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
1090 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
1091 $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
1092 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
1093 $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
1094 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
1095 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
1096
106
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1097 if ($step->INFUSE_AMOUNT)
228
98536f6539ee The mash grid now uses a popup editor. There is now a dropdown mash selector to replace the mash scheme.
Michiel Broek <mbroek@mbse.eu>
parents: 226
diff changeset
1098 $steps .= ',"step_infuse_amount":' . floatval($step->INFUSE_AMOUNT);
98536f6539ee The mash grid now uses a popup editor. There is now a dropdown mash selector to replace the mash scheme.
Michiel Broek <mbroek@mbse.eu>
parents: 226
diff changeset
1099 else
98536f6539ee The mash grid now uses a popup editor. There is now a dropdown mash selector to replace the mash scheme.
Michiel Broek <mbroek@mbse.eu>
parents: 226
diff changeset
1100 $steps .= ',"step_infuse_amount":0';
106
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1101 if ($step->STEP_TEMP)
228
98536f6539ee The mash grid now uses a popup editor. There is now a dropdown mash selector to replace the mash scheme.
Michiel Broek <mbroek@mbse.eu>
parents: 226
diff changeset
1102 $steps .= ',"step_temp":' . floatval($step->STEP_TEMP);
106
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1103 if ($step->STEP_TIME)
228
98536f6539ee The mash grid now uses a popup editor. There is now a dropdown mash selector to replace the mash scheme.
Michiel Broek <mbroek@mbse.eu>
parents: 226
diff changeset
1104 $steps .= ',"step_time":' . floatval($step->STEP_TIME);
106
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1105 if ($step->RAMP_TIME)
228
98536f6539ee The mash grid now uses a popup editor. There is now a dropdown mash selector to replace the mash scheme.
Michiel Broek <mbroek@mbse.eu>
parents: 226
diff changeset
1106 $steps .= ',"ramp_time":' . floatval($step->RAMP_TIME);
106
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1107 if ($step->END_TEMP)
228
98536f6539ee The mash grid now uses a popup editor. There is now a dropdown mash selector to replace the mash scheme.
Michiel Broek <mbroek@mbse.eu>
parents: 226
diff changeset
1108 $steps .= ',"end_temp":' . floatval($step->END_TEMP);
106
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1109 $steps .= "}";
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1110 }
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1111 $steps .= ']';
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1112 return $steps;
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1113 }
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1114
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1115
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1116
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1117 function do_recipes()
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1118 {
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
1119 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
1120 $len_fermentables = 0;
bdd1ec9b9c06 Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents: 45
diff changeset
1121 $len_hops = 0;
bdd1ec9b9c06 Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents: 45
diff changeset
1122 $len_miscs = 0;
49
4d27a7fb1265 Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents: 48
diff changeset
1123 $len_yeasts = 0;
48
bdd1ec9b9c06 Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents: 45
diff changeset
1124 $len_mash = 0;
bdd1ec9b9c06 Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents: 45
diff changeset
1125
106
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1126 echo " Start adding recipes to the database\n";
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1127 $sql = "TRUNCATE TABLE recipes;";
48
bdd1ec9b9c06 Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents: 45
diff changeset
1128 if (! $result = mysqli_query($db, $sql)) {
bdd1ec9b9c06 Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents: 45
diff changeset
1129 printf("Error: %s\n", mysqli_error($db));
bdd1ec9b9c06 Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents: 45
diff changeset
1130 }
bdd1ec9b9c06 Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents: 45
diff changeset
1131
106
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1132 $recipes = simplexml_load_file($brouwhulp . '/recipes.xml');
48
bdd1ec9b9c06 Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents: 45
diff changeset
1133
bdd1ec9b9c06 Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents: 45
diff changeset
1134 foreach ($recipes->RECIPE as $recipe) {
86
e977a505ea8c With recipe import calculate the OG
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
1135 $f_sugars = 0;
e977a505ea8c With recipe import calculate the OG
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
1136 $efficiency = 75;
e977a505ea8c With recipe import calculate the OG
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
1137 $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
1138 $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
1139 $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
1140 $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
1141 $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
1142 $colorw = 0;
105
d06ddc4d1af0 Added uuid and locked fields to the recipes table.
Michiel Broek <mbroek@mbse.eu>
parents: 104
diff changeset
1143 $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
1144
106
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1145 $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
1146 $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
1147 $sql .= "', locked='0";
48
bdd1ec9b9c06 Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents: 45
diff changeset
1148 if ($recipe->NOTES)
bdd1ec9b9c06 Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents: 45
diff changeset
1149 $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
1150 else
5d5fc6f7cbfe Improved recipes import. Finished inventory_suppliers.
Michiel Broek <mbroek@mbse.eu>
parents: 61
diff changeset
1151 $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
1152
14e349ff2a10 Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents: 217
diff changeset
1153 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
1154 $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
1155 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
1156 $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
1157 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
1158 $sql .= "', type='2";
64
5d5fc6f7cbfe Improved recipes import. Finished inventory_suppliers.
Michiel Broek <mbroek@mbse.eu>
parents: 61
diff changeset
1159 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
1160 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
1161
48
bdd1ec9b9c06 Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents: 45
diff changeset
1162 if ($recipe->BATCH_SIZE)
86
e977a505ea8c With recipe import calculate the OG
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
1163 $batch_size = floatval($recipe->BATCH_SIZE);
e977a505ea8c With recipe import calculate the OG
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
1164 $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
1165 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
1166 $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
1167 $sql .= "', boil_size='" . $boil_size;
48
bdd1ec9b9c06 Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents: 45
diff changeset
1168 if ($recipe->BOIL_TIME)
bdd1ec9b9c06 Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents: 45
diff changeset
1169 $sql .= "', boil_time='" . floatval($recipe->BOIL_TIME);
64
5d5fc6f7cbfe Improved recipes import. Finished inventory_suppliers.
Michiel Broek <mbroek@mbse.eu>
parents: 61
diff changeset
1170 else
5d5fc6f7cbfe Improved recipes import. Finished inventory_suppliers.
Michiel Broek <mbroek@mbse.eu>
parents: 61
diff changeset
1171 $sql .= "', boil_time='90";
48
bdd1ec9b9c06 Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents: 45
diff changeset
1172 if ($recipe->EFFICIENCY)
86
e977a505ea8c With recipe import calculate the OG
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
1173 $efficiency = floatval($recipe->EFFICIENCY);
e977a505ea8c With recipe import calculate the OG
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
1174 $sql .= "', efficiency='" . $efficiency;
e977a505ea8c With recipe import calculate the OG
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
1175 /* 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
1176 /* 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
1177 /* Don't use $recipe->EST_COLOR but recalculate it */
234
b8b5efa495bb Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
1178 $color_method = 0;
b8b5efa495bb Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
1179 if ($recipe->COLOR_METHOD == 'Morey') {
b8b5efa495bb Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
1180 $color_method = 0;
220
14e349ff2a10 Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents: 217
diff changeset
1181 $sql .= "', color_method='0";
234
b8b5efa495bb Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
1182 } else if ($recipe->COLOR_METHOD == 'Mosher') {
b8b5efa495bb Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
1183 $color_method = 1;
220
14e349ff2a10 Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents: 217
diff changeset
1184 $sql .= "', color_method='1";
234
b8b5efa495bb Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
1185 } else if ($recipe->COLOR_METHOD == 'Daniels') {
b8b5efa495bb Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
1186 $color_method = 2;
220
14e349ff2a10 Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents: 217
diff changeset
1187 $sql .= "', color_method='2";
234
b8b5efa495bb Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
1188 } 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
1189 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
1190
48
bdd1ec9b9c06 Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents: 45
diff changeset
1191 if ($recipe->IBU)
bdd1ec9b9c06 Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents: 45
diff changeset
1192 $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
1193 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
1194 $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
1195 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
1196 $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
1197 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
1198 $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
1199 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
1200 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
1201
102
679ddf512b65 Added est_carb field import in the recipes.
Michiel Broek <mbroek@mbse.eu>
parents: 100
diff changeset
1202 if ($recipe->CARBONATION)
679ddf512b65 Added est_carb field import in the recipes.
Michiel Broek <mbroek@mbse.eu>
parents: 100
diff changeset
1203 $sql .= "', est_carb='" . floatval($recipe->CARBONATION);
48
bdd1ec9b9c06 Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents: 45
diff changeset
1204
bdd1ec9b9c06 Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents: 45
diff changeset
1205 if ($recipe->STYLE) {
106
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1206 $sql .= recipe_style($recipe);
48
bdd1ec9b9c06 Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents: 45
diff changeset
1207 }
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
1208 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
1209 ($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
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->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
1212 $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
1213 }
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
1214 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
1215 $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
1216 } 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
1217 $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
1218 } 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
1219 $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
1220 } 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
1221 $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
1222 }
e6e5d007eb54 Added several sparge_ fields in the recipes databases. Added basic water mix calculator. Added fields on the water tab for water calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 143
diff changeset
1223 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
1224 $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
1225 }
e6e5d007eb54 Added several sparge_ fields in the recipes databases. Added basic water mix calculator. Added fields on the water tab for water calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 143
diff changeset
1226 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
1227 $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
1228 }
e6e5d007eb54 Added several sparge_ fields in the recipes databases. Added basic water mix calculator. Added fields on the water tab for water calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 143
diff changeset
1229 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
1230 $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
1231 }
230
8edca0488e65 Finished the water treatment in the recipes editor. It seems that the recipes editor is ready.
Michiel Broek <mbroek@mbse.eu>
parents: 228
diff changeset
1232 $sql .= "', sparge_source='0";
48
bdd1ec9b9c06 Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents: 45
diff changeset
1233
bdd1ec9b9c06 Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents: 45
diff changeset
1234 /*
bdd1ec9b9c06 Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents: 45
diff changeset
1235 * Put the fermentables in a json array
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 if ($recipe->FERMENTABLES) {
106
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1238 $fermentables = recipe_fermentables($recipe);
48
bdd1ec9b9c06 Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents: 45
diff changeset
1239 $sql .= "', json_fermentables='" . $fermentables;
bdd1ec9b9c06 Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents: 45
diff changeset
1240 if (strlen($fermentables) > $len_fermentables)
bdd1ec9b9c06 Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents: 45
diff changeset
1241 $len_fermentables = strlen($fermentables);
bdd1ec9b9c06 Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents: 45
diff changeset
1242 }
bdd1ec9b9c06 Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents: 45
diff changeset
1243
bdd1ec9b9c06 Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents: 45
diff changeset
1244 /*
bdd1ec9b9c06 Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents: 45
diff changeset
1245 * Put the hops in a json array
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 if ($recipe->HOPS) {
106
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1248 $hops = recipe_hops($recipe);
48
bdd1ec9b9c06 Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents: 45
diff changeset
1249 $sql .= "', json_hops='" . $hops;
bdd1ec9b9c06 Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents: 45
diff changeset
1250 if (strlen($hops) > $len_hops)
bdd1ec9b9c06 Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents: 45
diff changeset
1251 $len_hops = strlen($hops);
bdd1ec9b9c06 Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents: 45
diff changeset
1252 }
bdd1ec9b9c06 Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents: 45
diff changeset
1253
bdd1ec9b9c06 Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents: 45
diff changeset
1254 /*
bdd1ec9b9c06 Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents: 45
diff changeset
1255 * Put the miscs in a json array
bdd1ec9b9c06 Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents: 45
diff changeset
1256 */
bdd1ec9b9c06 Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents: 45
diff changeset
1257 if ($recipe->MISCS) {
106
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1258 $miscs = recipe_miscs($recipe);
48
bdd1ec9b9c06 Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents: 45
diff changeset
1259 $sql .= "', json_miscs='" . $miscs;
bdd1ec9b9c06 Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents: 45
diff changeset
1260 if (strlen($miscs) > $len_miscs)
bdd1ec9b9c06 Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents: 45
diff changeset
1261 $len_miscs = strlen($miscs);
bdd1ec9b9c06 Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents: 45
diff changeset
1262 }
bdd1ec9b9c06 Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents: 45
diff changeset
1263
49
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 * Put the yeasts in a json array
4d27a7fb1265 Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents: 48
diff changeset
1266 */
4d27a7fb1265 Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents: 48
diff changeset
1267 if ($recipe->YEASTS) {
106
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1268 $yeasts = recipe_yeasts($recipe);
49
4d27a7fb1265 Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents: 48
diff changeset
1269 $sql .= "', json_yeasts='" . $yeasts;
4d27a7fb1265 Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents: 48
diff changeset
1270 if (strlen($yeasts) > $len_yeasts)
4d27a7fb1265 Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents: 48
diff changeset
1271 $len_yeasts = strlen($yeasts);
4d27a7fb1265 Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents: 48
diff changeset
1272 }
4d27a7fb1265 Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents: 48
diff changeset
1273
4d27a7fb1265 Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents: 48
diff changeset
1274 /*
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
1275 * Get the waters
49
4d27a7fb1265 Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents: 48
diff changeset
1276 */
4d27a7fb1265 Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents: 48
diff changeset
1277 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
1278 $sql .= recipe_waters($recipe, $db);
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 /*
4d27a7fb1265 Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents: 48
diff changeset
1282 * Put the mash in a json array
4d27a7fb1265 Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents: 48
diff changeset
1283 */
4d27a7fb1265 Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents: 48
diff changeset
1284 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
1285 $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
1286 $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
1287 if ($recipe->MASH->NAME)
51
7224109adfe1 More recipe editor changes
Michiel Broek <mbroek@mbse.eu>
parents: 50
diff changeset
1288 $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
1289
49
4d27a7fb1265 Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents: 48
diff changeset
1290 if ($recipe->MASH->MASH_STEPS) {
106
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1291 $steps = recipe_mash_steps($recipe);
51
7224109adfe1 More recipe editor changes
Michiel Broek <mbroek@mbse.eu>
parents: 50
diff changeset
1292 $sql .= "', json_mashs='" . $steps;
7224109adfe1 More recipe editor changes
Michiel Broek <mbroek@mbse.eu>
parents: 50
diff changeset
1293 if (strlen($steps) > $len_mash)
7224109adfe1 More recipe editor changes
Michiel Broek <mbroek@mbse.eu>
parents: 50
diff changeset
1294 $len_mash = strlen($steps);
49
4d27a7fb1265 Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents: 48
diff changeset
1295 }
4d27a7fb1265 Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents: 48
diff changeset
1296 }
4d27a7fb1265 Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents: 48
diff changeset
1297
86
e977a505ea8c With recipe import calculate the OG
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
1298 /*
e977a505ea8c With recipe import calculate the OG
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
1299 * Added the calculated values
e977a505ea8c With recipe import calculate the OG
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
1300 * OG, FG, color, IBU
e977a505ea8c With recipe import calculate the OG
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
1301 */
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
1302 $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
1303 $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
1304 $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
1305 $sql .= "', est_fg='" . floatval($fg);
88
0a39cbdcf085 Added ABV clculation.
Michiel Broek <mbroek@mbse.eu>
parents: 87
diff changeset
1306 $abv = abvol($og, $fg);
0a39cbdcf085 Added ABV clculation.
Michiel Broek <mbroek@mbse.eu>
parents: 87
diff changeset
1307 $sql .= "', est_abv='" . floatval($abv);
234
b8b5efa495bb Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
1308 $color = kw_to_ebc($color_method, $colorw);
89
082c23b26055 Missing Water agent costs from Brouwhulp import are now added from the imported miscs database. The printed recipe report now calculates the beer color from the ingredients. Also set during recipes import. This will later allow to set the color method for each recipe individually.
Michiel Broek <mbroek@mbse.eu>
parents: 88
diff changeset
1309 $sql .= "', est_color='" . floatval($color);
48
bdd1ec9b9c06 Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents: 45
diff changeset
1310 $sql .= "';";
bdd1ec9b9c06 Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents: 45
diff changeset
1311 if (! $result = mysqli_query($db, $sql)) {
bdd1ec9b9c06 Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents: 45
diff changeset
1312 printf("Error: %s\n", mysqli_error($db));
bdd1ec9b9c06 Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents: 45
diff changeset
1313 }
bdd1ec9b9c06 Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents: 45
diff changeset
1314 }
64
5d5fc6f7cbfe Improved recipes import. Finished inventory_suppliers.
Michiel Broek <mbroek@mbse.eu>
parents: 61
diff changeset
1315 // echo "Fermentables: " . $len_fermentables . PHP_EOL;
5d5fc6f7cbfe Improved recipes import. Finished inventory_suppliers.
Michiel Broek <mbroek@mbse.eu>
parents: 61
diff changeset
1316 // echo "Hops: " . $len_hops . PHP_EOL;
5d5fc6f7cbfe Improved recipes import. Finished inventory_suppliers.
Michiel Broek <mbroek@mbse.eu>
parents: 61
diff changeset
1317 // echo "Miscs: " . $len_miscs . PHP_EOL;
5d5fc6f7cbfe Improved recipes import. Finished inventory_suppliers.
Michiel Broek <mbroek@mbse.eu>
parents: 61
diff changeset
1318 // echo "Yeasts: " . $len_yeasts . PHP_EOL;
5d5fc6f7cbfe Improved recipes import. Finished inventory_suppliers.
Michiel Broek <mbroek@mbse.eu>
parents: 61
diff changeset
1319 // echo "Mash: " . $len_mash . PHP_EOL;
48
bdd1ec9b9c06 Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents: 45
diff changeset
1320 }
bdd1ec9b9c06 Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents: 45
diff changeset
1321
bdd1ec9b9c06 Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents: 45
diff changeset
1322
bdd1ec9b9c06 Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents: 45
diff changeset
1323
106
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1324 function do_brews()
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 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
1327 $len_fermentables = 0;
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1328 $len_hops = 0;
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1329 $len_miscs = 0;
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1330 $len_yeasts = 0;
234
b8b5efa495bb Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
1331 $len_mash = 0;
106
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1332
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1333 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
1334 $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
1335 if (! $presult = mysqli_query($db, $sql)) {
106
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1336 printf("Error: %s\n", mysqli_error($db));
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1337 }
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1338
108
a466373bc23f Finished brews import
Michiel Broek <mbroek@mbse.eu>
parents: 107
diff changeset
1339 date_default_timezone_set('Europe/Amsterdam');
106
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1340 $recipes = simplexml_load_file($brouwhulp . '/brews.xml');
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1341
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1342 foreach ($recipes->RECIPE as $recipe) {
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1343 $f_sugars = 0;
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1344 $efficiency = 75;
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1345 $batch_size = 20;
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1346 $boil_size = 22;
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1347 $pCara = 0;
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1348 $pSugar = 0;
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1349 $svg = 77;
108
a466373bc23f Finished brews import
Michiel Broek <mbroek@mbse.eu>
parents: 107
diff changeset
1350 $colorw = 0;
234
b8b5efa495bb Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
1351 $stage = 0;
106
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1352 $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
1353
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
1354 $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
1355 $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
1356
111
8c4ba91adf58 Basic screens for brew products.
Michiel Broek <mbroek@mbse.eu>
parents: 108
diff changeset
1357 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
1358 $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
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 .= "', notes='";
111
8c4ba91adf58 Basic screens for brew products.
Michiel Broek <mbroek@mbse.eu>
parents: 108
diff changeset
1361 }
234
b8b5efa495bb Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
1362
b8b5efa495bb Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
1363 if ($recipe->TYPE == 'Extract')
b8b5efa495bb Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
1364 $sql .= "', type='0";
b8b5efa495bb Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
1365 else if ($recipe->TYPE == 'Partial Mash')
b8b5efa495bb Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
1366 $sql .= "', type='1";
b8b5efa495bb Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
1367 else if ($recipe->TYPE == 'All Grain')
b8b5efa495bb Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
1368 $sql .= "', type='2";
b8b5efa495bb Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
1369
106
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1370 if ($recipe->BATCH_SIZE)
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1371 $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
1372 $sql .= "', batch_size='" . $batch_size;
106
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1373 if ($recipe->BOIL_SIZE)
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1374 $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
1375 $sql .= "', boil_size='" . $boil_size;
106
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1376 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
1377 $sql .= "', boil_time='" . floatval($recipe->BOIL_TIME);
106
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1378 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
1379 $sql .= "', boil_time='90";
106
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1380 if ($recipe->EFFICIENCY)
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1381 $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
1382 $sql .= "', efficiency='" . $efficiency;
106
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1383 /* Don't use $recipe->EST_OG but recalculate it */
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1384 /* Don't use $recipe->EST_FG but recalculate it */
234
b8b5efa495bb Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
1385 /* Don't use $recipe->EST_COLOR but recalculate it */
b8b5efa495bb Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
1386 $color_method = 0;
b8b5efa495bb Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
1387 if ($recipe->COLOR_METHOD == 'Morey') {
b8b5efa495bb Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
1388 $color_method = 0;
b8b5efa495bb Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
1389 $sql .= "', color_method='0";
b8b5efa495bb Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
1390 } else if ($recipe->COLOR_METHOD == 'Mosher') {
b8b5efa495bb Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
1391 $color_method = 1;
b8b5efa495bb Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
1392 $sql .= "', color_method='1";
b8b5efa495bb Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
1393 } else if ($recipe->COLOR_METHOD == 'Daniels') {
b8b5efa495bb Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
1394 $color_method = 2;
b8b5efa495bb Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
1395 $sql .= "', color_method='2";
b8b5efa495bb Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
1396 } else
b8b5efa495bb Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
1397 echo "Unknown COLOR_METHO " . $recipe->COLOR_METHOD . PHP_EOL;
b8b5efa495bb Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
1398
b8b5efa495bb Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
1399 if ($recipe->IBU)
b8b5efa495bb Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
1400 $sql .= "', est_ibu='" . floatval($recipe->IBU);
b8b5efa495bb Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
1401 if ($recipe->IBU_METHOD == 'Tinseth')
b8b5efa495bb Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
1402 $sql .= "', ibu_method='0";
b8b5efa495bb Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
1403 else if ($recipe->IBU_METHOD == 'Rager')
b8b5efa495bb Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
1404 $sql .= "', ibu_method='1";
b8b5efa495bb Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
1405 else if ($recipe->IBU_METHOD == 'Daniels')
b8b5efa495bb Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
1406 $sql .= "', ibu_method='2";
b8b5efa495bb Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
1407 else
b8b5efa495bb Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
1408 echo "Unknown IBU_METHOD " . $recipe->IBU_METHOD . PHP_EOL;
b8b5efa495bb Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
1409
106
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1410 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
1411 $sql .= "', est_carb='" . floatval($recipe->CARBONATION);
106
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1412
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1413 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
1414 $sql .= recipe_style($recipe);
106
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
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
1417 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
1418 ($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
1419 }
e6e5d007eb54 Added several sparge_ fields in the recipes databases. Added basic water mix calculator. Added fields on the water tab for water calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 143
diff changeset
1420 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
1421 $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
1422 }
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
1423 if ($recipe->SPARGE_ACID_TYPE && ($recipe->SPARGE_ACID_TYPE == "Lactic")) {
234
b8b5efa495bb Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
1424 $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
1425 } else if ($recipe->SPARGE_ACID_TYPE && ($recipe->SPARGE_ACID_TYPE == "Hydrochloric")) {
234
b8b5efa495bb Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
1426 $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
1427 } else if ($recipe->SPARGE_ACID_TYPE && ($recipe->SPARGE_ACID_TYPE == "Phosphoric")) {
234
b8b5efa495bb Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
1428 $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
1429 } else if ($recipe->SPARGE_ACID_TYPE && ($recipe->SPARGE_ACID_TYPE == "Sulfuric")) {
234
b8b5efa495bb Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
1430 $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
1431 }
e6e5d007eb54 Added several sparge_ fields in the recipes databases. Added basic water mix calculator. Added fields on the water tab for water calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 143
diff changeset
1432 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
1433 $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
1434 }
e6e5d007eb54 Added several sparge_ fields in the recipes databases. Added basic water mix calculator. Added fields on the water tab for water calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 143
diff changeset
1435 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
1436 $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
1437 }
e6e5d007eb54 Added several sparge_ fields in the recipes databases. Added basic water mix calculator. Added fields on the water tab for water calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 143
diff changeset
1438 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
1439 $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
1440 }
230
8edca0488e65 Finished the water treatment in the recipes editor. It seems that the recipes editor is ready.
Michiel Broek <mbroek@mbse.eu>
parents: 228
diff changeset
1441 $sql .= "', sparge_source='0";
147
e6e5d007eb54 Added several sparge_ fields in the recipes databases. Added basic water mix calculator. Added fields on the water tab for water calculations.
Michiel Broek <mbroek@mbse.eu>
parents: 143
diff changeset
1442
106
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 * Put the fermentables in a json array
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1445 */
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1446 if ($recipe->FERMENTABLES) {
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1447 $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
1448 $sql .= "', json_fermentables='" . $fermentables;
106
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1449 if (strlen($fermentables) > $len_fermentables)
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1450 $len_fermentables = strlen($fermentables);
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 /*
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1454 * Put the hops in a json array
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1455 */
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1456 if ($recipe->HOPS) {
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1457 $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
1458 $sql .= "', json_hops='" . $hops;
106
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1459 if (strlen($hops) > $len_hops)
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1460 $len_hops = strlen($hops);
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1461 }
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1462
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1463 /*
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1464 * Put the miscs in a json array
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1465 */
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1466 if ($recipe->MISCS) {
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1467 $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
1468 $sql .= "', json_miscs='" . $miscs;
106
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1469 if (strlen($miscs) > $len_miscs)
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1470 $len_miscs = strlen($miscs);
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1471 }
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1472
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1473 /*
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1474 * Put the yeasts in a json array
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1475 */
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1476 if ($recipe->YEASTS) {
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1477 $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
1478 $sql .= "', json_yeasts='" . $yeasts;
106
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1479 if (strlen($yeasts) > $len_yeasts)
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1480 $len_yeasts = strlen($yeasts);
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1481 }
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1482
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1483 /*
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
1484 * Get the waters
106
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1485 */
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1486 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
1487 $sql .= recipe_waters($recipe, $db);
106
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1488 }
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1489
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1490 /*
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1491 * Put the mash in a json array
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1492 */
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1493 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
1494 $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
1495 $sql .= "',sparge_ph='" . floatval($recipe->MASH->PH);
106
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1496 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
1497 $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
1498
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1499 if ($recipe->MASH->MASH_STEPS) {
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1500 $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
1501 $sql .= "', json_mashs='" . $steps;
106
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1502 if (strlen($steps) > $len_mash)
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1503 $len_mash = strlen($steps);
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1504 }
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1505 }
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1506
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1507 /*
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1508 * Added the calculated values
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1509 * OG, FG, color, IBU
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1510 */
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1511 $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
1512 $sql .= "', est_og='" . floatval($og);
106
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1513 $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
1514 $sql .= "', est_fg='" . floatval($fg);
106
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1515 $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
1516 $sql .= "', est_abv='" . floatval($abv);
234
b8b5efa495bb Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
1517 $color = kw_to_ebc($color_method, $colorw);
151
2c9cfe2f0860 Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents: 150
diff changeset
1518 $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
1519 $sql .= "', code='" . mysqli_real_escape_string($db, $recipe->NR_RECIPE);
108
a466373bc23f Finished brews import
Michiel Broek <mbroek@mbse.eu>
parents: 107
diff changeset
1520
a466373bc23f Finished brews import
Michiel Broek <mbroek@mbse.eu>
parents: 107
diff changeset
1521 /*
a466373bc23f Finished brews import
Michiel Broek <mbroek@mbse.eu>
parents: 107
diff changeset
1522 * Update external logfiles
a466373bc23f Finished brews import
Michiel Broek <mbroek@mbse.eu>
parents: 107
diff changeset
1523 */
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
1524 $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
1525 $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
1526 if (! $result = mysqli_query($db, $lsql)) {
108
a466373bc23f Finished brews import
Michiel Broek <mbroek@mbse.eu>
parents: 107
diff changeset
1527 printf("Error: %s\n", mysqli_error($db));
a466373bc23f Finished brews import
Michiel Broek <mbroek@mbse.eu>
parents: 107
diff changeset
1528 }
a466373bc23f Finished brews import
Michiel Broek <mbroek@mbse.eu>
parents: 107
diff changeset
1529 $count = mysqli_affected_rows($db);
a466373bc23f Finished brews import
Michiel Broek <mbroek@mbse.eu>
parents: 107
diff changeset
1530 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
1531 $sql .= "', log_brew='1";
108
a466373bc23f Finished brews import
Michiel Broek <mbroek@mbse.eu>
parents: 107
diff changeset
1532 }
234
b8b5efa495bb Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
1533
b8b5efa495bb Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
1534 $filename = '../log/fermentation/'.$recipe->NR_RECIPE.' '.$recipe->NAME.'.log';
b8b5efa495bb Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
1535 if (file_exists($filename)) {
151
2c9cfe2f0860 Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents: 150
diff changeset
1536 $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
1537 } else {
234
b8b5efa495bb Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
1538 if ($recipe->FERM_MEASUREMENTS) {
b8b5efa495bb Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
1539 /*
b8b5efa495bb Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
1540 * There is internal logdata in the xml, create a logfile
b8b5efa495bb Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
1541 */
b8b5efa495bb Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
1542 $fp = fopen($filename, "w+");
b8b5efa495bb Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
1543 foreach ($recipe->FERM_MEASUREMENTS->FERM_MEASUREMENT as $measurement) {
b8b5efa495bb Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
1544 $dt = substr($measurement->DATE_TIME, 6, 4).substr($measurement->DATE_TIME,2,4).substr($measurement->DATE_TIME,0,2);
b8b5efa495bb Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
1545 $dt .= ' '.substr($measurement->DATE_TIME, 11,8);
b8b5efa495bb Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
1546 $line = $dt.',NONE,PRIMARY,';
b8b5efa495bb Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
1547 $line .= sprintf("%.1f",floatval($measurement->TEMP_SENSOR_1)) .',';
b8b5efa495bb Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
1548 $line .= sprintf("%.1f",floatval($measurement->TEMP_SENSOR_2)) .',';
b8b5efa495bb Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
1549 $line .= 'NA,NA,NA,NA,NA,NA,NA,NA,' . PHP_EOL;
b8b5efa495bb Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
1550 fwrite($fp, $line);
b8b5efa495bb Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
1551 }
b8b5efa495bb Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
1552 fclose($fp);
151
2c9cfe2f0860 Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents: 150
diff changeset
1553 $sql .= "', log_fermentation='1";
234
b8b5efa495bb Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
1554 } else {
b8b5efa495bb Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
1555 $sql .= "', log_fermentation='0";
108
a466373bc23f Finished brews import
Michiel Broek <mbroek@mbse.eu>
parents: 107
diff changeset
1556 }
a466373bc23f Finished brews import
Michiel Broek <mbroek@mbse.eu>
parents: 107
diff changeset
1557 }
106
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1558
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1559 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
1560 $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
1561 $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
1562 $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
1563 $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
1564 $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
1565 $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
1566 $sql .= "', eq_tun_specific_heat='" . floatval($recipe->EQUIPMENT->TUN_SPECIFIC_HEAT);
234
b8b5efa495bb Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
1567 $sql .= "', eq_tun_material='" . $recipe->EQUIPMENT->TUN_MATERIAL;
151
2c9cfe2f0860 Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents: 150
diff changeset
1568 $sql .= "', eq_tun_height='" . floatval($recipe->EQUIPMENT->TUN_HEIGHT);
108
a466373bc23f Finished brews import
Michiel Broek <mbroek@mbse.eu>
parents: 107
diff changeset
1569 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
1570 $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
1571 $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
1572 /*
4935e86b2775 Small fixes for prject import from Brouwhulp. Fixes for poduct database read/write. New menu entries. Equipment select in product editor. Started brewday editor. Added conditions on some buttons and edit fields. Screen layout changes.
Michiel Broek <mbroek@mbse.eu>
parents: 111
diff changeset
1573 * 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
1574 * 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
1575 * 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
1576 * 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
1577 */
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
1578 $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
1579 $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
1580 ($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
1581 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
1582 $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
1583 $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
1584 $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
1585 $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
1586 $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
1587 $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
1588 $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
1589 $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
1590 $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
1591 $sql .= "', eq_efficiency='" . floatval($recipe->EQUIPMENT->EFFICIENCY);
106
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1592 }
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1593
108
a466373bc23f Finished brews import
Michiel Broek <mbroek@mbse.eu>
parents: 107
diff changeset
1594 if (($recipe->DATE) && (! $recipe->TIME_STARTED) && (! $recipe->TIME_ENDED)) {
a466373bc23f Finished brews import
Michiel Broek <mbroek@mbse.eu>
parents: 107
diff changeset
1595 /* 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
1596 $sql .= "', birth='" . date("Y-m-d");
234
b8b5efa495bb Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
1597 $stage = 1;
108
a466373bc23f Finished brews import
Michiel Broek <mbroek@mbse.eu>
parents: 107
diff changeset
1598 }
a466373bc23f Finished brews import
Michiel Broek <mbroek@mbse.eu>
parents: 107
diff changeset
1599
107
8b4fdadf320c Added brewday data
Michiel Broek <mbroek@mbse.eu>
parents: 106
diff changeset
1600 if (($recipe->DATE) && ($recipe->TIME_STARTED) && ($recipe->TIME_ENDED)) {
8b4fdadf320c Added brewday data
Michiel Broek <mbroek@mbse.eu>
parents: 106
diff changeset
1601 /* We have brew data */
234
b8b5efa495bb Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
1602 $stage = 3; // Need to think about during a brew...
108
a466373bc23f Finished brews import
Michiel Broek <mbroek@mbse.eu>
parents: 107
diff changeset
1603 $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
1604 $sql .= "', birth='" . $brewdate;
108
a466373bc23f Finished brews import
Michiel Broek <mbroek@mbse.eu>
parents: 107
diff changeset
1605 $date_start = $brewdate.' '.$recipe->TIME_STARTED;
a466373bc23f Finished brews import
Michiel Broek <mbroek@mbse.eu>
parents: 107
diff changeset
1606 $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
1607 $sql .= "', brew_date_start='" . $date_start;
107
8b4fdadf320c Added brewday data
Michiel Broek <mbroek@mbse.eu>
parents: 106
diff changeset
1608
8b4fdadf320c Added brewday data
Michiel Broek <mbroek@mbse.eu>
parents: 106
diff changeset
1609 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
1610 $sql .= "', brew_mash_ph='" . floatval($recipe->PH_ADJUSTED);
107
8b4fdadf320c Added brewday data
Michiel Broek <mbroek@mbse.eu>
parents: 106
diff changeset
1611 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
1612 $sql .= "', brew_mash_sg='" . floatval($recipe->SG_END_MASH);
107
8b4fdadf320c Added brewday data
Michiel Broek <mbroek@mbse.eu>
parents: 106
diff changeset
1613 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
1614 $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
1615 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
1616 $sql .= "', brew_sparge_ph='" . floatval($recipe->MASH->PH);
107
8b4fdadf320c Added brewday data
Michiel Broek <mbroek@mbse.eu>
parents: 106
diff changeset
1617 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
1618 $sql .= "', brew_sparge_volume='" . floatval($recipe->VOLUME_HLT);
107
8b4fdadf320c Added brewday data
Michiel Broek <mbroek@mbse.eu>
parents: 106
diff changeset
1619 if ($recipe->VOLUME_BEFORE_BOIL)
246
8580a08cbaa7 Tab brouwdag automatische berekening rendement voor en na het koken. Bij import worden de kook volumes omgerekend naar 100 graden.
Michiel Broek <mbroek@mbse.eu>
parents: 234
diff changeset
1620 $sql .= "', brew_preboil_volume='" . sprintf("%.5f",floatval($recipe->VOLUME_BEFORE_BOIL) * 1.04);
107
8b4fdadf320c Added brewday data
Michiel Broek <mbroek@mbse.eu>
parents: 106
diff changeset
1621 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
1622 $sql .= "', brew_preboil_sg='" . floatval($recipe->OG_BEFORE_BOIL);
107
8b4fdadf320c Added brewday data
Michiel Broek <mbroek@mbse.eu>
parents: 106
diff changeset
1623 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
1624 $sql .= "', brew_preboil_ph='" . floatval($recipe->PH_BEFORE_BOIL);
107
8b4fdadf320c Added brewday data
Michiel Broek <mbroek@mbse.eu>
parents: 106
diff changeset
1625 if ($recipe->VOLUME_AFTER_BOIL)
246
8580a08cbaa7 Tab brouwdag automatische berekening rendement voor en na het koken. Bij import worden de kook volumes omgerekend naar 100 graden.
Michiel Broek <mbroek@mbse.eu>
parents: 234
diff changeset
1626 $sql .= "', brew_aboil_volume='" . sprintf("%.5f",floatval($recipe->VOLUME_AFTER_BOIL) * 1.04);
151
2c9cfe2f0860 Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents: 150
diff changeset
1627 $sql .= "', brew_aboil_sg='" . floatval($recipe->OG);
107
8b4fdadf320c Added brewday data
Michiel Broek <mbroek@mbse.eu>
parents: 106
diff changeset
1628 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
1629 $sql .= "', brew_aboil_ph='" . floatval($recipe->PH_AFTER_BOIL);
107
8b4fdadf320c Added brewday data
Michiel Broek <mbroek@mbse.eu>
parents: 106
diff changeset
1630 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
1631 $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
1632 $sql .= "', brew_whirlpool2='" . floatval($recipe->WHIRLPOOL_TIME);
234
b8b5efa495bb Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
1633
b8b5efa495bb Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
1634 if ($recipe->COOLING_METHOD == '-')
b8b5efa495bb Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
1635 $sql .= "', brew_cooling_method='0";
b8b5efa495bb Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
1636 else if ($recipe->COOLING_METHOD == 'Emersion chiller')
b8b5efa495bb Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
1637 $sql .= "', brew_cooling_method='1";
b8b5efa495bb Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
1638 else if ($recipe->COOLING_METHOD == 'Counterflow chiller')
b8b5efa495bb Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
1639 $sql .= "', brew_cooling_method='2";
b8b5efa495bb Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
1640 else if ($recipe->COOLING_METHOD == 'Au bain marie')
b8b5efa495bb Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
1641 $sql .= "', brew_cooling_method='3";
b8b5efa495bb Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
1642 else if ($recipe->COOLING_METHOD == 'Natural')
b8b5efa495bb Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
1643 $sql .= "', brew_cooling_method='4";
b8b5efa495bb Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
1644 else
b8b5efa495bb Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
1645 echo "Unknown COOLING_METHOD " . $recipe->COOLING_METHOD . PHP_EOL;
151
2c9cfe2f0860 Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents: 150
diff changeset
1646 $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
1647 $sql .= "', brew_cooling_to='" . floatval($recipe->COOLING_TO);
107
8b4fdadf320c Added brewday data
Michiel Broek <mbroek@mbse.eu>
parents: 106
diff changeset
1648 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
1649 $sql .= "', brew_fermenter_volume='" . floatval($recipe->VOLUME_FERMENTER);
107
8b4fdadf320c Added brewday data
Michiel Broek <mbroek@mbse.eu>
parents: 106
diff changeset
1650 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
1651 $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
1652 $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
1653 $sql .= "', brew_fermenter_ibu='" . floatval($recipe->IBU);
234
b8b5efa495bb Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
1654
b8b5efa495bb Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
1655 if ($recipe->AERATION_TYPE == 'None')
b8b5efa495bb Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
1656 $sql .= "', brew_aeration_type='0";
b8b5efa495bb Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
1657 else if ($recipe->AERATION_TYPE == 'Air') {
b8b5efa495bb Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
1658 $sql .= "', brew_aeration_type='1";
151
2c9cfe2f0860 Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents: 150
diff changeset
1659 $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
1660 $sql .= "', brew_aeration_time='" . floatval($recipe->AERATION_TIME);
234
b8b5efa495bb Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
1661 } else if ($recipe->AERATION_TYPE == 'Oxygen') {
b8b5efa495bb Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
1662 $sql .= "', brew_aeration_type='2";
b8b5efa495bb Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
1663 $sql .= "', brew_aeration_speed='" . floatval($recipe->AERATION_SPEED);
b8b5efa495bb Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
1664 $sql .= "', brew_aeration_time='" . floatval($recipe->AERATION_TIME);
b8b5efa495bb Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
1665 } else
b8b5efa495bb Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
1666 echo "Unknown AERATION_TYPE " . $recipe->AERATION_TYPE . PHP_EOL;
b8b5efa495bb Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
1667
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
1668 $sql .= "', brew_date_end='" . $date_end;
107
8b4fdadf320c Added brewday data
Michiel Broek <mbroek@mbse.eu>
parents: 106
diff changeset
1669 }
108
a466373bc23f Finished brews import
Michiel Broek <mbroek@mbse.eu>
parents: 107
diff changeset
1670
163
4a4cc3497a57 Added the packaging tab contents.
Michiel Broek <mbroek@mbse.eu>
parents: 154
diff changeset
1671 $sql .= "', og='" . floatval($recipe->OG);
4a4cc3497a57 Added the packaging tab contents.
Michiel Broek <mbroek@mbse.eu>
parents: 154
diff changeset
1672 $sql .= "', fg='" . floatval($recipe->FG);
4a4cc3497a57 Added the packaging tab contents.
Michiel Broek <mbroek@mbse.eu>
parents: 154
diff changeset
1673
234
b8b5efa495bb Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
1674 if ($recipe->PRIMARY_AGE && ($stage >= 3)) {
108
a466373bc23f Finished brews import
Michiel Broek <mbroek@mbse.eu>
parents: 107
diff changeset
1675 /* 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
1676 $pdate = new DateTime($brewdate);
a466373bc23f Finished brews import
Michiel Broek <mbroek@mbse.eu>
parents: 107
diff changeset
1677 $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
1678 $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
1679 $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
1680 $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
1681 $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
1682 $sql .= "', primary_end_date='" . $pdate->format("Y-m-d");
234
b8b5efa495bb Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
1683 $stage = 4; // Secondary
108
a466373bc23f Finished brews import
Michiel Broek <mbroek@mbse.eu>
parents: 107
diff changeset
1684
234
b8b5efa495bb Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
1685 if ($recipe->SECONDARY_AGE && ($stage >= 4)) {
108
a466373bc23f Finished brews import
Michiel Broek <mbroek@mbse.eu>
parents: 107
diff changeset
1686 $sdate = new DateTime($brewdate);
a466373bc23f Finished brews import
Michiel Broek <mbroek@mbse.eu>
parents: 107
diff changeset
1687 $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
1688 $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
1689 $sql .= "', secondary_end_date='" . $sdate->format("Y-m-d");
234
b8b5efa495bb Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
1690 $stage = 5; // Tertiary
107
8b4fdadf320c Added brewday data
Michiel Broek <mbroek@mbse.eu>
parents: 106
diff changeset
1691
234
b8b5efa495bb Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
1692 if ($recipe->TERTIARY_TEMP && ($stage >= 5)) {
151
2c9cfe2f0860 Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents: 150
diff changeset
1693 $sql .= "', tertiary_temp='" . floatval($recipe->TERTIARY_TEMP);
108
a466373bc23f Finished brews import
Michiel Broek <mbroek@mbse.eu>
parents: 107
diff changeset
1694 }
a466373bc23f Finished brews import
Michiel Broek <mbroek@mbse.eu>
parents: 107
diff changeset
1695 }
a466373bc23f Finished brews import
Michiel Broek <mbroek@mbse.eu>
parents: 107
diff changeset
1696 }
a466373bc23f Finished brews import
Michiel Broek <mbroek@mbse.eu>
parents: 107
diff changeset
1697
a466373bc23f Finished brews import
Michiel Broek <mbroek@mbse.eu>
parents: 107
diff changeset
1698 if ($recipe->DATE_BOTTLING && ($recipe->AMOUNT_BOTTLING || $recipe->AMOUNT_KEGGED) &&
234
b8b5efa495bb Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
1699 ($recipe->AMOUNT_PRIMING || $recipe->AMOUNT_PRIMING_KEGS) && ($stage >= 5)) {
108
a466373bc23f Finished brews import
Michiel Broek <mbroek@mbse.eu>
parents: 107
diff changeset
1700 $bdate = substr($recipe->DATE_BOTTLING, 6, 4).substr($recipe->DATE_BOTTLING,2,4).substr($recipe->DATE_BOTTLING,0,2);
151
2c9cfe2f0860 Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents: 150
diff changeset
1701 $sql .= "', package_date='" . $bdate;
234
b8b5efa495bb Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
1702 $stage = 6; // Package
108
a466373bc23f Finished brews import
Michiel Broek <mbroek@mbse.eu>
parents: 107
diff changeset
1703 $dStart = new DateTime($bdate);
a466373bc23f Finished brews import
Michiel Broek <mbroek@mbse.eu>
parents: 107
diff changeset
1704 $dEnd = new DateTime('');
a466373bc23f Finished brews import
Michiel Broek <mbroek@mbse.eu>
parents: 107
diff changeset
1705 $dDiff = $dStart->diff($dEnd);
a466373bc23f Finished brews import
Michiel Broek <mbroek@mbse.eu>
parents: 107
diff changeset
1706 $age = floatval($dDiff->days);
150
159d7a89fcef Better stage detection during product import from brouwhulp. Added tooltips for treated water.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
1707 if ($age == 0) { // Package day
234
b8b5efa495bb Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
1708 $stage = 6;
150
159d7a89fcef Better stage detection during product import from brouwhulp. Added tooltips for treated water.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
1709 } else if ($age < 14) { // Carbonation period
234
b8b5efa495bb Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
1710 $stage = 7;
150
159d7a89fcef Better stage detection during product import from brouwhulp. Added tooltips for treated water.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
1711 } else if ($age < 42) { // Mature, fixed 6 weeks
234
b8b5efa495bb Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
1712 $stage = 8;
150
159d7a89fcef Better stage detection during product import from brouwhulp. Added tooltips for treated water.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
1713 } else { // Ready for tasting.
234
b8b5efa495bb Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
1714 $stage = 9;
150
159d7a89fcef Better stage detection during product import from brouwhulp. Added tooltips for treated water.
Michiel Broek <mbroek@mbse.eu>
parents: 149
diff changeset
1715 }
107
8b4fdadf320c Added brewday data
Michiel Broek <mbroek@mbse.eu>
parents: 106
diff changeset
1716
108
a466373bc23f Finished brews import
Michiel Broek <mbroek@mbse.eu>
parents: 107
diff changeset
1717 if ($recipe->AMOUNT_BOTTLING && $recipe->AMOUNT_PRIMING) {
151
2c9cfe2f0860 Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents: 150
diff changeset
1718 $sql .= "', bottle_amount='" . floatval($recipe->AMOUNT_BOTTLING);
2c9cfe2f0860 Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents: 150
diff changeset
1719 $sql .= "', bottle_carbonation='" . floatval($recipe->CARBONATION);
234
b8b5efa495bb Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
1720
163
4a4cc3497a57 Added the packaging tab contents.
Michiel Broek <mbroek@mbse.eu>
parents: 154
diff changeset
1721 if ($recipe->PRIMING_SUGAR_BOTTLES == "Saccharose")
234
b8b5efa495bb Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
1722 $sql .= "', bottle_priming_sugar='0";
163
4a4cc3497a57 Added the packaging tab contents.
Michiel Broek <mbroek@mbse.eu>
parents: 154
diff changeset
1723 else if ($recipe->PRIMING_SUGAR_BOTTLES == "Glucose or dextrose")
234
b8b5efa495bb Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
1724 $sql .= "', bottle_priming_sugar='1";
163
4a4cc3497a57 Added the packaging tab contents.
Michiel Broek <mbroek@mbse.eu>
parents: 154
diff changeset
1725 else if ($recipe->PRIMING_SUGAR_BOTTLES == "Honey")
234
b8b5efa495bb Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
1726 $sql .= "', bottle_priming_sugar='2";
163
4a4cc3497a57 Added the packaging tab contents.
Michiel Broek <mbroek@mbse.eu>
parents: 154
diff changeset
1727 else if ($recipe->PRIMING_SUGAR_BOTTLES == "DME")
234
b8b5efa495bb Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
1728 $sql .= "', bottle_priming_sugar='3";
163
4a4cc3497a57 Added the packaging tab contents.
Michiel Broek <mbroek@mbse.eu>
parents: 154
diff changeset
1729 else if ($recipe->PRIMING_SUGAR_BOTTLES == "Molassis")
234
b8b5efa495bb Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
1730 $sql .= "', bottle_priming_sugar='4";
151
2c9cfe2f0860 Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents: 150
diff changeset
1731 $sql .= "', bottle_priming_amount='" . floatval($recipe->AMOUNT_PRIMING);
2c9cfe2f0860 Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents: 150
diff changeset
1732 $sql .= "', bottle_carbonation_temp='" . floatval($recipe->CARBONATION_TEMP);
108
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 if ($recipe->AMOUNT_KEGGED && $recipe->AMOUNT_PRIMING_KEGS) {
151
2c9cfe2f0860 Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents: 150
diff changeset
1735 $sql .= "', keg_amount='" . floatval($recipe->AMOUNT_KEGGED);
2c9cfe2f0860 Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents: 150
diff changeset
1736 $sql .= "', keg_carbonation='" . floatval($recipe->CARBONATION); // Lijkt wel hetzelfde als bottles
163
4a4cc3497a57 Added the packaging tab contents.
Michiel Broek <mbroek@mbse.eu>
parents: 154
diff changeset
1737 if ($recipe->PRIMING_SUGAR_BOTTLES == "Saccharose")
234
b8b5efa495bb Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
1738 $sql .= "', keg_priming_sugar='0";
163
4a4cc3497a57 Added the packaging tab contents.
Michiel Broek <mbroek@mbse.eu>
parents: 154
diff changeset
1739 else if ($recipe->PRIMING_SUGAR_BOTTLES == "Glucose or dextrose")
234
b8b5efa495bb Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
1740 $sql .= "', keg_priming_sugar='1";
163
4a4cc3497a57 Added the packaging tab contents.
Michiel Broek <mbroek@mbse.eu>
parents: 154
diff changeset
1741 else if ($recipe->PRIMING_SUGAR_BOTTLES == "Honey")
234
b8b5efa495bb Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
1742 $sql .= "', keg_priming_sugar='2";
163
4a4cc3497a57 Added the packaging tab contents.
Michiel Broek <mbroek@mbse.eu>
parents: 154
diff changeset
1743 else if ($recipe->PRIMING_SUGAR_BOTTLES == "DME")
234
b8b5efa495bb Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
1744 $sql .= "', keg_priming_sugar='3";
163
4a4cc3497a57 Added the packaging tab contents.
Michiel Broek <mbroek@mbse.eu>
parents: 154
diff changeset
1745 else if ($recipe->PRIMING_SUGAR_BOTTLES == "Molassis")
234
b8b5efa495bb Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
1746 $sql .= "', keg_priming_sugar='4";
151
2c9cfe2f0860 Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents: 150
diff changeset
1747 $sql .= "', keg_priming_amount='" . floatval($recipe->AMOUNT_PRIMING_KEGS);
2c9cfe2f0860 Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents: 150
diff changeset
1748 $sql .= "', keg_carbonation_temp='" . floatval($recipe->KEG_CARB_TEMP);
2c9cfe2f0860 Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents: 150
diff changeset
1749 ($recipe->FORCED_CARB_KEGS == 'TRUE') ? $sql .= "', keg_forced_carb='1" : $sql .= "', keg_forced_carb='0";
2c9cfe2f0860 Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents: 150
diff changeset
1750 $sql .= "', keg_pressure='" . floatval($recipe->KEG_PRESSURE);
108
a466373bc23f Finished brews import
Michiel Broek <mbroek@mbse.eu>
parents: 107
diff changeset
1751 }
a466373bc23f Finished brews import
Michiel Broek <mbroek@mbse.eu>
parents: 107
diff changeset
1752 }
a466373bc23f Finished brews import
Michiel Broek <mbroek@mbse.eu>
parents: 107
diff changeset
1753
234
b8b5efa495bb Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
1754 if ($recipe->TASTE_NOTES && $recipe->TASTING_RATE && $recipe->TASTE_DATE && ($stage >= 9)) {
b8b5efa495bb Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
1755 $stage = 10; // Ready
151
2c9cfe2f0860 Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents: 150
diff changeset
1756 $sql .= "', taste_notes='" . mysqli_real_escape_string($db, $recipe->TASTE_NOTES);
2c9cfe2f0860 Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents: 150
diff changeset
1757 $sql .= "', taste_rate='" . floatval($recipe->TASTING_RATE);
108
a466373bc23f Finished brews import
Michiel Broek <mbroek@mbse.eu>
parents: 107
diff changeset
1758 $tdate = substr($recipe->TASTE_DATE, 6, 4).substr($recipe->TASTE_DATE,2,4).substr($recipe->TASTE_DATE,0,2);
151
2c9cfe2f0860 Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents: 150
diff changeset
1759 $sql .= "', taste_date='" . $tdate;
2c9cfe2f0860 Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents: 150
diff changeset
1760 $sql .= "', taste_color='" . mysqli_real_escape_string($db, $recipe->TASTE_COLOR);
2c9cfe2f0860 Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents: 150
diff changeset
1761 $sql .= "', taste_transparency='" . mysqli_real_escape_string($db, $recipe->TASTE_TRANSPARENCY);
2c9cfe2f0860 Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents: 150
diff changeset
1762 $sql .= "', taste_head='" . mysqli_real_escape_string($db, $recipe->TASTE_HEAD);
2c9cfe2f0860 Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents: 150
diff changeset
1763 $sql .= "', taste_aroma='" . mysqli_real_escape_string($db, $recipe->TASTE_AROMA);
2c9cfe2f0860 Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents: 150
diff changeset
1764 $sql .= "', taste_taste='" . mysqli_real_escape_string($db, $recipe->TASTE_TASTE);
2c9cfe2f0860 Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents: 150
diff changeset
1765 $sql .= "', taste_mouthfeel='" . mysqli_real_escape_string($db, $recipe->TASTE_MOUTHFEEL);
2c9cfe2f0860 Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents: 150
diff changeset
1766 $sql .= "', taste_aftertaste='" . mysqli_real_escape_string($db, $recipe->TASTE_AFTERTASTE);
108
a466373bc23f Finished brews import
Michiel Broek <mbroek@mbse.eu>
parents: 107
diff changeset
1767 }
a466373bc23f Finished brews import
Michiel Broek <mbroek@mbse.eu>
parents: 107
diff changeset
1768
151
2c9cfe2f0860 Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents: 150
diff changeset
1769 ($recipe->INVENTORY_REDUCED == 'TRUE') ? $sql .= "', inventory_reduced='1" : $sql .= "', inventory_reduced='0";
234
b8b5efa495bb Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
1770 if (($recipe->LOCKED == 'TRUE') && ($stage == 10)) {
151
2c9cfe2f0860 Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents: 150
diff changeset
1771 $sql .= "', locked='1";
234
b8b5efa495bb Import products uses indexes.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
1772 $stage = 11;
108
a466373bc23f Finished brews import
Michiel Broek <mbroek@mbse.eu>
parents: 107
diff changeset
1773 } else {
151
2c9cfe2f0860 Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents: 150
diff changeset
1774 $sql .= "', locked='0";
108
a466373bc23f Finished brews import
Michiel Broek <mbroek@mbse.eu>
parents: 107
diff changeset
1775 }
a466373bc23f Finished brews import
Michiel Broek <mbroek@mbse.eu>
parents: 107
diff changeset
1776
151
2c9cfe2f0860 Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents: 150
diff changeset
1777 $sql .= "', stage='" . $stage;
108
a466373bc23f Finished brews import
Michiel Broek <mbroek@mbse.eu>
parents: 107
diff changeset
1778 // echo ' '.$brewdate.' '.$recipe->NR_RECIPE.' '.$stage . PHP_EOL;
a466373bc23f Finished brews import
Michiel Broek <mbroek@mbse.eu>
parents: 107
diff changeset
1779
151
2c9cfe2f0860 Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents: 150
diff changeset
1780 $sql .= "';";
2c9cfe2f0860 Merged prod_main and prod_recipe database tables into products. Added recipe tabs in the products editor.
Michiel Broek <mbroek@mbse.eu>
parents: 150
diff changeset
1781 if (! $rresult = mysqli_query($db, $sql)) {
106
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1782 printf("Error: %s\n", mysqli_error($db));
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1783 }
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1784 }
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1785 }
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1786
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1787
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1788
64
5d5fc6f7cbfe Improved recipes import. Finished inventory_suppliers.
Michiel Broek <mbroek@mbse.eu>
parents: 61
diff changeset
1789 do_fermentables();
5d5fc6f7cbfe Improved recipes import. Finished inventory_suppliers.
Michiel Broek <mbroek@mbse.eu>
parents: 61
diff changeset
1790 do_hops();
5d5fc6f7cbfe Improved recipes import. Finished inventory_suppliers.
Michiel Broek <mbroek@mbse.eu>
parents: 61
diff changeset
1791 do_yeasts();
5d5fc6f7cbfe Improved recipes import. Finished inventory_suppliers.
Michiel Broek <mbroek@mbse.eu>
parents: 61
diff changeset
1792 do_miscs();
250
30e7d6ea119b Don't overwrite the inventories water, equipment and profiles water, styles and mash.
Michiel Broek <mbroek@mbse.eu>
parents: 246
diff changeset
1793 //do_waters();
30e7d6ea119b Don't overwrite the inventories water, equipment and profiles water, styles and mash.
Michiel Broek <mbroek@mbse.eu>
parents: 246
diff changeset
1794 //do_equipments();
30e7d6ea119b Don't overwrite the inventories water, equipment and profiles water, styles and mash.
Michiel Broek <mbroek@mbse.eu>
parents: 246
diff changeset
1795 //do_styles();
30e7d6ea119b Don't overwrite the inventories water, equipment and profiles water, styles and mash.
Michiel Broek <mbroek@mbse.eu>
parents: 246
diff changeset
1796 //do_mash();
106
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1797 do_recipes();
c64d979613ab Prepare for production brews databases
Michiel Broek <mbroek@mbse.eu>
parents: 105
diff changeset
1798 do_brews();
48
bdd1ec9b9c06 Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents: 45
diff changeset
1799
11
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1800
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1801 mysqli_close($db);
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1802
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1803 echo "Finished adding data\n";
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1804
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1805
d341f0a91a91 Added fermentable inventory
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1806 ?>

mercurial