2010-06-21 04:18:06 +00:00
|
|
|
<?php
|
2017-03-14 14:37:14 +00:00
|
|
|
|
|
|
|
|
// Don't refresh this page to stop adding multiple ports
|
|
|
|
|
$no_refresh = true;
|
|
|
|
|
|
2019-04-11 23:26:42 -05:00
|
|
|
require 'includes/html/javascript-interfacepicker.inc.php';
|
2020-09-21 15:40:17 +02:00
|
|
|
|
2015-12-25 00:54:13 +01:00
|
|
|
// This needs more verification. Is it already added? Does it exist?
|
|
|
|
|
// Calculation to extract MB/GB/TB of Kbps/Mbps/Gbps
|
2019-06-23 00:29:12 -05:00
|
|
|
$base = \LibreNMS\Config::get('billing.base');
|
2020-09-21 15:40:17 +02:00
|
|
|
|
2016-08-18 20:28:22 -05:00
|
|
|
if ($bill_data['bill_type'] == 'quota') {
|
2020-09-21 15:40:17 +02:00
|
|
|
$data = $bill_data['bill_quota'];
|
2016-08-18 20:28:22 -05:00
|
|
|
$tmp['mb'] = ($data / $base / $base);
|
|
|
|
|
$tmp['gb'] = ($data / $base / $base / $base);
|
|
|
|
|
$tmp['tb'] = ($data / $base / $base / $base / $base);
|
|
|
|
|
if ($tmp['tb'] >= 1) {
|
2020-09-21 15:40:17 +02:00
|
|
|
$quota = [
|
2016-08-18 20:28:22 -05:00
|
|
|
'type' => 'tb',
|
|
|
|
|
'select_tb' => ' selected',
|
|
|
|
|
'data' => $tmp['tb'],
|
2020-09-21 15:40:17 +02:00
|
|
|
];
|
2016-08-18 20:28:22 -05:00
|
|
|
} elseif (($tmp['gb'] >= 1) and ($tmp['gb'] < $base)) {
|
2020-09-21 15:40:17 +02:00
|
|
|
$quota = [
|
2016-08-18 20:28:22 -05:00
|
|
|
'type' => 'gb',
|
|
|
|
|
'select_gb' => ' selected',
|
|
|
|
|
'data' => $tmp['gb'],
|
2020-09-21 15:40:17 +02:00
|
|
|
];
|
2016-08-18 20:28:22 -05:00
|
|
|
} elseif (($tmp['mb'] >= 1) and ($tmp['mb'] < $base)) {
|
2020-09-21 15:40:17 +02:00
|
|
|
$quota = [
|
2016-08-18 20:28:22 -05:00
|
|
|
'type' => 'mb',
|
|
|
|
|
'select_mb' => ' selected',
|
|
|
|
|
'data' => $tmp['mb'],
|
2020-09-21 15:40:17 +02:00
|
|
|
];
|
2016-08-18 20:28:22 -05:00
|
|
|
}
|
|
|
|
|
}//end if
|
2020-09-21 15:40:17 +02:00
|
|
|
|
2016-08-18 20:28:22 -05:00
|
|
|
if ($bill_data['bill_type'] == 'cdr') {
|
2020-09-21 15:40:17 +02:00
|
|
|
$data = $bill_data['bill_cdr'];
|
2016-08-18 20:28:22 -05:00
|
|
|
$tmp['kbps'] = ($data / $base);
|
|
|
|
|
$tmp['mbps'] = ($data / $base / $base);
|
|
|
|
|
$tmp['gbps'] = ($data / $base / $base / $base);
|
|
|
|
|
if ($tmp['gbps'] >= 1) {
|
2020-09-21 15:40:17 +02:00
|
|
|
$cdr = [
|
2016-08-18 20:28:22 -05:00
|
|
|
'type' => 'gbps',
|
|
|
|
|
'select_gbps' => ' selected',
|
|
|
|
|
'data' => $tmp['gbps'],
|
2020-09-21 15:40:17 +02:00
|
|
|
];
|
2016-08-18 20:28:22 -05:00
|
|
|
} elseif (($tmp['mbps'] >= 1) and ($tmp['mbps'] < $base)) {
|
2020-09-21 15:40:17 +02:00
|
|
|
$cdr = [
|
2016-08-18 20:28:22 -05:00
|
|
|
'type' => 'mbps',
|
|
|
|
|
'select_mbps' => ' selected',
|
|
|
|
|
'data' => $tmp['mbps'],
|
2020-09-21 15:40:17 +02:00
|
|
|
];
|
2016-08-18 20:28:22 -05:00
|
|
|
} elseif (($tmp['kbps'] >= 1) and ($tmp['kbps'] < $base)) {
|
2020-09-21 15:40:17 +02:00
|
|
|
$cdr = [
|
2016-08-18 20:28:22 -05:00
|
|
|
'type' => 'kbps',
|
|
|
|
|
'select_kbps' => ' selected',
|
|
|
|
|
'data' => $tmp['kbps'],
|
2020-09-21 15:40:17 +02:00
|
|
|
];
|
2016-08-18 20:28:22 -05:00
|
|
|
}
|
|
|
|
|
}//end if
|
2020-04-03 08:41:24 -05:00
|
|
|
?>
|
2016-03-07 12:48:27 +00:00
|
|
|
<div class="row">
|
|
|
|
|
<div class="col-lg-6 col-md-12">
|
|
|
|
|
<div class="panel panel-default">
|
|
|
|
|
<div class="panel-heading">
|
|
|
|
|
<h3 class="panel-title">Bill Properties</h3>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="panel-body">
|
|
|
|
|
<form id="edit" name="edit" method="post" action="" class="form-horizontal" role="form">
|
2019-07-17 07:20:26 -05:00
|
|
|
<?php echo csrf_field() ?>
|
2016-03-07 12:48:27 +00:00
|
|
|
<input type=hidden name="action" value="update_bill">
|
|
|
|
|
<script type="text/javascript">
|
|
|
|
|
function billType() {
|
|
|
|
|
$('#cdrDiv').toggle();
|
|
|
|
|
$('#quotaDiv').toggle();
|
|
|
|
|
}
|
|
|
|
|
</script>
|
2019-04-11 23:26:42 -05:00
|
|
|
<?php include 'includes/html/pages/bill/addoreditbill.inc.php'; ?>
|
2016-03-07 12:48:27 +00:00
|
|
|
<div class="form-group">
|
|
|
|
|
<div class="col-sm-offset-4 col-sm-4">
|
|
|
|
|
<button type="submit" class="btn btn-primary" name="Submit" value="Save" /><i class="fa fa-check"></i> Save Properties</button>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</form>
|
|
|
|
|
</div>
|
2014-01-13 10:05:19 +00:00
|
|
|
</div>
|
2016-03-07 12:48:27 +00:00
|
|
|
</div>
|
|
|
|
|
<div class="col-lg-6 col-md-12">
|
|
|
|
|
<div class="panel panel-default">
|
|
|
|
|
<div class="panel-heading">
|
|
|
|
|
<h3 class="panel-title">Billed Ports</h3>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="panel-body">
|
|
|
|
|
<div class="form-group">
|
2016-08-18 20:28:22 -05:00
|
|
|
<?php
|
2016-03-07 12:48:27 +00:00
|
|
|
//This needs a proper cleanup
|
|
|
|
|
$ports = dbFetchRows(
|
|
|
|
|
'SELECT * FROM `bill_ports` AS B, `ports` AS P, `devices` AS D
|
|
|
|
|
WHERE B.bill_id = ? AND P.port_id = B.port_id
|
|
|
|
|
AND D.device_id = P.device_id ORDER BY D.device_id',
|
2020-09-21 15:40:17 +02:00
|
|
|
[$bill_data['bill_id']]
|
2016-03-07 12:48:27 +00:00
|
|
|
);
|
2020-09-21 15:40:17 +02:00
|
|
|
|
2016-03-07 12:48:27 +00:00
|
|
|
if (is_array($ports)) {
|
2020-04-03 08:41:24 -05:00
|
|
|
?>
|
2016-03-07 12:48:27 +00:00
|
|
|
<div class="list-group">
|
2020-04-03 08:41:24 -05:00
|
|
|
<?php foreach ($ports as $port) {
|
|
|
|
|
$port = cleanPort($port);
|
2016-03-07 12:48:27 +00:00
|
|
|
$emptyCheck = true;
|
2020-09-21 15:40:17 +02:00
|
|
|
$portalias = (empty($port['ifAlias']) ? '' : ' - ' . $port['ifAlias'] . ''); ?>
|
2016-03-07 12:48:27 +00:00
|
|
|
<div class="list-group-item">
|
|
|
|
|
<form action="" class="form-inline" method="post" name="delete<?php echo $port['port_id'] ?>" style="display: none;">
|
2019-07-17 07:20:26 -05:00
|
|
|
<?php echo csrf_field() ?>
|
2016-03-07 12:48:27 +00:00
|
|
|
<input type="hidden" name="action" value="delete_bill_port" />
|
|
|
|
|
<input type="hidden" name="port_id" value="<?php echo $port['port_id'] ?>" />
|
|
|
|
|
</form>
|
|
|
|
|
|
|
|
|
|
<button class="btn btn-danger btn-xs pull-right" onclick="if (confirm('Are you sure you wish to remove this port?')) { document.forms['delete<?php echo $port['port_id'] ?>'].submit(); }">
|
|
|
|
|
<i class="fa fa-minus"></i>
|
|
|
|
|
Remove Interface
|
|
|
|
|
</button>
|
|
|
|
|
<?php echo generate_device_link($port); ?>
|
|
|
|
|
<i class="fa fa-random"></i>
|
|
|
|
|
<?php echo generate_port_link($port, $port['ifName'] . '' . $portalias); ?>
|
|
|
|
|
</div>
|
2020-09-21 15:40:17 +02:00
|
|
|
<?php
|
|
|
|
|
}
|
|
|
|
|
if (! $emptyCheck) { ?>
|
2016-03-07 12:48:27 +00:00
|
|
|
<div class="alert alert-info">There are no ports assigned to this bill</alert>
|
2020-04-03 08:41:24 -05:00
|
|
|
<?php } ?>
|
2016-03-07 12:48:27 +00:00
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
2020-04-03 08:41:24 -05:00
|
|
|
<?php
|
2016-03-07 12:48:27 +00:00
|
|
|
}
|
2020-04-12 02:10:45 +02:00
|
|
|
$port_device_id = -1;
|
2020-04-03 08:41:24 -05:00
|
|
|
?>
|
2016-03-07 12:48:27 +00:00
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<h4>Add Port</h4>
|
|
|
|
|
|
|
|
|
|
<form action="" method="post" class="form-horizontal" role="form">
|
2019-07-17 07:20:26 -05:00
|
|
|
<?php echo csrf_field() ?>
|
2016-03-07 12:48:27 +00:00
|
|
|
<input type="hidden" name="action" value="add_bill_port" />
|
|
|
|
|
<input type="hidden" name="bill_id" value="<?php echo $bill_id; ?>" />
|
|
|
|
|
|
|
|
|
|
<div class="form-group">
|
|
|
|
|
<label class="col-sm-2 control-label" for="device">Device</label>
|
|
|
|
|
<div class="col-sm-8">
|
2020-04-12 02:10:45 +02:00
|
|
|
<select class="form-control input-sm" id="device" name="device" onchange="getInterfaceList(this)"></select>
|
|
|
|
|
<script type="text/javascript">
|
|
|
|
|
init_select2('#device', 'device', {}, <?php echo "{id: $port_device_id, text: '" . format_hostname($device) . "'}"; ?>);
|
|
|
|
|
</script>
|
2016-03-07 12:48:27 +00:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="form-group">
|
|
|
|
|
<label class="col-sm-2 control-label" for="port_id">Port</label>
|
|
|
|
|
<div class="col-sm-8">
|
|
|
|
|
<select class="form-control input-sm" id="port_id" name="port_id"></select>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="col-sm-2 col-sm-offset-2">
|
|
|
|
|
<button type="submit" class="btn btn-primary" name="Submit" value=" Add " /><i class="fa fa-plus"></i> Add Port</button>
|
|
|
|
|
</div>
|
|
|
|
|
</form>
|
2014-01-13 10:05:19 +00:00
|
|
|
</div>
|
2015-12-25 00:54:13 +01:00
|
|
|
</div>
|