Fixed ADSL traffic collection, and migrated Task to Minion

This commit is contained in:
Deon George
2013-06-01 23:43:31 +10:00
parent d4168146ee
commit 1a40f95b30
10 changed files with 115 additions and 126 deletions

View File

@@ -11,7 +11,6 @@
*/
class Model_ADSL_Plan extends ORM_OSB {
// Relationships
// @todo This model should probably be joined with product_plugin_adsl
protected $_belongs_to = array(
'adsl_supplier_plan'=>array('model'=>'ADSL_Supplier_Plan'),
);
@@ -34,5 +33,16 @@ class Model_ADSL_Plan extends ORM_OSB {
array('Currency::display',array(':value')),
),
);
public function products($active) {
$x = ORM::factory('Product')
->where('prod_plugin_file','=','ADSL')
->and_where('prod_plugin_data','=',$this);
if ($active)
$x->where_active();
return $x;
}
}
?>

View File

@@ -10,27 +10,23 @@
* @license http://dev.osbill.net/license.html
*/
class Model_ADSL_Supplier extends ORM_OSB {
protected $_updated_column = FALSE;
// Relationships
protected $_has_many = array(
'adsl_supplier_plan'=>array('model'=>'ADSL_Supplier_Plan','foreign_key'=>'supplier_id','far_key'=>'id'),
);
protected $_updated_column = FALSE;
/**
* Return a list of plans that this supplier makes available
*/
public function plans($active=TRUE) {
$a = $this->adsl_supplier_plan;
if ($active)
$a->where_active();
return $a;
return $active ? $this->adsl_supplier_plan->where_active() : $this->adsl_supplier_plan;
}
/**
* Return a list of plans that we provide by this supplier
* @deprecated
*/
public function adsl_plans($active=TRUE) {
$result = array();
@@ -48,25 +44,19 @@ class Model_ADSL_Supplier extends ORM_OSB {
* @param boolean $active TRUE List only active Services|False List all services
*/
public function services($active=TRUE) {
$services = array();
$result = array();
// Get a list of plans made for this supplier
$plans = array_keys($this->adsl_plans(FALSE));
foreach ($this->plans(FALSE)->find_all() as $aspo) {
foreach ($aspo->adsl_plan->find_all() as $apo) {
foreach ($apo->products(FALSE)->find_all() as $po) {
foreach ($po->services($active)->find_all() as $so) {
array_push($result,$so);
}
}
}
}
// Start with all our ADSL Plans
foreach (ORM::factory('Service')->list_bylistgroup('ADSL') as $so)
if (! $active OR $so->status)
if (in_array($so->product->prod_plugin_data,$plans) OR in_array($so->plugin()->provided_adsl_plan_id,$plans))
array_push($services,$so);
// @todo poor cludge, we should find them without using list_bylistgroup()
if (! $services)
foreach (ORM::factory('Service')->list_bylistgroup('HSPA') as $so)
if (! $active OR $so->status)
if (in_array($so->product->prod_plugin_data,$plans) OR in_array($so->plugin()->provided_adsl_plan_id,$plans))
array_push($services,$so);
return $services;
return $result;
}
}
?>