$_POST['bill_name'], 'bill_type' => $_POST['bill_type'], 'bill_cdr' => $_POST['bill_cdr'], 'bill_day' => $_POST['bill_day'], 'bill_gb' => $_POST['bill_quota'],
'bill_custid' => $_POST['bill_custid'], 'bill_ref' => $_POST['bill_ref'], 'bill_notes' => $_POST['bill_notes']);
$affected = dbInsert($insert, 'bills');
$message .= $message_break . "Bill ".mres($_POST['bill_name'])." added!";
$message_break .= "
";
}
$pagetitle[] = "Billing";
echo("");
if ($_GET['opta'] == "history")
{
include("pages/bills/search.inc.php");
include("pages/bills/pmonth.inc.php");
}
elseif ($_GET['opta'] == "add")
{
?>
Add Bill
|
Billing name |
|
Type |
Allowed |
Used |
Overusage |
|
|
");
foreach (dbFetchRows("SELECT * FROM `bills` ORDER BY `bill_name`") as $bill)
{
if (bill_permitted($bill['bill_id']))
{
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_data = $bill;
$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);
$background = get_percentage_colours($percent);
$overuse = $rate_data['rate_95th'] - $bill['bill_cdr'];
$overuse = (($overuse <= 0) ? "-" : "".formatRates($overuse * 1000)."");
} elseif ($bill['bill_type'] == "quota") {
$type = "Quota";
$allowed = formatStorage($bill['bill_gb']* 1000 * 1000 * 1000);
$used = formatStorage($rate_data['total_data'] * 1000 * 1000);
$percent = round(($rate_data['total_data'] / ($bill['bill_gb'] * 1000)) * 100,2);
$background = get_percentage_colours($percent);
$overuse = $rate_data['total_data'] - ($bill['bill_gb'] * 1000);
$overuse = (($overuse <= 0) ? "-" : "".formatStorage($overuse * 1000 * 1000)."");
}
$right_background = $background['right'];
$left_background = $background['left'];
if (!is_integer($i/2)) { $row_colour = $list_colour_a; } else { $row_colour = $list_colour_b; }
echo("
|
"bill", 'bill_id' => $bill['bill_id']))."'>".$bill['bill_name']." ".strftime("%F", strtotime($datefrom))." to ".strftime("%F", strtotime($dateto))." |
$notes |
$type |
$allowed |
$used |
$overuse |
".print_percentage_bar (250, 20, $perc, NULL, "ffffff", $background['left'], $percent . "%", "ffffff", $background['right'])." |
"bill", 'bill_id' => $bill['bill_id'], 'view' => "edit"))."'> Edit |
");
$i++;
} ### PERMITTED
}
echo("");
}
echo("");
?>