Work on Email and other major consistency work
This commit is contained in:
@@ -14,9 +14,9 @@
|
||||
*/
|
||||
class Model_Product extends ORM_OSB {
|
||||
protected $_has_many = array(
|
||||
'product_translate'=>array('far_key'=>'id'),
|
||||
'service'=>array('far_key'=>'id'),
|
||||
'invoice'=>array('through'=>'invoice_item'),
|
||||
'service'=>array('far_key'=>'id'),
|
||||
'translate'=>array('model'=>'Product_Translate','far_key'=>'id'),
|
||||
);
|
||||
|
||||
protected $_sorting = array(
|
||||
@@ -44,6 +44,8 @@ class Model_Product extends ORM_OSB {
|
||||
'price_group',
|
||||
);
|
||||
|
||||
protected $_save_message = TRUE;
|
||||
|
||||
/**
|
||||
* Which categories is this product available in
|
||||
*/
|
||||
@@ -106,29 +108,22 @@ class Model_Product extends ORM_OSB {
|
||||
}
|
||||
|
||||
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));
|
||||
parent::save($validation);
|
||||
|
||||
// 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();
|
||||
if ($x = array_diff_key($_POST,$this->_object) AND ! empty($_POST['language_id']) AND ! empty($_POST['translate']) AND is_array($_POST['translate'])) {
|
||||
$to = $this->translate->where('language_id','=',$_POST['language_id'])->find();
|
||||
|
||||
// For a new entry, we need to set the product_id
|
||||
if (! $pto->loaded()) {
|
||||
$pto->product_id = $this->id;
|
||||
$pto->language_id = $_POST['language_id'];
|
||||
if (! $to->loaded()) {
|
||||
$to->product_id = $this->id;
|
||||
$to->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));
|
||||
$to->values($x['translate'])->save();
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -143,7 +138,7 @@ class Model_Product extends ORM_OSB {
|
||||
}
|
||||
|
||||
private function translate() {
|
||||
return $this->product_translate->where('language_id','=',Config::language())->find();
|
||||
return $this->translate->where('language_id','=',Config::language())->find();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -20,14 +20,16 @@ class Model_Product_Category extends ORM_OSB {
|
||||
);
|
||||
|
||||
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'),
|
||||
'translate'=>array('model'=>'Product_Category_Translate','foreign_key'=>'product_cat_id','far_key'=>'id'),
|
||||
);
|
||||
|
||||
protected $_sorting = array(
|
||||
'position'=>'ASC',
|
||||
);
|
||||
|
||||
protected $_save_message = TRUE;
|
||||
|
||||
/**
|
||||
* Return the translated description for a category.
|
||||
*/
|
||||
@@ -51,29 +53,22 @@ class Model_Product_Category extends ORM_OSB {
|
||||
}
|
||||
|
||||
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));
|
||||
parent::save($validation);
|
||||
|
||||
// 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();
|
||||
if ($x = array_diff_key($_POST,$this->_object) AND ! empty($_POST['language_id']) AND ! empty($_POST['translate']) AND is_array($_POST['translate'])) {
|
||||
$to = $this->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 (! $to->loaded()) {
|
||||
$to->product_cat_id = $this->id;
|
||||
$to->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));
|
||||
$to->values($x['translate'])->save();
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -111,7 +106,7 @@ class Model_Product_Category extends ORM_OSB {
|
||||
|
||||
|
||||
private function translate() {
|
||||
return $this->product_category_translate->where('language_id','=',Config::language())->find();
|
||||
return $this->translate->where('language_id','=',Config::language())->find();
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
@@ -17,5 +17,7 @@ class Model_Product_Category_Translate extends ORM_OSB {
|
||||
protected $_belongs_to = array(
|
||||
'product_category'=>array(),
|
||||
);
|
||||
|
||||
protected $_save_message = TRUE;
|
||||
}
|
||||
?>
|
||||
|
@@ -16,5 +16,7 @@ class Model_Product_Translate extends ORM_OSB {
|
||||
protected $_belongs_to = array(
|
||||
'product'=>array(),
|
||||
);
|
||||
|
||||
protected $_save_message = TRUE;
|
||||
}
|
||||
?>
|
||||
|
Reference in New Issue
Block a user