mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Add Interface at bill create screen
This commit is contained in:
@@ -11,8 +11,16 @@
|
|||||||
* the source code distribution for details.
|
* the source code distribution for details.
|
||||||
*/
|
*/
|
||||||
if(is_admin() !== false) {
|
if(is_admin() !== false) {
|
||||||
|
|
||||||
|
require 'includes/javascript-interfacepicker.inc.php';
|
||||||
|
|
||||||
|
$port_device_id = -1;
|
||||||
if (is_numeric($vars['port'])) {
|
if (is_numeric($vars['port'])) {
|
||||||
$port = dbFetchRow('SELECT * FROM `ports` AS P, `devices` AS D WHERE `port_id` = ? AND D.device_id = P.device_id', array($vars['port']));
|
$port = dbFetchRow('SELECT * FROM `ports` AS P, `devices` AS D WHERE `port_id` = ? AND D.device_id = P.device_id', array($vars['port']));
|
||||||
|
$bill_data['bill_name'] = $port['port_descr_descr'];
|
||||||
|
$bill_data['bill_ref'] = $port['port_descr_circuit'];
|
||||||
|
$bill_data['bill_notes'] = $port['port_descr_speed'];
|
||||||
|
$port_device_id = $port['device_id'];
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
||||||
@@ -27,23 +35,39 @@ if(is_admin() !== false) {
|
|||||||
<form method="post" role="form" action="bills/" class="form-horizontal alerts-form">
|
<form method="post" role="form" action="bills/" class="form-horizontal alerts-form">
|
||||||
<input type="hidden" name="addbill" value="yes" />
|
<input type="hidden" name="addbill" value="yes" />
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-4 control-label" for="device">Device</label>
|
||||||
|
<div class="col-sm-8">
|
||||||
|
<select class="form-control input-sm" id="device" name="device" onchange="getInterfaceList(this)">
|
||||||
|
<option value=''>Select a device</option>
|
||||||
<?php
|
<?php
|
||||||
if (is_array($port)) {
|
$devices = dbFetchRows('SELECT * FROM `devices` ORDER BY hostname');
|
||||||
$portalias = (empty($port['ifAlias']) ? '' : ' - '.$port['ifAlias'].'');
|
foreach ($devices as $device) {
|
||||||
?>
|
$selected = $device['device_id'] == $port_device_id ? " selected" : "";
|
||||||
<div class="well">
|
echo "<option value='${device['device_id']}' $selected>${device['hostname']}</option>\n";
|
||||||
<input type="hidden" name="port" value="<?php echo $port['port_id'] ?>" />
|
|
||||||
<p>
|
|
||||||
<?php echo generate_device_link($port) ?>
|
|
||||||
<i class="fa fa-random"></i>
|
|
||||||
<?php echo generate_port_link($port, $port['ifName'] . $portalias) ?>
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
<?php
|
|
||||||
$bill_data['bill_name'] = $port['port_descr_descr'];
|
|
||||||
$bill_data['bill_ref'] = $port['port_descr_circuit'];
|
|
||||||
$bill_data['bill_notes'] = $port['port_descr_speed'];
|
|
||||||
}
|
}
|
||||||
|
?>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-sm-4 control-label" for="port_id">Port</label>
|
||||||
|
<div class="col-sm-8">
|
||||||
|
<select class="form-control input-sm" id="port_id" name="port_id">
|
||||||
|
<?php if (is_array($port)) {
|
||||||
|
// Need to pre-populate port as we've got a port pre-selected
|
||||||
|
foreach (dbFetch('SELECT * FROM ports WHERE device_id = ?', array($port_device_id)) as $interface) {
|
||||||
|
$interface = ifNameDescr($interface);
|
||||||
|
$string = $interface['label'].' - '.$interface['ifAlias'];
|
||||||
|
$selected = $interface['port_id'] === $port['port_id'] ? " selected" : "";
|
||||||
|
echo "<option value='${interface['port_id']}' $selected>$string</option>\n";
|
||||||
|
}
|
||||||
|
} ?>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
|
||||||
$bill_data['bill_type'] = 'cdr';
|
$bill_data['bill_type'] = 'cdr';
|
||||||
$quota = array('select_gb' => ' selected');
|
$quota = array('select_gb' => ' selected');
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
<h4>Bill Information</h4>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="bill_name" class="col-sm-4 control-label">Description</label>
|
<label for="bill_name" class="col-sm-4 control-label">Description</label>
|
||||||
<div class="col-sm-8">
|
<div class="col-sm-8">
|
||||||
|
|||||||
@@ -150,16 +150,7 @@
|
|||||||
<?php
|
<?php
|
||||||
$devices = dbFetchRows('SELECT * FROM `devices` ORDER BY hostname');
|
$devices = dbFetchRows('SELECT * FROM `devices` ORDER BY hostname');
|
||||||
foreach ($devices as $device) {
|
foreach ($devices as $device) {
|
||||||
unset($done);
|
echo "<option value='${device['device_id']}'>${device['hostname']}</option>\n";
|
||||||
foreach ($access_list as $ac) {
|
|
||||||
if ($ac == $device['device_id']) {
|
|
||||||
$done = 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!$done) {
|
|
||||||
echo " <option value='".$device['device_id']."'>".$device['hostname']."</option>\n";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|||||||
@@ -75,8 +75,8 @@ if ($_POST['addbill'] == 'yes') {
|
|||||||
|
|
||||||
$bill_id = dbInsert($insert, 'bills');
|
$bill_id = dbInsert($insert, 'bills');
|
||||||
|
|
||||||
if (is_numeric($bill_id) && is_numeric($_POST['port'])) {
|
if (is_numeric($bill_id) && is_numeric($_POST['port_id'])) {
|
||||||
dbInsert(array('bill_id' => $bill_id, 'port_id' => $_POST['port']), 'bill_ports');
|
dbInsert(array('bill_id' => $bill_id, 'port_id' => $_POST['port_id']), 'bill_ports');
|
||||||
}
|
}
|
||||||
|
|
||||||
header('Location: /' . generate_url(array('page' => 'bill', 'bill_id' => $bill_id, 'view' => 'edit')));
|
header('Location: /' . generate_url(array('page' => 'bill', 'bill_id' => $bill_id, 'view' => 'edit')));
|
||||||
|
|||||||
Reference in New Issue
Block a user