These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | $no_refresh = true; |
||
4 | $pagetitle[] = 'Previous Billing Period'; |
||
5 | |||
6 | echo '<table class="table table-condensed table-striped"> |
||
7 | <thead> |
||
8 | <tr> |
||
9 | <th>Billing name</th> |
||
10 | <th>Type</th> |
||
11 | <th>Allowed</th> |
||
12 | <th>Inbound</th> |
||
13 | <th>Outbound</th> |
||
14 | <th>Total</th> |
||
15 | <th>95 percentile</th> |
||
16 | <th>Overusage</th> |
||
17 | <th></th> |
||
18 | </tr> |
||
19 | </thead> |
||
20 | <tbody>'; |
||
21 | |||
22 | $wheres = array(); |
||
23 | $params = array(); |
||
24 | |||
25 | View Code Duplication | if (!empty($_GET['search'])) { |
|
0 ignored issues
–
show
|
|||
26 | $wheres[] = 'bills.bill_name LIKE ?'; |
||
27 | $params[] = '%'.$_GET['search'].'%'; |
||
28 | } |
||
29 | View Code Duplication | if (!empty($_GET['bill_type'])) { |
|
0 ignored issues
–
show
This code seems to be duplicated across your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository.
Loading history...
|
|||
30 | $wheres[] = 'bill_history.bill_type = ?'; |
||
31 | $params[] = $_GET['bill_type']; |
||
32 | } |
||
33 | View Code Duplication | if ($_GET['state'] === 'under') { |
|
0 ignored issues
–
show
This code seems to be duplicated across your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository.
Loading history...
|
|||
34 | $wheres[] = 'bill_history.bill_overuse = 0'; |
||
35 | } else if ($_GET['state'] === 'over') { |
||
36 | $wheres[] = 'bill_history.bill_overuse > 0'; |
||
37 | } |
||
38 | |||
39 | $query = 'SELECT bills.bill_name, bill_history.* |
||
40 | FROM `bills` |
||
41 | INNER JOIN (SELECT bill_id, MAX(bill_hist_id) AS bill_hist_id FROM bill_history WHERE bill_dateto < NOW() AND bill_dateto > subdate(NOW(), 40) GROUP BY bill_id) qLastBills ON bills.bill_id = qLastBills.bill_id |
||
42 | INNER JOIN bill_history ON qLastBills.bill_hist_id = bill_history.bill_hist_id |
||
43 | '; |
||
44 | View Code Duplication | if (sizeof($wheres) > 0) { |
|
0 ignored issues
–
show
This code seems to be duplicated across your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository.
Loading history...
|
|||
45 | $query .= 'WHERE ' . implode(' AND ', $wheres) . "\n"; |
||
46 | } |
||
47 | $query .= 'ORDER BY bills.bill_name'; |
||
48 | |||
49 | foreach (dbFetchRows($query, $params) as $bill) { |
||
50 | if (bill_permitted($bill['bill_id'])) { |
||
51 | $datefrom = $bill['bill_datefrom']; |
||
52 | $dateto = $bill['bill_dateto']; |
||
53 | |||
54 | unset($class); |
||
55 | $type = $bill['bill_type']; |
||
56 | $percent = $bill['bill_percent']; |
||
57 | $dir_95th = $bill['dir_95th']; |
||
58 | $rate_95th = format_si($bill['rate_95th']).'bps'; |
||
59 | $total_data = format_bytes_billing($bill['traf_total']); |
||
60 | |||
61 | $background = get_percentage_colours($percent); |
||
62 | |||
63 | if ($type == 'CDR') { |
||
64 | $allowed = format_si($bill['bill_allowed']).'bps'; |
||
65 | $used = format_si($bill['rate_95th']).'bps'; |
||
66 | $in = format_si($bill['rate_95th_in']).'bps'; |
||
67 | $out = format_si($bill['rate_95th_out']).'bps'; |
||
68 | $overuse = (($bill['bill_overuse'] <= 0) ? '-' : '<span style="color: #'.$background['left'].'; font-weight: bold;">'.format_si($bill['bill_overuse']).'bps</span>'); |
||
69 | } |
||
70 | else if ($type == 'Quota') { |
||
71 | $allowed = format_bytes_billing($bill['bill_allowed']); |
||
72 | $used = format_bytes_billing($bill['total_data']); |
||
73 | $in = format_bytes_billing($bill['traf_in']); |
||
74 | $out = format_bytes_billing($bill['traf_out']); |
||
75 | $overuse = (($bill['bill_overuse'] <= 0) ? '-' : '<span style="color: #'.$background['left'].'; font-weight: bold;">'.format_bytes_billing($bill['bill_overuse']).'</span>'); |
||
76 | } |
||
77 | |||
78 | $total_data = (($type == 'Quota') ? '<b>'.$total_data.'</b>' : $total_data); |
||
79 | $rate_95th = (($type == 'CDR') ? '<b>'.$rate_95th.'</b>' : $rate_95th); |
||
80 | |||
81 | echo " |
||
82 | <tr> |
||
83 | <td><a href=\"".generate_url(array('page' => 'bill', 'bill_id' => $bill['bill_id'], 'view' => 'history', detail => $bill['bill_hist_id'])).'"><span style="font-weight: bold;" class="interface">'.$bill['bill_name'].'</a></span><br />from '.strftime('%x', strtotime($datefrom)).' to '.strftime('%x', strtotime($dateto))."</td> |
||
84 | <td>$type</td> |
||
85 | <td>$allowed</td> |
||
86 | <td>$in</td> |
||
87 | <td>$out</td> |
||
88 | <td>$total_data</td> |
||
89 | <td>$rate_95th</td> |
||
90 | <td style=\"text-align: center;\">$overuse</td> |
||
91 | <td>".print_percentage_bar(250, 20, $percent, null, 'ffffff', $background['left'], $percent.'%', 'ffffff', $background['right']).'</td> |
||
92 | </tr>'; |
||
93 | |||
94 | }//end if |
||
95 | }//end foreach |
||
96 | |||
97 | echo '</tbody> |
||
98 | </table>'; |
||
99 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.