Billed Ports';
foreach ($ports as $port) {
    echo generate_port_link($port).' on '.generate_device_link($port).'
';
}
$cur_days   = date('d', (strtotime('now') - strtotime($datefrom)));
$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 {
    $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) {
    $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);
    return $res;
}//end showPercent()
echo '
| Bandwidth'; echo ' | '; echo ' | Used'; echo ' | Allowed'; echo ' | Average'; echo ' | Estimated'; echo ' | '; echo ' | 
| Transferred'; echo ' | :'; echo ' | '.$total['data'].''; echo ' | '.$total['allow'].''; echo ' | '.$total['ave'].''; echo ' | '.$total['est'].''; echo ' | '.showPercent($total['per']).''; echo ' | 
| Inbound'; echo ' | :'; echo ' | '.$in['data'].''; echo ' | '.$in['allow'].''; echo ' | '.$in['ave'].''; echo ' | '.$in['est'].''; echo ' | '.showPercent($in['per']).''; echo ' | 
| Outbound'; echo ' | :'; echo ' | '.$out['data'].''; echo ' | '.$out['allow'].''; echo ' | '.$out['ave'].''; echo ' | '.$out['est'].''; echo ' | '.showPercent($out['per']).''; echo ' | 
| Already overusage'; echo ' | :'; echo ' | '.$ousage['data'].''; echo ' | '.$ousage['allow'].''; echo ' | '.$ousage['ave'].''; echo ' | '.$ousage['est'].''; echo ' | '.showPercent($ousage['per']).''; } echo ' |