Added Traffic Data matching

This commit is contained in:
Deon George 2013-10-11 15:02:56 +11:00
parent 6e95184b0c
commit 335e8e65bd
3 changed files with 75 additions and 0 deletions

View File

@ -0,0 +1,70 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* This class provides Admin ADSL 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_Adsl extends Controller_Adsl {
protected $secure_actions = array(
'index'=>TRUE,
'traffic'=>TRUE,
);
public function action_index() {
$output = '';
$output .= Form::open(URL::link('admin','adsl/traffic'));
$output .= Form::select('sid',ORM::factory('ADSL_Supplier')->list_select());
$output .= Form::button('submit','Submit',array('class'=>'btn btn-primary'));
$output .= Form::close();
Block::factory()
->title('Select ADSL Supplier')
->title_icon('icon-share')
->body($output);
}
/**
* Reconcile billing for an ADSL supplier
*/
public function action_traffic() {
if (empty($_POST['sid']))
HTTP::redirect(URL::link('admin','adsl/index'));
$aso = ORM::factory('ADSL_Supplier',$_POST['sid']);
if (! $aso->loaded())
HTTP::redirect(URL::link('admin','adsl/index'));
$t = ORM::factory('Service_Plugin_Adsl_Traffic');
$date = date('Y-m-d',time()-86400);
Block::factory()
->title(sprintf('ADSL Traffic for %s',$date))
->title_icon('icon-th-list')
->body(Table::factory()
->jssort('traffic')
->data($aso->traffic->where('date','=',$date)->find_all())
->columns(array(
'service'=>'Service Login',
'plan->service->id'=>'Service',
'plan->service_number'=>'Service',
'plan->service->status(TRUE)'=>'Active',
'up_peak'=>'Up Peak',
'down_peak'=>'Down Peak',
'up_offpeak'=>'Up OffPeak',
'down_offpeak'=>'Down OffPeak',
'peer'=>'Peer',
'internal'=>'Internal',
))
->prepend(array(
'plan->service->id'=>array('url'=>URL::link('user','service/view/')),
))
);
}
}
?>

View File

@ -15,6 +15,7 @@ class Model_ADSL_Supplier extends ORM_OSB {
// Relationships // Relationships
protected $_has_many = array( protected $_has_many = array(
'adsl_supplier_plan'=>array('model'=>'ADSL_Supplier_Plan','foreign_key'=>'supplier_id','far_key'=>'id'), 'adsl_supplier_plan'=>array('model'=>'ADSL_Supplier_Plan','foreign_key'=>'supplier_id','far_key'=>'id'),
'traffic'=>array('model'=>'Service_Plugin_Adsl_Traffic','foreign_key'=>'supplier_id','far_key'=>'id'),
); );
protected $_form = array('id'=>'id','value'=>'name'); protected $_form = array('id'=>'id','value'=>'name');

View File

@ -17,6 +17,10 @@ class Model_Service_Plugin_Adsl_Traffic extends ORM_OSB {
protected $_created_column = FALSE; protected $_created_column = FALSE;
protected $_updated_column = FALSE; protected $_updated_column = FALSE;
protected $_has_one = array(
'plan'=>array('model'=>'Service_Plugin_Adsl','foreign_key'=>'service_username','far_key'=>'service'),
);
public function rules() { public function rules() {
$result = parent::rules(); $result = parent::rules();