mirror of
				https://github.com/librenms/librenms.git
				synced 2024-10-07 16:52:45 +00:00 
			
		
		
		
	hacks to billing (this shit needs rewritten so badly)
git-svn-id: http://www.observium.org/svn/observer/trunk@2034 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
		@@ -9,9 +9,18 @@ if (is_numeric($_GET['id']) && ($config['allow_unauth_graphs'] || bill_permitted
 | 
			
		||||
  $bill_query   = mysql_query("SELECT * FROM `bills` WHERE bill_id = '".mres($_GET['id'])."'");
 | 
			
		||||
  $bill         = mysql_fetch_assoc($bill_query);
 | 
			
		||||
 | 
			
		||||
  $day_data     = getDates($bill['bill_day']);
 | 
			
		||||
  $datefrom     = $day_data['0'];
 | 
			
		||||
  $dateto       = $day_data['1'];
 | 
			
		||||
#  $day_data     = getDates($bill['bill_day']);
 | 
			
		||||
#  $datefrom     = $day_data['0'];
 | 
			
		||||
#  $dateto       = $day_data['1'];
 | 
			
		||||
 | 
			
		||||
#print_r($day_data);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
   $datefrom = date('YmdHis', $_GET['from']);
 | 
			
		||||
   $dateto   = date('YmdHis', $_GET['to']);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
  $rates = getRates($_GET['id'], $datefrom,  $dateto);
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -28,8 +28,8 @@ $rra_out = "OUTOCTETS";
 | 
			
		||||
 | 
			
		||||
if($bill['bill_type'] == "cdr") {
 | 
			
		||||
   $custom_graph = " COMMENT:'\\r' ";
 | 
			
		||||
   $custom_graph .= " HRULE:" . $rates['rate_average'] * 1000 . "#cc0000:'95th %ile \: ".formatRates($rates['rate_95th']*1000)." (".$rates['dir_95th'].") (CDR\: ".formatRates($bill['bill_cdr']*1000).")'";
 | 
			
		||||
   $custom_graph .= " HRULE:" . $rates['rate_average'] * 1000 * -1 . "#cc0000";
 | 
			
		||||
   $custom_graph .= " HRULE:" . $rates['rate_95th'] * 1000 . "#cc0000:'95th %ile \: ".formatRates($rates['rate_95th']*1000)." (".$rates['dir_95th'].") (CDR\: ".formatRates($bill['bill_cdr']*1000).")'";
 | 
			
		||||
   $custom_graph .= " HRULE:" . $rates['rate_95th'] * 1000 * -1 . "#cc0000";
 | 
			
		||||
} elseif($bill['bill_type'] == "quota") {
 | 
			
		||||
   $custom_graph = " COMMENT:'\\r' ";
 | 
			
		||||
   $custom_graph .= " HRULE:" . $rates['rate_average'] * 1000 . "#cc0000:'Usage \: ".formatStorage($rates['total_data']*1024*1024)." (".formatRates($rates['rate_average']*1000).")'";
 | 
			
		||||
 
 | 
			
		||||
@@ -33,6 +33,8 @@ if (bill_permitted($bill_id))
 | 
			
		||||
  $day_data     = getDates($dayofmonth);
 | 
			
		||||
  $datefrom     = $day_data['0'];
 | 
			
		||||
  $dateto       = $day_data['1'];
 | 
			
		||||
  $lastfrom	= $day_data['2'];
 | 
			
		||||
  $lastto	= $day_data['3'];
 | 
			
		||||
  $rate_data    = getRates($bill_id,$datefrom,$dateto);
 | 
			
		||||
  $rate_95th    = $rate_data['rate_95th'];
 | 
			
		||||
  $dir_95th     = $rate_data['dir_95th'];
 | 
			
		||||
@@ -57,6 +59,9 @@ if (bill_permitted($bill_id))
 | 
			
		||||
  $unixfrom = mysql_result(mysql_query("SELECT UNIX_TIMESTAMP('$datefrom')"), 0);
 | 
			
		||||
  $unixto = mysql_result(mysql_query("SELECT UNIX_TIMESTAMP('$dateto')"), 0);
 | 
			
		||||
 | 
			
		||||
  $unix_prev_from = mysql_result(mysql_query("SELECT UNIX_TIMESTAMP('$lastfrom')"), 0); 
 | 
			
		||||
  $unix_prev_to   = mysql_result(mysql_query("SELECT UNIX_TIMESTAMP('$lastto')"), 0);
 | 
			
		||||
 | 
			
		||||
  echo("<font face=\"Verdana, Arial, Sans-Serif\"><h2>
 | 
			
		||||
  Bill : " . $bill_name . "</h2>");
 | 
			
		||||
 | 
			
		||||
@@ -186,6 +191,12 @@ if (bill_permitted($bill_id))
 | 
			
		||||
  $yesterday = mysql_result(mysql_query("SELECT UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 1 DAY))"), 0);
 | 
			
		||||
  $rightnow = date(U);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
  $li = "<img src='graph.php?type=bill_bits&id=" . $bill_id;
 | 
			
		||||
  $li .= "&from=" . $unix_prev_from .  "&to=" . $unix_prev_to;
 | 
			
		||||
  $li .= "&width=715&height=200&total=1'>";
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#  $di =       "<img src='billing-graph.php?bill_id=" . $bill_id . "&bill_code=" . $_GET['bill_code'];
 | 
			
		||||
#  $di = $di . "&from=" . $yesterday .  "&to=" . $rightnow . "&x=715&y=250";
 | 
			
		||||
#  $di = $di . "$type'>";
 | 
			
		||||
@@ -247,7 +258,9 @@ if (bill_permitted($bill_id))
 | 
			
		||||
   }
 | 
			
		||||
   else
 | 
			
		||||
   {
 | 
			
		||||
     echo("<h3>Billing View</h3>$bi<h3>24 Hour View</h3>$di");
 | 
			
		||||
     echo("<h3>Billing View</h3>$bi");
 | 
			
		||||
     echo("<h3>Previous Bill View</h3>$li");
 | 
			
		||||
     echo("<h3>24 Hour View</h3>$di");
 | 
			
		||||
     echo("<h3>Monthly View</h3>$mi");
 | 
			
		||||
#     echo("<br /><a href=\"rate.php?" . $_SERVER['QUERY_STRING'] . "&all=yes\">Graph All Data (SLOW)</a>");
 | 
			
		||||
   }
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user