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

76 lines
1.7 KiB
PHP
Raw Normal View History

2010-11-29 22:41:08 +00:00
<?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'),
2010-11-29 22:41:08 +00:00
);
protected $_updated_column = FALSE;
2011-12-20 05:46:10 +00:00
/**
* 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;
}
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) {
$services = array();
// Get a list of plans made for this supplier
2011-12-20 05:46:10 +00:00
$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);
2010-11-29 22:41:08 +00:00
return $services;
}
2011-08-16 02:27:19 +00:00
/** LIST FUNCTIONS **/
/**
* Return a list of active suppliers
*/
2011-08-16 02:27:19 +00:00
public function list_active() {
return $this->where('status','=',1)->find_all();
}
2010-11-29 22:41:08 +00:00
}
?>