www/getfermentablesources.php

Wed, 15 Jul 2020 16:03:23 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Wed, 15 Jul 2020 16:03:23 +0200
changeset 705
d77b723f7b35
parent 296
69fadd1aded2
child 771
9856238e9217
permissions
-rw-r--r--

Make sure enumerated values are not empty in database updates. On several data queries set the database connection to UTF-8.

57
bb9a06aa9acd Completed framework inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1 <?php
bb9a06aa9acd Completed framework inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2 require_once('config.php');
bb9a06aa9acd Completed framework inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3
65
5d5c67818d11 Fermentable editor checks. Fermentables dropdown list shows a frienlier list
Michiel Broek <mbroek@mbse.eu>
parents: 57
diff changeset
4 $query = "SELECT * FROM inventory_fermentables ORDER BY supplier,name";
57
bb9a06aa9acd Completed framework inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5 $connect = mysqli_connect(DBASE_HOST,DBASE_USER,DBASE_PASS,DBASE_NAME);
bb9a06aa9acd Completed framework inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6 if (! $connect) {
bb9a06aa9acd Completed framework inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7 echo "[]";
bb9a06aa9acd Completed framework inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8 return;
bb9a06aa9acd Completed framework inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9 }
705
d77b723f7b35 Make sure enumerated values are not empty in database updates. On several data queries set the database connection to UTF-8.
Michiel Broek <mbroek@mbse.eu>
parents: 296
diff changeset
10 mysqli_set_charset($connect, "utf8");
57
bb9a06aa9acd Completed framework inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11 $result = mysqli_query($connect, $query);
bb9a06aa9acd Completed framework inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12 while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) {
bb9a06aa9acd Completed framework inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13 $fermentables[] = array(
bb9a06aa9acd Completed framework inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14 'record' => $row['record'],
bb9a06aa9acd Completed framework inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
15 'name' => $row['name'],
bb9a06aa9acd Completed framework inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
16 'type' => $row['type'],
bb9a06aa9acd Completed framework inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
17 'yield' => $row['yield'],
bb9a06aa9acd Completed framework inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
18 'color' => $row['color'],
bb9a06aa9acd Completed framework inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
19 'add_after_boil' => $row['add_after_boil'],
bb9a06aa9acd Completed framework inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
20 'origin' => $row['origin'],
bb9a06aa9acd Completed framework inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
21 'supplier' => $row['supplier'],
bb9a06aa9acd Completed framework inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
22 'coarse_fine_diff' => $row['coarse_fine_diff'],
bb9a06aa9acd Completed framework inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
23 'moisture' => $row['moisture'],
bb9a06aa9acd Completed framework inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
24 'diastatic_power' => $row['diastatic_power'],
bb9a06aa9acd Completed framework inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
25 'protein' => $row['protein'],
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: 65
diff changeset
26 'dissolved_protein' => $row['dissolved_protein'],
57
bb9a06aa9acd Completed framework inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
27 'max_in_batch' => $row['max_in_batch'],
bb9a06aa9acd Completed framework inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
28 'recommend_mash' => $row['recommend_mash'],
bb9a06aa9acd Completed framework inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
29 'graintype' => $row['graintype'],
bb9a06aa9acd Completed framework inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
30 'di_ph' => $row['di_ph'],
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: 65
diff changeset
31 'acid_to_ph_57' => $row['acid_to_ph_57'],
57
bb9a06aa9acd Completed framework inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
32 'inventory' => $row['inventory'],
bb9a06aa9acd Completed framework inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
33 'cost' => $row['cost']
bb9a06aa9acd Completed framework inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
34 );
bb9a06aa9acd Completed framework inline fermentables editor
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
35 }
296
69fadd1aded2 Updated design document. Add content header application/json to all scripts that produce json output. Chart prints show the beer code and name in the header. Charts don't display the menu anymore.
Michiel Broek <mbroek@mbse.eu>
parents: 221
diff changeset
36 header("Content-type: application/json");
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: 65
diff changeset
37 echo json_encode($fermentables, JSON_UNESCAPED_UNICODE);

mercurial