www/getbrewlog.php

Wed, 06 Dec 2023 20:26:00 +0100

author
Michiel Broek <mbroek@mbse.eu>
date
Wed, 06 Dec 2023 20:26:00 +0100
changeset 855
2d328a2a4025
parent 297
5e2424bfbc4a
permissions
-rw-r--r--

Fixed init scripts names in Makefile. Update crontasks to use the database to check the log entries for products.

294
1e09d1d102a8 Updated crontask to check for fermentation logs and update the products. Added initial brew log graph.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1 <?php
1e09d1d102a8 Updated crontask to check for fermentation logs and update the products. Added initial brew log graph.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2
1e09d1d102a8 Updated crontask to check for fermentation logs and update the products. Added initial brew log graph.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3 require_once('config.php');
1e09d1d102a8 Updated crontask to check for fermentation logs and update the products. Added initial brew log graph.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4
1e09d1d102a8 Updated crontask to check for fermentation logs and update the products. Added initial brew log graph.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5 if (isset($_GET["code"]))
1e09d1d102a8 Updated crontask to check for fermentation logs and update the products. Added initial brew log graph.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6 $code = $_GET["code"];
1e09d1d102a8 Updated crontask to check for fermentation logs and update the products. Added initial brew log graph.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7 else
1e09d1d102a8 Updated crontask to check for fermentation logs and update the products. Added initial brew log graph.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8 $code = "CB0011";
1e09d1d102a8 Updated crontask to check for fermentation logs and update the products. Added initial brew log graph.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9
1e09d1d102a8 Updated crontask to check for fermentation logs and update the products. Added initial brew log graph.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10 $connect = mysqli_connect(DBASE_HOST, DBASE_USER, DBASE_PASS, DBASE_NAME);
1e09d1d102a8 Updated crontask to check for fermentation logs and update the products. Added initial brew log graph.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11 if (! $connect) {
1e09d1d102a8 Updated crontask to check for fermentation logs and update the products. Added initial brew log graph.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12 die('Connect Error (' . mysqli_connect_errno() . ') ' . mysqli_connect_error());
1e09d1d102a8 Updated crontask to check for fermentation logs and update the products. Added initial brew log graph.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13 }
1e09d1d102a8 Updated crontask to check for fermentation logs and update the products. Added initial brew log graph.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14 mysqli_set_charset($connect, "utf8" );
1e09d1d102a8 Updated crontask to check for fermentation logs and update the products. Added initial brew log graph.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
15
297
5e2424bfbc4a Added import brew json logfiles
Michiel Broek <mbroek@mbse.eu>
parents: 296
diff changeset
16 $query = "SELECT * FROM log_brews WHERE code='".$code."' ORDER BY datetime;";
294
1e09d1d102a8 Updated crontask to check for fermentation logs and update the products. Added initial brew log graph.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
17 $result = mysqli_query($connect, $query) or die("SQL Error 1: " . mysqli_error($connect));
1e09d1d102a8 Updated crontask to check for fermentation logs and update the products. Added initial brew log graph.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
18 while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) {
1e09d1d102a8 Updated crontask to check for fermentation logs and update the products. Added initial brew log graph.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
19 $lines[] = array(
1e09d1d102a8 Updated crontask to check for fermentation logs and update the products. Added initial brew log graph.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
20 'record' => $row['record'],
1e09d1d102a8 Updated crontask to check for fermentation logs and update the products. Added initial brew log graph.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
21 'date' => substr($row['datetime'],0,16),
1e09d1d102a8 Updated crontask to check for fermentation logs and update the products. Added initial brew log graph.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
22 'version' => $row['version'],
297
5e2424bfbc4a Added import brew json logfiles
Michiel Broek <mbroek@mbse.eu>
parents: 296
diff changeset
23 'code' => $row['code'],
5e2424bfbc4a Added import brew json logfiles
Michiel Broek <mbroek@mbse.eu>
parents: 296
diff changeset
24 'name' => $row['name'],
5e2424bfbc4a Added import brew json logfiles
Michiel Broek <mbroek@mbse.eu>
parents: 296
diff changeset
25 'pv_mlt' => $row['pv_mlt'],
5e2424bfbc4a Added import brew json logfiles
Michiel Broek <mbroek@mbse.eu>
parents: 296
diff changeset
26 'pv_hlt' => $row['pv_hlt'],
5e2424bfbc4a Added import brew json logfiles
Michiel Broek <mbroek@mbse.eu>
parents: 296
diff changeset
27 'pv_room' => $row['pv_room'],
5e2424bfbc4a Added import brew json logfiles
Michiel Broek <mbroek@mbse.eu>
parents: 296
diff changeset
28 'sp_mlt' => $row['sp_mlt'],
5e2424bfbc4a Added import brew json logfiles
Michiel Broek <mbroek@mbse.eu>
parents: 296
diff changeset
29 'sp_hlt' => $row['sp_hlt'],
5e2424bfbc4a Added import brew json logfiles
Michiel Broek <mbroek@mbse.eu>
parents: 296
diff changeset
30 'pwm_mlt' => $row['pwm_mlt'],
5e2424bfbc4a Added import brew json logfiles
Michiel Broek <mbroek@mbse.eu>
parents: 296
diff changeset
31 'pwm_hlt' => $row['pwm_hlt'],
294
1e09d1d102a8 Updated crontask to check for fermentation logs and update the products. Added initial brew log graph.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
32 'event' => $row['event']
1e09d1d102a8 Updated crontask to check for fermentation logs and update the products. Added initial brew log graph.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
33 );
1e09d1d102a8 Updated crontask to check for fermentation logs and update the products. Added initial brew log graph.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
34 }
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: 294
diff changeset
35 header("Content-type: application/json");
294
1e09d1d102a8 Updated crontask to check for fermentation logs and update the products. Added initial brew log graph.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
36 echo json_encode($lines);

mercurial