diff --git a/functions/functions.php b/functions/functions.php index 942e6cc..d8c0d78 100644 --- a/functions/functions.php +++ b/functions/functions.php @@ -106,14 +106,15 @@ function get_grid_feed_by_month(mysqli $db, string $table_aggregation, string $t $price_result = $db->query($price_query); $price = []; - while ($row = $price_result->fetch_assoc()) { - $price[$row['year'] . '-' . str_pad($row['month'], 2, '0', STR_PAD_LEFT)] = $row['price']; + while ($price_row = $price_result->fetch_assoc()) { + $price[$price_row['year'] . '-' . str_pad($price_row['month'], 2, '0', STR_PAD_LEFT)] = $price_row['price']; } $grid_feed_by_month = []; - while ($row = $feed_result->fetch_assoc()) { - $grid_feed_by_month[$row['year'] . '-' . str_pad($row['month'], 2, '0', STR_PAD_LEFT)] = $row['SUM(grid_feed)'] * $price[$row['year'] . '-' . str_pad($row['month'], 2, '0', STR_PAD_LEFT)] / 100000; + $key = $row['year'] . '-' . str_pad($row['month'], 2, '0', STR_PAD_LEFT); + $price[$key] = $price[$key] ?? 0; + $grid_feed_by_month[$key] = $row['SUM(grid_feed)'] * $price[$key] / 100000; } return $grid_feed_by_month; diff --git a/public/css/layout.css b/public/css/layout.css index 6e9e6fe..4a604b0 100644 --- a/public/css/layout.css +++ b/public/css/layout.css @@ -47,6 +47,7 @@ button, .button { color: rgb(0, 0, 0); font-size: 1.3rem; padding: 8px 0; + cursor: pointer; } #chart-container { diff --git a/public/production.php b/public/production.php index ccd2832..bc93c3e 100644 --- a/public/production.php +++ b/public/production.php @@ -45,11 +45,11 @@ $chosen_date_time = new DateTime($chosen_date); Consumption values - -
+ + modify('-1 month')->format('Y-m') . "\")'><"; + echo "\n"; } else { echo ''; } @@ -66,7 +66,7 @@ $chosen_date_time = new DateTime($chosen_date);
+ style="display: grid; grid-template-columns: 20% 20% 20% 20% 20%; gap: 2px 10px; margin-top: 10px; font-size: 1.3rem; border-top: 2px solid gray; padding-top: 20px;"> diff --git a/public/year.php b/public/year.php index 8895bae..41f03e1 100644 --- a/public/year.php +++ b/public/year.php @@ -11,6 +11,10 @@ $chosen_year = (isset($_POST['year'])) ? $_POST['year'] : date('Y'); $years = get_years($local_db, $table_aggregation); $values = get_year_values($local_db, $table_aggregation, $chosen_year); +$aggregation = get_year_aggregation($local_db, $table_aggregation, $chosen_year); +$year_production = get_year_production($local_db, $table_production, $chosen_year); +$grid_feed_by_month = get_grid_feed_by_month($local_db, $table_aggregation, $table_production, $chosen_year); + ?> @@ -41,6 +45,37 @@ $values = get_year_values($local_db, $table_aggregation, $chosen_year); Werte
+ +
+ + + Jahr + + + + KWh + + + + KWh + + + + KWh + + + + KWh + + + + + + + + % +
+