mirror of
https://github.com/stylersnico/librenms.git
synced 2026-07-12 16:06:25 +02:00
prettier billing editing/adding
git-svn-id: http://www.observium.org/svn/observer/trunk@2902 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
+165
-81
@@ -4,111 +4,195 @@ include("includes/javascript-interfacepicker.inc.php");
|
||||
|
||||
### This needs more verification. Is it already added? Does it exist?
|
||||
|
||||
echo("
|
||||
### Calculation to extract MB/GB/TB of Kbps/Mbps/Gbps
|
||||
|
||||
<h3>Bill Properties</h3>
|
||||
$base = $config["billing"]["base"];
|
||||
|
||||
<form id='edit' name='edit' method='post' action=''>
|
||||
<input type=hidden name='action' value='update_bill'>
|
||||
<table width='400' border='0'>
|
||||
<tr>
|
||||
<td><div align='right'>Name</div></td>
|
||||
<td colspan='3'><input name='bill_name' size='32' value='" . $bill_data['bill_name'] . "'></input></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td width='300'><div align='right'>Billing Day</div></td>
|
||||
<td colspan='3'><input name='bill_day' size='20' value='" . $bill_data['bill_day'] . "'></input>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td width='300'><div align='right'>Monthly Quota</div></td>
|
||||
<td colspan='3'><input name='bill_quota' size='20' value='" . $bill_data['bill_quota']/$config['billing']['base']/$config['billing']['base']/$config['billing']['base'] . "'></input>GB
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td width='300'><div align='right'>CDR with 95th</div></td>
|
||||
<td colspan='3'><input name='bill_cdr' size='20' value='" . $bill_data['bill_cdr']/1000 . "'></input>Kbps
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align='right'>
|
||||
Type
|
||||
</td>
|
||||
<td>
|
||||
<select name='bill_type'>");
|
||||
|
||||
$bill_data_types = array ('cdr' => 'CDR with 95th', 'quota' => 'Monthly Quota');
|
||||
|
||||
$unknown = 1;
|
||||
foreach ($bill_data_types as $type => $text)
|
||||
{
|
||||
echo(' <option value="'.$type.'"');
|
||||
if ($bill_data['bill_type'] == $type)
|
||||
{
|
||||
echo('selected="1"');
|
||||
$unknown = 0;
|
||||
}
|
||||
echo(' >' . ucfirst($text) . '</option>');
|
||||
if ($bill_data['bill_type'] == "quota") {
|
||||
$data = $bill_data['bill_quota'];
|
||||
$tmp['mb'] = $data / $base / $base;
|
||||
$tmp['gb'] = $data / $base / $base / $base;
|
||||
$tmp['tb'] = $data / $base / $base / $base / $base;
|
||||
if (($tmp['tb']>1) and ($tmp['tb']<$base)) { $quota = array("type" => "tb", "select_tb" => " selected", "data" => $tmp['tb']); }
|
||||
elseif (($tmp['gb']>1) and ($tmp['gb']<$base)) { $quota = array("type" => "gb", "select_gb" => " selected", "data" => $tmp['gb']); }
|
||||
elseif (($tmp['mb']>1) and ($tmp['mb']<$base)) { $quota = array("type" => "mb", "select_mb" => " selected", "data" => $tmp['mb']); }
|
||||
}
|
||||
echo("
|
||||
if ($bill_data['bill_type'] == "cdr") {
|
||||
$data = $bill_data['bill_cdr'];
|
||||
$tmp['kbps'] = $data / $base / $base;
|
||||
$tmp['mbps'] = $data / $base / $base / $base;
|
||||
$tmp['gbps'] = $data / $base / $base / $base / $base;
|
||||
if ($tmp['gbps']>1 and ($tmp['mbps']<$base)) { $cdr = array("type" => "gbps", "select_tbps" => " selected", "data" => $tmp['gbps']); }
|
||||
elseif (($tmp['mbps']>1) and ($tmp['mbps']<$base)) { $cdr = array("type" => "mbps", "select_gbps" => " selected", "data" => $tmp['mbps']); }
|
||||
elseif (($tmp['kbps']>1) and ($tmp['kbps']<$base)) { $cdr = array("type" => "kbps", "select_mbps" => " selected", "data" => $tmp['kbps']); }
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<form id="edit" name="edit" method="post" action="" class="form-horizontal">
|
||||
<input type=hidden name="action" value="update_bill">
|
||||
<link rel="stylesheet" href="<?php echo $config["base_url"]; ?>/css/bootstrap.min.css">
|
||||
<script type="text/javascript">
|
||||
function billType() {
|
||||
$('#cdrDiv').toggle();
|
||||
$('#quotaDiv').toggle();
|
||||
}
|
||||
</script>
|
||||
<fieldset>
|
||||
<legend>Bill Properties</legend>
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="bill_name"><strong>Description</strong></label>
|
||||
<div class="controls">
|
||||
<input class="span4" name="bill_name" value="<?php echo $bill_data["bill_name"]; ?>" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="bill_type"><strong>Billing Type</strong></label>
|
||||
<div class="controls">
|
||||
<input type="radio" name="bill_type" value="cdr" onchange="javascript: billType();" <?php if($bill_data['bill_type'] == "cdr") { echo('checked '); } ?>/> CDR 95th
|
||||
<input type="radio" name="bill_type" value="quota" onchange="javascript: billType();" <?php if($bill_data['bill_type'] == "quota") { echo('checked '); } ?>/> Quota
|
||||
<div id="cdrDiv"<?php if($bill_data['bill_type'] == "quota") { echo(' style="display: none"'); } ?>>
|
||||
<input class="span1" type="text" name="bill_cdr" value="<?php echo $cdr['data']; ?>">
|
||||
<select name="bill_cdr_type" style="width: 233px;">
|
||||
<option value="Kbps"<?php echo $cdr['select_kbps']; ?>>Kilobits per second (Kbps)</option>
|
||||
<option value="Mbps"<?php echo $cdr['select_mbps']; ?>>Megabits per second (Mbps)</option>
|
||||
<option value="Gbps"<?php echo $cdr['select_gbps']; ?>>Gigabits per second (Gbps)</option>
|
||||
</select>
|
||||
</div>
|
||||
<div id="quotaDiv"<?php if($bill_data['bill_type'] == "cdr") { echo(' style="display: none"'); } ?>>
|
||||
<input class="span1" type="text" name="bill_quota" value="<?php echo $quota['data']; ?>">
|
||||
<select name="bill_quota_type" style="width: 233px;">
|
||||
<option value="MB"<?php echo $quota['select_mb']; ?>>Megabytes (MB)</option>
|
||||
<option value="GB"<?php echo $quota['select_gb']; ?>>Gigabytes (GB)</option>
|
||||
<option value="TB"<?php echo $quota['select_tb']; ?>>Terabytes (TB)</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="bill_day"><strong>Billing Day</strong></label>
|
||||
<div class="controls">
|
||||
<select name="bill_day" style="width: 60px;">
|
||||
<?php
|
||||
|
||||
for ($x=1;$x<32;$x++) {
|
||||
$select = (($bill_data['bill_day'] == $x) ? " selected" : "");
|
||||
echo(" <option value=\"".$x."\"".$select.">".$x."</option>\n");
|
||||
}
|
||||
|
||||
?>
|
||||
</select>
|
||||
</td>
|
||||
</tr>");
|
||||
|
||||
echo('
|
||||
</table>
|
||||
<input type="submit" name="Submit" value="Save" />
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<legend>Optional Information</legend>
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="bill_custid"><strong>Customer Reference</strong></label>
|
||||
<div class="controls">
|
||||
<input class="span4" type="text" name="bill_custid" value="<?php echo $bill_data['bill_custid']; ?>" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="bill_ref"><strong>Billing Reference</strong></label>
|
||||
<div class="controls">
|
||||
<input class="span4" type="text" name="bill_ref" value="<?php echo $bill_data['bill_ref']; ?>" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="bill_notes"><strong>Notes</strong></label>
|
||||
<div class="controls">
|
||||
<input class="span4" type="textarea" name="bill_notes" value="<?php echo $bill_data['bill_notes']; ?>" />
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
<div class="form-actions">
|
||||
<button type="submit" class="btn btn-success" name="Submit" value="Save" /><i class="icon-ok icon-white"></i> <strong>Save Properties</strong></button>
|
||||
</div>
|
||||
</form>
|
||||
');
|
||||
|
||||
echo("<hr />");
|
||||
<form class="form-horizontal">
|
||||
<fieldset>
|
||||
<legend>Billed Ports</legend>
|
||||
<div class="control-group">
|
||||
<?php
|
||||
|
||||
$ports = dbFetchRows("SELECT * FROM `bill_ports` AS B, `ports` AS P, `devices` AS D
|
||||
WHERE B.bill_id = ? AND P.interface_id = B.port_id
|
||||
AND D.device_id = P.device_id", array($bill_data['bill_id']));
|
||||
AND D.device_id = P.device_id ORDER BY D.device_id", array($bill_data['bill_id']));
|
||||
|
||||
if (is_array($ports))
|
||||
{
|
||||
echo("<h3>Billed Ports</h3>");
|
||||
|
||||
echo("<table cellpadding=5 cellspacing=0>");
|
||||
foreach ($ports as $port)
|
||||
{
|
||||
if ($bg == $list_colour_a) { $bg = $list_colour_b; } else { $bg=$list_colour_a; }
|
||||
echo("<tr style=\"background-color: $bg\">");
|
||||
echo("<td>");
|
||||
echo(generate_device_link($port) . " - " . generate_port_link($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>");
|
||||
$emptyCheck = true;
|
||||
$devicebtn = str_replace("list-device", "btn", generate_device_link($port));
|
||||
$portbtn = str_replace("interface-upup", "btn", generate_port_link($port));
|
||||
$portbtn = str_replace("interface-updown", "btn btn-warning", $portbtn);
|
||||
$portbtn = str_replace("interface-downdown", "btn btn-warning", $portbtn);
|
||||
$portbtn = str_replace("interface-admindown", "btn btn-warning disabled", $portbtn);
|
||||
$portalias = (empty($port['ifAlias']) ? "" : " - ".$port['ifAlias']."");
|
||||
$devicebtn = str_replace("\">".$port['hostname'], "\" style=\"color: #000;\"><i class=\"icon-asterisk\"></i> ".$port['hostname'], $devicebtn);
|
||||
$portbtn = str_replace("\">".strtolower($port['ifName']), "\" style=\"color: #000;\"><i class=\"icon-random\"></i> ".$port['ifName']."".$portalias, $portbtn);
|
||||
echo(" <form action=\"\" method=\"post\" name=\"delete".$port['interface_id']."\" style=\"display: none;\">\n");
|
||||
echo(" <input type=\"hidden\" name=\"action\" value=\"delete_bill_port\" />\n");
|
||||
echo(" <input type=\"hidden\" name=\"interface_id\" value=\"".$port['interface_id']."\" />\n");
|
||||
echo(" </form>\n");
|
||||
echo(" <div class=\"btn-toolbar\">\n");
|
||||
echo(" <div class=\"btn-group\" style=\"width: 600px;\">\n");
|
||||
//echo(" <a class=\"btn btn-danger\" href=\"javascript:;\" onclick=\"document.delete".$port['interface_id'].".submit();\" style=\"color: #fff;\"><i class=\"icon-trash icon-white\"></i></a>\n");
|
||||
echo(" ".$devicebtn."\n");
|
||||
echo(" ".$portbtn."\n");
|
||||
echo(" </div>\n");
|
||||
echo(" <div class=\"btn-group\">\n");
|
||||
echo(" <a class=\"btn btn-danger btn-mini\" href=\"javascript:;\" onclick=\"document.delete".$port['interface_id'].".submit();\" style=\"color: #fff;\"><i class=\"icon-minus-sign icon-white\"></i> <strong>Remove Interface</strong></a>\n");
|
||||
echo(" </div>\n");
|
||||
echo(" </div>\n");
|
||||
}
|
||||
if (!$emptyCheck) {
|
||||
echo(" <div class=\"alert alert-info\">\n");
|
||||
echo(" <i class=\"icon-info-sign\"></i> <strong>There are no ports assigned to this bill</strong>\n");
|
||||
echo(" </div>\n");
|
||||
}
|
||||
echo("</table>");
|
||||
}
|
||||
|
||||
echo("<h4>Add Port</h4>");
|
||||
|
||||
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>");
|
||||
?>
|
||||
</div>
|
||||
</fieldset>
|
||||
</form>
|
||||
<form action="" method="post" class="form-horizontal">
|
||||
<input type="hidden" name="action" value="add_bill_port" />
|
||||
<input type="hidden" name="bill_id" value="<?php echo $bill_id; ?>" />
|
||||
<fieldset>
|
||||
<legend>Add Port</legend>
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="device"><strong>Device</strong></label>
|
||||
<div class="controls">
|
||||
<select style="width: 300px;" id="device" name="device" onchange="getInterfaceList(this)">
|
||||
<option value=''>Select a device</option>
|
||||
<?php
|
||||
|
||||
$devices = dbFetchRows("SELECT * FROM `devices` ORDER BY hostname");
|
||||
foreach ($devices as $device)
|
||||
{
|
||||
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>"); }
|
||||
if (!$done) { echo(" <option value='" . $device['device_id'] . "'>" . $device['hostname'] . "</option>\n"); }
|
||||
}
|
||||
|
||||
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>");
|
||||
|
||||
?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="interface_id"><strong>Interface</strong></label>
|
||||
<div class="controls">
|
||||
<select style="width: 300px;" id="interface_id" name="interface_id"></select>
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
<div class="form-actions">
|
||||
<button type="submit" class="btn btn-primary" name="Submit" value=" Add " /><i class="icon-plus-sign icon-white"></i> <strong>Add Interface</strong></button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
Reference in New Issue
Block a user