Adjust month view to year view.
This commit is contained in:
@@ -19,8 +19,9 @@ if (isset($_POST['action']) && $_POST['action'] == 'set_values') {
|
||||
$local_db->query($query);
|
||||
}
|
||||
|
||||
$dates = build_date_dropdown($local_db, $table_aggregation);
|
||||
$chosen_date = (isset($_POST['date'])) ? $_POST['date'] : $dates[0];
|
||||
$actual = new DateTime();
|
||||
$dates = get_month($local_db, $table_aggregation);
|
||||
$chosen_date = (isset($_POST['date'])) ? $_POST['date'] : $actual->format('Y-m');
|
||||
$data = get_aggregation($local_db, $table_aggregation, $chosen_date);
|
||||
$month_values = get_month_aggregation($local_db, $table_aggregation, $chosen_date);
|
||||
$year_values = get_year_aggregation($local_db, $table_aggregation, $chosen_date);
|
||||
@@ -29,6 +30,7 @@ $month_production = get_month_production($local_db, $table_production, $chosen_d
|
||||
$year_production = get_year_production($local_db, $table_production, $chosen_date);
|
||||
$last_value = get_last_value($local_db, $table_aggregation, $chosen_date);
|
||||
|
||||
$chosen_date_time = new DateTime($chosen_date);
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="de">
|
||||
@@ -37,19 +39,23 @@ $last_value = get_last_value($local_db, $table_aggregation, $chosen_date);
|
||||
<link rel="stylesheet" href="/css/layout.css"/>
|
||||
</head>
|
||||
<body>
|
||||
<form style="display: grid; grid-template-columns: 5% 5% 20% 5% 5%; gap: 10px;" action="/index.php" method="post">
|
||||
<label for="date">Datum</label>
|
||||
<select name="date" id="date" onchange="submit();">
|
||||
<?php
|
||||
foreach ($dates as $date) {
|
||||
$selected = ($date == $chosen_date) ? ' selected="selected"' : '';
|
||||
echo '<option value="' . $date . '"' . $selected . '>' . $date . '</option>';
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
<span></span>
|
||||
<a class="button" href="production.php">Werte setzen</a>
|
||||
<a class="button" href="year.php">Jahresübersicht</a>
|
||||
<form id="date_form" style="align-self: center; width: 500px; display: grid; grid-template-columns: 20% 20% 20% 20% 20%; gap: 10px;" action="/index.php" method="post">
|
||||
<?php
|
||||
if ($dates['first'] < $chosen_date_time) {
|
||||
echo "<button type='button' onclick='submit_form(\"" . $chosen_date_time->modify('-1 month')->format('Y-m') . "\")'><</button>";
|
||||
} else {
|
||||
echo '<span></span>';
|
||||
}
|
||||
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')) {
|
||||
echo "<button type='button' onclick='submit_form(\"" . $chosen_date_time->format('Y-m') . "\")'>></button>";
|
||||
} else {
|
||||
echo '<span></span>';
|
||||
}
|
||||
?>
|
||||
<a class="button" href="year.php">Jahr</a>
|
||||
<a class="button" href="production.php">Werte</a>
|
||||
<input type="hidden" name="date" id="date" value=""/>
|
||||
</form>
|
||||
|
||||
<div style="display: grid; grid-template-columns: 5% 15% 15% 15% 15% 15% 15%; gap: 2px 10px; margin-top: 5px; border-top: 2px solid gray; padding-top: 5px;">
|
||||
@@ -120,6 +126,12 @@ $last_value = get_last_value($local_db, $table_aggregation, $chosen_date);
|
||||
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/4.4.1/chart.umd.js"></script>
|
||||
<script>
|
||||
function submit_form(value) {
|
||||
document.getElementById('date').value = value;
|
||||
document.getElementById('date_form').submit();
|
||||
}
|
||||
|
||||
|
||||
const chart = document.getElementById('chart');
|
||||
|
||||
new Chart(chart, {
|
||||
|
||||
Reference in New Issue
Block a user