sdg.matiaan
2019-05-27 09:25
<?php
ini_set('max_execution_time', 300);
// this
shows a graph of your daily cost. you need to fill in the username, password,
account number and date range
// yes
this report is slow. it is also server intensive, so you want to cache the
output so that it wont overwhelm the server
$username = 'sdg.demo';
$password = 'demo';
$account = '26336';
$start = '2017-04-01';
$end = '2017-04-10';
$curr = $start;
$chars = '';
$tag = null;
$prevDay = 0;
$profile = array();
function
startElements($parser, $name, $attrs) {
global $tag, $chars;
$tag = $name;
$chars = '';
}
function
characterData($parser, $data) {
global $chars;
$chars .= $data;
}
function
endElements($parser, $name) {
global $curr, $chars, $profile;
switch ($name)
{
case 'AMOUNT': @$profile[$curr] += $chars * 1; break;
}
}
while ($curr < $end)
{
$curr = date('Y-m-d',
strtotime($curr) + 24 * 60 * 60);
$profileData =
file_get_contents('https://sdg-adam.pnpscada.com:445/getProvisionalBill.jsp?LOGIN=' . $username . '&PWD=' . $password . '&key1=' . $account . '&startdate=' .
start . '&enddate=' . $curr . '&TGIDX=0');
$parser =
xml_parser_create();
xml_set_element_handler($parser, 'startElements', 'endElements');
xml_set_character_data_handler($parser, 'characterData');
xml_parse($parser, $profileData);
xml_parser_free($parser);
$pd = $prevDay;
$prevDay = $profile[$curr];
$profile[$curr] -= $pd;
}
?>
<script type='text/javascript'>
var data = [
<?php
$first = true;
foreach ($profile as $date => $kwh) {
if ($first) $first = false; else echo ',';
echo '['' . $date . '',' . $kwh . ']';
}
?>
];
</script>
<script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js'></script>
<script type='text/javascript' src='http://adam.pnpscada.com/lib/jquery.jqplot.min.js'></script>
<script type='text/javascript' src='http://adam.pnpscada.com/lib/plugins/jqplot.dateAxisRenderer.min.js'></script>
<link rel='stylesheet' type='text/css' href='http://adam.pnpscada.com/lib/jquery.jqplot.min.css' />
<div id='chart1'></div>
<script type='text/javascript'>
$(function() {
plot1 = $.jqplot('chart1', [data], {
axes:{
xaxis:{
renderer:$.jqplot.DateAxisRenderer
}
}
});
});
</script>
var data = [
$first = true;
foreach ($profile as $date => $kwh) {
? if ($first) $first = false; else echo ',';
? echo '['' . $date . '',' . $kwh . ']';
}
?>
];
$(function() {
? plot1 = $.jqplot('chart1', [data], {
? ? axes:{
? ? ? xaxis:{
? ? ? ? renderer:$.jqplot.DateAxisRenderer
? ? ? }
? ? }
? });
});
var data = [
$first = true;
foreach ($profile as $date => $kwh) {
? if ($first) $first = false; else echo ',';
? echo '['' . $date . '',' . $kwh . ']';
}
?>
];
$(function() {
? plot1 = $.jqplot('chart1', [data], {
? ? axes:{
? ? ? xaxis:{
? ? ? ? renderer:$.jqplot.DateAxisRenderer
? ? ? }
? ? }
? });
});
var data = [
$first = true;
foreach ($profile as $date => $kwh) {
? if ($first) $first = false; else echo ',';
? echo '['' . $date . '',' . $kwh . ']';
}
?>
];
$(function() {
? plot1 = $.jqplot('chart1', [data], {
? ? axes:{
? ? ? xaxis:{
? ? ? ? renderer:$.jqplot.DateAxisRenderer
? ? ? }
? ? }
? });
});