Sun, 11 Apr 2021 10:09:44 +0200
Removed websocket debug info from the mainmenu
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 | |
211
63d0e40c58b9
Water profile uses POST instead of GET. Added tooltips to the editor screen. Updated the editor screen. Total alkalinity and Bicarbonate update each other. More and smaller columns in the listing screen. Rearranged the editor screen.
Michiel Broek <mbroek@mbse.eu>
parents:
77
diff
changeset
|
13 | if (isset($_POST['insert']) || isset($_POST['update'])) { |
63d0e40c58b9
Water profile uses POST instead of GET. Added tooltips to the editor screen. Updated the editor screen. Total alkalinity and Bicarbonate update each other. More and smaller columns in the listing screen. Rearranged the editor screen.
Michiel Broek <mbroek@mbse.eu>
parents:
77
diff
changeset
|
14 | if (isset($_POST['insert'])) { |
63d0e40c58b9
Water profile uses POST instead of GET. Added tooltips to the editor screen. Updated the editor screen. Total alkalinity and Bicarbonate update each other. More and smaller columns in the listing screen. Rearranged the editor screen.
Michiel Broek <mbroek@mbse.eu>
parents:
77
diff
changeset
|
15 | $sql = "INSERT INTO `profile_water` SET "; |
63d0e40c58b9
Water profile uses POST instead of GET. Added tooltips to the editor screen. Updated the editor screen. Total alkalinity and Bicarbonate update each other. More and smaller columns in the listing screen. Rearranged the editor screen.
Michiel Broek <mbroek@mbse.eu>
parents:
77
diff
changeset
|
16 | } |
63d0e40c58b9
Water profile uses POST instead of GET. Added tooltips to the editor screen. Updated the editor screen. Total alkalinity and Bicarbonate update each other. More and smaller columns in the listing screen. Rearranged the editor screen.
Michiel Broek <mbroek@mbse.eu>
parents:
77
diff
changeset
|
17 | if (isset($_POST['update'])) { |
63d0e40c58b9
Water profile uses POST instead of GET. Added tooltips to the editor screen. Updated the editor screen. Total alkalinity and Bicarbonate update each other. More and smaller columns in the listing screen. Rearranged the editor screen.
Michiel Broek <mbroek@mbse.eu>
parents:
77
diff
changeset
|
18 | $sql = "UPDATE `profile_water` SET "; |
63d0e40c58b9
Water profile uses POST instead of GET. Added tooltips to the editor screen. Updated the editor screen. Total alkalinity and Bicarbonate update each other. More and smaller columns in the listing screen. Rearranged the editor screen.
Michiel Broek <mbroek@mbse.eu>
parents:
77
diff
changeset
|
19 | } |
63d0e40c58b9
Water profile uses POST instead of GET. Added tooltips to the editor screen. Updated the editor screen. Total alkalinity and Bicarbonate update each other. More and smaller columns in the listing screen. Rearranged the editor screen.
Michiel Broek <mbroek@mbse.eu>
parents:
77
diff
changeset
|
20 | |
63d0e40c58b9
Water profile uses POST instead of GET. Added tooltips to the editor screen. Updated the editor screen. Total alkalinity and Bicarbonate update each other. More and smaller columns in the listing screen. Rearranged the editor screen.
Michiel Broek <mbroek@mbse.eu>
parents:
77
diff
changeset
|
21 | $sql .= "name='" . mysqli_real_escape_string($connect, $_POST['name']); |
63d0e40c58b9
Water profile uses POST instead of GET. Added tooltips to the editor screen. Updated the editor screen. Total alkalinity and Bicarbonate update each other. More and smaller columns in the listing screen. Rearranged the editor screen.
Michiel Broek <mbroek@mbse.eu>
parents:
77
diff
changeset
|
22 | $sql .= "', calcium='" . $_POST['calcium']; |
63d0e40c58b9
Water profile uses POST instead of GET. Added tooltips to the editor screen. Updated the editor screen. Total alkalinity and Bicarbonate update each other. More and smaller columns in the listing screen. Rearranged the editor screen.
Michiel Broek <mbroek@mbse.eu>
parents:
77
diff
changeset
|
23 | $sql .= "', bicarbonate='" . $_POST['bicarbonate']; |
63d0e40c58b9
Water profile uses POST instead of GET. Added tooltips to the editor screen. Updated the editor screen. Total alkalinity and Bicarbonate update each other. More and smaller columns in the listing screen. Rearranged the editor screen.
Michiel Broek <mbroek@mbse.eu>
parents:
77
diff
changeset
|
24 | $sql .= "', sulfate='" . $_POST['sulfate']; |
63d0e40c58b9
Water profile uses POST instead of GET. Added tooltips to the editor screen. Updated the editor screen. Total alkalinity and Bicarbonate update each other. More and smaller columns in the listing screen. Rearranged the editor screen.
Michiel Broek <mbroek@mbse.eu>
parents:
77
diff
changeset
|
25 | $sql .= "', chloride='" . $_POST['chloride']; |
63d0e40c58b9
Water profile uses POST instead of GET. Added tooltips to the editor screen. Updated the editor screen. Total alkalinity and Bicarbonate update each other. More and smaller columns in the listing screen. Rearranged the editor screen.
Michiel Broek <mbroek@mbse.eu>
parents:
77
diff
changeset
|
26 | $sql .= "', sodium='" . $_POST['sodium']; |
63d0e40c58b9
Water profile uses POST instead of GET. Added tooltips to the editor screen. Updated the editor screen. Total alkalinity and Bicarbonate update each other. More and smaller columns in the listing screen. Rearranged the editor screen.
Michiel Broek <mbroek@mbse.eu>
parents:
77
diff
changeset
|
27 | $sql .= "', magnesium='" . $_POST['magnesium']; |
63d0e40c58b9
Water profile uses POST instead of GET. Added tooltips to the editor screen. Updated the editor screen. Total alkalinity and Bicarbonate update each other. More and smaller columns in the listing screen. Rearranged the editor screen.
Michiel Broek <mbroek@mbse.eu>
parents:
77
diff
changeset
|
28 | $sql .= "', ph='" . $_POST['ph']; |
63d0e40c58b9
Water profile uses POST instead of GET. Added tooltips to the editor screen. Updated the editor screen. Total alkalinity and Bicarbonate update each other. More and smaller columns in the listing screen. Rearranged the editor screen.
Michiel Broek <mbroek@mbse.eu>
parents:
77
diff
changeset
|
29 | $sql .= "', notes='" . mysqli_real_escape_string($connect, $_POST['notes']); |
63d0e40c58b9
Water profile uses POST instead of GET. Added tooltips to the editor screen. Updated the editor screen. Total alkalinity and Bicarbonate update each other. More and smaller columns in the listing screen. Rearranged the editor screen.
Michiel Broek <mbroek@mbse.eu>
parents:
77
diff
changeset
|
30 | $sql .= "', total_alkalinity='" . $_POST['total_alkalinity']; |
63d0e40c58b9
Water profile uses POST instead of GET. Added tooltips to the editor screen. Updated the editor screen. Total alkalinity and Bicarbonate update each other. More and smaller columns in the listing screen. Rearranged the editor screen.
Michiel Broek <mbroek@mbse.eu>
parents:
77
diff
changeset
|
31 | if (isset($_POST['insert'])) { |
63d0e40c58b9
Water profile uses POST instead of GET. Added tooltips to the editor screen. Updated the editor screen. Total alkalinity and Bicarbonate update each other. More and smaller columns in the listing screen. Rearranged the editor screen.
Michiel Broek <mbroek@mbse.eu>
parents:
77
diff
changeset
|
32 | $sql .= "';"; |
63d0e40c58b9
Water profile uses POST instead of GET. Added tooltips to the editor screen. Updated the editor screen. Total alkalinity and Bicarbonate update each other. More and smaller columns in the listing screen. Rearranged the editor screen.
Michiel Broek <mbroek@mbse.eu>
parents:
77
diff
changeset
|
33 | } |
63d0e40c58b9
Water profile uses POST instead of GET. Added tooltips to the editor screen. Updated the editor screen. Total alkalinity and Bicarbonate update each other. More and smaller columns in the listing screen. Rearranged the editor screen.
Michiel Broek <mbroek@mbse.eu>
parents:
77
diff
changeset
|
34 | if (isset($_POST['update'])) { |
63d0e40c58b9
Water profile uses POST instead of GET. Added tooltips to the editor screen. Updated the editor screen. Total alkalinity and Bicarbonate update each other. More and smaller columns in the listing screen. Rearranged the editor screen.
Michiel Broek <mbroek@mbse.eu>
parents:
77
diff
changeset
|
35 | $sql .= "' WHERE record='" . $_POST['record'] . "';"; |
63d0e40c58b9
Water profile uses POST instead of GET. Added tooltips to the editor screen. Updated the editor screen. Total alkalinity and Bicarbonate update each other. More and smaller columns in the listing screen. Rearranged the editor screen.
Michiel Broek <mbroek@mbse.eu>
parents:
77
diff
changeset
|
36 | } |
716
57118e6a4bdb
Remove log messages if database profile updates are successfull.
Michiel Broek <mbroek@mbse.eu>
parents:
296
diff
changeset
|
37 | //syslog(LOG_NOTICE, $sql); |
211
63d0e40c58b9
Water profile uses POST instead of GET. Added tooltips to the editor screen. Updated the editor screen. Total alkalinity and Bicarbonate update each other. More and smaller columns in the listing screen. Rearranged the editor screen.
Michiel Broek <mbroek@mbse.eu>
parents:
77
diff
changeset
|
38 | |
22 | 39 | $result = mysqli_query($connect, $sql); |
40 | if (! $result) { | |
45
95251bedfab4
Moved three inventory tables and screens to profiles
Michiel Broek <mbroek@mbse.eu>
parents:
37
diff
changeset
|
41 | syslog(LOG_NOTICE, "db_profile_water: ".$sql." result: ".mysqli_error($connect)); |
716
57118e6a4bdb
Remove log messages if database profile updates are successfull.
Michiel Broek <mbroek@mbse.eu>
parents:
296
diff
changeset
|
42 | //} else { |
57118e6a4bdb
Remove log messages if database profile updates are successfull.
Michiel Broek <mbroek@mbse.eu>
parents:
296
diff
changeset
|
43 | // if (isset($_POST['update'])) { |
57118e6a4bdb
Remove log messages if database profile updates are successfull.
Michiel Broek <mbroek@mbse.eu>
parents:
296
diff
changeset
|
44 | // syslog(LOG_NOTICE, "db_profile_water: updated record ".$_POST['record']); |
57118e6a4bdb
Remove log messages if database profile updates are successfull.
Michiel Broek <mbroek@mbse.eu>
parents:
296
diff
changeset
|
45 | // } else { |
57118e6a4bdb
Remove log messages if database profile updates are successfull.
Michiel Broek <mbroek@mbse.eu>
parents:
296
diff
changeset
|
46 | // $lastid = mysqli_insert_id($connect); |
57118e6a4bdb
Remove log messages if database profile updates are successfull.
Michiel Broek <mbroek@mbse.eu>
parents:
296
diff
changeset
|
47 | // syslog(LOG_NOTICE, "db_profile_water: inserted record ".$lastid); |
57118e6a4bdb
Remove log messages if database profile updates are successfull.
Michiel Broek <mbroek@mbse.eu>
parents:
296
diff
changeset
|
48 | // } |
22 | 49 | } |
50 | echo $result; | |
51 | ||
211
63d0e40c58b9
Water profile uses POST instead of GET. Added tooltips to the editor screen. Updated the editor screen. Total alkalinity and Bicarbonate update each other. More and smaller columns in the listing screen. Rearranged the editor screen.
Michiel Broek <mbroek@mbse.eu>
parents:
77
diff
changeset
|
52 | } else if (isset($_POST['delete'])) { |
63d0e40c58b9
Water profile uses POST instead of GET. Added tooltips to the editor screen. Updated the editor screen. Total alkalinity and Bicarbonate update each other. More and smaller columns in the listing screen. Rearranged the editor screen.
Michiel Broek <mbroek@mbse.eu>
parents:
77
diff
changeset
|
53 | // DELETE COMMAND |
63d0e40c58b9
Water profile uses POST instead of GET. Added tooltips to the editor screen. Updated the editor screen. Total alkalinity and Bicarbonate update each other. More and smaller columns in the listing screen. Rearranged the editor screen.
Michiel Broek <mbroek@mbse.eu>
parents:
77
diff
changeset
|
54 | $sql = "DELETE FROM `profile_water` WHERE record='".$_POST['record']."';"; |
22 | 55 | $result = mysqli_query($connect, $sql); |
56 | if (! $result) { | |
45
95251bedfab4
Moved three inventory tables and screens to profiles
Michiel Broek <mbroek@mbse.eu>
parents:
37
diff
changeset
|
57 | syslog(LOG_NOTICE, "db_profile_water: ".$sql." result: ".mysqli_error($connect)); |
22 | 58 | } else { |
211
63d0e40c58b9
Water profile uses POST instead of GET. Added tooltips to the editor screen. Updated the editor screen. Total alkalinity and Bicarbonate update each other. More and smaller columns in the listing screen. Rearranged the editor screen.
Michiel Broek <mbroek@mbse.eu>
parents:
77
diff
changeset
|
59 | syslog(LOG_NOTICE, "db_profile_water: deleted record ".$_POST['record']); |
22 | 60 | } |
61 | echo $result; | |
62 | ||
63 | } else { | |
64 | // SELECT COMMAND | |
211
63d0e40c58b9
Water profile uses POST instead of GET. Added tooltips to the editor screen. Updated the editor screen. Total alkalinity and Bicarbonate update each other. More and smaller columns in the listing screen. Rearranged the editor screen.
Michiel Broek <mbroek@mbse.eu>
parents:
77
diff
changeset
|
65 | $query = "SELECT * FROM profile_water ORDER BY name"; |
22 | 66 | $result = mysqli_query($connect, $query) or die("SQL Error 1: " . mysqli_error($connect)); |
67 | while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { | |
68 | $waters[] = array( | |
69 | 'record' => $row['record'], | |
70 | 'name' => $row['name'], | |
71 | 'calcium' => $row['calcium'], | |
72 | 'bicarbonate' => $row['bicarbonate'], | |
73 | 'sulfate' => $row['sulfate'], | |
74 | 'chloride' => $row['chloride'], | |
75 | 'sodium' => $row['sodium'], | |
76 | 'magnesium' => $row['magnesium'], | |
77 | 'ph' => $row['ph'], | |
78 | 'notes' => $row['notes'], | |
79 | 'total_alkalinity' => $row['total_alkalinity'] | |
80 | ); | |
81 | } | |
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:
211
diff
changeset
|
82 | header("Content-type: application/json"); |
22 | 83 | echo json_encode($waters); |
84 | } | |
85 | ?> |