Mon, 31 Dec 2018 22:20:04 +0100
Moved the tooltips to the field declarations.
27 | 1 | <?php |
2 | require($_SERVER['DOCUMENT_ROOT']."/config.php"); | |
3 | require($_SERVER['DOCUMENT_ROOT']."/version.php"); | |
4 | ||
5 | #Connect to the database | |
6 | $connect = mysqli_connect(DBASE_HOST, DBASE_USER, DBASE_PASS, DBASE_NAME); | |
7 | if (! $connect) { | |
8 | die('Connect Error (' . mysqli_connect_errno() . ') ' . mysqli_connect_error()); | |
9 | } | |
77
a9f8de2d7b2b
Fixed most charset problems. Added fpdf library. Added inventory pdf creation.
Michiel Broek <mbroek@mbse.eu>
parents:
37
diff
changeset
|
10 | mysqli_set_charset($connect, "utf8" ); |
27 | 11 | |
12 | // get data and store in a json array | |
37
9362eb9e9e5b
Sorting the inventory and changes some grid tables.
Michiel Broek <mbroek@mbse.eu>
parents:
27
diff
changeset
|
13 | $query = "SELECT * FROM inventory_equipments ORDER BY name"; |
115
ad31f4bd4036
Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents:
77
diff
changeset
|
14 | if (isset($_GET['insert']) || isset($_GET['update'])) { |
ad31f4bd4036
Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents:
77
diff
changeset
|
15 | if (isset($_GET['insert'])) { |
ad31f4bd4036
Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents:
77
diff
changeset
|
16 | // INSERT COMMAND |
ad31f4bd4036
Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents:
77
diff
changeset
|
17 | $sql = "INSERT INTO `inventory_equipments` SET "; |
ad31f4bd4036
Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents:
77
diff
changeset
|
18 | } |
ad31f4bd4036
Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents:
77
diff
changeset
|
19 | if (isset($_GET['update'])) { |
ad31f4bd4036
Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents:
77
diff
changeset
|
20 | // UPDATE COMMAND |
ad31f4bd4036
Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents:
77
diff
changeset
|
21 | $sql = "UPDATE `inventory_equipments` SET "; |
ad31f4bd4036
Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents:
77
diff
changeset
|
22 | } |
ad31f4bd4036
Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents:
77
diff
changeset
|
23 | $sql .= "name='" . mysqli_real_escape_string($connect, $_GET['name']); |
27 | 24 | $sql .= "', boil_size='" . $_GET['boil_size']; |
116
ac993ef43b13
Removed all calculations from the equipemnts database script and added missing fields. Added missing fields to the inventory equipemnts edit screen. Added conditional batch size calculation to the equipments editor. Added specific heat settings to the equipments editor.
Michiel Broek <mbroek@mbse.eu>
parents:
115
diff
changeset
|
25 | $sql .= "', batch_size='" . $_GET['batch_size']; |
27 | 26 | $sql .= "', tun_volume='" . $_GET['tun_volume']; |
27 | $sql .= "', tun_weight='" . $_GET['tun_weight']; | |
116
ac993ef43b13
Removed all calculations from the equipemnts database script and added missing fields. Added missing fields to the inventory equipemnts edit screen. Added conditional batch size calculation to the equipments editor. Added specific heat settings to the equipments editor.
Michiel Broek <mbroek@mbse.eu>
parents:
115
diff
changeset
|
28 | $sql .= "', tun_specific_heat='" . $_GET['tun_specific_heat']; |
ac993ef43b13
Removed all calculations from the equipemnts database script and added missing fields. Added missing fields to the inventory equipemnts edit screen. Added conditional batch size calculation to the equipments editor. Added specific heat settings to the equipments editor.
Michiel Broek <mbroek@mbse.eu>
parents:
115
diff
changeset
|
29 | $sql .= "', tun_material='" . mysqli_real_escape_string($connect, $_GET['tun_material']); |
27 | 30 | $sql .= "', tun_height='" . $_GET['tun_height'] / 100.0; |
115
ad31f4bd4036
Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents:
77
diff
changeset
|
31 | $sql .= "', top_up_water='" . $_GET['top_up_water']; |
ad31f4bd4036
Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents:
77
diff
changeset
|
32 | $sql .= "', trub_chiller_loss='" . $_GET['trub_chiller_loss']; |
ad31f4bd4036
Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents:
77
diff
changeset
|
33 | $sql .= "', evap_rate='" . $_GET['evap_rate']; |
ad31f4bd4036
Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents:
77
diff
changeset
|
34 | $sql .= "', boil_time='" . $_GET['boil_time']; |
ad31f4bd4036
Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents:
77
diff
changeset
|
35 | ($_GET['calc_boil_volume'] == 'true') ? $sql .= "', calc_boil_volume='1" : $sql .= "', calc_boil_volume='0"; |
ad31f4bd4036
Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents:
77
diff
changeset
|
36 | $sql .= "', top_up_kettle='" . $_GET['top_up_kettle']; |
ad31f4bd4036
Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents:
77
diff
changeset
|
37 | $sql .= "', hop_utilization='" . $_GET['hop_utilization']; |
ad31f4bd4036
Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents:
77
diff
changeset
|
38 | $sql .= "', notes='" . mysqli_real_escape_string($connect, $_GET['notes']); |
ad31f4bd4036
Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents:
77
diff
changeset
|
39 | $sql .= "', lauter_volume='" . $_GET['lauter_volume']; |
ad31f4bd4036
Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents:
77
diff
changeset
|
40 | $sql .= "', lauter_height='" . $_GET['lauter_height'] / 100.0; |
ad31f4bd4036
Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents:
77
diff
changeset
|
41 | $sql .= "', lauter_deadspace='" . $_GET['lauter_deadspace']; |
ad31f4bd4036
Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents:
77
diff
changeset
|
42 | $sql .= "', kettle_volume='" . $_GET['kettle_volume']; |
27 | 43 | $sql .= "', kettle_height='" . $_GET['kettle_height'] / 100.0; |
44 | $sql .= "', mash_volume='" . $_GET['mash_volume']; | |
149
ff45488d480e
Added some icons from Brewersfriend. They should be replaced someday. Added maximum mash weight setting to the equipment database. Usefull for brew automate and RIMS systems. During recipes import acid and base additions are translated. Brews and recipes now have 2 water sources. Added water mixer. Added basic water treatment, but not for pH yet. Redesigned the fermentables and water tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
116
diff
changeset
|
45 | $sql .= "', mash_max='" . $_GET['mash_max']; |
27 | 46 | $sql .= "', efficiency='" . $_GET['efficiency']; |
115
ad31f4bd4036
Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents:
77
diff
changeset
|
47 | if (isset($_GET['insert'])) { |
ad31f4bd4036
Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents:
77
diff
changeset
|
48 | $sql .= "';"; |
ad31f4bd4036
Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents:
77
diff
changeset
|
49 | } |
ad31f4bd4036
Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents:
77
diff
changeset
|
50 | if (isset($_GET['update'])) { |
116
ac993ef43b13
Removed all calculations from the equipemnts database script and added missing fields. Added missing fields to the inventory equipemnts edit screen. Added conditional batch size calculation to the equipments editor. Added specific heat settings to the equipments editor.
Michiel Broek <mbroek@mbse.eu>
parents:
115
diff
changeset
|
51 | $sql .= "' WHERE record='" . $_GET['record'] . "';"; |
115
ad31f4bd4036
Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents:
77
diff
changeset
|
52 | } |
27 | 53 | $result = mysqli_query($connect, $sql); |
54 | if (! $result) { | |
55 | syslog(LOG_NOTICE, "db_inventory_equipment: ".$sql." result: ".mysqli_error($connect)); | |
56 | } else { | |
115
ad31f4bd4036
Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents:
77
diff
changeset
|
57 | if (isset($_GET['update'])) { |
ad31f4bd4036
Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents:
77
diff
changeset
|
58 | syslog(LOG_NOTICE, "db_inventory_equipment: updated record ".$_GET['record']); |
ad31f4bd4036
Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents:
77
diff
changeset
|
59 | } else { |
ad31f4bd4036
Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents:
77
diff
changeset
|
60 | $lastid = mysqli_insert_id($connect); |
ad31f4bd4036
Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents:
77
diff
changeset
|
61 | syslog(LOG_NOTICE, "db_inventory_equipment: inserted record ".$lastid); |
ad31f4bd4036
Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents:
77
diff
changeset
|
62 | } |
27 | 63 | } |
64 | echo $result; | |
65 | ||
66 | } else if (isset($_GET['delete'])) { | |
67 | // DELETE COMMAND | |
68 | // FIXME: need to check if the record is in use | |
69 | $sql = "DELETE FROM `inventory_equipments` WHERE record='".$_GET['record']."';"; | |
70 | $result = mysqli_query($connect, $sql); | |
71 | if (! $result) { | |
72 | syslog(LOG_NOTICE, "db_inventory_equipment: ".$sql." result: ".mysqli_error($connect)); | |
73 | } else { | |
74 | syslog(LOG_NOTICE, "db_inventory_equipment: deleted record ".$_GET['record']); | |
75 | } | |
76 | echo $result; | |
77 | ||
78 | } else { | |
79 | // SELECT COMMAND | |
80 | $result = mysqli_query($connect, $query) or die("SQL Error 1: " . mysqli_error($connect)); | |
81 | while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { | |
82 | $equipments[] = array( | |
83 | 'record' => $row['record'], | |
84 | 'name' => $row['name'], | |
85 | 'boil_size' => $row['boil_size'], | |
86 | 'batch_size' => $row['batch_size'], | |
87 | 'tun_volume' => $row['tun_volume'], | |
88 | 'tun_weight' => $row['tun_weight'], | |
115
ad31f4bd4036
Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents:
77
diff
changeset
|
89 | 'tun_specific_heat' => $row['tun_specific_heat'], |
ad31f4bd4036
Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents:
77
diff
changeset
|
90 | 'tun_material' => $row['tun_material'], |
ad31f4bd4036
Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents:
77
diff
changeset
|
91 | 'tun_height' => $row['tun_height'] * 100.0, |
27 | 92 | 'top_up_water' => $row['top_up_water'], |
93 | 'trub_chiller_loss' => $row['trub_chiller_loss'], | |
94 | 'evap_rate' => $row['evap_rate'], | |
95 | 'boil_time' => $row['boil_time'], | |
115
ad31f4bd4036
Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents:
77
diff
changeset
|
96 | 'calc_boil_volume' => $row['calc_boil_volume'], |
27 | 97 | 'top_up_kettle' => $row['top_up_kettle'], |
98 | 'hop_utilization' => $row['hop_utilization'], | |
99 | 'notes' => $row['notes'], | |
100 | 'lauter_volume' => $row['lauter_volume'], | |
115
ad31f4bd4036
Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents:
77
diff
changeset
|
101 | 'lauter_height' => $row['lauter_height'] * 100.0, |
ad31f4bd4036
Inventory database script added missing fields. Product database script added JOIN with the prod_recipes table.
Michiel Broek <mbroek@mbse.eu>
parents:
77
diff
changeset
|
102 | 'lauter_deadspace' => $row['lauter_deadspace'], |
27 | 103 | 'kettle_volume' => $row['kettle_volume'], |
104 | 'kettle_height' => $row['kettle_height'] * 100.0, | |
105 | 'mash_volume' => $row['mash_volume'], | |
149
ff45488d480e
Added some icons from Brewersfriend. They should be replaced someday. Added maximum mash weight setting to the equipment database. Usefull for brew automate and RIMS systems. During recipes import acid and base additions are translated. Brews and recipes now have 2 water sources. Added water mixer. Added basic water treatment, but not for pH yet. Redesigned the fermentables and water tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
116
diff
changeset
|
106 | 'mash_max' => $row['mash_max'], |
27 | 107 | 'efficiency' => $row['efficiency'] |
108 | ); | |
109 | } | |
110 | echo json_encode($equipments); | |
111 | } | |
112 | ?> |