diff --git a/functions.php b/functions.php index 8491809..7b84b80 100644 --- a/functions.php +++ b/functions.php @@ -1,7 +1,7 @@ 'success', 'message' => 'OK']); +function return_success($msg = 'OK') { + return json_encode(['status' => 'success', 'message' => $msg]); } function return_error($code, $msg) { diff --git a/index.php b/index.php index c5aac2e..013f405 100644 --- a/index.php +++ b/index.php @@ -10,6 +10,8 @@ use Twig\Loader\FilesystemLoader; $loader = new FilesystemLoader(__DIR__ . '/templates'); $twig = new Environment($loader); +setlocale(LC_ALL, 'de-DE'); + // -------------- $dbconn = pg_connect($dbconnstring) diff --git a/templates/index.html.twig b/templates/index.html.twig index 8a0caef..9c743fa 100644 --- a/templates/index.html.twig +++ b/templates/index.html.twig @@ -5,17 +5,18 @@ {% block content %} {% if tests is not empty %} -
Test auswählen:
- +

Test auswählen:

+ +
{% for test in tests %} - + {% endfor %}
{{ test.timestamp }}
{{ test.timestamp | date('D j. M Y, H:i:s') }}
{% else %}
-
Keine Tests gefunden.
+
Keine Tests gefunden.
{% endif %} diff --git a/webhook.php b/webhook.php index 4d15651..d0b41dc 100644 --- a/webhook.php +++ b/webhook.php @@ -63,7 +63,9 @@ function test_finished() { or die(return_error(500, 'connect Datenbankfehler: ' . pg_last_error())); $query = "INSERT INTO tests VALUES (DEFAULT, $1, $2) RETURNING id"; - $values = [ date('Y-m-d H:i:s'), json_encode($data) ]; + + $date = $data['test']['data']['temperatureSamples'][0]['time']; + $values = [ $date, json_encode($data) ]; $rc = pg_query_params($dbconn, $query, $values);