Overhaul ADSL traffic reporting/graphing

This commit is contained in:
Deon George
2013-11-14 22:50:35 +11:00
parent 158a4f9e47
commit e01d37244c
33 changed files with 891 additions and 471 deletions

View File

@@ -52,6 +52,9 @@ class Model_Service extends ORM_OSB {
protected $_form = array('id'=>'id','value'=>'service_name()');
// Cache our calls to our plugins
public static $plugin = array();
/**
* Get the additional charges associated with this service
*/
@@ -201,9 +204,10 @@ class Model_Service extends ORM_OSB {
if (! $this->product->prod_plugin_file)
return NULL;
$o = ORM::factory(Kohana::classname(sprintf('Service_Plugin_%s',$this->product->prod_plugin_file)),array('service_id'=>$this->id));
if (! isset(Model_Service::$plugin[$this->id]))
Model_Service::$plugin[$this->id] = ORM::factory(Kohana::classname(sprintf('Service_Plugin_%s',$this->product->prod_plugin_file)),array('service_id'=>$this->id));
return $type ? $o->$type : $o;
return $type ? Model_Service::$plugin[$this->id]->$type : Model_Service::$plugin[$this->id];
}
public function revenue($annual=FALSE) {
@@ -237,7 +241,7 @@ class Model_Service extends ORM_OSB {
if (! $original AND ! is_null($this->price_override))
$p = $this->price_override;
if ($tax)
$p = Tax::add($p);
@@ -266,10 +270,7 @@ class Model_Service extends ORM_OSB {
* Enable the plugin to store data
*/
public function admin_update() {
if (is_null($plugin = $this->plugin()))
return NULL;
else
return $plugin->admin_update();
return (is_null($plugin = $this->plugin())) ? NULL : $plugin->admin_update();
}
public function transactions() {

View File

@@ -13,33 +13,39 @@ abstract class Model_Service_Plugin extends ORM_OSB {
// Reset any sorting that may be defined in our parent
protected $_sorting = array();
/**
* Our service name as defined in the DB
*/
abstract public function name();
/**
* When does our service expire
*/
abstract public function expire();
/**
* Show our service name as defined in the DB with product suffix.
* Our service name as defined in the DB
*/
public function service_name() {
return sprintf('%s - %s',$this->service->product->title(),$this->name());
}
/**
* View details of the service
*/
abstract public function service_view();
abstract public function name();
/**
* The table attributes that provide username/password values
*/
abstract public function username_value();
abstract public function password_value();
abstract public function username_value();
/**
* Get specific service details for use in other modules
* For Example: Invoice
*
* @todo Make the rendered items configurable
* @todo Change this method name, now that it is public
*/
public function _details($type) {
switch ($type) {
// Nothing to add for invoices
case 'invoice_detail_items':
return array();
default:
throw new Kohana_Exception('Unkown detail request :type',array(':type'=>$type));
}
}
/**
* Form info for admins to update
@@ -49,6 +55,9 @@ abstract class Model_Service_Plugin extends ORM_OSB {
->set('o',$this);
}
/**
* Provide the button that launches the management of this service, generally from a 3rd party
*/
public function manage_button() {
if (! $this->service->status OR $this->service->expiring())
return FALSE;
@@ -79,26 +88,26 @@ function() { $("form[id=id_"+t[0]+"_"+t[1]+"]").submit(); });
return TRUE;
}
/**
* Return the name of the plugin
*/
protected function plugin() {
return strtolower(preg_replace('/(.*)_([a-zA-Z]+)$/',"$2",get_class($this)));
}
/**
* Get specific service details for use in other modules
* For Example: Invoice
*
* @todo Make the rendered items configurable
* @todo Change this method name, now that it is public
* Show our service name as defined in the DB with product suffix.
*/
public function _details($type) {
switch ($type) {
// Nothing to add for invoices
case 'invoice_detail_items':
return array();
public function service_name() {
return sprintf('%s - %s',$this->service->product->title(),$this->name());
}
default:
throw new Kohana_Exception('Unkown detail request :type',array(':type'=>$type));
}
/**
* View details of the service
*/
public function service_view() {
return View::factory(sprintf('service/user/plugin/%s/view',$this->plugin()))
->set('o',$this);
}
}
?>