Work on Service Reports

This commit is contained in:
Deon George
2013-10-11 00:08:02 +11:00
parent 91980b891e
commit 6f855fb32d
18 changed files with 198 additions and 225 deletions

View File

@@ -0,0 +1,60 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* This class provides Admin ADSL Service functions
*
* @package ADSL
* @category Controllers/Admin
* @author Deon George
* @copyright (c) 2009-2013 Open Source Billing
* @license http://dev.osbill.net/license.html
*/
class Controller_Admin_Service_Adsl extends Controller_Service {
protected $secure_actions = array(
'stat'=>TRUE,
);
public function action_stat() {
// @todo This needs to be configurable.
$traffic = array(1000,2000,5000,10000,25000,50000,75000,100000);
$svs = ORM::factory('Service')->list_bylistgroup('ADSL');
$stats = array();
$output = '';
$ts = 0;
foreach ($svs as $a=>$so) {
// Number of services
if (! isset($stats[$so->product->plugin()->adsl_supplier_plan->speed]['c']))
$stats[$so->product->plugin()->adsl_supplier_plan->speed]['c'] = 0;
$stats[$so->product->plugin()->adsl_supplier_plan->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()->adsl_supplier_plan->speed]['d'][$a]))
$stats[$so->product->plugin()->adsl_supplier_plan->speed]['d'][$a] = 0;
$stats[$so->product->plugin()->adsl_supplier_plan->speed]['d'][$a]++;
}
Block::factory()
->title('ADSL Traffic Summary Stats - Last Month')
->title_icon('icon-list')
->body(
View::factory('service/admin/adslstat')
->set('stats',$stats)
->set('traffic',$traffic)
->set('ts',$ts)
);
}
}
?>

View File

@@ -0,0 +1,35 @@
<table class="table table-striped table-condensed table-hover">
<thead>
<tr>
<th>Speed</th>
<th>#</th>
<th><small>%</small></th>
<?php foreach ($traffic as $i) : ?>
<th><?php echo $i; ?></th>
<th><small>%</small></th>
<?php endforeach ?>
<th>Other</th>
<th><small>%</small></th>
</tr>
</thead>
<tbody>
<?php foreach ($stats as $speed => $details) : ?>
<tr>
<td><?php echo $speed; ?></td>
<td><?php echo $details['c']; ?></td>
<td><small><?php printf('%2.1f',$details['c']/$ts*100); ?></small></td>
<?php foreach ($traffic as $i) : ?>
<td><?php echo $c=isset($details['d'][$i]) ? $details['d'][$i] : 0; ?></td>
<td><small><?php printf('%2.1f',$c/$details['c']*100); ?></small></td>
<?php endforeach ?>
<td><?php echo $c=isset($details['d'][0]) ? $details['d'][0] : 0; ?></td>
<td><small><?php printf('%2.1f',$c/$details['c']*100); ?></small></td>
</tr>
<?php endforeach ?>
</tbody>
</table>

View File

@@ -1 +0,0 @@
<td><?php echo $count; ?></td><td><?php echo $percent; ?></td>

View File

@@ -1,4 +0,0 @@
<tr class="list-data">
<td><?php echo $speed; ?></td>
<td><?php echo $count; ?></td>
<td><?php echo $percent; ?></td>

View File

@@ -1 +0,0 @@
</table>

View File

@@ -1,3 +0,0 @@
<table class="list-box-left">
<tr class="list-head">
<th><?php echo $name; ?></th>

View File

@@ -1 +0,0 @@
<th><?php echo $name; ?></th><th>%</th>