This repository has been archived on 2024-04-08. You can view files and clone it, but cannot push or open issues or pull requests.
khosb/modules/adsl/classes/Model/ADSL/Supplier.php

63 lines
1.5 KiB
PHP

<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* This class supports ADSL Suppliers
*
* @package ADSL
* @category Models
* @author Deon George
* @copyright (c) 2009-2013 Open Source Billing
* @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'),
);
/**
* Return a list of plans that this supplier makes available
*/
public function plans($active=TRUE) {
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();
foreach ($this->plans($active)->find_all() as $po)
foreach ($po->adsl_plan->find_all() as $apo)
$result[$apo->id] = $apo;
return $result;
}
/**
* 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) {
$result = array();
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);
}
}
}
}
return $result;
}
}
?>