diff --git a/functions/functions.php b/functions/functions.php index 4ca9109..8523ed2 100644 --- a/functions/functions.php +++ b/functions/functions.php @@ -109,4 +109,13 @@ function get_year_production(mysqli $db, string $table, $date): array $sum_result = $db->query($sum_query); return $sum_result->fetch_assoc(); +} + +function get_last_value(mysqli $db, string $table, $date): float +{ + $value_query = 'SELECT last_value FROM ' . $table . ' WHERE date LIKE "' . $date . '%" ORDER BY date DESC LIMIT 1;'; + $value_result = $db->query($value_query); + $data = $value_result->fetch_assoc(); + + return floatval($data['last_value']) / 1000; } \ No newline at end of file diff --git a/public/index.php b/public/index.php index 5641bc1..7f726d7 100644 --- a/public/index.php +++ b/public/index.php @@ -27,6 +27,7 @@ $year_values = get_year_aggregation($local_db, $table_aggregation, $chosen_date) $grid_feed_by_month = get_grid_feed_by_month($local_db, $table_aggregation, $table_production, $chosen_date); $month_production = get_month_production($local_db, $table_production, $chosen_date); $year_production = get_year_production($local_db, $table_production, $chosen_date); +$last_value = get_last_value($local_db, $table_aggregation, $chosen_date); $colors = ['#375BEB', '#90EB36', '#EB5F36', '#DAE32D']; @@ -178,6 +179,12 @@ $colors = ['#375BEB', '#90EB36', '#EB5F36', '#DAE32D']; % +