2013-06-04 11:50:41 +00:00
|
|
|
<?php defined('SYSPATH') or die('No direct access allowed.');
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This class provides Reseller ADSL Service functions
|
|
|
|
*
|
|
|
|
* @package ADSL
|
|
|
|
* @category Controllers/Reseller
|
|
|
|
* @author Deon George
|
|
|
|
* @copyright (c) 2009-2013 Open Source Billing
|
|
|
|
* @license http://dev.osbill.net/license.html
|
|
|
|
*/
|
|
|
|
class Controller_Reseller_Service_Adsl extends Controller_Service {
|
|
|
|
protected $secure_actions = array(
|
|
|
|
'list'=>TRUE,
|
|
|
|
);
|
|
|
|
|
|
|
|
private function consoltraffic($svs,$date) {
|
|
|
|
$data = array();
|
|
|
|
|
|
|
|
foreach ($svs as $so) {
|
|
|
|
$c = array();
|
|
|
|
foreach ($so->plugin()->get_traffic_data_monthly($date) as $metric => $ma) {
|
|
|
|
foreach ($ma as $month => $traffic) {
|
|
|
|
// Only count the service once, not for each metric.
|
|
|
|
if (! isset($c[$month])) {
|
|
|
|
if (isset($data['svs'][$month]))
|
|
|
|
$data['svs'][$month] += 1;
|
|
|
|
else
|
|
|
|
$data['svs'][$month] = 1;
|
|
|
|
|
|
|
|
$c[$month] = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isset($data['data'][$metric][$month]))
|
|
|
|
$data['data'][$metric][$month] += (int)$traffic;
|
|
|
|
else
|
|
|
|
$data['data'][$metric][$month] = (int)$traffic;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ksort($data['svs']);
|
|
|
|
foreach ($data['data'] as $metric => $details)
|
|
|
|
ksort($data['data'][$metric]);
|
|
|
|
|
|
|
|
return $data;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function action_list() {
|
2013-06-10 11:48:06 +00:00
|
|
|
$svs = ORM::factory('Service')->where('account_id','IN',$this->ao->RTM->customers($this->ao->RTM))->list_byplugin('ADSL');
|
2013-06-04 11:50:41 +00:00
|
|
|
|
|
|
|
$data = $this->consoltraffic($svs,time());
|
|
|
|
|
|
|
|
$google = GoogleChart::factory('Legacy')
|
|
|
|
->type('vertical_bar')
|
|
|
|
->title(sprintf('ADSL traffic as at %s',date('Y-m-d',strtotime('yesterday'))));
|
|
|
|
|
|
|
|
foreach ($data['data'] as $key => $values)
|
|
|
|
$google->sdata(array('yl'=>$key),array($key=>$values));
|
|
|
|
|
|
|
|
$google->sdata(array('yr'=>'services'),array('services'=>$data['svs']));
|
|
|
|
|
|
|
|
Block::add(array('body'=>(string)$google));
|
|
|
|
|
|
|
|
Block::factory()
|
|
|
|
->title('ADSL Services')
|
|
|
|
->title_icon('icon-th-list')
|
|
|
|
->body(Table::factory()
|
|
|
|
->jssort('adsl')
|
|
|
|
->data($svs)
|
|
|
|
->columns(array(
|
|
|
|
'id'=>'ID',
|
|
|
|
'name()'=>'Service',
|
|
|
|
'plugin()->ipaddress()'=>'IP Address',
|
2013-06-17 12:47:44 +00:00
|
|
|
'product->plugin()->adsl_supplier_plan->speed'=>'Speed',
|
2013-06-04 11:50:41 +00:00
|
|
|
'product->plugin()->allowance()'=>'Allowance',
|
|
|
|
'plugin()->traffic_thismonth()'=>'This Month',
|
|
|
|
'plugin()->traffic_lastmonth()'=>'Last Month',
|
|
|
|
'recur_schedule'=>'Billing',
|
|
|
|
'price(TRUE,TRUE)'=>'Price',
|
|
|
|
'account->accnum()'=>'Cust ID',
|
|
|
|
'account->name()'=>'Customer',
|
|
|
|
'date_next_invoice'=>'Next Invoice',
|
|
|
|
'due(TRUE)'=>'Due Invoices',
|
|
|
|
))
|
|
|
|
->prepend(array(
|
|
|
|
'id'=>array('url'=>URL::link('user','service/view/')),
|
|
|
|
))
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
?>
|