'."\n";
- $out.= $langs->trans('SelectMailModel').': ';
+ $out.= $langs->trans('SelectMailModel').': '; // Do not put disabled on option, it is already on select and it makes chrome crazy.
if ($user->admin) $out.= info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1);
$out.= ' ';
$out.= '';
@@ -770,9 +770,10 @@ function get_form($addfileaction='addfile',$removefileaction='removefile')
* @param string $user Use template public or limited to this user
* @param Translate $outputlangs Output lang object
* @param int $id Id template to find
+ * @param int $active 1=Only active template, 0=Only disabled, -1=All
* @return array array('topic'=>,'content'=>,..)
*/
- private function getEMailTemplate($db, $type_template, $user, $outputlangs,$id=0)
+ private function getEMailTemplate($db, $type_template, $user, $outputlangs, $id=0, $active=1)
{
$ret=array();
@@ -781,6 +782,7 @@ private function getEMailTemplate($db, $type_template, $user, $outputlangs,$id=0
$sql.= " WHERE type_template='".$db->escape($type_template)."'";
$sql.= " AND entity IN (".getEntity("c_email_templates").")";
$sql.= " AND (fk_user is NULL or fk_user = 0 or fk_user = ".$user->id.")";
+ if ($active >= 0) $sql.=" AND active = ".$active;
if (is_object($outputlangs)) $sql.= " AND (lang = '".$outputlangs->defaultlang."' OR lang IS NULL OR lang = '')";
if (!empty($id)) $sql.= " AND rowid=".$id;
$sql.= $db->order("lang,label","ASC");
@@ -870,9 +872,10 @@ public function isEMailTemplate($type_template, $user, $outputlangs)
* @param string $type_template Get message for key module
* @param string $user Use template public or limited to this user
* @param Translate $outputlangs Output lang object
- * @return int <0 if KO,
+ * @param int $active 1=Only active template, 0=Only disabled, -1=All
+ * @return int <0 if KO, nb of records found if OK
*/
- public function fetchAllEMailTemplate($type_template, $user, $outputlangs)
+ public function fetchAllEMailTemplate($type_template, $user, $outputlangs, $active=1)
{
$ret=array();
@@ -881,6 +884,7 @@ public function fetchAllEMailTemplate($type_template, $user, $outputlangs)
$sql.= " WHERE type_template='".$this->db->escape($type_template)."'";
$sql.= " AND entity IN (".getEntity("c_email_templates").")";
$sql.= " AND (fk_user is NULL or fk_user = 0 or fk_user = ".$user->id.")";
+ if ($active >= 0) $sql.=" AND active = ".$active;
if (is_object($outputlangs)) $sql.= " AND (lang = '".$outputlangs->defaultlang."' OR lang IS NULL OR lang = '')";
$sql.= $this->db->order("position,lang,label","ASC");
//print $sql;