PSR2 Cleanup: /html edition

Travis tests for code conformance. Ignore warnings for now.
Fixed all errors, left most warnings.
This commit is contained in:
Tony Murray
2016-08-18 20:28:22 -05:00
parent f0c82498b5
commit 8c639aa5a4
468 changed files with 6605 additions and 7629 deletions

View File

@@ -101,6 +101,6 @@ if ($_POST['action'] == 'update_bill') {
'`bill_id` = ?',
array($bill_id)
)) {
print_message('Bill Properties Updated');
print_message('Bill Properties Updated');
}
}//end if

View File

@@ -1,90 +1,94 @@
<h4>Bill Information</h4>
<div class="form-group">
<label for="bill_name" class="col-sm-4 control-label">Description</label>
<div class="col-sm-8">
<input class="form-control input-sm" type="text" id="bill_name" name="bill_name" value="<?php echo $bill_data['bill_name']; ?>">
</div>
</div>
<div class="form-group">
<label class="col-sm-4 control-label" for="bill_type">Billing Type</label>
<div class="col-sm-8">
<label class="radio-inline">
<input type="radio" name="bill_type" id="bill_type_cdr" value="cdr" <?php if ($bill_data['bill_type'] == 'cdr') { echo "checked"; } ?> onchange="javascript: billType();" /> CDR 95th
</label>
<label class="radio-inline">
<input type="radio" name="bill_type" id="bill_type_quota" value="quota" <?php if ($bill_data['bill_type'] == 'quota') { echo "checked"; } ?> onchange="javascript: billType();" /> Quota
</label>
</div>
</div>
<div class="form-group">
<div id="cdrDiv">
<label class="col-sm-4 control-label" for="bill_cdr">CDR</label>
<div class="col-sm-3">
<input class="form-control input-sm" type="text" name="bill_cdr" value="<?php echo $cdr['data'] ?>">
</div>
<div class="col-sm-5">
<select name="bill_cdr_type" class="form-control input-sm">
<option <?php echo $cdr['select_kbps'] ?> value="Kbps">Kilobits per second (Kbps)</option>
<option <?php echo $cdr['select_mbps'] ?> value="Mbps">Megabits per second (Mbps)</option>
<option <?php echo $cdr['select_gbps'] ?> value="Gbps">Gigabits per second (Gbps)</option>
</select>
</div>
</div>
<div id="quotaDiv">
<label class="col-sm-4 control-label" for="bill_quota">Quota</label>
<div class="col-sm-3">
<input class="form-control input-sm" type="text" name="bill_quota" value="<?php echo $quota['data'] ?>">
</div>
<div class="col-sm-5">
<select name="bill_quota_type" class="form-control input-sm">
<option <?php echo $quota['select_mb'] ?> value="MB">Megabytes (MB)</option>
<option <?php echo $quota['select_gb'] ?> value="GB">Gigabytes (GB)</option>
<option <?php echo $quota['select_tb'] ?> value="TB">Terabytes (TB)</option>
</select>
</div>
</div>
</div>
<div class="form-group">
<label class="col-sm-4 control-label" for="bill_day">Billing Day</label>
<div class="col-sm-2">
<select name="bill_day" class="form-control input-sm">
<?php
for ($x = 1; $x < 32; $x++) {
$sel = $bill_data['bill_day'] == $x ? "selected " : "";
echo "<option $sel value='$x'>$x</option>\n";
}
?>
</select>
</div>
</div>
<fieldset>
<h4>Optional Information</h4>
<div class="form-group">
<label class="col-sm-4 control-label" for="bill_custid">Customer Reference</label>
<div class="col-sm-8">
<input class="form-control input-sm" type="text" name="bill_custid" value="<?php echo $bill_data['bill_custid'] ?>">
</div>
</div>
<div class="form-group">
<label class="col-sm-4 control-label" for="bill_ref">Billing Reference</label>
<div class="col-sm-8">
<input class="form-control input-sm" type="text" name="bill_ref" value="<?php echo $bill_data['bill_ref']; ?>">
</div>
</div>
<div class="form-group">
<label class="col-sm-4 control-label" for="bill_notes">Notes</label>
<div class="col-sm-8">
<input class="form-control input-sm" type="textarea" name="bill_notes" value="<?php echo $bill_data['bill_notes']; ?>">
</div>
</div>
</fieldset>
<script type="text/javascript">
function billType() {
var selected = $('input[name=bill_type]:checked').val();
$('#cdrDiv').toggle(selected === 'cdr');
$('#quotaDiv').toggle(selected === 'quota');
}
billType();
</script>
<h4>Bill Information</h4>
<div class="form-group">
<label for="bill_name" class="col-sm-4 control-label">Description</label>
<div class="col-sm-8">
<input class="form-control input-sm" type="text" id="bill_name" name="bill_name" value="<?php echo $bill_data['bill_name']; ?>">
</div>
</div>
<div class="form-group">
<label class="col-sm-4 control-label" for="bill_type">Billing Type</label>
<div class="col-sm-8">
<label class="radio-inline">
<input type="radio" name="bill_type" id="bill_type_cdr" value="cdr" <?php if ($bill_data['bill_type'] == 'cdr') {
echo "checked";
} ?> onchange="javascript: billType();" /> CDR 95th
</label>
<label class="radio-inline">
<input type="radio" name="bill_type" id="bill_type_quota" value="quota" <?php if ($bill_data['bill_type'] == 'quota') {
echo "checked";
} ?> onchange="javascript: billType();" /> Quota
</label>
</div>
</div>
<div class="form-group">
<div id="cdrDiv">
<label class="col-sm-4 control-label" for="bill_cdr">CDR</label>
<div class="col-sm-3">
<input class="form-control input-sm" type="text" name="bill_cdr" value="<?php echo $cdr['data'] ?>">
</div>
<div class="col-sm-5">
<select name="bill_cdr_type" class="form-control input-sm">
<option <?php echo $cdr['select_kbps'] ?> value="Kbps">Kilobits per second (Kbps)</option>
<option <?php echo $cdr['select_mbps'] ?> value="Mbps">Megabits per second (Mbps)</option>
<option <?php echo $cdr['select_gbps'] ?> value="Gbps">Gigabits per second (Gbps)</option>
</select>
</div>
</div>
<div id="quotaDiv">
<label class="col-sm-4 control-label" for="bill_quota">Quota</label>
<div class="col-sm-3">
<input class="form-control input-sm" type="text" name="bill_quota" value="<?php echo $quota['data'] ?>">
</div>
<div class="col-sm-5">
<select name="bill_quota_type" class="form-control input-sm">
<option <?php echo $quota['select_mb'] ?> value="MB">Megabytes (MB)</option>
<option <?php echo $quota['select_gb'] ?> value="GB">Gigabytes (GB)</option>
<option <?php echo $quota['select_tb'] ?> value="TB">Terabytes (TB)</option>
</select>
</div>
</div>
</div>
<div class="form-group">
<label class="col-sm-4 control-label" for="bill_day">Billing Day</label>
<div class="col-sm-2">
<select name="bill_day" class="form-control input-sm">
<?php
for ($x = 1; $x < 32; $x++) {
$sel = $bill_data['bill_day'] == $x ? "selected " : "";
echo "<option $sel value='$x'>$x</option>\n";
}
?>
</select>
</div>
</div>
<fieldset>
<h4>Optional Information</h4>
<div class="form-group">
<label class="col-sm-4 control-label" for="bill_custid">Customer Reference</label>
<div class="col-sm-8">
<input class="form-control input-sm" type="text" name="bill_custid" value="<?php echo $bill_data['bill_custid'] ?>">
</div>
</div>
<div class="form-group">
<label class="col-sm-4 control-label" for="bill_ref">Billing Reference</label>
<div class="col-sm-8">
<input class="form-control input-sm" type="text" name="bill_ref" value="<?php echo $bill_data['bill_ref']; ?>">
</div>
</div>
<div class="form-group">
<label class="col-sm-4 control-label" for="bill_notes">Notes</label>
<div class="col-sm-8">
<input class="form-control input-sm" type="textarea" name="bill_notes" value="<?php echo $bill_data['bill_notes']; ?>">
</div>
</div>
</fieldset>
<script type="text/javascript">
function billType() {
var selected = $('input[name=bill_type]:checked').val();
$('#cdrDiv').toggle(selected === 'cdr');
$('#quotaDiv').toggle(selected === 'quota');
}
billType();
</script>

View File

@@ -5,62 +5,58 @@
// Calculation to extract MB/GB/TB of Kbps/Mbps/Gbps
$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'],
);
}
}//end if
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
?>
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'],
);
}
}//end if
?>
<div class="row">
<div class="col-lg-6 col-md-12">
<div class="panel panel-default">
@@ -76,7 +72,7 @@
$('#quotaDiv').toggle();
}
</script>
<?php include 'pages/bill/addoreditbill.inc.php'; ?>
<?php include 'pages/bill/addoreditbill.inc.php'; ?>
<div class="form-group">
<div class="col-sm-offset-4 col-sm-4">
<button type="submit" class="btn btn-primary" name="Submit" value="Save" /><i class="fa fa-check"></i> Save Properties</button>
@@ -93,7 +89,7 @@
</div>
<div class="panel-body">
<div class="form-group">
<?php
<?php
//This needs a proper cleanup
$ports = dbFetchRows(
'SELECT * FROM `bill_ports` AS B, `ports` AS P, `devices` AS D
@@ -105,7 +101,7 @@
if (is_array($ports)) {
?>
<div class="list-group">
<?php foreach ($ports as $port) {
<?php foreach ($ports as $port) {
$emptyCheck = true;
$portalias = (empty($port['ifAlias']) ? '' : ' - '.$port['ifAlias'].'');
@@ -124,14 +120,14 @@
<i class="fa fa-random"></i>
<?php echo generate_port_link($port, $port['ifName'] . '' . $portalias); ?>
</div>
<?php }
if (!$emptyCheck) { ?>
<?php }
if (!$emptyCheck) { ?>
<div class="alert alert-info">There are no ports assigned to this bill</alert>
<?php } ?>
<?php } ?>
</div>
<?php
<?php
}
?>
</div>
@@ -149,11 +145,11 @@
<option value=''>Select a device</option>
<?php
$devices = dbFetchRows('SELECT * FROM `devices` ORDER BY hostname');
foreach ($devices as $device) {
echo "<option value='${device['device_id']}'>${device['hostname']}</option>\n";
}
foreach ($devices as $device) {
echo "<option value='${device['device_id']}'>${device['hostname']}</option>\n";
}
?>
?>
</select>
</div>
</div>

View File

@@ -20,19 +20,18 @@ $img['his'] .= '" style="margin: 15px 5px 25px 5px;" />';
<?php echo $img['his'] ?>
</div>
<?php
<?php
function showDetails($bill_id, $imgtype, $bill_hist_id, $bittype='Quota') {
function showDetails($bill_id, $imgtype, $bill_hist_id, $bittype = 'Quota')
{
if ($imgtype == 'bitrate') {
$res = '<img src="billing-graph.php?bill_id='.$bill_id;
if ($bittype == 'Quota') {
$res .= '&amp;ave=yes';
}
else if ($bittype == 'CDR') {
} elseif ($bittype == 'CDR') {
$res .= '&amp;95th=yes';
}
}
else {
} else {
$res = '<img src="bandwidth-graph.php?bill_id='.$bill_id;
}
@@ -42,7 +41,6 @@ function showDetails($bill_id, $imgtype, $bill_hist_id, $bittype='Quota') {
$res .= '&amp;bill_hist_id='.$bill_hist_id;
$res .= '" style="margin: 15px 5px 25px 5px;" />';
return $res;
}//end showDetails()
@@ -87,8 +85,7 @@ foreach (dbFetchRows('SELECT * FROM `bill_history` WHERE `bill_id` = ? ORDER BY
$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') {
} 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']);

View File

@@ -35,8 +35,7 @@ foreach (dbFetchRows('SELECT * FROM `bill_hist` WHERE `bill_id`= ? AND `id` = ?
$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 {
} 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']));
@@ -91,33 +90,32 @@ $html .= $css;
// 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)));
return $res;
}//end gbConvert()
// Generate graphs
function genGraphs($bill_id, $imgtype, $from, $to, $bittype='Quota') {
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') {
} elseif ($bittype == 'CDR') {
$res .= '&95th=yes';
}
}
else {
} else {
$res .= 'bandwidth-graph.php?bill_id='.$bill_id;
}
@@ -129,14 +127,14 @@ function genGraphs($bill_id, $imgtype, $from, $to, $bittype='Quota') {
}
return $res;
}//end genGraphs()
// Device Information
function listBillPorts($bill_id) {
function listBillPorts($bill_id)
{
$device = array();
$res = '';
$res .= '<table>';
@@ -170,14 +168,14 @@ function listBillPorts($bill_id) {
$res .= '</table>';
return $res;
}//end listBillPorts()
// Bitrate Graph overview
function graphOverviewBitrate($bill_id, $history) {
function graphOverviewBitrate($bill_id, $history)
{
global $pdf;
$img = array();
@@ -186,14 +184,14 @@ function graphOverviewBitrate($bill_id, $history) {
$res = '';
$res .= '<tcpdf method="Image" params="'.$bitrate.'" />';
return $res;
}//end graphOverviewBitrate()
// Transfer Graph overview
function graphOverviewTransfer($bill_id, $history) {
function graphOverviewTransfer($bill_id, $history)
{
global $pdf;
$img = array();
@@ -205,14 +203,14 @@ function graphOverviewTransfer($bill_id, $history) {
$res .= '<tcpdf method="Image" params="'.$bw_day.'" />';
$res .= '<tcpdf method="Image" params="'.$bw_hour.'" />';
return $res;
}//end graphOverviewTransfer()
// Transfer overview
function transferOverview($bill_id, $history) {
function transferOverview($bill_id, $history)
{
global $list_colour_a, $list_colour_b, $config;
$i = 0;
@@ -258,7 +256,6 @@ function transferOverview($bill_id, $history) {
$res .= ' </tr>';
$res .= '</table>';
return $res;
}//end transferOverview()

View File

@@ -36,8 +36,7 @@ $total_days = date('d', (strtotime($dateto) - strtotime($datefrom)));
$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 {
} else {
$total['allow'] = '-';
}
@@ -71,13 +70,13 @@ $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(200, 20, $per, null, 'ffffff', $left_background, $per.'%', 'ffffff', $right_background);
return $res;
}//end showPercent()
?>
@@ -152,7 +151,7 @@ function showPercent($per) {
<?php
<?php
$bi = "<img src='bandwidth-graph.php?bill_id=".$bill_id.'&amp;bill_code='.$_GET['bill_code'];
$bi .= '&amp;from='.$unixfrom.'&amp;to='.$unixto;
$bi .= '&amp;type=day&imgbill=1';