Fixes for ADSL traffic collection and other ADSL items
This commit is contained in:
parent
94b7b4bcd4
commit
7819a05515
@ -14,6 +14,8 @@ abstract class Task extends Minion_Task {
|
|||||||
protected $_options = array(
|
protected $_options = array(
|
||||||
'site'=>NULL,
|
'site'=>NULL,
|
||||||
'id'=>NULL,
|
'id'=>NULL,
|
||||||
|
'force'=>FALSE,
|
||||||
|
'verbose'=>FALSE,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
@ -33,7 +33,7 @@ class ADSL {
|
|||||||
if (preg_match('/^a:/',$data))
|
if (preg_match('/^a:/',$data))
|
||||||
throw new Kohana_Exception('Data shouldnt be a serialized array');
|
throw new Kohana_Exception('Data shouldnt be a serialized array');
|
||||||
|
|
||||||
$ao = ORM::factory('ADSL_Plan',$data);
|
$ao = ORM::factory('Adsl_Plan',$data);
|
||||||
$output = View::factory('adsl/contract_view')
|
$output = View::factory('adsl/contract_view')
|
||||||
->set('record',$ao)
|
->set('record',$ao)
|
||||||
->set('price_base',$price_base)
|
->set('price_base',$price_base)
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
* @copyright (c) 2010 Open Source Billing
|
* @copyright (c) 2010 Open Source Billing
|
||||||
* @license http://dev.osbill.net/license.html
|
* @license http://dev.osbill.net/license.html
|
||||||
*/
|
*/
|
||||||
class Model_ADSL_Plan extends ORM_OSB {
|
class Model_Adsl_Plan extends ORM_OSB {
|
||||||
// Relationships
|
// Relationships
|
||||||
// @todo This model should probably be joined with product_plugin_adsl
|
// @todo This model should probably be joined with product_plugin_adsl
|
||||||
protected $_belongs_to = array(
|
protected $_belongs_to = array(
|
@ -10,10 +10,10 @@
|
|||||||
* @copyright (c) 2010 Open Source Billing
|
* @copyright (c) 2010 Open Source Billing
|
||||||
* @license http://dev.osbill.net/license.html
|
* @license http://dev.osbill.net/license.html
|
||||||
*/
|
*/
|
||||||
class Model_ADSL_Supplier extends ORM_OSB {
|
class Model_Adsl_Supplier extends ORM_OSB {
|
||||||
// Relationships
|
// Relationships
|
||||||
protected $_has_many = array(
|
protected $_has_many = array(
|
||||||
'ADSL_supplier_plan'=>array('foreign_key'=>'supplier_id','far_key'=>'id'),
|
'adsl_supplier_plan'=>array('foreign_key'=>'supplier_id','far_key'=>'id'),
|
||||||
);
|
);
|
||||||
|
|
||||||
protected $_updated_column = FALSE;
|
protected $_updated_column = FALSE;
|
||||||
@ -22,7 +22,7 @@ class Model_ADSL_Supplier extends ORM_OSB {
|
|||||||
* Return a list of plans that this supplier makes available
|
* Return a list of plans that this supplier makes available
|
||||||
*/
|
*/
|
||||||
public function plans($active=TRUE) {
|
public function plans($active=TRUE) {
|
||||||
$a = $this->ADSL_supplier_plan;
|
$a = $this->adsl_supplier_plan;
|
||||||
|
|
||||||
if ($active)
|
if ($active)
|
||||||
$a->where_active();
|
$a->where_active();
|
||||||
@ -37,7 +37,7 @@ class Model_ADSL_Supplier extends ORM_OSB {
|
|||||||
$return = array();
|
$return = array();
|
||||||
|
|
||||||
foreach ($this->plans($active)->find_all() as $po)
|
foreach ($this->plans($active)->find_all() as $po)
|
||||||
foreach ($po->ADSL_plan->find_all() as $apo)
|
foreach ($po->adsl_plan->find_all() as $apo)
|
||||||
$return[$apo->id] = $apo;
|
$return[$apo->id] = $apo;
|
||||||
|
|
||||||
return $return;
|
return $return;
|
@ -10,13 +10,13 @@
|
|||||||
* @copyright (c) 2010 Open Source Billing
|
* @copyright (c) 2010 Open Source Billing
|
||||||
* @license http://dev.osbill.net/license.html
|
* @license http://dev.osbill.net/license.html
|
||||||
*/
|
*/
|
||||||
class Model_ADSL_Supplier_Plan extends ORM_OSB {
|
class Model_Adsl_Supplier_Plan extends ORM_OSB {
|
||||||
// Relationships
|
// Relationships
|
||||||
protected $_has_many = array(
|
protected $_has_many = array(
|
||||||
'ADSL_plan'=>array('far_key'=>'id'),
|
'adsl_plan'=>array('far_key'=>'id'),
|
||||||
);
|
);
|
||||||
protected $_belongs_to = array(
|
protected $_belongs_to = array(
|
||||||
'ADSL_supplier'=>array('foreign_key'=>'supplier_id'),
|
'adsl_supplier'=>array('foreign_key'=>'supplier_id'),
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
@ -10,7 +10,7 @@
|
|||||||
* @copyright (c) 2010 Open Source Billing
|
* @copyright (c) 2010 Open Source Billing
|
||||||
* @license http://dev.osbill.net/license.html
|
* @license http://dev.osbill.net/license.html
|
||||||
*/
|
*/
|
||||||
class Model_Service_Plugin_ADSL_Traffic extends ORM_OSB {
|
class Model_Service_Plugin_Adsl_Traffic extends ORM_OSB {
|
||||||
protected $_table_name = 'service__adsl_traffic';
|
protected $_table_name = 'service__adsl_traffic';
|
||||||
protected $_primary_key = 'service';
|
protected $_primary_key = 'service';
|
||||||
protected $_disable_wild_select = TRUE;
|
protected $_disable_wild_select = TRUE;
|
||||||
@ -27,7 +27,7 @@ class Model_Service_Plugin_ADSL_Traffic extends ORM_OSB {
|
|||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function traffic(Model_Product_Plugin_ADSL $plan) {
|
public function traffic(Model_Product_Plugin_Adsl $plan) {
|
||||||
// Roll up the charges according to the product plan configuration
|
// Roll up the charges according to the product plan configuration
|
||||||
return ADSL::allowance(array(
|
return ADSL::allowance(array(
|
||||||
'base_down_peak'=>is_null($plan->base_down_peak) ? NULL : $this->down_peak,
|
'base_down_peak'=>is_null($plan->base_down_peak) ? NULL : $this->down_peak,
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
* @copyright (c) 2010 Deon George
|
* @copyright (c) 2010 Deon George
|
||||||
* @license http://dev.leenooks.net/license.html
|
* @license http://dev.leenooks.net/license.html
|
||||||
*/
|
*/
|
||||||
class Service_Traffic_ADSL {
|
class Service_Traffic_Adsl {
|
||||||
protected $so;
|
protected $so;
|
||||||
protected $today;
|
protected $today;
|
||||||
protected $fetchresult = NULL;
|
protected $fetchresult = NULL;
|
||||||
@ -51,7 +51,7 @@ class Service_Traffic_ADSL {
|
|||||||
* @return HeadImage
|
* @return HeadImage
|
||||||
*/
|
*/
|
||||||
public static function instance($supplier) {
|
public static function instance($supplier) {
|
||||||
$sc = sprintf('%s_%s',get_called_class(),$supplier);
|
$sc = sprintf('%s_%s',get_called_class(),ucwords(strtolower($supplier)));
|
||||||
|
|
||||||
if (! class_exists($sc))
|
if (! class_exists($sc))
|
||||||
throw new Kohana_Exception('Class doesnt exist for :supplier',array(':supplier'=>$supplier));
|
throw new Kohana_Exception('Class doesnt exist for :supplier',array(':supplier'=>$supplier));
|
@ -1,7 +1,7 @@
|
|||||||
<?php defined('SYSPATH') or die('No direct access allowed.');
|
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class is able to collect traffic information for Exetel HSPA
|
* This class is able to collect traffic information for Exetel hspa
|
||||||
*
|
*
|
||||||
* Traffic information is collected by each service, and cached,
|
* Traffic information is collected by each service, and cached,
|
||||||
* returning just the date in question.
|
* returning just the date in question.
|
||||||
@ -13,7 +13,7 @@
|
|||||||
* @copyright (c) 2010 Open Source Billing
|
* @copyright (c) 2010 Open Source Billing
|
||||||
* @license http://dev.osbill.net/license.html
|
* @license http://dev.osbill.net/license.html
|
||||||
*/
|
*/
|
||||||
class Service_Traffic_ADSL_ExetelHSPA extends Service_Traffic_ADSL {
|
class Service_Traffic_Adsl_Exetelhspa extends Service_Traffic_Adsl {
|
||||||
private $login_user_field = 'login_name';
|
private $login_user_field = 'login_name';
|
||||||
private $login_pass_field = 'password';
|
private $login_pass_field = 'password';
|
||||||
private $date_field = 'date';
|
private $date_field = 'date';
|
||||||
@ -21,7 +21,7 @@ class Service_Traffic_ADSL_ExetelHSPA extends Service_Traffic_ADSL {
|
|||||||
static $return = array();
|
static $return = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the data for Exetel HSPA services
|
* Get the data for Exetel hspa services
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
@ -30,8 +30,8 @@ class Service_Traffic_ADSL_ExetelHSPA extends Service_Traffic_ADSL {
|
|||||||
$this->fetchresult = TRUE;
|
$this->fetchresult = TRUE;
|
||||||
|
|
||||||
// If we have already collected the date data, return it.
|
// If we have already collected the date data, return it.
|
||||||
if (! empty(Service_Traffic_ADSL_ExetelHSPA::$return[$date]))
|
if (! empty(Service_Traffic_Adsl_Exetelhspa::$return[$date]))
|
||||||
return Service_Traffic_ADSL_ExetelHSPA::$return[$date];
|
return Service_Traffic_Adsl_Exetelhspa::$return[$date];
|
||||||
|
|
||||||
include_once 'includes/kohana/modules/simplehtmldom/classes/simple_html_dom.php';
|
include_once 'includes/kohana/modules/simplehtmldom/classes/simple_html_dom.php';
|
||||||
|
|
||||||
@ -174,14 +174,14 @@ class Service_Traffic_ADSL_ExetelHSPA extends Service_Traffic_ADSL {
|
|||||||
// Reformat the data into date order.
|
// Reformat the data into date order.
|
||||||
foreach ($update as $service => $sdata)
|
foreach ($update as $service => $sdata)
|
||||||
foreach ($sdata as $sdate => $details)
|
foreach ($sdata as $sdate => $details)
|
||||||
Service_Traffic_ADSL_ExetelHSPA::$return[$sdate][$service] = $details;
|
Service_Traffic_Adsl_Exetelhspa::$return[$sdate][$service] = $details;
|
||||||
|
|
||||||
// If the date we want is empty, return an array
|
// If the date we want is empty, return an array
|
||||||
if (empty(Service_Traffic_ADSL_ExetelHSPA::$return[$date]))
|
if (empty(Service_Traffic_Adsl_Exetelhspa::$return[$date]))
|
||||||
return array();
|
return array();
|
||||||
|
|
||||||
// Return the date we asked for
|
// Return the date we asked for
|
||||||
return Service_Traffic_ADSL_ExetelHSPA::$return[$date];
|
return Service_Traffic_Adsl_Exetelhspa::$return[$date];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
@ -13,7 +13,7 @@
|
|||||||
* @copyright (c) 2010 Open Source Billing
|
* @copyright (c) 2010 Open Source Billing
|
||||||
* @license http://dev.osbill.net/license.html
|
* @license http://dev.osbill.net/license.html
|
||||||
*/
|
*/
|
||||||
class Service_Traffic_ADSL_ExetelPE extends Service_Traffic_ADSL {
|
class Service_Traffic_Adsl_Exetelpe extends Service_Traffic_Adsl {
|
||||||
private $login_user_field = 'login_name';
|
private $login_user_field = 'login_name';
|
||||||
private $login_pass_field = 'password';
|
private $login_pass_field = 'password';
|
||||||
private $date_field = 'date';
|
private $date_field = 'date';
|
||||||
@ -30,8 +30,8 @@ class Service_Traffic_ADSL_ExetelPE extends Service_Traffic_ADSL {
|
|||||||
$this->fetchresult = TRUE;
|
$this->fetchresult = TRUE;
|
||||||
|
|
||||||
// If we have already collected the date data, return it.
|
// If we have already collected the date data, return it.
|
||||||
if (! empty(Service_Traffic_ADSL_ExetelPE::$return[$date]))
|
if (! empty(Service_Traffic_Adsl_Exetelpe::$return[$date]))
|
||||||
return Service_Traffic_ADSL_ExetelPE::$return[$date];
|
return Service_Traffic_Adsl_Exetelpe::$return[$date];
|
||||||
|
|
||||||
include_once 'includes/kohana/modules/simplehtmldom/classes/simple_html_dom.php';
|
include_once 'includes/kohana/modules/simplehtmldom/classes/simple_html_dom.php';
|
||||||
|
|
||||||
@ -167,14 +167,14 @@ class Service_Traffic_ADSL_ExetelPE extends Service_Traffic_ADSL {
|
|||||||
// Reformat the data into date order.
|
// Reformat the data into date order.
|
||||||
foreach ($update as $service => $sdata)
|
foreach ($update as $service => $sdata)
|
||||||
foreach ($sdata as $sdate => $details)
|
foreach ($sdata as $sdate => $details)
|
||||||
Service_Traffic_ADSL_ExetelPE::$return[$sdate][$service] = $details;
|
Service_Traffic_Adsl_Exetelpe::$return[$sdate][$service] = $details;
|
||||||
|
|
||||||
// If the date we want is empty, return an array
|
// If the date we want is empty, return an array
|
||||||
if (empty(Service_Traffic_ADSL_ExetelPE::$return[$date]))
|
if (empty(Service_Traffic_Adsl_Exetelpe::$return[$date]))
|
||||||
return array();
|
return array();
|
||||||
|
|
||||||
// Return the date we asked for
|
// Return the date we asked for
|
||||||
return Service_Traffic_ADSL_ExetelPE::$return[$date];
|
return Service_Traffic_Adsl_Exetelpe::$return[$date];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
@ -10,7 +10,7 @@
|
|||||||
* @copyright (c) 2010 Open Source Billing
|
* @copyright (c) 2010 Open Source Billing
|
||||||
* @license http://dev.osbill.net/license.html
|
* @license http://dev.osbill.net/license.html
|
||||||
*/
|
*/
|
||||||
class Service_Traffic_ADSL_ExetelVisp extends Service_Traffic_ADSL {
|
class Service_Traffic_Adsl_Exetelvisp extends Service_Traffic_Adsl {
|
||||||
private $login_user_field = 'username';
|
private $login_user_field = 'username';
|
||||||
private $login_pass_field = 'password';
|
private $login_pass_field = 'password';
|
||||||
private $date_field = 'date';
|
private $date_field = 'date';
|
@ -480,7 +480,7 @@ class Controller_Admin_Service extends Controller_TemplateDefault_Admin {
|
|||||||
public function action_listadslbilling() {
|
public function action_listadslbilling() {
|
||||||
$id = $this->request->param('id');
|
$id = $this->request->param('id');
|
||||||
|
|
||||||
$aso = ORM::factory('ADSL_Supplier',$id);
|
$aso = ORM::factory('Adsl_Supplier',$id);
|
||||||
|
|
||||||
// Process upload
|
// Process upload
|
||||||
// @todo This should be separated out by supplier in case each supplier has a different format
|
// @todo This should be separated out by supplier in case each supplier has a different format
|
||||||
|
@ -25,7 +25,7 @@ class Controller_Task_Service extends Controller_Task {
|
|||||||
if (Minion_CLI::options('verbose'))
|
if (Minion_CLI::options('verbose'))
|
||||||
echo $aso->name."\n";
|
echo $aso->name."\n";
|
||||||
|
|
||||||
$traffic = Service_Traffic_ADSL::instance($aso->name)->update_traffic();
|
$traffic = Service_Traffic_Adsl::instance($aso->name)->update_traffic();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -34,7 +34,7 @@ class Controller_Task_Service extends Controller_Task {
|
|||||||
*/
|
*/
|
||||||
public function action_chargetraffic() {
|
public function action_chargetraffic() {
|
||||||
foreach ($this->_traffic_suppliers(TRUE) as $aso)
|
foreach ($this->_traffic_suppliers(TRUE) as $aso)
|
||||||
$traffic = Service_Traffic_ADSL::instance($aso->name)->charge_excess_traffic();
|
$traffic = Service_Traffic_Adsl::instance($aso->name)->charge_excess_traffic();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -42,7 +42,7 @@ class Controller_Task_Service extends Controller_Task {
|
|||||||
*/
|
*/
|
||||||
public function action_alerttraffic() {
|
public function action_alerttraffic() {
|
||||||
foreach ($this->_traffic_suppliers(TRUE) as $aso)
|
foreach ($this->_traffic_suppliers(TRUE) as $aso)
|
||||||
$traffic = Service_Traffic_ADSL::instance($aso->name)->alert_traffic();
|
$traffic = Service_Traffic_Adsl::instance($aso->name)->alert_traffic();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
@ -17,7 +17,7 @@ class Model_Task extends ORM_OSB {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
public function run() {
|
public function run($force=FALSE) {
|
||||||
$r = rand(0,9999);
|
$r = rand(0,9999);
|
||||||
$tlo = ORM::factory('Task_Log');
|
$tlo = ORM::factory('Task_Log');
|
||||||
$tlo->task_id = $this->id;
|
$tlo->task_id = $this->id;
|
||||||
@ -28,7 +28,7 @@ class Model_Task extends ORM_OSB {
|
|||||||
elseif (! $this->status)
|
elseif (! $this->status)
|
||||||
$tlo->message = sprintf('Task %s is not active',$this->id);
|
$tlo->message = sprintf('Task %s is not active',$this->id);
|
||||||
|
|
||||||
elseif ($this->running)
|
elseif ($this->running AND ! $force)
|
||||||
$tlo->message = sprintf('Task %s is already running',$this->id);
|
$tlo->message = sprintf('Task %s is already running',$this->id);
|
||||||
|
|
||||||
elseif (! preg_match('/\//',$this->command))
|
elseif (! preg_match('/\//',$this->command))
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
*/
|
*/
|
||||||
class Task_Task_Run extends Task {
|
class Task_Task_Run extends Task {
|
||||||
protected function _execute(array $params) {
|
protected function _execute(array $params) {
|
||||||
if (isset($params['id'])) {
|
if ($params['id']) {
|
||||||
$to = ORM::factory('Task',$params['id']);
|
$to = ORM::factory('Task',$params['id']);
|
||||||
|
|
||||||
if ($to->loaded()) {
|
if ($to->loaded()) {
|
||||||
@ -20,7 +20,7 @@ class Task_Task_Run extends Task {
|
|||||||
throw new Minion_Exception_InvalidTask('Task :task (:name) NOT active',array(':task'=>$params['id'],':name'=>$to->name));
|
throw new Minion_Exception_InvalidTask('Task :task (:name) NOT active',array(':task'=>$params['id'],':name'=>$to->name));
|
||||||
|
|
||||||
if (! Kohana::$config->load('debug')->task_sim)
|
if (! Kohana::$config->load('debug')->task_sim)
|
||||||
$to->run();
|
$to->run($params['force']);
|
||||||
else
|
else
|
||||||
printf('Would Run task: (%s) %s',$params['id'],$to->name);
|
printf('Would Run task: (%s) %s',$params['id'],$to->name);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user