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:
Deon George
2013-04-26 11:42:09 +10:00
parent eeb8d61237
commit 04ebda2aaa
114 changed files with 1732 additions and 6797 deletions

View File

@@ -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

View File

@@ -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();
}
}
?>

View File

@@ -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(),