From d94b0bd1c2a308574f150eac1aadd893e278b711 Mon Sep 17 00:00:00 2001 From: Adam Amstrong Date: Mon, 5 Dec 2011 12:15:41 +0000 Subject: [PATCH] add bill from device/port, some billing changes git-svn-id: http://www.observium.org/svn/observer/trunk@2756 61d68cd4-352d-0410-923a-c4978735b2b8 --- html/pages/bills.inc.php | 35 +++++++++++++++++++++++++++------- html/pages/device/port.inc.php | 5 +++++ includes/billing.php | 1 - poll-billing.php | 7 +++---- 4 files changed, 36 insertions(+), 12 deletions(-) diff --git a/html/pages/bills.inc.php b/html/pages/bills.inc.php index ed8c22096e..a64c05706e 100644 --- a/html/pages/bills.inc.php +++ b/html/pages/bills.inc.php @@ -7,10 +7,17 @@ if ($_POST['addbill'] == "yes") $insert = array('bill_name' => $_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'); + $bill_id = dbInsert($insert, 'bills'); - $message .= $message_break . "Bill ".mres($_POST['bill_name'])." added!"; + $message .= $message_break . "Bill ".mres($_POST['bill_name'])." (".$bill_id.") added!"; $message_break .= "
"; + + if (is_numeric($bill_id) && is_numeric($_POST['port'])) + { + dbInsert(array('bill_id' => $bill_id, 'port_id' => $_POST['port']), 'bill_ports'); + $message .= $message_break . "Port ".mres($_POST['port'])." added!"; + $message_break .= "
"; + } } $pagetitle[] = "Billing"; @@ -25,19 +32,33 @@ if ($_GET['opta'] == "history") } elseif ($_GET['opta'] == "add") { + if(is_numeric($vars['port'])) + { + $port = dbFetchRow("SELECT * FROM `ports` AS P, `devices` AS D WHERE `interface_id` = ? AND D.device_id = P.device_id", array($vars['port'])); + } ?> -
Add Bill
+
Add Bill
- +Ports"); + echo(generate_port_link($port) . " on " . generate_device_link($port) . "
"); + echo(""); +} + +?> + +
- + @@ -58,11 +79,11 @@ elseif ($_GET['opta'] == "add") - + - + diff --git a/html/pages/device/port.inc.php b/html/pages/device/port.inc.php index c7409325e4..c8753188a8 100644 --- a/html/pages/device/port.inc.php +++ b/html/pages/device/port.inc.php @@ -137,6 +137,11 @@ if (dbFetchCell("SELECT COUNT(*) FROM juniAtmVp WHERE interface_id = '".$port['i if ($vars['view'] == "junose-atm-vp" && $vars['graph'] == "bits") { echo(""); } } +if ($_SESSION['userlevel'] == '10') +{ + echo(" Create Bill"); +} + print_optionbar_end(); echo("
"); diff --git a/includes/billing.php b/includes/billing.php index 45d76f22ad..56b9ec51a4 100644 --- a/includes/billing.php +++ b/includes/billing.php @@ -103,7 +103,6 @@ function getLastPortCounter($port_id,$inout) } else { $return[state] = "failed"; } - return($return); } diff --git a/poll-billing.php b/poll-billing.php index ef10e603a5..b083765601 100755 --- a/poll-billing.php +++ b/poll-billing.php @@ -22,20 +22,19 @@ function CollectData($bill_id) { foreach (dbFetchRows("SELECT * FROM `bill_ports` as P, `ports` as I, `devices` as D WHERE P.bill_id=? AND I.interface_id = P.port_id AND D.device_id = I.device_id", array($bill_id)) as $port_data) { - $port_id = $port_data['port_id']; $host = $port_data['hostname']; $port = $port_data['port']; echo("\nPolling ".$port_data['ifDescr']." on ".$port_data['hostname']."\n"); - $port_data['in_measurement'] = getValue($host, $port, $port_data['ifIndex'], "In"); - $port_data['out_measurement'] = getValue($host, $port, $port_data['ifIndex'], "Out"); + $port_data['in_measurement'] = getValue($port_data['hostname'], $port_data['port'], $port_data['ifIndex'], "In"); + $port_data['out_measurement'] = getValue($port_data['hostname'], $port_data['port'], $port_data['ifIndex'], "Out"); $now = dbFetchCell("SELECT NOW()"); $last_data = getLastPortCounter($port_id,in); - if ($last_data[state] == "ok") + if ($last_data['state'] == "ok") { $port_data['last_in_measurement'] = $last_data[counter]; $port_data['last_in_delta'] = $last_data[delta];
Description
Billing Type
Billing Reference
Notes