Theme work with focusbusiness and baseadmin
Improvements to NAVBAR, updates to StaticList methods, other minor items Enable product category rendering and other minor improvements Added ADSL-large category price plan
This commit is contained in:
@@ -9,48 +9,165 @@
|
||||
* @copyright (c) 2009-2013 Open Source Billing
|
||||
* @license http://dev.osbill.net/license.html
|
||||
*/
|
||||
class Controller_Admin_Product extends Controller_TemplateDefault_Admin {
|
||||
class Controller_Admin_Product extends Controller_Product {
|
||||
protected $auth_required = TRUE;
|
||||
|
||||
protected $secure_actions = array(
|
||||
'ajaxtranslateform'=>TRUE,
|
||||
'ajaxtranslatecategory'=>TRUE,
|
||||
'ajaxtranslate'=>TRUE,
|
||||
'category'=>TRUE,
|
||||
'edit'=>TRUE,
|
||||
'list'=>TRUE,
|
||||
'update'=>TRUE,
|
||||
'view'=>TRUE,
|
||||
);
|
||||
|
||||
public function action_ajaxtranslateform() {
|
||||
$this->auto_render = FALSE;
|
||||
|
||||
public function action_ajaxtranslate() {
|
||||
$po = ORM::factory('Product',$this->request->param('id'));
|
||||
|
||||
if (! $this->request->is_ajax() OR ! $po->loaded() OR ! isset($_REQUEST['key']))
|
||||
$this->response->body(_('Unable to find translate data'));
|
||||
|
||||
else {
|
||||
if (! $po->loaded() OR ! isset($_REQUEST['key'])) {
|
||||
$output = _('Unable to find translate data');
|
||||
|
||||
} else {
|
||||
$pto = $po->product_translate->where('language_id','=',$_REQUEST['key'])->find();
|
||||
|
||||
$this->response->body(View::factory($this->viewpath())->set('pto',$pto));
|
||||
$output = View::factory('product/admin/ajaxtranslate')
|
||||
->set('o',$pto);
|
||||
}
|
||||
|
||||
$this->response->body($output);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the product category translate record
|
||||
*/
|
||||
public function action_ajaxtranslatecategory() {
|
||||
$pco = ORM::factory('Product_Category',$this->request->param('id'));
|
||||
|
||||
if (! $pco->loaded() OR ! isset($_REQUEST['key'])) {
|
||||
$output = _('Unable to find translate data');
|
||||
|
||||
} else {
|
||||
$pcto = $pco->product_category_translate->where('language_id','=',$_REQUEST['key'])->find();
|
||||
|
||||
$output = View::factory('product/category/admin/ajaxtranslate')
|
||||
->set('o',$pcto);
|
||||
}
|
||||
|
||||
$this->response->body($output);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the product category
|
||||
*/
|
||||
public function action_category() {
|
||||
$pco = ORM::factory('Product_Category',$this->request->param('id'));
|
||||
|
||||
if (! $pco->loaded())
|
||||
HTTP::redirect('welcome/index');
|
||||
|
||||
if ($_POST)
|
||||
$pco->values($_POST)->save();
|
||||
|
||||
Script::factory()
|
||||
->type('stdin')
|
||||
->data('
|
||||
$(document).ready(function() {
|
||||
$("select[name=language_id]").change(function() {
|
||||
// If we select a blank, then dont continue
|
||||
if (this.value == 0)
|
||||
return false;
|
||||
|
||||
// Send the request and update sub category dropdown
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
data: "key="+$(this).val(),
|
||||
dataType: "html",
|
||||
cache: false,
|
||||
url: "'.URL::link('admin','product/ajaxtranslatecategory/'.$pco->id,TRUE).'",
|
||||
timeout: 2000,
|
||||
error: function(x) {
|
||||
alert("Failed to submit");
|
||||
},
|
||||
success: function(data) {
|
||||
$("div[id=translate]").replaceWith(data);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
');
|
||||
|
||||
Block::factory()
|
||||
->type('form-horizontal')
|
||||
->title('Update Category')
|
||||
->title_icon('icon-wrench')
|
||||
->body(View::factory('product/category/admin/edit')
|
||||
->set('o',$pco));
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit a product configuration
|
||||
*/
|
||||
public function action_edit() {
|
||||
$po = ORM::factory('Product',$this->request->param('id'));
|
||||
|
||||
if (! $po->loaded())
|
||||
HTTP::redirect('welcome/index');
|
||||
|
||||
if ($_POST)
|
||||
$po->values($_POST)->save();
|
||||
|
||||
Script::factory()
|
||||
->type('stdin')
|
||||
->data('
|
||||
$(document).ready(function() {
|
||||
$("select[name=language_id]").change(function() {
|
||||
// If we select a blank, then dont continue
|
||||
if (this.value == 0)
|
||||
return false;
|
||||
// Send the request and update sub category dropdown
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
data: "key="+$(this).val(),
|
||||
dataType: "html",
|
||||
cache: false,
|
||||
url: "'.URL::link('admin','product/ajaxtranslate/'.$po->id,TRUE).'",
|
||||
timeout: 2000,
|
||||
error: function(x) {
|
||||
alert("Failed to submit");
|
||||
},
|
||||
success: function(data) {
|
||||
$("div[id=translate]").replaceWith(data);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
');
|
||||
|
||||
Block::factory()
|
||||
->type('form-horizontal')
|
||||
->title('Update Product')
|
||||
->title_icon('icon-wrench')
|
||||
->body(View::factory('product/admin/edit')
|
||||
->set('plugin_form',$po->admin_update())
|
||||
->set('o',$po));
|
||||
}
|
||||
|
||||
/**
|
||||
* Show a list of products
|
||||
*/
|
||||
public function action_list() {
|
||||
if ($this->request->param('id'))
|
||||
$prods = ORM::factory('Product_Category',$this->request->param('id'))->products();
|
||||
else
|
||||
$prods = ORM::factory('Product')->order_by('status DESC,prod_plugin_file')->find_all();
|
||||
$products = ($x=$this->request->param('id')) ? ORM::factory('Product_Category',$x)->products() : ORM::factory('Product')->order_by('status DESC,prod_plugin_file')->find_all();
|
||||
|
||||
Block::add(array(
|
||||
'title'=>_('Customer Products'),
|
||||
'body'=>Table::display(
|
||||
$prods,
|
||||
Block::factory()
|
||||
->title(_('Products'))
|
||||
->title_icon('icon-th')
|
||||
->body(Table::display(
|
||||
$products,
|
||||
25,
|
||||
array(
|
||||
'id'=>array('label'=>'ID','url'=>URL::link('admin','product/view/')),
|
||||
'name()'=>array('label'=>'Details'),
|
||||
'status'=>array('label'=>'Active'),
|
||||
'title()'=>array('label'=>'Details'),
|
||||
'status(TRUE)'=>array('label'=>'Active'),
|
||||
'prod_plugin_file'=>array('label'=>'Plugin Name'),
|
||||
'prod_plugin_data'=>array('label'=>'Plugin Data'),
|
||||
'price_type'=>array('label'=>'Price Type'),
|
||||
@@ -62,81 +179,31 @@ class Controller_Admin_Product extends Controller_TemplateDefault_Admin {
|
||||
'page'=>TRUE,
|
||||
'type'=>'select',
|
||||
'form'=>URL::link('admin','product/view'),
|
||||
)),
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Edit a product configuration
|
||||
*/
|
||||
public function action_update() {
|
||||
$po = ORM::factory('Product',$this->request->param('id'));
|
||||
|
||||
if (! $po->loaded())
|
||||
HTTP::redirect('welcome/index');
|
||||
|
||||
if ($_POST) {
|
||||
if (isset($_POST['product_translate']['id']) AND ($pto=ORM::factory('Product_Translate',$_POST['product_translate']['id'])) AND $pto->loaded())
|
||||
if (! $pto->values($_POST['product_translate'])->save())
|
||||
throw new Kohana_Exception('Failed to save updates to product_translate data for record :record',array(':record'=>$po->id()));
|
||||
|
||||
if (! $po->values($_POST)->save())
|
||||
throw new Kohana_Exception('Failed to save updates to product data for record :record',array(':record'=>$so->id()));
|
||||
}
|
||||
|
||||
Block::add(array(
|
||||
'title'=>sprintf('%s %s:%s',_('Update Product'),$po->id,$po->name()),
|
||||
'body'=>View::factory($this->viewpath())
|
||||
->set('po',$po)
|
||||
->set('mediapath',Route::get('default/media'))
|
||||
->set('plugin_form',$po->admin_update()),
|
||||
));
|
||||
|
||||
Script::add(array('type'=>'stdin','data'=>'
|
||||
$(document).ready(function() {
|
||||
$("select[name=language_id]").change(function() {
|
||||
// Send the request and update sub category dropdown
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
data: "key="+$(this).val(),
|
||||
dataType: "html",
|
||||
cache: false,
|
||||
url: "'.URL::link('admin','product/ajaxtranslateform/'.$po->id,TRUE).'",
|
||||
timeout: 2000,
|
||||
error: function(x) {
|
||||
alert("Failed to submit");
|
||||
},
|
||||
success: function(data) {
|
||||
$("div[id=translate]").replaceWith(data);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
'));
|
||||
)));
|
||||
}
|
||||
|
||||
public function action_view() {
|
||||
$po = ORM::factory('Product',$this->request->param('id'));
|
||||
|
||||
Block::add(array(
|
||||
'title'=>sprintf('%s: %s',_('Current Services Using this Product'),$po->name()),
|
||||
'body'=>Table::display(
|
||||
ORM::factory('Service')->where('product_id','=',$po->id)->find_all(),
|
||||
Block::factory()
|
||||
->title(sprintf('%s: %s',_('Current Services Using this Product'),$po->title()))
|
||||
->title_icon('icon-th-list')
|
||||
->body(Table::display(
|
||||
$po->services()->find_all(),
|
||||
25,
|
||||
array(
|
||||
'id'=>array('label'=>'ID','url'=>URL::link('user','service/view/')),
|
||||
'account->accnum()'=>array(),
|
||||
'account->name()'=>array('label'=>'Account'),
|
||||
'name()'=>array('label'=>'Details'),
|
||||
'status'=>array('label'=>'Active'),
|
||||
'status(TRUE)'=>array('label'=>'Active'),
|
||||
'price(TRUE,TRUE)'=>array('label'=>'Price','align'=>'right'),
|
||||
),
|
||||
array(
|
||||
'page'=>TRUE,
|
||||
'type'=>'select',
|
||||
'form'=>URL::link('user','service/view'),
|
||||
)),
|
||||
));
|
||||
)));
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
@@ -12,26 +12,6 @@
|
||||
class Controller_Product extends Controller_TemplateDefault {
|
||||
protected $auth_required = FALSE;
|
||||
|
||||
/**
|
||||
* Show a list of product categories
|
||||
*/
|
||||
public function action_categorys() {
|
||||
$output = '<div id="category">';
|
||||
$output .= '<ul>';
|
||||
|
||||
foreach (ORM::factory('Product_Category')->list_active() as $pco) {
|
||||
$a = '<h3>'.$pco->display('name').'</h3>';
|
||||
$a .= '<p>'.$pco->description().'</p>';
|
||||
|
||||
$output .= '<li>'.HTML::anchor('product/category/'.$pco->id,$a).'</li>';
|
||||
}
|
||||
|
||||
$output .= '</ul>';
|
||||
$output .= '</div>';
|
||||
|
||||
$this->template->content = $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the available topics in a category
|
||||
*
|
||||
@@ -43,29 +23,15 @@ class Controller_Product extends Controller_TemplateDefault {
|
||||
|
||||
$pco = ORM::factory('Product_Category',$this->request->param('id'));
|
||||
|
||||
if (! $pco->loaded())
|
||||
// Only show categories that are active.
|
||||
if (! $pco->loaded() OR ((! $pco->status AND ! Kohana::$config->load('debug')->show_inactive)))
|
||||
HTTP::redirect('welcome/index');
|
||||
|
||||
if (! $pco->status AND ! Kohana::$config->load('debug')->show_inactive)
|
||||
HTTP::redirect('welcome/index');
|
||||
Style::factory()
|
||||
->type('file')
|
||||
->data('media/css/pages/welcome.css');
|
||||
|
||||
BreadCrumb::name($this->request->uri(),$pco->name);
|
||||
BreadCrumb::url('product','product/categorys');
|
||||
BreadCrumb::url('product/category','product/categorys');
|
||||
|
||||
foreach ($pco->products() as $po)
|
||||
$output .= View::factory($this->viewpath().'/list_item')
|
||||
->set('co',$pco)
|
||||
->set('o',$po);
|
||||
|
||||
// If our output is blank, then there are no products
|
||||
if (! $output)
|
||||
$output = _('Sorry, no pages were found in this category, or your account is not authorized for this category.');
|
||||
|
||||
Block::add(array(
|
||||
'title'=>sprintf('%s: %s',_('Category'),$pco->name),
|
||||
'body'=>$output,
|
||||
));
|
||||
return $this->template->content = (string)$pco->template();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -77,28 +43,14 @@ class Controller_Product extends Controller_TemplateDefault {
|
||||
$po = ORM::factory('Product',$id);
|
||||
|
||||
if (! $po->loaded())
|
||||
HTTP::redirect('Product_Category/index');
|
||||
HTTP::redirect('welcome/index');
|
||||
|
||||
BreadCrumb::name($this->request->uri(),$po->product_translate->find()->name);
|
||||
BreadCrumb::url('product','product/categorys');
|
||||
// @todo This breadcrumb may not be working anymore.
|
||||
#BreadCrumb::name($this->request->uri(),$po->product_translate->find()->name);
|
||||
#BreadCrumb::url('product','product/categorys');
|
||||
|
||||
// Work out our category id for the control line
|
||||
if (! empty($_GET['cid'])) {
|
||||
$co = ORM::factory('Product_Category',$_GET['cid']);
|
||||
|
||||
// If the product category doesnt exist, or doesnt match the product
|
||||
if (! $co->loaded() OR ! in_array($co->id,$po->avail_category))
|
||||
HTTP::redirect('Product_Category/index');
|
||||
|
||||
BreadCrumb::name('product/view',$co->name);
|
||||
BreadCrumb::url('product/view','product/category/'.$co->id);
|
||||
}
|
||||
|
||||
Block::add(array(
|
||||
'title'=>$po->description_short(),
|
||||
'body'=>View::factory($this->viewpath())
|
||||
->set('record',$po),
|
||||
));
|
||||
$this->template->content = (string)View::factory('product/view')
|
||||
->set('o',$po);
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
@@ -1,39 +0,0 @@
|
||||
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||
|
||||
/**
|
||||
* This class provides product categories
|
||||
*
|
||||
* @package Product
|
||||
* @category Controllers
|
||||
* @author Deon George
|
||||
* @copyright (c) 2009-2013 Open Source Billing
|
||||
* @license http://dev.osbill.net/license.html
|
||||
*/
|
||||
class Controller_Product_Category extends Controller_TemplateDefault {
|
||||
/**
|
||||
* By default show a menu of available categories
|
||||
*/
|
||||
public function action_index() {
|
||||
HTTP::redirect('product_category/list');
|
||||
}
|
||||
|
||||
public function action_list() {
|
||||
Block::add(array(
|
||||
'title'=>_('Product Categories'),
|
||||
'body'=>View::factory('product/category/list')
|
||||
->set('results',$this->_get_categories()),
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtain a list of our categories
|
||||
* @todo Only show categories according to the users group memeberhsip
|
||||
* @todo Obey sort order
|
||||
* @todo Move this to the model
|
||||
*/
|
||||
private function _get_categories() {
|
||||
return ORM::factory('Product_Category')
|
||||
->list_active();
|
||||
}
|
||||
}
|
||||
?>
|
@@ -26,16 +26,20 @@ class Model_Product extends ORM_OSB {
|
||||
|
||||
protected $_display_filters = array(
|
||||
'price_type'=>array(
|
||||
array('StaticList_PriceType::display',array(':value')),
|
||||
array('StaticList_PriceType::get',array(':value')),
|
||||
),
|
||||
'status'=>array(
|
||||
array('StaticList_YesNo::display',array(':value')),
|
||||
array('StaticList_YesNo::get',array(':value')),
|
||||
),
|
||||
'taxable'=>array(
|
||||
array('StaticList_YesNo::display',array(':value')),
|
||||
array('StaticList_YesNo::get',array(':value')),
|
||||
),
|
||||
);
|
||||
|
||||
protected $_nullifempty = array(
|
||||
'price_group',
|
||||
);
|
||||
|
||||
// Our attributes that are arrays, we'll convert/unconvert them
|
||||
protected $_serialize_column = array(
|
||||
'avail_category',
|
||||
@@ -43,41 +47,12 @@ class Model_Product extends ORM_OSB {
|
||||
);
|
||||
|
||||
/**
|
||||
* Which categories is this product available in
|
||||
* Return the translated description for a category.
|
||||
*/
|
||||
public function categories() {
|
||||
return $this->avail_category;
|
||||
}
|
||||
public function description($full=FALSE) {
|
||||
$x = $this->translate();
|
||||
|
||||
/**
|
||||
* Get the product description, after translating
|
||||
* @todo This needs to be improved to find the right language item.
|
||||
*/
|
||||
public function description_long() {
|
||||
return $this->product_translate->find()->display('description_full');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the product description, after translating
|
||||
* @todo This needs to be improved to find the right language item.
|
||||
*/
|
||||
public function description_short() {
|
||||
return $this->product_translate->find()->display('description_short');
|
||||
}
|
||||
|
||||
/**
|
||||
* This will render the product feature summary information
|
||||
*/
|
||||
public function feature_summary() {
|
||||
return (is_null($plugin = $this->plugin())) ? HTML::nbsp('') : $plugin->feature_summary();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the product name, after translating
|
||||
* @todo This needs to be improved to find the right language item.
|
||||
*/
|
||||
public function name() {
|
||||
return $this->product_translate->find()->display('name');
|
||||
return $x->loaded() ? $x->display($full ? 'description_full' : 'description_short') : 'No Description';
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -93,6 +68,66 @@ class Model_Product extends ORM_OSB {
|
||||
return ORM::factory(Kohana::classname(sprintf('Product_Plugin_%s',$this->prod_plugin_file)),$this->prod_plugin_data);
|
||||
}
|
||||
|
||||
public function save(Validation $validation=NULL) {
|
||||
if ($this->changed())
|
||||
if (parent::save($validation))
|
||||
SystemMessage::factory()
|
||||
->title('Record Updated')
|
||||
->type('success')
|
||||
->body(sprintf('Record %s Updated',$this->id));
|
||||
|
||||
// Save our Translated Message
|
||||
if ($x = array_diff_key($_POST,$this->_object) AND ! empty($_POST['language_id']) AND ! empty($_POST['product_translate']) AND is_array($_POST['product_translate'])) {
|
||||
$pto = $this->product_translate->where('language_id','=',$_POST['language_id'])->find();
|
||||
|
||||
// For a new entry, we need to set the product_cat_id
|
||||
if (! $pto->loaded()) {
|
||||
$pto->product_cat_id = $this->id;
|
||||
$pto->language_id = $_POST['language_id'];
|
||||
}
|
||||
|
||||
if ($pto->values($x['product_translate'])->save())
|
||||
SystemMessage::factory()
|
||||
->title('Record Updated')
|
||||
->type('success')
|
||||
->body(sprintf('Translation for Record %s Updated',$this->id));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* List the services that are linked to this product
|
||||
*/
|
||||
public function services($active=FALSE) {
|
||||
return $active ? $this->service->where_active() : $this->service;
|
||||
}
|
||||
|
||||
private function translate() {
|
||||
return $this->product_translate->where('language_id','=',Config::language())->find();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the translated title for a category
|
||||
*/
|
||||
public function title() {
|
||||
$x = $this->translate();
|
||||
|
||||
return $x->loaded() ? $x->display('name') : 'No Title';
|
||||
}
|
||||
|
||||
/**
|
||||
* Which categories is this product available in
|
||||
*/
|
||||
public function categories() {
|
||||
return $this->avail_category;
|
||||
}
|
||||
|
||||
/**
|
||||
* This will render the product feature summary information
|
||||
*/
|
||||
public function feature_summary() {
|
||||
return (is_null($plugin = $this->plugin())) ? HTML::nbsp('') : $plugin->feature_summary();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the best price to the uesr based on the users group's memberships
|
||||
* @todo This needs to be tested with more than one price group enabled
|
||||
|
@@ -11,27 +11,30 @@
|
||||
*/
|
||||
class Model_Product_Category extends ORM_OSB {
|
||||
protected $_table_name = 'product_cat';
|
||||
protected $_created_column = FALSE;
|
||||
protected $_updated_column = FALSE;
|
||||
|
||||
protected $_nullifempty = array(
|
||||
'status',
|
||||
'template',
|
||||
);
|
||||
|
||||
protected $_has_many = array(
|
||||
'product_category_translate'=>array('foreign_key'=>'product_cat_id','far_key'=>'id'),
|
||||
'subcategories'=>array('model'=>'product_category','foreign_key'=>'parent_id','far_key'=>'id'),
|
||||
);
|
||||
|
||||
protected $_sorting = array(
|
||||
'name'=>'asc',
|
||||
);
|
||||
|
||||
/**
|
||||
* Return the translated description for a category.
|
||||
*/
|
||||
public function description() {
|
||||
// If the user is not logged in, show the site default language
|
||||
// @todo This needs to change to the session language.
|
||||
if (! $ao=Auth::instance()->get_user())
|
||||
$ao=Company::instance()->so();
|
||||
$x = $this->translate();
|
||||
|
||||
return ($x=$this->product_category_translate->where('language_id','=',$ao->language_id)->find()->description) ? $x : _('No Description');
|
||||
return $x->loaded() ? $x->display('description') : 'No Description';
|
||||
}
|
||||
|
||||
/**
|
||||
* List all the products belonging to this cateogry
|
||||
* @todo Consider if we should cache this
|
||||
*/
|
||||
public function products() {
|
||||
$result = array();
|
||||
@@ -43,13 +46,68 @@ class Model_Product_Category extends ORM_OSB {
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function list_bylistgroup($cat) {
|
||||
$result = array();
|
||||
public function save(Validation $validation=NULL) {
|
||||
if ($this->changed())
|
||||
if (parent::save($validation))
|
||||
SystemMessage::factory()
|
||||
->title('Record Updated')
|
||||
->type('success')
|
||||
->body(sprintf('Record %s Updated',$this->id));
|
||||
|
||||
foreach ($this->where('list_group','=',$cat)->find_all() as $pco)
|
||||
$result[$pco->id] = $pco;
|
||||
// Save our Translated Message
|
||||
if ($x = array_diff_key($_POST,$this->_object) AND ! empty($_POST['language_id']) AND ! empty($_POST['product_category_translate']) AND is_array($_POST['product_category_translate'])) {
|
||||
$pcto = $this->product_category_translate->where('language_id','=',$_POST['language_id'])->find();
|
||||
|
||||
// For a new entry, we need to set the product_cat_id
|
||||
if (! $pcto->loaded()) {
|
||||
$pcto->product_cat_id = $this->id;
|
||||
$pcto->language_id = $_POST['language_id'];
|
||||
}
|
||||
|
||||
if ($pcto->values($x['product_category_translate'])->save())
|
||||
SystemMessage::factory()
|
||||
->title('Record Updated')
|
||||
->type('success')
|
||||
->body(sprintf('Translation for Record %s Updated',$this->id));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the template that is used to render the product category
|
||||
*/
|
||||
public function template() {
|
||||
if (! $this->template)
|
||||
throw new Kohana_Exception('Product category :category doesnt have a template',array(':category'=>$this->id));
|
||||
|
||||
$o = Kohana::classname('Product_Category_Template_'.$this->template);
|
||||
|
||||
return new $o($this);
|
||||
}
|
||||
|
||||
public function templates() {
|
||||
$template_path = 'classes/Product/Category/Template';
|
||||
$result = array('');
|
||||
|
||||
foreach (Kohana::list_files($template_path) as $file => $path) {
|
||||
$file = strtoupper(preg_replace('/.php$/','',str_replace($template_path.'/','',$file)));
|
||||
$result[$file] = $file;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the translated title for a category
|
||||
*/
|
||||
public function title() {
|
||||
$x = $this->translate();
|
||||
|
||||
return $x->loaded() ? $x->display('name') : 'No Title';
|
||||
}
|
||||
|
||||
|
||||
private function translate() {
|
||||
return $this->product_category_translate->where('language_id','=',Config::language())->find();
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
@@ -11,6 +11,8 @@
|
||||
*/
|
||||
class Model_Product_Category_Translate extends ORM_OSB {
|
||||
protected $_table_name = 'product_cat_translate';
|
||||
protected $_created_column = FALSE;
|
||||
protected $_updated_column = FALSE;
|
||||
|
||||
protected $_belongs_to = array(
|
||||
'product_category'=>array(),
|
||||
|
25
modules/product/classes/Product/Category/Template.php
Normal file
25
modules/product/classes/Product/Category/Template.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||
|
||||
/**
|
||||
* This class provides the rendering of Product Category Templates
|
||||
*
|
||||
* @package Product
|
||||
* @category Helper
|
||||
* @author Deon George
|
||||
* @copyright (c) 2009-2013 Open Source Billing
|
||||
* @license http://dev.osbill.net/license.html
|
||||
*/
|
||||
abstract class Product_Category_Template {
|
||||
protected $pco = NULL;
|
||||
|
||||
abstract protected function render();
|
||||
|
||||
public function __construct(Model_Product_Category $pco) {
|
||||
$this->pco = $pco;
|
||||
}
|
||||
|
||||
public function __toString() {
|
||||
return (string)$this->render();
|
||||
}
|
||||
}
|
||||
?>
|
@@ -0,0 +1,20 @@
|
||||
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||
|
||||
/**
|
||||
* This class provides the rendering of Product Category Template Super Category
|
||||
*
|
||||
* This Template renders sub categories of the same type.
|
||||
*
|
||||
* @package Product
|
||||
* @category Helper
|
||||
* @author Deon George
|
||||
* @copyright (c) 2009-2013 Open Source Billing
|
||||
* @license http://dev.osbill.net/license.html
|
||||
*/
|
||||
class Product_Category_Template_Supercat extends Product_Category_Template {
|
||||
protected function render() {
|
||||
return View::factory('product/category/list/supercat')
|
||||
->set('o',$this->pco);
|
||||
}
|
||||
}
|
||||
?>
|
Reference in New Issue
Block a user