<?php
// - acinfo.php
session_start();
ini_set('display_errors', 1);
error_reporting(E_ALL);
require_once "main.php";
Logger::configure('log4php.xml');
$log = Logger::getLogger('acinfo');
global $db, $defaultHomeLink;
$comz = $_SESSION['comnum'];
$x[0] = 0;
$y[0] = 0;
?>
<script src="https://cdn.plot.ly/plotly-latest.min.js"></script>
<div id="tester" style="width:400px;height:250px;"></div>
<?PHP
$result = bill_get_readings($comz, $_GET['id']);
if (count($result)>0) {
    for ($i=0;$i<count($result);$i++) {
        $x[$i] = $result[$i]['timestamp'];
        $y[$i+1] = (floatval(@$result[$i]['meterread']) - @floatval($result[$i-1]['meterread']));
    }
echo '<script>
    TESTER = document.getElementById("tester");
    Plotly.newPlot( TESTER, [{ x: ["' . implode('", "',$x) . '"], y: ["' . implode('", "',$y) .
     '" ]}], {
    margin: { t: 20 }},
    {displayModeBar: false} );
</script>';

} else echo 'NO DATA FOR THIS ACCOUNT';
?>
