Improved service display
This commit is contained in:
@@ -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();
|
||||
|
58
modules/product/classes/model/product/adsl.php
Normal file
58
modules/product/classes/model/product/adsl.php
Normal 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;
|
||||
}
|
||||
}
|
||||
?>
|
28
modules/product/views/product/adsl/feature_summary.php
Normal file
28
modules/product/views/product/adsl/feature_summary.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<!-- //@todo To translate -->
|
||||
<table class="box-full">
|
||||
<tr>
|
||||
<td style="width: 40%;">Speed</td>
|
||||
<td class="data" style="width: 60%;" colspan="2"><?php echo $po->display('speed'); ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td> </td>
|
||||
<td>Peak</td>
|
||||
<?php if ($po->base_down_offpeak OR $po->extra_down_offpeak) { ?>
|
||||
<td>Off Peak</td>
|
||||
<?php } ?>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Included Download Traffic</td>
|
||||
<!-- // @todo Since price is stored in the DB in GB, so should the traffic. -->
|
||||
<td class="data"><?php echo $po->base_down_peak/1000; ?> GB</td>
|
||||
<td class="data"><?php echo $po->base_down_offpeak ? ($po->base_down_offpeak/1000).'GB' : HTML::nbsp(''); ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Extra Download Traffic</td>
|
||||
<td class="data"><?php echo $po->display('extra_down_peak'); ?>/GB</td>
|
||||
<td class="data"><?php echo $po->extra_down_offpeak ? $po->display('extra_down_offpeak').'/GB' : HTML::nbsp(''); ?></td>
|
||||
</tr>
|
||||
</table>
|
Reference in New Issue
Block a user