Adjust production view to existing views and fix typo in month view.

This commit is contained in:
2025-03-31 09:41:50 +02:00
parent 5e2d693345
commit 94c012cd70
3 changed files with 33 additions and 18 deletions

View File

@@ -1,10 +1,11 @@
body { body {
font-family: sans-serif; font-family: sans-serif;
font-size: 1.3rem;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
} }
input[type="number"] { input {
font-size: 1.3rem; font-size: 1.3rem;
} }
@@ -38,12 +39,14 @@ form > div {
flex-direction: row; flex-direction: row;
} }
.button { button, .button {
text-align: center; text-align: center;
background-color: rgb(239, 239, 239); background-color: rgb(239, 239, 239);
border: 2px outset rgb(0, 0 , 0); border: 2px outset rgb(0, 0 , 0);
text-decoration: none; text-decoration: none;
color: rgb(0, 0, 0); color: rgb(0, 0, 0);
font-size: 1.3rem;
padding: 8px 0;
} }
#chart-container { #chart-container {

View File

@@ -92,7 +92,7 @@ $chosen_date_time = new DateTime($chosen_date);
<span><?php echo number_format($data['avg_feed'] / 1000, 1, ',', '.'); ?> KWh</span> <span><?php echo number_format($data['avg_feed'] / 1000, 1, ',', '.'); ?> KWh</span>
<span class="color color-4"></span> <span class="color color-4"></span>
<label>Produktion OG</label> <label>Produktion</label>
<span><?php echo number_format($month_production['eg'] + $month_production['og'], 1, ',', '.'); ?> KWh</span> <span><?php echo number_format($month_production['eg'] + $month_production['og'], 1, ',', '.'); ?> KWh</span>
<span><?php echo number_format($year_production['eg'] + $year_production['og'], 1, ',', '.'); ?> KWh</span> <span><?php echo number_format($year_production['eg'] + $year_production['og'], 1, ',', '.'); ?> KWh</span>
<span><?php echo number_format($data['min_production'] / 1000, 1, ',', '.'); ?> KWh</span> <span><?php echo number_format($data['min_production'] / 1000, 1, ',', '.'); ?> KWh</span>

View File

@@ -30,11 +30,13 @@ if (isset($_POST['action']) && $_POST['action'] == 'set_values') {
$local_db->query($query); $local_db->query($query);
} }
$dates = build_date_dropdown($local_db, $table_aggregation); $dates = get_month($local_db, $table_aggregation);
$chosen_date = (isset($_POST['date'])) ? $_POST['date'] : $dates[0]; $chosen_date = (isset($_POST['date'])) ? $_POST['date'] : $dates[0];
$production_values = get_production_values_for_month($local_db, $table_aggregation, $chosen_date); $production_values = get_production_values_for_month($local_db, $table_aggregation, $chosen_date);
$month_production = get_month_production($local_db, $table_production, $chosen_date); $month_production = get_month_production($local_db, $table_production, $chosen_date);
$chosen_date_time = new DateTime($chosen_date);
?> ?>
<!DOCTYPE html> <!DOCTYPE html>
<html lang="de"> <html lang="de">
@@ -43,23 +45,27 @@ $month_production = get_month_production($local_db, $table_production, $chosen_d
<link rel="stylesheet" href="/css/layout.css"/> <link rel="stylesheet" href="/css/layout.css"/>
</head> </head>
<body> <body>
<form style="display: grid; grid-template-columns: 5% 5% 5% 5% 5%; gap: 10px; border-bottom: 1px solid black;" action="/production.php" method="post"> <form id="date_form" style="align-self: center; width: 500px; display: grid; grid-template-columns: 20% 20% 20% 20% 20%; gap: 10px;" action="/production.php" method="post">
<label for="date">Datum</label> <?php
<select name="date" id="date" onchange="submit();"> if ($dates['first'] < $chosen_date_time) {
<?php echo "<button type='button' onclick='submit_form(\"" . $chosen_date_time->modify('-1 month')->format('Y-m') . "\")'><</button>";
foreach ($dates as $date) { } else {
$selected = ($date == $chosen_date) ? ' selected="selected"' : ''; echo '<span></span>';
echo '<option value="' . $date . '"' . $selected . '>' . $date . '</option>'; }
} echo '<span style="text-align: center">' . $chosen_date_time->modify('+1 month')->format('Y-m') . '</span>';
?> if ($dates['last'] > $chosen_date_time->modify('+1 month')) {
</select> echo "<button type='button' onclick='submit_form(\"" . $chosen_date_time->format('Y-m') . "\")'>></button>";
<span></span> } else {
<span></span> echo '<span></span>';
<a class="button" href="index.php">Übersicht</a> }
?>
<a class="button" href="index.php">Monat</a>
<a class="button" href="year.php">Jahr</a>
<input type="hidden" name="date" id="date" value=""/>
</form> </form>
<form action="production.php" method="post" <form action="production.php" method="post"
style="display: grid; grid-template-columns: 5% 5% 5% 5% 5%; gap: 2px 10px; margin-top: 10px; font-size: 1.3rem;"> style="display: grid; grid-template-columns: 15% 12% 10% 10% 12%; gap: 2px 10px; margin-top: 10px; font-size: 1.3rem;">
<?php <?php
foreach ($production_values as $daily_production) { foreach ($production_values as $daily_production) {
?> ?>
@@ -83,6 +89,12 @@ $month_production = get_month_production($local_db, $table_production, $chosen_d
<input type="hidden" name="action" value="set_values"/> <input type="hidden" name="action" value="set_values"/>
<input type="hidden" name="date" value="<?php echo $chosen_date; ?>"/> <input type="hidden" name="date" value="<?php echo $chosen_date; ?>"/>
</form> </form>
<script>
function submit_form(value) {
document.getElementById('date').value = value;
document.getElementById('date_form').submit();
}
</script>
</body> </body>
</html> </html>