2010-11-29 22:41:08 +00:00
|
|
|
<?php defined('SYSPATH') or die('No direct access allowed.');
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This class supports ADSL Suppliers
|
|
|
|
*
|
2013-03-19 22:35:19 +00:00
|
|
|
* @package ADSL
|
2010-11-29 22:41:08 +00:00
|
|
|
* @category Models
|
|
|
|
* @author Deon George
|
2013-03-19 22:35:19 +00:00
|
|
|
* @copyright (c) 2009-2013 Open Source Billing
|
2010-11-29 22:41:08 +00:00
|
|
|
* @license http://dev.osbill.net/license.html
|
|
|
|
*/
|
2013-04-20 01:40:44 +00:00
|
|
|
class Model_ADSL_Supplier extends ORM_OSB {
|
2013-06-01 13:43:31 +00:00
|
|
|
protected $_updated_column = FALSE;
|
|
|
|
|
2010-11-29 22:41:08 +00:00
|
|
|
// Relationships
|
|
|
|
protected $_has_many = array(
|
2013-04-20 01:40:44 +00:00
|
|
|
'adsl_supplier_plan'=>array('model'=>'ADSL_Supplier_Plan','foreign_key'=>'supplier_id','far_key'=>'id'),
|
2010-11-29 22:41:08 +00:00
|
|
|
);
|
|
|
|
|
2011-12-20 05:46:10 +00:00
|
|
|
/**
|
|
|
|
* Return a list of plans that this supplier makes available
|
|
|
|
*/
|
|
|
|
public function plans($active=TRUE) {
|
2013-06-01 13:43:31 +00:00
|
|
|
return $active ? $this->adsl_supplier_plan->where_active() : $this->adsl_supplier_plan;
|
2011-12-20 05:46:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return a list of plans that we provide by this supplier
|
2013-06-01 13:43:31 +00:00
|
|
|
* @deprecated
|
2011-12-20 05:46:10 +00:00
|
|
|
*/
|
|
|
|
public function adsl_plans($active=TRUE) {
|
2013-04-05 12:50:08 +00:00
|
|
|
$result = array();
|
2011-12-20 05:46:10 +00:00
|
|
|
|
|
|
|
foreach ($this->plans($active)->find_all() as $po)
|
2013-01-11 10:51:37 +00:00
|
|
|
foreach ($po->adsl_plan->find_all() as $apo)
|
2013-04-05 12:50:08 +00:00
|
|
|
$result[$apo->id] = $apo;
|
2011-12-20 05:46:10 +00:00
|
|
|
|
2013-04-05 12:50:08 +00:00
|
|
|
return $result;
|
2011-12-20 05:46:10 +00:00
|
|
|
}
|
|
|
|
|
2010-11-29 22:41:08 +00:00
|
|
|
/**
|
|
|
|
* Return a list of services for this supplier
|
|
|
|
*
|
|
|
|
* @param boolean $active TRUE List only active Services|False List all services
|
|
|
|
*/
|
|
|
|
public function services($active=TRUE) {
|
2013-06-01 13:43:31 +00:00
|
|
|
$result = array();
|
2010-11-29 22:41:08 +00:00
|
|
|
|
2013-06-01 13:43:31 +00:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-02-22 08:15:46 +00:00
|
|
|
|
2013-06-01 13:43:31 +00:00
|
|
|
return $result;
|
2010-11-29 22:41:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
?>
|