From fdc2eb6c07803db3cb758fd16c1f1dc95a0f9149 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anna=20Christina=20Na=C3=9F?= Date: Tue, 15 Jul 2025 17:45:51 +0200 Subject: [PATCH] =?UTF-8?q?Datum=20vom=20ersten=20Datenpunkt=20im=20Test?= =?UTF-8?q?=20nehmen;=20Startseite=20h=C3=BCbscher?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- functions.php | 4 ++-- index.php | 2 ++ templates/index.html.twig | 9 +++++---- webhook.php | 4 +++- 4 files changed, 12 insertions(+), 7 deletions(-) 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);