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:
Deon George
2011-09-28 16:46:22 +10:00
parent 147d035e46
commit 130a87aa9a
199 changed files with 1536 additions and 10742 deletions

View File

@@ -36,7 +36,7 @@ class Controller_Product extends Controller_TemplateDefault {
* Obtain a list of pages in a category
*/
private function _get_category($id) {
return ORM::factory('product')->category($id);
return ORM::factory('product')->list_category($id);
}
/**

View File

@@ -14,6 +14,7 @@ class Model_Product extends ORMOSB {
// @todo this doesnt have our site_id when getting the translation
protected $_has_many = array(
'product_translate'=>array('far_key'=>'id'),
'service'=>array('far_key'=>'id'),
);
protected $_sorting = array(
@@ -27,21 +28,6 @@ class Model_Product extends ORMOSB {
),
);
/**
* 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
*/
@@ -52,8 +38,7 @@ class Model_Product extends ORMOSB {
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);
return ORM::factory(sprintf('product_plugin_%s',$this->prod_plugin_file),$this->prod_plugin_data);
}
/**
@@ -67,36 +52,7 @@ class Model_Product extends ORMOSB {
* 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();
foreach ($this->where('active','=',TRUE)->find_all() as $po) {
if ($c = unserialize($po->avail_category_id) AND in_array($cat,$c))
array_push($results,$po);
}
return $results;
return (is_null($plugin = $this->plugin())) ? HTML::nbsp('') : $plugin->feature_summary();
}
/**
@@ -155,5 +111,20 @@ class Model_Product extends ORMOSB {
// @todo Change the ALT to the product name.
echo HTML::image($thumb,array('alt'=>_('Thumb Nail')));
}
/**
* Return the products for a given category
* @todo This shouldnt be here.
*/
public function list_category($cat) {
$results = array();
foreach ($this->where('active','=',TRUE)->find_all() as $po) {
if ($c = unserialize($po->avail_category_id) AND in_array($cat,$c))
array_push($results,$po);
}
return $results;
}
}
?>

View File

@@ -16,5 +16,14 @@ class Model_Product_Category extends ORMOSB {
protected $_sorting = array(
'name'=>'asc',
);
public function list_bylistgroup($cat) {
$result = array();
foreach ($this->where('list_group','=',$cat)->find_all() as $pco)
$result[$pco->id] = $pco;
return $result;
}
}
?>

View File

@@ -0,0 +1,23 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* This class supports Product Plugins.
*
* @package OSB
* @subpackage Product/Plugin
* @category Models
* @author Deon George
* @copyright (c) 2010 Open Source Billing
* @license http://dev.osbill.net/license.html
*/
abstract class Model_Product_Plugin extends ORMOSB {
// Reset any sorting that may be defined in our parent
protected $_sorting = array();
/**
* The feature summary should be implemented in plugins.
* It is displayed on the product overview page, as a summary of the products features.
*/
abstract public function feature_summary();
}
?>

View File

@@ -10,11 +10,11 @@
* @copyright (c) 2010 Open Source Billing
* @license http://dev.osbill.net/license.html
*/
class Model_Product_ADSL extends Model_Product {
class Model_Product_Plugin_ADSL extends Model_Product_Plugin {
protected $_table_name = 'adsl_plan';
protected $_primary_key = 'id';
protected $_sorting = array(
protected $_belongs_to = array(
'adsl_supplier_plan'=>array(),
);
protected $_display_filters = array(
@@ -28,15 +28,13 @@ class Model_Product_ADSL extends Model_Product {
),
);
protected function _feature_summary() {
return View::factory('product/adsl/feature_summary')
// Our required abstract methods
public function feature_summary() {
// @todo This view should render based on the the results of this::allowance();
return View::factory('product/plugin/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
*/

View File

@@ -0,0 +1,41 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* This class supports DOMAIN products
*
* @package OSB
* @subpackage Product/Domain
* @category Models
* @author Deon George
* @copyright (c) 2010 Open Source Billing
* @license http://dev.osbill.net/license.html
*/
class Model_Product_Plugin_Domain extends Model_Product_Plugin {
// This model doesnt have a database table
public function __construct() {
}
// Our required abstract methods
public function feature_summary() {}
// @todo This is not used, but should be.
public function order_features() {
$output = '';
$t = ORM::factory('domain_tld');
// @todo Change this to a view.
$output = sprintf('<table class="box-full"><tr class="head"><td>%s</td></tr><tr><td>',_('Domains are available with the following suffixes'));
$output .= Table::display(
$t->where('status','=','1')->find_all(),
25,
array(
'display("name")'=>array('label'=>'TLD Suffix'),
),
array(
));
$output .= '</td></tr></table>';
return $output;
}
}
?>

View File

@@ -0,0 +1,25 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* This class supports Host products
*
* @package OSB
* @subpackage Product/Host
* @category Models
* @author Deon George
* @copyright (c) 2010 Open Source Billing
* @license http://dev.osbill.net/license.html
*/
class Model_Product_Plugin_Host extends Model_Product_Plugin {
// @todo This model doesnt have a database table
public function __construct() {
}
// Our required abstract methods
public function feature_summary() {}
// @todo This is not used, but should be.
public function order_features() {
}
}
?>

View File

@@ -42,6 +42,13 @@ echo Form::open('cart/add');
echo '<td style="vertical-align: top;">'.$pio->contract_view($record->prod_plugin_data,$record->price_base,$record->price_setup).'</td>';
} ?>
</tr>
<tr>
<?php if ($record->prod_plugin && method_exists($record->prod_plugin_file,'feature_summary')) {
// @todo This doesnt work, it needs to be product_plugin_xx class
$pio = new $record->prod_plugin_file;
echo '<td style="vertical-align: top;">'.$pio->feature_summary().'</td>';
} ?>
</tr>
<tr>
<td class="spacer" colspan="2">&nbsp;</td>
</tr>
@@ -77,7 +84,16 @@ echo Form::open('cart/add');
</td>
</tr>
<tr>
<td style="text-align: center;"><?php echo Form::submit('submit','Add to Cart',array('class'=>'form_button')); ?> | <?php echo Form::submit('submit','Add to Cart & Checkout',array('disabled'=>'disabled'),array('class'=>'form_button')); ?></td>
<td class="spacer" colspan="2">&nbsp;</td>
</tr>
<tr>
<?php if ($record->prod_plugin && method_exists($record->prod_plugin_file,'product_cart')) {
$pio = new $record->prod_plugin_file;
echo '<td style="vertical-align: top;">'.$pio->product_cart($record->prod_plugin_data).'</td>';
} ?>
</tr>
<tr>
<td style="text-align: center;"><?php echo Form::submit('submit','Add to Cart',array('class'=>'form_button','disabled'=>'disabled')); ?> | <?php echo Form::submit('submit','Add to Cart & Checkout',array('disabled'=>'disabled'),array('class'=>'form_button')); ?></td>
</tr>
</table>
</td>