1 | <?php |
||||
2 | |||||
3 | // Don't refresh this page to stop adding multiple ports |
||||
4 | $no_refresh = true; |
||||
5 | |||||
6 | require 'includes/html/javascript-interfacepicker.inc.php'; |
||||
7 | |||||
8 | // This needs more verification. Is it already added? Does it exist? |
||||
9 | // Calculation to extract MB/GB/TB of Kbps/Mbps/Gbps |
||||
10 | $base = \LibreNMS\Config::get('billing.base'); |
||||
11 | |||||
12 | if ($bill_data['bill_type'] == 'quota') { |
||||
13 | $data = $bill_data['bill_quota']; |
||||
14 | $tmp['mb'] = ($data / $base / $base); |
||||
15 | $tmp['gb'] = ($data / $base / $base / $base); |
||||
16 | $tmp['tb'] = ($data / $base / $base / $base / $base); |
||||
17 | if ($tmp['tb'] >= 1) { |
||||
18 | $quota = [ |
||||
19 | 'type' => 'tb', |
||||
20 | 'select_tb' => ' selected', |
||||
21 | 'data' => $tmp['tb'], |
||||
22 | ]; |
||||
23 | } elseif (($tmp['gb'] >= 1) and ($tmp['gb'] < $base)) { |
||||
24 | $quota = [ |
||||
25 | 'type' => 'gb', |
||||
26 | 'select_gb' => ' selected', |
||||
27 | 'data' => $tmp['gb'], |
||||
28 | ]; |
||||
29 | } elseif (($tmp['mb'] >= 1) and ($tmp['mb'] < $base)) { |
||||
30 | $quota = [ |
||||
31 | 'type' => 'mb', |
||||
32 | 'select_mb' => ' selected', |
||||
33 | 'data' => $tmp['mb'], |
||||
34 | ]; |
||||
35 | } |
||||
36 | }//end if |
||||
37 | |||||
38 | if ($bill_data['bill_type'] == 'cdr') { |
||||
39 | $data = $bill_data['bill_cdr']; |
||||
40 | $tmp['kbps'] = ($data / $base); |
||||
41 | $tmp['mbps'] = ($data / $base / $base); |
||||
42 | $tmp['gbps'] = ($data / $base / $base / $base); |
||||
43 | if ($tmp['gbps'] >= 1) { |
||||
44 | $cdr = [ |
||||
45 | 'type' => 'gbps', |
||||
46 | 'select_gbps' => ' selected', |
||||
47 | 'data' => $tmp['gbps'], |
||||
48 | ]; |
||||
49 | } elseif (($tmp['mbps'] >= 1) and ($tmp['mbps'] < $base)) { |
||||
50 | $cdr = [ |
||||
51 | 'type' => 'mbps', |
||||
52 | 'select_mbps' => ' selected', |
||||
53 | 'data' => $tmp['mbps'], |
||||
54 | ]; |
||||
55 | } elseif (($tmp['kbps'] >= 1) and ($tmp['kbps'] < $base)) { |
||||
56 | $cdr = [ |
||||
57 | 'type' => 'kbps', |
||||
58 | 'select_kbps' => ' selected', |
||||
59 | 'data' => $tmp['kbps'], |
||||
60 | ]; |
||||
61 | } |
||||
62 | }//end if |
||||
63 | ?> |
||||
64 | <div class="row"> |
||||
65 | <div class="col-lg-6 col-md-12"> |
||||
66 | <div class="panel panel-default"> |
||||
67 | <div class="panel-heading"> |
||||
68 | <h3 class="panel-title">Bill Properties</h3> |
||||
69 | </div> |
||||
70 | <div class="panel-body"> |
||||
71 | <form id="edit" name="edit" method="post" action="" class="form-horizontal" role="form"> |
||||
72 | <?php echo csrf_field() ?> |
||||
73 | <input type=hidden name="action" value="update_bill"> |
||||
74 | <script type="text/javascript"> |
||||
75 | function billType() { |
||||
76 | $('#cdrDiv').toggle(); |
||||
77 | $('#quotaDiv').toggle(); |
||||
78 | } |
||||
79 | </script> |
||||
80 | <?php include 'includes/html/pages/bill/addoreditbill.inc.php'; ?> |
||||
81 | <div class="form-group"> |
||||
82 | <div class="col-sm-offset-4 col-sm-4"> |
||||
83 | <button type="submit" class="btn btn-primary" name="Submit" value="Save" /><i class="fa fa-check"></i> Save Properties</button> |
||||
84 | </div> |
||||
85 | </div> |
||||
86 | </form> |
||||
87 | </div> |
||||
88 | </div> |
||||
89 | </div> |
||||
90 | <div class="col-lg-6 col-md-12"> |
||||
91 | <div class="panel panel-default"> |
||||
92 | <div class="panel-heading"> |
||||
93 | <h3 class="panel-title">Billed Ports</h3> |
||||
94 | </div> |
||||
95 | <div class="panel-body"> |
||||
96 | <div class="form-group"> |
||||
97 | <?php |
||||
98 | //This needs a proper cleanup |
||||
99 | $ports = dbFetchRows( |
||||
100 | 'SELECT * FROM `bill_ports` AS B, `ports` AS P, `devices` AS D |
||||
101 | WHERE B.bill_id = ? AND P.port_id = B.port_id |
||||
102 | AND D.device_id = P.device_id ORDER BY D.device_id', |
||||
103 | [$bill_data['bill_id']] |
||||
104 | ); |
||||
105 | |||||
106 | if (is_array($ports)) { |
||||
0 ignored issues
–
show
introduced
by
Loading history...
|
|||||
107 | ?> |
||||
108 | <div class="list-group"> |
||||
109 | <?php foreach ($ports as $port) { |
||||
110 | $port = cleanPort($port); |
||||
111 | $emptyCheck = true; |
||||
112 | $portalias = (empty($port['ifAlias']) ? '' : ' - ' . $port['ifAlias'] . ''); ?> |
||||
113 | <div class="list-group-item"> |
||||
114 | <form action="" class="form-inline" method="post" name="delete<?php echo $port['port_id'] ?>" style="display: none;"> |
||||
115 | <?php echo csrf_field() ?> |
||||
116 | <input type="hidden" name="action" value="delete_bill_port" /> |
||||
117 | <input type="hidden" name="port_id" value="<?php echo $port['port_id'] ?>" /> |
||||
118 | </form> |
||||
119 | |||||
120 | <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(); }"> |
||||
121 | <i class="fa fa-minus"></i> |
||||
122 | Remove Interface |
||||
123 | </button> |
||||
124 | <?php echo generate_device_link($port); ?> |
||||
125 | <i class="fa fa-random"></i> |
||||
126 | <?php echo generate_port_link($port, $port['ifName'] . '' . $portalias); ?> |
||||
0 ignored issues
–
show
Are you sure
generate_port_link($port...me'] . '' . $portalias) of type array|string can be used in echo ?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
127 | </div> |
||||
128 | <?php |
||||
129 | } |
||||
130 | if (! $emptyCheck) { ?> |
||||
131 | <div class="alert alert-info">There are no ports assigned to this bill</alert> |
||||
132 | <?php } ?> |
||||
133 | |||||
134 | </div> |
||||
135 | |||||
136 | <?php |
||||
137 | } |
||||
138 | $port_device_id = -1; |
||||
139 | ?> |
||||
140 | </div> |
||||
141 | |||||
142 | <h4>Add Port</h4> |
||||
143 | |||||
144 | <form action="" method="post" class="form-horizontal" role="form"> |
||||
145 | <?php echo csrf_field() ?> |
||||
146 | <input type="hidden" name="action" value="add_bill_port" /> |
||||
147 | <input type="hidden" name="bill_id" value="<?php echo $bill_id; ?>" /> |
||||
148 | |||||
149 | <div class="form-group"> |
||||
150 | <label class="col-sm-2 control-label" for="device">Device</label> |
||||
151 | <div class="col-sm-8"> |
||||
152 | <select class="form-control input-sm" id="device" name="device" onchange="getInterfaceList(this)"></select> |
||||
153 | <script type="text/javascript"> |
||||
154 | init_select2('#device', 'device', {}, <?php echo "{id: $port_device_id, text: '" . format_hostname($device) . "'}"; ?>); |
||||
155 | </script> |
||||
156 | </div> |
||||
157 | </div> |
||||
158 | <div class="form-group"> |
||||
159 | <label class="col-sm-2 control-label" for="port_id">Port</label> |
||||
160 | <div class="col-sm-8"> |
||||
161 | <select class="form-control input-sm" id="port_id" name="port_id"></select> |
||||
162 | </div> |
||||
163 | </div> |
||||
164 | <div class="col-sm-2 col-sm-offset-2"> |
||||
165 | <button type="submit" class="btn btn-primary" name="Submit" value=" Add " /><i class="fa fa-plus"></i> Add Port</button> |
||||
166 | </div> |
||||
167 | </form> |
||||
168 | </div> |
||||
169 | </div> |
||||
170 |