Fix coding style part 2

This commit is contained in:
Job Snijders
2015-07-13 20:10:26 +02:00
parent ad9590df9b
commit d8693f05ae
733 changed files with 37359 additions and 33947 deletions

View File

@@ -1,75 +1,71 @@
<?php
$pagetitle[] = "Previous Billing Period";
$i=0;
$pagetitle[] = 'Previous Billing Period';
$i = 0;
echo('<table class="table table-condensed">
<tr>
<th>Billing name</th>
<th>Type</th>
<th>Allowed</th>
<th>Inbound</th>
<th>Outbound</th>
<th>Total</th>
<th>95 percentile</th>
<th>Overusage</th>
<th></th>
</tr>');
echo '<table class="table table-condensed">
<tr>
<th>Billing name</th>
<th>Type</th>
<th>Allowed</th>
<th>Inbound</th>
<th>Outbound</th>
<th>Total</th>
<th>95 percentile</th>
<th>Overusage</th>
<th></th>
</tr>';
foreach (dbFetchRows("SELECT * FROM `bills` ORDER BY `bill_name`") as $bill)
{
if (bill_permitted($bill['bill_id']))
{
$day_data = getDates($bill['bill_day']);
$datefrom = $day_data['2'];
$dateto = $day_data['3'];
foreach (dbFetchRows("SELECT * FROM `bill_history` WHERE `bill_id` = ? AND `bill_datefrom` = ? ORDER BY `bill_datefrom` LIMIT 1", array($bill['bill_id'], $datefrom, $dateto)) as $history)
{
unset($class);
$type = $history['bill_type'];
$percent = $history['bill_percent'];
$dir_95th = $history['dir_95th'];
$rate_95th = format_si($history['rate_95th'])."bps";
$total_data = format_bytes_billing($history['traf_total']);
foreach (dbFetchRows('SELECT * FROM `bills` ORDER BY `bill_name`') as $bill) {
if (bill_permitted($bill['bill_id'])) {
$day_data = getDates($bill['bill_day']);
$datefrom = $day_data['2'];
$dateto = $day_data['3'];
foreach (dbFetchRows('SELECT * FROM `bill_history` WHERE `bill_id` = ? AND `bill_datefrom` = ? ORDER BY `bill_datefrom` LIMIT 1', array($bill['bill_id'], $datefrom, $dateto)) as $history) {
unset($class);
$type = $history['bill_type'];
$percent = $history['bill_percent'];
$dir_95th = $history['dir_95th'];
$rate_95th = format_si($history['rate_95th']).'bps';
$total_data = format_bytes_billing($history['traf_total']);
$background = get_percentage_colours($percent);
$row_colour = ((!is_integer($i/2)) ? $list_colour_a : $list_colour_b);
$background = get_percentage_colours($percent);
$row_colour = ((!is_integer($i / 2)) ? $list_colour_a : $list_colour_b);
if ($type == "CDR")
{
$allowed = format_si($history['bill_allowed'])."bps";
$used = format_si($history['rate_95th'])."bps";
$in = format_si($history['rate_95th_in'])."bps";
$out = format_si($history['rate_95th_out'])."bps";
$overuse = (($history['bill_overuse'] <= 0) ? "-" : "<span style=\"color: #".$background['left']."; font-weight: bold;\">".format_si($history['bill_overuse'])."bps</span>");
} elseif ($type == "Quota") {
$allowed = format_bytes_billing($history['bill_allowed']);
$used = format_bytes_billing($history['total_data']);
$in = format_bytes_billing($history['traf_in']);
$out = format_bytes_billing($history['traf_out']);
$overuse = (($history['bill_overuse'] <= 0) ? "-" : "<span style=\"color: #".$background['left']."; font-weight: bold;\">".format_bytes_billing($history['bill_overuse'])."</span>");
}
if ($type == 'CDR') {
$allowed = format_si($history['bill_allowed']).'bps';
$used = format_si($history['rate_95th']).'bps';
$in = format_si($history['rate_95th_in']).'bps';
$out = format_si($history['rate_95th_out']).'bps';
$overuse = (($history['bill_overuse'] <= 0) ? '-' : '<span style="color: #'.$background['left'].'; font-weight: bold;">'.format_si($history['bill_overuse']).'bps</span>');
}
else if ($type == 'Quota') {
$allowed = format_bytes_billing($history['bill_allowed']);
$used = format_bytes_billing($history['total_data']);
$in = format_bytes_billing($history['traf_in']);
$out = format_bytes_billing($history['traf_out']);
$overuse = (($history['bill_overuse'] <= 0) ? '-' : '<span style="color: #'.$background['left'].'; font-weight: bold;">'.format_bytes_billing($history['bill_overuse']).'</span>');
}
$total_data = (($type == "Quota") ? "<b>".$total_data."</b>" : $total_data);
$rate_95th = (($type == "CDR") ? "<b>".$rate_95th."</b>" : $rate_95th);
$total_data = (($type == 'Quota') ? '<b>'.$total_data.'</b>' : $total_data);
$rate_95th = (($type == 'CDR') ? '<b>'.$rate_95th.'</b>' : $rate_95th);
echo("
<tr style=\"background: $row_colour;\">
<td><a href=\"".generate_url(array('page' => "bill", 'bill_id' => $bill['bill_id']))."\"><span style=\"font-weight: bold;\" class=\"interface\">".$bill['bill_name']."</a></span><br />from ".strftime("%x", strtotime($datefrom))." to ".strftime("%x", strtotime($dateto))."</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>".print_percentage_bar (250, 20, $perc, NULL, "ffffff", $background['left'], $percent . "%", "ffffff", $background['right'])."</td>
</tr>");
echo "
<tr style=\"background: $row_colour;\">
<td><a href=\"".generate_url(array('page' => 'bill', 'bill_id' => $bill['bill_id'])).'"><span style="font-weight: bold;" class="interface">'.$bill['bill_name'].'</a></span><br />from '.strftime('%x', strtotime($datefrom)).' to '.strftime('%x', strtotime($dateto))."</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>".print_percentage_bar(250, 20, $perc, null, 'ffffff', $background['left'], $percent.'%', 'ffffff', $background['right']).'</td>
</tr>';
$i++;
} // PERMITTED
}
}
echo("</table>");
$i++;
} //end foreach
}//end if
}//end foreach
?>
echo '</table>';

View File

@@ -9,7 +9,7 @@
Bills
</div>
<div class="form-group">
<input type="text" name="hostname" id="hostname" class="form-control input-sm" value="<?php echo($_POST['hostname']); ?>" />
<input type="text" name="hostname" id="hostname" class="form-control input-sm" value="<?php echo $_POST['hostname']; ?>" />
</div>
<div class="form-group">
<select name='os' id='os' class="form-control input-sm">
@@ -34,15 +34,13 @@
<button type="submit" class="btn btn-default input-sm">Search</button>
<div class="form-group">
<?php
if ($vars['view'] == "history")
{
echo('<a href="bills/"><img src="images/16/clock.png" align=absmiddle alt="Current Billing Period"> Current Billing Period</a>');
} else
{
if ($vars['view'] == 'history') {
echo '<a href="bills/"><img src="images/16/clock.png" align=absmiddle alt="Current Billing Period"> Current Billing Period</a>';
}
else {
// FIXME - generate_url
echo('<a href="bills/view=history/"><img src="images/16/clock_red.png" align=absmiddle alt="Previous Billing Period"> Previous Billing Period</a>');
}
echo '<a href="bills/view=history/"><img src="images/16/clock_red.png" align=absmiddle alt="Previous Billing Period"> Previous Billing Period</a>';
}
?>
</div>
@@ -52,7 +50,4 @@
</form>
<?php
print_optionbar_end();
?>
print_optionbar_end();