Add last meter consumption value.
This commit is contained in:
@@ -110,3 +110,12 @@ function get_year_production(mysqli $db, string $table, $date): array
|
|||||||
|
|
||||||
return $sum_result->fetch_assoc();
|
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;
|
||||||
|
}
|
||||||
@@ -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);
|
$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);
|
$month_production = get_month_production($local_db, $table_production, $chosen_date);
|
||||||
$year_production = get_year_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'];
|
$colors = ['#375BEB', '#90EB36', '#EB5F36', '#DAE32D'];
|
||||||
|
|
||||||
@@ -178,6 +179,12 @@ $colors = ['#375BEB', '#90EB36', '#EB5F36', '#DAE32D'];
|
|||||||
<span><b><?php echo number_format(100 - $year_values['grid_feed'] * 100 / ($year_production['eg'] + $year_production['og']), 2, ',', '.'); ?> %</b></span>
|
<span><b><?php echo number_format(100 - $year_values['grid_feed'] * 100 / ($year_production['eg'] + $year_production['og']), 2, ',', '.'); ?> %</b></span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<span class="color"></span>
|
||||||
|
<label><b>Letzter Zählerstand</b></label>
|
||||||
|
<span><b><?php echo number_format($last_value, 3, ',', '.'); ?> %</b></span>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div id="chart-container">
|
<div id="chart-container">
|
||||||
<canvas id="chart"></canvas>
|
<canvas id="chart"></canvas>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user