mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
make billing usable (shonky interface it now has!)
git-svn-id: http://www.observium.org/svn/observer/trunk@1227 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
@@ -14,3 +14,4 @@ ALTER TABLE `temperature` CHANGE `temp_index` `temp_index` VARCHAR(32) NOT NU
|
|||||||
ALTER TABLE `ports` CHANGE `ifDescr` `ifDescr` VARCHAR(255) NOT NULL;
|
ALTER TABLE `ports` CHANGE `ifDescr` `ifDescr` VARCHAR(255) NOT NULL;
|
||||||
CREATE TABLE IF NOT EXISTS `ucd_diskio` ( `diskio_id` int(11) NOT NULL AUTO_INCREMENT, `device_id` int(11) NOT NULL, `diskio_index` int(11) NOT NULL, `diskio_descr` varchar(32) NOT NULL, PRIMARY KEY (`diskio_id`)) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=11 ;
|
CREATE TABLE IF NOT EXISTS `ucd_diskio` ( `diskio_id` int(11) NOT NULL AUTO_INCREMENT, `device_id` int(11) NOT NULL, `diskio_index` int(11) NOT NULL, `diskio_descr` varchar(32) NOT NULL, PRIMARY KEY (`diskio_id`)) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=11 ;
|
||||||
ALTER TABLE `eventlog` CHANGE `type` `type` VARCHAR( 64 ) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL;
|
ALTER TABLE `eventlog` CHANGE `type` `type` VARCHAR( 64 ) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL;
|
||||||
|
ALTER TABLE `bills` ADD `bill_custid` VARCHAR( 64 ) NOT NULL ,ADD `bill_ref` VARCHAR( 64 ) NOT NULL ,ADD `bill_notes` VARCHAR( 256 ) NOT NULL;
|
||||||
|
@@ -1,9 +1,20 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
include("../../includes/defaults.inc.php");
|
if($_GET['debug']) {
|
||||||
include("../../config.php");
|
ini_set('display_errors', 1);
|
||||||
include("../../includes/functions.php");
|
ini_set('display_startup_errors', 0);
|
||||||
include("../includes/authenticate.inc.php");
|
ini_set('log_errors', 0);
|
||||||
|
ini_set('allow_url_fopen', 0);
|
||||||
|
ini_set('error_reporting', E_ALL);
|
||||||
|
}
|
||||||
|
|
||||||
|
include("../includes/defaults.inc.php");
|
||||||
|
include("../config.php");
|
||||||
|
include("../includes/common.php");
|
||||||
|
include("../includes/rewrites.php");
|
||||||
|
include("includes/authenticate.inc.php");
|
||||||
|
|
||||||
|
|
||||||
if(!$_SESSION['authenticated']) { echo("unauthenticated"); exit; }
|
if(!$_SESSION['authenticated']) { echo("unauthenticated"); exit; }
|
||||||
|
|
||||||
if(isset($_GET['device_id'])){
|
if(isset($_GET['device_id'])){
|
@@ -1,9 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
#ini_set('display_errors', 1);
|
if($_GET['debug']) {
|
||||||
#ini_set('display_startup_errors', 1);
|
ini_set('display_errors', 1);
|
||||||
#ini_set('log_errors', 1);
|
ini_set('display_startup_errors', 0);
|
||||||
#ini_set('error_reporting', E_ALL);
|
ini_set('log_errors', 0);
|
||||||
|
ini_set('allow_url_fopen', 0);
|
||||||
|
ini_set('error_reporting', E_ALL);
|
||||||
|
} else { ini_set('display_errors', 0); }
|
||||||
|
|
||||||
include("../includes/defaults.inc.php");
|
include("../includes/defaults.inc.php");
|
||||||
include("../config.php");
|
include("../config.php");
|
||||||
@@ -146,6 +149,9 @@ while($row = mysql_fetch_array($data))
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#print_r($ticks);
|
||||||
|
#print_r($tot_data);
|
||||||
|
|
||||||
$graph_name = date('M j g:ia', $start) . " - " . date('M j g:ia', $last);
|
$graph_name = date('M j g:ia', $start) . " - " . date('M j g:ia', $last);
|
||||||
|
|
||||||
$n = count($ticks);
|
$n = count($ticks);
|
||||||
@@ -157,14 +163,14 @@ $graph_name = date('M j g:ia', $xmin) . " - " . date('M j g:ia', $xmax);
|
|||||||
|
|
||||||
$graph = new Graph($xsize, $ysize, $graph_name);
|
$graph = new Graph($xsize, $ysize, $graph_name);
|
||||||
$graph->img->SetImgFormat("png");
|
$graph->img->SetImgFormat("png");
|
||||||
$graph->img->SetAntiAliasing(true);
|
#$graph->img->SetAntiAliasing(true);
|
||||||
$graph->SetScale( "intlin");
|
$graph->SetScale( "intlin");
|
||||||
#$graph->SetScale('intlin',0,0,$xmin,$xmax);
|
#$graph->SetScale('intlin',0,0,$xmin,$xmax);
|
||||||
$graph->title->Set("$graph_name");
|
$graph->title->Set("$graph_name");
|
||||||
$graph->title->SetFont(FF_VERDANA,FS_BOLD);
|
$graph->title->SetFont(FF_FONT2,FS_BOLD,10);
|
||||||
$graph->xaxis->SetFont(FF_VERDANA,FS_NORMAL);
|
$graph->xaxis->SetFont(FF_FONT1,FS_BOLD);
|
||||||
|
|
||||||
#$graph->xaxis->SetTickLabels($ticks);
|
$graph->xaxis->SetTickLabels($ticks);
|
||||||
|
|
||||||
if(count($tickPositions) > 24) {
|
if(count($tickPositions) > 24) {
|
||||||
$graph->xaxis->SetTextLabelInterval(3);
|
$graph->xaxis->SetTextLabelInterval(3);
|
||||||
@@ -173,22 +179,22 @@ if(count($tickPositions) > 24) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$graph->xaxis->SetPos('min');
|
$graph->xaxis->SetPos('min');
|
||||||
$graph->xaxis->SetLabelAngle(15);
|
#$graph->xaxis->SetLabelAngle(15);
|
||||||
$graph->yaxis->HideZeroLabel(1);
|
$graph->yaxis->HideZeroLabel(1);
|
||||||
$graph->yaxis->SetFont(FF_VERDANA);
|
$graph->yaxis->SetFont(FF_FONT1);
|
||||||
$graph->yaxis->SetLabelAngle(0);
|
$graph->yaxis->SetLabelAngle(0);
|
||||||
$graph->xaxis->title->SetFont(FF_VERDANA,FS_NORMAL,10);
|
$graph->xaxis->title->SetFont(FF_FONT1,FS_NORMAL,10);
|
||||||
$graph->yaxis->title->SetFont(FF_VERDANA,FS_NORMAL,10);
|
$graph->yaxis->title->SetFont(FF_FONT1,FS_NORMAL,10);
|
||||||
$graph->yaxis->SetTitleMargin(50);
|
$graph->yaxis->SetTitleMargin(50);
|
||||||
$graph->xaxis->SetTitleMargin(30);
|
$graph->xaxis->SetTitleMargin(30);
|
||||||
#$graph->xaxis->HideLastTickLabel();
|
#$graph->xaxis->HideLastTickLabel();
|
||||||
$graph->xaxis->HideFirstTickLabel();
|
#$graph->xaxis->HideFirstTickLabel();
|
||||||
#$graph->yaxis->scale->SetAutoMin(1);
|
#$graph->yaxis->scale->SetAutoMin(1);
|
||||||
#$graph->xaxis->title->Set("$type");
|
#$graph->xaxis->title->Set("$type");
|
||||||
$graph->yaxis->title->Set("$yaxis");
|
$graph->yaxis->title->Set("$yaxis");
|
||||||
|
|
||||||
$graph->xaxis->SetTickPositions($tickPositions,$tickMinPositions,$tickLabels);
|
$graph->xaxis->SetTickPositions($tickPositions,$tickMinPositions,$tickLabels);
|
||||||
#$graph->xaxis->SetMajTickPositions($tickPositions,$tickLabels);
|
$graph->xaxis->SetMajTickPositions($tickPositions,$tickLabels);
|
||||||
|
|
||||||
$graph->ygrid->SetFill(true,'#EFEFEF@0.5','#FFFFFF@0.5');
|
$graph->ygrid->SetFill(true,'#EFEFEF@0.5','#FFFFFF@0.5');
|
||||||
$graph->xgrid->Show(true,true);
|
$graph->xgrid->Show(true,true);
|
||||||
@@ -196,7 +202,7 @@ $graph->xgrid->SetColor('#e0e0e0','#efefef');
|
|||||||
$graph->SetMarginColor('white');
|
$graph->SetMarginColor('white');
|
||||||
$graph->SetFrame(false);
|
$graph->SetFrame(false);
|
||||||
$graph->SetMargin(75,30,30,45);
|
$graph->SetMargin(75,30,30,45);
|
||||||
$graph->legend->SetFont(FF_VERDANA,FS_NORMAL);
|
$graph->legend->SetFont(FF_FONT1,FS_NORMAL);
|
||||||
|
|
||||||
$lineplot = new LinePlot($tot_data);
|
$lineplot = new LinePlot($tot_data);
|
||||||
#$lineplot->SetLegend("Traffic total");
|
#$lineplot->SetLegend("Traffic total");
|
||||||
|
28
html/includes/javascript-interfacepicker.inc.php
Normal file
28
html/includes/javascript-interfacepicker.inc.php
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
<script type="text/javascript" src="<?php echo($config['base_url']); ?>/js/tw-sack.js"></script>
|
||||||
|
<script type="text/javascript">
|
||||||
|
|
||||||
|
|
||||||
|
var ajax = new Array();
|
||||||
|
|
||||||
|
function getInterfaceList(sel)
|
||||||
|
{
|
||||||
|
var deviceId = sel.options[sel.selectedIndex].value;
|
||||||
|
document.getElementById('interface_id').options.length = 0; // Empty city select box
|
||||||
|
if(deviceId.length>0){
|
||||||
|
var index = ajax.length;
|
||||||
|
ajax[index] = new sack();
|
||||||
|
|
||||||
|
ajax[index].requestFile = '<?php echo($config['base_url']); ?>/ajax_listports.php?device_id='+deviceId; // Specifying which file to get
|
||||||
|
ajax[index].onCompletion = function(){ createInterfaces(index) }; // Specify function that will be executed after file has been found
|
||||||
|
ajax[index].runAJAX(); // Execute AJAX function
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function createInterfaces(index)
|
||||||
|
{
|
||||||
|
var obj = document.getElementById('interface_id');
|
||||||
|
eval(ajax[index].response); // Executing the response from Ajax as Javascript code
|
||||||
|
}
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
202
html/pages/bill.php
Normal file
202
html/pages/bill.php
Normal file
@@ -0,0 +1,202 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
$bill_id = mres($_GET['opta']);
|
||||||
|
|
||||||
|
|
||||||
|
$bi_q = mysql_query("SELECT * FROM bills WHERE bill_id = $bill_id");
|
||||||
|
$bill_data = mysql_fetch_array($bi_q);
|
||||||
|
|
||||||
|
$today = str_replace("-", "", mysql_result(mysql_query("SELECT CURDATE()"), 0));
|
||||||
|
$yesterday = str_replace("-", "", mysql_result(mysql_query("SELECT DATE_SUB(CURDATE(), INTERVAL 1 DAY)"), 0));
|
||||||
|
$tomorrow = str_replace("-", "", mysql_result(mysql_query("SELECT DATE_ADD(CURDATE(), INTERVAL 1 DAY)"), 0));
|
||||||
|
$last_month = str_replace("-", "", mysql_result(mysql_query("SELECT DATE_SUB(CURDATE(), INTERVAL 1 MONTH)"), 0));
|
||||||
|
|
||||||
|
$now = $today . date(His);
|
||||||
|
$before = $yesterday . date(His);
|
||||||
|
$lastmonth = $last_month . date(His);
|
||||||
|
|
||||||
|
$bill_name = $bill_data['bill_name'];
|
||||||
|
$dayofmonth = $bill_data['bill_day'];
|
||||||
|
$paidrate = $bill_data['bill_paid_rate'];
|
||||||
|
$paid_kb = $paidrate / 1000;
|
||||||
|
$paid_mb = $paid_kb / 1000;
|
||||||
|
|
||||||
|
if ($paidrate < 1000000) { $paidrate_text = $paid_kb . "Kbps is the CDR."; }
|
||||||
|
if ($paidrate >= 1000000) { $paidrate_text = $paid_mb . "Mbps is the CDR."; }
|
||||||
|
|
||||||
|
$day_data = getDates($dayofmonth);
|
||||||
|
$datefrom = $day_data['0'];
|
||||||
|
$dateto = $day_data['1'];
|
||||||
|
$rate_data = getRates($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 ($rate_95th > $paid_kb) {
|
||||||
|
$over = $rate_95th - $paid_kb;
|
||||||
|
$bill_text = $over . "Kbit excess.";
|
||||||
|
$bill_color = "#cc0000";
|
||||||
|
} else {
|
||||||
|
$under = $paid_kb - $rate_95th;
|
||||||
|
$bill_text = $under . "Kbit headroom.";
|
||||||
|
$bill_color = "#0000cc";
|
||||||
|
}
|
||||||
|
|
||||||
|
$fromtext = mysql_result(mysql_query("SELECT DATE_FORMAT($datefrom, '%M %D %Y')"), 0);
|
||||||
|
$totext = mysql_result(mysql_query("SELECT DATE_FORMAT($dateto, '%M %D %Y')"), 0);
|
||||||
|
$unixfrom = mysql_result(mysql_query("SELECT UNIX_TIMESTAMP('$datefrom')"), 0);
|
||||||
|
$unixto = mysql_result(mysql_query("SELECT UNIX_TIMESTAMP('$dateto')"), 0);
|
||||||
|
|
||||||
|
echo("<font face=\"Verdana, Arial, Sans-Serif\"><h2>
|
||||||
|
" . $bill_name . "</h2>");
|
||||||
|
|
||||||
|
print_optionbar_start();
|
||||||
|
|
||||||
|
if(!$_GET['optb']) { $_GET['optb'] = "details"; }
|
||||||
|
|
||||||
|
if($_GET['optb'] == "details") { echo("<strong>"); }
|
||||||
|
echo("<a href='".$config['base_url']."/bill/".$bill_id."/details/'>Details</a>");
|
||||||
|
if($_GET['optb'] == "details") { echo("</strong>"); }
|
||||||
|
|
||||||
|
echo(" | ");
|
||||||
|
if($_GET['optb'] == "edit") { echo("<strong>"); }
|
||||||
|
echo("<a href='".$config['base_url']."/bill/".$bill_id."/edit/'>Edit</a>");
|
||||||
|
if($_GET['optb'] == "edit") { echo("</strong>"); }
|
||||||
|
|
||||||
|
print_optionbar_end();
|
||||||
|
|
||||||
|
echo("<table width=715 border=0 cellspace=0 cellpadding=0><tr><td>");
|
||||||
|
|
||||||
|
|
||||||
|
if($_GET['optb'] == "edit") {
|
||||||
|
|
||||||
|
include("pages/bill/edit.php");
|
||||||
|
|
||||||
|
}elseif($_GET['optb'] == "details") {
|
||||||
|
|
||||||
|
|
||||||
|
echo("<h3>Billed Ports</h3>");
|
||||||
|
|
||||||
|
$ports = mysql_query("SELECT * FROM interfaces AS I, devices AS D, bill_ports as B WHERE B.bill_id = '$bill_id' AND B.port_id = I.interface_id AND I.device_id = D.device_id");
|
||||||
|
|
||||||
|
while ($port = mysql_fetch_array($ports)) {
|
||||||
|
|
||||||
|
echo(generateiflink($port) . " on " . generatedevicelink($port) . "<br />");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
echo("<h3>Bill Summary</h3>");
|
||||||
|
|
||||||
|
if($bill_data['bill_type'] == "quota") {
|
||||||
|
|
||||||
|
// The Customer is billed based on a pre-paid quota
|
||||||
|
|
||||||
|
$percent = round(($total_data / 1024) / $bill_data['bill_gb'] * 100, 2);
|
||||||
|
$unit = "MB";
|
||||||
|
$total_data = round($total_data, 2);
|
||||||
|
echo("Billing Period from " . $fromtext . " to " . $totext . "
|
||||||
|
<br />Transferred ".formatStorage($total_data * 1024 * 1024)." of ".formatStorage($bill_data['bill_gb'] * 1024 * 1024 * 1024)." (".$percent."%)
|
||||||
|
<br />Average rate " . formatRates($rate_average * 1000));
|
||||||
|
if ($percent > 100) { $percent = "100"; }
|
||||||
|
echo("<p><img src='percentage.php?per=$percent&width=350'></p>");
|
||||||
|
|
||||||
|
$type="&ave=yes";
|
||||||
|
|
||||||
|
|
||||||
|
} elseif($bill_data['bill_type'] == "cdr") {
|
||||||
|
|
||||||
|
// The customer is billed based on a CDR with 95th%ile overage
|
||||||
|
|
||||||
|
$unit = "kbps";
|
||||||
|
$cdr = $bill_data['bill_cdr'];
|
||||||
|
if($rate_95th > "1000") { $rate_95th = $rate_95th / 1000; $cdr = $cdr / 1000; $unit = "Mbps"; }
|
||||||
|
if($rate_95th > "1000") { $rate_95th = $rate_95th / 1000; $cdr = $cdr / 1000; $unit = "Gps"; }
|
||||||
|
$rate_95th = round($rate_95th, 2);
|
||||||
|
|
||||||
|
$percent = round(($rate_95th) / $cdr * 100, 2);
|
||||||
|
|
||||||
|
$type="&95th=yes";
|
||||||
|
|
||||||
|
|
||||||
|
echo("<strong>" . $fromtext . " to " . $totext . "</strong>
|
||||||
|
<br />Measured ".$rate_95th."$unit of ".$cdr."$unit (".$percent."%)");
|
||||||
|
if ($percent > 100) { $percent = "100"; }
|
||||||
|
echo("<p><img src='percentage.php?per=$percent&width=350'></p>");
|
||||||
|
|
||||||
|
# echo("<p>Billing Period : " . $fromtext . " to " . $totext . "<br />
|
||||||
|
# " . $paidrate_text . " <br />
|
||||||
|
# " . $total_data . "MB transfered in the current billing cycle. <br />
|
||||||
|
# " . $rate_average . "Kbps Average during the current billing cycle. </p>
|
||||||
|
# <font face=\"Trebuchet MS, Verdana, Arial, Sans-Serif\" color=" . $bill_color . "><B>" . $rate_95th . "Kbps @ 95th Percentile.</b> (" . $dir_95th . ") (" . $bill_text . ")</font>
|
||||||
|
# </td><td><img src=\"images/billing-key.png\"></td></tr></table>
|
||||||
|
# <br />");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
echo("</td><td><img src='images/billing-key.png'></td></tr></table>");
|
||||||
|
|
||||||
|
$bi = "<img src='billing-graph.php?bill_id=" . $bill_id . "&bill_code=" . $_GET['bill_code'];
|
||||||
|
$bi = $bi . "&from=" . $unixfrom . "&to=" . $unixto;
|
||||||
|
$bi = $bi . "&x=715&y=250";
|
||||||
|
$bi = $bi . "$type'>";
|
||||||
|
|
||||||
|
$lastmonth = mysql_result(mysql_query("SELECT UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 1 MONTH))"), 0);
|
||||||
|
$yesterday = mysql_result(mysql_query("SELECT UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 1 DAY))"), 0);
|
||||||
|
$now = date(U);
|
||||||
|
|
||||||
|
$di = "<img src='".$config['base_url']."/billing-graph.php?bill_id=" . $bill_id . "&bill_code=" . $_GET['bill_code'];
|
||||||
|
$di = $di . "&from=" . $yesterday . "&to=" . $now . "&x=715&y=250";
|
||||||
|
$di = $di . "$type'>";
|
||||||
|
|
||||||
|
$mi = "<img src='".$config['base_url']."/billing-graph.php?bill_id=" . $bill_id . "&bill_code=" . $_GET['bill_code'];
|
||||||
|
$mi = $mi . "&from=" . $lastmonth . "&to=" . $now . "&x=715&y=250";
|
||||||
|
$mi = $mi . "$type'>";
|
||||||
|
|
||||||
|
if($null) {
|
||||||
|
|
||||||
|
echo("
|
||||||
|
<script type='text/javascript' src='js/calendarDateInput.js'>
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<FORM action='/' method='get'>
|
||||||
|
<INPUT type='hidden' name='bill' value='".$_GET['bill']."'>
|
||||||
|
<INPUT type='hidden' name='code' value='".$_GET['code']."'>
|
||||||
|
<INPUT type='hidden' name='page' value='bills'>
|
||||||
|
<INPUT type='hidden' name='custom' value='yes'>
|
||||||
|
|
||||||
|
From:
|
||||||
|
<script>DateInput('fromdate', true, 'YYYYMMDD')</script>
|
||||||
|
|
||||||
|
To:
|
||||||
|
<script>DateInput('todate', true, 'YYYYMMDD')</script>
|
||||||
|
<INPUT type='submit' value='Generate Graph'>
|
||||||
|
|
||||||
|
</FORM>
|
||||||
|
|
||||||
|
");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($_GET[all]) {
|
||||||
|
$ai = "<img src=\"billing-graph.php?bill_id=" . $bill_id . "&bill_code=" . $_GET['bill_code'];
|
||||||
|
$ai = $ai . "&from=0&to=" . $now;
|
||||||
|
$ai = $ai . "&x=715&y=250";
|
||||||
|
$ai = $ai . "&count=60\">";
|
||||||
|
echo("<h3>Entire Data View</h3>$ai");
|
||||||
|
} elseif ($_GET[custom]) {
|
||||||
|
$cg = "<img src=\"billing-graph.php?bill_id=" . $bill_id . "&bill_code=" . $_GET['bill_code'];
|
||||||
|
$cg = $cg . "&from=" . $_GET['fromdate'] . "000000&to=" . $_GET['todate'] . "235959";
|
||||||
|
$cg = $cg . "&x=715&y=250";
|
||||||
|
$cg = $cg . "&count=60\">";
|
||||||
|
echo("<h3>Custom Graph</h3>$cg");
|
||||||
|
} else {
|
||||||
|
echo("<h3>Billing View</h3>$bi<h3>24 Hour View</h3>$di");
|
||||||
|
#echo("<h3>Monthly View</h3>$li");
|
||||||
|
#echo("<br /><a href=\"rate.php?" . $_SERVER['QUERY_STRING'] . "&all=yes\">Graph All Data (SLOW)</a>");
|
||||||
|
}
|
||||||
|
|
||||||
|
} # End if details
|
||||||
|
|
||||||
|
?>
|
||||||
|
|
63
html/pages/bill/edit.php
Normal file
63
html/pages/bill/edit.php
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
include("includes/javascript-interfacepicker.inc.php");
|
||||||
|
|
||||||
|
### This needs more verification. Is it already added? Does it exist?
|
||||||
|
|
||||||
|
if($_POST['action'] == "add_bill_port") { mysql_query("INSERT INTO `bill_ports` (`bill_id`, `port_id`) VALUES ('".mres($_POST['bill_id'])."','".mres($_POST['interface_id'])."')"); }
|
||||||
|
if($_POST['action'] == "delete_bill_port") { mysql_query("DELETE FROM `bill_ports` WHERE `bill_id` = '".mres($bill_id)."' AND `port_id` = '".mres($_POST['interface_id'])."'"); }
|
||||||
|
|
||||||
|
#print_r($_POST);
|
||||||
|
|
||||||
|
|
||||||
|
$ports_array = mysql_query("SELECT * FROM `bill_ports` AS B, `ports` AS P, `devices` AS D
|
||||||
|
WHERE B.bill_id = '".$bill_id."' AND P.interface_id = B.port_id
|
||||||
|
AND D.device_id = P.device_id");
|
||||||
|
|
||||||
|
if(mysql_affected_rows())
|
||||||
|
{
|
||||||
|
|
||||||
|
echo("<h3>Billed Ports</h3>");
|
||||||
|
|
||||||
|
echo("<table cellpadding=5 cellspacing=0>");
|
||||||
|
while($port = mysql_fetch_array($ports_array))
|
||||||
|
{
|
||||||
|
if($bg == $list_colour_a) { $bg = $list_colour_b; } else { $bg=$list_colour_a; }
|
||||||
|
echo("<tr style=\"background-color: $bg\">");
|
||||||
|
echo("<td>");
|
||||||
|
echo(generatedevicelink($port) . " - " . generateiflink($port));
|
||||||
|
if($port['ifAlias']) { echo(" - " . $port['ifAlias']); }
|
||||||
|
echo("</td><td>");
|
||||||
|
echo("<form action='' method='post'><input type='hidden' name='action' value='delete_bill_port'>
|
||||||
|
<input type=hidden name=interface_id value='".$port['interface_id']."'>
|
||||||
|
<input type=submit value=' Delete ' name='Delete'></form>");
|
||||||
|
echo("</td>");
|
||||||
|
}
|
||||||
|
echo("</table>");
|
||||||
|
}
|
||||||
|
|
||||||
|
echo("<h3>Add Billed Port</h3>");
|
||||||
|
|
||||||
|
echo("<form action='' method='post'>
|
||||||
|
<input type='hidden' name='action' value='add_bill_port'>
|
||||||
|
<input type='hidden' name='bill_id' value='".$bill_id."'>
|
||||||
|
|
||||||
|
<table><tr><td>Device: </td>
|
||||||
|
<td><select id='device' class='selector' name='device' onchange='getInterfaceList(this)'>
|
||||||
|
<option value=''>Select a device</option>");
|
||||||
|
|
||||||
|
$device_list = mysql_query("SELECT * FROM `devices` ORDER BY hostname");
|
||||||
|
while($device = mysql_fetch_array($device_list)) {
|
||||||
|
unset($done);
|
||||||
|
foreach($access_list as $ac) { if($ac == $device['device_id']) { $done = 1; } }
|
||||||
|
if(!$done) { echo("<option value='" . $device['device_id'] . "'>" . $device['hostname'] . "</option>"); }
|
||||||
|
}
|
||||||
|
|
||||||
|
echo("</select></td></tr><tr>
|
||||||
|
<td>Interface: </td><td><select class=selector id='interface_id' name='interface_id'>
|
||||||
|
</select></td>
|
||||||
|
</tr><tr></table><input type='submit' name='Submit' value=' Add '></form>");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
?>
|
@@ -1,12 +1,75 @@
|
|||||||
|
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
if($_POST['addbill'] == "yes") {
|
||||||
|
|
||||||
|
$updated = '1';
|
||||||
|
|
||||||
|
$sql = "INSERT INTO `bills` (`bill_name`,`bill_type`,`bill_cdr`,`bill_day`,`bill_gb`, `bill_custid`, `bill_ref`, `bill_notes`)
|
||||||
|
VALUES ('" . mres($_POST['bill_name']) . "','" . mres($_POST['bill_type']) . "',
|
||||||
|
'" . mres($_POST['bill_cdr']) . "','" . mres($_POST['bill_day']) . "',
|
||||||
|
'" . mres($_POST['bill_quota']) . "','" . mres($_POST['bill_custid']) . "',
|
||||||
|
'" . mres($_POST['bill_ref']) . "','" . mres($_POST['bill_notes']) . "' )";
|
||||||
|
|
||||||
|
$query = mysql_query($sql);
|
||||||
|
$affected = mysql_affected_rows() . "records affected";
|
||||||
|
|
||||||
|
$message .= $message_break . "Bill ".mres($_POST['bill_name'])." added!";
|
||||||
|
$message_break .= "<br />";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
echo("<meta http-equiv='refresh' content='10000'>");
|
||||||
|
|
||||||
if($_GET['opta'] == "add") {
|
if($_GET['opta'] == "add") {
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<div style='padding:10px;font-size:20px; font-weight: bold;'>Add Bill</div>
|
<div style='padding:10px;font-size:20px; font-weight: bold;'>Add Bill</div>
|
||||||
|
|
||||||
<form method='post' action=''>
|
<form name="form1" method="post" action="bills/">
|
||||||
|
|
||||||
|
<input type=hidden name=addbill value=yes>
|
||||||
|
|
||||||
|
<div style="padding: 10px; background: #f0f0f0;">
|
||||||
|
<table cellpadding=2px width=400px>
|
||||||
|
<tr>
|
||||||
|
<td><strong>Description</strong></td>
|
||||||
|
<td><input type="text" name="bill_name" size="32"></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><strong>Billing Type</strong></td>
|
||||||
|
<td>
|
||||||
|
<input type="radio" name="bill_type" value="cdr" checked /> CDR 95th: <input type="text" name="bill_cdr" size="10">KBps
|
||||||
|
<br />
|
||||||
|
<input type="radio" name="bill_type" value="quota" /> Quota: <input type="text" name="bill_quota" size="10">GB
|
||||||
|
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><strong>Billing Day</strong></td>
|
||||||
|
<td><input type="text" name="bill_day" size="5" value="1"></td>
|
||||||
|
</tr>
|
||||||
|
<tr><td colspan=4><h3>Optional Information</h3></td></tr>
|
||||||
|
<tr>
|
||||||
|
<td><strong>Customer Reference</strong></td>
|
||||||
|
<td><input type="text" name="bill_custid" size="32"></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><strong>Billing Reference</strong></td>
|
||||||
|
<td><input type="text" name="bill_ref" size="32"></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><strong>Notes</strong></td>
|
||||||
|
<td><input type="textarea" name="bill_notes" size="32"></td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td></td><td><input type="submit" class="submit" name="Submit" value=" Add Bill "></td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
@@ -96,7 +159,7 @@ print_optionbar_end();
|
|||||||
<td>$used</td>
|
<td>$used</td>
|
||||||
<td><img src='percentage.php?width=350&per=$percent'> $percent%</td>
|
<td><img src='percentage.php?width=350&per=$percent'> $percent%</td>
|
||||||
<td></td>
|
<td></td>
|
||||||
<td width=60><a><img src='images/16/wrench.png' align=absmiddle alt='Edit'> Edit</a></td>
|
<td width=60><a href='".$config['base_url']."/bills/1/edit/'><img src='images/16/wrench.png' align=absmiddle alt='Edit'> Edit</a></td>
|
||||||
</tr>
|
</tr>
|
||||||
");
|
");
|
||||||
$i++;
|
$i++;
|
||||||
|
@@ -1,33 +1,7 @@
|
|||||||
<script type="text/javascript" src="<?php echo($config['base_url']); ?>/js/tw-sack.js"></script>
|
|
||||||
<script type="text/javascript">
|
|
||||||
|
|
||||||
|
|
||||||
var ajax = new Array();
|
|
||||||
|
|
||||||
function getInterfaceList(sel)
|
|
||||||
{
|
|
||||||
var deviceId = sel.options[sel.selectedIndex].value;
|
|
||||||
document.getElementById('interface_id').options.length = 0; // Empty city select box
|
|
||||||
if(deviceId.length>0){
|
|
||||||
var index = ajax.length;
|
|
||||||
ajax[index] = new sack();
|
|
||||||
|
|
||||||
ajax[index].requestFile = '<?php echo($config['base_url']); ?>/ajax/list_ports.php?device_id='+deviceId; // Specifying which file to get
|
|
||||||
ajax[index].onCompletion = function(){ createInterfaces(index) }; // Specify function that will be executed after file has been found
|
|
||||||
ajax[index].runAJAX(); // Execute AJAX function
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function createInterfaces(index)
|
|
||||||
{
|
|
||||||
var obj = document.getElementById('interface_id');
|
|
||||||
eval(ajax[index].response); // Executing the response from Ajax as Javascript code
|
|
||||||
}
|
|
||||||
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
include("includes/javascript-interfacepicker.inc.php");
|
||||||
|
|
||||||
echo("<div style='margin: 10px;'>");
|
echo("<div style='margin: 10px;'>");
|
||||||
|
|
||||||
if($_SESSION['userlevel'] != '10') { include("includes/error-no-perm.inc.php"); } else {
|
if($_SESSION['userlevel'] != '10') { include("includes/error-no-perm.inc.php"); } else {
|
||||||
|
Reference in New Issue
Block a user