Major work to domain and hosting
Minor updates for ADSL services Updates to Sort::MAsort() Move core OSB items under application/ Moved ACCOUNT functions under application Minor updates to task
This commit is contained in:
@@ -15,10 +15,6 @@ class Model_Service extends ORMOSB {
|
||||
protected $_has_many = array(
|
||||
'invoice'=>array('through'=>'invoice_item'),
|
||||
);
|
||||
protected $_has_one = array(
|
||||
'service_adsl'=>array('far_key'=>'id'),
|
||||
'service_domain'=>array('far_key'=>'id'),
|
||||
);
|
||||
protected $_belongs_to = array(
|
||||
'product'=>array(),
|
||||
'account'=>array(),
|
||||
@@ -76,15 +72,14 @@ class Model_Service extends ORMOSB {
|
||||
/**
|
||||
* Return the object of the product plugin
|
||||
*/
|
||||
private function plugin() {
|
||||
public function plugin() {
|
||||
if (! $this->product->prod_plugin_file)
|
||||
return NULL;
|
||||
|
||||
if (! is_numeric($this->product->prod_plugin_data))
|
||||
throw new Kohana_Exception('Missing plugin_id for :product (:type)',array(':product'=>$this->product->id,':type'=>$this->product->prod_plugin_file));
|
||||
|
||||
$spn = sprintf('%s_%s',get_class($this),$this->product->prod_plugin_file);
|
||||
return new $spn(array('service_id'=>$this->id));
|
||||
return ORM::factory(sprintf('service_plugin_%s',$this->product->prod_plugin_file),array('service_id'=>$this->id));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -98,7 +93,15 @@ class Model_Service extends ORMOSB {
|
||||
* Display the service product name
|
||||
*/
|
||||
public function name() {
|
||||
return $this->product->name();
|
||||
return is_null($plugin=$this->plugin()) ? $this->product->name() : $plugin->name();
|
||||
}
|
||||
|
||||
public function service_name() {
|
||||
return is_null($plugin=$this->plugin()) ? $this->name() : $plugin->service_name();
|
||||
}
|
||||
|
||||
public function service_view() {
|
||||
return is_null($plugin=$this->plugin()) ? HTML::nbsp('') : $plugin->service_view();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -108,29 +111,12 @@ class Model_Service extends ORMOSB {
|
||||
return $this->product->feature_summary();
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the service details
|
||||
*/
|
||||
public function service_view() {
|
||||
if (is_null($plugin = $this->plugin()))
|
||||
return HTML::nbsp('');
|
||||
else
|
||||
return $plugin->_service_view();
|
||||
}
|
||||
|
||||
public function service_name() {
|
||||
if (is_null($plugin = $this->plugin()))
|
||||
return $this->name();
|
||||
else
|
||||
return $plugin->_service_name();
|
||||
}
|
||||
|
||||
/**
|
||||
* Render some details for specific calls, eg: invoice
|
||||
*/
|
||||
public function details($type) {
|
||||
switch ($type) {
|
||||
case 'invoice':
|
||||
case 'invoice_detail_items':
|
||||
if (is_null($plugin = $this->plugin()))
|
||||
return array();
|
||||
else
|
||||
@@ -156,5 +142,26 @@ class Model_Service extends ORMOSB {
|
||||
public function tax() {
|
||||
return $this->price * .1;
|
||||
}
|
||||
|
||||
public function list_active() {
|
||||
return $this->where('active','=','1')->find_all();
|
||||
}
|
||||
|
||||
public function list_bylistgroup($cat) {
|
||||
$result = array();
|
||||
|
||||
$cats = ORM::factory('product_category')->list_bylistgroup($cat);
|
||||
|
||||
foreach ($this->list_active() as $so) {
|
||||
if (! $so->product->avail_category_id OR ! preg_match('/^a:/',$so->product->avail_category_id))
|
||||
continue;
|
||||
|
||||
$pc = unserialize($so->product->avail_category_id);
|
||||
if (array_intersect($pc,array_keys($cats)))
|
||||
array_push($result,$so);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
Reference in New Issue
Block a user