";
}
echo("");
if($_GET['opta'] == "add") {
?>
Add Bill
	
");
  $i=1;
  while($bill = mysql_fetch_array($query)) {
    unset($class);
    $day_data     = getDates($bill['bill_day']);
    $datefrom     = $day_data['0'];
    $dateto       = $day_data['1'];
    $rate_data    = getRates($bill['bill_id'],$datefrom,$dateto);
    $rate_95th    = $rate_data['rate_95th'];
    $dir_95th     = $rate_data['dir_95th'];
    $total_data   = $rate_data['total_data'];
    $rate_average = $rate_data['rate_average'];
    if($bill['bill_type'] == "cdr") {
       $type = "CDR"; 
       $allowed = formatRates($bill['bill_cdr'] * 1000);
       $used    = formatRates($rate_data['rate_95th'] * 1000);
       $percent = round(($rate_data['rate_95th'] / $bill['bill_cdr']) * 100,2);
    } elseif ($bill['bill_type'] == "quota") { 
       $type = "Quota"; 
       $allowed = formatStorage($bill['bill_gb']* 1024 * 1024 * 1024);
       $used    = formatStorage($rate_data['total_data'] * 1024 * 1024);
       $percent = round(($rate_data['total_data'] / ($bill['bill_gb'] * 1024)) * 100,2);
    }
    if(!is_integer($i/2)) { $row_colour = $list_colour_a; } else { $row_colour = $list_colour_b; }
    echo("
           
             |  | ".$bill['bill_name']." | $notes | $type | $allowed | $used |  $percent% |  |  Edit | 
         ");
    $i++;
  }
  echo("");
}
echo("");
?>