Added ADSL Stat report
This commit is contained in:
parent
1d2d589ff5
commit
0eecfe8abd
1
modules/adsl/views/service/admin/adslstat/body_data.php
Normal file
1
modules/adsl/views/service/admin/adslstat/body_data.php
Normal file
@ -0,0 +1 @@
|
|||||||
|
<td><?php echo $count; ?></td><td><?php echo $percent; ?></td>
|
1
modules/adsl/views/service/admin/adslstat/body_end.php
Normal file
1
modules/adsl/views/service/admin/adslstat/body_end.php
Normal file
@ -0,0 +1 @@
|
|||||||
|
</tr>
|
4
modules/adsl/views/service/admin/adslstat/body_head.php
Normal file
4
modules/adsl/views/service/admin/adslstat/body_head.php
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
<tr class="list-data">
|
||||||
|
<td><?php echo $speed; ?></td>
|
||||||
|
<td><?php echo $count; ?></td>
|
||||||
|
<td><?php echo $percent; ?></td>
|
1
modules/adsl/views/service/admin/adslstat/foot.php
Normal file
1
modules/adsl/views/service/admin/adslstat/foot.php
Normal file
@ -0,0 +1 @@
|
|||||||
|
</table>
|
3
modules/adsl/views/service/admin/adslstat/head.php
Normal file
3
modules/adsl/views/service/admin/adslstat/head.php
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
<table class="list-box-left">
|
||||||
|
<tr class="list-head">
|
||||||
|
<th><?php echo $name; ?></th>
|
1
modules/adsl/views/service/admin/adslstat/head_data.php
Normal file
1
modules/adsl/views/service/admin/adslstat/head_data.php
Normal file
@ -0,0 +1 @@
|
|||||||
|
<th><?php echo $name; ?></th><th>%</th>
|
1
modules/adsl/views/service/admin/adslstat/head_end.php
Normal file
1
modules/adsl/views/service/admin/adslstat/head_end.php
Normal file
@ -0,0 +1 @@
|
|||||||
|
</tr>
|
@ -13,6 +13,7 @@
|
|||||||
class Controller_Admin_Service extends Controller_TemplateDefault_Admin {
|
class Controller_Admin_Service extends Controller_TemplateDefault_Admin {
|
||||||
protected $secure_actions = array(
|
protected $secure_actions = array(
|
||||||
'autolist'=>FALSE, // @todo To Change
|
'autolist'=>FALSE, // @todo To Change
|
||||||
|
'adslstat'=>TRUE,
|
||||||
'list'=>TRUE,
|
'list'=>TRUE,
|
||||||
'listbycheckout'=>TRUE,
|
'listbycheckout'=>TRUE,
|
||||||
'listadslbilling'=>TRUE,
|
'listadslbilling'=>TRUE,
|
||||||
@ -680,7 +681,76 @@ class Controller_Admin_Service extends Controller_TemplateDefault_Admin {
|
|||||||
'title'=>sprintf('%s: %s',$so->id(),$so->service_name()),
|
'title'=>sprintf('%s: %s',$so->id(),$so->service_name()),
|
||||||
'body'=>$output,
|
'body'=>$output,
|
||||||
));
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function action_adslstat() {
|
||||||
|
$output = '';
|
||||||
|
$svs = ORM::factory('service')->list_bylistgroup('ADSL');
|
||||||
|
$stats = array();
|
||||||
|
// @todo This needs to be configurable.
|
||||||
|
$traffic = array(1000,2000,5000,10000,25000,50000,75000,100000);
|
||||||
|
$ts = 0;
|
||||||
|
|
||||||
|
foreach ($svs as $a=>$so) {
|
||||||
|
// Number of services
|
||||||
|
if (! isset($stats[$so->product->plugin()->speed]['c']))
|
||||||
|
$stats[$so->product->plugin()->speed]['c'] = 0;
|
||||||
|
|
||||||
|
$stats[$so->product->plugin()->speed]['c']++;
|
||||||
|
$ts++;
|
||||||
|
|
||||||
|
// Amount of traffic
|
||||||
|
$t = array_sum($so->plugin()->traffic_lastmonth(FALSE));
|
||||||
|
$a = 0;
|
||||||
|
foreach (array_reverse($traffic) as $i) {
|
||||||
|
if ($i < $t)
|
||||||
|
break;
|
||||||
|
$a = $i;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! isset($stats[$so->product->plugin()->speed]['d'][$a]))
|
||||||
|
$stats[$so->product->plugin()->speed]['d'][$a] = 0;
|
||||||
|
|
||||||
|
$stats[$so->product->plugin()->speed]['d'][$a]++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (count($stats)) {
|
||||||
|
$output .= View::factory($this->viewpath().'/head')
|
||||||
|
->set('name','SPEED');
|
||||||
|
$output .= View::factory($this->viewpath().'/head_data')
|
||||||
|
->set('name','#');
|
||||||
|
foreach ($traffic as $i)
|
||||||
|
$output .= View::factory($this->viewpath().'/head_data')
|
||||||
|
->set('name',$i);
|
||||||
|
$output .= View::factory($this->viewpath().'/head_data')
|
||||||
|
->set('name','Other');
|
||||||
|
$output .= View::factory($this->viewpath().'/head_end');
|
||||||
|
|
||||||
|
foreach ($stats as $speed => $details) {
|
||||||
|
$output .= View::factory($this->viewpath().'/body_head')
|
||||||
|
->set('count',$details['c'])
|
||||||
|
->set('percent',sprintf('%2.1f',$details['c']/$ts*100))
|
||||||
|
->set('speed',$speed);
|
||||||
|
|
||||||
|
foreach ($traffic as $i) {
|
||||||
|
$output .= View::factory($this->viewpath().'/body_data')
|
||||||
|
->set('count',$c=isset($details['d'][$i]) ? $details['d'][$i] : 0)
|
||||||
|
->set('percent',sprintf('%2.1f',$c/$details['c']*100));
|
||||||
|
}
|
||||||
|
|
||||||
|
$output .= View::factory($this->viewpath().'/body_data')
|
||||||
|
->set('count',$c=isset($details['d'][0]) ? $details['d'][0] : 0)
|
||||||
|
->set('percent',sprintf('%2.1f',$c/$details['c']*100));
|
||||||
|
$output .= View::factory($this->viewpath().'/body_end');
|
||||||
|
}
|
||||||
|
|
||||||
|
$output .= View::factory($this->viewpath().'/foot');
|
||||||
|
}
|
||||||
|
|
||||||
|
Block::add(array(
|
||||||
|
'title'=>_('ADSL Traffic Summary Stats - Last Month'),
|
||||||
|
'body'=>$output,
|
||||||
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
Reference in New Issue
Block a user