Fri, 25 Jan 2019 13:33:10 +0100
Fixed yeast database import differences between grams, ml and packs. Added cells field filled with defaults. Some edit screen improvements. Dynamic prompts depending on the yeast type. Disable men and filter of most columns in the yeasts list. Friendlier display of inverntory.
22 | 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:
45
diff
changeset
|
11 | mysqli_set_charset($connect, "utf8" ); |
22 | 12 | |
13 | // get data and store in a json array | |
45
95251bedfab4
Moved three inventory tables and screens to profiles
Michiel Broek <mbroek@mbse.eu>
parents:
37
diff
changeset
|
14 | $query = "SELECT * FROM profile_water ORDER BY name"; |
22 | 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_water` SET name='" . mysqli_real_escape_string($connect, $_GET['name']); |
22 | 18 | $sql .= "', calcium='" . $_GET['calcium']; |
19 | $sql .= "', bicarbonate='" . $_GET['bicarbonate']; | |
20 | $sql .= "', sulfate='" . $_GET['sulfate']; | |
21 | $sql .= "', chloride='" . $_GET['chloride']; | |
22 | $sql .= "', sodium='" . $_GET['sodium']; | |
23 | $sql .= "', magnesium='" . $_GET['magnesium']; | |
24 | $sql .= "', ph='" . $_GET['ph']; | |
25 | $sql .= "', notes='" . mysqli_real_escape_string($connect, $_GET['notes']); | |
26 | $sql .= "', total_alkalinity='" . $_GET['total_alkalinity']; | |
27 | $sql .= "';"; | |
28 | $result = mysqli_query($connect, $sql); | |
29 | if (! $result) { | |
45
95251bedfab4
Moved three inventory tables and screens to profiles
Michiel Broek <mbroek@mbse.eu>
parents:
37
diff
changeset
|
30 | syslog(LOG_NOTICE, "db_profile_water: ".$sql." result: ".mysqli_error($connect)); |
22 | 31 | } else { |
45
95251bedfab4
Moved three inventory tables and screens to profiles
Michiel Broek <mbroek@mbse.eu>
parents:
37
diff
changeset
|
32 | syslog(LOG_NOTICE, "db_profile_water: inserted ".$_GET['name']); |
22 | 33 | } |
34 | echo $result; | |
35 | ||
36 | } else if (isset($_GET['update'])) { | |
37 | // UPDATE COMMAND | |
45
95251bedfab4
Moved three inventory tables and screens to profiles
Michiel Broek <mbroek@mbse.eu>
parents:
37
diff
changeset
|
38 | $sql = "UPDATE `profile_water` SET name='" . mysqli_real_escape_string($connect, $_GET['name']); |
22 | 39 | $sql .= "', calcium='" . $_GET['calcium']; |
40 | $sql .= "', bicarbonate='" . $_GET['bicarbonate']; | |
41 | $sql .= "', sulfate='" . $_GET['sulfate']; | |
42 | $sql .= "', chloride='" . $_GET['chloride']; | |
43 | $sql .= "', sodium='" . $_GET['sodium']; | |
44 | $sql .= "', magnesium='" . $_GET['magnesium']; | |
45 | $sql .= "', ph='" . $_GET['ph']; | |
46 | $sql .= "', notes='" . mysqli_real_escape_string($connect, $_GET['notes']); | |
47 | $sql .= "', total_alkalinity='" . $_GET['total_alkalinity']; | |
48 | $sql .= "' WHERE record='" . $_GET['record'] . "';"; | |
49 | $result = mysqli_query($connect, $sql); | |
50 | if (! $result) { | |
45
95251bedfab4
Moved three inventory tables and screens to profiles
Michiel Broek <mbroek@mbse.eu>
parents:
37
diff
changeset
|
51 | syslog(LOG_NOTICE, "db_profile_water: ".$sql." result: ".mysqli_error($connect)); |
22 | 52 | } else { |
45
95251bedfab4
Moved three inventory tables and screens to profiles
Michiel Broek <mbroek@mbse.eu>
parents:
37
diff
changeset
|
53 | syslog(LOG_NOTICE, "db_profile_water: updated record ".$_GET['record']); |
22 | 54 | } |
55 | echo $result; | |
56 | ||
57 | } else if (isset($_GET['delete'])) { | |
58 | // DELETE COMMAND | |
45
95251bedfab4
Moved three inventory tables and screens to profiles
Michiel Broek <mbroek@mbse.eu>
parents:
37
diff
changeset
|
59 | $sql = "DELETE FROM `profile_water` WHERE record='".$_GET['record']."';"; |
22 | 60 | $result = mysqli_query($connect, $sql); |
61 | if (! $result) { | |
45
95251bedfab4
Moved three inventory tables and screens to profiles
Michiel Broek <mbroek@mbse.eu>
parents:
37
diff
changeset
|
62 | syslog(LOG_NOTICE, "db_profile_water: ".$sql." result: ".mysqli_error($connect)); |
22 | 63 | } else { |
45
95251bedfab4
Moved three inventory tables and screens to profiles
Michiel Broek <mbroek@mbse.eu>
parents:
37
diff
changeset
|
64 | syslog(LOG_NOTICE, "db_profile_water: deleted record ".$_GET['record']); |
22 | 65 | } |
66 | echo $result; | |
67 | ||
68 | } else { | |
69 | // SELECT COMMAND | |
70 | $result = mysqli_query($connect, $query) or die("SQL Error 1: " . mysqli_error($connect)); | |
71 | while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { | |
72 | $waters[] = array( | |
73 | 'record' => $row['record'], | |
74 | 'name' => $row['name'], | |
75 | 'calcium' => $row['calcium'], | |
76 | 'bicarbonate' => $row['bicarbonate'], | |
77 | 'sulfate' => $row['sulfate'], | |
78 | 'chloride' => $row['chloride'], | |
79 | 'sodium' => $row['sodium'], | |
80 | 'magnesium' => $row['magnesium'], | |
81 | 'ph' => $row['ph'], | |
82 | 'notes' => $row['notes'], | |
83 | 'total_alkalinity' => $row['total_alkalinity'] | |
84 | ); | |
85 | } | |
86 | echo json_encode($waters); | |
87 | } | |
88 | ?> |