mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Fix coding style part 2
This commit is contained in:
@@ -1,8 +1,7 @@
|
||||
<?php
|
||||
|
||||
if ($_POST['action'] == 'delete_bill' && $_POST['confirm'] == 'confirm') {
|
||||
foreach (dbFetchRows('SELECT * FROM `bill_ports` WHERE `bill_id` = ?', array($bill_id)) as $port_data)
|
||||
{
|
||||
foreach (dbFetchRows('SELECT * FROM `bill_ports` WHERE `bill_id` = ?', array($bill_id)) as $port_data) {
|
||||
dbDelete('port_in_measurements', '`port_id` = ?', array($port_data['bill_id']));
|
||||
dbDelete('port_out_measurements', '`port_id` = ?', array($port_data['bill_id']));
|
||||
}
|
||||
|
@@ -1,47 +1,82 @@
|
||||
<?php
|
||||
|
||||
include("includes/javascript-interfacepicker.inc.php");
|
||||
require 'includes/javascript-interfacepicker.inc.php';
|
||||
|
||||
// This needs more verification. Is it already added? Does it exist?
|
||||
|
||||
// Calculation to extract MB/GB/TB of Kbps/Mbps/Gbps
|
||||
$base = $config['billing']['base'];
|
||||
|
||||
$base = $config["billing"]["base"];
|
||||
if ($bill_data['bill_type'] == 'quota') {
|
||||
$data = $bill_data['bill_quota'];
|
||||
$tmp['mb'] = ($data / $base / $base);
|
||||
$tmp['gb'] = ($data / $base / $base / $base);
|
||||
$tmp['tb'] = ($data / $base / $base / $base / $base);
|
||||
if ($tmp['tb'] >= 1) {
|
||||
$quota = array(
|
||||
'type' => 'tb',
|
||||
'select_tb' => ' selected',
|
||||
'data' => $tmp['tb'],
|
||||
);
|
||||
}
|
||||
else if (($tmp['gb'] >= 1) and ($tmp['gb'] < $base)) {
|
||||
$quota = array(
|
||||
'type' => 'gb',
|
||||
'select_gb' => ' selected',
|
||||
'data' => $tmp['gb'],
|
||||
);
|
||||
}
|
||||
else if (($tmp['mb'] >= 1) and ($tmp['mb'] < $base)) {
|
||||
$quota = array(
|
||||
'type' => 'mb',
|
||||
'select_mb' => ' selected',
|
||||
'data' => $tmp['mb'],
|
||||
);
|
||||
}
|
||||
}//end if
|
||||
|
||||
if ($bill_data['bill_type'] == "quota") {
|
||||
$data = $bill_data['bill_quota'];
|
||||
$tmp['mb'] = $data / $base / $base;
|
||||
$tmp['gb'] = $data / $base / $base / $base;
|
||||
$tmp['tb'] = $data / $base / $base / $base / $base;
|
||||
if ($tmp['tb']>=1) { $quota = array("type" => "tb", "select_tb" => " selected", "data" => $tmp['tb']); }
|
||||
elseif (($tmp['gb']>=1) and ($tmp['gb']<$base)) { $quota = array("type" => "gb", "select_gb" => " selected", "data" => $tmp['gb']); }
|
||||
elseif (($tmp['mb']>=1) and ($tmp['mb']<$base)) { $quota = array("type" => "mb", "select_mb" => " selected", "data" => $tmp['mb']); }
|
||||
}
|
||||
if ($bill_data['bill_type'] == "cdr") {
|
||||
$data = $bill_data['bill_cdr'];
|
||||
$tmp['kbps'] = $data / $base;
|
||||
$tmp['mbps'] = $data / $base / $base;
|
||||
$tmp['gbps'] = $data / $base / $base / $base;
|
||||
if ($tmp['gbps']>=1) { $cdr = array("type" => "gbps", "select_gbps" => " selected", "data" => $tmp['gbps']); }
|
||||
elseif (($tmp['mbps']>=1) and ($tmp['mbps']<$base)) { $cdr = array("type" => "mbps", "select_mbps" => " selected", "data" => $tmp['mbps']); }
|
||||
elseif (($tmp['kbps']>=1) and ($tmp['kbps']<$base)) { $cdr = array("type" => "kbps", "select_kbps" => " selected", "data" => $tmp['kbps']); }
|
||||
}
|
||||
if ($bill_data['bill_type'] == 'cdr') {
|
||||
$data = $bill_data['bill_cdr'];
|
||||
$tmp['kbps'] = ($data / $base);
|
||||
$tmp['mbps'] = ($data / $base / $base);
|
||||
$tmp['gbps'] = ($data / $base / $base / $base);
|
||||
if ($tmp['gbps'] >= 1) {
|
||||
$cdr = array(
|
||||
'type' => 'gbps',
|
||||
'select_gbps' => ' selected',
|
||||
'data' => $tmp['gbps'],
|
||||
);
|
||||
}
|
||||
else if (($tmp['mbps'] >= 1) and ($tmp['mbps'] < $base)) {
|
||||
$cdr = array(
|
||||
'type' => 'mbps',
|
||||
'select_mbps' => ' selected',
|
||||
'data' => $tmp['mbps'],
|
||||
);
|
||||
}
|
||||
else if (($tmp['kbps'] >= 1) and ($tmp['kbps'] < $base)) {
|
||||
$cdr = array(
|
||||
'type' => 'kbps',
|
||||
'select_kbps' => ' selected',
|
||||
'data' => $tmp['kbps'],
|
||||
);
|
||||
}
|
||||
}//end if
|
||||
|
||||
?>
|
||||
|
||||
<form id="edit" name="edit" method="post" action="" class="form-horizontal" role="form">
|
||||
<input type=hidden name="action" value="update_bill">
|
||||
<script type="text/javascript">
|
||||
function billType() {
|
||||
$('#cdrDiv').toggle();
|
||||
$('#quotaDiv').toggle();
|
||||
}
|
||||
</script>
|
||||
<script type="text/javascript">
|
||||
function billType() {
|
||||
$('#cdrDiv').toggle();
|
||||
$('#quotaDiv').toggle();
|
||||
}
|
||||
</script>
|
||||
<h3>Bill Properties</h3>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-2 control-label" for="bill_name"><strong>Description</strong></label>
|
||||
<div class="col-sm-4">
|
||||
<input class="form-control input-sm" name="bill_name" value="<?php echo $bill_data["bill_name"]; ?>" />
|
||||
<input class="form-control input-sm" name="bill_name" value="<?php echo $bill_data['bill_name']; ?>" />
|
||||
</div>
|
||||
<div class="col-sm-6">
|
||||
</div>
|
||||
@@ -51,17 +86,35 @@ if ($bill_data['bill_type'] == "cdr") {
|
||||
<div class="col-sm-10">
|
||||
<div class="radio">
|
||||
<label>
|
||||
<input type="radio" name="bill_type" value="cdr" onchange="javascript: billType();" <?php if ($bill_data['bill_type'] == "cdr") { echo('checked '); } ?>/> CDR 95th
|
||||
<input type="radio" name="bill_type" value="cdr" onchange="javascript: billType();"
|
||||
<?php
|
||||
if ($bill_data['bill_type'] == 'cdr') {
|
||||
echo 'checked ';
|
||||
};
|
||||
?>
|
||||
/> CDR 95th
|
||||
</label>
|
||||
</div>
|
||||
<div class="radio">
|
||||
<label>
|
||||
<input type="radio" name="bill_type" value="quota" onchange="javascript: billType();" <?php if ($bill_data['bill_type'] == "quota") { echo('checked '); } ?>/> Quota
|
||||
<input type="radio" name="bill_type" value="quota" onchange="javascript: billType();"
|
||||
<?php
|
||||
if ($bill_data['bill_type'] == 'quota') {
|
||||
echo 'checked ';
|
||||
};
|
||||
?>
|
||||
/> Quota
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="cdrDiv"<?php if ($bill_data['bill_type'] == "quota") { echo(' style="display: none"'); } ?>>
|
||||
<div id="cdrDiv"
|
||||
<?php
|
||||
if ($bill_data['bill_type'] == 'quota') {
|
||||
echo ' style="display: none"';
|
||||
};
|
||||
?>
|
||||
>
|
||||
<div class="form-group">
|
||||
<div class="col-sm-2">
|
||||
</div>
|
||||
@@ -79,7 +132,13 @@ if ($bill_data['bill_type'] == "cdr") {
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="quotaDiv"<?php if ($bill_data['bill_type'] == "cdr") { echo(' style="display: none"'); } ?>>
|
||||
<div id="quotaDiv"
|
||||
<?php
|
||||
if ($bill_data['bill_type'] == 'cdr') {
|
||||
echo ' style="display: none"';
|
||||
};
|
||||
?>
|
||||
>
|
||||
<div class="form-group">
|
||||
<div class="col-sm-2">
|
||||
</div>
|
||||
@@ -102,10 +161,9 @@ if ($bill_data['bill_type'] == "cdr") {
|
||||
<div class="col-sm-2">
|
||||
<select name="bill_day" class="form-control input">
|
||||
<?php
|
||||
|
||||
for ($x=1;$x<32;$x++) {
|
||||
$select = (($bill_data['bill_day'] == $x) ? " selected" : "");
|
||||
echo(" <option value=\"".$x."\"".$select.">".$x."</option>\n");
|
||||
for ($x = 1; $x < 32; $x++) {
|
||||
$select = (($bill_data['bill_day'] == $x) ? ' selected' : '');
|
||||
echo ' <option value="'.$x.'"'.$select.'>'.$x."</option>\n";
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -141,50 +199,50 @@ for ($x=1;$x<32;$x++) {
|
||||
<h3>Billed Ports</h3>
|
||||
<div class="form-group">
|
||||
<?php
|
||||
$ports = dbFetchRows(
|
||||
'SELECT * FROM `bill_ports` AS B, `ports` AS P, `devices` AS D
|
||||
WHERE B.bill_id = ? AND P.port_id = B.port_id
|
||||
AND D.device_id = P.device_id ORDER BY D.device_id',
|
||||
array($bill_data['bill_id'])
|
||||
);
|
||||
|
||||
$ports = dbFetchRows("SELECT * FROM `bill_ports` AS B, `ports` AS P, `devices` AS D
|
||||
WHERE B.bill_id = ? AND P.port_id = B.port_id
|
||||
AND D.device_id = P.device_id ORDER BY D.device_id", array($bill_data['bill_id']));
|
||||
|
||||
if (is_array($ports))
|
||||
{
|
||||
foreach ($ports as $port)
|
||||
{
|
||||
$emptyCheck = true;
|
||||
$devicebtn = str_replace("list-device", "btn", generate_device_link($port));
|
||||
$devicebtn = str_replace("overlib('", "overlib('<div style=\'border: 5px solid #e5e5e5; background: #fff; padding: 10px;\'>", $devicebtn);
|
||||
$devicebtn = str_replace("<div>',;", "</div></div>',", $devicebtn);
|
||||
$portbtn = str_replace("interface-upup", "btn", generate_port_link($port));
|
||||
$portbtn = str_replace("interface-updown", "btn btn-warning", $portbtn);
|
||||
$portbtn = str_replace("interface-downdown", "btn btn-warning", $portbtn);
|
||||
$portbtn = str_replace("interface-admindown", "btn btn-warning disabled", $portbtn);
|
||||
$portbtn = str_replace("overlib('", "overlib('<div style=\'border: 5px solid #e5e5e5; background: #fff; padding: 10px;\'>", $portbtn);
|
||||
$portbtn = str_replace("<div>',;", "</div></div>',", $portbtn);
|
||||
$portalias = (empty($port['ifAlias']) ? "" : " - ".$port['ifAlias']."");
|
||||
$devicebtn = str_replace("\">".$port['hostname'], "\" style=\"color: #000;\"><i class=\"glyphicon glyphicon-asterisk\"></i> ".$port['hostname'], $devicebtn);
|
||||
$portbtn = str_replace("\">".strtolower($port['ifName']), "\" style=\"color: #000;\"><i class=\"glyphicon glyphicon-random\"></i> ".$port['ifName']."".$portalias, $portbtn);
|
||||
echo(" <form action=\"\" class=\"form-inline\" method=\"post\" name=\"delete".$port['port_id']."\" style=\"display: none;\">\n");
|
||||
echo(" <input type=\"hidden\" name=\"action\" value=\"delete_bill_port\" />\n");
|
||||
echo(" <input type=\"hidden\" name=\"port_id\" value=\"".$port['port_id']."\" />\n");
|
||||
echo(" </form>\n");
|
||||
echo(" <div class=\"btn-toolbar\">\n");
|
||||
echo(" <div class=\"btn-group\" style=\"width: 600px;\">\n");
|
||||
//echo(" <a class=\"btn btn-danger\" href=\"javascript:;\" onclick=\"document.delete".$port['port_id'].".submit();\" style=\"color: #fff;\"><i class=\"icon-trash icon-white\"></i></a>\n");
|
||||
echo(" ".$devicebtn."\n");
|
||||
echo(" ".$portbtn."\n");
|
||||
echo(" </div>\n");
|
||||
echo(" <div class=\"btn-group\">\n");
|
||||
echo(" <a class=\"btn btn-danger btn-mini\" href=\"javascript:;\" onclick=\"document.delete".$port['port_id'].".submit();\" style=\"color: #fff;\"><i class=\"icon-minus-sign icon-white\"></i> <strong>Remove Interface</strong></a>\n");
|
||||
echo(" </div>\n");
|
||||
echo(" </div>\n");
|
||||
}
|
||||
if (!$emptyCheck) {
|
||||
echo(" <div class=\"alert alert-info\">\n");
|
||||
echo(" <i class=\"icon-info-sign\"></i> <strong>There are no ports assigned to this bill</strong>\n");
|
||||
echo(" </div>\n");
|
||||
}
|
||||
}
|
||||
if (is_array($ports)) {
|
||||
foreach ($ports as $port) {
|
||||
$emptyCheck = true;
|
||||
$devicebtn = str_replace('list-device', 'btn', generate_device_link($port));
|
||||
$devicebtn = str_replace("overlib('", "overlib('<div style=\'border: 5px solid #e5e5e5; background: #fff; padding: 10px;\'>", $devicebtn);
|
||||
$devicebtn = str_replace("<div>',;", "</div></div>',", $devicebtn);
|
||||
$portbtn = str_replace('interface-upup', 'btn', generate_port_link($port));
|
||||
$portbtn = str_replace('interface-updown', 'btn btn-warning', $portbtn);
|
||||
$portbtn = str_replace('interface-downdown', 'btn btn-warning', $portbtn);
|
||||
$portbtn = str_replace('interface-admindown', 'btn btn-warning disabled', $portbtn);
|
||||
$portbtn = str_replace("overlib('", "overlib('<div style=\'border: 5px solid #e5e5e5; background: #fff; padding: 10px;\'>", $portbtn);
|
||||
$portbtn = str_replace("<div>',;", "</div></div>',", $portbtn);
|
||||
$portalias = (empty($port['ifAlias']) ? '' : ' - '.$port['ifAlias'].'');
|
||||
$devicebtn = str_replace('">'.$port['hostname'], '" style="color: #000;"><i class="glyphicon glyphicon-asterisk"></i> '.$port['hostname'], $devicebtn);
|
||||
$portbtn = str_replace('">'.strtolower($port['ifName']), '" style="color: #000;"><i class="glyphicon glyphicon-random"></i> '.$port['ifName'].''.$portalias, $portbtn);
|
||||
echo ' <form action="" class="form-inline" method="post" name="delete'.$port['port_id']."\" style=\"display: none;\">\n";
|
||||
echo " <input type=\"hidden\" name=\"action\" value=\"delete_bill_port\" />\n";
|
||||
echo ' <input type="hidden" name="port_id" value="'.$port['port_id']."\" />\n";
|
||||
echo " </form>\n";
|
||||
echo " <div class=\"btn-toolbar\">\n";
|
||||
echo " <div class=\"btn-group\" style=\"width: 600px;\">\n";
|
||||
// echo(" <a class=\"btn btn-danger\" href=\"javascript:;\" onclick=\"document.delete".$port['port_id'].".submit();\" style=\"color: #fff;\"><i class=\"icon-trash icon-white\"></i></a>\n");
|
||||
echo ' '.$devicebtn."\n";
|
||||
echo ' '.$portbtn."\n";
|
||||
echo " </div>\n";
|
||||
echo " <div class=\"btn-group\">\n";
|
||||
echo ' <a class="btn btn-danger btn-mini" href="javascript:;" onclick="document.delete'.$port['port_id'].".submit();\" style=\"color: #fff;\"><i class=\"icon-minus-sign icon-white\"></i> <strong>Remove Interface</strong></a>\n";
|
||||
echo " </div>\n";
|
||||
echo " </div>\n";
|
||||
}//end foreach
|
||||
|
||||
if (!$emptyCheck) {
|
||||
echo " <div class=\"alert alert-info\">\n";
|
||||
echo " <i class=\"icon-info-sign\"></i> <strong>There are no ports assigned to this bill</strong>\n";
|
||||
echo " </div>\n";
|
||||
}
|
||||
}//end if
|
||||
?>
|
||||
</div>
|
||||
</fieldset>
|
||||
@@ -198,13 +256,18 @@ if (is_array($ports))
|
||||
<select class="form-control input-sm" id="device" name="device" onchange="getInterfaceList(this)">
|
||||
<option value=''>Select a device</option>
|
||||
<?php
|
||||
$devices = dbFetchRows('SELECT * FROM `devices` ORDER BY hostname');
|
||||
foreach ($devices as $device) {
|
||||
unset($done);
|
||||
foreach ($access_list as $ac) {
|
||||
if ($ac == $device['device_id']) {
|
||||
$done = 1;
|
||||
}
|
||||
}
|
||||
|
||||
$devices = dbFetchRows("SELECT * FROM `devices` ORDER BY hostname");
|
||||
foreach ($devices as $device)
|
||||
{
|
||||
unset($done);
|
||||
foreach ($access_list as $ac) { if ($ac == $device['device_id']) { $done = 1; } }
|
||||
if (!$done) { echo(" <option value='" . $device['device_id'] . "'>" . $device['hostname'] . "</option>\n"); }
|
||||
if (!$done) {
|
||||
echo " <option value='".$device['device_id']."'>".$device['hostname']."</option>\n";
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
@@ -1,130 +1,131 @@
|
||||
<?php
|
||||
|
||||
$pagetitle[] = "Historical Usage";
|
||||
// $detail = (isset($vars['detail']) ? $vars['detail'] : "");
|
||||
// $url = $PHP_SELF."/bill/".$bill_id."/history/";
|
||||
$i = 0;
|
||||
$pagetitle[] = 'Historical Usage';
|
||||
// $detail = (isset($vars['detail']) ? $vars['detail'] : "");
|
||||
// $url = $PHP_SELF."/bill/".$bill_id."/history/";
|
||||
$i = 0;
|
||||
|
||||
$img['his'] = "<img src=\"bandwidth-graph.php?bill_id=".$bill_id;
|
||||
$img['his'] .= "&type=historical";
|
||||
$img['his'] .= "&x=1190&y=250";
|
||||
$img['his'] .= "\" style=\"margin: 15px 5px 25px 5px;\" />";
|
||||
$img['his'] = '<img src="bandwidth-graph.php?bill_id='.$bill_id;
|
||||
$img['his'] .= '&type=historical';
|
||||
$img['his'] .= '&x=1190&y=250';
|
||||
$img['his'] .= '" style="margin: 15px 5px 25px 5px;" />';
|
||||
|
||||
echo($img['his']);
|
||||
echo $img['his'];
|
||||
|
||||
function showDetails($bill_id, $imgtype, $from, $to, $bittype = "Quota")
|
||||
{
|
||||
if ($imgtype == "bitrate") {
|
||||
$res = "<img src=\"billing-graph.php?bill_id=".$bill_id;
|
||||
if ($bittype == "Quota")
|
||||
{
|
||||
$res .= "&ave=yes";
|
||||
}
|
||||
elseif ($bittype == "CDR") {
|
||||
$res .= "&95th=yes";
|
||||
}
|
||||
} else
|
||||
{
|
||||
$res = "<img src=\"bandwidth-graph.php?bill_id=".$bill_id;
|
||||
|
||||
function showDetails($bill_id, $imgtype, $from, $to, $bittype='Quota') {
|
||||
if ($imgtype == 'bitrate') {
|
||||
$res = '<img src="billing-graph.php?bill_id='.$bill_id;
|
||||
if ($bittype == 'Quota') {
|
||||
$res .= '&ave=yes';
|
||||
}
|
||||
else if ($bittype == 'CDR') {
|
||||
$res .= '&95th=yes';
|
||||
}
|
||||
}
|
||||
//$res .= "&type=".$type;
|
||||
$res .= "&type=".$imgtype;
|
||||
$res .= "&x=1190&y=250";
|
||||
$res .= "&from=".$from."&to=".$to;
|
||||
$res .= "\" style=\"margin: 15px 5px 25px 5px;\" />";
|
||||
else {
|
||||
$res = '<img src="bandwidth-graph.php?bill_id='.$bill_id;
|
||||
}
|
||||
|
||||
// $res .= "&type=".$type;
|
||||
$res .= '&type='.$imgtype;
|
||||
$res .= '&x=1190&y=250';
|
||||
$res .= '&from='.$from.'&to='.$to;
|
||||
$res .= '" style="margin: 15px 5px 25px 5px;" />';
|
||||
return $res;
|
||||
}
|
||||
|
||||
// $url = generate_url($vars, array('detail' => 'yes'));
|
||||
$url = $PHP_SELF."/bill/".$bill_id."/history/detail=all/";
|
||||
}//end showDetails()
|
||||
|
||||
echo("<table border=0 cellspacing=0 cellpadding=5 class=devicetable width=100%>
|
||||
<tr style=\"font-weight: bold; \">
|
||||
<td width=\"7\"></td>
|
||||
<td width=\"250\">Period</td>
|
||||
<td>Type</td>
|
||||
<td>Allowed</td>
|
||||
<td>Inbound</td>
|
||||
<td>Outbound</td>
|
||||
<td>Total</td>
|
||||
<td>95th %ile</td>
|
||||
<td style=\"text-align: center;\">Overusage</td>
|
||||
<td colspan=\"2\" style=\"text-align: right;\"><a href=\"".generate_url($vars, array('detail' => "all"))."\"><img src=\"images/16/chart_curve.png\" border=\"0\" align=\"absmiddle\" alt=\"Show details\" title=\"Show details\" /> Show all details</a></td>
|
||||
</tr>");
|
||||
|
||||
foreach (dbFetchRows("SELECT * FROM `bill_history` WHERE `bill_id` = ? ORDER BY `bill_datefrom` DESC LIMIT 24", array($bill_id)) as $history)
|
||||
{
|
||||
if (bill_permitted($history['bill_id']))
|
||||
{
|
||||
unset($class);
|
||||
$datefrom = $history['bill_datefrom'];
|
||||
$dateto = $history['bill_dateto'];
|
||||
$type = $history['bill_type'];
|
||||
$percent = $history['bill_percent'];
|
||||
$dir_95th = $history['dir_95th'];
|
||||
$rate_95th = formatRates($history['rate_95th']);
|
||||
$total_data = format_number($history['traf_total'], $config['billing']['base']);
|
||||
// $url = generate_url($vars, array('detail' => 'yes'));
|
||||
$url = $PHP_SELF.'/bill/'.$bill_id.'/history/detail=all/';
|
||||
|
||||
$background = get_percentage_colours($percent);
|
||||
$row_colour = ((!is_integer($i/2)) ? $list_colour_a : $list_colour_b);
|
||||
echo '<table border=0 cellspacing=0 cellpadding=5 class=devicetable width=100%>
|
||||
<tr style="font-weight: bold; ">
|
||||
<td width="7"></td>
|
||||
<td width="250">Period</td>
|
||||
<td>Type</td>
|
||||
<td>Allowed</td>
|
||||
<td>Inbound</td>
|
||||
<td>Outbound</td>
|
||||
<td>Total</td>
|
||||
<td>95th %ile</td>
|
||||
<td style="text-align: center;">Overusage</td>
|
||||
<td colspan="2" style="text-align: right;"><a href="'.generate_url($vars, array('detail' => 'all')).'">
|
||||
<img src="images/16/chart_curve.png" border="0" align="absmiddle" alt="Show details" title="Show details" /> Show all details</a>
|
||||
</td>
|
||||
</tr>';
|
||||
|
||||
if ($type == "CDR")
|
||||
{
|
||||
$allowed = formatRates($history['bill_allowed']);
|
||||
$used = formatRates($history['rate_95th']);
|
||||
$in = formatRates($history['rate_95th_in']);
|
||||
$out = formatRates($history['rate_95th_out']);
|
||||
$overuse = (($history['bill_overuse'] <= 0) ? "-" : "<span style=\"color: #".$background['left']."; font-weight: bold;\">".formatRates($history['bill_overuse'])."</span>");
|
||||
} elseif ($type == "Quota") {
|
||||
$allowed = format_number($history['bill_allowed'], $config['billing']['base']);
|
||||
$used = format_number($history['total_data'], $config['billing']['base']);
|
||||
$in = format_number($history['traf_in'], $config['billing']['base']);
|
||||
$out = format_number($history['traf_out'], $config['billing']['base']);
|
||||
$overuse = (($history['bill_overuse'] <= 0) ? "-" : "<span style=\"color: #".$background['left']."; font-weight: bold;\">".format_number($history['bill_overuse'], $config['billing']['base'])."B</span>");
|
||||
}
|
||||
foreach (dbFetchRows('SELECT * FROM `bill_history` WHERE `bill_id` = ? ORDER BY `bill_datefrom` DESC LIMIT 24', array($bill_id)) as $history) {
|
||||
if (bill_permitted($history['bill_id'])) {
|
||||
unset($class);
|
||||
$datefrom = $history['bill_datefrom'];
|
||||
$dateto = $history['bill_dateto'];
|
||||
$type = $history['bill_type'];
|
||||
$percent = $history['bill_percent'];
|
||||
$dir_95th = $history['dir_95th'];
|
||||
$rate_95th = formatRates($history['rate_95th']);
|
||||
$total_data = format_number($history['traf_total'], $config['billing']['base']);
|
||||
|
||||
$total_data = (($type == "Quota") ? "<b>".$total_data."</b>" : $total_data);
|
||||
$rate_95th = (($type == "CDR") ? "<b>".$rate_95th."</b>" : $rate_95th);
|
||||
$background = get_percentage_colours($percent);
|
||||
$row_colour = ((!is_integer($i / 2)) ? $list_colour_a : $list_colour_b);
|
||||
|
||||
$url = generate_url($vars, array('detail' => $history['bill_hist_id']));
|
||||
if ($type == 'CDR') {
|
||||
$allowed = formatRates($history['bill_allowed']);
|
||||
$used = formatRates($history['rate_95th']);
|
||||
$in = formatRates($history['rate_95th_in']);
|
||||
$out = formatRates($history['rate_95th_out']);
|
||||
$overuse = (($history['bill_overuse'] <= 0) ? '-' : '<span style="color: #'.$background['left'].'; font-weight: bold;">'.formatRates($history['bill_overuse']).'</span>');
|
||||
}
|
||||
else if ($type == 'Quota') {
|
||||
$allowed = format_number($history['bill_allowed'], $config['billing']['base']);
|
||||
$used = format_number($history['total_data'], $config['billing']['base']);
|
||||
$in = format_number($history['traf_in'], $config['billing']['base']);
|
||||
$out = format_number($history['traf_out'], $config['billing']['base']);
|
||||
$overuse = (($history['bill_overuse'] <= 0) ? '-' : '<span style="color: #'.$background['left'].'; font-weight: bold;">'.format_number($history['bill_overuse'], $config['billing']['base']).'B</span>');
|
||||
}
|
||||
|
||||
echo("
|
||||
<tr style=\"background: ".$row_colour.";\">
|
||||
<td></td>
|
||||
<td><span style=\"font-weight: bold;\" class=\"interface\">".strftime("%Y-%m-%d", strtotime($datefrom))." -> ".strftime("%Y-%m-%d", strtotime($dateto))."</span></td>
|
||||
<td>$type</td>
|
||||
<td>$allowed</td>
|
||||
<td>$in</td>
|
||||
<td>$out</td>
|
||||
<td>$total_data</td>
|
||||
<td>$rate_95th</td>
|
||||
<td style=\"text-align: center;\">$overuse</td>
|
||||
<td width=\"250\">".print_percentage_bar(250, 20, $perc, NULL, "ffffff", $background['left'], $percent."%", "ffffff", $background['right'])."</td>
|
||||
<td>
|
||||
<a href=\"".$url."\"><img src=\"images/16/chart_curve.png\" border=\"0\" align=\"absmiddle\" alt=\"Show details\" title=\"Show details\"/></a>
|
||||
</td>
|
||||
</tr>");
|
||||
$total_data = (($type == 'Quota') ? '<b>'.$total_data.'</b>' : $total_data);
|
||||
$rate_95th = (($type == 'CDR') ? '<b>'.$rate_95th.'</b>' : $rate_95th);
|
||||
|
||||
if ($vars['detail'] == $history['bill_hist_id'] || $vars['detail'] == "all") {
|
||||
$img['bitrate'] = showDetails($bill_id, "bitrate", strtotime($datefrom), strtotime($dateto), $type);
|
||||
$img['bw_day'] = showDetails($bill_id, "day", strtotime($datefrom), strtotime($dateto));
|
||||
$img['bw_hour'] = showDetails($bill_id, "hour", strtotime($datefrom), strtotime($dateto));
|
||||
echo("
|
||||
<tr style=\"background: #fff; border-top: 1px solid ".$row_colour."; border-bottom: 1px solid #ccc;\">
|
||||
<td colspan=\"11\">
|
||||
<!-- <b>Accuate Graph</b><br /> //-->
|
||||
".$img['bitrate']."<br />
|
||||
<!-- <b>Bandwidth Graph per day</b><br /> //-->
|
||||
".$img['bw_day']."<br />
|
||||
<!-- <b>Bandwidth Graph per hour</b><br /> //-->
|
||||
".$img['bw_hour']."
|
||||
</td>
|
||||
</tr>");
|
||||
}
|
||||
$url = generate_url($vars, array('detail' => $history['bill_hist_id']));
|
||||
|
||||
$i++;
|
||||
} // PERMITTED
|
||||
}
|
||||
echo("</table>");
|
||||
echo '
|
||||
<tr style="background: '.$row_colour.';">
|
||||
<td></td>
|
||||
<td><span style="font-weight: bold;" class="interface">'.strftime('%Y-%m-%d', strtotime($datefrom)).' -> '.strftime('%Y-%m-%d', strtotime($dateto))."</span></td>
|
||||
<td>$type</td>
|
||||
<td>$allowed</td>
|
||||
<td>$in</td>
|
||||
<td>$out</td>
|
||||
<td>$total_data</td>
|
||||
<td>$rate_95th</td>
|
||||
<td style=\"text-align: center;\">$overuse</td>
|
||||
<td width=\"250\">".print_percentage_bar(250, 20, $perc, null, 'ffffff', $background['left'], $percent.'%', 'ffffff', $background['right']).'</td>
|
||||
<td>
|
||||
<a href="'.$url.'"><img src="images/16/chart_curve.png" border="0" align="absmiddle" alt="Show details" title="Show details"/></a>
|
||||
</td>
|
||||
</tr>';
|
||||
|
||||
?>
|
||||
if ($vars['detail'] == $history['bill_hist_id'] || $vars['detail'] == 'all') {
|
||||
$img['bitrate'] = showDetails($bill_id, 'bitrate', strtotime($datefrom), strtotime($dateto), $type);
|
||||
$img['bw_day'] = showDetails($bill_id, 'day', strtotime($datefrom), strtotime($dateto));
|
||||
$img['bw_hour'] = showDetails($bill_id, 'hour', strtotime($datefrom), strtotime($dateto));
|
||||
echo '
|
||||
<tr style="background: #fff; border-top: 1px solid '.$row_colour.'; border-bottom: 1px solid #ccc;">
|
||||
<td colspan="11">
|
||||
<!-- <b>Accuate Graph</b><br /> //-->
|
||||
'.$img['bitrate'].'<br />
|
||||
<!-- <b>Bandwidth Graph per day</b><br /> //-->
|
||||
'.$img['bw_day'].'<br />
|
||||
<!-- <b>Bandwidth Graph per hour</b><br /> //-->
|
||||
'.$img['bw_hour'].'
|
||||
</td>
|
||||
</tr>';
|
||||
}
|
||||
|
||||
$i++;
|
||||
} //end if
|
||||
}//end foreach
|
||||
|
||||
echo '</table>';
|
||||
|
@@ -1,350 +1,391 @@
|
||||
<?php
|
||||
|
||||
$bill_id = ((is_numeric($_GET['bill_id'])) ? $_GET['bill_id'] : 0);
|
||||
$history_id = ((is_numeric($_GET['history_id'])) ? $_GET['history_id'] : 0);
|
||||
$bill_id = ((is_numeric($_GET['bill_id'])) ? $_GET['bill_id'] : 0);
|
||||
$history_id = ((is_numeric($_GET['history_id'])) ? $_GET['history_id'] : 0);
|
||||
|
||||
$filename = "billing-report_".$history_id.".pdf";
|
||||
$i = 0;
|
||||
$config['billing']['base'] = $config['billing']['base'];
|
||||
$html = "";
|
||||
$history = array();
|
||||
$customer = array();
|
||||
$device = array();
|
||||
$filename = 'billing-report_'.$history_id.'.pdf';
|
||||
$i = 0;
|
||||
$config['billing']['base'] = $config['billing']['base'];
|
||||
$html = '';
|
||||
$history = array();
|
||||
$customer = array();
|
||||
$device = array();
|
||||
|
||||
// Page Layout
|
||||
$portret = $pdf->serializeTCPDFtagParameters(array('P'));
|
||||
$landscape = $pdf->serializeTCPDFtagParameters(array('L'));
|
||||
// Page Layout
|
||||
$portret = $pdf->serializeTCPDFtagParameters(array('P'));
|
||||
$landscape = $pdf->serializeTCPDFtagParameters(array('L'));
|
||||
|
||||
// History Database content
|
||||
foreach (dbFetchRows("SELECT * FROM `bill_hist` WHERE `bill_id`= ? AND `id` = ? ORDER BY `bill_datefrom` DESC LIMIT 1", array($bill_id, $history_id)) as $row) {
|
||||
// History Database content
|
||||
foreach (dbFetchRows('SELECT * FROM `bill_hist` WHERE `bill_id`= ? AND `id` = ? ORDER BY `bill_datefrom` DESC LIMIT 1', array($bill_id, $history_id)) as $row) {
|
||||
if (bill_permitted($row['bill_id'])) {
|
||||
$history['datefrom'] = strftime("%A, %e %B %Y @ %T", strtotime($row['bill_datefrom']));
|
||||
$history['dateto'] = strftime("%A, %e %B %Y @ %T", strtotime($row['bill_dateto']));
|
||||
$history['timestampfrom'] = strtotime($row['bill_datefrom']);
|
||||
$history['timestampto'] = strtotime($row['bill_dateto']);
|
||||
$history['type'] = $row['bill_type'];
|
||||
$history['percent'] = $row['bill_percent'];
|
||||
$history['dir_95th'] = $row['dir_95th'];
|
||||
$history['rate_95th'] = formatRates($row['rate_95th']);
|
||||
$history['total_data'] = formatStorage($row['traf_total'] * $config['billing']['base'] * $config['billing']['base']);;
|
||||
$history['background'] = get_percentage_colours($row['bill_percent']);
|
||||
if ($row['bill_type'] == "CDR") {
|
||||
$history['allowed'] = format_number($row['bill_allowed'], $config['billing']['base'])."B";
|
||||
$history['used'] = format_number($row['rate_95th'], $config['billing']['base'])."B";
|
||||
$history['in'] = format_number($row['rate_95th_in'], $config['billing']['base'])."B";
|
||||
$history['out'] = format_number($row['rate_95th_out'], $config['billing']['base'])."B";
|
||||
$history['overusage'] = (($row['bill_overuse'] <= 0) ? "-" : "<span style=\"color: #".$history['background']['left']."; \">".format_number($row['bill_overuse'] * 1000)."</span>" );
|
||||
} else {
|
||||
$history['allowed'] = formatStorage($row['bill_allowed'] * $config['billing']['base'] * $config['billing']['base']);
|
||||
$history['used'] = formatStorage($row['traf_total'] * $config['billing']['base'] * $config['billing']['base']);
|
||||
$history['in'] = formatStorage($row['traf_in'] * $config['billing']['base'] * $config['billing']['base']);
|
||||
$history['out'] = formatStorage($row['traf_out'] * $config['billing']['base'] * $config['billing']['base']);
|
||||
$history['overusage'] = (($row['bill_overuse'] <= 0) ? "-" : "<span style=\"color: #".$history['background']['left']."; \">".formatStorage($row['bill_overuse'] * $config['billing']['base'] * $config['billing']['base'])."</span>" );
|
||||
}
|
||||
}
|
||||
}
|
||||
$history['datefrom'] = strftime('%A, %e %B %Y @ %T', strtotime($row['bill_datefrom']));
|
||||
$history['dateto'] = strftime('%A, %e %B %Y @ %T', strtotime($row['bill_dateto']));
|
||||
$history['timestampfrom'] = strtotime($row['bill_datefrom']);
|
||||
$history['timestampto'] = strtotime($row['bill_dateto']);
|
||||
$history['type'] = $row['bill_type'];
|
||||
$history['percent'] = $row['bill_percent'];
|
||||
$history['dir_95th'] = $row['dir_95th'];
|
||||
$history['rate_95th'] = formatRates($row['rate_95th']);
|
||||
$history['total_data'] = formatStorage(($row['traf_total'] * $config['billing']['base'] * $config['billing']['base']));
|
||||
;
|
||||
$history['background'] = get_percentage_colours($row['bill_percent']);
|
||||
if ($row['bill_type'] == 'CDR') {
|
||||
$history['allowed'] = format_number($row['bill_allowed'], $config['billing']['base']).'B';
|
||||
$history['used'] = format_number($row['rate_95th'], $config['billing']['base']).'B';
|
||||
$history['in'] = format_number($row['rate_95th_in'], $config['billing']['base']).'B';
|
||||
$history['out'] = format_number($row['rate_95th_out'], $config['billing']['base']).'B';
|
||||
$history['overusage'] = (($row['bill_overuse'] <= 0) ? '-' : '<span style="color: #'.$history['background']['left'].'; ">'.format_number(($row['bill_overuse'] * 1000)).'</span>' );
|
||||
}
|
||||
else {
|
||||
$history['allowed'] = formatStorage(($row['bill_allowed'] * $config['billing']['base'] * $config['billing']['base']));
|
||||
$history['used'] = formatStorage(($row['traf_total'] * $config['billing']['base'] * $config['billing']['base']));
|
||||
$history['in'] = formatStorage(($row['traf_in'] * $config['billing']['base'] * $config['billing']['base']));
|
||||
$history['out'] = formatStorage(($row['traf_out'] * $config['billing']['base'] * $config['billing']['base']));
|
||||
$history['overusage'] = (($row['bill_overuse'] <= 0) ? '-' : '<span style="color: #'.$history['background']['left'].'; ">'.formatStorage(($row['bill_overuse'] * $config['billing']['base'] * $config['billing']['base'])).'</span>' );
|
||||
}
|
||||
}//end if
|
||||
}//end foreach
|
||||
|
||||
// Customer Database content
|
||||
foreach (dbFetchRows("SELECT bill_name, bill_custid, bill_ref, bill_notes FROM `bills` WHERE `bill_id` = ? ORDER BY `bill_id` LIMIT 1", array($bill_id)) as $row) {
|
||||
// Customer Database content
|
||||
foreach (dbFetchRows('SELECT bill_name, bill_custid, bill_ref, bill_notes FROM `bills` WHERE `bill_id` = ? ORDER BY `bill_id` LIMIT 1', array($bill_id)) as $row) {
|
||||
if (bill_permitted($bill_id)) {
|
||||
$customer['id'] = $row['bill_custid'];
|
||||
$customer['name'] = $row['bill_name'];
|
||||
$customer['ref'] = $row['bill_ref'];
|
||||
$customer['notes'] = $row['bill_notes'];
|
||||
$customer['id'] = $row['bill_custid'];
|
||||
$customer['name'] = $row['bill_name'];
|
||||
$customer['ref'] = $row['bill_ref'];
|
||||
$customer['notes'] = $row['bill_notes'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Billing types
|
||||
$bill_type['95per'] = (($history['type'] != "CDR") ? "[ ] 95 Percentile" : "<b>[X] 95 Percentile</b>");
|
||||
$bill_type['quota'] = (($history['type'] != "Quota") ? "[ ] Quota" : "<b>[X] Quota</b>");
|
||||
$bill_type['average'] = (($history['type'] != "Ave") ? "[ ] Average" : "<b>[X] Average</b>");
|
||||
// Billing types
|
||||
$bill_type['95per'] = (($history['type'] != 'CDR') ? '[ ] 95 Percentile' : '<b>[X] 95 Percentile</b>');
|
||||
$bill_type['quota'] = (($history['type'] != 'Quota') ? '[ ] Quota' : '<b>[X] Quota</b>');
|
||||
$bill_type['average'] = (($history['type'] != 'Ave') ? '[ ] Average' : '<b>[X] Average</b>');
|
||||
|
||||
// QR Tag
|
||||
$http = ((empty($_SERVER['HTTPS'])) ? "http" : "https" );
|
||||
$url['his'] = $http."://".$_SERVER['HTTP_HOST']."/bill/bill_id=".$bill_id."/view=history/detail=".$history_id."/";
|
||||
$url['pdf'] = $http."://".$_SERVER['HTTP_HOST']."/pdf.php?type=billing&report=history&bill_id=".$bill_id."&history_id=".$history_id;
|
||||
$created = strftime("%A, %e %B %Y @ %T", strtotime("now"));
|
||||
//$qrInfo = "More Info : ".$url['his']."\nPDF Report : ".$url['pdf']."\nPDF Created: ".$created."\n";
|
||||
$qrInfo = "More Info : ".$url['his']."\nPDF Created: ".$created."\n";
|
||||
$qrStyle = array('border' => false, 'vpadding' => auto, 'hpadding' => auto, 'fgcolor' => array(0, 0, 0), 'bgcolor' => false, 'module_width' => 1, 'module_height' => 1);
|
||||
$qrTag = $pdf->serializeTCPDFtagParameters(array($qrInfo, 'QRCODE,H', 162, 68, 50, 50, $qrStyle, 'N'));
|
||||
// QR Tag
|
||||
$http = ((empty($_SERVER['HTTPS'])) ? 'http' : 'https' );
|
||||
$url['his'] = $http.'://'.$_SERVER['HTTP_HOST'].'/bill/bill_id='.$bill_id.'/view=history/detail='.$history_id.'/';
|
||||
$url['pdf'] = $http.'://'.$_SERVER['HTTP_HOST'].'/pdf.php?type=billing&report=history&bill_id='.$bill_id.'&history_id='.$history_id;
|
||||
$created = strftime('%A, %e %B %Y @ %T', strtotime('now'));
|
||||
// $qrInfo = "More Info : ".$url['his']."\nPDF Report : ".$url['pdf']."\nPDF Created: ".$created."\n";
|
||||
$qrInfo = 'More Info : '.$url['his']."\nPDF Created: ".$created."\n";
|
||||
$qrStyle = array(
|
||||
'border' => false,
|
||||
'vpadding' => auto,
|
||||
'hpadding' => auto,
|
||||
'fgcolor' => array(
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
),
|
||||
'bgcolor' => false,
|
||||
'module_width' => 1,
|
||||
'module_height' => 1,
|
||||
);
|
||||
$qrTag = $pdf->serializeTCPDFtagParameters(array($qrInfo, 'QRCODE,H', 162, 68, 50, 50, $qrStyle, 'N'));
|
||||
|
||||
// Include css
|
||||
// Include css
|
||||
require_once 'pdf_css.inc.php';
|
||||
|
||||
include_once("pdf_css.inc.php");
|
||||
$html .= $css;
|
||||
|
||||
$html .= $css;
|
||||
// GB Convert (1000 vs 1024)
|
||||
|
||||
// GB Convert (1000 vs 1024)
|
||||
function gbConvert($data) {
|
||||
|
||||
function gbConvert($data) {
|
||||
global $config;
|
||||
|
||||
$count = strlen($data);
|
||||
$div = floor($count / 4);
|
||||
$res = round($data / pow(1000, $div) * pow($config['billing']['base'], $div));
|
||||
$res = round(($data / pow(1000, $div) * pow($config['billing']['base'], $div)));
|
||||
return $res;
|
||||
}
|
||||
|
||||
// Generate graphs
|
||||
function genGraphs($bill_id, $imgtype, $from, $to, $bittype = "Quota") {
|
||||
$http = ((empty($_SERVER['HTTPS'])) ? "http" : "https" );
|
||||
$res = $http."://".$_SERVER['HTTP_HOST']."/";
|
||||
if ($imgtype == "bitrate") {
|
||||
$res .= "billing-graph.php?bill_id=".$bill_id;
|
||||
if ($bittype == "Quota") {
|
||||
$res .= "&ave=yes";
|
||||
} elseif ($bittype == "CDR") {
|
||||
$res .= "&95th=yes";
|
||||
}
|
||||
} else {
|
||||
$res .= "bandwidth-graph.php?bill_id=".$bill_id;
|
||||
}//end gbConvert()
|
||||
|
||||
|
||||
// Generate graphs
|
||||
|
||||
|
||||
function genGraphs($bill_id, $imgtype, $from, $to, $bittype='Quota') {
|
||||
$http = ((empty($_SERVER['HTTPS'])) ? 'http' : 'https' );
|
||||
$res = $http.'://'.$_SERVER['HTTP_HOST'].'/';
|
||||
if ($imgtype == 'bitrate') {
|
||||
$res .= 'billing-graph.php?bill_id='.$bill_id;
|
||||
if ($bittype == 'Quota') {
|
||||
$res .= '&ave=yes';
|
||||
}
|
||||
else if ($bittype == 'CDR') {
|
||||
$res .= '&95th=yes';
|
||||
}
|
||||
}
|
||||
$res .= "&type=".$imgtype;
|
||||
$res .= "&x=1190&y=250";
|
||||
$res .= "&from=".$from."&to=".$to;
|
||||
else {
|
||||
$res .= 'bandwidth-graph.php?bill_id='.$bill_id;
|
||||
}
|
||||
|
||||
$res .= '&type='.$imgtype;
|
||||
$res .= '&x=1190&y=250';
|
||||
$res .= '&from='.$from.'&to='.$to;
|
||||
if (!bill_permitted($bill_id)) {
|
||||
$res = "images/observium-logo.png";
|
||||
$res = 'images/observium-logo.png';
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
|
||||
// Device Information
|
||||
function listBillPorts($bill_id) {
|
||||
return $res;
|
||||
|
||||
}//end genGraphs()
|
||||
|
||||
|
||||
// Device Information
|
||||
|
||||
|
||||
function listBillPorts($bill_id) {
|
||||
$device = array();
|
||||
$res = "";
|
||||
$res .= "<table>";
|
||||
$res .= " <tr>";
|
||||
$res .= " <th>Device</th>";
|
||||
$res .= " <th>Hardeware</th>";
|
||||
$res .= " <th>Interface/Port</th>";
|
||||
$res .= " <th>Speed</th>";
|
||||
//$res .= " <th>Description</th>";
|
||||
//$res .= " <th>Notes</th>";
|
||||
$res .= " </tr>";
|
||||
foreach (dbFetchRows("SELECT * FROM `bill_ports` as b, `ports` as p, `devices` as d WHERE b.bill_id = ? AND p.port_id = b.port_id AND d.device_id = p.device_id", array($bill_id)) as $row) {
|
||||
if (bill_permitted($bill_id)) {
|
||||
$device['name'] = $row['sysName'];
|
||||
//$device['port'] = $row['ifName']." (".$row['ifDescr'].")";
|
||||
$device['port'] = $row['ifName'];
|
||||
$device['speed'] = formatRates($row['ifSpeed']);
|
||||
$device['hw'] = $row['hardware'];
|
||||
$device['descr'] = $row['port_descr_descr'];
|
||||
$device['notes'] = $row['port_descr_notres'];
|
||||
$res .= " <tr>";
|
||||
$res .= " <td>".$device['name']."</td>";
|
||||
$res .= " <td>".$device['hw']."</td>";
|
||||
$res .= " <td>".$device['port']."</td>";
|
||||
$res .= " <td>".$device['speed']."</td>";
|
||||
//$res .= " <td>".$device['descr']."</td>";
|
||||
//$res .= " <td>".$device['notes']."</td>";
|
||||
$res .= " </tr>";
|
||||
}
|
||||
$res = '';
|
||||
$res .= '<table>';
|
||||
$res .= ' <tr>';
|
||||
$res .= ' <th>Device</th>';
|
||||
$res .= ' <th>Hardeware</th>';
|
||||
$res .= ' <th>Interface/Port</th>';
|
||||
$res .= ' <th>Speed</th>';
|
||||
// $res .= " <th>Description</th>";
|
||||
// $res .= " <th>Notes</th>";
|
||||
$res .= ' </tr>';
|
||||
foreach (dbFetchRows('SELECT * FROM `bill_ports` as b, `ports` as p, `devices` as d WHERE b.bill_id = ? AND p.port_id = b.port_id AND d.device_id = p.device_id', array($bill_id)) as $row) {
|
||||
if (bill_permitted($bill_id)) {
|
||||
$device['name'] = $row['sysName'];
|
||||
// $device['port'] = $row['ifName']." (".$row['ifDescr'].")";
|
||||
$device['port'] = $row['ifName'];
|
||||
$device['speed'] = formatRates($row['ifSpeed']);
|
||||
$device['hw'] = $row['hardware'];
|
||||
$device['descr'] = $row['port_descr_descr'];
|
||||
$device['notes'] = $row['port_descr_notres'];
|
||||
$res .= ' <tr>';
|
||||
$res .= ' <td>'.$device['name'].'</td>';
|
||||
$res .= ' <td>'.$device['hw'].'</td>';
|
||||
$res .= ' <td>'.$device['port'].'</td>';
|
||||
$res .= ' <td>'.$device['speed'].'</td>';
|
||||
// $res .= " <td>".$device['descr']."</td>";
|
||||
// $res .= " <td>".$device['notes']."</td>";
|
||||
$res .= ' </tr>';
|
||||
}
|
||||
}
|
||||
$res .= "</table>";
|
||||
return $res;
|
||||
}
|
||||
|
||||
// Bitrate Graph overview
|
||||
function graphOverviewBitrate($bill_id, $history) {
|
||||
$res .= '</table>';
|
||||
return $res;
|
||||
|
||||
}//end listBillPorts()
|
||||
|
||||
|
||||
// Bitrate Graph overview
|
||||
|
||||
|
||||
function graphOverviewBitrate($bill_id, $history) {
|
||||
global $pdf;
|
||||
$img = array();
|
||||
|
||||
$img['bitrate'] = genGraphs($bill_id, "bitrate", $history['timestampfrom'], $history['timestampto'], $history['type']);
|
||||
$img['bitrate'] = genGraphs($bill_id, 'bitrate', $history['timestampfrom'], $history['timestampto'], $history['type']);
|
||||
$bitrate = $pdf->serializeTCPDFtagParameters(array($img['bitrate'], 10, 44, 280, '', 'PNG', '', 'T'));
|
||||
$res = "";
|
||||
$res .= "<tcpdf method=\"Image\" params=\"".$bitrate."\" />";
|
||||
$res = '';
|
||||
$res .= '<tcpdf method="Image" params="'.$bitrate.'" />';
|
||||
return $res;
|
||||
}
|
||||
|
||||
// Transfer Graph overview
|
||||
function graphOverviewTransfer($bill_id, $history) {
|
||||
}//end graphOverviewBitrate()
|
||||
|
||||
|
||||
// Transfer Graph overview
|
||||
|
||||
|
||||
function graphOverviewTransfer($bill_id, $history) {
|
||||
global $pdf;
|
||||
$img = array();
|
||||
|
||||
$img['bw_day'] = genGraphs($bill_id, "day", $history['timestampfrom'], $history['timestampto']);
|
||||
$img['bw_hour'] = genGraphs($bill_id, "hour", $history['timestampfrom'], $history['timestampto']);
|
||||
$img['bw_day'] = genGraphs($bill_id, 'day', $history['timestampfrom'], $history['timestampto']);
|
||||
$img['bw_hour'] = genGraphs($bill_id, 'hour', $history['timestampfrom'], $history['timestampto']);
|
||||
$bw_day = $pdf->serializeTCPDFtagParameters(array($img['bw_day'], 10, 44, 280, '', 'PNG', '', 'T'));
|
||||
$bw_hour = $pdf->serializeTCPDFtagParameters(array($img['bw_hour'], 10, 117, 280, '', 'PNG', '', 'T'));
|
||||
$res = "";
|
||||
$res .= "<tcpdf method=\"Image\" params=\"".$bw_day."\" />";
|
||||
$res .= "<tcpdf method=\"Image\" params=\"".$bw_hour."\" />";
|
||||
$res = '';
|
||||
$res .= '<tcpdf method="Image" params="'.$bw_day.'" />';
|
||||
$res .= '<tcpdf method="Image" params="'.$bw_hour.'" />';
|
||||
return $res;
|
||||
}
|
||||
|
||||
// Transfer overview
|
||||
function transferOverview($bill_id, $history) {
|
||||
}//end graphOverviewTransfer()
|
||||
|
||||
|
||||
// Transfer overview
|
||||
|
||||
|
||||
function transferOverview($bill_id, $history) {
|
||||
global $list_colour_a, $list_colour_b, $config;
|
||||
|
||||
$i = 0;
|
||||
$tot = array();
|
||||
$traf = array();
|
||||
$start = $history['timestampfrom'];
|
||||
$end = $history['timestampto'];
|
||||
//$background= $history['background'];
|
||||
$res = "";
|
||||
$res .= "<table class=\"transferOverview\">";
|
||||
$res .= " <tr bgcolor=\"#000\">";
|
||||
$res .= " <th class=\"period\">Date</th>";
|
||||
$res .= " <th class=\"inbound\">Inbound</th>";
|
||||
$res .= " <th class=\"outbound\">Outbound</th>";
|
||||
$res .= " <th class=\"total\">Total</th>";
|
||||
$res .= " </tr>";
|
||||
foreach (dbFetch("SELECT DISTINCT UNIX_TIMESTAMP(timestamp) as timestamp, SUM(delta) as traf_total, SUM(in_delta) as traf_in, SUM(out_delta) as traf_out FROM bill_data WHERE `bill_id`= ? AND `timestamp` >= FROM_UNIXTIME(?) AND `timestamp` <= FROM_UNIXTIME(?) GROUP BY DATE(timestamp) ORDER BY timestamp ASC", array($bill_id, $start, $end)) as $data) {
|
||||
$date = strftime("%A, %e %B %Y", $data['timestamp']);
|
||||
$tot['in'] += gbConvert($data['traf_in']);
|
||||
$tot['out'] += gbConvert($data['traf_out']);
|
||||
$tot['tot'] += gbConvert($data['traf_total']);
|
||||
$traf['in'] = formatStorage(gbConvert($data['traf_in']), "3");
|
||||
$traf['out'] = formatStorage(gbConvert($data['traf_out']), "3");
|
||||
$traf['tot'] = formatStorage(gbConvert($data['traf_total']), "3");
|
||||
$row_colour = ((!is_integer($i/2)) ? $list_colour_a : $list_colour_b );
|
||||
$res .= " <tr bgcolor=\"".$row_colour."\">";
|
||||
$res .= " <td>".$date."</td>";
|
||||
$res .= " <td class=\"right\">".$traf['in']."</td>";
|
||||
$res .= " <td class=\"right\">".$traf['out']."</td>";
|
||||
$res .= " <td class=\"right\">".$traf['tot']."</td>";
|
||||
$res .= " </tr>";
|
||||
$i++;
|
||||
$i = 0;
|
||||
$tot = array();
|
||||
$traf = array();
|
||||
$start = $history['timestampfrom'];
|
||||
$end = $history['timestampto'];
|
||||
// $background= $history['background'];
|
||||
$res = '';
|
||||
$res .= '<table class="transferOverview">';
|
||||
$res .= ' <tr bgcolor="#000">';
|
||||
$res .= ' <th class="period">Date</th>';
|
||||
$res .= ' <th class="inbound">Inbound</th>';
|
||||
$res .= ' <th class="outbound">Outbound</th>';
|
||||
$res .= ' <th class="total">Total</th>';
|
||||
$res .= ' </tr>';
|
||||
foreach (dbFetch('SELECT DISTINCT UNIX_TIMESTAMP(timestamp) as timestamp, SUM(delta) as traf_total, SUM(in_delta) as traf_in, SUM(out_delta) as traf_out FROM bill_data WHERE `bill_id`= ? AND `timestamp` >= FROM_UNIXTIME(?) AND `timestamp` <= FROM_UNIXTIME(?) GROUP BY DATE(timestamp) ORDER BY timestamp ASC', array($bill_id, $start, $end)) as $data) {
|
||||
$date = strftime('%A, %e %B %Y', $data['timestamp']);
|
||||
$tot['in'] += gbConvert($data['traf_in']);
|
||||
$tot['out'] += gbConvert($data['traf_out']);
|
||||
$tot['tot'] += gbConvert($data['traf_total']);
|
||||
$traf['in'] = formatStorage(gbConvert($data['traf_in']), '3');
|
||||
$traf['out'] = formatStorage(gbConvert($data['traf_out']), '3');
|
||||
$traf['tot'] = formatStorage(gbConvert($data['traf_total']), '3');
|
||||
$row_colour = ((!is_integer($i / 2)) ? $list_colour_a : $list_colour_b );
|
||||
$res .= ' <tr bgcolor="'.$row_colour.'">';
|
||||
$res .= ' <td>'.$date.'</td>';
|
||||
$res .= ' <td class="right">'.$traf['in'].'</td>';
|
||||
$res .= ' <td class="right">'.$traf['out'].'</td>';
|
||||
$res .= ' <td class="right">'.$traf['tot'].'</td>';
|
||||
$res .= ' </tr>';
|
||||
$i++;
|
||||
}
|
||||
$tot['in'] = formatStorage($tot['in']);
|
||||
$tot['out']= formatStorage($tot['out']);
|
||||
$tot['tot']= formatStorage($tot['tot']);
|
||||
$res .= " <tr bgcolor=\"#ccc\" style=\"border-top: 1px solid #000;\">";
|
||||
$res .= " <td></td>";
|
||||
$res .= " <td class=\"right\"><b>".$tot['in']."</b></td>";
|
||||
$res .= " <td class=\"right\"><b>".$tot['out']."</b></td>";
|
||||
$res .= " <td class=\"right\"><b>".$tot['tot']."</b></td>";
|
||||
$res .= " </tr>";
|
||||
$res .= "</table>";
|
||||
|
||||
$tot['in'] = formatStorage($tot['in']);
|
||||
$tot['out'] = formatStorage($tot['out']);
|
||||
$tot['tot'] = formatStorage($tot['tot']);
|
||||
$res .= ' <tr bgcolor="#ccc" style="border-top: 1px solid #000;">';
|
||||
$res .= ' <td></td>';
|
||||
$res .= ' <td class="right"><b>'.$tot['in'].'</b></td>';
|
||||
$res .= ' <td class="right"><b>'.$tot['out'].'</b></td>';
|
||||
$res .= ' <td class="right"><b>'.$tot['tot'].'</b></td>';
|
||||
$res .= ' </tr>';
|
||||
$res .= '</table>';
|
||||
return $res;
|
||||
}
|
||||
|
||||
// Html template
|
||||
$logo = $pdf->serializeTCPDFtagParameters(array('images/dummy-logo.png', 15, 18, 100, '', '', 'www.example.com', 'T'));
|
||||
$html .= "<tcpdf method=\"Image\" params=\"".$logo."\" />";
|
||||
$html .= "<h1 class=\"right\">Billing Report</h1>";
|
||||
$html .= "<p></p>";
|
||||
$html .= "<p></p>";
|
||||
$html .= "<p></p>";
|
||||
}//end transferOverview()
|
||||
|
||||
$html .= "<h2>Billing information</h2>";
|
||||
$html .= "<p></p>";
|
||||
$html .= "<table>";
|
||||
$html .= " <tr>";
|
||||
$html .= " <th class=\"title\">Customer</th>";
|
||||
$html .= " <td class=\"divider\">:</td>";
|
||||
$html .= " <td class=\"content\">".$customer['name']."</td>";
|
||||
$html .= " <td class=\"qtag\" rowspan=\"6\"><tcpdf method=\"write2DBarcode\" params=\"".$qrTag."\" /></td>";
|
||||
$html .= " </tr>";
|
||||
$html .= " <tr>";
|
||||
$html .= " <th>Customer ID</th>";
|
||||
$html .= " <td>:</td>";
|
||||
$html .= " <td>".$customer['id']."</td>";
|
||||
$html .= " </tr>";
|
||||
$html .= " <tr>";
|
||||
$html .= " <th>Customer Info</th>";
|
||||
$html .= " <td>:</td>";
|
||||
$html .= " <td>".$customer['ref']."</td>";
|
||||
$html .= " </tr>";
|
||||
$html .= " <tr>";
|
||||
$html .= " <th>Customer Notes</th>";
|
||||
$html .= " <td>:</td>";
|
||||
$html .= " <td>".$customer['notes']."</td>";
|
||||
$html .= " </tr>";
|
||||
$html .= " <tr>";
|
||||
$html .= " <th>Billing ID</th>";
|
||||
$html .= " <td>:</td>";
|
||||
$html .= " <td>".$bill_id."</td>";
|
||||
$html .= " </tr>";
|
||||
$html .= " <tr>";
|
||||
$html .= " <th>History ID</th>";
|
||||
$html .= " <td>:</td>";
|
||||
$html .= " <td>".$history_id."</td>";
|
||||
$html .= " </tr>";
|
||||
$html .= "</table>";
|
||||
$html .= "<p></p>";
|
||||
|
||||
$html .= "<h2>Billing period</h2>";
|
||||
$html .= "<p></p>";
|
||||
$html .= "<table>";
|
||||
$html .= " <tr>";
|
||||
$html .= " <th class=\"title\">From</th>";
|
||||
$html .= " <td class=\"divider\">:</td>";
|
||||
$html .= " <td class=\"content\">".$history['datefrom']."</td>";
|
||||
$html .= " </tr>";
|
||||
$html .= " <tr>";
|
||||
$html .= " <th>To</th>";
|
||||
$html .= " <td>:</td>";
|
||||
$html .= " <td>".$history['dateto']."</td>";
|
||||
$html .= " </tr>";
|
||||
$html .= "</table>";
|
||||
$html .= "<p></p>";
|
||||
$html .= "<p></p>";
|
||||
// Html template
|
||||
$logo = $pdf->serializeTCPDFtagParameters(array('images/dummy-logo.png', 15, 18, 100, '', '', 'www.example.com', 'T'));
|
||||
$html .= '<tcpdf method="Image" params="'.$logo.'" />';
|
||||
$html .= '<h1 class="right">Billing Report</h1>';
|
||||
$html .= '<p></p>';
|
||||
$html .= '<p></p>';
|
||||
$html .= '<p></p>';
|
||||
|
||||
$html .= "<h2>Device interface/port information</h2>";
|
||||
$html .= "<p></p>";
|
||||
$html .= listBillPorts($bill_id);
|
||||
$html .= "<p></p>";
|
||||
$html .= "<p></p>";
|
||||
$html .= '<h2>Billing information</h2>';
|
||||
$html .= '<p></p>';
|
||||
$html .= '<table>';
|
||||
$html .= ' <tr>';
|
||||
$html .= ' <th class="title">Customer</th>';
|
||||
$html .= ' <td class="divider">:</td>';
|
||||
$html .= ' <td class="content">'.$customer['name'].'</td>';
|
||||
$html .= ' <td class="qtag" rowspan="6"><tcpdf method="write2DBarcode" params="'.$qrTag.'" /></td>';
|
||||
$html .= ' </tr>';
|
||||
$html .= ' <tr>';
|
||||
$html .= ' <th>Customer ID</th>';
|
||||
$html .= ' <td>:</td>';
|
||||
$html .= ' <td>'.$customer['id'].'</td>';
|
||||
$html .= ' </tr>';
|
||||
$html .= ' <tr>';
|
||||
$html .= ' <th>Customer Info</th>';
|
||||
$html .= ' <td>:</td>';
|
||||
$html .= ' <td>'.$customer['ref'].'</td>';
|
||||
$html .= ' </tr>';
|
||||
$html .= ' <tr>';
|
||||
$html .= ' <th>Customer Notes</th>';
|
||||
$html .= ' <td>:</td>';
|
||||
$html .= ' <td>'.$customer['notes'].'</td>';
|
||||
$html .= ' </tr>';
|
||||
$html .= ' <tr>';
|
||||
$html .= ' <th>Billing ID</th>';
|
||||
$html .= ' <td>:</td>';
|
||||
$html .= ' <td>'.$bill_id.'</td>';
|
||||
$html .= ' </tr>';
|
||||
$html .= ' <tr>';
|
||||
$html .= ' <th>History ID</th>';
|
||||
$html .= ' <td>:</td>';
|
||||
$html .= ' <td>'.$history_id.'</td>';
|
||||
$html .= ' </tr>';
|
||||
$html .= '</table>';
|
||||
$html .= '<p></p>';
|
||||
|
||||
$html .= "<h2>Usage information</h2>";
|
||||
$html .= "<p></p>";
|
||||
$html .= "<table>";
|
||||
$html .= " <tr>";
|
||||
$html .= " <th class=\"title\">Type</th>";
|
||||
$html .= " <td class=\"divider\">:</td>";
|
||||
$html .= " <td class=\"content\">".$bill_type['95per']."</td>";
|
||||
$html .= " </tr>";
|
||||
$html .= " <tr>";
|
||||
$html .= " <td></td>";
|
||||
$html .= " <td></td>";
|
||||
$html .= " <td>".$bill_type['quota']."</td>";
|
||||
$html .= " </tr>";
|
||||
$html .= " <tr>";
|
||||
$html .= " <td></td>";
|
||||
$html .= " <td></td>";
|
||||
$html .= " <td>".$bill_type['average']."</td>";
|
||||
$html .= " </tr>";
|
||||
$html .= " <tr>";
|
||||
$html .= " <th>Transferred</th>";
|
||||
$html .= " <td>:</td>";
|
||||
$html .= " <td>".$history['used']." (<span style=\"color: #".$history['background']['left']."; \">".$history['percent']."%</span>) </td>";
|
||||
$html .= " </tr>";
|
||||
$html .= " <tr>";
|
||||
$html .= " <th>Inbound</th>";
|
||||
$html .= " <td>:</td>";
|
||||
$html .= " <td>".$history['in']."</td>";
|
||||
$html .= " </tr>";
|
||||
$html .= " <tr>";
|
||||
$html .= " <th>Outbound</th>";
|
||||
$html .= " <td>:</td>";
|
||||
$html .= " <td>".$history['out']."</td>";
|
||||
$html .= " </tr>";
|
||||
$html .= " <tr>";
|
||||
$html .= " <th>Allowed</th>";
|
||||
$html .= " <td>:</td>";
|
||||
$html .= " <td>".$history['allowed']."</td>";
|
||||
$html .= " </tr>";
|
||||
$html .= " <tr>";
|
||||
$html .= " <th>Overusage</th>";
|
||||
$html .= " <td>:</td>";
|
||||
$html .= " <td>".$history['overusage']."</td>";
|
||||
$html .= " </tr>";
|
||||
$html .= "</table>";
|
||||
$html .= '<h2>Billing period</h2>';
|
||||
$html .= '<p></p>';
|
||||
$html .= '<table>';
|
||||
$html .= ' <tr>';
|
||||
$html .= ' <th class="title">From</th>';
|
||||
$html .= ' <td class="divider">:</td>';
|
||||
$html .= ' <td class="content">'.$history['datefrom'].'</td>';
|
||||
$html .= ' </tr>';
|
||||
$html .= ' <tr>';
|
||||
$html .= ' <th>To</th>';
|
||||
$html .= ' <td>:</td>';
|
||||
$html .= ' <td>'.$history['dateto'].'</td>';
|
||||
$html .= ' </tr>';
|
||||
$html .= '</table>';
|
||||
$html .= '<p></p>';
|
||||
$html .= '<p></p>';
|
||||
|
||||
$html .= "<tcpdf method=\"AddPage\" params=\"".$landscape."\" />";
|
||||
$html .= "<h2>Bitrate Graph overview</h2>";
|
||||
$html .= "<p></p>";
|
||||
$html .= graphOverviewBitrate($bill_id, $history);
|
||||
$html .= '<h2>Device interface/port information</h2>';
|
||||
$html .= '<p></p>';
|
||||
$html .= listBillPorts($bill_id);
|
||||
$html .= '<p></p>';
|
||||
$html .= '<p></p>';
|
||||
|
||||
$html .= "<tcpdf method=\"AddPage\" params=\"".$landscape."\" />";
|
||||
$html .= "<h2>Transfer Graph overview</h2>";
|
||||
$html .= "<p></p>";
|
||||
$html .= graphOverviewTransfer($bill_id, $history);
|
||||
$html .= '<h2>Usage information</h2>';
|
||||
$html .= '<p></p>';
|
||||
$html .= '<table>';
|
||||
$html .= ' <tr>';
|
||||
$html .= ' <th class="title">Type</th>';
|
||||
$html .= ' <td class="divider">:</td>';
|
||||
$html .= ' <td class="content">'.$bill_type['95per'].'</td>';
|
||||
$html .= ' </tr>';
|
||||
$html .= ' <tr>';
|
||||
$html .= ' <td></td>';
|
||||
$html .= ' <td></td>';
|
||||
$html .= ' <td>'.$bill_type['quota'].'</td>';
|
||||
$html .= ' </tr>';
|
||||
$html .= ' <tr>';
|
||||
$html .= ' <td></td>';
|
||||
$html .= ' <td></td>';
|
||||
$html .= ' <td>'.$bill_type['average'].'</td>';
|
||||
$html .= ' </tr>';
|
||||
$html .= ' <tr>';
|
||||
$html .= ' <th>Transferred</th>';
|
||||
$html .= ' <td>:</td>';
|
||||
$html .= ' <td>'.$history['used'].' (<span style="color: #'.$history['background']['left'].'; ">'.$history['percent'].'%</span>) </td>';
|
||||
$html .= ' </tr>';
|
||||
$html .= ' <tr>';
|
||||
$html .= ' <th>Inbound</th>';
|
||||
$html .= ' <td>:</td>';
|
||||
$html .= ' <td>'.$history['in'].'</td>';
|
||||
$html .= ' </tr>';
|
||||
$html .= ' <tr>';
|
||||
$html .= ' <th>Outbound</th>';
|
||||
$html .= ' <td>:</td>';
|
||||
$html .= ' <td>'.$history['out'].'</td>';
|
||||
$html .= ' </tr>';
|
||||
$html .= ' <tr>';
|
||||
$html .= ' <th>Allowed</th>';
|
||||
$html .= ' <td>:</td>';
|
||||
$html .= ' <td>'.$history['allowed'].'</td>';
|
||||
$html .= ' </tr>';
|
||||
$html .= ' <tr>';
|
||||
$html .= ' <th>Overusage</th>';
|
||||
$html .= ' <td>:</td>';
|
||||
$html .= ' <td>'.$history['overusage'].'</td>';
|
||||
$html .= ' </tr>';
|
||||
$html .= '</table>';
|
||||
|
||||
$html .= "<tcpdf method=\"AddPage\" params=\"".$portret."\" />";
|
||||
$html .= "<h2>Detailed transfer overview</h2>";
|
||||
$html .= "<p></p>";
|
||||
$html .= transferOverview($bill_id, $history);
|
||||
$html .= '<tcpdf method="AddPage" params="'.$landscape.'" />';
|
||||
$html .= '<h2>Bitrate Graph overview</h2>';
|
||||
$html .= '<p></p>';
|
||||
$html .= graphOverviewBitrate($bill_id, $history);
|
||||
|
||||
?>
|
||||
$html .= '<tcpdf method="AddPage" params="'.$landscape.'" />';
|
||||
$html .= '<h2>Transfer Graph overview</h2>';
|
||||
$html .= '<p></p>';
|
||||
$html .= graphOverviewTransfer($bill_id, $history);
|
||||
|
||||
$html .= '<tcpdf method="AddPage" params="'.$portret.'" />';
|
||||
$html .= '<h2>Detailed transfer overview</h2>';
|
||||
$html .= '<p></p>';
|
||||
$html .= transferOverview($bill_id, $history);
|
||||
|
@@ -1,172 +1,170 @@
|
||||
<?php
|
||||
|
||||
$pagetitle[] = "Bandwidth Graphs";
|
||||
$pagetitle[] = 'Bandwidth Graphs';
|
||||
|
||||
# $bill_data = dbFetchRow("SELECT * FROM bills WHERE bill_id = ?", array($bill_id));
|
||||
// $bill_data = dbFetchRow("SELECT * FROM bills WHERE bill_id = ?", array($bill_id));
|
||||
// $today = str_replace("-", "", dbFetchCell("SELECT CURDATE()"));
|
||||
// $tomorrow = str_replace("-", "", dbFetchCell("SELECT DATE_ADD(CURDATE(), INTERVAL 1 DAY)"));
|
||||
// $last_month = str_replace("-", "", dbFetchCell("SELECT DATE_SUB(CURDATE(), INTERVAL 1 MONTH)"));
|
||||
// $rightnow = $today . date(His);
|
||||
// $before = $yesterday . date(His);
|
||||
// $lastmonth = $last_month . date(His);
|
||||
// $dayofmonth = $bill_data['bill_day'];
|
||||
// $day_data = getDates($dayofmonth);
|
||||
// $datefrom = $day_data['0'];
|
||||
// $dateto = $day_data['1'];
|
||||
// $lastfrom = $day_data['2'];
|
||||
// $lastto = $day_data['3'];
|
||||
// print_r($bill_data);
|
||||
$total_data = $bill_data['total_data'];
|
||||
$in_data = $bill_data['total_data_in'];
|
||||
$out_data = $bill_data['total_data_out'];
|
||||
|
||||
# $today = str_replace("-", "", dbFetchCell("SELECT CURDATE()"));
|
||||
# $tomorrow = str_replace("-", "", dbFetchCell("SELECT DATE_ADD(CURDATE(), INTERVAL 1 DAY)"));
|
||||
# $last_month = str_replace("-", "", dbFetchCell("SELECT DATE_SUB(CURDATE(), INTERVAL 1 MONTH)"));
|
||||
$fromtext = dbFetchCell("SELECT DATE_FORMAT($datefrom, '".$config['dateformat']['mysql']['date']."')");
|
||||
$totext = dbFetchCell("SELECT DATE_FORMAT($dateto, '".$config['dateformat']['mysql']['date']."')");
|
||||
$unixfrom = dbFetchCell("SELECT UNIX_TIMESTAMP('$datefrom')");
|
||||
$unixto = dbFetchCell("SELECT UNIX_TIMESTAMP('$dateto')");
|
||||
$unix_prev_from = dbFetchCell("SELECT UNIX_TIMESTAMP('$lastfrom')");
|
||||
$unix_prev_to = dbFetchCell("SELECT UNIX_TIMESTAMP('$lastto')");
|
||||
$lastmonth = dbFetchCell('SELECT UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 1 MONTH))');
|
||||
$yesterday = dbFetchCell('SELECT UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 1 DAY))');
|
||||
$rightnow = date(U);
|
||||
|
||||
# $rightnow = $today . date(His);
|
||||
# $before = $yesterday . date(His);
|
||||
# $lastmonth = $last_month . date(His);
|
||||
echo '<h3>Billed Ports</h3>';
|
||||
|
||||
# $dayofmonth = $bill_data['bill_day'];
|
||||
# $day_data = getDates($dayofmonth);
|
||||
# $datefrom = $day_data['0'];
|
||||
# $dateto = $day_data['1'];
|
||||
# $lastfrom = $day_data['2'];
|
||||
# $lastto = $day_data['3'];
|
||||
foreach ($ports as $port) {
|
||||
echo generate_port_link($port).' on '.generate_device_link($port).'<br />';
|
||||
}
|
||||
|
||||
# print_r($bill_data);
|
||||
$cur_days = date('d', (strtotime('now') - strtotime($datefrom)));
|
||||
$total_days = date('d', (strtotime($dateto) - strtotime($datefrom)));
|
||||
|
||||
$total_data = $bill_data['total_data'];
|
||||
$in_data = $bill_data['total_data_in'];
|
||||
$out_data = $bill_data['total_data_out'];
|
||||
$total['data'] = format_bytes_billing($bill_data['total_data']);
|
||||
if ($bill_data['bill_type'] == 'quota') {
|
||||
$total['allow'] = format_bytes_billing($bill_data['bill_quota']);
|
||||
}
|
||||
else {
|
||||
$total['allow'] = '-';
|
||||
}
|
||||
|
||||
$fromtext = dbFetchCell("SELECT DATE_FORMAT($datefrom, '".$config['dateformat']['mysql']['date']."')");
|
||||
$totext = dbFetchCell("SELECT DATE_FORMAT($dateto, '".$config['dateformat']['mysql']['date']."')");
|
||||
$unixfrom = dbFetchCell("SELECT UNIX_TIMESTAMP('$datefrom')");
|
||||
$unixto = dbFetchCell("SELECT UNIX_TIMESTAMP('$dateto')");
|
||||
$unix_prev_from = dbFetchCell("SELECT UNIX_TIMESTAMP('$lastfrom')");
|
||||
$unix_prev_to = dbFetchCell("SELECT UNIX_TIMESTAMP('$lastto')");
|
||||
$lastmonth = dbFetchCell("SELECT UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 1 MONTH))");
|
||||
$yesterday = dbFetchCell("SELECT UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 1 DAY))");
|
||||
$rightnow = date(U);
|
||||
$total['ave'] = format_bytes_billing(($bill_data['total_data'] / $cur_days));
|
||||
$total['est'] = format_bytes_billing(($bill_data['total_data'] / $cur_days * $total_days));
|
||||
$total['per'] = round(($bill_data['total_data'] / $bill_data['bill_quota'] * 100), 2);
|
||||
$total['bg'] = get_percentage_colours($total['per']);
|
||||
|
||||
echo("<h3>Billed Ports</h3>");
|
||||
$in['data'] = format_bytes_billing($bill_data['total_data_in']);
|
||||
$in['allow'] = $total['allow'];
|
||||
$in['ave'] = format_bytes_billing(($bill_data['total_data_in'] / $cur_days));
|
||||
$in['est'] = format_bytes_billing(($bill_data['total_data_in'] / $cur_days * $total_days));
|
||||
$in['per'] = round(($bill_data['total_data_in'] / $bill_data['total_data'] * 100), 2);
|
||||
$in['bg'] = get_percentage_colours($in['per']);
|
||||
|
||||
foreach ($ports as $port)
|
||||
{
|
||||
echo(generate_port_link($port) . " on " . generate_device_link($port) . "<br />");
|
||||
}
|
||||
$out['data'] = format_bytes_billing($bill_data['total_data_out']);
|
||||
$out['allow'] = $total['allow'];
|
||||
$out['ave'] = format_bytes_billing(($bill_data['total_data_out'] / $cur_days));
|
||||
$out['est'] = format_bytes_billing(($bill_data['total_data_out'] / $cur_days * $total_days));
|
||||
$out['per'] = round(($bill_data['total_data_out'] / $bill_data['total_data'] * 100), 2);
|
||||
$out['bg'] = get_percentage_colours($out['per']);
|
||||
|
||||
$cur_days = date('d', (strtotime("now") - strtotime($datefrom)));
|
||||
$total_days = date('d', (strtotime($dateto) - strtotime($datefrom)));
|
||||
$ousage['over'] = ($bill_data['total_data'] - ($bill_data['bill_quota']));
|
||||
$ousage['over'] = (($ousage['over'] < 0) ? '0' : $ousage['over']);
|
||||
$ousage['data'] = format_number($ousage['over'], $config['billing']['base']);
|
||||
$ousage['allow'] = $total['allow'];
|
||||
$ousage['ave'] = format_bytes_billing(($ousage['over'] / $cur_days));
|
||||
$ousage['est'] = format_bytes_billing(($ousage['over'] / $cur_days * $total_days));
|
||||
$ousage['per'] = round((($bill_data['total_data'] / $bill_data['bill_quota'] * 100) - 100), 2);
|
||||
$ousage['per'] = (($ousage['per'] < 0) ? '0' : $ousage['per']);
|
||||
$ousage['bg'] = get_percentage_colours($ousage['per']);
|
||||
|
||||
$total['data'] = format_bytes_billing($bill_data['total_data']);
|
||||
if ($bill_data['bill_type'] == "quota") {
|
||||
$total['allow'] = format_bytes_billing($bill_data['bill_quota']);
|
||||
} else {
|
||||
$total['allow'] = "-";
|
||||
}
|
||||
$total['ave'] = format_bytes_billing($bill_data['total_data'] / $cur_days);
|
||||
$total['est'] = format_bytes_billing($bill_data['total_data'] / $cur_days * $total_days);
|
||||
$total['per'] = round(($bill_data['total_data'] / $bill_data['bill_quota'] * 100), 2);
|
||||
$total['bg'] = get_percentage_colours($total['per']);
|
||||
|
||||
$in['data'] = format_bytes_billing($bill_data['total_data_in']);
|
||||
$in['allow'] = $total['allow'];
|
||||
$in['ave'] = format_bytes_billing($bill_data['total_data_in'] / $cur_days);
|
||||
$in['est'] = format_bytes_billing($bill_data['total_data_in'] / $cur_days * $total_days);
|
||||
$in['per'] = round(($bill_data['total_data_in'] / $bill_data['total_data'] * 100), 2);
|
||||
$in['bg'] = get_percentage_colours($in['per']);
|
||||
|
||||
$out['data'] = format_bytes_billing($bill_data['total_data_out']);
|
||||
$out['allow'] = $total['allow'];
|
||||
$out['ave'] = format_bytes_billing($bill_data['total_data_out'] / $cur_days);
|
||||
$out['est'] = format_bytes_billing($bill_data['total_data_out'] / $cur_days * $total_days);
|
||||
$out['per'] = round(($bill_data['total_data_out'] / $bill_data['total_data'] * 100), 2);
|
||||
$out['bg'] = get_percentage_colours($out['per']);
|
||||
|
||||
$ousage['over'] = $bill_data['total_data'] - ($bill_data['bill_quota']);
|
||||
$ousage['over'] = (($ousage['over'] < 0) ? "0" : $ousage['over']);
|
||||
$ousage['data'] = format_number($ousage['over'] , $config['billing']['base']);
|
||||
$ousage['allow'] = $total['allow'];
|
||||
$ousage['ave'] = format_bytes_billing($ousage['over'] / $cur_days );
|
||||
$ousage['est'] = format_bytes_billing($ousage['over'] / $cur_days * $total_days);
|
||||
$ousage['per'] = round((($bill_data['total_data'] / $bill_data['bill_quota'] * 100) - 100), 2);
|
||||
$ousage['per'] = (($ousage['per'] < 0) ? "0" : $ousage['per']);
|
||||
$ousage['bg'] = get_percentage_colours($ousage['per']);
|
||||
|
||||
function showPercent($per) {
|
||||
function showPercent($per) {
|
||||
$background = get_percentage_colours($per);
|
||||
$right_background = $background['right'];
|
||||
$left_background = $background['left'];
|
||||
$res = print_percentage_bar(350, 20, $per, NULL, "ffffff", $left_background, $per."%", "ffffff", $right_background);
|
||||
$res = print_percentage_bar(350, 20, $per, null, 'ffffff', $left_background, $per.'%', 'ffffff', $right_background);
|
||||
return $res;
|
||||
}
|
||||
|
||||
echo("<h3>Bill Summary</h3>");
|
||||
echo("<h4>Quota Bill</h4>");
|
||||
echo("<table cellpadding=\"5\" cellspacing=\"0\" border=\"0\" class=\"devicetable\">");
|
||||
echo(" <tr><td colspan=\"7\">Billing Period from ".$fromtext." to ".$totext."</td></tr>");
|
||||
echo(" <tr style=\"font-weight: bold;\">");
|
||||
echo(" <td width=\"125\">Bandwidth</td>");
|
||||
echo(" <td width=\"10\"></td>");
|
||||
echo(" <td width=\"100\">Used</td>");
|
||||
echo(" <td width=\"100\">Allowed</td>");
|
||||
echo(" <td width=\"100\">Average</td>");
|
||||
echo(" <td width=\"100\">Estimated</td>");
|
||||
echo(" <td width=\"360\"></td>");
|
||||
echo(" </tr>");
|
||||
echo(" <tr style=\"background: ".$list_colour_b.";\">");
|
||||
echo(" <td>Transferred</td>");
|
||||
echo(" <td>:</td>");
|
||||
echo(" <td>".$total['data']."</td>");
|
||||
echo(" <td>".$total['allow']."</td>");
|
||||
echo(" <td>".$total['ave']."</td>");
|
||||
echo(" <td>".$total['est']."</td>");
|
||||
echo(" <td width=\"360\">".showPercent($total['per'])."</td>");
|
||||
echo(" </tr>");
|
||||
}//end showPercent()
|
||||
|
||||
echo(" <tr style=\"background: ".$list_colour_a.";\">");
|
||||
echo(" <td>Inbound</td>");
|
||||
echo(" <td>:</td>");
|
||||
echo(" <td>".$in['data']."</td>");
|
||||
echo(" <td>".$in['allow']."</td>");
|
||||
echo(" <td>".$in['ave']."</td>");
|
||||
echo(" <td>".$in['est']."</td>");
|
||||
echo(" <td>".showPercent($in['per'])."</td>");
|
||||
echo(" </tr>");
|
||||
echo(" <tr style=\"background: ".$list_colour_b.";\">");
|
||||
echo(" <td>Outbound</td>");
|
||||
echo(" <td>:</td>");
|
||||
echo(" <td>".$out['data']."</td>");
|
||||
echo(" <td>".$out['allow']."</td>");
|
||||
echo(" <td>".$out['ave']."</td>");
|
||||
echo(" <td>".$out['est']."</td>");
|
||||
echo(" <td>".showPercent($out['per'])."</td>");
|
||||
echo(" </tr>");
|
||||
if ($ousage['over'] > 0 && $bill_data['bill_type'] == "quota") {
|
||||
echo(" <tr style=\"background: ".$list_colour_a.";\">");
|
||||
echo(" <td>Already overusage</td>");
|
||||
echo(" <td>:</td>");
|
||||
echo(" <td><span style=\"color: #".$total['bg']['left']."; font-weight: bold;\">".$ousage['data']."</span></td>");
|
||||
echo(" <td>".$ousage['allow']."</td>");
|
||||
echo(" <td>".$ousage['ave']."</td>");
|
||||
echo(" <td>".$ousage['est']."</td>");
|
||||
echo(" <td>".showPercent($ousage['per'])."</td>");
|
||||
}
|
||||
echo("</table>");
|
||||
|
||||
$bi = "<img src='bandwidth-graph.php?bill_id=" . $bill_id . "&bill_code=" . $_GET['bill_code'];
|
||||
$bi .= "&from=" . $unixfrom . "&to=" . $unixto;
|
||||
$bi .= "&type=day&imgbill=1";
|
||||
$bi .= "&x=1190&y=250";
|
||||
$bi .= "$type'>";
|
||||
echo '<h3>Bill Summary</h3>';
|
||||
echo '<h4>Quota Bill</h4>';
|
||||
echo '<table cellpadding="5" cellspacing="0" border="0" class="devicetable">';
|
||||
echo ' <tr><td colspan="7">Billing Period from '.$fromtext.' to '.$totext.'</td></tr>';
|
||||
echo ' <tr style="font-weight: bold;">';
|
||||
echo ' <td width="125">Bandwidth</td>';
|
||||
echo ' <td width="10"></td>';
|
||||
echo ' <td width="100">Used</td>';
|
||||
echo ' <td width="100">Allowed</td>';
|
||||
echo ' <td width="100">Average</td>';
|
||||
echo ' <td width="100">Estimated</td>';
|
||||
echo ' <td width="360"></td>';
|
||||
echo ' </tr>';
|
||||
echo ' <tr style="background: '.$list_colour_b.';">';
|
||||
echo ' <td>Transferred</td>';
|
||||
echo ' <td>:</td>';
|
||||
echo ' <td>'.$total['data'].'</td>';
|
||||
echo ' <td>'.$total['allow'].'</td>';
|
||||
echo ' <td>'.$total['ave'].'</td>';
|
||||
echo ' <td>'.$total['est'].'</td>';
|
||||
echo ' <td width="360">'.showPercent($total['per']).'</td>';
|
||||
echo ' </tr>';
|
||||
|
||||
$li = "<img src='bandwidth-graph.php?bill_id=" . $bill_id . "&bill_code=" . $_GET['bill_code'];
|
||||
$li .= "&from=" . $unix_prev_from . "&to=" . $unix_prev_to;
|
||||
$li .= "&type=day";
|
||||
$li .= "&x=1190&y=250";
|
||||
$li .= "$type'>";
|
||||
echo ' <tr style="background: '.$list_colour_a.';">';
|
||||
echo ' <td>Inbound</td>';
|
||||
echo ' <td>:</td>';
|
||||
echo ' <td>'.$in['data'].'</td>';
|
||||
echo ' <td>'.$in['allow'].'</td>';
|
||||
echo ' <td>'.$in['ave'].'</td>';
|
||||
echo ' <td>'.$in['est'].'</td>';
|
||||
echo ' <td>'.showPercent($in['per']).'</td>';
|
||||
echo ' </tr>';
|
||||
echo ' <tr style="background: '.$list_colour_b.';">';
|
||||
echo ' <td>Outbound</td>';
|
||||
echo ' <td>:</td>';
|
||||
echo ' <td>'.$out['data'].'</td>';
|
||||
echo ' <td>'.$out['allow'].'</td>';
|
||||
echo ' <td>'.$out['ave'].'</td>';
|
||||
echo ' <td>'.$out['est'].'</td>';
|
||||
echo ' <td>'.showPercent($out['per']).'</td>';
|
||||
echo ' </tr>';
|
||||
if ($ousage['over'] > 0 && $bill_data['bill_type'] == 'quota') {
|
||||
echo ' <tr style="background: '.$list_colour_a.';">';
|
||||
echo ' <td>Already overusage</td>';
|
||||
echo ' <td>:</td>';
|
||||
echo ' <td><span style="color: #'.$total['bg']['left'].'; font-weight: bold;">'.$ousage['data'].'</span></td>';
|
||||
echo ' <td>'.$ousage['allow'].'</td>';
|
||||
echo ' <td>'.$ousage['ave'].'</td>';
|
||||
echo ' <td>'.$ousage['est'].'</td>';
|
||||
echo ' <td>'.showPercent($ousage['per']).'</td>';
|
||||
}
|
||||
|
||||
$di = "<img src='bandwidth-graph.php?bill_id=" . $bill_id . "&bill_code=" . $_GET['bill_code'];
|
||||
$di .= "&from=" . $config['time']['day'] . "&to=" . $config['time']['now'];
|
||||
$di .= "&type=hour";
|
||||
$di .= "&x=1190&y=250";
|
||||
$di .= "$type'>";
|
||||
echo '</table>';
|
||||
|
||||
$mi = "<img src='bandwidth-graph.php?bill_id=" . $bill_id . "&bill_code=" . $_GET['bill_code'];
|
||||
$mi .= "&from=" . $lastmonth . "&to=" . $rightnow;
|
||||
$mi .= "&&type=day";
|
||||
$mi .= "&x=1190&y=250";
|
||||
$mi .= "$type'>";
|
||||
$bi = "<img src='bandwidth-graph.php?bill_id=".$bill_id.'&bill_code='.$_GET['bill_code'];
|
||||
$bi .= '&from='.$unixfrom.'&to='.$unixto;
|
||||
$bi .= '&type=day&imgbill=1';
|
||||
$bi .= '&x=1190&y=250';
|
||||
$bi .= "$type'>";
|
||||
|
||||
echo("<h3>Billing Period View</h3>$bi");
|
||||
echo("<h3>Rolling 24 Hour View</h3>$di");
|
||||
echo("<h3>Rolling Monthly View</h3>$mi");
|
||||
$li = "<img src='bandwidth-graph.php?bill_id=".$bill_id.'&bill_code='.$_GET['bill_code'];
|
||||
$li .= '&from='.$unix_prev_from.'&to='.$unix_prev_to;
|
||||
$li .= '&type=day';
|
||||
$li .= '&x=1190&y=250';
|
||||
$li .= "$type'>";
|
||||
|
||||
?>
|
||||
$di = "<img src='bandwidth-graph.php?bill_id=".$bill_id.'&bill_code='.$_GET['bill_code'];
|
||||
$di .= '&from='.$config['time']['day'].'&to='.$config['time']['now'];
|
||||
$di .= '&type=hour';
|
||||
$di .= '&x=1190&y=250';
|
||||
$di .= "$type'>";
|
||||
|
||||
$mi = "<img src='bandwidth-graph.php?bill_id=".$bill_id.'&bill_code='.$_GET['bill_code'];
|
||||
$mi .= '&from='.$lastmonth.'&to='.$rightnow;
|
||||
$mi .= '&&type=day';
|
||||
$mi .= '&x=1190&y=250';
|
||||
$mi .= "$type'>";
|
||||
|
||||
echo "<h3>Billing Period View</h3>$bi";
|
||||
echo "<h3>Rolling 24 Hour View</h3>$di";
|
||||
echo "<h3>Rolling Monthly View</h3>$mi";
|
||||
|
Reference in New Issue
Block a user