Improved service display

This commit is contained in:
Deon George
2011-07-14 19:09:03 +10:00
parent 46c3b9a075
commit 27cdab1fe4
37 changed files with 1319 additions and 1042 deletions

View File

@@ -21,12 +21,71 @@ class Model_Product extends ORMOSB {
'sku'=>'asc',
);
protected $_formats = array(
protected $_display_format = array(
'price_type'=>array('StaticList_PriceType::display'=>array()),
);
/**
* The feature summary should be implemented in child objects.
* It is displayed on the product overview page, as a summary of the products features.
*/
protected function _feature_summary() {
throw new Kohana_Exception(':method not defined in child class :class',array(':method'=>__METHOD__,':class'=>get_class($this)));
}
/**
* The summary should be implemented in child objects.
*/
protected function _summary() {
return _('No Description');
}
/**
* Return the object of the product plugin
*/
private function plugin() {
if (! $this->prod_plugin_file)
return NULL;
if (! is_numeric($this->prod_plugin_data))
throw new Kohana_Exception('Missing plugin_id for :product (:type)',array(':product'=>$this->id,':type'=>$this->prod_plugin_file));
$spn = sprintf('%s_%s',get_class($this),$this->prod_plugin_file);
return new $spn($this->prod_plugin_data);
}
/**
* Get the product name, after translating
*/
public function name() {
return $this->product_translate->find()->display('name');
}
/**
* This will render the product feature summary information
*/
public function feature_summary() {
if (is_null($plugin = $this->plugin()))
return HTML::nbsp('');
else
return $plugin->_feature_summary();
}
/**
* Get the summary description
*
* Generally this is used on the invoice summary page
*/
public function summary() {
if (is_null($plugin = $this->plugin()))
return _('Other');
else
return $plugin->_summary();
}
/**
* Return the products for a given category
* @todo This shouldnt be here.
*/
public function category($cat) {
$results = array();

View File

@@ -0,0 +1,58 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* This class supports ADSL products
*
* @package OSB
* @subpackage Product/ADSL
* @category Models
* @author Deon George
* @copyright (c) 2010 Open Source Billing
* @license http://dev.osbill.net/license.html
*/
class Model_Product_ADSL extends Model_Product {
protected $_table_name = 'adsl_plan';
protected $_primary_key = 'id';
protected $_sorting = array(
);
protected $_display_filters = array(
'extra_down_peak'=>array(
array('Tax::add',array(':value')),
array('Currency::display',array(':value')),
),
'extra_down_offpeak'=>array(
array('Tax::add',array(':value')),
array('Currency::display',array(':value')),
),
);
protected function _feature_summary() {
return View::factory('product/adsl/feature_summary')
->set('po',$this);
}
protected function _summary() {
return sprintf('%s: %s %s','ADSL Services',$this->speed,$this->allowance(TRUE));
}
/**
* Show the ADSL allowance as a peak/offpeak metric
*/
public function allowance($string=TRUE) {
$output = ADSL::allowance(array(
'base_down_peak'=>$this->base_down_peak,
'base_down_offpeak'=>$this->base_down_offpeak,
'base_up_peak'=>$this->base_up_peak,
'base_up_offpeak'=>$this->base_up_offpeak,
'extra_down_peak'=>$this->extra_down_peak,
'extra_down_offpeak'=>$this->extra_down_offpeak,
'extra_up_peak'=>$this->extra_up_peak,
'extra_up_offpeak'=>$this->extra_up_offpeak,
));
return $string ? implode('/',$output) : $output;
}
}
?>