More ADSL updates and fixes from live site

This commit is contained in:
Deon George
2013-11-15 21:05:22 +11:00
parent c66f2f14c4
commit a711e70b60
9 changed files with 118 additions and 229 deletions

View File

@@ -14,6 +14,7 @@ class Controller_Admin_Adsl extends Controller_Adsl {
'index'=>TRUE,
'edit'=>TRUE,
'list'=>TRUE,
'stat'=>TRUE,
'traffic'=>TRUE,
);
@@ -119,6 +120,51 @@ class Controller_Admin_Adsl extends Controller_Adsl {
);
}
/**
* Usage statistics for the previous moth
*/
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()->supplier_plan->speed]['c']))
$stats[$so->product->plugin()->supplier_plan->speed]['c'] = 0;
$stats[$so->product->plugin()->supplier_plan->speed]['c']++;
$ts++;
$a = 0;
foreach (array_reverse($traffic) as $i) {
if ($i < $so->plugin()->traffic_month(strtotime('last month'),TRUE))
break;
$a = $i;
}
if (! isset($stats[$so->product->plugin()->supplier_plan->speed]['d'][$a]))
$stats[$so->product->plugin()->supplier_plan->speed]['d'][$a] = 0;
$stats[$so->product->plugin()->supplier_plan->speed]['d'][$a]++;
}
Block::factory()
->title('ADSL Traffic Summary Stats - Last Month')
->title_icon('icon-list')
->body(
View::factory('adsl/admin/stats')
->set('stats',$stats)
->set('traffic',$traffic)
->set('ts',$ts)
);
}
/**
* Reconcile billing for an ADSL supplier
*/