Mon, 12 Nov 2018 16:34:43 +0100
Missing Water agent costs from Brouwhulp import are now added from the imported miscs database. The printed recipe report now calculates the beer color from the ingredients. Also set during recipes import. This will later allow to set the color method for each recipe individually.
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"; |
27 | 14 | if (isset($_GET['insert'])) { |
15 | // INSERT COMMAND | |
16 | $sql = "INSERT INTO `inventory_equipments` SET name='" . mysqli_real_escape_string($connect, $_GET['name']); | |
17 | $sql .= "', boil_size='" . $_GET['boil_size']; | |
18 | $sql .= "', tun_volume='" . $_GET['tun_volume']; | |
19 | $sql .= "', tun_weight='" . $_GET['tun_weight']; | |
20 | $sql .= "', trub_chiller_loss='" . $_GET['trub_chiller_loss']; | |
21 | $sql .= "', evap_rate='" . $_GET['evap_rate']; | |
22 | $sql .= "', boil_time='" . $_GET['boil_time']; | |
23 | $sql .= "', calc_boil_volume='Y"; | |
24 | $batch = '$_GET[\'boil_size\'] - ($_GET[\'evap_rate\'] * ($_GET[\'boil_time\'] / 60))'; | |
25 | $sql .= "', batch_size='" . eval('return ' . $batch . ';'); | |
26 | $sql .= "', lauter_deadspace='" . $_GET['lauter_deadspace']; | |
27 | $sql .= "', top_up_kettle='" . $_GET['top_up_kettle']; | |
28 | $sql .= "', hop_utilization='" . $_GET['hop_utilization']; | |
29 | $sql .= "', notes='" . mysqli_real_escape_string($connect, $_GET['notes']); | |
30 | $sql .= "', lauter_volume='" . $_GET['lauter_volume']; | |
31 | $sql .= "', kettle_volume='" . $_GET['kettle_volume']; | |
32 | $material = mysqli_real_escape_string($connect, $_GET['tun_material']); | |
33 | $sql .= "', tun_material='" . $material; | |
34 | if ($material == "RVS") { | |
35 | $sql .= "', tun_specific_heat='0.11"; | |
36 | } else if ($material == "Aluminium") { | |
37 | $sql .= "', tun_specific_heat='0.22"; | |
38 | } else if ($material == "Kunststof") { | |
39 | $sql .= "', tun_specific_heat='0.46"; | |
40 | } else if ($material == "Koper") { | |
41 | $sql .= "', tun_specific_heat='0.092"; | |
42 | } | |
43 | $sql .= "', tun_height='" . $_GET['tun_height'] / 100.0; | |
44 | $sql .= "', kettle_height='" . $_GET['kettle_height'] / 100.0; | |
45 | $sql .= "', lauter_height='" . $_GET['lauter_height'] / 100.0; | |
46 | $sql .= "', mash_volume='" . $_GET['mash_volume']; | |
47 | $sql .= "', efficiency='" . $_GET['efficiency']; | |
48 | $sql .= "';"; | |
49 | $result = mysqli_query($connect, $sql); | |
50 | if (! $result) { | |
51 | syslog(LOG_NOTICE, "db_inventory_equipment: ".$sql." result: ".mysqli_error($connect)); | |
52 | } else { | |
53 | syslog(LOG_NOTICE, "db_inventory_equipment: inserted ".$_GET['name']); | |
54 | } | |
55 | echo $result; | |
56 | ||
57 | } else if (isset($_GET['update'])) { | |
58 | // UPDATE COMMAND | |
59 | $sql = "UPDATE `inventory_equipments` SET name='" . mysqli_real_escape_string($connect, $_GET['name']); | |
60 | $sql .= "', boil_size='" . $_GET['boil_size']; | |
61 | $sql .= "', tun_volume='" . $_GET['tun_volume']; | |
62 | $sql .= "', tun_weight='" . $_GET['tun_weight']; | |
63 | $sql .= "', trub_chiller_loss='" . $_GET['trub_chiller_loss']; | |
64 | $sql .= "', evap_rate='" . $_GET['evap_rate']; | |
65 | $sql .= "', boil_time='" . $_GET['boil_time']; | |
66 | $sql .= "', calc_boil_volume='Y"; | |
67 | $batch = '$_GET[\'boil_size\'] - ($_GET[\'evap_rate\'] * ($_GET[\'boil_time\'] / 60))'; | |
68 | $sql .= "', batch_size='" . eval('return ' . $batch . ';'); | |
69 | $sql .= "', lauter_deadspace='" . $_GET['lauter_deadspace']; | |
70 | $sql .= "', top_up_kettle='" . $_GET['top_up_kettle']; | |
71 | $sql .= "', hop_utilization='" . $_GET['hop_utilization']; | |
72 | $sql .= "', notes='" . mysqli_real_escape_string($connect, $_GET['notes']); | |
73 | $sql .= "', lauter_volume='" . $_GET['lauter_volume']; | |
74 | $sql .= "', kettle_volume='" . $_GET['kettle_volume']; | |
75 | $material = mysqli_real_escape_string($connect, $_GET['tun_material']); | |
76 | $sql .= "', tun_material='" . $material; | |
77 | if ($material == "RVS") { | |
78 | $sql .= "', tun_specific_heat='0.11"; | |
79 | } else if ($material == "Aluminium") { | |
80 | $sql .= "', tun_specific_heat='0.22"; | |
81 | } else if ($material == "Kunststof") { | |
82 | $sql .= "', tun_specific_heat='0.46"; | |
83 | } else if ($material == "Koper") { | |
84 | $sql .= "', tun_specific_heat='0.092"; | |
85 | } | |
86 | $sql .= "', tun_height='" . $_GET['tun_height'] / 100.0; | |
87 | $sql .= "', kettle_height='" . $_GET['kettle_height'] / 100.0; | |
88 | $sql .= "', lauter_height='" . $_GET['lauter_height'] / 100.0; | |
89 | $sql .= "', mash_volume='" . $_GET['mash_volume']; | |
90 | $sql .= "', efficiency='" . $_GET['efficiency']; | |
91 | $sql .= "' WHERE record='" . $_GET['record'] . "';"; | |
92 | $result = mysqli_query($connect, $sql); | |
93 | if (! $result) { | |
94 | syslog(LOG_NOTICE, "db_inventory_equipment: ".$sql." result: ".mysqli_error($connect)); | |
95 | } else { | |
96 | syslog(LOG_NOTICE, "db_inventory_equipment: updated record ".$_GET['record']); | |
97 | } | |
98 | echo $result; | |
99 | ||
100 | } else if (isset($_GET['delete'])) { | |
101 | // DELETE COMMAND | |
102 | // FIXME: need to check if the record is in use | |
103 | $sql = "DELETE FROM `inventory_equipments` WHERE record='".$_GET['record']."';"; | |
104 | $result = mysqli_query($connect, $sql); | |
105 | if (! $result) { | |
106 | syslog(LOG_NOTICE, "db_inventory_equipment: ".$sql." result: ".mysqli_error($connect)); | |
107 | } else { | |
108 | syslog(LOG_NOTICE, "db_inventory_equipment: deleted record ".$_GET['record']); | |
109 | } | |
110 | echo $result; | |
111 | ||
112 | } else { | |
113 | // SELECT COMMAND | |
114 | $result = mysqli_query($connect, $query) or die("SQL Error 1: " . mysqli_error($connect)); | |
115 | while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { | |
116 | $equipments[] = array( | |
117 | 'record' => $row['record'], | |
118 | 'name' => $row['name'], | |
119 | 'boil_size' => $row['boil_size'], | |
120 | 'batch_size' => $row['batch_size'], | |
121 | 'tun_volume' => $row['tun_volume'], | |
122 | 'tun_weight' => $row['tun_weight'], | |
123 | 'top_up_water' => $row['top_up_water'], | |
124 | 'trub_chiller_loss' => $row['trub_chiller_loss'], | |
125 | 'evap_rate' => $row['evap_rate'], | |
126 | 'boil_time' => $row['boil_time'], | |
127 | 'lauter_deadspace' => $row['lauter_deadspace'], | |
128 | 'top_up_kettle' => $row['top_up_kettle'], | |
129 | 'hop_utilization' => $row['hop_utilization'], | |
130 | 'notes' => $row['notes'], | |
131 | 'lauter_volume' => $row['lauter_volume'], | |
132 | 'kettle_volume' => $row['kettle_volume'], | |
133 | 'tun_material' => $row['tun_material'], | |
134 | 'tun_height' => $row['tun_height'] * 100.0, | |
135 | 'kettle_height' => $row['kettle_height'] * 100.0, | |
136 | 'lauter_height' => $row['lauter_height'] * 100.0, | |
137 | 'mash_volume' => $row['mash_volume'], | |
138 | 'efficiency' => $row['efficiency'] | |
139 | ); | |
140 | } | |
141 | echo json_encode($equipments); | |
142 | } | |
143 | ?> |