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

73 lines
1.9 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
*
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
*/
class Model_Adsl_Supplier extends ORM_OSB {
2010-11-29 22:41:08 +00:00
// 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;
2011-12-20 05:46:10 +00:00
if ($active)
2012-08-01 12:43:33 +00:00
$a->where_active();
2011-12-20 05:46:10 +00:00
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)
2011-12-20 05:46:10 +00:00
$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
2012-11-09 23:13:57 +00:00
foreach (ORM::factory('Service')->list_bylistgroup('ADSL') as $so)
2012-08-01 12:43:33 +00:00
if (! $active OR $so->status)
2011-12-20 05:46:10 +00:00
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
2012-02-22 08:15:46 +00:00
// @todo poor cludge, we should find them without using list_bylistgroup()
if (! $services)
2012-11-09 23:13:57 +00:00
foreach (ORM::factory('Service')->list_bylistgroup('HSPA') as $so)
2012-08-01 12:43:33 +00:00
if (! $active OR $so->status)
2012-02-22 08:15:46 +00:00
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;
}
}
?>