2013-10-10 02:44:53 +00:00
|
|
|
<?php defined('SYSPATH') or die('No direct access allowed.');
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @package Email
|
|
|
|
* @category Models
|
|
|
|
* @author Deon George
|
|
|
|
* @copyright (c) 2009-2013 Open Source Billing
|
|
|
|
* @license http://dev.osbill.net/license.html
|
|
|
|
*/
|
2016-08-15 11:23:18 +00:00
|
|
|
class Model_Email_Template extends ORM {
|
2013-10-10 02:44:53 +00:00
|
|
|
protected $_has_many = array(
|
2013-11-22 04:36:50 +00:00
|
|
|
'translate'=>array('model'=>'Email_Template_Translate','foreign_key'=>'email_template_id','far_key'=>'id'),
|
2013-10-10 02:44:53 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
// This module doesnt keep track of column updates automatically
|
|
|
|
protected $_created_column = FALSE;
|
|
|
|
protected $_updated_column = FALSE;
|
|
|
|
|
|
|
|
protected $_sorting = array(
|
|
|
|
'name'=>'ASC',
|
|
|
|
);
|
|
|
|
|
|
|
|
protected $_display_filters = array(
|
2016-08-31 05:03:09 +00:00
|
|
|
'active'=>array(
|
2013-11-14 11:50:35 +00:00
|
|
|
array('StaticList_YesNo::get',array(':value',TRUE)),
|
2013-10-10 02:44:53 +00:00
|
|
|
),
|
|
|
|
);
|
2013-10-28 23:41:14 +00:00
|
|
|
|
2013-11-22 04:36:50 +00:00
|
|
|
protected $_save_message = TRUE;
|
|
|
|
|
2016-08-03 04:00:51 +00:00
|
|
|
public function name($variable=NULL) {
|
2013-10-28 23:41:14 +00:00
|
|
|
return ! is_null($this->description) ? $this->description : $this->name;
|
|
|
|
}
|
2013-11-22 04:36:50 +00:00
|
|
|
|
|
|
|
public function save(Validation $validation=NULL) {
|
|
|
|
parent::save();
|
|
|
|
|
|
|
|
// Save our Translated Message
|
2016-08-10 06:07:00 +00:00
|
|
|
if ($x = array_diff_key($_POST,$this->_object) AND Arr::get($_POST,'language_id') AND is_array(Arr::get($_POST,'translate'))) {
|
2016-08-03 06:20:25 +00:00
|
|
|
$to = $this->translate->where('language_id','=',Arr::get($_POST,'language_id'))->find();
|
2013-11-22 04:36:50 +00:00
|
|
|
|
|
|
|
// For a new entry, we need to set the product_id
|
|
|
|
if (! $to->loaded()) {
|
|
|
|
$to->product_id = $this->id;
|
2016-08-03 06:20:25 +00:00
|
|
|
$to->language_id = Arr::get($_POST,'language_id');
|
2013-11-22 04:36:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
$to->values($x['translate'])->save();
|
|
|
|
}
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
2013-10-10 02:44:53 +00:00
|
|
|
}
|
|
|
|
?>
|