Added Payment, other minor fixes
This commit is contained in:
@@ -16,9 +16,6 @@ class Model_ADSL_Plan extends ORMOSB {
|
||||
protected $_belongs_to = array(
|
||||
'adsl_supplier_plan'=>array(),
|
||||
);
|
||||
protected $_has_many = array(
|
||||
'product'=>array('far_key'=>'id','foreign_key'=>'prod_plugin_data'),
|
||||
);
|
||||
|
||||
protected $_display_filters = array(
|
||||
'extra_down_peak'=>array(
|
||||
|
@@ -18,6 +18,31 @@ class Model_ADSL_Supplier extends ORMOSB {
|
||||
|
||||
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('status','=',TRUE);
|
||||
|
||||
return $a;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a list of plans that we provide by this supplier
|
||||
*/
|
||||
public function adsl_plans($active=TRUE) {
|
||||
$return = array();
|
||||
|
||||
foreach ($this->plans($active)->find_all() as $po)
|
||||
foreach ($po->adsl_plan->find_all() as $apo)
|
||||
$return[$apo->id] = $apo;
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a list of services for this supplier
|
||||
*
|
||||
@@ -27,16 +52,13 @@ class Model_ADSL_Supplier extends ORMOSB {
|
||||
$services = array();
|
||||
|
||||
// Get a list of plans made for this supplier
|
||||
// @todo This doesnt work if a product adsl plan is overriden.
|
||||
foreach ($this->adsl_supplier_plan->find_all() as $aspo)
|
||||
// Find all the plan who use this supplier plan
|
||||
foreach ($aspo->adsl_plan->find_all() as $apo)
|
||||
// Find all the products who use this plan
|
||||
foreach ($apo->product->find_all() as $po)
|
||||
// Find all the services who that use this product
|
||||
foreach ($po->service->find_all() as $so)
|
||||
if (! $active OR $so->active)
|
||||
array_push($services,$so);
|
||||
$plans = array_keys($this->adsl_plans(FALSE));
|
||||
|
||||
// Start with all our ADSL Plans
|
||||
foreach (ORM::factory('service')->list_bylistgroup('ADSL') as $so)
|
||||
if (! $active OR $so->active)
|
||||
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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user