www/includes/db_recipes.php

Wed, 06 Dec 2023 20:26:00 +0100

author
Michiel Broek <mbroek@mbse.eu>
date
Wed, 06 Dec 2023 20:26:00 +0100
changeset 855
2d328a2a4025
parent 777
daf55c944fb0
permissions
-rw-r--r--

Fixed init scripts names in Makefile. Update crontasks to use the database to check the log entries for products.

49
4d27a7fb1265 Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1 <?php
4d27a7fb1265 Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2
50
6d94167c2697 Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents: 49
diff changeset
3 require($_SERVER['DOCUMENT_ROOT']."/config.php");
6d94167c2697 Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents: 49
diff changeset
4 require($_SERVER['DOCUMENT_ROOT']."/version.php");
49
4d27a7fb1265 Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5
4d27a7fb1265 Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6 #Connect to the database
4d27a7fb1265 Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7 $connect = mysqli_connect(DBASE_HOST, DBASE_USER, DBASE_PASS, DBASE_NAME);
4d27a7fb1265 Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8 if (! $connect) {
4d27a7fb1265 Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9 die('Connect Error (' . mysqli_connect_errno() . ') ' . mysqli_connect_error());
4d27a7fb1265 Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10 }
77
a9f8de2d7b2b Fixed most charset problems. Added fpdf library. Added inventory pdf creation.
Michiel Broek <mbroek@mbse.eu>
parents: 72
diff changeset
11 mysqli_set_charset($connect, "utf8" );
49
4d27a7fb1265 Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12
50
6d94167c2697 Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents: 49
diff changeset
13 $escapers = array("\\", "/", "\"", "\n", "\r", "\t", "\x08", "\x0c");
6d94167c2697 Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents: 49
diff changeset
14 $replacements = array("\\\\", "\\/", "\\\"", "\\n", "\\r", "\\t", "\\f", "\\b");
61
3469979f83be Added inline yeast editor
Michiel Broek <mbroek@mbse.eu>
parents: 60
diff changeset
15 $rescapers = array("'");
3469979f83be Added inline yeast editor
Michiel Broek <mbroek@mbse.eu>
parents: 60
diff changeset
16 $rreplacements = array("\\'");
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: 142
diff changeset
17 $disallowed = array('visibleindex','uniqueid','boundindex','uid','h_weight','m_weight');
50
6d94167c2697 Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents: 49
diff changeset
18
777
daf55c944fb0 Recipes backport for new dry-yeast fields and SQL error handlers.
Michiel Broek <mbroek@mbse.eu>
parents: 726
diff changeset
19 $response = array(
daf55c944fb0 Recipes backport for new dry-yeast fields and SQL error handlers.
Michiel Broek <mbroek@mbse.eu>
parents: 726
diff changeset
20 'error' => false,
daf55c944fb0 Recipes backport for new dry-yeast fields and SQL error handlers.
Michiel Broek <mbroek@mbse.eu>
parents: 726
diff changeset
21 'msg' => 'Ok',
daf55c944fb0 Recipes backport for new dry-yeast fields and SQL error handlers.
Michiel Broek <mbroek@mbse.eu>
parents: 726
diff changeset
22 );
daf55c944fb0 Recipes backport for new dry-yeast fields and SQL error handlers.
Michiel Broek <mbroek@mbse.eu>
parents: 726
diff changeset
23
60
dbbe408108ea Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents: 57
diff changeset
24 if (isset($_POST['insert']) || isset($_POST['update'])) {
dbbe408108ea Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents: 57
diff changeset
25 if (isset($_POST['insert'])) {
52
b1f2a893572f More progress on the recipes design
Michiel Broek <mbroek@mbse.eu>
parents: 51
diff changeset
26 // INSERT COMMAND
60
dbbe408108ea Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents: 57
diff changeset
27 $sql = "INSERT INTO `recipes` SET ";
dbbe408108ea Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents: 57
diff changeset
28 }
dbbe408108ea Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents: 57
diff changeset
29 if (isset($_POST['update'])) {
dbbe408108ea Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents: 57
diff changeset
30 // UPDATE COMMAND
dbbe408108ea Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents: 57
diff changeset
31 $sql = "UPDATE `recipes` SET ";
52
b1f2a893572f More progress on the recipes design
Michiel Broek <mbroek@mbse.eu>
parents: 51
diff changeset
32 }
60
dbbe408108ea Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents: 57
diff changeset
33 // Basic settings
166
635033a29c48 Fixed new recipes uuid generation and saving missing new fields.
Michiel Broek <mbroek@mbse.eu>
parents: 156
diff changeset
34 if (isset($_POST['uuid'])) {
635033a29c48 Fixed new recipes uuid generation and saving missing new fields.
Michiel Broek <mbroek@mbse.eu>
parents: 156
diff changeset
35 $sql .= "uuid='" . $_POST['uuid'];
635033a29c48 Fixed new recipes uuid generation and saving missing new fields.
Michiel Broek <mbroek@mbse.eu>
parents: 156
diff changeset
36 } else {
635033a29c48 Fixed new recipes uuid generation and saving missing new fields.
Michiel Broek <mbroek@mbse.eu>
parents: 156
diff changeset
37 $uuid = str_replace("\n", "", file_get_contents('/proc/sys/kernel/random/uuid'));
635033a29c48 Fixed new recipes uuid generation and saving missing new fields.
Michiel Broek <mbroek@mbse.eu>
parents: 156
diff changeset
38 $sql .= "uuid='" . $uuid;
635033a29c48 Fixed new recipes uuid generation and saving missing new fields.
Michiel Broek <mbroek@mbse.eu>
parents: 156
diff changeset
39 }
359
98354ef399cd Lot's of improvements for recipes and products database load and save. Insert missing yeast tolerance field for old products and recipes. Recipe locked and calc_acid fields coverted to integer. In recipe edit screen removed the Print button. It is now included in the export screen. Added recipe export to forum screen.
Michiel Broek <mbroek@mbse.eu>
parents: 352
diff changeset
40 $sql .= "', locked='" . $_POST['locked'];
166
635033a29c48 Fixed new recipes uuid generation and saving missing new fields.
Michiel Broek <mbroek@mbse.eu>
parents: 156
diff changeset
41 $sql .= "', st_name='" . mysqli_real_escape_string($connect, $_POST['st_name']);
60
dbbe408108ea Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents: 57
diff changeset
42 $sql .= "', st_letter='" . mysqli_real_escape_string($connect, $_POST['st_letter']);
dbbe408108ea Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents: 57
diff changeset
43 $sql .= "', st_guide='" . mysqli_real_escape_string($connect, $_POST['st_guide']);
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: 168
diff changeset
44 $sql .= "', st_type='" . $_POST['st_type'];
80
75b9227fb98c Added beginning of recipe print.
Michiel Broek <mbroek@mbse.eu>
parents: 77
diff changeset
45 $sql .= "', st_category='" . mysqli_real_escape_string($connect, $_POST['st_category']);
72
93a0be4f5be3 Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents: 71
diff changeset
46 $sql .= "', st_category_number='" . $_POST['st_category_number'];
60
dbbe408108ea Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents: 57
diff changeset
47 $sql .= "', st_og_min='" . $_POST['st_og_min'];
dbbe408108ea Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents: 57
diff changeset
48 $sql .= "', st_og_max='" . $_POST['st_og_max'];
dbbe408108ea Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents: 57
diff changeset
49 $sql .= "', st_fg_min='" . $_POST['st_fg_min'];
dbbe408108ea Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents: 57
diff changeset
50 $sql .= "', st_fg_max='" . $_POST['st_fg_max'];
dbbe408108ea Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents: 57
diff changeset
51 $sql .= "', st_ibu_min='" . $_POST['st_ibu_min'];
dbbe408108ea Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents: 57
diff changeset
52 $sql .= "', st_ibu_max='" . $_POST['st_ibu_max'];
dbbe408108ea Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents: 57
diff changeset
53 $sql .= "', st_color_min='" . $_POST['st_color_min'];
dbbe408108ea Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents: 57
diff changeset
54 $sql .= "', st_color_max='" . $_POST['st_color_max'];
dbbe408108ea Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents: 57
diff changeset
55 $sql .= "', st_carb_min='" . $_POST['st_carb_min'];
dbbe408108ea Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents: 57
diff changeset
56 $sql .= "', st_carb_max='" . $_POST['st_carb_max'];
dbbe408108ea Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents: 57
diff changeset
57 $sql .= "', st_abv_min='" . $_POST['st_abv_min'];
dbbe408108ea Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents: 57
diff changeset
58 $sql .= "', st_abv_max='" . $_POST['st_abv_max'];
dbbe408108ea Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents: 57
diff changeset
59 $sql .= "', name='" . mysqli_real_escape_string($connect, $_POST['name']);
dbbe408108ea Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents: 57
diff changeset
60 $sql .= "', notes='" . mysqli_real_escape_string($connect, $_POST['notes']);
dbbe408108ea Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents: 57
diff changeset
61 $sql .= "', type='" . $_POST['type'];
dbbe408108ea Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents: 57
diff changeset
62 $sql .= "', batch_size='" . $_POST['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: 80
diff changeset
63 $sql .= "', boil_size='" . $_POST['boil_size'];
60
dbbe408108ea Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents: 57
diff changeset
64 $sql .= "', boil_time='" . $_POST['boil_time'];
dbbe408108ea Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents: 57
diff changeset
65 $sql .= "', efficiency='" . $_POST['efficiency'];
dbbe408108ea Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents: 57
diff changeset
66 $sql .= "', est_og='" . $_POST['est_og'];
dbbe408108ea Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents: 57
diff changeset
67 $sql .= "', est_fg='" . $_POST['est_fg'];
72
93a0be4f5be3 Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents: 71
diff changeset
68 $sql .= "', est_abv='" . $_POST['est_abv'];
93a0be4f5be3 Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents: 71
diff changeset
69 $sql .= "', est_carb='" . $_POST['est_carb'];
60
dbbe408108ea Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents: 57
diff changeset
70 $sql .= "', est_color='" . $_POST['est_color'];
dbbe408108ea Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents: 57
diff changeset
71 $sql .= "', color_method='" . $_POST['color_method'];
dbbe408108ea Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents: 57
diff changeset
72 $sql .= "', est_ibu='" . $_POST['est_ibu'];
dbbe408108ea Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents: 57
diff changeset
73 $sql .= "', ibu_method='" . $_POST['ibu_method'];
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
74 $sql .= "', sparge_temp='" . $_POST['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
75 $sql .= "', sparge_ph='" . $_POST['sparge_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
76 $sql .= "', sparge_volume='" . $_POST['sparge_volume'];
156
35860890224c Added sparge water acid calculation. Added residual alkalinity calculation.
Michiel Broek <mbroek@mbse.eu>
parents: 154
diff changeset
77 $sql .= "', sparge_source='" . $_POST['sparge_source'];
35860890224c Added sparge water acid calculation. Added residual alkalinity calculation.
Michiel Broek <mbroek@mbse.eu>
parents: 154
diff changeset
78 $sql .= "', sparge_acid_type='" . $_POST['sparge_acid_type'];
35860890224c Added sparge water acid calculation. Added residual alkalinity calculation.
Michiel Broek <mbroek@mbse.eu>
parents: 154
diff changeset
79 $sql .= "', sparge_acid_perc='" . $_POST['sparge_acid_perc'];
35860890224c Added sparge water acid calculation. Added residual alkalinity calculation.
Michiel Broek <mbroek@mbse.eu>
parents: 154
diff changeset
80 $sql .= "', sparge_acid_amount='" . $_POST['sparge_acid_amount'];
60
dbbe408108ea Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents: 57
diff changeset
81 $sql .= "', mash_ph='" . $_POST['mash_ph'];
dbbe408108ea Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents: 57
diff changeset
82 $sql .= "', mash_name='" . $_POST['mash_name'];
359
98354ef399cd Lot's of improvements for recipes and products database load and save. Insert missing yeast tolerance field for old products and recipes. Recipe locked and calc_acid fields coverted to integer. In recipe edit screen removed the Print button. It is now included in the export screen. Added recipe export to forum screen.
Michiel Broek <mbroek@mbse.eu>
parents: 352
diff changeset
83 $sql .= "', calc_acid='" . $_POST['calc_acid'];
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
84 if (isset($_POST['w1_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
85 $sql .= "', w1_name='" . mysqli_real_escape_string($connect, $_POST['w1_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
86 $sql .= "', w1_amount='" . $_POST['w1_amount'];
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
87 $sql .= "', w1_calcium='" . $_POST['w1_calcium'];
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
88 $sql .= "', w1_sulfate='" . $_POST['w1_sulfate'];
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
89 $sql .= "', w1_chloride='" . $_POST['w1_chloride'];
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
90 $sql .= "', w1_sodium='" . $_POST['w1_sodium'];
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
91 $sql .= "', w1_magnesium='" . $_POST['w1_magnesium'];
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
92 $sql .= "', w1_total_alkalinity='" . $_POST['w1_total_alkalinity'];
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
93 $sql .= "', w1_ph='" . $_POST['w1_ph'];
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
94 $sql .= "', w1_cost='" . $_POST['w1_cost'];
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
95 }
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
96 if (isset($_POST['w2_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
97 $sql .= "', w2_name='" . mysqli_real_escape_string($connect, $_POST['w2_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
98 $sql .= "', w2_amount='" . $_POST['w2_amount'];
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
99 $sql .= "', w2_calcium='" . $_POST['w2_calcium'];
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
100 $sql .= "', w2_sulfate='" . $_POST['w2_sulfate'];
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
101 $sql .= "', w2_chloride='" . $_POST['w2_chloride'];
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
102 $sql .= "', w2_sodium='" . $_POST['w2_sodium'];
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
103 $sql .= "', w2_magnesium='" . $_POST['w2_magnesium'];
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
104 $sql .= "', w2_total_alkalinity='" . $_POST['w2_total_alkalinity'];
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
105 $sql .= "', w2_ph='" . $_POST['w2_ph'];
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
106 $sql .= "', w2_cost='" . $_POST['w2_cost'];
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
107 }
392
544d7d0183b2 Added 15 fields to the recipes table. Added 18 fields to the products table. These are calculated values that are now stored in the database so export programs can use these values without calculating them again. Product and recipe print have water and mash schedule added. Product print has brewday results added if the brewday is over. The ingredients layout changed in the product and recipe prints.
Michiel Broek <mbroek@mbse.eu>
parents: 359
diff changeset
108 $sql .= "', wg_amount='" . $_POST['wg_amount'];
544d7d0183b2 Added 15 fields to the recipes table. Added 18 fields to the products table. These are calculated values that are now stored in the database so export programs can use these values without calculating them again. Product and recipe print have water and mash schedule added. Product print has brewday results added if the brewday is over. The ingredients layout changed in the product and recipe prints.
Michiel Broek <mbroek@mbse.eu>
parents: 359
diff changeset
109 $sql .= "', wg_calcium='" . $_POST['wg_calcium'];
544d7d0183b2 Added 15 fields to the recipes table. Added 18 fields to the products table. These are calculated values that are now stored in the database so export programs can use these values without calculating them again. Product and recipe print have water and mash schedule added. Product print has brewday results added if the brewday is over. The ingredients layout changed in the product and recipe prints.
Michiel Broek <mbroek@mbse.eu>
parents: 359
diff changeset
110 $sql .= "', wg_sulfate='" . $_POST['wg_sulfate'];
544d7d0183b2 Added 15 fields to the recipes table. Added 18 fields to the products table. These are calculated values that are now stored in the database so export programs can use these values without calculating them again. Product and recipe print have water and mash schedule added. Product print has brewday results added if the brewday is over. The ingredients layout changed in the product and recipe prints.
Michiel Broek <mbroek@mbse.eu>
parents: 359
diff changeset
111 $sql .= "', wg_chloride='" . $_POST['wg_chloride'];
544d7d0183b2 Added 15 fields to the recipes table. Added 18 fields to the products table. These are calculated values that are now stored in the database so export programs can use these values without calculating them again. Product and recipe print have water and mash schedule added. Product print has brewday results added if the brewday is over. The ingredients layout changed in the product and recipe prints.
Michiel Broek <mbroek@mbse.eu>
parents: 359
diff changeset
112 $sql .= "', wg_sodium='" . $_POST['wg_sodium'];
544d7d0183b2 Added 15 fields to the recipes table. Added 18 fields to the products table. These are calculated values that are now stored in the database so export programs can use these values without calculating them again. Product and recipe print have water and mash schedule added. Product print has brewday results added if the brewday is over. The ingredients layout changed in the product and recipe prints.
Michiel Broek <mbroek@mbse.eu>
parents: 359
diff changeset
113 $sql .= "', wg_magnesium='" . $_POST['wg_magnesium'];
544d7d0183b2 Added 15 fields to the recipes table. Added 18 fields to the products table. These are calculated values that are now stored in the database so export programs can use these values without calculating them again. Product and recipe print have water and mash schedule added. Product print has brewday results added if the brewday is over. The ingredients layout changed in the product and recipe prints.
Michiel Broek <mbroek@mbse.eu>
parents: 359
diff changeset
114 $sql .= "', wg_total_alkalinity='" . $_POST['wg_total_alkalinity'];
544d7d0183b2 Added 15 fields to the recipes table. Added 18 fields to the products table. These are calculated values that are now stored in the database so export programs can use these values without calculating them again. Product and recipe print have water and mash schedule added. Product print has brewday results added if the brewday is over. The ingredients layout changed in the product and recipe prints.
Michiel Broek <mbroek@mbse.eu>
parents: 359
diff changeset
115 $sql .= "', wg_ph='" . $_POST['wg_ph'];
544d7d0183b2 Added 15 fields to the recipes table. Added 18 fields to the products table. These are calculated values that are now stored in the database so export programs can use these values without calculating them again. Product and recipe print have water and mash schedule added. Product print has brewday results added if the brewday is over. The ingredients layout changed in the product and recipe prints.
Michiel Broek <mbroek@mbse.eu>
parents: 359
diff changeset
116 $sql .= "', wb_calcium='" . $_POST['wb_calcium'];
544d7d0183b2 Added 15 fields to the recipes table. Added 18 fields to the products table. These are calculated values that are now stored in the database so export programs can use these values without calculating them again. Product and recipe print have water and mash schedule added. Product print has brewday results added if the brewday is over. The ingredients layout changed in the product and recipe prints.
Michiel Broek <mbroek@mbse.eu>
parents: 359
diff changeset
117 $sql .= "', wb_sulfate='" . $_POST['wb_sulfate'];
544d7d0183b2 Added 15 fields to the recipes table. Added 18 fields to the products table. These are calculated values that are now stored in the database so export programs can use these values without calculating them again. Product and recipe print have water and mash schedule added. Product print has brewday results added if the brewday is over. The ingredients layout changed in the product and recipe prints.
Michiel Broek <mbroek@mbse.eu>
parents: 359
diff changeset
118 $sql .= "', wb_chloride='" . $_POST['wb_chloride'];
544d7d0183b2 Added 15 fields to the recipes table. Added 18 fields to the products table. These are calculated values that are now stored in the database so export programs can use these values without calculating them again. Product and recipe print have water and mash schedule added. Product print has brewday results added if the brewday is over. The ingredients layout changed in the product and recipe prints.
Michiel Broek <mbroek@mbse.eu>
parents: 359
diff changeset
119 $sql .= "', wb_sodium='" . $_POST['wb_sodium'];
544d7d0183b2 Added 15 fields to the recipes table. Added 18 fields to the products table. These are calculated values that are now stored in the database so export programs can use these values without calculating them again. Product and recipe print have water and mash schedule added. Product print has brewday results added if the brewday is over. The ingredients layout changed in the product and recipe prints.
Michiel Broek <mbroek@mbse.eu>
parents: 359
diff changeset
120 $sql .= "', wb_magnesium='" . $_POST['wb_magnesium'];
544d7d0183b2 Added 15 fields to the recipes table. Added 18 fields to the products table. These are calculated values that are now stored in the database so export programs can use these values without calculating them again. Product and recipe print have water and mash schedule added. Product print has brewday results added if the brewday is over. The ingredients layout changed in the product and recipe prints.
Michiel Broek <mbroek@mbse.eu>
parents: 359
diff changeset
121 $sql .= "', wb_total_alkalinity='" . $_POST['wb_total_alkalinity'];
544d7d0183b2 Added 15 fields to the recipes table. Added 18 fields to the products table. These are calculated values that are now stored in the database so export programs can use these values without calculating them again. Product and recipe print have water and mash schedule added. Product print has brewday results added if the brewday is over. The ingredients layout changed in the product and recipe prints.
Michiel Broek <mbroek@mbse.eu>
parents: 359
diff changeset
122 $sql .= "', wb_ph='" . $_POST['wb_ph'];
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: 168
diff changeset
123 $sql .= "', wa_acid_name='" . $_POST['wa_acid_name'];
14e349ff2a10 Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents: 168
diff changeset
124 $sql .= "', wa_acid_perc='" . $_POST['wa_acid_perc'];
14e349ff2a10 Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents: 168
diff changeset
125 $sql .= "', wa_base_name='" . $_POST['wa_base_name'];
359
98354ef399cd Lot's of improvements for recipes and products database load and save. Insert missing yeast tolerance field for old products and recipes. Recipe locked and calc_acid fields coverted to integer. In recipe edit screen removed the Print button. It is now included in the export screen. Added recipe export to forum screen.
Michiel Broek <mbroek@mbse.eu>
parents: 352
diff changeset
126 //syslog(LOG_NOTICE, $sql);
60
dbbe408108ea Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents: 57
diff changeset
127
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: 168
diff changeset
128 $fermentables = '[';
14e349ff2a10 Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents: 168
diff changeset
129 $comma = FALSE;
60
dbbe408108ea Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents: 57
diff changeset
130 if (isset($_POST['fermentables'])) {
dbbe408108ea Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents: 57
diff changeset
131 $array = $_POST['fermentables'];
394
ccd85f0ed96c Added ingredient sorting to the database write functions.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
132 // Sort the array
ccd85f0ed96c Added ingredient sorting to the database write functions.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
133 $added = array();
ccd85f0ed96c Added ingredient sorting to the database write functions.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
134 $amount = array();
ccd85f0ed96c Added ingredient sorting to the database write functions.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
135 for ($i = 0; $i < count($array); $i++) {
ccd85f0ed96c Added ingredient sorting to the database write functions.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
136 $added[] = $array[$i]['f_added'];
ccd85f0ed96c Added ingredient sorting to the database write functions.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
137 $amount[] = $array[$i]['f_amount'];
ccd85f0ed96c Added ingredient sorting to the database write functions.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
138 }
ccd85f0ed96c Added ingredient sorting to the database write functions.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
139 array_multisort($added, SORT_ASC, SORT_NUMERIC,
ccd85f0ed96c Added ingredient sorting to the database write functions.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
140 $amount, SORT_DESC, SORT_NUMERIC,
ccd85f0ed96c Added ingredient sorting to the database write functions.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
141 $array);
ccd85f0ed96c Added ingredient sorting to the database write functions.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
142 // Write the sorted array.
60
dbbe408108ea Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents: 57
diff changeset
143 foreach($array as $key => $item){
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: 168
diff changeset
144 /*
14e349ff2a10 Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents: 168
diff changeset
145 * Manual encode to json.
14e349ff2a10 Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents: 168
diff changeset
146 */
14e349ff2a10 Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents: 168
diff changeset
147 if ($comma)
14e349ff2a10 Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents: 168
diff changeset
148 $fermentables .= ',';
14e349ff2a10 Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents: 168
diff changeset
149 $comma = TRUE;
14e349ff2a10 Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents: 168
diff changeset
150 $fermentable = '{"f_name":"' . str_replace($rescapers,$rreplacements,$item['f_name']);
14e349ff2a10 Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents: 168
diff changeset
151 $fermentable .= '","f_origin":"' . str_replace($rescapers,$rreplacements,$item['f_origin']);
14e349ff2a10 Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents: 168
diff changeset
152 $fermentable .= '","f_supplier":"' . str_replace($rescapers,$rreplacements,$item['f_supplier']);
14e349ff2a10 Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents: 168
diff changeset
153 $fermentable .= '","f_amount":' . $item['f_amount'];
14e349ff2a10 Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents: 168
diff changeset
154 $fermentable .= ',"f_cost":' . $item['f_cost'];
14e349ff2a10 Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents: 168
diff changeset
155 $fermentable .= ',"f_type":' . $item['f_type'];
14e349ff2a10 Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents: 168
diff changeset
156 $fermentable .= ',"f_yield":' . $item['f_yield'];
14e349ff2a10 Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents: 168
diff changeset
157 $fermentable .= ',"f_color":' . $item['f_color'];
14e349ff2a10 Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents: 168
diff changeset
158 $fermentable .= ',"f_coarse_fine_diff":' . $item['f_coarse_fine_diff'];
14e349ff2a10 Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents: 168
diff changeset
159 $fermentable .= ',"f_moisture":' . $item['f_moisture'];
14e349ff2a10 Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents: 168
diff changeset
160 $fermentable .= ',"f_diastatic_power":' . $item['f_diastatic_power'];
14e349ff2a10 Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents: 168
diff changeset
161 $fermentable .= ',"f_protein":' . $item['f_protein'];
14e349ff2a10 Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents: 168
diff changeset
162 $fermentable .= ',"f_dissolved_protein":' . $item['f_dissolved_protein'];
14e349ff2a10 Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents: 168
diff changeset
163 $fermentable .= ',"f_max_in_batch":' . $item['f_max_in_batch'];
14e349ff2a10 Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents: 168
diff changeset
164 $fermentable .= ',"f_graintype":' . $item['f_graintype'];
14e349ff2a10 Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents: 168
diff changeset
165 $fermentable .= ',"f_added":' . $item['f_added'];
14e349ff2a10 Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents: 168
diff changeset
166 $fermentable .= ',"f_recommend_mash":' . $item['f_recommend_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: 168
diff changeset
167 $fermentable .= ',"f_add_after_boil":' . $item['f_add_after_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: 168
diff changeset
168 $fermentable .= ',"f_adjust_to_total_100":' . $item['f_adjust_to_total_100'];
14e349ff2a10 Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents: 168
diff changeset
169 $fermentable .= ',"f_percentage":' . $item['f_percentage'];
14e349ff2a10 Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents: 168
diff changeset
170 $fermentable .= ',"f_di_ph":' . $item['f_di_ph'];
14e349ff2a10 Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents: 168
diff changeset
171 $fermentable .= ',"f_acid_to_ph_57":' . $item['f_acid_to_ph_57'] . '}';
225
ad2e1e3ccaca The miscs grid rebuild to use a popup editor for the rows.
Michiel Broek <mbroek@mbse.eu>
parents: 223
diff changeset
172 //syslog(LOG_NOTICE, $fermentable);
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: 168
diff changeset
173 $fermentables .= $fermentable;
60
dbbe408108ea Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents: 57
diff changeset
174 }
52
b1f2a893572f More progress on the recipes design
Michiel Broek <mbroek@mbse.eu>
parents: 51
diff changeset
175 }
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: 168
diff changeset
176 $fermentables .= ']';
14e349ff2a10 Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents: 168
diff changeset
177 $sql .= "', json_fermentables='" . $fermentables;
60
dbbe408108ea Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents: 57
diff changeset
178
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: 168
diff changeset
179 $hops = '[';
14e349ff2a10 Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents: 168
diff changeset
180 $comma = FALSE;
60
dbbe408108ea Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents: 57
diff changeset
181 if (isset($_POST['hops'])) {
dbbe408108ea Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents: 57
diff changeset
182 $array = $_POST['hops'];
394
ccd85f0ed96c Added ingredient sorting to the database write functions.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
183 // Sort the array
ccd85f0ed96c Added ingredient sorting to the database write functions.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
184 $useat = array();
ccd85f0ed96c Added ingredient sorting to the database write functions.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
185 $time = array();
ccd85f0ed96c Added ingredient sorting to the database write functions.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
186 $amount = array();
ccd85f0ed96c Added ingredient sorting to the database write functions.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
187 for ($i = 0; $i < count($array); $i++) {
ccd85f0ed96c Added ingredient sorting to the database write functions.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
188 $useat[] = $array[$i]['h_useat'];
ccd85f0ed96c Added ingredient sorting to the database write functions.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
189 $time[] = $array[$i]['h_time'];
ccd85f0ed96c Added ingredient sorting to the database write functions.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
190 $amount[] = $array[$i]['h_amount'];
ccd85f0ed96c Added ingredient sorting to the database write functions.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
191 }
ccd85f0ed96c Added ingredient sorting to the database write functions.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
192 array_multisort($useat, SORT_ASC, SORT_NUMERIC,
ccd85f0ed96c Added ingredient sorting to the database write functions.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
193 $time, SORT_DESC, SORT_NUMERIC,
ccd85f0ed96c Added ingredient sorting to the database write functions.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
194 $amount, SORT_DESC, SORT_NUMERIC,
ccd85f0ed96c Added ingredient sorting to the database write functions.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
195 $array);
ccd85f0ed96c Added ingredient sorting to the database write functions.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
196 // Write the sorted array.
60
dbbe408108ea Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents: 57
diff changeset
197 foreach($array as $key => $item){
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: 168
diff changeset
198 if ($comma)
14e349ff2a10 Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents: 168
diff changeset
199 $hops .= ',';
14e349ff2a10 Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents: 168
diff changeset
200 $comma = TRUE;
14e349ff2a10 Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents: 168
diff changeset
201 $hop = '{"h_name":"' . str_replace($rescapers,$rreplacements,$item['h_name']);
14e349ff2a10 Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents: 168
diff changeset
202 $hop .= '","h_origin":"' . str_replace($rescapers,$rreplacements,$item['h_origin']);
14e349ff2a10 Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents: 168
diff changeset
203 $hop .= '","h_amount":' . $item['h_amount'];
14e349ff2a10 Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents: 168
diff changeset
204 $hop .= ',"h_cost":' . $item['h_cost'];
14e349ff2a10 Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents: 168
diff changeset
205 $hop .= ',"h_type":' . $item['h_type'];
14e349ff2a10 Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents: 168
diff changeset
206 $hop .= ',"h_form":' . $item['h_form'];
14e349ff2a10 Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents: 168
diff changeset
207 $hop .= ',"h_useat":' . $item['h_useat'];
14e349ff2a10 Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents: 168
diff changeset
208 $hop .= ',"h_time":' . $item['h_time'];
14e349ff2a10 Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents: 168
diff changeset
209 $hop .= ',"h_alpha":' . $item['h_alpha'];
14e349ff2a10 Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents: 168
diff changeset
210 $hop .= ',"h_beta":' . $item['h_beta'];
14e349ff2a10 Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents: 168
diff changeset
211 $hop .= ',"h_hsi":' . $item['h_hsi'];
14e349ff2a10 Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents: 168
diff changeset
212 $hop .= ',"h_humulene":' . $item['h_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: 222
diff changeset
213 $hop .= ',"h_caryophyllene":' . $item['h_caryophyllene'];
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: 168
diff changeset
214 $hop .= ',"h_cohumulone":' . $item['h_cohumulone'];
14e349ff2a10 Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents: 168
diff changeset
215 $hop .= ',"h_myrcene":' . $item['h_myrcene'];
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: 222
diff changeset
216 $hop .= ',"h_total_oil":' . $item['h_total_oil'] . '}';
225
ad2e1e3ccaca The miscs grid rebuild to use a popup editor for the rows.
Michiel Broek <mbroek@mbse.eu>
parents: 223
diff changeset
217 //syslog(LOG_NOTICE, $hop);
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: 168
diff changeset
218 $hops .= $hop;
60
dbbe408108ea Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents: 57
diff changeset
219 }
dbbe408108ea Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents: 57
diff changeset
220 }
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: 168
diff changeset
221 $hops .= ']';
14e349ff2a10 Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents: 168
diff changeset
222 $sql .= "', json_hops='" . $hops;
60
dbbe408108ea Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents: 57
diff changeset
223
225
ad2e1e3ccaca The miscs grid rebuild to use a popup editor for the rows.
Michiel Broek <mbroek@mbse.eu>
parents: 223
diff changeset
224 $miscs = '[';
ad2e1e3ccaca The miscs grid rebuild to use a popup editor for the rows.
Michiel Broek <mbroek@mbse.eu>
parents: 223
diff changeset
225 $comma = FALSE;
60
dbbe408108ea Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents: 57
diff changeset
226 if (isset($_POST['miscs'])) {
dbbe408108ea Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents: 57
diff changeset
227 $array = $_POST['miscs'];
394
ccd85f0ed96c Added ingredient sorting to the database write functions.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
228 // Sort the array
ccd85f0ed96c Added ingredient sorting to the database write functions.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
229 $use = array();
ccd85f0ed96c Added ingredient sorting to the database write functions.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
230 $type = array();
ccd85f0ed96c Added ingredient sorting to the database write functions.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
231 $amount = array();
ccd85f0ed96c Added ingredient sorting to the database write functions.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
232 for ($i = 0; $i < count($array); $i++) {
ccd85f0ed96c Added ingredient sorting to the database write functions.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
233 $use[] = $array[$i]['m_use_use'];
ccd85f0ed96c Added ingredient sorting to the database write functions.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
234 $type[] = $array[$i]['m_type'];
ccd85f0ed96c Added ingredient sorting to the database write functions.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
235 $amount[] = $array[$i]['m_amount'];
ccd85f0ed96c Added ingredient sorting to the database write functions.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
236 }
ccd85f0ed96c Added ingredient sorting to the database write functions.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
237 array_multisort($use, SORT_ASC, SORT_NUMERIC,
ccd85f0ed96c Added ingredient sorting to the database write functions.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
238 $type, SORT_ASC, SORT_NUMERIC,
ccd85f0ed96c Added ingredient sorting to the database write functions.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
239 $amount, SORT_DESC, SORT_NUMERIC,
ccd85f0ed96c Added ingredient sorting to the database write functions.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
240 $array);
ccd85f0ed96c Added ingredient sorting to the database write functions.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
241 // Write the sorted array.
225
ad2e1e3ccaca The miscs grid rebuild to use a popup editor for the rows.
Michiel Broek <mbroek@mbse.eu>
parents: 223
diff changeset
242 foreach($array as $key => $item) {
ad2e1e3ccaca The miscs grid rebuild to use a popup editor for the rows.
Michiel Broek <mbroek@mbse.eu>
parents: 223
diff changeset
243 if ($comma)
ad2e1e3ccaca The miscs grid rebuild to use a popup editor for the rows.
Michiel Broek <mbroek@mbse.eu>
parents: 223
diff changeset
244 $miscs .= ',';
ad2e1e3ccaca The miscs grid rebuild to use a popup editor for the rows.
Michiel Broek <mbroek@mbse.eu>
parents: 223
diff changeset
245 $comma = TRUE;
ad2e1e3ccaca The miscs grid rebuild to use a popup editor for the rows.
Michiel Broek <mbroek@mbse.eu>
parents: 223
diff changeset
246 $misc = '{"m_name":"' . str_replace($rescapers,$rreplacements,$item['m_name']);
ad2e1e3ccaca The miscs grid rebuild to use a popup editor for the rows.
Michiel Broek <mbroek@mbse.eu>
parents: 223
diff changeset
247 $misc .= '","m_amount":' . $item['m_amount'];
ad2e1e3ccaca The miscs grid rebuild to use a popup editor for the rows.
Michiel Broek <mbroek@mbse.eu>
parents: 223
diff changeset
248 $misc .= ',"m_type":' . $item['m_type'];
ad2e1e3ccaca The miscs grid rebuild to use a popup editor for the rows.
Michiel Broek <mbroek@mbse.eu>
parents: 223
diff changeset
249 $misc .= ',"m_use_use":' . $item['m_use_use'];
ad2e1e3ccaca The miscs grid rebuild to use a popup editor for the rows.
Michiel Broek <mbroek@mbse.eu>
parents: 223
diff changeset
250 $misc .= ',"m_time":' . $item['m_time'];
ad2e1e3ccaca The miscs grid rebuild to use a popup editor for the rows.
Michiel Broek <mbroek@mbse.eu>
parents: 223
diff changeset
251 $misc .= ',"m_amount_is_weight":' . $item['m_amount_is_weight'];
ad2e1e3ccaca The miscs grid rebuild to use a popup editor for the rows.
Michiel Broek <mbroek@mbse.eu>
parents: 223
diff changeset
252 $misc .= ',"m_cost":' . $item['m_cost'] . '}';
226
40e68b18b50d The recipes yeast grid now uses a popup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
253 //syslog(LOG_NOTICE, $misc);
225
ad2e1e3ccaca The miscs grid rebuild to use a popup editor for the rows.
Michiel Broek <mbroek@mbse.eu>
parents: 223
diff changeset
254 $miscs .= $misc;
60
dbbe408108ea Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents: 57
diff changeset
255 }
dbbe408108ea Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents: 57
diff changeset
256 }
225
ad2e1e3ccaca The miscs grid rebuild to use a popup editor for the rows.
Michiel Broek <mbroek@mbse.eu>
parents: 223
diff changeset
257 $miscs .= ']';
ad2e1e3ccaca The miscs grid rebuild to use a popup editor for the rows.
Michiel Broek <mbroek@mbse.eu>
parents: 223
diff changeset
258 $sql .= "', json_miscs='" . $miscs;
52
b1f2a893572f More progress on the recipes design
Michiel Broek <mbroek@mbse.eu>
parents: 51
diff changeset
259
226
40e68b18b50d The recipes yeast grid now uses a popup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
260 $yeasts = '[';
40e68b18b50d The recipes yeast grid now uses a popup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
261 $comma = FALSE;
60
dbbe408108ea Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents: 57
diff changeset
262 if (isset($_POST['yeasts'])) {
dbbe408108ea Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents: 57
diff changeset
263 $array = $_POST['yeasts'];
394
ccd85f0ed96c Added ingredient sorting to the database write functions.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
264 // Sort the array
ccd85f0ed96c Added ingredient sorting to the database write functions.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
265 $use = array();
ccd85f0ed96c Added ingredient sorting to the database write functions.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
266 $amount = array();
ccd85f0ed96c Added ingredient sorting to the database write functions.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
267 for ($i = 0; $i < count($array); $i++) {
ccd85f0ed96c Added ingredient sorting to the database write functions.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
268 $use[] = $array[$i]['y_use'];
ccd85f0ed96c Added ingredient sorting to the database write functions.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
269 $amount[] = $array[$i]['y_amount'];
ccd85f0ed96c Added ingredient sorting to the database write functions.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
270 }
ccd85f0ed96c Added ingredient sorting to the database write functions.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
271 array_multisort($use, SORT_ASC, SORT_NUMERIC,
ccd85f0ed96c Added ingredient sorting to the database write functions.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
272 $amount, SORT_DESC, SORT_NUMERIC,
ccd85f0ed96c Added ingredient sorting to the database write functions.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
273 $array);
ccd85f0ed96c Added ingredient sorting to the database write functions.
Michiel Broek <mbroek@mbse.eu>
parents: 392
diff changeset
274 // Write the sorted array.
226
40e68b18b50d The recipes yeast grid now uses a popup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
275 foreach($array as $key => $item) {
40e68b18b50d The recipes yeast grid now uses a popup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
276 if ($comma)
40e68b18b50d The recipes yeast grid now uses a popup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
277 $yeasts .= ',';
40e68b18b50d The recipes yeast grid now uses a popup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
278 $comma = TRUE;
40e68b18b50d The recipes yeast grid now uses a popup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
279 $yeast = '{"y_name":"' . str_replace($rescapers,$rreplacements,$item['y_name']);
40e68b18b50d The recipes yeast grid now uses a popup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
280 $yeast .= '","y_laboratory":"' . str_replace($rescapers,$rreplacements,$item['y_laboratory']);
40e68b18b50d The recipes yeast grid now uses a popup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
281 $yeast .= '","y_product_id":"' . str_replace($rescapers,$rreplacements,$item['y_product_id']);
40e68b18b50d The recipes yeast grid now uses a popup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
282 $yeast .= '","y_amount":' . $item['y_amount'];
40e68b18b50d The recipes yeast grid now uses a popup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
283 $yeast .= ',"y_type":' . $item['y_type'];
40e68b18b50d The recipes yeast grid now uses a popup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
284 $yeast .= ',"y_form":' . $item['y_form'];
40e68b18b50d The recipes yeast grid now uses a popup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
285 $yeast .= ',"y_min_temperature":' . $item['y_min_temperature'];
40e68b18b50d The recipes yeast grid now uses a popup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
286 $yeast .= ',"y_max_temperature":' . $item['y_max_temperature'];
40e68b18b50d The recipes yeast grid now uses a popup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
287 $yeast .= ',"y_flocculation":' . $item['y_flocculation'];
40e68b18b50d The recipes yeast grid now uses a popup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
288 $yeast .= ',"y_attenuation":' . $item['y_attenuation'];
40e68b18b50d The recipes yeast grid now uses a popup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
289 $yeast .= ',"y_cells":' . $item['y_cells'];
332
f0ca77097236 Display alcohol tolerance in the yeast editor. Display in red when the recipe estimate is higher then the yeast tolerance.
Michiel Broek <mbroek@mbse.eu>
parents: 233
diff changeset
290 $yeast .= ',"y_tolerance":' . $item['y_tolerance'];
226
40e68b18b50d The recipes yeast grid now uses a popup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
291 $yeast .= ',"y_inventory":' . $item['y_inventory'];
40e68b18b50d The recipes yeast grid now uses a popup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
292 $yeast .= ',"y_use":' . $item['y_use'];
559
10cc2400b5d5 Backported extra yeast fields and the SO4:Cl ratio changes into the recipes editor.
Michiel Broek <mbroek@mbse.eu>
parents: 394
diff changeset
293 $yeast .= ',"y_sta1":' . $item['y_sta1'];
10cc2400b5d5 Backported extra yeast fields and the SO4:Cl ratio changes into the recipes editor.
Michiel Broek <mbroek@mbse.eu>
parents: 394
diff changeset
294 $yeast .= ',"y_bacteria":' . $item['y_bacteria'];
10cc2400b5d5 Backported extra yeast fields and the SO4:Cl ratio changes into the recipes editor.
Michiel Broek <mbroek@mbse.eu>
parents: 394
diff changeset
295 $yeast .= ',"y_harvest_top":' . $item['y_harvest_top'];
10cc2400b5d5 Backported extra yeast fields and the SO4:Cl ratio changes into the recipes editor.
Michiel Broek <mbroek@mbse.eu>
parents: 394
diff changeset
296 $yeast .= ',"y_harvest_time":' . $item['y_harvest_time'];
10cc2400b5d5 Backported extra yeast fields and the SO4:Cl ratio changes into the recipes editor.
Michiel Broek <mbroek@mbse.eu>
parents: 394
diff changeset
297 $yeast .= ',"y_pitch_temperature":' . $item['y_pitch_temperature'];
10cc2400b5d5 Backported extra yeast fields and the SO4:Cl ratio changes into the recipes editor.
Michiel Broek <mbroek@mbse.eu>
parents: 394
diff changeset
298 $yeast .= ',"y_pofpos":' . $item['y_pofpos'];
10cc2400b5d5 Backported extra yeast fields and the SO4:Cl ratio changes into the recipes editor.
Michiel Broek <mbroek@mbse.eu>
parents: 394
diff changeset
299 $yeast .= ',"y_zymocide":' . $item['y_zymocide'];
726
872a3635e4ef Changed dry-yeast calculation.
Michiel Broek <mbroek@mbse.eu>
parents: 711
diff changeset
300 $yeast .= ',"y_gr_hl_lo":' . $item['y_gr_hl_lo'];
872a3635e4ef Changed dry-yeast calculation.
Michiel Broek <mbroek@mbse.eu>
parents: 711
diff changeset
301 $yeast .= ',"y_sg_lo":' . $item['y_sg_lo'];
872a3635e4ef Changed dry-yeast calculation.
Michiel Broek <mbroek@mbse.eu>
parents: 711
diff changeset
302 $yeast .= ',"y_gr_hl_hi":' . $item['y_gr_hl_hi'];
872a3635e4ef Changed dry-yeast calculation.
Michiel Broek <mbroek@mbse.eu>
parents: 711
diff changeset
303 $yeast .= ',"y_sg_hi":' . $item['y_sg_hi'];
226
40e68b18b50d The recipes yeast grid now uses a popup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
304 $yeast .= ',"y_cost":' . $item['y_cost'] . '}';
711
0a1be3bfcc60 Removed some debug messages in products and recipes
Michiel Broek <mbroek@mbse.eu>
parents: 710
diff changeset
305 //syslog(LOG_NOTICE, $yeast);
226
40e68b18b50d The recipes yeast grid now uses a popup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
306 $yeasts .= $yeast;
57
bb9a06aa9acd Completed framework inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents: 52
diff changeset
307 }
bb9a06aa9acd Completed framework inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents: 52
diff changeset
308 }
226
40e68b18b50d The recipes yeast grid now uses a popup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
309 $yeasts .= ']';
40e68b18b50d The recipes yeast grid now uses a popup editor.
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
310 $sql .= "', json_yeasts='" . $yeasts;
57
bb9a06aa9acd Completed framework inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents: 52
diff changeset
311
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
312 $mashs = '[';
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
313 $comma = FALSE;
60
dbbe408108ea Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents: 57
diff changeset
314 if (isset($_POST['mashs'])) {
dbbe408108ea Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents: 57
diff changeset
315 $array = $_POST['mashs'];
667
1246550451ca Removed the last compressed css file. Reworked all mash steps, implemented deconction steps. Added calculations for infuse amounts and decoctions amounts. The mash steps are now manually sorted in the editor grids to have full control over the steps order. Display errors in red in the grid. Updated beerxml export, the product checklist and print output of the products and recipes for all these mash steps changes.
Michiel Broek <mbroek@mbse.eu>
parents: 565
diff changeset
316 // Write the array and fix missing data.
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
317 foreach($array as $key => $item) {
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
318 if ($comma)
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
319 $mashs .= ',';
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
320 $comma = TRUE;
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
321 $mash = '{"step_name":"' . str_replace($rescapers,$rreplacements,$item['step_name']);
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
322 $mash .= '","step_type":' . $item['step_type'];
667
1246550451ca Removed the last compressed css file. Reworked all mash steps, implemented deconction steps. Added calculations for infuse amounts and decoctions amounts. The mash steps are now manually sorted in the editor grids to have full control over the steps order. Display errors in red in the grid. Updated beerxml export, the product checklist and print output of the products and recipes for all these mash steps changes.
Michiel Broek <mbroek@mbse.eu>
parents: 565
diff changeset
323 if (isset($item['step_volume']) && $item['step_volume'] != "")
1246550451ca Removed the last compressed css file. Reworked all mash steps, implemented deconction steps. Added calculations for infuse amounts and decoctions amounts. The mash steps are now manually sorted in the editor grids to have full control over the steps order. Display errors in red in the grid. Updated beerxml export, the product checklist and print output of the products and recipes for all these mash steps changes.
Michiel Broek <mbroek@mbse.eu>
parents: 565
diff changeset
324 $mash .= ',"step_volume":' . $item['step_volume'];
1246550451ca Removed the last compressed css file. Reworked all mash steps, implemented deconction steps. Added calculations for infuse amounts and decoctions amounts. The mash steps are now manually sorted in the editor grids to have full control over the steps order. Display errors in red in the grid. Updated beerxml export, the product checklist and print output of the products and recipes for all these mash steps changes.
Michiel Broek <mbroek@mbse.eu>
parents: 565
diff changeset
325 else
1246550451ca Removed the last compressed css file. Reworked all mash steps, implemented deconction steps. Added calculations for infuse amounts and decoctions amounts. The mash steps are now manually sorted in the editor grids to have full control over the steps order. Display errors in red in the grid. Updated beerxml export, the product checklist and print output of the products and recipes for all these mash steps changes.
Michiel Broek <mbroek@mbse.eu>
parents: 565
diff changeset
326 $mash .= ',"step_volume":0';
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
327 if (isset($item['step_infuse_amount']) && $item['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
328 $mash .= ',"step_infuse_amount":' . $item['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
329 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
330 $mash .= ',"step_infuse_amount":0';
667
1246550451ca Removed the last compressed css file. Reworked all mash steps, implemented deconction steps. Added calculations for infuse amounts and decoctions amounts. The mash steps are now manually sorted in the editor grids to have full control over the steps order. Display errors in red in the grid. Updated beerxml export, the product checklist and print output of the products and recipes for all these mash steps changes.
Michiel Broek <mbroek@mbse.eu>
parents: 565
diff changeset
331 if (isset($item['step_infuse_temp']) && $item['step_infuse_temp'] != "")
1246550451ca Removed the last compressed css file. Reworked all mash steps, implemented deconction steps. Added calculations for infuse amounts and decoctions amounts. The mash steps are now manually sorted in the editor grids to have full control over the steps order. Display errors in red in the grid. Updated beerxml export, the product checklist and print output of the products and recipes for all these mash steps changes.
Michiel Broek <mbroek@mbse.eu>
parents: 565
diff changeset
332 $mash .= ',"step_infuse_temp":' . $item['step_infuse_temp'];
1246550451ca Removed the last compressed css file. Reworked all mash steps, implemented deconction steps. Added calculations for infuse amounts and decoctions amounts. The mash steps are now manually sorted in the editor grids to have full control over the steps order. Display errors in red in the grid. Updated beerxml export, the product checklist and print output of the products and recipes for all these mash steps changes.
Michiel Broek <mbroek@mbse.eu>
parents: 565
diff changeset
333 else
1246550451ca Removed the last compressed css file. Reworked all mash steps, implemented deconction steps. Added calculations for infuse amounts and decoctions amounts. The mash steps are now manually sorted in the editor grids to have full control over the steps order. Display errors in red in the grid. Updated beerxml export, the product checklist and print output of the products and recipes for all these mash steps changes.
Michiel Broek <mbroek@mbse.eu>
parents: 565
diff changeset
334 $mash .= ',"step_infuse_temp":0';
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
335 $mash .= ',"step_temp":' . $item['step_temp'];
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
336 $mash .= ',"step_time":' . $item['step_time'];
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
337 $mash .= ',"ramp_time":' . $item['ramp_time'];
667
1246550451ca Removed the last compressed css file. Reworked all mash steps, implemented deconction steps. Added calculations for infuse amounts and decoctions amounts. The mash steps are now manually sorted in the editor grids to have full control over the steps order. Display errors in red in the grid. Updated beerxml export, the product checklist and print output of the products and recipes for all these mash steps changes.
Michiel Broek <mbroek@mbse.eu>
parents: 565
diff changeset
338 $mash .= ',"end_temp":' . $item['end_temp'];
1246550451ca Removed the last compressed css file. Reworked all mash steps, implemented deconction steps. Added calculations for infuse amounts and decoctions amounts. The mash steps are now manually sorted in the editor grids to have full control over the steps order. Display errors in red in the grid. Updated beerxml export, the product checklist and print output of the products and recipes for all these mash steps changes.
Michiel Broek <mbroek@mbse.eu>
parents: 565
diff changeset
339 if (isset($item['step_wg_ratio']) && $item['step_wg_ratio'] != "")
1246550451ca Removed the last compressed css file. Reworked all mash steps, implemented deconction steps. Added calculations for infuse amounts and decoctions amounts. The mash steps are now manually sorted in the editor grids to have full control over the steps order. Display errors in red in the grid. Updated beerxml export, the product checklist and print output of the products and recipes for all these mash steps changes.
Michiel Broek <mbroek@mbse.eu>
parents: 565
diff changeset
340 $mash .= ',"step_wg_ratio":' . $item['step_wg_ratio'];
1246550451ca Removed the last compressed css file. Reworked all mash steps, implemented deconction steps. Added calculations for infuse amounts and decoctions amounts. The mash steps are now manually sorted in the editor grids to have full control over the steps order. Display errors in red in the grid. Updated beerxml export, the product checklist and print output of the products and recipes for all these mash steps changes.
Michiel Broek <mbroek@mbse.eu>
parents: 565
diff changeset
341 else
1246550451ca Removed the last compressed css file. Reworked all mash steps, implemented deconction steps. Added calculations for infuse amounts and decoctions amounts. The mash steps are now manually sorted in the editor grids to have full control over the steps order. Display errors in red in the grid. Updated beerxml export, the product checklist and print output of the products and recipes for all these mash steps changes.
Michiel Broek <mbroek@mbse.eu>
parents: 565
diff changeset
342 $mash .= ',"step_wg_ratio":0';
1246550451ca Removed the last compressed css file. Reworked all mash steps, implemented deconction steps. Added calculations for infuse amounts and decoctions amounts. The mash steps are now manually sorted in the editor grids to have full control over the steps order. Display errors in red in the grid. Updated beerxml export, the product checklist and print output of the products and recipes for all these mash steps changes.
Michiel Broek <mbroek@mbse.eu>
parents: 565
diff changeset
343 $mash .= '}';
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
344 $mashs .= $mash;
359
98354ef399cd Lot's of improvements for recipes and products database load and save. Insert missing yeast tolerance field for old products and recipes. Recipe locked and calc_acid fields coverted to integer. In recipe edit screen removed the Print button. It is now included in the export screen. Added recipe export to forum screen.
Michiel Broek <mbroek@mbse.eu>
parents: 352
diff changeset
345 //syslog(LOG_NOTICE, $mash);
60
dbbe408108ea Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents: 57
diff changeset
346 }
dbbe408108ea Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents: 57
diff changeset
347 }
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
348 $mashs .= ']';
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
349 $sql .= "', json_mashs='" . $mashs;
60
dbbe408108ea Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents: 57
diff changeset
350
dbbe408108ea Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents: 57
diff changeset
351 if (isset($_POST['insert'])) {
52
b1f2a893572f More progress on the recipes design
Michiel Broek <mbroek@mbse.eu>
parents: 51
diff changeset
352 $sql .= "';";
b1f2a893572f More progress on the recipes design
Michiel Broek <mbroek@mbse.eu>
parents: 51
diff changeset
353 }
60
dbbe408108ea Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents: 57
diff changeset
354 if (isset($_POST['update'])) {
dbbe408108ea Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents: 57
diff changeset
355 $sql .= "' WHERE record='" . $_POST['record'] . "';";
52
b1f2a893572f More progress on the recipes design
Michiel Broek <mbroek@mbse.eu>
parents: 51
diff changeset
356 }
49
4d27a7fb1265 Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
357
52
b1f2a893572f More progress on the recipes design
Michiel Broek <mbroek@mbse.eu>
parents: 51
diff changeset
358 $result = mysqli_query($connect, $sql);
b1f2a893572f More progress on the recipes design
Michiel Broek <mbroek@mbse.eu>
parents: 51
diff changeset
359 if (! $result) {
61
3469979f83be Added inline yeast editor
Michiel Broek <mbroek@mbse.eu>
parents: 60
diff changeset
360 syslog(LOG_NOTICE, "db_recipes: result: ".mysqli_error($connect));
777
daf55c944fb0 Recipes backport for new dry-yeast fields and SQL error handlers.
Michiel Broek <mbroek@mbse.eu>
parents: 726
diff changeset
361 $response['error'] = true;
daf55c944fb0 Recipes backport for new dry-yeast fields and SQL error handlers.
Michiel Broek <mbroek@mbse.eu>
parents: 726
diff changeset
362 $response['msg'] = "SQL fout: ".mysqli_error($connect);
52
b1f2a893572f More progress on the recipes design
Michiel Broek <mbroek@mbse.eu>
parents: 51
diff changeset
363 } else {
60
dbbe408108ea Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents: 57
diff changeset
364 if (isset($_POST['update'])) {
777
daf55c944fb0 Recipes backport for new dry-yeast fields and SQL error handlers.
Michiel Broek <mbroek@mbse.eu>
parents: 726
diff changeset
365 //syslog(LOG_NOTICE, "db_recipes: updated record ".$_POST['record']);
60
dbbe408108ea Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents: 57
diff changeset
366 } else {
72
93a0be4f5be3 Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents: 71
diff changeset
367 $lastid = mysqli_insert_id($connect);
777
daf55c944fb0 Recipes backport for new dry-yeast fields and SQL error handlers.
Michiel Broek <mbroek@mbse.eu>
parents: 726
diff changeset
368 //syslog(LOG_NOTICE, "db_recipes: inserted record ".$lastid);
60
dbbe408108ea Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents: 57
diff changeset
369 }
dbbe408108ea Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents: 57
diff changeset
370 }
777
daf55c944fb0 Recipes backport for new dry-yeast fields and SQL error handlers.
Michiel Broek <mbroek@mbse.eu>
parents: 726
diff changeset
371 echo json_encode($response);
60
dbbe408108ea Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents: 57
diff changeset
372
dbbe408108ea Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents: 57
diff changeset
373 } else if (isset($_POST['delete'])) {
dbbe408108ea Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents: 57
diff changeset
374 // DELETE COMMAND
dbbe408108ea Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents: 57
diff changeset
375 $sql = "DELETE FROM `recipes` WHERE record='".$_POST['record']."';";
dbbe408108ea Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents: 57
diff changeset
376 $result = mysqli_query($connect, $sql);
dbbe408108ea Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents: 57
diff changeset
377 if (! $result) {
61
3469979f83be Added inline yeast editor
Michiel Broek <mbroek@mbse.eu>
parents: 60
diff changeset
378 syslog(LOG_NOTICE, "db_recipes: result: ".mysqli_error($connect));
777
daf55c944fb0 Recipes backport for new dry-yeast fields and SQL error handlers.
Michiel Broek <mbroek@mbse.eu>
parents: 726
diff changeset
379 $response['error'] = true;
daf55c944fb0 Recipes backport for new dry-yeast fields and SQL error handlers.
Michiel Broek <mbroek@mbse.eu>
parents: 726
diff changeset
380 $response['msg'] = "SQL delete fout: ".mysqli_error($connect);
60
dbbe408108ea Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents: 57
diff changeset
381 } else {
dbbe408108ea Added miscs inline editor. Switched to http POST because of GET limitations.
Michiel Broek <mbroek@mbse.eu>
parents: 57
diff changeset
382 syslog(LOG_NOTICE, "db_recipes: deleted record ".$_POST['record']);
52
b1f2a893572f More progress on the recipes design
Michiel Broek <mbroek@mbse.eu>
parents: 51
diff changeset
383 }
777
daf55c944fb0 Recipes backport for new dry-yeast fields and SQL error handlers.
Michiel Broek <mbroek@mbse.eu>
parents: 726
diff changeset
384 echo json_encode($response);
49
4d27a7fb1265 Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
385
4d27a7fb1265 Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
386 } else {
130
601920b902e5 Load a single recipe from the database instead of client side select.
Michiel Broek <mbroek@mbse.eu>
parents: 94
diff changeset
387 /*
601920b902e5 Load a single recipe from the database instead of client side select.
Michiel Broek <mbroek@mbse.eu>
parents: 94
diff changeset
388 * Select all or a given record.
601920b902e5 Load a single recipe from the database instead of client side select.
Michiel Broek <mbroek@mbse.eu>
parents: 94
diff changeset
389 */
601920b902e5 Load a single recipe from the database instead of client side select.
Michiel Broek <mbroek@mbse.eu>
parents: 94
diff changeset
390 if (isset($_GET['record'])) {
601920b902e5 Load a single recipe from the database instead of client side select.
Michiel Broek <mbroek@mbse.eu>
parents: 94
diff changeset
391 $query = "SELECT * FROM recipes WHERE record='" . $_GET['record'] . "';";
601920b902e5 Load a single recipe from the database instead of client side select.
Michiel Broek <mbroek@mbse.eu>
parents: 94
diff changeset
392 } else {
601920b902e5 Load a single recipe from the database instead of client side select.
Michiel Broek <mbroek@mbse.eu>
parents: 94
diff changeset
393 $query = "SELECT * FROM recipes ORDER BY st_guide,st_letter,st_name,name";
601920b902e5 Load a single recipe from the database instead of client side select.
Michiel Broek <mbroek@mbse.eu>
parents: 94
diff changeset
394 }
49
4d27a7fb1265 Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
395 $result = mysqli_query($connect, $query) or die("SQL Error 1: " . mysqli_error($connect));
4d27a7fb1265 Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
396 $recipes = '[';
4d27a7fb1265 Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
397 $comma = FALSE;
4d27a7fb1265 Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
398 while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) {
4d27a7fb1265 Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
399 // Manual encode to JSON.
4d27a7fb1265 Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
400 if ($comma) {
4d27a7fb1265 Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
401 $recipes .= ',';
4d27a7fb1265 Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
402 }
4d27a7fb1265 Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
403 $comma = TRUE;
4d27a7fb1265 Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
404 $recipes .= '{"record":' . $row['record'];
359
98354ef399cd Lot's of improvements for recipes and products database load and save. Insert missing yeast tolerance field for old products and recipes. Recipe locked and calc_acid fields coverted to integer. In recipe edit screen removed the Print button. It is now included in the export screen. Added recipe export to forum screen.
Michiel Broek <mbroek@mbse.eu>
parents: 352
diff changeset
405 $recipes .= ',"uuid":"' . str_replace($escapers, $replacements, $row['uuid']);
168
ce92dc75cb09 Added locked setting to the recipes. Is not working well when a recipe is loaded and locked. Added uuid load and save for recipes. Mad a lot of variables local in functions. The subgrids are loaded async.
Michiel Broek <mbroek@mbse.eu>
parents: 166
diff changeset
406 $recipes .= '","locked":' . $row['locked'];
51
7224109adfe1 More recipe editor changes
Michiel Broek <mbroek@mbse.eu>
parents: 50
diff changeset
407 $recipes .= ',"st_guide":"' . str_replace($escapers, $replacements, $row['st_guide']);
7224109adfe1 More recipe editor changes
Michiel Broek <mbroek@mbse.eu>
parents: 50
diff changeset
408 $recipes .= '","st_letter":"' . str_replace($escapers, $replacements, $row['st_letter']);
7224109adfe1 More recipe editor changes
Michiel Broek <mbroek@mbse.eu>
parents: 50
diff changeset
409 $recipes .= '","st_name":"' . str_replace($escapers, $replacements, $row['st_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: 168
diff changeset
410 $recipes .= '","st_type":' . $row['st_type'];
14e349ff2a10 Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents: 168
diff changeset
411 $recipes .= ',"st_category":"' . str_replace($escapers, $replacements, $row['st_category']);
710
9646123ea063 Fixed st_category_namber to be an integer value instead of float. The calc_acid in a new recipe is integer. Added missing wg_ and wb_ fields in a new recipe.
Michiel Broek <mbroek@mbse.eu>
parents: 667
diff changeset
412 $recipes .= '","st_category_number":' . $row['st_category_number'];
72
93a0be4f5be3 Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents: 71
diff changeset
413 $recipes .= ',"st_og_min":' . floatval($row['st_og_min']);
51
7224109adfe1 More recipe editor changes
Michiel Broek <mbroek@mbse.eu>
parents: 50
diff changeset
414 $recipes .= ',"st_og_max":' . floatval($row['st_og_max']);
7224109adfe1 More recipe editor changes
Michiel Broek <mbroek@mbse.eu>
parents: 50
diff changeset
415 $recipes .= ',"st_fg_min":' . floatval($row['st_fg_min']);
7224109adfe1 More recipe editor changes
Michiel Broek <mbroek@mbse.eu>
parents: 50
diff changeset
416 $recipes .= ',"st_fg_max":' . floatval($row['st_fg_max']);
7224109adfe1 More recipe editor changes
Michiel Broek <mbroek@mbse.eu>
parents: 50
diff changeset
417 $recipes .= ',"st_ibu_min":' . floatval($row['st_ibu_min']);
7224109adfe1 More recipe editor changes
Michiel Broek <mbroek@mbse.eu>
parents: 50
diff changeset
418 $recipes .= ',"st_ibu_max":' . floatval($row['st_ibu_max']);
7224109adfe1 More recipe editor changes
Michiel Broek <mbroek@mbse.eu>
parents: 50
diff changeset
419 $recipes .= ',"st_color_min":' . floatval($row['st_color_min']);
7224109adfe1 More recipe editor changes
Michiel Broek <mbroek@mbse.eu>
parents: 50
diff changeset
420 $recipes .= ',"st_color_max":' . floatval($row['st_color_max']);
7224109adfe1 More recipe editor changes
Michiel Broek <mbroek@mbse.eu>
parents: 50
diff changeset
421 $recipes .= ',"st_carb_min":' . floatval($row['st_carb_min']);
7224109adfe1 More recipe editor changes
Michiel Broek <mbroek@mbse.eu>
parents: 50
diff changeset
422 $recipes .= ',"st_carb_max":' . floatval($row['st_carb_max']);
7224109adfe1 More recipe editor changes
Michiel Broek <mbroek@mbse.eu>
parents: 50
diff changeset
423 $recipes .= ',"st_abv_min":' . floatval($row['st_abv_min']);
7224109adfe1 More recipe editor changes
Michiel Broek <mbroek@mbse.eu>
parents: 50
diff changeset
424 $recipes .= ',"st_abv_max":' . floatval($row['st_abv_max']);
7224109adfe1 More recipe editor changes
Michiel Broek <mbroek@mbse.eu>
parents: 50
diff changeset
425 $recipes .= ',"name":"' . str_replace($escapers, $replacements, $row['name']);
50
6d94167c2697 Next steps to implement a recipe editor
Michiel Broek <mbroek@mbse.eu>
parents: 49
diff changeset
426 $recipes .= '","notes":"' . str_replace($escapers, $replacements, $row['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: 168
diff changeset
427 $recipes .= '","type":' . $row['type'];
14e349ff2a10 Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents: 168
diff changeset
428 $recipes .= ',"batch_size":' . floatval($row['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: 80
diff changeset
429 $recipes .= ',"boil_size":' . floatval($row['boil_size']);
49
4d27a7fb1265 Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
430 $recipes .= ',"boil_time":' . floatval($row['boil_time']);
4d27a7fb1265 Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
431 $recipes .= ',"efficiency":' . floatval($row['efficiency']);
4d27a7fb1265 Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
432 $recipes .= ',"est_og":' . floatval($row['est_og']);
4d27a7fb1265 Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
433 $recipes .= ',"est_fg":' . floatval($row['est_fg']);
72
93a0be4f5be3 Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents: 71
diff changeset
434 $recipes .= ',"est_abv":' . floatval($row['est_abv']);
93a0be4f5be3 Added category and type to the recipe style. Added tooltips in the edit screen. Added Alcohol and Carbonation to the recipe style. Redesigned the main edit window and added the style limits.
Michiel Broek <mbroek@mbse.eu>
parents: 71
diff changeset
435 $recipes .= ',"est_carb":' . floatval($row['est_carb']);
49
4d27a7fb1265 Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
436 $recipes .= ',"est_color":' . floatval($row['est_color']);
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: 168
diff changeset
437 $recipes .= ',"color_method":' . $row['color_method'];
14e349ff2a10 Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents: 168
diff changeset
438 $recipes .= ',"est_ibu":' . floatval($row['est_ibu']);
14e349ff2a10 Recipes import uses indexes instead of strings. Started rebuilding the recipes editor using indexes and standard formats. Rebuild the fermentable editor from grid editing to popup editing. Most calculations are using indexes for dropdown values.
Michiel Broek <mbroek@mbse.eu>
parents: 168
diff changeset
439 $recipes .= ',"ibu_method":' . $row['ibu_method'];
359
98354ef399cd Lot's of improvements for recipes and products database load and save. Insert missing yeast tolerance field for old products and recipes. Recipe locked and calc_acid fields coverted to integer. In recipe edit screen removed the Print button. It is now included in the export screen. Added recipe export to forum screen.
Michiel Broek <mbroek@mbse.eu>
parents: 352
diff changeset
440 $recipes .= ',"sparge_temp":' . floatval($row['sparge_temp']);
98354ef399cd Lot's of improvements for recipes and products database load and save. Insert missing yeast tolerance field for old products and recipes. Recipe locked and calc_acid fields coverted to integer. In recipe edit screen removed the Print button. It is now included in the export screen. Added recipe export to forum screen.
Michiel Broek <mbroek@mbse.eu>
parents: 352
diff changeset
441 $recipes .= ',"sparge_ph":' . floatval($row['sparge_ph']);
98354ef399cd Lot's of improvements for recipes and products database load and save. Insert missing yeast tolerance field for old products and recipes. Recipe locked and calc_acid fields coverted to integer. In recipe edit screen removed the Print button. It is now included in the export screen. Added recipe export to forum screen.
Michiel Broek <mbroek@mbse.eu>
parents: 352
diff changeset
442 $recipes .= ',"sparge_volume":' . floatval($row['sparge_volume']);
156
35860890224c Added sparge water acid calculation. Added residual alkalinity calculation.
Michiel Broek <mbroek@mbse.eu>
parents: 154
diff changeset
443 $recipes .= ',"sparge_source":"' . $row['sparge_source'];
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: 168
diff changeset
444 $recipes .= '","sparge_acid_type":' . $row['sparge_acid_type'];
359
98354ef399cd Lot's of improvements for recipes and products database load and save. Insert missing yeast tolerance field for old products and recipes. Recipe locked and calc_acid fields coverted to integer. In recipe edit screen removed the Print button. It is now included in the export screen. Added recipe export to forum screen.
Michiel Broek <mbroek@mbse.eu>
parents: 352
diff changeset
445 $recipes .= ',"sparge_acid_perc":' . floatval($row['sparge_acid_perc']);
98354ef399cd Lot's of improvements for recipes and products database load and save. Insert missing yeast tolerance field for old products and recipes. Recipe locked and calc_acid fields coverted to integer. In recipe edit screen removed the Print button. It is now included in the export screen. Added recipe export to forum screen.
Michiel Broek <mbroek@mbse.eu>
parents: 352
diff changeset
446 $recipes .= ',"sparge_acid_amount":' . floatval($row['sparge_acid_amount']);
98354ef399cd Lot's of improvements for recipes and products database load and save. Insert missing yeast tolerance field for old products and recipes. Recipe locked and calc_acid fields coverted to integer. In recipe edit screen removed the Print button. It is now included in the export screen. Added recipe export to forum screen.
Michiel Broek <mbroek@mbse.eu>
parents: 352
diff changeset
447 $recipes .= ',"mash_ph":' . floatval($row['mash_ph']);
98354ef399cd Lot's of improvements for recipes and products database load and save. Insert missing yeast tolerance field for old products and recipes. Recipe locked and calc_acid fields coverted to integer. In recipe edit screen removed the Print button. It is now included in the export screen. Added recipe export to forum screen.
Michiel Broek <mbroek@mbse.eu>
parents: 352
diff changeset
448 $recipes .= ',"mash_name":"' . str_replace($escapers, $replacements, $row['mash_name']);
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
449 $recipes .= '","calc_acid":' . $row['calc_acid'];
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
450 $recipes .= ',"w1_name":"' . str_replace($escapers, $replacements, $row['w1_name']);
359
98354ef399cd Lot's of improvements for recipes and products database load and save. Insert missing yeast tolerance field for old products and recipes. Recipe locked and calc_acid fields coverted to integer. In recipe edit screen removed the Print button. It is now included in the export screen. Added recipe export to forum screen.
Michiel Broek <mbroek@mbse.eu>
parents: 352
diff changeset
451 $recipes .= '","w1_amount":' . floatval($row['w1_amount']);
98354ef399cd Lot's of improvements for recipes and products database load and save. Insert missing yeast tolerance field for old products and recipes. Recipe locked and calc_acid fields coverted to integer. In recipe edit screen removed the Print button. It is now included in the export screen. Added recipe export to forum screen.
Michiel Broek <mbroek@mbse.eu>
parents: 352
diff changeset
452 $recipes .= ',"w1_calcium":' . floatval($row['w1_calcium']);
98354ef399cd Lot's of improvements for recipes and products database load and save. Insert missing yeast tolerance field for old products and recipes. Recipe locked and calc_acid fields coverted to integer. In recipe edit screen removed the Print button. It is now included in the export screen. Added recipe export to forum screen.
Michiel Broek <mbroek@mbse.eu>
parents: 352
diff changeset
453 $recipes .= ',"w1_sulfate":' . floatval($row['w1_sulfate']);
98354ef399cd Lot's of improvements for recipes and products database load and save. Insert missing yeast tolerance field for old products and recipes. Recipe locked and calc_acid fields coverted to integer. In recipe edit screen removed the Print button. It is now included in the export screen. Added recipe export to forum screen.
Michiel Broek <mbroek@mbse.eu>
parents: 352
diff changeset
454 $recipes .= ',"w1_chloride":' . floatval($row['w1_chloride']);
98354ef399cd Lot's of improvements for recipes and products database load and save. Insert missing yeast tolerance field for old products and recipes. Recipe locked and calc_acid fields coverted to integer. In recipe edit screen removed the Print button. It is now included in the export screen. Added recipe export to forum screen.
Michiel Broek <mbroek@mbse.eu>
parents: 352
diff changeset
455 $recipes .= ',"w1_sodium":' . floatval($row['w1_sodium']);
98354ef399cd Lot's of improvements for recipes and products database load and save. Insert missing yeast tolerance field for old products and recipes. Recipe locked and calc_acid fields coverted to integer. In recipe edit screen removed the Print button. It is now included in the export screen. Added recipe export to forum screen.
Michiel Broek <mbroek@mbse.eu>
parents: 352
diff changeset
456 $recipes .= ',"w1_magnesium":' . floatval($row['w1_magnesium']);
98354ef399cd Lot's of improvements for recipes and products database load and save. Insert missing yeast tolerance field for old products and recipes. Recipe locked and calc_acid fields coverted to integer. In recipe edit screen removed the Print button. It is now included in the export screen. Added recipe export to forum screen.
Michiel Broek <mbroek@mbse.eu>
parents: 352
diff changeset
457 $recipes .= ',"w1_total_alkalinity":' . floatval($row['w1_total_alkalinity']);
98354ef399cd Lot's of improvements for recipes and products database load and save. Insert missing yeast tolerance field for old products and recipes. Recipe locked and calc_acid fields coverted to integer. In recipe edit screen removed the Print button. It is now included in the export screen. Added recipe export to forum screen.
Michiel Broek <mbroek@mbse.eu>
parents: 352
diff changeset
458 $recipes .= ',"w1_ph":' . floatval($row['w1_ph']);
98354ef399cd Lot's of improvements for recipes and products database load and save. Insert missing yeast tolerance field for old products and recipes. Recipe locked and calc_acid fields coverted to integer. In recipe edit screen removed the Print button. It is now included in the export screen. Added recipe export to forum screen.
Michiel Broek <mbroek@mbse.eu>
parents: 352
diff changeset
459 $recipes .= ',"w1_cost":' . floatval($row['w1_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
460 $recipes .= ',"w2_name":"' . str_replace($escapers, $replacements, $row['w2_name']);
359
98354ef399cd Lot's of improvements for recipes and products database load and save. Insert missing yeast tolerance field for old products and recipes. Recipe locked and calc_acid fields coverted to integer. In recipe edit screen removed the Print button. It is now included in the export screen. Added recipe export to forum screen.
Michiel Broek <mbroek@mbse.eu>
parents: 352
diff changeset
461 $recipes .= '","w2_amount":' . floatval($row['w2_amount']);
98354ef399cd Lot's of improvements for recipes and products database load and save. Insert missing yeast tolerance field for old products and recipes. Recipe locked and calc_acid fields coverted to integer. In recipe edit screen removed the Print button. It is now included in the export screen. Added recipe export to forum screen.
Michiel Broek <mbroek@mbse.eu>
parents: 352
diff changeset
462 $recipes .= ',"w2_calcium":' . floatval($row['w2_calcium']);
98354ef399cd Lot's of improvements for recipes and products database load and save. Insert missing yeast tolerance field for old products and recipes. Recipe locked and calc_acid fields coverted to integer. In recipe edit screen removed the Print button. It is now included in the export screen. Added recipe export to forum screen.
Michiel Broek <mbroek@mbse.eu>
parents: 352
diff changeset
463 $recipes .= ',"w2_sulfate":' . floatval($row['w2_sulfate']);
98354ef399cd Lot's of improvements for recipes and products database load and save. Insert missing yeast tolerance field for old products and recipes. Recipe locked and calc_acid fields coverted to integer. In recipe edit screen removed the Print button. It is now included in the export screen. Added recipe export to forum screen.
Michiel Broek <mbroek@mbse.eu>
parents: 352
diff changeset
464 $recipes .= ',"w2_chloride":' . floatval($row['w2_chloride']);
98354ef399cd Lot's of improvements for recipes and products database load and save. Insert missing yeast tolerance field for old products and recipes. Recipe locked and calc_acid fields coverted to integer. In recipe edit screen removed the Print button. It is now included in the export screen. Added recipe export to forum screen.
Michiel Broek <mbroek@mbse.eu>
parents: 352
diff changeset
465 $recipes .= ',"w2_sodium":' . floatval($row['w2_sodium']);
98354ef399cd Lot's of improvements for recipes and products database load and save. Insert missing yeast tolerance field for old products and recipes. Recipe locked and calc_acid fields coverted to integer. In recipe edit screen removed the Print button. It is now included in the export screen. Added recipe export to forum screen.
Michiel Broek <mbroek@mbse.eu>
parents: 352
diff changeset
466 $recipes .= ',"w2_magnesium":' . floatval($row['w2_magnesium']);
98354ef399cd Lot's of improvements for recipes and products database load and save. Insert missing yeast tolerance field for old products and recipes. Recipe locked and calc_acid fields coverted to integer. In recipe edit screen removed the Print button. It is now included in the export screen. Added recipe export to forum screen.
Michiel Broek <mbroek@mbse.eu>
parents: 352
diff changeset
467 $recipes .= ',"w2_total_alkalinity":' . floatval($row['w2_total_alkalinity']);
98354ef399cd Lot's of improvements for recipes and products database load and save. Insert missing yeast tolerance field for old products and recipes. Recipe locked and calc_acid fields coverted to integer. In recipe edit screen removed the Print button. It is now included in the export screen. Added recipe export to forum screen.
Michiel Broek <mbroek@mbse.eu>
parents: 352
diff changeset
468 $recipes .= ',"w2_ph":' . floatval($row['w2_ph']);
98354ef399cd Lot's of improvements for recipes and products database load and save. Insert missing yeast tolerance field for old products and recipes. Recipe locked and calc_acid fields coverted to integer. In recipe edit screen removed the Print button. It is now included in the export screen. Added recipe export to forum screen.
Michiel Broek <mbroek@mbse.eu>
parents: 352
diff changeset
469 $recipes .= ',"w2_cost":' . floatval($row['w2_cost']);
392
544d7d0183b2 Added 15 fields to the recipes table. Added 18 fields to the products table. These are calculated values that are now stored in the database so export programs can use these values without calculating them again. Product and recipe print have water and mash schedule added. Product print has brewday results added if the brewday is over. The ingredients layout changed in the product and recipe prints.
Michiel Broek <mbroek@mbse.eu>
parents: 359
diff changeset
470 $recipes .= ',"wg_amount":' . floatval($row['wg_amount']);
544d7d0183b2 Added 15 fields to the recipes table. Added 18 fields to the products table. These are calculated values that are now stored in the database so export programs can use these values without calculating them again. Product and recipe print have water and mash schedule added. Product print has brewday results added if the brewday is over. The ingredients layout changed in the product and recipe prints.
Michiel Broek <mbroek@mbse.eu>
parents: 359
diff changeset
471 $recipes .= ',"wg_calcium":' . floatval($row['wg_calcium']);
544d7d0183b2 Added 15 fields to the recipes table. Added 18 fields to the products table. These are calculated values that are now stored in the database so export programs can use these values without calculating them again. Product and recipe print have water and mash schedule added. Product print has brewday results added if the brewday is over. The ingredients layout changed in the product and recipe prints.
Michiel Broek <mbroek@mbse.eu>
parents: 359
diff changeset
472 $recipes .= ',"wg_sulfate":' . floatval($row['wg_sulfate']);
544d7d0183b2 Added 15 fields to the recipes table. Added 18 fields to the products table. These are calculated values that are now stored in the database so export programs can use these values without calculating them again. Product and recipe print have water and mash schedule added. Product print has brewday results added if the brewday is over. The ingredients layout changed in the product and recipe prints.
Michiel Broek <mbroek@mbse.eu>
parents: 359
diff changeset
473 $recipes .= ',"wg_chloride":' . floatval($row['wg_chloride']);
544d7d0183b2 Added 15 fields to the recipes table. Added 18 fields to the products table. These are calculated values that are now stored in the database so export programs can use these values without calculating them again. Product and recipe print have water and mash schedule added. Product print has brewday results added if the brewday is over. The ingredients layout changed in the product and recipe prints.
Michiel Broek <mbroek@mbse.eu>
parents: 359
diff changeset
474 $recipes .= ',"wg_sodium":' . floatval($row['wg_sodium']);
544d7d0183b2 Added 15 fields to the recipes table. Added 18 fields to the products table. These are calculated values that are now stored in the database so export programs can use these values without calculating them again. Product and recipe print have water and mash schedule added. Product print has brewday results added if the brewday is over. The ingredients layout changed in the product and recipe prints.
Michiel Broek <mbroek@mbse.eu>
parents: 359
diff changeset
475 $recipes .= ',"wg_magnesium":' . floatval($row['wg_magnesium']);
544d7d0183b2 Added 15 fields to the recipes table. Added 18 fields to the products table. These are calculated values that are now stored in the database so export programs can use these values without calculating them again. Product and recipe print have water and mash schedule added. Product print has brewday results added if the brewday is over. The ingredients layout changed in the product and recipe prints.
Michiel Broek <mbroek@mbse.eu>
parents: 359
diff changeset
476 $recipes .= ',"wg_total_alkalinity":' . floatval($row['wg_total_alkalinity']);
544d7d0183b2 Added 15 fields to the recipes table. Added 18 fields to the products table. These are calculated values that are now stored in the database so export programs can use these values without calculating them again. Product and recipe print have water and mash schedule added. Product print has brewday results added if the brewday is over. The ingredients layout changed in the product and recipe prints.
Michiel Broek <mbroek@mbse.eu>
parents: 359
diff changeset
477 $recipes .= ',"wg_ph":' . floatval($row['wg_ph']);
544d7d0183b2 Added 15 fields to the recipes table. Added 18 fields to the products table. These are calculated values that are now stored in the database so export programs can use these values without calculating them again. Product and recipe print have water and mash schedule added. Product print has brewday results added if the brewday is over. The ingredients layout changed in the product and recipe prints.
Michiel Broek <mbroek@mbse.eu>
parents: 359
diff changeset
478 $recipes .= ',"wb_calcium":' . floatval($row['wb_calcium']);
544d7d0183b2 Added 15 fields to the recipes table. Added 18 fields to the products table. These are calculated values that are now stored in the database so export programs can use these values without calculating them again. Product and recipe print have water and mash schedule added. Product print has brewday results added if the brewday is over. The ingredients layout changed in the product and recipe prints.
Michiel Broek <mbroek@mbse.eu>
parents: 359
diff changeset
479 $recipes .= ',"wb_sulfate":' . floatval($row['wb_sulfate']);
544d7d0183b2 Added 15 fields to the recipes table. Added 18 fields to the products table. These are calculated values that are now stored in the database so export programs can use these values without calculating them again. Product and recipe print have water and mash schedule added. Product print has brewday results added if the brewday is over. The ingredients layout changed in the product and recipe prints.
Michiel Broek <mbroek@mbse.eu>
parents: 359
diff changeset
480 $recipes .= ',"wb_chloride":' . floatval($row['wb_chloride']);
544d7d0183b2 Added 15 fields to the recipes table. Added 18 fields to the products table. These are calculated values that are now stored in the database so export programs can use these values without calculating them again. Product and recipe print have water and mash schedule added. Product print has brewday results added if the brewday is over. The ingredients layout changed in the product and recipe prints.
Michiel Broek <mbroek@mbse.eu>
parents: 359
diff changeset
481 $recipes .= ',"wb_sodium":' . floatval($row['wb_sodium']);
544d7d0183b2 Added 15 fields to the recipes table. Added 18 fields to the products table. These are calculated values that are now stored in the database so export programs can use these values without calculating them again. Product and recipe print have water and mash schedule added. Product print has brewday results added if the brewday is over. The ingredients layout changed in the product and recipe prints.
Michiel Broek <mbroek@mbse.eu>
parents: 359
diff changeset
482 $recipes .= ',"wb_magnesium":' . floatval($row['wb_magnesium']);
544d7d0183b2 Added 15 fields to the recipes table. Added 18 fields to the products table. These are calculated values that are now stored in the database so export programs can use these values without calculating them again. Product and recipe print have water and mash schedule added. Product print has brewday results added if the brewday is over. The ingredients layout changed in the product and recipe prints.
Michiel Broek <mbroek@mbse.eu>
parents: 359
diff changeset
483 $recipes .= ',"wb_total_alkalinity":' . floatval($row['wb_total_alkalinity']);
544d7d0183b2 Added 15 fields to the recipes table. Added 18 fields to the products table. These are calculated values that are now stored in the database so export programs can use these values without calculating them again. Product and recipe print have water and mash schedule added. Product print has brewday results added if the brewday is over. The ingredients layout changed in the product and recipe prints.
Michiel Broek <mbroek@mbse.eu>
parents: 359
diff changeset
484 $recipes .= ',"wb_ph":' . floatval($row['wb_ph']);
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: 168
diff changeset
485 $recipes .= ',"wa_acid_name":' . $row['wa_acid_name'];
359
98354ef399cd Lot's of improvements for recipes and products database load and save. Insert missing yeast tolerance field for old products and recipes. Recipe locked and calc_acid fields coverted to integer. In recipe edit screen removed the Print button. It is now included in the export screen. Added recipe export to forum screen.
Michiel Broek <mbroek@mbse.eu>
parents: 352
diff changeset
486 $recipes .= ',"wa_acid_perc":' . floatval($row['wa_acid_perc']);
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: 168
diff changeset
487 $recipes .= ',"wa_base_name":' . $row['wa_base_name'];
221
a8aabb63fbcc Added two missing fields in getfermentablesources.php. When getting a single recipe from the database, update the fermentables json data with available inventory and ingredient. Added inventory column in the fermentable grid. Added ingredient selection in the fermentable popup window to replace ingredient.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
488 if (isset($_GET['record'])) {
a8aabb63fbcc Added two missing fields in getfermentablesources.php. When getting a single recipe from the database, update the fermentables json data with available inventory and ingredient. Added inventory column in the fermentable grid. Added ingredient selection in the fermentable popup window to replace ingredient.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
489 // Append stock information.
a8aabb63fbcc Added two missing fields in getfermentablesources.php. When getting a single recipe from the database, update the fermentables json data with available inventory and ingredient. Added inventory column in the fermentable grid. Added ingredient selection in the fermentable popup window to replace ingredient.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
490 $fermentables = json_decode($row['json_fermentables'], true);
a8aabb63fbcc Added two missing fields in getfermentablesources.php. When getting a single recipe from the database, update the fermentables json data with available inventory and ingredient. Added inventory column in the fermentable grid. Added ingredient selection in the fermentable popup window to replace ingredient.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
491 for ($i = 0; $i < count($fermentables); $i++) {
a8aabb63fbcc Added two missing fields in getfermentablesources.php. When getting a single recipe from the database, update the fermentables json data with available inventory and ingredient. Added inventory column in the fermentable grid. Added ingredient selection in the fermentable popup window to replace ingredient.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
492 $fermentables[$i]['f_inventory'] = 0; // Not in stock
a8aabb63fbcc Added two missing fields in getfermentablesources.php. When getting a single recipe from the database, update the fermentables json data with available inventory and ingredient. Added inventory column in the fermentable grid. Added ingredient selection in the fermentable popup window to replace ingredient.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
493 $fermentables[$i]['f_avail'] = 0; // Ingredient not in db
a8aabb63fbcc Added two missing fields in getfermentablesources.php. When getting a single recipe from the database, update the fermentables json data with available inventory and ingredient. Added inventory column in the fermentable grid. Added ingredient selection in the fermentable popup window to replace ingredient.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
494 $sql2 = "SELECT inventory FROM inventory_fermentables ";
222
78946739b3a6 All recipe data now has inventory information added.
Michiel Broek <mbroek@mbse.eu>
parents: 221
diff changeset
495 $sql2 .= "WHERE name='".str_replace($rescapers, $rreplacements, $fermentables[$i]['f_name'])."' AND";
78946739b3a6 All recipe data now has inventory information added.
Michiel Broek <mbroek@mbse.eu>
parents: 221
diff changeset
496 $sql2 .= " supplier='".str_replace($rescapers, $rreplacements, $fermentables[$i]['f_supplier'])."'";
221
a8aabb63fbcc Added two missing fields in getfermentablesources.php. When getting a single recipe from the database, update the fermentables json data with available inventory and ingredient. Added inventory column in the fermentable grid. Added ingredient selection in the fermentable popup window to replace ingredient.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
497 if ($result2 = mysqli_query($connect, $sql2)) {
a8aabb63fbcc Added two missing fields in getfermentablesources.php. When getting a single recipe from the database, update the fermentables json data with available inventory and ingredient. Added inventory column in the fermentable grid. Added ingredient selection in the fermentable popup window to replace ingredient.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
498 if ($obj = mysqli_fetch_object($result2)) {
222
78946739b3a6 All recipe data now has inventory information added.
Michiel Broek <mbroek@mbse.eu>
parents: 221
diff changeset
499 $fermentables[$i]['f_inventory'] = floatval($obj->inventory);
221
a8aabb63fbcc Added two missing fields in getfermentablesources.php. When getting a single recipe from the database, update the fermentables json data with available inventory and ingredient. Added inventory column in the fermentable grid. Added ingredient selection in the fermentable popup window to replace ingredient.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
500 $fermentables[$i]['f_avail'] = 1;
a8aabb63fbcc Added two missing fields in getfermentablesources.php. When getting a single recipe from the database, update the fermentables json data with available inventory and ingredient. Added inventory column in the fermentable grid. Added ingredient selection in the fermentable popup window to replace ingredient.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
501 }
a8aabb63fbcc Added two missing fields in getfermentablesources.php. When getting a single recipe from the database, update the fermentables json data with available inventory and ingredient. Added inventory column in the fermentable grid. Added ingredient selection in the fermentable popup window to replace ingredient.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
502 mysqli_free_result($result2);
a8aabb63fbcc Added two missing fields in getfermentablesources.php. When getting a single recipe from the database, update the fermentables json data with available inventory and ingredient. Added inventory column in the fermentable grid. Added ingredient selection in the fermentable popup window to replace ingredient.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
503 }
a8aabb63fbcc Added two missing fields in getfermentablesources.php. When getting a single recipe from the database, update the fermentables json data with available inventory and ingredient. Added inventory column in the fermentable grid. Added ingredient selection in the fermentable popup window to replace ingredient.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
504 }
a8aabb63fbcc Added two missing fields in getfermentablesources.php. When getting a single recipe from the database, update the fermentables json data with available inventory and ingredient. Added inventory column in the fermentable grid. Added ingredient selection in the fermentable popup window to replace ingredient.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
505 $recipes .= ',"fermentables":' . json_encode($fermentables, JSON_UNESCAPED_UNICODE);
222
78946739b3a6 All recipe data now has inventory information added.
Michiel Broek <mbroek@mbse.eu>
parents: 221
diff changeset
506
78946739b3a6 All recipe data now has inventory information added.
Michiel Broek <mbroek@mbse.eu>
parents: 221
diff changeset
507 $hops = json_decode($row['json_hops'], true);
78946739b3a6 All recipe data now has inventory information added.
Michiel Broek <mbroek@mbse.eu>
parents: 221
diff changeset
508 for ($i = 0; $i < count($hops); $i++) {
78946739b3a6 All recipe data now has inventory information added.
Michiel Broek <mbroek@mbse.eu>
parents: 221
diff changeset
509 $hops[$i]['h_inventory'] = 0; // Not in stock
78946739b3a6 All recipe data now has inventory information added.
Michiel Broek <mbroek@mbse.eu>
parents: 221
diff changeset
510 $hops[$i]['h_avail'] = 0; // Ingredient not in db
78946739b3a6 All recipe data now has inventory information added.
Michiel Broek <mbroek@mbse.eu>
parents: 221
diff changeset
511 $sql2 = "SELECT inventory FROM inventory_hops ";
78946739b3a6 All recipe data now has inventory information added.
Michiel Broek <mbroek@mbse.eu>
parents: 221
diff changeset
512 $sql2 .= "WHERE name='".str_replace($rescapers, $rreplacements, $hops[$i]['h_name'])."' AND";
78946739b3a6 All recipe data now has inventory information added.
Michiel Broek <mbroek@mbse.eu>
parents: 221
diff changeset
513 $sql2 .= " origin='".str_replace($rescapers, $rreplacements, $hops[$i]['h_origin'])."' AND";
78946739b3a6 All recipe data now has inventory information added.
Michiel Broek <mbroek@mbse.eu>
parents: 221
diff changeset
514 $sql2 .= " form='".$hops[$i]['h_form']."'";
78946739b3a6 All recipe data now has inventory information added.
Michiel Broek <mbroek@mbse.eu>
parents: 221
diff changeset
515 if ($result2 = mysqli_query($connect, $sql2)) {
78946739b3a6 All recipe data now has inventory information added.
Michiel Broek <mbroek@mbse.eu>
parents: 221
diff changeset
516 if ($obj = mysqli_fetch_object($result2)) {
78946739b3a6 All recipe data now has inventory information added.
Michiel Broek <mbroek@mbse.eu>
parents: 221
diff changeset
517 $hops[$i]['h_inventory'] = floatval($obj->inventory);
78946739b3a6 All recipe data now has inventory information added.
Michiel Broek <mbroek@mbse.eu>
parents: 221
diff changeset
518 $hops[$i]['h_avail'] = 1;
78946739b3a6 All recipe data now has inventory information added.
Michiel Broek <mbroek@mbse.eu>
parents: 221
diff changeset
519 }
78946739b3a6 All recipe data now has inventory information added.
Michiel Broek <mbroek@mbse.eu>
parents: 221
diff changeset
520 mysqli_free_result($result2);
78946739b3a6 All recipe data now has inventory information added.
Michiel Broek <mbroek@mbse.eu>
parents: 221
diff changeset
521 }
78946739b3a6 All recipe data now has inventory information added.
Michiel Broek <mbroek@mbse.eu>
parents: 221
diff changeset
522 }
78946739b3a6 All recipe data now has inventory information added.
Michiel Broek <mbroek@mbse.eu>
parents: 221
diff changeset
523 $recipes .= ',"hops":' . json_encode($hops, JSON_UNESCAPED_UNICODE);
78946739b3a6 All recipe data now has inventory information added.
Michiel Broek <mbroek@mbse.eu>
parents: 221
diff changeset
524
78946739b3a6 All recipe data now has inventory information added.
Michiel Broek <mbroek@mbse.eu>
parents: 221
diff changeset
525 $miscs = json_decode($row['json_miscs'], true);
78946739b3a6 All recipe data now has inventory information added.
Michiel Broek <mbroek@mbse.eu>
parents: 221
diff changeset
526 for ($i = 0; $i < count($miscs); $i++) {
78946739b3a6 All recipe data now has inventory information added.
Michiel Broek <mbroek@mbse.eu>
parents: 221
diff changeset
527 $miscs[$i]['m_inventory'] = 0; // Not in stock
78946739b3a6 All recipe data now has inventory information added.
Michiel Broek <mbroek@mbse.eu>
parents: 221
diff changeset
528 $miscs[$i]['m_avail'] = 0; // Ingredient not in db
78946739b3a6 All recipe data now has inventory information added.
Michiel Broek <mbroek@mbse.eu>
parents: 221
diff changeset
529 $sql2 = "SELECT inventory FROM inventory_miscs ";
78946739b3a6 All recipe data now has inventory information added.
Michiel Broek <mbroek@mbse.eu>
parents: 221
diff changeset
530 $sql2 .= "WHERE name='".str_replace($rescapers, $rreplacements, $miscs[$i]['m_name'])."' AND";
78946739b3a6 All recipe data now has inventory information added.
Michiel Broek <mbroek@mbse.eu>
parents: 221
diff changeset
531 $sql2 .= " type='".$miscs[$i]['m_type']."'";
78946739b3a6 All recipe data now has inventory information added.
Michiel Broek <mbroek@mbse.eu>
parents: 221
diff changeset
532 if ($result2 = mysqli_query($connect, $sql2)) {
78946739b3a6 All recipe data now has inventory information added.
Michiel Broek <mbroek@mbse.eu>
parents: 221
diff changeset
533 if ($obj = mysqli_fetch_object($result2)) {
78946739b3a6 All recipe data now has inventory information added.
Michiel Broek <mbroek@mbse.eu>
parents: 221
diff changeset
534 $miscs[$i]['m_inventory'] = floatval($obj->inventory);
78946739b3a6 All recipe data now has inventory information added.
Michiel Broek <mbroek@mbse.eu>
parents: 221
diff changeset
535 $miscs[$i]['m_avail'] = 1;
78946739b3a6 All recipe data now has inventory information added.
Michiel Broek <mbroek@mbse.eu>
parents: 221
diff changeset
536 }
78946739b3a6 All recipe data now has inventory information added.
Michiel Broek <mbroek@mbse.eu>
parents: 221
diff changeset
537 mysqli_free_result($result2);
78946739b3a6 All recipe data now has inventory information added.
Michiel Broek <mbroek@mbse.eu>
parents: 221
diff changeset
538 }
78946739b3a6 All recipe data now has inventory information added.
Michiel Broek <mbroek@mbse.eu>
parents: 221
diff changeset
539 }
78946739b3a6 All recipe data now has inventory information added.
Michiel Broek <mbroek@mbse.eu>
parents: 221
diff changeset
540 $recipes .= ',"miscs":' . json_encode($miscs, JSON_UNESCAPED_UNICODE);
78946739b3a6 All recipe data now has inventory information added.
Michiel Broek <mbroek@mbse.eu>
parents: 221
diff changeset
541
78946739b3a6 All recipe data now has inventory information added.
Michiel Broek <mbroek@mbse.eu>
parents: 221
diff changeset
542 $yeasts = json_decode($row['json_yeasts'], true);
78946739b3a6 All recipe data now has inventory information added.
Michiel Broek <mbroek@mbse.eu>
parents: 221
diff changeset
543 for ($i = 0; $i < count($yeasts); $i++) {
78946739b3a6 All recipe data now has inventory information added.
Michiel Broek <mbroek@mbse.eu>
parents: 221
diff changeset
544 $yeasts[$i]['y_inventory'] = 0; // Not in stock
78946739b3a6 All recipe data now has inventory information added.
Michiel Broek <mbroek@mbse.eu>
parents: 221
diff changeset
545 $yeasts[$i]['y_avail'] = 0; // Ingredient not in db
359
98354ef399cd Lot's of improvements for recipes and products database load and save. Insert missing yeast tolerance field for old products and recipes. Recipe locked and calc_acid fields coverted to integer. In recipe edit screen removed the Print button. It is now included in the export screen. Added recipe export to forum screen.
Michiel Broek <mbroek@mbse.eu>
parents: 352
diff changeset
546 if (! isset($yeasts[$i]['y_tolerance']))
98354ef399cd Lot's of improvements for recipes and products database load and save. Insert missing yeast tolerance field for old products and recipes. Recipe locked and calc_acid fields coverted to integer. In recipe edit screen removed the Print button. It is now included in the export screen. Added recipe export to forum screen.
Michiel Broek <mbroek@mbse.eu>
parents: 352
diff changeset
547 $yeasts[$i]['y_tolerance'] = 0;
559
10cc2400b5d5 Backported extra yeast fields and the SO4:Cl ratio changes into the recipes editor.
Michiel Broek <mbroek@mbse.eu>
parents: 394
diff changeset
548 $sql2 = "SELECT inventory,tolerance,sta1,bacteria,harvest_top,harvest_time,pitch_temperature,pofpos,zymocide ";
10cc2400b5d5 Backported extra yeast fields and the SO4:Cl ratio changes into the recipes editor.
Michiel Broek <mbroek@mbse.eu>
parents: 394
diff changeset
549 $sql2 .= "FROM inventory_yeasts ";
222
78946739b3a6 All recipe data now has inventory information added.
Michiel Broek <mbroek@mbse.eu>
parents: 221
diff changeset
550 $sql2 .= "WHERE name='".str_replace($rescapers, $rreplacements, $yeasts[$i]['y_name'])."' AND";
78946739b3a6 All recipe data now has inventory information added.
Michiel Broek <mbroek@mbse.eu>
parents: 221
diff changeset
551 $sql2 .= " form='".str_replace($rescapers, $rreplacements, $yeasts[$i]['y_form'])."' AND";
78946739b3a6 All recipe data now has inventory information added.
Michiel Broek <mbroek@mbse.eu>
parents: 221
diff changeset
552 $sql2 .= " laboratory='".str_replace($rescapers, $rreplacements, $yeasts[$i]['y_laboratory'])."' AND";
78946739b3a6 All recipe data now has inventory information added.
Michiel Broek <mbroek@mbse.eu>
parents: 221
diff changeset
553 $sql2 .= " product_id='".str_replace($rescapers, $rreplacements, $yeasts[$i]['y_product_id'])."'";
78946739b3a6 All recipe data now has inventory information added.
Michiel Broek <mbroek@mbse.eu>
parents: 221
diff changeset
554 if ($result2 = mysqli_query($connect, $sql2)) {
78946739b3a6 All recipe data now has inventory information added.
Michiel Broek <mbroek@mbse.eu>
parents: 221
diff changeset
555 if ($obj = mysqli_fetch_object($result2)) {
78946739b3a6 All recipe data now has inventory information added.
Michiel Broek <mbroek@mbse.eu>
parents: 221
diff changeset
556 $yeasts[$i]['y_inventory'] = floatval($obj->inventory);
78946739b3a6 All recipe data now has inventory information added.
Michiel Broek <mbroek@mbse.eu>
parents: 221
diff changeset
557 $yeasts[$i]['y_avail'] = 1;
559
10cc2400b5d5 Backported extra yeast fields and the SO4:Cl ratio changes into the recipes editor.
Michiel Broek <mbroek@mbse.eu>
parents: 394
diff changeset
558 if ($yeasts[$i]['y_tolerance'] == 0)
332
f0ca77097236 Display alcohol tolerance in the yeast editor. Display in red when the recipe estimate is higher then the yeast tolerance.
Michiel Broek <mbroek@mbse.eu>
parents: 233
diff changeset
559 $yeasts[$i]['y_tolerance'] = floatval($obj->tolerance); // Upgrade alcohol tolerance
559
10cc2400b5d5 Backported extra yeast fields and the SO4:Cl ratio changes into the recipes editor.
Michiel Broek <mbroek@mbse.eu>
parents: 394
diff changeset
560 // Upgrade new fields
10cc2400b5d5 Backported extra yeast fields and the SO4:Cl ratio changes into the recipes editor.
Michiel Broek <mbroek@mbse.eu>
parents: 394
diff changeset
561 if (! isset($yeasts[$i]['y_sta1']))
10cc2400b5d5 Backported extra yeast fields and the SO4:Cl ratio changes into the recipes editor.
Michiel Broek <mbroek@mbse.eu>
parents: 394
diff changeset
562 $yeasts[$i]['y_sta1'] = intval($obj->sta1);
10cc2400b5d5 Backported extra yeast fields and the SO4:Cl ratio changes into the recipes editor.
Michiel Broek <mbroek@mbse.eu>
parents: 394
diff changeset
563 if (! isset($yeasts[$i]['y_bacteria']))
10cc2400b5d5 Backported extra yeast fields and the SO4:Cl ratio changes into the recipes editor.
Michiel Broek <mbroek@mbse.eu>
parents: 394
diff changeset
564 $yeasts[$i]['y_bacteria'] = intval($obj->bacteria);
10cc2400b5d5 Backported extra yeast fields and the SO4:Cl ratio changes into the recipes editor.
Michiel Broek <mbroek@mbse.eu>
parents: 394
diff changeset
565 if (! isset($yeasts[$i]['y_harvest_top']))
10cc2400b5d5 Backported extra yeast fields and the SO4:Cl ratio changes into the recipes editor.
Michiel Broek <mbroek@mbse.eu>
parents: 394
diff changeset
566 $yeasts[$i]['y_harvest_top'] = intval($obj->harvest_top);
10cc2400b5d5 Backported extra yeast fields and the SO4:Cl ratio changes into the recipes editor.
Michiel Broek <mbroek@mbse.eu>
parents: 394
diff changeset
567 if (! isset($yeasts[$i]['y_harvest_time']))
10cc2400b5d5 Backported extra yeast fields and the SO4:Cl ratio changes into the recipes editor.
Michiel Broek <mbroek@mbse.eu>
parents: 394
diff changeset
568 $yeasts[$i]['y_harvest_time'] = intval($obj->harvest_time);
10cc2400b5d5 Backported extra yeast fields and the SO4:Cl ratio changes into the recipes editor.
Michiel Broek <mbroek@mbse.eu>
parents: 394
diff changeset
569 if (! isset($yeasts[$i]['y_pitch_temperature']))
10cc2400b5d5 Backported extra yeast fields and the SO4:Cl ratio changes into the recipes editor.
Michiel Broek <mbroek@mbse.eu>
parents: 394
diff changeset
570 $yeasts[$i]['y_pitch_temperature'] = floatval($obj->pitch_temperature);
10cc2400b5d5 Backported extra yeast fields and the SO4:Cl ratio changes into the recipes editor.
Michiel Broek <mbroek@mbse.eu>
parents: 394
diff changeset
571 if (! isset($yeasts[$i]['y_pofpos']))
10cc2400b5d5 Backported extra yeast fields and the SO4:Cl ratio changes into the recipes editor.
Michiel Broek <mbroek@mbse.eu>
parents: 394
diff changeset
572 $yeasts[$i]['y_pofpos'] = intval($obj->pofpos);
10cc2400b5d5 Backported extra yeast fields and the SO4:Cl ratio changes into the recipes editor.
Michiel Broek <mbroek@mbse.eu>
parents: 394
diff changeset
573 if (! isset($yeasts[$i]['y_zymocide']))
777
daf55c944fb0 Recipes backport for new dry-yeast fields and SQL error handlers.
Michiel Broek <mbroek@mbse.eu>
parents: 726
diff changeset
574 $yeasts[$i]['y_zymocide'] = intval($obj->zymocide);
daf55c944fb0 Recipes backport for new dry-yeast fields and SQL error handlers.
Michiel Broek <mbroek@mbse.eu>
parents: 726
diff changeset
575 if (! isset($yeasts[$i]['y_gr_hl_lo']))
daf55c944fb0 Recipes backport for new dry-yeast fields and SQL error handlers.
Michiel Broek <mbroek@mbse.eu>
parents: 726
diff changeset
576 $yeasts[$i]['y_gr_hl_lo'] = intval($obj->gr_hl_lo);
daf55c944fb0 Recipes backport for new dry-yeast fields and SQL error handlers.
Michiel Broek <mbroek@mbse.eu>
parents: 726
diff changeset
577 if (! isset($yeasts[$i]['y_sg_lo']))
daf55c944fb0 Recipes backport for new dry-yeast fields and SQL error handlers.
Michiel Broek <mbroek@mbse.eu>
parents: 726
diff changeset
578 $yeasts[$i]['y_sg_lo'] = floatval($obj->sg_lo);
daf55c944fb0 Recipes backport for new dry-yeast fields and SQL error handlers.
Michiel Broek <mbroek@mbse.eu>
parents: 726
diff changeset
579 if (! isset($yeasts[$i]['y_gr_hl_hi']))
daf55c944fb0 Recipes backport for new dry-yeast fields and SQL error handlers.
Michiel Broek <mbroek@mbse.eu>
parents: 726
diff changeset
580 $yeasts[$i]['y_gr_hl_hi'] = intval($obj->gr_hl_hi);
daf55c944fb0 Recipes backport for new dry-yeast fields and SQL error handlers.
Michiel Broek <mbroek@mbse.eu>
parents: 726
diff changeset
581 if (! isset($yeasts[$i]['y_sg_hi']))
daf55c944fb0 Recipes backport for new dry-yeast fields and SQL error handlers.
Michiel Broek <mbroek@mbse.eu>
parents: 726
diff changeset
582 $yeasts[$i]['y_sg_hi'] = floatval($obj->sg_hi);
565
dfc850e6ee1f Fix upgrade of the yeast data in products and recipes if the original yeast is not found. Export product or recipe for forum is now coded in forum format and copied to the clipboard ready to paste on a forum.
Michiel Broek <mbroek@mbse.eu>
parents: 559
diff changeset
583 } else {
dfc850e6ee1f Fix upgrade of the yeast data in products and recipes if the original yeast is not found. Export product or recipe for forum is now coded in forum format and copied to the clipboard ready to paste on a forum.
Michiel Broek <mbroek@mbse.eu>
parents: 559
diff changeset
584 if (! isset($yeasts[$i]['y_sta1']))
dfc850e6ee1f Fix upgrade of the yeast data in products and recipes if the original yeast is not found. Export product or recipe for forum is now coded in forum format and copied to the clipboard ready to paste on a forum.
Michiel Broek <mbroek@mbse.eu>
parents: 559
diff changeset
585 $yeasts[$i]['y_sta1'] = 0;
dfc850e6ee1f Fix upgrade of the yeast data in products and recipes if the original yeast is not found. Export product or recipe for forum is now coded in forum format and copied to the clipboard ready to paste on a forum.
Michiel Broek <mbroek@mbse.eu>
parents: 559
diff changeset
586 if (! isset($yeasts[$i]['y_bacteria']))
dfc850e6ee1f Fix upgrade of the yeast data in products and recipes if the original yeast is not found. Export product or recipe for forum is now coded in forum format and copied to the clipboard ready to paste on a forum.
Michiel Broek <mbroek@mbse.eu>
parents: 559
diff changeset
587 $yeasts[$i]['y_bacteria'] = 0;
dfc850e6ee1f Fix upgrade of the yeast data in products and recipes if the original yeast is not found. Export product or recipe for forum is now coded in forum format and copied to the clipboard ready to paste on a forum.
Michiel Broek <mbroek@mbse.eu>
parents: 559
diff changeset
588 if (! isset($yeasts[$i]['y_harvest_top']))
dfc850e6ee1f Fix upgrade of the yeast data in products and recipes if the original yeast is not found. Export product or recipe for forum is now coded in forum format and copied to the clipboard ready to paste on a forum.
Michiel Broek <mbroek@mbse.eu>
parents: 559
diff changeset
589 $yeasts[$i]['y_harvest_top'] = 0;
dfc850e6ee1f Fix upgrade of the yeast data in products and recipes if the original yeast is not found. Export product or recipe for forum is now coded in forum format and copied to the clipboard ready to paste on a forum.
Michiel Broek <mbroek@mbse.eu>
parents: 559
diff changeset
590 if (! isset($yeasts[$i]['y_harvest_time']))
dfc850e6ee1f Fix upgrade of the yeast data in products and recipes if the original yeast is not found. Export product or recipe for forum is now coded in forum format and copied to the clipboard ready to paste on a forum.
Michiel Broek <mbroek@mbse.eu>
parents: 559
diff changeset
591 $yeasts[$i]['y_harvest_time'] = 0;
dfc850e6ee1f Fix upgrade of the yeast data in products and recipes if the original yeast is not found. Export product or recipe for forum is now coded in forum format and copied to the clipboard ready to paste on a forum.
Michiel Broek <mbroek@mbse.eu>
parents: 559
diff changeset
592 if (! isset($yeasts[$i]['y_pitch_temperature']))
dfc850e6ee1f Fix upgrade of the yeast data in products and recipes if the original yeast is not found. Export product or recipe for forum is now coded in forum format and copied to the clipboard ready to paste on a forum.
Michiel Broek <mbroek@mbse.eu>
parents: 559
diff changeset
593 $yeasts[$i]['y_pitch_temperature'] = 0;
dfc850e6ee1f Fix upgrade of the yeast data in products and recipes if the original yeast is not found. Export product or recipe for forum is now coded in forum format and copied to the clipboard ready to paste on a forum.
Michiel Broek <mbroek@mbse.eu>
parents: 559
diff changeset
594 if (! isset($yeasts[$i]['y_pofpos']))
dfc850e6ee1f Fix upgrade of the yeast data in products and recipes if the original yeast is not found. Export product or recipe for forum is now coded in forum format and copied to the clipboard ready to paste on a forum.
Michiel Broek <mbroek@mbse.eu>
parents: 559
diff changeset
595 $yeasts[$i]['y_pofpos'] = 0;
dfc850e6ee1f Fix upgrade of the yeast data in products and recipes if the original yeast is not found. Export product or recipe for forum is now coded in forum format and copied to the clipboard ready to paste on a forum.
Michiel Broek <mbroek@mbse.eu>
parents: 559
diff changeset
596 if (! isset($yeasts[$i]['y_zymocide']))
777
daf55c944fb0 Recipes backport for new dry-yeast fields and SQL error handlers.
Michiel Broek <mbroek@mbse.eu>
parents: 726
diff changeset
597 $yeasts[$i]['y_zymocide'] = 0;
daf55c944fb0 Recipes backport for new dry-yeast fields and SQL error handlers.
Michiel Broek <mbroek@mbse.eu>
parents: 726
diff changeset
598 if (! isset($yeasts[$i]['y_gr_hl_lo']))
daf55c944fb0 Recipes backport for new dry-yeast fields and SQL error handlers.
Michiel Broek <mbroek@mbse.eu>
parents: 726
diff changeset
599 $yeasts[$i]['y_gr_hl_lo'] = 50;
daf55c944fb0 Recipes backport for new dry-yeast fields and SQL error handlers.
Michiel Broek <mbroek@mbse.eu>
parents: 726
diff changeset
600 if (! isset($yeasts[$i]['y_sg_lo']))
daf55c944fb0 Recipes backport for new dry-yeast fields and SQL error handlers.
Michiel Broek <mbroek@mbse.eu>
parents: 726
diff changeset
601 $yeasts[$i]['y_sg_lo'] = 1.04;
daf55c944fb0 Recipes backport for new dry-yeast fields and SQL error handlers.
Michiel Broek <mbroek@mbse.eu>
parents: 726
diff changeset
602 if (! isset($yeasts[$i]['y_gr_hl_hi']))
daf55c944fb0 Recipes backport for new dry-yeast fields and SQL error handlers.
Michiel Broek <mbroek@mbse.eu>
parents: 726
diff changeset
603 $yeasts[$i]['y_gr_hl_hi'] = 80;
daf55c944fb0 Recipes backport for new dry-yeast fields and SQL error handlers.
Michiel Broek <mbroek@mbse.eu>
parents: 726
diff changeset
604 if (! isset($yeasts[$i]['y_sg_hi']))
daf55c944fb0 Recipes backport for new dry-yeast fields and SQL error handlers.
Michiel Broek <mbroek@mbse.eu>
parents: 726
diff changeset
605 $yeasts[$i]['y_sg_hi'] = 1.08;
222
78946739b3a6 All recipe data now has inventory information added.
Michiel Broek <mbroek@mbse.eu>
parents: 221
diff changeset
606 }
78946739b3a6 All recipe data now has inventory information added.
Michiel Broek <mbroek@mbse.eu>
parents: 221
diff changeset
607 mysqli_free_result($result2);
78946739b3a6 All recipe data now has inventory information added.
Michiel Broek <mbroek@mbse.eu>
parents: 221
diff changeset
608 }
78946739b3a6 All recipe data now has inventory information added.
Michiel Broek <mbroek@mbse.eu>
parents: 221
diff changeset
609 }
711
0a1be3bfcc60 Removed some debug messages in products and recipes
Michiel Broek <mbroek@mbse.eu>
parents: 710
diff changeset
610 //syslog(LOG_NOTICE, json_encode($yeasts, JSON_UNESCAPED_UNICODE));
222
78946739b3a6 All recipe data now has inventory information added.
Michiel Broek <mbroek@mbse.eu>
parents: 221
diff changeset
611 $recipes .= ',"yeasts":' . json_encode($yeasts, JSON_UNESCAPED_UNICODE);
221
a8aabb63fbcc Added two missing fields in getfermentablesources.php. When getting a single recipe from the database, update the fermentables json data with available inventory and ingredient. Added inventory column in the fermentable grid. Added ingredient selection in the fermentable popup window to replace ingredient.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
612 } else {
a8aabb63fbcc Added two missing fields in getfermentablesources.php. When getting a single recipe from the database, update the fermentables json data with available inventory and ingredient. Added inventory column in the fermentable grid. Added ingredient selection in the fermentable popup window to replace ingredient.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
613 // Just leave it.
a8aabb63fbcc Added two missing fields in getfermentablesources.php. When getting a single recipe from the database, update the fermentables json data with available inventory and ingredient. Added inventory column in the fermentable grid. Added ingredient selection in the fermentable popup window to replace ingredient.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
614 $recipes .= ',"fermentables":' . $row['json_fermentables'];
a8aabb63fbcc Added two missing fields in getfermentablesources.php. When getting a single recipe from the database, update the fermentables json data with available inventory and ingredient. Added inventory column in the fermentable grid. Added ingredient selection in the fermentable popup window to replace ingredient.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
615 $recipes .= ',"hops":' . $row['json_hops'];
a8aabb63fbcc Added two missing fields in getfermentablesources.php. When getting a single recipe from the database, update the fermentables json data with available inventory and ingredient. Added inventory column in the fermentable grid. Added ingredient selection in the fermentable popup window to replace ingredient.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
616 $recipes .= ',"miscs":' . $row['json_miscs'];
a8aabb63fbcc Added two missing fields in getfermentablesources.php. When getting a single recipe from the database, update the fermentables json data with available inventory and ingredient. Added inventory column in the fermentable grid. Added ingredient selection in the fermentable popup window to replace ingredient.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
617 $recipes .= ',"yeasts":' . $row['json_yeasts'];
a8aabb63fbcc Added two missing fields in getfermentablesources.php. When getting a single recipe from the database, update the fermentables json data with available inventory and ingredient. Added inventory column in the fermentable grid. Added ingredient selection in the fermentable popup window to replace ingredient.
Michiel Broek <mbroek@mbse.eu>
parents: 220
diff changeset
618 }
352
9d2a4703bdac Version 0.1.2 Calculate mash thickness.
Michiel Broek <mbroek@mbse.eu>
parents: 350
diff changeset
619 $recipes .= ',"mashs":' . $row['json_mashs'];
49
4d27a7fb1265 Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
620 $recipes .= '}';
4d27a7fb1265 Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
621 }
4d27a7fb1265 Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
622 $recipes .= ']';
4d27a7fb1265 Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
623 header("Content-type: application/json");
4d27a7fb1265 Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
624 echo $recipes;
4d27a7fb1265 Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
625 }
4d27a7fb1265 Finisched recipe import. Added recipe retrieve script.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
626 ?>

mercurial