130a87aa9a
Minor updates for ADSL services Updates to Sort::MAsort() Move core OSB items under application/ Moved ACCOUNT functions under application Minor updates to task
54 lines
1.4 KiB
PHP
54 lines
1.4 KiB
PHP
<?php defined('SYSPATH') or die('No direct access allowed.');
|
|
|
|
/**
|
|
* This class supports ADSL Suppliers
|
|
*
|
|
* @package OSB
|
|
* @subpackage ADSL
|
|
* @category Models
|
|
* @author Deon George
|
|
* @copyright (c) 2010 Open Source Billing
|
|
* @license http://dev.osbill.net/license.html
|
|
*/
|
|
class Model_ADSL_Supplier extends ORMOSB {
|
|
// Relationships
|
|
protected $_has_many = array(
|
|
'adsl_supplier_plan'=>array('foreign_key'=>'supplier_id','far_key'=>'id'),
|
|
);
|
|
|
|
protected $_updated_column = FALSE;
|
|
|
|
/**
|
|
* 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) {
|
|
$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);
|
|
|
|
return $services;
|
|
}
|
|
|
|
/** LIST FUNCTIONS **/
|
|
|
|
/**
|
|
* Return a list of active suppliers
|
|
*/
|
|
public function list_active() {
|
|
return $this->where('status','=',1)->find_all();
|
|
}
|
|
}
|
|
?>
|