Thu, 13 Dec 2018 20:32:36 +0100
Added EBC color examples. Added simple progessbars for hop flavour and aroma contribution. We need something better. In the fermentables tab, above the grid display the malt color and OG estimates. Display supplier as well in the fermentables grid.
28 | 1 | <?php |
2 | ||
3 | require($_SERVER['DOCUMENT_ROOT']."/config.php"); | |
4 | require($_SERVER['DOCUMENT_ROOT']."/version.php"); | |
5 | ||
6 | #Connect to the database | |
7 | $connect = mysqli_connect(DBASE_HOST, DBASE_USER, DBASE_PASS, DBASE_NAME); | |
8 | if (! $connect) { | |
9 | die('Connect Error (' . mysqli_connect_errno() . ') ' . mysqli_connect_error()); | |
10 | } | |
77
a9f8de2d7b2b
Fixed most charset problems. Added fpdf library. Added inventory pdf creation.
Michiel Broek <mbroek@mbse.eu>
parents:
48
diff
changeset
|
11 | mysqli_set_charset($connect, "utf8" ); |
28 | 12 | |
13 | // get data and store in a json array | |
48
bdd1ec9b9c06
Start recipes import and menus.
Michiel Broek <mbroek@mbse.eu>
parents:
45
diff
changeset
|
14 | $query = "SELECT * FROM profile_styles ORDER BY style_guide,style_letter,name"; |
28 | 15 | if (isset($_GET['insert'])) { |
16 | // INSERT COMMAND | |
45
95251bedfab4
Moved three inventory tables and screens to profiles
Michiel Broek <mbroek@mbse.eu>
parents:
37
diff
changeset
|
17 | $sql = "INSERT INTO `profile_styles` SET name='" . mysqli_real_escape_string($connect, $_GET['name']); |
28 | 18 | $sql .= "', category='" . mysqli_real_escape_string($connect, $_GET['category']); |
19 | $sql .= "', category_number='" . $_GET['category_number']; | |
20 | $sql .= "', style_letter='" . mysqli_real_escape_string($connect, $_GET['style_letter']); | |
21 | $sql .= "', style_guide='" . mysqli_real_escape_string($connect, $_GET['style_guide']); | |
22 | $sql .= "', type='" . $_GET['type']; | |
23 | $sql .= "', og_min='" . $_GET['og_min']; | |
24 | $sql .= "', og_max='" . $_GET['og_max']; | |
25 | $sql .= "', fg_min='" . $_GET['fg_min']; | |
26 | $sql .= "', fg_max='" . $_GET['fg_max']; | |
27 | $sql .= "', ibu_min='" . $_GET['ibu_min']; | |
28 | $sql .= "', ibu_max='" . $_GET['ibu_max']; | |
29 | $sql .= "', color_min='" . $_GET['color_min']; | |
30 | $sql .= "', color_max='" . $_GET['color_max']; | |
31 | $sql .= "', carb_min='" . $_GET['carb_min']; | |
32 | $sql .= "', carb_max='" . $_GET['carb_max']; | |
33 | $sql .= "', abv_min='" . $_GET['abv_min']; | |
34 | $sql .= "', abv_max='" . $_GET['abv_max']; | |
35 | $sql .= "', notes='" . mysqli_real_escape_string($connect, $_GET['notes']); | |
36 | $sql .= "', profile='" . mysqli_real_escape_string($connect, $_GET['profile']); | |
37 | $sql .= "', ingredients='" . mysqli_real_escape_string($connect, $_GET['ingredients']); | |
38 | $sql .= "', examples='" . mysqli_real_escape_string($connect, $_GET['examples']); | |
39 | $sql .= "';"; | |
40 | $result = mysqli_query($connect, $sql); | |
41 | if (! $result) { | |
45
95251bedfab4
Moved three inventory tables and screens to profiles
Michiel Broek <mbroek@mbse.eu>
parents:
37
diff
changeset
|
42 | syslog(LOG_NOTICE, "db_profile_styles: ".$sql." result: ".mysqli_error($connect)); |
28 | 43 | } else { |
45
95251bedfab4
Moved three inventory tables and screens to profiles
Michiel Broek <mbroek@mbse.eu>
parents:
37
diff
changeset
|
44 | syslog(LOG_NOTICE, "db_profile_styles: inserted ".$_GET['name']); |
28 | 45 | } |
46 | echo $result; | |
47 | ||
48 | } else if (isset($_GET['update'])) { | |
49 | // UPDATE COMMAND | |
45
95251bedfab4
Moved three inventory tables and screens to profiles
Michiel Broek <mbroek@mbse.eu>
parents:
37
diff
changeset
|
50 | $sql = "UPDATE `profile_styles` SET name='" . mysqli_real_escape_string($connect, $_GET['name']); |
28 | 51 | $sql .= "', category='" . mysqli_real_escape_string($connect, $_GET['category']); |
52 | $sql .= "', category_number='" . $_GET['category_number']; | |
53 | $sql .= "', style_letter='" . mysqli_real_escape_string($connect, $_GET['style_letter']); | |
54 | $sql .= "', style_guide='" . mysqli_real_escape_string($connect, $_GET['style_guide']); | |
55 | $sql .= "', type='" . $_GET['type']; | |
56 | $sql .= "', og_min='" . $_GET['og_min']; | |
57 | $sql .= "', og_max='" . $_GET['og_max']; | |
58 | $sql .= "', fg_min='" . $_GET['fg_min']; | |
59 | $sql .= "', fg_max='" . $_GET['fg_max']; | |
60 | $sql .= "', ibu_min='" . $_GET['ibu_min']; | |
61 | $sql .= "', ibu_max='" . $_GET['ibu_max']; | |
62 | $sql .= "', color_min='" . $_GET['color_min']; | |
63 | $sql .= "', color_max='" . $_GET['color_max']; | |
64 | $sql .= "', carb_min='" . $_GET['carb_min']; | |
65 | $sql .= "', carb_max='" . $_GET['carb_max']; | |
66 | $sql .= "', abv_min='" . $_GET['abv_min']; | |
67 | $sql .= "', abv_max='" . $_GET['abv_max']; | |
68 | $sql .= "', notes='" . mysqli_real_escape_string($connect, $_GET['notes']); | |
69 | $sql .= "', profile='" . mysqli_real_escape_string($connect, $_GET['profile']); | |
70 | $sql .= "', ingredients='" . mysqli_real_escape_string($connect, $_GET['ingredients']); | |
71 | $sql .= "', examples='" . mysqli_real_escape_string($connect, $_GET['examples']); | |
72 | $sql .= "' WHERE record='" . $_GET['record'] . "';"; | |
73 | $result = mysqli_query($connect, $sql); | |
74 | if (! $result) { | |
45
95251bedfab4
Moved three inventory tables and screens to profiles
Michiel Broek <mbroek@mbse.eu>
parents:
37
diff
changeset
|
75 | syslog(LOG_NOTICE, "db_profile_styles: ".$sql." result: ".mysqli_error($connect)); |
28 | 76 | } else { |
45
95251bedfab4
Moved three inventory tables and screens to profiles
Michiel Broek <mbroek@mbse.eu>
parents:
37
diff
changeset
|
77 | syslog(LOG_NOTICE, "db_profile_styles: updated record ".$_GET['record']); |
28 | 78 | } |
79 | echo $result; | |
80 | ||
81 | } else if (isset($_GET['delete'])) { | |
82 | // DELETE COMMAND | |
45
95251bedfab4
Moved three inventory tables and screens to profiles
Michiel Broek <mbroek@mbse.eu>
parents:
37
diff
changeset
|
83 | $sql = "DELETE FROM `profile_styles` WHERE record='".$_GET['record']."';"; |
28 | 84 | $result = mysqli_query($connect, $sql); |
85 | if (! $result) { | |
45
95251bedfab4
Moved three inventory tables and screens to profiles
Michiel Broek <mbroek@mbse.eu>
parents:
37
diff
changeset
|
86 | syslog(LOG_NOTICE, "db_profile_styles: ".$sql." result: ".mysqli_error($connect)); |
28 | 87 | } else { |
45
95251bedfab4
Moved three inventory tables and screens to profiles
Michiel Broek <mbroek@mbse.eu>
parents:
37
diff
changeset
|
88 | syslog(LOG_NOTICE, "db_profile_styles: deleted record ".$_GET['record']); |
28 | 89 | } |
90 | echo $result; | |
91 | ||
92 | } else { | |
93 | // SELECT COMMAND | |
94 | $result = mysqli_query($connect, $query) or die("SQL Error 1: " . mysqli_error($connect)); | |
95 | while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { | |
96 | $styles[] = array( | |
97 | 'record' => $row['record'], | |
98 | 'name' => $row['name'], | |
99 | 'category' => $row['category'], | |
100 | 'category_number' => $row['category_number'], | |
101 | 'style_letter' => $row['style_letter'], | |
102 | 'style_guide' => $row['style_guide'], | |
103 | 'type' => $row['type'], | |
104 | 'og_min' => $row['og_min'], | |
105 | 'og_max' => $row['og_max'], | |
106 | 'fg_min' => $row['fg_min'], | |
107 | 'fg_max' => $row['fg_max'], | |
108 | 'ibu_min' => $row['ibu_min'], | |
109 | 'ibu_max' => $row['ibu_max'], | |
110 | 'color_min' => $row['color_min'], | |
111 | 'color_max' => $row['color_max'], | |
112 | 'carb_min' => $row['carb_min'], | |
113 | 'carb_max' => $row['carb_max'], | |
114 | 'abv_min' => $row['abv_min'], | |
115 | 'abv_max' => $row['abv_max'], | |
116 | 'notes' => $row['notes'], | |
117 | 'profile' => $row['profile'], | |
118 | 'ingredients' => $row['ingredients'], | |
119 | 'examples' => $row['examples'] | |
120 | ); | |
121 | } | |
122 | echo json_encode($styles); | |
123 | } | |
124 | ?> |