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,
|
|
|
|
);
|
|
|
|
|
2013-11-14 11:50:35 +00:00
|
|
|
private function consoltraffic($period) {
|
|
|
|
$result = array();
|
2013-06-04 11:50:41 +00:00
|
|
|
|
2013-11-14 11:50:35 +00:00
|
|
|
$periodstart = mktime(0,0,0,date('m',$period),1,date('Y',$period)-1);
|
2013-06-04 11:50:41 +00:00
|
|
|
|
2013-11-14 11:50:35 +00:00
|
|
|
$t = ORM::factory('Service_Plugin_Adsl_Traffic')
|
|
|
|
->select(array('date_format(date,\'%y-%m\')','month'))
|
|
|
|
->selectsummetric()
|
|
|
|
->join('service__adsl','INNER')
|
|
|
|
->on('service__adsl.service_username','=','service_plugin_adsl_traffic.service')
|
|
|
|
->on('service__adsl.site_id','=','service_plugin_adsl_traffic.site_id')
|
|
|
|
->join('service','INNER')
|
|
|
|
->on('service__adsl.service_id','=','service.id')
|
|
|
|
->on('service__adsl.site_id','=','service.site_id')
|
|
|
|
->where_authorised($this->ao,'service.account_id')
|
|
|
|
->and_where('date','>=',date('Y-m-d',$periodstart))
|
|
|
|
->and_where('date','<=',date('Y-m-d',strtotime('last day of '.date('M Y',$period))))
|
|
|
|
->group_by('date_format(date,\'%Y-%m\')');
|
2013-06-04 11:50:41 +00:00
|
|
|
|
2013-11-14 11:50:35 +00:00
|
|
|
foreach ($t->find_all() as $to)
|
|
|
|
foreach ($to->traffic_data() as $metric => $v)
|
|
|
|
$result[$metric][$to->month] = $v;
|
2013-06-04 11:50:41 +00:00
|
|
|
|
2013-11-14 11:50:35 +00:00
|
|
|
return $result;
|
2013-06-04 11:50:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public function action_list() {
|
2013-11-14 11:50:35 +00:00
|
|
|
$highchart = HighChart::factory('Combo');
|
|
|
|
$highchart->title(sprintf('Monthly DSL traffic usage as at %s',date('Y-m-d',strtotime('yesterday'))));
|
2013-11-22 04:36:50 +00:00
|
|
|
$highchart->ymetric('MB');
|
2013-06-04 11:50:41 +00:00
|
|
|
|
2013-11-14 11:50:35 +00:00
|
|
|
$c = 0;
|
|
|
|
foreach ($this->consoltraffic(time()) as $k => $details) {
|
|
|
|
$highchart->series('column','yl')
|
|
|
|
->name($k)
|
|
|
|
->data($details)
|
|
|
|
->index($c)
|
|
|
|
->order($c++*-1); // This is a kludge to get around highcharts rendering from the bottom up.
|
2013-06-04 11:50:41 +00:00
|
|
|
|
2013-11-14 11:50:35 +00:00
|
|
|
$highchart->autopie($k);
|
|
|
|
}
|
2013-06-04 11:50:41 +00:00
|
|
|
|
2013-11-14 11:50:35 +00:00
|
|
|
Block::factory()
|
|
|
|
->body((string)$highchart);
|
2013-06-04 11:50:41 +00:00
|
|
|
|
|
|
|
Block::factory()
|
|
|
|
->title('ADSL Services')
|
|
|
|
->title_icon('icon-th-list')
|
|
|
|
->body(Table::factory()
|
|
|
|
->jssort('adsl')
|
2013-11-14 11:50:35 +00:00
|
|
|
->data(ORM::factory('Service')->where_authorised($this->ao)->list_byplugin('ADSL'))
|
2013-06-04 11:50:41 +00:00
|
|
|
->columns(array(
|
|
|
|
'id'=>'ID',
|
|
|
|
'name()'=>'Service',
|
|
|
|
'plugin()->ipaddress()'=>'IP Address',
|
2013-11-14 11:50:35 +00:00
|
|
|
'product->plugin()->supplier_plan->speed'=>'Speed',
|
2013-11-18 04:18:50 +00:00
|
|
|
'product->plugin()->allowance(array(),TRUE,TRUE,TRUE)'=>'Allowance',
|
|
|
|
'plugin()->traffic_month(strtotime("yesterday"),TRUE,TRUE)'=>'This Month',
|
2013-12-31 06:18:49 +00:00
|
|
|
'plugin()->traffic_month(strtotime("first day of last month"),TRUE,TRUE)'=>'Last Month',
|
2013-06-04 11:50:41 +00:00
|
|
|
'recur_schedule'=>'Billing',
|
|
|
|
'price(TRUE,TRUE)'=>'Price',
|
2016-07-29 13:04:34 +00:00
|
|
|
'account->refnum()'=>'Cust ID',
|
2013-06-04 11:50:41 +00:00
|
|
|
'account->name()'=>'Customer',
|
|
|
|
'date_next_invoice'=>'Next Invoice',
|
|
|
|
'due(TRUE)'=>'Due Invoices',
|
|
|
|
))
|
|
|
|
->prepend(array(
|
|
|
|
'id'=>array('url'=>URL::link('user','service/view/')),
|
|
|
|
))
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
?>
|